Home | History | Annotate | Download | only in anritsu_lib
      1 #!/usr/bin/env python3.4
      2 #
      3 #   Copyright 2016 - The Android Open Source Project
      4 #
      5 #   Licensed under the Apache License, Version 2.0 (the "License");
      6 #   you may not use this file except in compliance with the License.
      7 #   You may obtain a copy of the License at
      8 #
      9 #       http://www.apache.org/licenses/LICENSE-2.0
     10 #
     11 #   Unless required by applicable law or agreed to in writing, software
     12 #   distributed under the License is distributed on an "AS IS" BASIS,
     13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14 #   See the License for the specific language governing permissions and
     15 #   limitations under the License.
     16 """
     17 Controller interface for Anritsu Signalling Tester MD8475A.
     18 """
     19 
     20 import time
     21 import socket
     22 from enum import Enum
     23 from enum import IntEnum
     24 
     25 from acts.controllers.anritsu_lib._anritsu_utils import AnritsuError
     26 from acts.controllers.anritsu_lib._anritsu_utils import AnritsuUtils
     27 from acts.controllers.anritsu_lib._anritsu_utils import NO_ERROR
     28 from acts.controllers.anritsu_lib._anritsu_utils import OPERATION_COMPLETE
     29 
     30 TERMINATOR = "\0"
     31 # The following wait times (except COMMUNICATION_STATE_WAIT_TIME) are actually
     32 # the times for socket to time out. Increasing them is to make sure there is
     33 # enough time for MD8475A operation to be completed in some cases.
     34 # It won't increase test execution time.
     35 SMARTSTUDIO_LAUNCH_WAIT_TIME = 300  # was 90
     36 SMARTSTUDIO_SIMULATION_START_WAIT_TIME = 300  # was 120
     37 REGISTRATION_STATE_WAIT_TIME = 240
     38 LOAD_SIMULATION_PARAM_FILE_WAIT_TIME = 30
     39 COMMUNICATION_STATE_WAIT_TIME = 240
     40 ANRITSU_SOCKET_BUFFER_SIZE = 8192
     41 COMMAND_COMPLETE_WAIT_TIME = 180  # was 90
     42 SETTLING_TIME = 1
     43 WAIT_TIME_IDENTITY_RESPONSE = 5
     44 
     45 IMSI_READ_USERDATA_WCDMA = "081501"
     46 IMEI_READ_USERDATA_WCDMA = "081502"
     47 IMEISV_READ_USERDATA_WCDMA = "081503"
     48 IMSI_READ_USERDATA_LTE = "075501"
     49 IMEI_READ_USERDATA_LTE = "075502"
     50 IMEISV_READ_USERDATA_LTE = "075503"
     51 IMSI_READ_USERDATA_GSM = "081501"
     52 IMEI_READ_USERDATA_GSM = "081502"
     53 IMEISV_READ_USERDATA_GSM = "081503"
     54 IDENTITY_REQ_DATA_LEN = 24
     55 SEQ_LOG_MESSAGE_START_INDEX = 60
     56 
     57 WCDMA_BANDS = {
     58     "I": "1",
     59     "II": "2",
     60     "III": "3",
     61     "IV": "4",
     62     "V": "5",
     63     "VI": "6",
     64     "VII": "7",
     65     "VIII": "8",
     66     "IX": "9",
     67     "X": "10",
     68     "XI": "11",
     69     "XII": "12",
     70     "XIII": "13",
     71     "XIV": "14"
     72 }
     73 
     74 
     75 def create(configs, logger):
     76     objs = []
     77     for c in configs:
     78         ip_address = c["ip_address"]
     79         objs.append(MD8475A(ip_address, logger))
     80     return objs
     81 
     82 
     83 def destroy(objs):
     84     return
     85 
     86 
     87 class ProcessingStatus(Enum):
     88     ''' MD8475A processing status for UE,Packet,Voice,Video,SMS,
     89         PPP, PWS '''
     90     PROCESS_STATUS_NONE = "NONE"
     91     PROCESS_STATUS_NOTRUN = "NOTRUN"
     92     PROCESS_STATUS_POWEROFF = "POWEROFF"
     93     PROCESS_STATUS_REGISTRATION = "REGISTRATION"
     94     PROCESS_STATUS_DETACH = "DETACH"
     95     PROCESS_STATUS_IDLE = "IDLE"
     96     PROCESS_STATUS_ORIGINATION = "ORIGINATION"
     97     PROCESS_STATUS_HANDOVER = "HANDOVER"
     98     PROCESS_STATUS_UPDATING = "UPDATING"
     99     PROCESS_STATUS_TERMINATION = "TERMINATION"
    100     PROCESS_STATUS_COMMUNICATION = "COMMUNICATION"
    101     PROCESS_STATUS_UERELEASE = "UERELEASE"
    102     PROCESS_STATUS_NWRELEASE = "NWRELEASE"
    103 
    104 
    105 class BtsNumber(Enum):
    106     '''ID number for MD8475A supported BTS '''
    107     BTS1 = "BTS1"
    108     BTS2 = "BTS2"
    109     BTS3 = "BTS3"
    110     BTS4 = "BTS4"
    111 
    112 
    113 class BtsTechnology(Enum):
    114     ''' BTS system technology'''
    115     LTE = "LTE"
    116     WCDMA = "WCDMA"
    117     TDSCDMA = "TDSCDMA"
    118     GSM = "GSM"
    119     CDMA1X = "CDMA1X"
    120     EVDO = "EVDO"
    121 
    122 
    123 class BtsBandwidth(Enum):
    124     ''' Values for Cell Bandwidth '''
    125     LTE_BANDWIDTH_1dot4MHz = "1.4MHz"
    126     LTE_BANDWIDTH_3MHz = "3MHz"
    127     LTE_BANDWIDTH_5MHz = "5MHz"
    128     LTE_BANDWIDTH_10MHz = "10MHz"
    129     LTE_BANDWIDTH_15MHz = "15MHz"
    130     LTE_BANDWIDTH_20MHz = "20MHz"
    131 
    132 
    133 class BtsPacketRate(Enum):
    134     ''' Values for Cell Packet rate '''
    135     LTE_MANUAL = "MANUAL"
    136     LTE_BESTEFFORT = "BESTEFFORT"
    137     WCDMA_DLHSAUTO_REL7_UL384K = "DLHSAUTO_REL7_UL384K"
    138     WCDMA_DL18_0M_UL384K = "DL18_0M_UL384K"
    139     WCDMA_DL21_6M_UL384K = "DL21_6M_UL384K"
    140     WCDMA_DLHSAUTO_REL7_ULHSAUTO = "DLHSAUTO_REL7_ULHSAUTO"
    141     WCDMA_DL18_0M_UL1_46M = "DL18_0M_UL1_46M"
    142     WCDMA_DL18_0M_UL2_0M = "DL18_0M_UL2_0M"
    143     WCDMA_DL18_0M_UL5_76M = "DL18_0M_UL5_76M"
    144     WCDMA_DL21_6M_UL1_46M = "DL21_6M_UL1_46M"
    145     WCDMA_DL21_6M_UL2_0M = "DL21_6M_UL2_0M"
    146     WCDMA_DL21_6M_UL5_76M = "DL21_6M_UL5_76M"
    147     WCDMA_DLHSAUTO_REL8_UL384K = "DLHSAUTO_REL8_UL384K"
    148     WCDMA_DL23_4M_UL384K = "DL23_4M_UL384K"
    149     WCDMA_DL28_0M_UL384K = "DL28_0M_UL384K"
    150     WCDMA_DL36_0M_UL384K = "DL36_0M_UL384K"
    151     WCDMA_DL43_2M_UL384K = "DL43_2M_UL384K"
    152     WCDMA_DLHSAUTO_REL8_ULHSAUTO = "DLHSAUTO_REL8_ULHSAUTO"
    153     WCDMA_DL23_4M_UL1_46M = "DL23_4M_UL1_46M"
    154     WCDMA_DL23_4M_UL2_0M = "DL23_4M_UL2_0M"
    155     WCDMA_DL23_4M_UL5_76M = "DL23_4M_UL5_76M"
    156     WCDMA_DL28_0M_UL1_46M = "DL28_0M_UL1_46M"
    157     WCDMA_DL28_0M_UL2_0M = "DL28_0M_UL2_0M"
    158     WCDMA_DL28_0M_UL5_76M = "L28_0M_UL5_76M"
    159     WCDMA_DL36_0M_UL1_46M = "DL36_0M_UL1_46M"
    160     WCDMA_DL36_0M_UL2_0M = "DL36_0M_UL2_0M"
    161     WCDMA_DL36_0M_UL5_76M = "DL36_0M_UL5_76M"
    162     WCDMA_DL43_2M_UL1_46M = "DL43_2M_UL1_46M"
    163     WCDMA_DL43_2M_UL2_0M = "DL43_2M_UL2_0M"
    164     WCDMA_DL43_2M_UL5_76M = "L43_2M_UL5_76M"
    165 
    166 
    167 class BtsPacketWindowSize(Enum):
    168     ''' Values for Cell Packet window size '''
    169     WINDOW_SIZE_1 = 1
    170     WINDOW_SIZE_8 = 8
    171     WINDOW_SIZE_16 = 16
    172     WINDOW_SIZE_32 = 32
    173     WINDOW_SIZE_64 = 64
    174     WINDOW_SIZE_128 = 128
    175     WINDOW_SIZE_256 = 256
    176     WINDOW_SIZE_512 = 512
    177     WINDOW_SIZE_768 = 768
    178     WINDOW_SIZE_1024 = 1024
    179     WINDOW_SIZE_1536 = 1536
    180     WINDOW_SIZE_2047 = 2047
    181 
    182 
    183 class BtsServiceState(Enum):
    184     ''' Values for BTS service state '''
    185     SERVICE_STATE_IN = "IN"
    186     SERVICE_STATE_OUT = "OUT"
    187 
    188 
    189 class BtsCellBarred(Enum):
    190     ''' Values for Cell barred parameter '''
    191     NOTBARRED = "NOTBARRED"
    192     BARRED = "BARRED"
    193 
    194 
    195 class BtsAccessClassBarred(Enum):
    196     ''' Values for Access class barred parameter '''
    197     NOTBARRED = "NOTBARRED"
    198     EMERGENCY = "EMERGENCY"
    199     BARRED = "BARRED"
    200     USERSPECIFIC = "USERSPECIFIC"
    201 
    202 
    203 class BtsLteEmergencyAccessClassBarred(Enum):
    204     ''' Values for Lte emergency access class barred parameter '''
    205     NOTBARRED = "NOTBARRED"
    206     BARRED = "BARRED"
    207 
    208 
    209 class BtsNwNameEnable(Enum):
    210     ''' Values for BT network name enable parameter '''
    211     NAME_ENABLE = "ON"
    212     NAME_DISABLE = "OFF"
    213 
    214 
    215 class IPAddressType(Enum):
    216     ''' Values for IP address type '''
    217     IPV4 = "IPV4"
    218     IPV6 = "IPV6"
    219     IPV4V6 = "IPV4V6"
    220 
    221 
    222 class TriggerMessageIDs(Enum):
    223     ''' ID for Trigger messages  '''
    224     RRC_CONNECTION_REQ = 111101
    225     RRC_CONN_REESTABLISH_REQ = 111100
    226     ATTACH_REQ = 141141
    227     DETACH_REQ = 141145
    228     MM_LOC_UPDATE_REQ = 221108
    229     GMM_ATTACH_REQ = 241101
    230     GMM_RA_UPDATE_REQ = 241108
    231     IDENTITY_REQUEST_LTE = 141155
    232     IDENTITY_REQUEST_WCDMA = 241115
    233     IDENTITY_REQUEST_GSM = 641115
    234 
    235 
    236 class TriggerMessageReply(Enum):
    237     ''' Values for Trigger message reply parameter '''
    238     ACCEPT = "ACCEPT"
    239     REJECT = "REJECT"
    240     IGNORE = "IGNORE"
    241     NONE = "NONE"
    242     ILLEGAL = "ILLEGAL"
    243 
    244 
    245 class TestProcedure(Enum):
    246     ''' Values for different Test procedures in MD8475A '''
    247     PROCEDURE_BL = "BL"
    248     PROCEDURE_SELECTION = "SELECTION"
    249     PROCEDURE_RESELECTION = "RESELECTION"
    250     PROCEDURE_REDIRECTION = "REDIRECTION"
    251     PROCEDURE_HO = "HO"
    252     PROCEDURE_HHO = "HHO"
    253     PROCEDURE_SHO = "SHO"
    254     PROCEDURE_MEASUREMENT = "MEASUREMENT"
    255     PROCEDURE_CELLCHANGE = "CELLCHANGE"
    256     PROCEDURE_MULTICELL = "MULTICELL"
    257 
    258 
    259 class TestPowerControl(Enum):
    260     ''' Values for power control in test procedure '''
    261     POWER_CONTROL_ENABLE = "ENABLE"
    262     POWER_CONTROL_DISABLE = "DISABLE"
    263 
    264 
    265 class TestMeasurement(Enum):
    266     ''' Values for mesaurement in test procedure '''
    267     MEASUREMENT_ENABLE = "ENABLE"
    268     MEASUREMENT_DISABLE = "DISABLE"
    269 
    270 
    271 '''MD8475A processing states'''
    272 _PROCESS_STATES = {
    273     "NONE": ProcessingStatus.PROCESS_STATUS_NONE,
    274     "NOTRUN": ProcessingStatus.PROCESS_STATUS_NOTRUN,
    275     "POWEROFF": ProcessingStatus.PROCESS_STATUS_POWEROFF,
    276     "REGISTRATION": ProcessingStatus.PROCESS_STATUS_REGISTRATION,
    277     "DETACH": ProcessingStatus.PROCESS_STATUS_DETACH,
    278     "IDLE": ProcessingStatus.PROCESS_STATUS_IDLE,
    279     "ORIGINATION": ProcessingStatus.PROCESS_STATUS_ORIGINATION,
    280     "HANDOVER": ProcessingStatus.PROCESS_STATUS_HANDOVER,
    281     "UPDATING": ProcessingStatus.PROCESS_STATUS_UPDATING,
    282     "TERMINATION": ProcessingStatus.PROCESS_STATUS_TERMINATION,
    283     "COMMUNICATION": ProcessingStatus.PROCESS_STATUS_COMMUNICATION,
    284     "UERELEASE": ProcessingStatus.PROCESS_STATUS_UERELEASE,
    285     "NWRELEASE": ProcessingStatus.PROCESS_STATUS_NWRELEASE,
    286 }
    287 
    288 
    289 class ImsCscfStatus(Enum):
    290     """ MD8475A ims cscf status for UE
    291     """
    292     OFF = "OFF"
    293     SIPIDLE = "SIPIDLE"
    294     CONNECTED = "CONNECTED"
    295     CALLING = "CALLING"
    296     RINGING = "RINGING"
    297     UNKNOWN = "UNKNOWN"
    298 
    299 
    300 class ImsCscfCall(Enum):
    301     """ MD8475A ims cscf call action
    302     """
    303     MAKE = "MAKE"
    304     END = "END"
    305     MAKEVIDEO = "MAKEVIDEO"
    306     MAKE2ND = "MAKE2ND"
    307     END2ND = "END2ND"
    308     ANSWER = "ANSWER"
    309     HOLD = "HOLD"
    310     RESUME = "RESUME"
    311 
    312 
    313 class VirtualPhoneStatus(IntEnum):
    314     ''' MD8475A virtual phone status for UE voice and UE video
    315         PPP, PWS '''
    316     STATUS_IDLE = 0
    317     STATUS_VOICECALL_ORIGINATION = 1
    318     STATUS_VOICECALL_INCOMING = 2
    319     STATUS_VOICECALL_INPROGRESS = 3
    320     STATUS_VOICECALL_DISCONNECTING = 4
    321     STATUS_VOICECALL_DISCONNECTED = 5
    322     STATUS_VIDEOCALL_ORIGINATION = 6
    323     STATUS_VIDEOCALL_INCOMING = 7
    324     STATUS_VIDEOCALL_INPROGRESS = 8
    325     STATUS_VIDEOCALL_DISCONNECTING = 9
    326     STATUS_VIDEOCALL_DISCONNECTED = 10
    327 
    328 
    329 '''Virtual Phone Status '''
    330 _VP_STATUS = {
    331     "0": VirtualPhoneStatus.STATUS_IDLE,
    332     "1": VirtualPhoneStatus.STATUS_VOICECALL_ORIGINATION,
    333     "2": VirtualPhoneStatus.STATUS_VOICECALL_INCOMING,
    334     "3": VirtualPhoneStatus.STATUS_VOICECALL_INPROGRESS,
    335     "4": VirtualPhoneStatus.STATUS_VOICECALL_DISCONNECTING,
    336     "5": VirtualPhoneStatus.STATUS_VOICECALL_DISCONNECTED,
    337     "6": VirtualPhoneStatus.STATUS_VIDEOCALL_ORIGINATION,
    338     "7": VirtualPhoneStatus.STATUS_VIDEOCALL_INCOMING,
    339     "8": VirtualPhoneStatus.STATUS_VIDEOCALL_INPROGRESS,
    340     "9": VirtualPhoneStatus.STATUS_VIDEOCALL_DISCONNECTING,
    341     "10": VirtualPhoneStatus.STATUS_VIDEOCALL_DISCONNECTED,
    342 }
    343 
    344 
    345 class VirtualPhoneAutoAnswer(Enum):
    346     ''' Virtual phone auto answer enable values'''
    347     ON = "ON"
    348     OFF = "OFF"
    349 
    350 
    351 class CsfbType(Enum):
    352     ''' CSFB Type values'''
    353     CSFB_TYPE_REDIRECTION = "REDIRECTION"
    354     CSFB_TYPE_HANDOVER = "HO"
    355 
    356 
    357 class ReturnToEUTRAN(Enum):
    358     '''Return to EUTRAN setting values '''
    359     RETEUTRAN_ENABLE = "ENABLE"
    360     RETEUTRAN_DISABLE = "DISABLE"
    361 
    362 
    363 class CTCHSetup(Enum):
    364     '''CTCH setting values '''
    365     CTCH_ENABLE = "ENABLE"
    366     CTCH_DISABLE = "DISABLE"
    367 
    368 
    369 class UEIdentityType(Enum):
    370     '''UE Identity type values '''
    371     IMSI = "IMSI"
    372     IMEI = "IMEI"
    373     IMEISV = "IMEISV"
    374 
    375 
    376 class CBCHSetup(Enum):
    377     '''CBCH setting values '''
    378     CBCH_ENABLE = "ENABLE"
    379     CBCH_DISABLE = "DISABLE"
    380 
    381 
    382 class Switch(Enum):
    383     ''' Values for ENABLE or DISABLE '''
    384     ENABLE = "ENABLE"
    385     DISABLE = "DISABLE"
    386 
    387 
    388 class MD8475A(object):
    389     """Class to communicate with Anritsu MD8475A Signalling Tester.
    390        This uses GPIB command to interface with Anritsu MD8475A """
    391 
    392     def __init__(self, ip_address, log_handle, wlan=False):
    393         self._error_reporting = True
    394         self._ipaddr = ip_address
    395         self.log = log_handle
    396         self._wlan = wlan
    397 
    398         # Open socket connection to Signaling Tester
    399         self.log.info("Opening Socket Connection with "
    400                       "Signaling Tester ({}) ".format(self._ipaddr))
    401         try:
    402             self._sock = socket.create_connection(
    403                 (self._ipaddr, 28002), timeout=120)
    404             self.send_query("*IDN?", 60)
    405             self.log.info("Communication with Signaling Tester OK.")
    406             self.log.info("Opened Socket connection to ({})"
    407                           "with handle ({})".format(self._ipaddr, self._sock))
    408             # launching Smart Studio Application needed for the simulation
    409             ret = self.launch_smartstudio()
    410         except socket.timeout:
    411             raise AnritsuError("Timeout happened while conencting to"
    412                                " Anritsu MD8475A")
    413         except socket.error:
    414             raise AnritsuError("Socket creation error")
    415 
    416     def get_BTS(self, btsnumber):
    417         """ Returns the BTS object based on the BTS number provided
    418 
    419         Args:
    420             btsnumber: BTS number (BTS1, BTS2)
    421 
    422         Returns:
    423             BTS object
    424         """
    425         return _BaseTransceiverStation(self, btsnumber)
    426 
    427     def get_AnritsuTestCases(self):
    428         """ Returns the Anritsu Test Case Module Object
    429 
    430         Args:
    431             None
    432 
    433         Returns:
    434             Anritsu Test Case Module Object
    435         """
    436         return _AnritsuTestCases(self)
    437 
    438     def get_VirtualPhone(self):
    439         """ Returns the Anritsu Virtual Phone Module Object
    440 
    441         Args:
    442             None
    443 
    444         Returns:
    445             Anritsu Virtual Phone Module Object
    446         """
    447         return _VirtualPhone(self)
    448 
    449     def get_PDN(self, pdn_number):
    450         """ Returns the PDN Module Object
    451 
    452         Args:
    453             None
    454 
    455         Returns:
    456             Anritsu PDN Module Object
    457         """
    458         return _PacketDataNetwork(self, pdn_number)
    459 
    460     def get_TriggerMessage(self):
    461         """ Returns the Anritsu Trigger Message Module Object
    462 
    463         Args:
    464             None
    465 
    466         Returns:
    467             Anritsu Trigger Message Module Object
    468         """
    469         return _TriggerMessage(self)
    470 
    471     def get_IMS(self, vnid):
    472         """ Returns the IMS Module Object with VNID
    473 
    474         Args:
    475             vnid: Virtual Network ID
    476 
    477         Returns:
    478             Anritsu IMS VNID Module Object
    479         """
    480         return _IMS_Services(self, vnid)
    481 
    482     def get_ims_cscf_status(self, virtual_network_id):
    483         """ Get the IMS CSCF Status of virtual network
    484 
    485         Args:
    486             virtual_network_id: virtual network id
    487 
    488         Returns:
    489             IMS CSCF status
    490         """
    491         cmd = "IMSCSCFSTAT? {}".format(virtual_network_id)
    492         return self.send_query(cmd)
    493 
    494     def ims_cscf_call_action(self, virtual_network_id, action):
    495         """ IMS CSCF Call action
    496 
    497         Args:
    498             virtual_network_id: virtual network id
    499             action: action to make
    500 
    501         Returns:
    502             None
    503         """
    504         cmd = "IMSCSCFCALL {},{}".format(virtual_network_id, action)
    505         self.send_command(cmd)
    506 
    507     def send_query(self, query, sock_timeout=10):
    508         """ Sends a Query message to Anritsu and return response
    509 
    510         Args:
    511             query - Query string
    512 
    513         Returns:
    514             query response
    515         """
    516         self.log.info("--> {}".format(query))
    517         querytoSend = (query + TERMINATOR).encode('utf-8')
    518         self._sock.settimeout(sock_timeout)
    519         try:
    520             self._sock.send(querytoSend)
    521             result = self._sock.recv(ANRITSU_SOCKET_BUFFER_SIZE).rstrip(
    522                 TERMINATOR.encode('utf-8'))
    523             response = result.decode('utf-8')
    524             self.log.info('<-- {}'.format(response))
    525             return response
    526         except socket.timeout:
    527             raise AnritsuError("Timeout: Response from Anritsu")
    528         except socket.error:
    529             raise AnritsuError("Socket Error")
    530 
    531     def send_command(self, command, sock_timeout=20):
    532         """ Sends a Command message to Anritsu
    533 
    534         Args:
    535             command - command string
    536 
    537         Returns:
    538             None
    539         """
    540         self.log.info("--> {}".format(command))
    541         if self._error_reporting:
    542             cmdToSend = (command + ";ERROR?" + TERMINATOR).encode('utf-8')
    543             self._sock.settimeout(sock_timeout)
    544             try:
    545                 self._sock.send(cmdToSend)
    546                 err = self._sock.recv(ANRITSU_SOCKET_BUFFER_SIZE).rstrip(
    547                     TERMINATOR.encode('utf-8'))
    548                 error = int(err.decode('utf-8'))
    549                 if error != NO_ERROR:
    550                     raise AnritsuError(error, command)
    551             except socket.timeout:
    552                 raise AnritsuError("Timeout for Command Response from Anritsu")
    553             except socket.error:
    554                 raise AnritsuError("Socket Error for Anritsu command")
    555             except Exception as e:
    556                 raise AnritsuError(e, command)
    557         else:
    558             cmdToSend = (command + TERMINATOR).encode('utf-8')
    559             try:
    560                 self._sock.send(cmdToSend)
    561             except socket.error:
    562                 raise AnritsuError("Socket Error", command)
    563             return
    564 
    565     def launch_smartstudio(self):
    566         """ launch the Smart studio application
    567             This should be done before stating simulation
    568 
    569         Args:
    570             None
    571 
    572         Returns:
    573             None
    574         """
    575         # check the Smart Studio status . If Smart Studio doesn't exist ,
    576         # start it.if it is running, stop it. Smart Studio should be in
    577         # NOTRUN (Simulation Stopped) state to start new simulation
    578         stat = self.send_query("STAT?", 30)
    579         if stat == "NOTEXIST":
    580             self.log.info("Launching Smart Studio Application,"
    581                           "it takes about a minute.")
    582             time_to_wait = SMARTSTUDIO_LAUNCH_WAIT_TIME
    583             sleep_interval = 15
    584             waiting_time = 0
    585 
    586             err = self.send_command("RUN", SMARTSTUDIO_LAUNCH_WAIT_TIME)
    587             stat = self.send_query("STAT?")
    588             while stat != "NOTRUN":
    589                 time.sleep(sleep_interval)
    590                 waiting_time = waiting_time + sleep_interval
    591                 if waiting_time <= time_to_wait:
    592                     stat = self.send_query("STAT?")
    593                 else:
    594                     raise AnritsuError("Timeout: Smart Studio launch")
    595         elif stat == "RUNNING":
    596             # Stop simulation if necessary
    597             self.send_command("STOP", 60)
    598             stat = self.send_query("STAT?")
    599 
    600         # The state of the Smart Studio should be NOTRUN at this point
    601         # after the one of the steps from above
    602         if stat != "NOTRUN":
    603             self.log.info(
    604                 "Can not launch Smart Studio, "
    605                 "please shut down all the Smart Studio SW components")
    606             raise AnritsuError("Could not run SmartStudio")
    607 
    608     def close_smartstudio(self):
    609         """ Closes the Smart studio application
    610 
    611         Args:
    612             None
    613 
    614         Returns:
    615             None
    616         """
    617         self.stop_simulation()
    618         self.send_command("EXIT", 60)
    619 
    620     def get_smartstudio_status(self):
    621         """ Gets the Smart studio status
    622 
    623         Args:
    624             None
    625 
    626         Returns:
    627             Smart studio status
    628         """
    629         return self.send_query("STAT?")
    630 
    631     def start_simulation(self):
    632         """ Starting the simulation of the network model.
    633             simulation model or simulation parameter file
    634             should be set before starting the simulation
    635 
    636         Args:
    637           None
    638 
    639         Returns:
    640             None
    641         """
    642         time_to_wait = SMARTSTUDIO_SIMULATION_START_WAIT_TIME
    643         sleep_interval = 2
    644         waiting_time = 0
    645 
    646         self.send_command("START", SMARTSTUDIO_SIMULATION_START_WAIT_TIME)
    647 
    648         self.log.info("Waiting for CALLSTAT=POWEROFF")
    649         callstat = self.send_query("CALLSTAT? BTS1").split(",")
    650         while callstat[0] != "POWEROFF":
    651             time.sleep(sleep_interval)
    652             waiting_time += sleep_interval
    653             if waiting_time <= time_to_wait:
    654                 callstat = self.send_query("CALLSTAT? BTS1").split(",")
    655             else:
    656                 raise AnritsuError("Timeout: Starting simulation")
    657 
    658     def stop_simulation(self):
    659         """ Stop simulation operation
    660 
    661         Args:
    662           None
    663 
    664         Returns:
    665             None
    666         """
    667         # Stop virtual network (IMS) #1 if still running
    668         # this is needed before Sync command is supported in 6.40a
    669         if self.send_query("IMSVNSTAT? 1") == "RUNNING":
    670             self.send_command("IMSSTOPVN 1")
    671         if self.send_query("IMSVNSTAT? 2") == "RUNNING":
    672             self.send_command("IMSSTOPVN 2")
    673         stat = self.send_query("STAT?")
    674         # Stop simulation if its is RUNNING
    675         if stat == "RUNNING":
    676             self.send_command("STOP", 60)
    677             stat = self.send_query("STAT?")
    678             if stat != "NOTRUN":
    679                 self.log.info("Failed to stop simulation")
    680                 raise AnritsuError("Failed to stop simulation")
    681 
    682     def reset(self):
    683         """ reset simulation parameters
    684 
    685         Args:
    686           None
    687 
    688         Returns:
    689             None
    690         """
    691         self.send_command("*RST", COMMAND_COMPLETE_WAIT_TIME)
    692 
    693     def load_simulation_paramfile(self, filepath):
    694         """ loads simulation model parameter file
    695         Args:
    696           filepath : simulation model parameter file path
    697 
    698         Returns:
    699             None
    700         """
    701         self.stop_simulation()
    702         cmd = "LOADSIMPARAM \"" + filepath + '\";ERROR?'
    703         self.send_query(cmd, LOAD_SIMULATION_PARAM_FILE_WAIT_TIME)
    704 
    705     def load_cell_paramfile(self, filepath):
    706         """ loads cell model parameter file
    707 
    708         Args:
    709           filepath : cell model parameter file path
    710 
    711         Returns:
    712             None
    713         """
    714         self.stop_simulation()
    715         cmd = "LOADCELLPARAM \"" + filepath + '\";ERROR?'
    716         status = int(self.send_query(cmd))
    717         if status != NO_ERROR:
    718             raise AnritsuError(status, cmd)
    719 
    720     def _set_simulation_model(self, sim_model):
    721         """ Set simulation model and valid the configuration
    722 
    723         Args:
    724             sim_model: simulation model
    725 
    726         Returns:
    727             True/False
    728         """
    729         error = int(
    730             self.send_query("SIMMODEL %s;ERROR?" % sim_model,
    731                             COMMAND_COMPLETE_WAIT_TIME))
    732         if error:  # Try again if first set SIMMODEL fails
    733             time.sleep(3)
    734             if "WLAN" in sim_model:
    735                 new_sim_model = sim_model[:-5]
    736                 error = int(
    737                     self.send_query("SIMMODEL %s;ERROR?" % new_sim_model,
    738                                     COMMAND_COMPLETE_WAIT_TIME))
    739                 time.sleep(3)
    740             error = int(
    741                 self.send_query("SIMMODEL %s;ERROR?" % sim_model,
    742                                 COMMAND_COMPLETE_WAIT_TIME))
    743             if error:
    744                 return False
    745         # Reset every time after SIMMODEL is set because SIMMODEL will load
    746         # some of the contents from previous parameter files.
    747         self.reset()
    748         return True
    749 
    750     def set_simulation_model(self, bts1, bts2=None, bts3=None, bts4=None):
    751         """ Sets the simulation model
    752 
    753         Args:
    754             bts1 - BTS1 RAT
    755             bts1 - BTS2 RAT
    756             bts3 - Not used now
    757             bts4 - Not used now
    758 
    759         Returns:
    760             True or False
    761         """
    762         self.stop_simulation()
    763         simmodel = bts1.value
    764         if bts2 is not None:
    765             simmodel = simmodel + "," + bts2.value
    766         if self._wlan:
    767             simmodel = simmodel + "," + "WLAN"
    768         return self._set_simulation_model(simmodel)
    769 
    770     def get_simulation_model(self):
    771         """ Gets the simulation model
    772 
    773         Args:
    774             None
    775 
    776         Returns:
    777             Current simulation model
    778         """
    779         cmd = "SIMMODEL?"
    780         return self.send_query(cmd)
    781 
    782     def set_simulation_state_to_poweroff(self):
    783         """ Sets the simulation state to POWER OFF
    784 
    785         Args:
    786           None
    787 
    788         Returns:
    789             None
    790         """
    791         self.send_command("RESETSIMULATION POWEROFF")
    792         time_to_wait = 30
    793         sleep_interval = 2
    794         waiting_time = 0
    795 
    796         self.log.info("Waiting for CALLSTAT=POWEROFF")
    797         callstat = self.send_query("CALLSTAT?").split(",")
    798         while callstat[0] != "POWEROFF":
    799             time.sleep(sleep_interval)
    800             waiting_time = waiting_time + sleep_interval
    801             if waiting_time <= time_to_wait:
    802                 callstat = self.send_query("CALLSTAT?").split(",")
    803             else:
    804                 break
    805 
    806     def set_simulation_state_to_idle(self, btsnumber):
    807         """ Sets the simulation state to IDLE
    808 
    809         Args:
    810           None
    811 
    812         Returns:
    813             None
    814         """
    815         if not isinstance(btsnumber, BtsNumber):
    816             raise ValueError(' The parameter should be of type "BtsNumber" ')
    817         cmd = "RESETSIMULATION IDLE," + btsnumber.value
    818         self.send_command(cmd)
    819         time_to_wait = 30
    820         sleep_interval = 2
    821         waiting_time = 0
    822 
    823         self.log.info("Waiting for CALLSTAT=IDLE")
    824         callstat = self.send_query("CALLSTAT?").split(",")
    825         while callstat[0] != "IDLE":
    826             time.sleep(sleep_interval)
    827             waiting_time = waiting_time + sleep_interval
    828             if waiting_time <= time_to_wait:
    829                 callstat = self.send_query("CALLSTAT?").split(",")
    830             else:
    831                 break
    832 
    833     def wait_for_registration_state(self, bts=1):
    834         """ Waits for UE registration state on Anritsu
    835 
    836         Args:
    837           bts: index of MD8475A BTS, eg 1, 2
    838 
    839         Returns:
    840             None
    841         """
    842         self.log.info("wait for IDLE/COMMUNICATION state on anritsu.")
    843         time_to_wait = REGISTRATION_STATE_WAIT_TIME
    844         sleep_interval = 1
    845         sim_model = (self.get_simulation_model()).split(",")
    846         #wait 1 more round for GSM because of PS attach
    847         registration_check_iterations = 2 if sim_model[bts - 1] == "GSM" else 1
    848         for _ in range(registration_check_iterations):
    849             waiting_time = 0
    850             while waiting_time <= time_to_wait:
    851                 callstat = self.send_query(
    852                     "CALLSTAT? BTS{}".format(bts)).split(",")
    853                 if callstat[0] == "IDLE" or callstat[1] == "COMMUNICATION":
    854                     break
    855                 time.sleep(sleep_interval)
    856                 waiting_time += sleep_interval
    857             else:
    858                 raise AnritsuError(
    859                     "UE failed to register in {} seconds".format(time_to_wait))
    860             time.sleep(sleep_interval)
    861 
    862     def wait_for_communication_state(self):
    863         """ Waits for UE communication state on Anritsu
    864 
    865         Args:
    866           None
    867 
    868         Returns:
    869             None
    870         """
    871         self.log.info("wait for COMMUNICATION state on anritsu")
    872         time_to_wait = COMMUNICATION_STATE_WAIT_TIME
    873         sleep_interval = 1
    874         waiting_time = 0
    875 
    876         self.log.info("Waiting for CALLSTAT=COMMUNICATION")
    877         callstat = self.send_query("CALLSTAT? BTS1").split(",")
    878         while callstat[1] != "COMMUNICATION":
    879             time.sleep(sleep_interval)
    880             waiting_time += sleep_interval
    881             if waiting_time <= time_to_wait:
    882                 callstat = self.send_query("CALLSTAT? BTS1").split(",")
    883             else:
    884                 raise AnritsuError("UE failed to register on network")
    885 
    886     def get_camping_cell(self):
    887         """ Gets the current camping cell information
    888 
    889         Args:
    890           None
    891 
    892         Returns:
    893             returns a tuple (BTS number, RAT Technology) '
    894         """
    895         bts_number, rat_info = self.send_query("CAMPINGCELL?").split(",")
    896         return bts_number, rat_info
    897 
    898     def get_supported_bands(self, rat):
    899         """ Gets the supported bands from UE capability information
    900 
    901         Args:
    902           rat: LTE or WCDMA
    903 
    904         Returns:
    905             returns a list of bnads
    906         """
    907         cmd = "UEINFO? "
    908         if rat == "LTE":
    909             cmd += "L"
    910         elif rat == "WCDMA":
    911             cmd += "W"
    912         else:
    913             raise ValueError('The rat argument needs to be "LTE" or "WCDMA"')
    914         cmd += "_SupportedBand"
    915         result = self.send_query(cmd).split(",")
    916         if result == "NONE":
    917             return None
    918         if rat == "WCDMA":
    919             bands = []
    920             for band in result:
    921                 bands.append(WCDMA_BANDS[band])
    922             return bands
    923         else:
    924             return result
    925 
    926     def start_testcase(self):
    927         """ Starts a test case on Anritsu
    928 
    929         Args:
    930           None
    931 
    932         Returns:
    933             None
    934         """
    935         self.send_command("STARTTEST")
    936 
    937     def get_testcase_status(self):
    938         """ Gets the current test case status on Anritsu
    939 
    940         Args:
    941           None
    942 
    943         Returns:
    944             current test case status
    945         """
    946         return self.send_query("TESTSTAT?")
    947 
    948     @property
    949     def gateway_ipv4addr(self):
    950         """ Gets the IPv4 address of the default gateway
    951 
    952         Args:
    953           None
    954 
    955         Returns:
    956             current UE status
    957         """
    958         return self.send_query("DGIPV4?")
    959 
    960     @gateway_ipv4addr.setter
    961     def gateway_ipv4addr(self, ipv4_addr):
    962         """ sets the IPv4 address of the default gateway
    963         Args:
    964             ipv4_addr: IPv4 address of the default gateway
    965 
    966         Returns:
    967             None
    968         """
    969         cmd = "DGIPV4 " + ipv4_addr
    970         self.send_command(cmd)
    971 
    972     @property
    973     def usim_key(self):
    974         """ Gets the USIM Security Key
    975 
    976         Args:
    977           None
    978 
    979         Returns:
    980             USIM Security Key
    981         """
    982         return self.send_query("USIMK?")
    983 
    984     @usim_key.setter
    985     def usim_key(self, usimk):
    986         """ sets the USIM Security Key
    987         Args:
    988             usimk: USIM Security Key, eg "000102030405060708090A0B0C0D0E0F"
    989 
    990         Returns:
    991             None
    992         """
    993         cmd = "USIMK " + usimk
    994         self.send_command(cmd)
    995 
    996     def get_ue_status(self):
    997         """ Gets the current UE status on Anritsu
    998 
    999         Args:
   1000           None
   1001 
   1002         Returns:
   1003             current UE status
   1004         """
   1005         UE_STATUS_INDEX = 0
   1006         ue_status = self.send_query("CALLSTAT?").split(",")[UE_STATUS_INDEX]
   1007         return _PROCESS_STATES[ue_status]
   1008 
   1009     def get_packet_status(self):
   1010         """ Gets the current Packet status on Anritsu
   1011 
   1012         Args:
   1013           None
   1014 
   1015         Returns:
   1016             current Packet status
   1017         """
   1018         PACKET_STATUS_INDEX = 1
   1019         packet_status = self.send_query("CALLSTAT?").split(",")[
   1020             PACKET_STATUS_INDEX]
   1021         return _PROCESS_STATES[packet_status]
   1022 
   1023     def disconnect(self):
   1024         """ Disconnect the Anritsu box from test PC
   1025 
   1026         Args:
   1027           None
   1028 
   1029         Returns:
   1030             None
   1031         """
   1032         # no need to # exit smart studio application
   1033         # self.close_smartstudio()
   1034         self._sock.close()
   1035 
   1036     def machine_reboot(self):
   1037         """ Reboots the Anritsu Machine
   1038 
   1039         Args:
   1040           None
   1041 
   1042         Returns:
   1043             None
   1044         """
   1045         self.send_command("REBOOT")
   1046 
   1047     def save_sequence_log(self, fileName):
   1048         """ Saves the Anritsu Sequence logs to file
   1049 
   1050         Args:
   1051           fileName: log file name
   1052 
   1053         Returns:
   1054             None
   1055         """
   1056         cmd = 'SAVESEQLOG "{}"'.format(fileName)
   1057         self.send_command(cmd)
   1058 
   1059     def clear_sequence_log(self):
   1060         """ Clears the Anritsu Sequence logs
   1061 
   1062         Args:
   1063           None
   1064 
   1065         Returns:
   1066             None
   1067         """
   1068         self.send_command("CLEARSEQLOG")
   1069 
   1070     def save_message_log(self, fileName):
   1071         """ Saves the Anritsu Message logs to file
   1072 
   1073         Args:
   1074           fileName: log file name
   1075 
   1076         Returns:
   1077             None
   1078         """
   1079         cmd = 'SAVEMSGLOG "{}"'.format(fileName)
   1080         self.send_command(cmd)
   1081 
   1082     def clear_message_log(self):
   1083         """ Clears the Anritsu Message logs
   1084 
   1085         Args:
   1086           None
   1087 
   1088         Returns:
   1089             None
   1090         """
   1091         self.send_command("CLEARMSGLOG")
   1092 
   1093     def save_trace_log(self, fileName, fileType, overwrite, start, end):
   1094         """ Saves the Anritsu Trace logs
   1095 
   1096         Args:
   1097           fileName: log file name
   1098           fileType: file type (BINARY, TEXT, H245,PACKET, CPLABE)
   1099           overwrite: whether to over write
   1100           start: starting trace number
   1101           end: ending trace number
   1102 
   1103         Returns:
   1104             None
   1105         """
   1106         cmd = 'SAVETRACELOG "{}",{},{},{},{}'.format(fileName, fileType,
   1107                                                      overwrite, start, end)
   1108         self.send_command(cmd)
   1109 
   1110     def send_cmas_lte_wcdma(self, serialNo, messageID, warningMessage):
   1111         """ Sends a CMAS message
   1112 
   1113         Args:
   1114           serialNo: serial number of CMAS message
   1115           messageID: CMAS message ID
   1116           warningMessage:  CMAS Warning message
   1117 
   1118         Returns:
   1119             None
   1120         """
   1121         cmd = ('PWSSENDWM 3GPP,"BtsNo=1&WarningSystem=CMAS&SerialNo={}'
   1122                '&MessageID={}&wm={}"').format(serialNo, messageID,
   1123                                               warningMessage)
   1124         self.send_command(cmd)
   1125 
   1126     def send_etws_lte_wcdma(self, serialNo, messageID, warningType,
   1127                             warningMessage, userAlertenable, popUpEnable):
   1128         """ Sends a ETWS message
   1129 
   1130         Args:
   1131           serialNo: serial number of CMAS message
   1132           messageID: CMAS message ID
   1133           warningMessage:  CMAS Warning message
   1134 
   1135         Returns:
   1136             None
   1137         """
   1138         cmd = (
   1139             'PWSSENDWM 3GPP,"BtsNo=1&WarningSystem=ETWS&SerialNo={}&'
   1140             'Primary=ON&PrimaryMessageID={}&Secondary=ON&SecondaryMessageID={}'
   1141             '&WarningType={}&wm={}&UserAlert={}&Popup={}&dcs=0x10&LanguageCode=en"'
   1142         ).format(serialNo, messageID, messageID, warningType, warningMessage,
   1143                  userAlertenable, popUpEnable)
   1144         self.send_command(cmd)
   1145 
   1146     def send_cmas_etws_cdma1x(self, message_id, service_category, alert_ext,
   1147                               response_type, severity, urgency, certainty):
   1148         """ Sends a CMAS/ETWS message on CDMA 1X
   1149 
   1150         Args:
   1151           serviceCategory: service category of alert
   1152           messageID: message ID
   1153           alertText: Warning message
   1154 
   1155         Returns:
   1156             None
   1157         """
   1158         cmd = (
   1159             'PWSSENDWM 3GPP2,"BtsNo=1&ServiceCategory={}&MessageID={}&AlertText={}&'
   1160             'CharSet=ASCII&ResponseType={}&Severity={}&Urgency={}&Certainty={}"'
   1161         ).format(service_category, message_id, alert_ext, response_type,
   1162                  severity, urgency, certainty)
   1163         self.send_command(cmd)
   1164 
   1165     @property
   1166     def csfb_type(self):
   1167         """ Gets the current CSFB type
   1168 
   1169         Args:
   1170             None
   1171 
   1172         Returns:
   1173             current CSFB type
   1174         """
   1175         return self.send_query("SIMMODELEX? CSFB")
   1176 
   1177     @csfb_type.setter
   1178     def csfb_type(self, csfb_type):
   1179         """ sets the CSFB type
   1180         Args:
   1181             csfb_type: CSFB type
   1182 
   1183         Returns:
   1184             None
   1185         """
   1186         if not isinstance(csfb_type, CsfbType):
   1187             raise ValueError('The parameter should be of type "CsfbType" ')
   1188         cmd = "SIMMODELEX CSFB," + csfb_type.value
   1189         self.send_command(cmd)
   1190 
   1191     @property
   1192     def csfb_return_to_eutran(self):
   1193         """ Gets the current return to EUTRAN status
   1194 
   1195         Args:
   1196             None
   1197 
   1198         Returns:
   1199             current return to EUTRAN status
   1200         """
   1201         return self.send_query("SIMMODELEX? RETEUTRAN")
   1202 
   1203     @csfb_return_to_eutran.setter
   1204     def csfb_return_to_eutran(self, enable):
   1205         """ sets the return to EUTRAN feature
   1206         Args:
   1207             enable: enable/disable return to EUTRAN feature
   1208 
   1209         Returns:
   1210             None
   1211         """
   1212         if not isinstance(enable, ReturnToEUTRAN):
   1213             raise ValueError(
   1214                 'The parameter should be of type "ReturnToEUTRAN"')
   1215         cmd = "SIMMODELEX RETEUTRAN," + enable.value
   1216         self.send_command(cmd)
   1217 
   1218     def set_packet_preservation(self):
   1219         """ Set packet state to Preservation
   1220 
   1221         Args:
   1222             None
   1223 
   1224         Returns:
   1225             None
   1226         """
   1227         cmd = "OPERATEPACKET PRESERVATION"
   1228         self.send_command(cmd)
   1229 
   1230     def set_packet_dormant(self):
   1231         """ Set packet state to Dormant
   1232 
   1233         Args:
   1234             None
   1235 
   1236         Returns:
   1237             None
   1238         """
   1239         cmd = "OPERATEPACKET DORMANT"
   1240         self.send_command(cmd)
   1241 
   1242     def get_ue_identity(self, identity_type):
   1243         """ Get the UE identity IMSI, IMEI, IMEISV
   1244 
   1245         Args:
   1246             identity_type : IMSI/IMEI/IMEISV
   1247 
   1248         Returns:
   1249             IMSI/IMEI/IMEISV value
   1250         """
   1251         bts, rat = self.get_camping_cell()
   1252         if rat == BtsTechnology.LTE.value:
   1253             identity_request = TriggerMessageIDs.IDENTITY_REQUEST_LTE.value
   1254             if identity_type == UEIdentityType.IMSI:
   1255                 userdata = IMSI_READ_USERDATA_LTE
   1256             elif identity_type == UEIdentityType.IMEI:
   1257                 userdata = IMEI_READ_USERDATA_LTE
   1258             elif identity_type == UEIdentityType.IMEISV:
   1259                 userdata = IMEISV_READ_USERDATA_LTE
   1260             else:
   1261                 return None
   1262         elif rat == BtsTechnology.WCDMA.value:
   1263             identity_request = TriggerMessageIDs.IDENTITY_REQUEST_WCDMA.value
   1264             if identity_type == UEIdentityType.IMSI:
   1265                 userdata = IMSI_READ_USERDATA_WCDMA
   1266             elif identity_type == UEIdentityType.IMEI:
   1267                 userdata = IMEI_READ_USERDATA_WCDMA
   1268             elif identity_type == UEIdentityType.IMEISV:
   1269                 userdata = IMEISV_READ_USERDATA_WCDMA
   1270             else:
   1271                 return None
   1272         elif rat == BtsTechnology.GSM.value:
   1273             identity_request = TriggerMessageIDs.IDENTITY_REQUEST_GSM.value
   1274             if identity_type == UEIdentityType.IMSI:
   1275                 userdata = IMSI_READ_USERDATA_GSM
   1276             elif identity_type == UEIdentityType.IMEI:
   1277                 userdata = IMEI_READ_USERDATA_GSM
   1278             elif identity_type == UEIdentityType.IMEISV:
   1279                 userdata = IMEISV_READ_USERDATA_GSM
   1280             else:
   1281                 return None
   1282         else:
   1283             return None
   1284 
   1285         self.send_command("TMMESSAGEMODE {},USERDATA".format(identity_request))
   1286         time.sleep(SETTLING_TIME)
   1287         self.send_command("TMUSERDATA {}, {}, {}".format(
   1288             identity_request, userdata, IDENTITY_REQ_DATA_LEN))
   1289         time.sleep(SETTLING_TIME)
   1290         self.send_command("TMSENDUSERMSG {}".format(identity_request))
   1291         time.sleep(WAIT_TIME_IDENTITY_RESPONSE)
   1292         # Go through sequence log and find the identity response message
   1293         target = '"{}"'.format(identity_type.value)
   1294         seqlog = self.send_query("SEQLOG?").split(",")
   1295         while (target not in seqlog):
   1296             index = int(seqlog[0]) - 1
   1297             if index < SEQ_LOG_MESSAGE_START_INDEX:
   1298                 self.log.error("Can not find " + target)
   1299                 return None
   1300             seqlog = self.send_query("SEQLOG? %d" % index).split(",")
   1301         return (seqlog[-1])
   1302 
   1303     def select_usim(self, usim):
   1304         """ Select pre-defined Anritsu USIM models
   1305 
   1306         Args:
   1307             usim: any of P0035Bx, P0135Ax, P0250Ax, P0260Ax
   1308 
   1309         Returns:
   1310             None
   1311         """
   1312         cmd = "SELECTUSIM {}".format(usim)
   1313         self.send_command(cmd)
   1314 
   1315 
   1316 class _AnritsuTestCases(object):
   1317     '''Class to interact with the MD8475 supported test procedures '''
   1318 
   1319     def __init__(self, anritsu):
   1320         self._anritsu = anritsu
   1321         self.log = anritsu.log
   1322 
   1323     @property
   1324     def procedure(self):
   1325         """ Gets the current Test Procedure type
   1326 
   1327         Args:
   1328             None
   1329 
   1330         Returns:
   1331             One of TestProcedure type values
   1332         """
   1333         return self._anritsu.send_query("TESTPROCEDURE?")
   1334 
   1335     @procedure.setter
   1336     def procedure(self, procedure):
   1337         """ sets the Test Procedure type
   1338         Args:
   1339             procedure: One of TestProcedure type values
   1340 
   1341         Returns:
   1342             None
   1343         """
   1344         if not isinstance(procedure, TestProcedure):
   1345             raise ValueError(
   1346                 'The parameter should be of type "TestProcedure" ')
   1347         cmd = "TESTPROCEDURE " + procedure.value
   1348         self._anritsu.send_command(cmd)
   1349 
   1350     @property
   1351     def bts_direction(self):
   1352         """ Gets the current Test direction
   1353 
   1354          Args:
   1355             None
   1356 
   1357         Returns:
   1358             Current Test direction eg:BTS2,BTS1
   1359         """
   1360         return self._anritsu.send_query("TESTBTSDIRECTION?")
   1361 
   1362     @bts_direction.setter
   1363     def bts_direction(self, direction):
   1364         """ sets the Test direction  eg: BTS1 to BTS2 '''
   1365 
   1366         Args:
   1367             direction: tuple (from-bts,to_bts) of type BtsNumber
   1368 
   1369         Returns:
   1370             None
   1371         """
   1372         if not isinstance(direction, tuple) or len(direction) is not 2:
   1373             raise ValueError("Pass a tuple with two items")
   1374         from_bts, to_bts = direction
   1375         if (isinstance(from_bts, BtsNumber) and isinstance(to_bts, BtsNumber)):
   1376             cmd = "TESTBTSDIRECTION {},{}".format(from_bts.value, to_bts.value)
   1377             self._anritsu.send_command(cmd)
   1378         else:
   1379             raise ValueError(' The parameters should be of type "BtsNumber" ')
   1380 
   1381     @property
   1382     def registration_timeout(self):
   1383         """ Gets the current Test registration timeout
   1384 
   1385         Args:
   1386             None
   1387 
   1388         Returns:
   1389             Current test registration timeout value
   1390         """
   1391         return self._anritsu.send_query("TESTREGISTRATIONTIMEOUT?")
   1392 
   1393     @registration_timeout.setter
   1394     def registration_timeout(self, timeout_value):
   1395         """ sets the Test registration timeout value
   1396         Args:
   1397             timeout_value: test registration timeout value
   1398 
   1399         Returns:
   1400             None
   1401         """
   1402         cmd = "TESTREGISTRATIONTIMEOUT " + str(timeout_value)
   1403         self._anritsu.send_command(cmd)
   1404 
   1405     @property
   1406     def power_control(self):
   1407         """ Gets the power control enabled/disabled status for test case
   1408 
   1409         Args:
   1410             None
   1411 
   1412         Returns:
   1413             current power control enabled/disabled status
   1414         """
   1415         return self._anritsu.send_query("TESTPOWERCONTROL?")
   1416 
   1417     @power_control.setter
   1418     def power_control(self, enable):
   1419         """ Sets the power control enabled/disabled status for test case
   1420 
   1421         Args:
   1422             enable:  enabled/disabled
   1423 
   1424         Returns:
   1425             None
   1426         """
   1427         if not isinstance(enable, TestPowerControl):
   1428             raise ValueError(' The parameter should be of type'
   1429                              ' "TestPowerControl" ')
   1430         cmd = "TESTPOWERCONTROL " + enable.value
   1431         self._anritsu.send_command(cmd)
   1432 
   1433     @property
   1434     def measurement_LTE(self):
   1435         """ Checks measurement status for LTE test case
   1436 
   1437         Args:
   1438             None
   1439 
   1440         Returns:
   1441             Enabled/Disabled
   1442         """
   1443         return self._anritsu.send_query("TESTMEASUREMENT? LTE")
   1444 
   1445     @measurement_LTE.setter
   1446     def measurement_LTE(self, enable):
   1447         """ Sets the measurement enabled/disabled status for LTE test case
   1448 
   1449         Args:
   1450             enable:  enabled/disabled
   1451 
   1452         Returns:
   1453             None
   1454         """
   1455         if not isinstance(enable, TestMeasurement):
   1456             raise ValueError(' The parameter should be of type'
   1457                              ' "TestMeasurement" ')
   1458         cmd = "TESTMEASUREMENT LTE," + enable.value
   1459         self._anritsu.send_command(cmd)
   1460 
   1461     @property
   1462     def measurement_WCDMA(self):
   1463         """ Checks measurement status for WCDMA test case
   1464 
   1465         Args:
   1466             None
   1467 
   1468         Returns:
   1469             Enabled/Disabled
   1470         """
   1471         return self._anritsu.send_query("TESTMEASUREMENT? WCDMA")
   1472 
   1473     @measurement_WCDMA.setter
   1474     def measurement_WCDMA(self, enable):
   1475         """ Sets the measurement enabled/disabled status for WCDMA test case
   1476 
   1477         Args:
   1478             enable:  enabled/disabled
   1479 
   1480         Returns:
   1481             None
   1482         """
   1483         if not isinstance(enable, TestMeasurement):
   1484             raise ValueError(' The parameter should be of type'
   1485                              ' "TestMeasurement" ')
   1486         cmd = "TESTMEASUREMENT WCDMA," + enable.value
   1487         self._anritsu.send_command(cmd)
   1488 
   1489     @property
   1490     def measurement_TDSCDMA(self):
   1491         """ Checks measurement status for TDSCDMA test case
   1492 
   1493         Args:
   1494             None
   1495 
   1496         Returns:
   1497             Enabled/Disabled
   1498         """
   1499         return self._anritsu.send_query("TESTMEASUREMENT? TDSCDMA")
   1500 
   1501     @measurement_TDSCDMA.setter
   1502     def measurement_WCDMA(self, enable):
   1503         """ Sets the measurement enabled/disabled status for TDSCDMA test case
   1504 
   1505         Args:
   1506             enable:  enabled/disabled
   1507 
   1508         Returns:
   1509             None
   1510         """
   1511         if not isinstance(enable, TestMeasurement):
   1512             raise ValueError(' The parameter should be of type'
   1513                              ' "TestMeasurement" ')
   1514         cmd = "TESTMEASUREMENT TDSCDMA," + enable.value
   1515         self._anritsu.send_command(cmd)
   1516 
   1517     def set_pdn_targeteps(self, pdn_order, pdn_number=1):
   1518         """ Sets PDN to connect as a target when performing the
   1519            test case for packet handover
   1520 
   1521         Args:
   1522             pdn_order:  PRIORITY/USER
   1523             pdn_number: Target PDN number
   1524 
   1525         Returns:
   1526             None
   1527         """
   1528         cmd = "TESTPDNTARGETEPS " + pdn_order
   1529         if pdn_order == "USER":
   1530             cmd = cmd + "," + str(pdn_number)
   1531         self._anritsu.send_command(cmd)
   1532 
   1533 
   1534 class _BaseTransceiverStation(object):
   1535     '''Class to interact different BTS supported by MD8475 '''
   1536 
   1537     def __init__(self, anritsu, btsnumber):
   1538         if not isinstance(btsnumber, BtsNumber):
   1539             raise ValueError(' The parameter should be of type "BtsNumber" ')
   1540         self._bts_number = btsnumber.value
   1541         self._anritsu = anritsu
   1542         self.log = anritsu.log
   1543 
   1544     @property
   1545     def output_level(self):
   1546         """ Gets the Downlink power of the cell
   1547 
   1548         Args:
   1549             None
   1550 
   1551         Returns:
   1552             DL Power level
   1553         """
   1554         cmd = "OLVL? " + self._bts_number
   1555         return self._anritsu.send_query(cmd)
   1556 
   1557     @output_level.setter
   1558     def output_level(self, level):
   1559         """ Sets the Downlink power of the cell
   1560 
   1561         Args:
   1562             level: Power level
   1563 
   1564         Returns:
   1565             None
   1566         """
   1567         counter = 1
   1568         while float(level) != float(self.output_level):
   1569             if counter > 3:
   1570                 raise AnritsuError("Fail to set output level in 3 tries!")
   1571             cmd = "OLVL {},{}".format(level, self._bts_number)
   1572             self._anritsu.send_command(cmd)
   1573             counter += 1
   1574             time.sleep(1)
   1575 
   1576     @property
   1577     def input_level(self):
   1578         """ Gets the reference power of the cell
   1579 
   1580         Args:
   1581             None
   1582 
   1583         Returns:
   1584             Reference Power level
   1585         """
   1586         cmd = "RFLVL? " + self._bts_number
   1587         return self._anritsu.send_query(cmd)
   1588 
   1589     @input_level.setter
   1590     def input_level(self, level):
   1591         """ Sets the reference power of the cell
   1592 
   1593         Args:
   1594             level: Power level
   1595 
   1596         Returns:
   1597             None
   1598         """
   1599         counter = 1
   1600         while float(level) != float(self.input_level):
   1601             if counter > 3:
   1602                 raise AnritsuError("Fail to set intput level in 3 tries!")
   1603             cmd = "RFLVL {},{}".format(level, self._bts_number)
   1604             self._anritsu.send_command(cmd)
   1605             counter += 1
   1606             time.sleep(1)
   1607 
   1608     @property
   1609     def band(self):
   1610         """ Gets the Band of the cell
   1611 
   1612         Args:
   1613             None
   1614 
   1615         Returns:
   1616             Cell band
   1617         """
   1618         cmd = "BAND? " + self._bts_number
   1619         return self._anritsu.send_query(cmd)
   1620 
   1621     @band.setter
   1622     def band(self, band):
   1623         """ Sets the Band of the cell
   1624 
   1625         Args:
   1626             band: Band of the cell
   1627 
   1628         Returns:
   1629             None
   1630         """
   1631         cmd = "BAND {},{}".format(band, self._bts_number)
   1632         self._anritsu.send_command(cmd)
   1633 
   1634     @property
   1635     def transmode(self):
   1636         """ Gets the Transmission Mode of the cell
   1637 
   1638         Args:
   1639             None
   1640 
   1641         Returns:
   1642             Transmission mode
   1643         """
   1644         cmd = "TRANSMODE? " + self._bts_number
   1645         return self._anritsu.send_query(cmd)
   1646 
   1647     @transmode.setter
   1648     def transmode(self, tm_mode):
   1649         """ Sets the TM of the cell
   1650 
   1651         Args:
   1652             TM: TM of the cell
   1653 
   1654         Returns:
   1655             None
   1656         """
   1657         cmd = "TRANSMODE {},{}".format(tm_mode, self._bts_number)
   1658         self._anritsu.send_command(cmd)
   1659 
   1660     @property
   1661     def dl_antenna(self):
   1662         """ Gets the DL ANTENNA count of the cell
   1663 
   1664         Args:
   1665             None
   1666 
   1667         Returns:
   1668             No of DL Antenna
   1669         """
   1670         cmd = "ANTENNAS? " + self._bts_number
   1671         return self._anritsu.send_query(cmd)
   1672 
   1673     @dl_antenna.setter
   1674     def dl_antenna(self, num_antenna):
   1675         """ Sets the DL ANTENNA of the cell
   1676 
   1677         Args:
   1678             c: DL ANTENNA of the cell
   1679 
   1680         Returns:
   1681             None
   1682         """
   1683         cmd = "ANTENNAS {},{}".format(num_antenna, self._bts_number)
   1684         self._anritsu.send_command(cmd)
   1685 
   1686     @property
   1687     def bandwidth(self):
   1688         """ Gets the channel bandwidth of the cell
   1689 
   1690         Args:
   1691             None
   1692 
   1693         Returns:
   1694             channel bandwidth
   1695         """
   1696         cmd = "BANDWIDTH? " + self._bts_number
   1697         return self._anritsu.send_query(cmd)
   1698 
   1699     @bandwidth.setter
   1700     def bandwidth(self, bandwidth):
   1701         """ Sets the channel bandwidth of the cell
   1702 
   1703         Args:
   1704             bandwidth: channel bandwidth  of the cell
   1705 
   1706         Returns:
   1707             None
   1708         """
   1709         if not isinstance(bandwidth, BtsBandwidth):
   1710             raise ValueError(' The parameter should be of type "BtsBandwidth"')
   1711         cmd = "BANDWIDTH {},{}".format(bandwidth.value, self._bts_number)
   1712         self._anritsu.send_command(cmd)
   1713 
   1714     @property
   1715     def dl_bandwidth(self):
   1716         """ Gets the downlink bandwidth of the cell
   1717 
   1718         Args:
   1719             None
   1720 
   1721         Returns:
   1722             downlink bandwidth
   1723         """
   1724         cmd = "DLBANDWIDTH? " + self._bts_number
   1725         return self._anritsu.send_query(cmd)
   1726 
   1727     @dl_bandwidth.setter
   1728     def dl_bandwidth(self, bandwidth):
   1729         """ Sets the downlink bandwidth of the cell
   1730 
   1731         Args:
   1732             bandwidth: downlink bandwidth of the cell
   1733 
   1734         Returns:
   1735             None
   1736         """
   1737         if not isinstance(bandwidth, BtsBandwidth):
   1738             raise ValueError(' The parameter should be of type "BtsBandwidth"')
   1739         cmd = "DLBANDWIDTH {},{}".format(bandwidth.value, self._bts_number)
   1740         self._anritsu.send_command(cmd)
   1741 
   1742     @property
   1743     def ul_bandwidth(self):
   1744         """ Gets the uplink bandwidth of the cell
   1745 
   1746         Args:
   1747             None
   1748 
   1749         Returns:
   1750             uplink bandwidth
   1751         """
   1752         cmd = "ULBANDWIDTH? " + self._bts_number
   1753         return self._anritsu.send_query(cmd)
   1754 
   1755     @ul_bandwidth.setter
   1756     def ul_bandwidth(self, bandwidth):
   1757         """ Sets the uplink bandwidth of the cell
   1758 
   1759         Args:
   1760             bandwidth: uplink bandwidth of the cell
   1761 
   1762         Returns:
   1763             None
   1764         """
   1765         if not isinstance(bandwidth, BtsBandwidth):
   1766             raise ValueError(
   1767                 ' The parameter should be of type "BtsBandwidth" ')
   1768         cmd = "ULBANDWIDTH {},{}".format(bandwidth.value, self._bts_number)
   1769         self._anritsu.send_command(cmd)
   1770 
   1771     @property
   1772     def packet_rate(self):
   1773         """ Gets the packet rate of the cell
   1774 
   1775         Args:
   1776             None
   1777 
   1778         Returns:
   1779             packet rate
   1780         """
   1781         cmd = "PACKETRATE? " + self._bts_number
   1782         return self._anritsu.send_query(cmd)
   1783 
   1784     @packet_rate.setter
   1785     def packet_rate(self, packetrate):
   1786         """ Sets the packet rate of the cell
   1787 
   1788         Args:
   1789             packetrate: packet rate of the cell
   1790 
   1791         Returns:
   1792             None
   1793         """
   1794         if not isinstance(packetrate, BtsPacketRate):
   1795             raise ValueError(' The parameter should be of type'
   1796                              ' "BtsPacketRate" ')
   1797         cmd = "PACKETRATE {},{}".format(packetrate.value, self._bts_number)
   1798         self._anritsu.send_command(cmd)
   1799 
   1800     @property
   1801     def ul_windowsize(self):
   1802         """ Gets the uplink window size of the cell
   1803 
   1804         Args:
   1805             None
   1806 
   1807         Returns:
   1808             uplink window size
   1809         """
   1810         cmd = "ULWINSIZE? " + self._bts_number
   1811         return self._anritsu.send_query(cmd)
   1812 
   1813     @ul_windowsize.setter
   1814     def ul_windowsize(self, windowsize):
   1815         """ Sets the uplink window size of the cell
   1816 
   1817         Args:
   1818             windowsize: uplink window size of the cell
   1819 
   1820         Returns:
   1821             None
   1822         """
   1823         if not isinstance(windowsize, BtsPacketWindowSize):
   1824             raise ValueError(' The parameter should be of type'
   1825                              ' "BtsPacketWindowSize" ')
   1826         cmd = "ULWINSIZE {},{}".format(windowsize.value, self._bts_number)
   1827         self._anritsu.send_command(cmd)
   1828 
   1829     @property
   1830     def dl_windowsize(self):
   1831         """ Gets the downlink window size of the cell
   1832 
   1833         Args:
   1834             None
   1835 
   1836         Returns:
   1837             downlink window size
   1838         """
   1839         cmd = "DLWINSIZE? " + self._bts_number
   1840         return self._anritsu.send_query(cmd)
   1841 
   1842     @dl_windowsize.setter
   1843     def dl_windowsize(self, windowsize):
   1844         """ Sets the downlink window size of the cell
   1845 
   1846         Args:
   1847             windowsize: downlink window size of the cell
   1848 
   1849         Returns:
   1850             None
   1851         """
   1852         if not isinstance(windowsize, BtsPacketWindowSize):
   1853             raise ValueError(' The parameter should be of type'
   1854                              ' "BtsPacketWindowSize" ')
   1855         cmd = "DLWINSIZE {},{}".format(windowsize.value, self._bts_number)
   1856         self._anritsu.send_command(cmd)
   1857 
   1858     @property
   1859     def service_state(self):
   1860         """ Gets the service state of BTS
   1861 
   1862         Args:
   1863             None
   1864 
   1865         Returns:
   1866             service state IN/OUT
   1867         """
   1868         cmd = "OUTOFSERVICE? " + self._bts_number
   1869         return self._anritsu.send_query(cmd)
   1870 
   1871     @service_state.setter
   1872     def service_state(self, service_state):
   1873         """ Sets the service state of BTS
   1874 
   1875         Args:
   1876             service_state: service state of BTS , IN/OUT
   1877 
   1878         Returns:
   1879             None
   1880         """
   1881         if not isinstance(service_state, BtsServiceState):
   1882             raise ValueError(' The parameter should be of type'
   1883                              ' "BtsServiceState" ')
   1884         cmd = "OUTOFSERVICE {},{}".format(service_state.value,
   1885                                           self._bts_number)
   1886         self._anritsu.send_command(cmd)
   1887 
   1888     @property
   1889     def cell_barred(self):
   1890         """ Gets the Cell Barred state of the cell
   1891 
   1892         Args:
   1893             None
   1894 
   1895         Returns:
   1896             one of BtsCellBarred value
   1897         """
   1898         cmd = "CELLBARRED?" + self._bts_number
   1899         return self._anritsu.send_query(cmd)
   1900 
   1901     @cell_barred.setter
   1902     def cell_barred(self, barred_option):
   1903         """ Sets the Cell Barred state of the cell
   1904 
   1905         Args:
   1906             barred_option: Cell Barred state of the cell
   1907 
   1908         Returns:
   1909             None
   1910         """
   1911         if not isinstance(barred_option, BtsCellBarred):
   1912             raise ValueError(' The parameter should be of type'
   1913                              ' "BtsCellBarred" ')
   1914         cmd = "CELLBARRED {},{}".format(barred_option.value, self._bts_number)
   1915         self._anritsu.send_command(cmd)
   1916 
   1917     @property
   1918     def accessclass_barred(self):
   1919         """ Gets the Access Class Barred state of the cell
   1920 
   1921         Args:
   1922             None
   1923 
   1924         Returns:
   1925             one of BtsAccessClassBarred value
   1926         """
   1927         cmd = "ACBARRED? " + self._bts_number
   1928         return self._anritsu.send_query(cmd)
   1929 
   1930     @accessclass_barred.setter
   1931     def accessclass_barred(self, barred_option):
   1932         """ Sets the Access Class Barred state of the cell
   1933 
   1934         Args:
   1935             barred_option: Access Class Barred state of the cell
   1936 
   1937         Returns:
   1938             None
   1939         """
   1940         if not isinstance(barred_option, BtsAccessClassBarred):
   1941             raise ValueError(' The parameter should be of type'
   1942                              ' "BtsAccessClassBarred" ')
   1943         cmd = "ACBARRED {},{}".format(barred_option.value, self._bts_number)
   1944         self._anritsu.send_command(cmd)
   1945 
   1946     @property
   1947     def lteemergency_ac_barred(self):
   1948         """ Gets the LTE emergency Access Class Barred state of the cell
   1949 
   1950         Args:
   1951             None
   1952 
   1953         Returns:
   1954             one of BtsLteEmergencyAccessClassBarred value
   1955         """
   1956         cmd = "LTEEMERGENCYACBARRED? " + self._bts_number
   1957         return self._anritsu.send_query(cmd)
   1958 
   1959     @lteemergency_ac_barred.setter
   1960     def lteemergency_ac_barred(self, barred_option):
   1961         """ Sets the LTE emergency Access Class Barred state of the cell
   1962 
   1963         Args:
   1964             barred_option: Access Class Barred state of the cell
   1965 
   1966         Returns:
   1967             None
   1968         """
   1969         if not isinstance(barred_option, BtsLteEmergencyAccessClassBarred):
   1970             raise ValueError(' The parameter should be of type'
   1971                              ' "BtsLteEmergencyAccessClassBarred" ')
   1972         cmd = "LTEEMERGENCYACBARRED {},{}".format(barred_option.value,
   1973                                                   self._bts_number)
   1974         self._anritsu.send_command(cmd)
   1975 
   1976     @property
   1977     def mcc(self):
   1978         """ Gets the MCC of the cell
   1979 
   1980         Args:
   1981             None
   1982 
   1983         Returns:
   1984             MCC of the cell
   1985         """
   1986         cmd = "MCC? " + self._bts_number
   1987         return self._anritsu.send_query(cmd)
   1988 
   1989     @mcc.setter
   1990     def mcc(self, mcc_code):
   1991         """ Sets the MCC of the cell
   1992 
   1993         Args:
   1994             mcc_code: MCC of the cell
   1995 
   1996         Returns:
   1997             None
   1998         """
   1999         cmd = "MCC {},{}".format(mcc_code, self._bts_number)
   2000         self._anritsu.send_command(cmd)
   2001 
   2002     @property
   2003     def mnc(self):
   2004         """ Gets the MNC of the cell
   2005 
   2006         Args:
   2007             None
   2008 
   2009         Returns:
   2010             MNC of the cell
   2011         """
   2012         cmd = "MNC? " + self._bts_number
   2013         return self._anritsu.send_query(cmd)
   2014 
   2015     @mnc.setter
   2016     def mnc(self, mnc_code):
   2017         """ Sets the MNC of the cell
   2018 
   2019         Args:
   2020             mnc_code: MNC of the cell
   2021 
   2022         Returns:
   2023             None
   2024         """
   2025         cmd = "MNC {},{}".format(mnc_code, self._bts_number)
   2026         self._anritsu.send_command(cmd)
   2027 
   2028     @property
   2029     def nw_fullname_enable(self):
   2030         """ Gets the network full name enable status
   2031 
   2032         Args:
   2033             None
   2034 
   2035         Returns:
   2036             one of BtsNwNameEnable value
   2037         """
   2038         cmd = "NWFNAMEON? " + self._bts_number
   2039         return self._anritsu.send_query(cmd)
   2040 
   2041     @nw_fullname_enable.setter
   2042     def nw_fullname_enable(self, enable):
   2043         """ Sets the network full name enable status
   2044 
   2045         Args:
   2046             enable: network full name enable status
   2047 
   2048         Returns:
   2049             None
   2050         """
   2051         if not isinstance(enable, BtsNwNameEnable):
   2052             raise ValueError(' The parameter should be of type'
   2053                              ' "BtsNwNameEnable" ')
   2054         cmd = "NWFNAMEON {},{}".format(enable.value, self._bts_number)
   2055         self._anritsu.send_command(cmd)
   2056 
   2057     @property
   2058     def nw_fullname(self):
   2059         """ Gets the network full name
   2060 
   2061         Args:
   2062             None
   2063 
   2064         Returns:
   2065             Network fulll name
   2066         """
   2067         cmd = "NWFNAME? " + self._bts_number
   2068         return self._anritsu.send_query(cmd)
   2069 
   2070     @nw_fullname.setter
   2071     def nw_fullname(self, fullname):
   2072         """ Sets the network full name
   2073 
   2074         Args:
   2075             fullname: network full name
   2076 
   2077         Returns:
   2078             None
   2079         """
   2080         cmd = "NWFNAME {},{}".format(fullname, self._bts_number)
   2081         self._anritsu.send_command(cmd)
   2082 
   2083     @property
   2084     def nw_shortname_enable(self):
   2085         """ Gets the network short name enable status
   2086 
   2087         Args:
   2088             None
   2089 
   2090         Returns:
   2091             one of BtsNwNameEnable value
   2092         """
   2093         cmd = "NWSNAMEON? " + self._bts_number
   2094         return self._anritsu.send_query(cmd)
   2095 
   2096     @nw_shortname_enable.setter
   2097     def nw_shortname_enable(self, enable):
   2098         """ Sets the network short name enable status
   2099 
   2100         Args:
   2101             enable: network short name enable status
   2102 
   2103         Returns:
   2104             None
   2105         """
   2106         if not isinstance(enable, BtsNwNameEnable):
   2107             raise ValueError(' The parameter should be of type'
   2108                              ' "BtsNwNameEnable" ')
   2109         cmd = "NWSNAMEON {},{}".format(enable.value, self._bts_number)
   2110         self._anritsu.send_command(cmd)
   2111 
   2112     @property
   2113     def nw_shortname(self):
   2114         """ Gets the network short name
   2115 
   2116         Args:
   2117             None
   2118 
   2119         Returns:
   2120             Network short name
   2121         """
   2122         cmd = "NWSNAME? " + self._bts_number
   2123         return self._anritsu.send_query(cmd)
   2124 
   2125     @nw_shortname.setter
   2126     def nw_shortname(self, shortname):
   2127         """ Sets the network short name
   2128 
   2129         Args:
   2130             shortname: network short name
   2131 
   2132         Returns:
   2133             None
   2134         """
   2135         cmd = "NWSNAME {},{}".format(shortname, self._bts_number)
   2136         self._anritsu.send_command(cmd)
   2137 
   2138     def apply_parameter_changes(self):
   2139         """ apply the parameter changes at run time
   2140 
   2141         Args:
   2142             None
   2143 
   2144         Returns:
   2145             None
   2146         """
   2147         cmd = "APPLYPARAM"
   2148         self._anritsu.send_command(cmd)
   2149 
   2150     @property
   2151     def wcdma_ctch(self):
   2152         """ Gets the WCDMA CTCH enable/disable status
   2153 
   2154         Args:
   2155             None
   2156 
   2157         Returns:
   2158             one of CTCHSetup values
   2159         """
   2160         cmd = "CTCHPARAMSETUP? " + self._bts_number
   2161         return self._anritsu.send_query(cmd)
   2162 
   2163     @wcdma_ctch.setter
   2164     def wcdma_ctch(self, enable):
   2165         """ Sets the WCDMA CTCH enable/disable status
   2166 
   2167         Args:
   2168             enable: WCDMA CTCH enable/disable status
   2169 
   2170         Returns:
   2171             None
   2172         """
   2173         cmd = "CTCHPARAMSETUP {},{}".format(enable.value, self._bts_number)
   2174         self._anritsu.send_command(cmd)
   2175 
   2176     @property
   2177     def lac(self):
   2178         """ Gets the Location Area Code of the cell
   2179 
   2180         Args:
   2181             None
   2182 
   2183         Returns:
   2184             LAC value
   2185         """
   2186         cmd = "LAC? " + self._bts_number
   2187         return self._anritsu.send_query(cmd)
   2188 
   2189     @lac.setter
   2190     def lac(self, lac):
   2191         """ Sets the Location Area Code of the cell
   2192 
   2193         Args:
   2194             lac: Location Area Code of the cell
   2195 
   2196         Returns:
   2197             None
   2198         """
   2199         cmd = "LAC {},{}".format(lac, self._bts_number)
   2200         self._anritsu.send_command(cmd)
   2201 
   2202     @property
   2203     def rac(self):
   2204         """ Gets the Routing Area Code of the cell
   2205 
   2206         Args:
   2207             None
   2208 
   2209         Returns:
   2210             RAC value
   2211         """
   2212         cmd = "RAC? " + self._bts_number
   2213         return self._anritsu.send_query(cmd)
   2214 
   2215     @rac.setter
   2216     def rac(self, rac):
   2217         """ Sets the Routing Area Code of the cell
   2218 
   2219         Args:
   2220             rac: Routing Area Code of the cell
   2221 
   2222         Returns:
   2223             None
   2224         """
   2225         cmd = "RAC {},{}".format(rac, self._bts_number)
   2226         self._anritsu.send_command(cmd)
   2227 
   2228     @property
   2229     def dl_channel(self):
   2230         """ Gets the downlink channel number of the cell
   2231 
   2232         Args:
   2233             None
   2234 
   2235         Returns:
   2236             RAC value
   2237         """
   2238         cmd = "DLCHAN? " + self._bts_number
   2239         return self._anritsu.send_query(cmd)
   2240 
   2241     @dl_channel.setter
   2242     def dl_channel(self, channel):
   2243         """ Sets the downlink channel number of the cell
   2244 
   2245         Args:
   2246             channel: downlink channel number of the cell
   2247 
   2248         Returns:
   2249             None
   2250         """
   2251         cmd = "DLCHAN {},{}".format(channel, self._bts_number)
   2252         self._anritsu.send_command(cmd)
   2253 
   2254     @property
   2255     def sector1_mcc(self):
   2256         """ Gets the sector 1 MCC of the CDMA cell
   2257 
   2258         Args:
   2259             None
   2260 
   2261         Returns:
   2262             sector 1 mcc
   2263         """
   2264         cmd = "S1MCC? " + self._bts_number
   2265         return self._anritsu.send_query(cmd)
   2266 
   2267     @sector1_mcc.setter
   2268     def sector1_mcc(self, mcc):
   2269         """ Sets the sector 1 MCC of the CDMA cell
   2270 
   2271         Args:
   2272             mcc: sector 1 MCC of the CDMA cell
   2273 
   2274         Returns:
   2275             None
   2276         """
   2277         cmd = "S1MCC {},{}".format(mcc, self._bts_number)
   2278         self._anritsu.send_command(cmd)
   2279 
   2280     @property
   2281     def sector1_sid(self):
   2282         """ Gets the sector 1 system ID of the CDMA cell
   2283 
   2284         Args:
   2285             None
   2286 
   2287         Returns:
   2288             sector 1 system Id
   2289         """
   2290         cmd = "S1SID? " + self._bts_number
   2291         return self._anritsu.send_query(cmd)
   2292 
   2293     @sector1_sid.setter
   2294     def sector1_sid(self, sid):
   2295         """ Sets the sector 1 system ID of the CDMA cell
   2296 
   2297         Args:
   2298             sid: sector 1 system ID of the CDMA cell
   2299 
   2300         Returns:
   2301             None
   2302         """
   2303         cmd = "S1SID {},{}".format(sid, self._bts_number)
   2304         self._anritsu.send_command(cmd)
   2305 
   2306     @property
   2307     def sector1_nid(self):
   2308         """ Gets the sector 1 network ID of the CDMA cell
   2309 
   2310         Args:
   2311             None
   2312 
   2313         Returns:
   2314             sector 1 network Id
   2315         """
   2316         cmd = "S1NID? " + self._bts_number
   2317         return self._anritsu.send_query(cmd)
   2318 
   2319     @sector1_nid.setter
   2320     def sector1_nid(self, nid):
   2321         """ Sets the sector 1 network ID of the CDMA cell
   2322 
   2323         Args:
   2324             nid: sector 1 network ID of the CDMA cell
   2325 
   2326         Returns:
   2327             None
   2328         """
   2329         cmd = "S1NID {},{}".format(nid, self._bts_number)
   2330         self._anritsu.send_command(cmd)
   2331 
   2332     @property
   2333     def sector1_baseid(self):
   2334         """ Gets the sector 1 Base ID of the CDMA cell
   2335 
   2336         Args:
   2337             None
   2338 
   2339         Returns:
   2340             sector 1 Base Id
   2341         """
   2342         cmd = "S1BASEID? " + self._bts_number
   2343         return self._anritsu.send_query(cmd)
   2344 
   2345     @sector1_baseid.setter
   2346     def sector1_baseid(self, baseid):
   2347         """ Sets the sector 1 Base ID of the CDMA cell
   2348 
   2349         Args:
   2350             baseid: sector 1 Base ID of the CDMA cell
   2351 
   2352         Returns:
   2353             None
   2354         """
   2355         cmd = "S1BASEID {},{}".format(baseid, self._bts_number)
   2356         self._anritsu.send_command(cmd)
   2357 
   2358     @property
   2359     def sector1_latitude(self):
   2360         """ Gets the sector 1 latitude of the CDMA cell
   2361 
   2362         Args:
   2363             None
   2364 
   2365         Returns:
   2366             sector 1 latitude
   2367         """
   2368         cmd = "S1LATITUDE? " + self._bts_number
   2369         return self._anritsu.send_query(cmd)
   2370 
   2371     @sector1_latitude.setter
   2372     def sector1_latitude(self, latitude):
   2373         """ Sets the sector 1 latitude of the CDMA cell
   2374 
   2375         Args:
   2376             latitude: sector 1 latitude of the CDMA cell
   2377 
   2378         Returns:
   2379             None
   2380         """
   2381         cmd = "S1LATITUDE {},{}".format(latitude, self._bts_number)
   2382         self._anritsu.send_command(cmd)
   2383 
   2384     @property
   2385     def sector1_longitude(self):
   2386         """ Gets the sector 1 longitude of the CDMA cell
   2387 
   2388         Args:
   2389             None
   2390 
   2391         Returns:
   2392             sector 1 longitude
   2393         """
   2394         cmd = "S1LONGITUDE? " + self._bts_number
   2395         return self._anritsu.send_query(cmd)
   2396 
   2397     @sector1_longitude.setter
   2398     def sector1_longitude(self, longitude):
   2399         """ Sets the sector 1 longitude of the CDMA cell
   2400 
   2401         Args:
   2402             longitude: sector 1 longitude of the CDMA cell
   2403 
   2404         Returns:
   2405             None
   2406         """
   2407         cmd = "S1LONGITUDE {},{}".format(longitude, self._bts_number)
   2408         self._anritsu.send_command(cmd)
   2409 
   2410     @property
   2411     def evdo_sid(self):
   2412         """ Gets the Sector ID of the EVDO cell
   2413 
   2414         Args:
   2415             None
   2416 
   2417         Returns:
   2418             Sector Id
   2419         """
   2420         cmd = "S1SECTORID? " + self._bts_number
   2421         return self._anritsu.send_query(cmd)
   2422 
   2423     @evdo_sid.setter
   2424     def evdo_sid(self, sid):
   2425         """ Sets the Sector ID of the EVDO cell
   2426 
   2427         Args:
   2428             sid: Sector ID of the EVDO cell
   2429 
   2430         Returns:
   2431             None
   2432         """
   2433         cmd = "S1SECTORID {},{}".format(sid, self._bts_number)
   2434         self._anritsu.send_command(cmd)
   2435 
   2436     @property
   2437     def cell_id(self):
   2438         """ Gets the cell identity of the cell
   2439 
   2440         Args:
   2441             None
   2442 
   2443         Returns:
   2444             cell identity
   2445         """
   2446         cmd = "CELLID? " + self._bts_number
   2447         return self._anritsu.send_query(cmd)
   2448 
   2449     @cell_id.setter
   2450     def cell_id(self, cell_id):
   2451         """ Sets the cell identity of the cell
   2452 
   2453         Args:
   2454             cell_id: cell identity of the cell
   2455 
   2456         Returns:
   2457             None
   2458         """
   2459         cmd = "CELLID {},{}".format(cell_id, self._bts_number)
   2460         self._anritsu.send_command(cmd)
   2461 
   2462     @property
   2463     def physical_cellid(self):
   2464         """ Gets the physical cell id of the cell
   2465 
   2466         Args:
   2467             None
   2468 
   2469         Returns:
   2470             physical cell id
   2471         """
   2472         cmd = "PHYCELLID? " + self._bts_number
   2473         return self._anritsu.send_query(cmd)
   2474 
   2475     @physical_cellid.setter
   2476     def physical_cellid(self, physical_cellid):
   2477         """ Sets the physical cell id of the cell
   2478 
   2479         Args:
   2480             physical_cellid: physical cell id of the cell
   2481 
   2482         Returns:
   2483             None
   2484         """
   2485         cmd = "PHYCELLID {},{}".format(physical_cellid, self._bts_number)
   2486         self._anritsu.send_command(cmd)
   2487 
   2488     @property
   2489     def gsm_mcs_dl(self):
   2490         """ Gets the Modulation and Coding scheme (DL) of the GSM cell
   2491 
   2492         Args:
   2493             None
   2494 
   2495         Returns:
   2496             DL MCS
   2497         """
   2498         cmd = "DLMCS? " + self._bts_number
   2499         return self._anritsu.send_query(cmd)
   2500 
   2501     @gsm_mcs_dl.setter
   2502     def gsm_mcs_dl(self, mcs_dl):
   2503         """ Sets the Modulation and Coding scheme (DL) of the GSM cell
   2504 
   2505         Args:
   2506             mcs_dl: Modulation and Coding scheme (DL) of the GSM cell
   2507 
   2508         Returns:
   2509             None
   2510         """
   2511         cmd = "DLMCS {},{}".format(mcs_dl, self._bts_number)
   2512         self._anritsu.send_command(cmd)
   2513 
   2514     @property
   2515     def gsm_mcs_ul(self):
   2516         """ Gets the Modulation and Coding scheme (UL) of the GSM cell
   2517 
   2518         Args:
   2519             None
   2520 
   2521         Returns:
   2522             UL MCS
   2523         """
   2524         cmd = "ULMCS? " + self._bts_number
   2525         return self._anritsu.send_query(cmd)
   2526 
   2527     @gsm_mcs_ul.setter
   2528     def gsm_mcs_ul(self, mcs_ul):
   2529         """ Sets the Modulation and Coding scheme (UL) of the GSM cell
   2530 
   2531         Args:
   2532             mcs_ul:Modulation and Coding scheme (UL) of the GSM cell
   2533 
   2534         Returns:
   2535             None
   2536         """
   2537         cmd = "ULMCS {},{}".format(mcs_ul, self._bts_number)
   2538         self._anritsu.send_command(cmd)
   2539 
   2540     @property
   2541     def lte_scheduling_mode(self):
   2542         """ Gets the Scheduling mode of the LTE cell
   2543 
   2544         Args:
   2545             None
   2546 
   2547         Returns:
   2548             Scheduling mode
   2549         """
   2550         cmd = "SCHEDULEMODE? " + self._bts_number
   2551         return self._anritsu.send_query(cmd)
   2552 
   2553     @lte_scheduling_mode.setter
   2554     def lte_scheduling_mode(self, mode):
   2555         """ Sets the Scheduling mode of the LTE cell
   2556 
   2557         Args:
   2558             mode: STATIC (default) or DYNAMIC
   2559 
   2560         Returns:
   2561             None
   2562         """
   2563         counter = 1
   2564         while mode != self.lte_scheduling_mode:
   2565             if counter > 3:
   2566                 raise AnritsuError("Fail to set scheduling mode in 3 tries!")
   2567             cmd = "SCHEDULEMODE {},{}".format(mode, self._bts_number)
   2568             self._anritsu.send_command(cmd)
   2569             counter += 1
   2570             time.sleep(1)
   2571 
   2572     @property
   2573     def lte_mcs_dl(self):
   2574         """ Gets the Modulation and Coding scheme (DL) of the LTE cell
   2575 
   2576         Args:
   2577             None
   2578 
   2579         Returns:
   2580             DL MCS
   2581         """
   2582         cmd = "DLIMCS? " + self._bts_number
   2583         return self._anritsu.send_query(cmd)
   2584 
   2585     @lte_mcs_dl.setter
   2586     def lte_mcs_dl(self, mcs_dl):
   2587         """ Sets the Modulation and Coding scheme (DL) of the LTE cell
   2588 
   2589         Args:
   2590             mcs_dl: Modulation and Coding scheme (DL) of the LTE cell
   2591 
   2592         Returns:
   2593             None
   2594         """
   2595         cmd = "DLIMCS {},{}".format(mcs_dl, self._bts_number)
   2596         self._anritsu.send_command(cmd)
   2597 
   2598     @property
   2599     def lte_mcs_ul(self):
   2600         """ Gets the Modulation and Coding scheme (UL) of the LTE cell
   2601 
   2602         Args:
   2603             None
   2604 
   2605         Returns:
   2606             UL MCS
   2607         """
   2608         cmd = "ULIMCS? " + self._bts_number
   2609         return self._anritsu.send_query(cmd)
   2610 
   2611     @lte_mcs_ul.setter
   2612     def lte_mcs_ul(self, mcs_ul):
   2613         """ Sets the Modulation and Coding scheme (UL) of the LTE cell
   2614 
   2615         Args:
   2616             mcs_ul: Modulation and Coding scheme (UL) of the LTE cell
   2617 
   2618         Returns:
   2619             None
   2620         """
   2621         cmd = "ULIMCS {},{}".format(mcs_ul, self._bts_number)
   2622         self._anritsu.send_command(cmd)
   2623 
   2624     @property
   2625     def nrb_dl(self):
   2626         """ Gets the Downlink N Resource Block of the cell
   2627 
   2628         Args:
   2629             None
   2630 
   2631         Returns:
   2632             Downlink NRB
   2633         """
   2634         cmd = "DLNRB? " + self._bts_number
   2635         return self._anritsu.send_query(cmd)
   2636 
   2637     @nrb_dl.setter
   2638     def nrb_dl(self, blocks):
   2639         """ Sets the Downlink N Resource Block of the cell
   2640 
   2641         Args:
   2642             blocks: Downlink N Resource Block of the cell
   2643 
   2644         Returns:
   2645             None
   2646         """
   2647         cmd = "DLNRB {},{}".format(blocks, self._bts_number)
   2648         self._anritsu.send_command(cmd)
   2649 
   2650     @property
   2651     def nrb_ul(self):
   2652         """ Gets the uplink N Resource Block of the cell
   2653 
   2654         Args:
   2655             None
   2656 
   2657         Returns:
   2658             uplink NRB
   2659         """
   2660         cmd = "ULNRB? " + self._bts_number
   2661         return self._anritsu.send_query(cmd)
   2662 
   2663     @nrb_ul.setter
   2664     def nrb_ul(self, blocks):
   2665         """ Sets the uplink N Resource Block of the cell
   2666 
   2667         Args:
   2668             blocks: uplink N Resource Block of the cell
   2669 
   2670         Returns:
   2671             None
   2672         """
   2673         cmd = "ULNRB {},{}".format(blocks, self._bts_number)
   2674         self._anritsu.send_command(cmd)
   2675 
   2676     @property
   2677     def neighbor_cell_mode(self):
   2678         """ Gets the neighbor cell mode
   2679 
   2680         Args:
   2681             None
   2682 
   2683         Returns:
   2684             current neighbor cell mode
   2685         """
   2686         cmd = "NCLIST? " + self._bts_number
   2687         return self._anritsu.send_query(cmd)
   2688 
   2689     @neighbor_cell_mode.setter
   2690     def neighbor_cell_mode(self, mode):
   2691         """ Sets the neighbor cell mode
   2692 
   2693         Args:
   2694             mode: neighbor cell mode , DEFAULT/ USERDATA
   2695 
   2696         Returns:
   2697             None
   2698         """
   2699         cmd = "NCLIST {},{}".format(mode, self._bts_number)
   2700         self._anritsu.send_command(cmd)
   2701 
   2702     def get_neighbor_cell_type(self, system, index):
   2703         """ Gets the neighbor cell type
   2704 
   2705         Args:
   2706             system: simulation model of neighbor cell
   2707                     LTE, WCDMA, TDSCDMA, GSM, CDMA1X,EVDO
   2708             index: Index of neighbor cell
   2709 
   2710         Returns:
   2711             neighbor cell type
   2712         """
   2713         cmd = "NCTYPE? {},{},{}".format(system, index, self._bts_number)
   2714         return self._anritsu.send_query(cmd)
   2715 
   2716     def set_neighbor_cell_type(self, system, index, cell_type):
   2717         """ Sets the neighbor cell type
   2718 
   2719         Args:
   2720             system: simulation model of neighbor cell
   2721                    LTE, WCDMA, TDSCDMA, GSM, CDMA1X,EVDO
   2722             index: Index of neighbor cell
   2723             cell_type: cell type
   2724                 BTS1, BTS2, BTS3, BTS4,CELLNAME, DISABLE
   2725 
   2726         Returns:
   2727             None
   2728         """
   2729         cmd = "NCTYPE {},{},{},{}".format(system, index, cell_type,
   2730                                           self._bts_number)
   2731         self._anritsu.send_command(cmd)
   2732 
   2733     def get_neighbor_cell_name(self, system, index):
   2734         """ Gets the neighbor cell name
   2735 
   2736         Args:
   2737             system: simulation model of neighbor cell
   2738                     LTE, WCDMA, TDSCDMA, GSM, CDMA1X,EVDO
   2739             index: Index of neighbor cell
   2740 
   2741         Returns:
   2742             neighbor cell name
   2743         """
   2744         cmd = "NCCELLNAME? {},{},{}".format(system, index, self._bts_number)
   2745         return self._anritsu.send_query(cmd)
   2746 
   2747     def set_neighbor_cell_name(self, system, index, name):
   2748         """ Sets the neighbor cell name
   2749 
   2750         Args:
   2751             system: simulation model of neighbor cell
   2752                    LTE, WCDMA, TDSCDMA, GSM, CDMA1X,EVDO
   2753             index: Index of neighbor cell
   2754             name: cell name
   2755 
   2756         Returns:
   2757             None
   2758         """
   2759         cmd = "NCCELLNAME {},{},{},{}".format(system, index, name,
   2760                                               self._bts_number)
   2761         self._anritsu.send_command(cmd)
   2762 
   2763     def get_neighbor_cell_mcc(self, system, index):
   2764         """ Gets the neighbor cell mcc
   2765 
   2766         Args:
   2767             system: simulation model of neighbor cell
   2768                     LTE, WCDMA, TDSCDMA, GSM, CDMA1X,EVDO
   2769             index: Index of neighbor cell
   2770 
   2771         Returns:
   2772             neighbor cell mcc
   2773         """
   2774         cmd = "NCMCC? {},{},{}".format(system, index, self._bts_number)
   2775         return self._anritsu.send_query(cmd)
   2776 
   2777     def get_neighbor_cell_mnc(self, system, index):
   2778         """ Gets the neighbor cell mnc
   2779 
   2780         Args:
   2781             system: simulation model of neighbor cell
   2782                     LTE, WCDMA, TDSCDMA, GSM, CDMA1X,EVDO
   2783             index: Index of neighbor cell
   2784 
   2785         Returns:
   2786             neighbor cell mnc
   2787         """
   2788         cmd = "NCMNC? {},{},{}".format(system, index, self._bts_number)
   2789         return self._anritsu.send_query(cmd)
   2790 
   2791     def get_neighbor_cell_id(self, system, index):
   2792         """ Gets the neighbor cell id
   2793 
   2794         Args:
   2795             system: simulation model of neighbor cell
   2796                     LTE, WCDMA, TDSCDMA, GSM, CDMA1X,EVDO
   2797             index: Index of neighbor cell
   2798 
   2799         Returns:
   2800             neighbor cell id
   2801         """
   2802         cmd = "NCCELLID? {},{},{}".format(system, index, self._bts_number)
   2803         return self._anritsu.send_query(cmd)
   2804 
   2805     def get_neighbor_cell_tac(self, system, index):
   2806         """ Gets the neighbor cell tracking area code
   2807 
   2808         Args:
   2809             system: simulation model of neighbor cell
   2810                     LTE, WCDMA, TDSCDMA, GSM, CDMA1X,EVDO
   2811             index: Index of neighbor cell
   2812 
   2813         Returns:
   2814             neighbor cell tracking area code
   2815         """
   2816         cmd = "NCTAC? {},{},{}".format(system, index, self._bts_number)
   2817         return self._anritsu.send_query(cmd)
   2818 
   2819     def get_neighbor_cell_dl_channel(self, system, index):
   2820         """ Gets the neighbor cell downlink channel
   2821 
   2822         Args:
   2823             system: simulation model of neighbor cell
   2824                     LTE, WCDMA, TDSCDMA, GSM, CDMA1X,EVDO
   2825             index: Index of neighbor cell
   2826 
   2827         Returns:
   2828             neighbor cell tracking downlink channel
   2829         """
   2830         cmd = "NCDLCHAN? {},{},{}".format(system, index, self._bts_number)
   2831         return self._anritsu.send_query(cmd)
   2832 
   2833     def get_neighbor_cell_dl_bandwidth(self, system, index):
   2834         """ Gets the neighbor cell downlink bandwidth
   2835 
   2836         Args:
   2837             system: simulation model of neighbor cell
   2838                     LTE, WCDMA, TDSCDMA, GSM, CDMA1X,EVDO
   2839             index: Index of neighbor cell
   2840 
   2841         Returns:
   2842             neighbor cell tracking downlink bandwidth
   2843         """
   2844         cmd = "NCDLBANDWIDTH {},{},{}".format(system, index, self._bts_number)
   2845         return self._anritsu.send_query(cmd)
   2846 
   2847     def get_neighbor_cell_pcid(self, system, index):
   2848         """ Gets the neighbor cell physical cell id
   2849 
   2850         Args:
   2851             system: simulation model of neighbor cell
   2852                     LTE, WCDMA, TDSCDMA, GSM, CDMA1X,EVDO
   2853             index: Index of neighbor cell
   2854 
   2855         Returns:
   2856             neighbor cell physical cell id
   2857         """
   2858         cmd = "NCPHYCELLID {},{},{}".format(system, index, self._bts_number)
   2859         return self._anritsu.send_query(cmd)
   2860 
   2861     def get_neighbor_cell_lac(self, system, index):
   2862         """ Gets the neighbor cell location area code
   2863 
   2864         Args:
   2865             system: simulation model of neighbor cell
   2866                     LTE, WCDMA, TDSCDMA, GSM, CDMA1X,EVDO
   2867             index: Index of neighbor cell
   2868 
   2869         Returns:
   2870             neighbor cell location area code
   2871         """
   2872         cmd = "NCLAC {},{},{}".format(system, index, self._bts_number)
   2873         return self._anritsu.send_query(cmd)
   2874 
   2875     def get_neighbor_cell_rac(self, system, index):
   2876         """ Gets the neighbor cell routing area code
   2877 
   2878         Args:
   2879             system: simulation model of neighbor cell
   2880                     LTE, WCDMA, TDSCDMA, GSM, CDMA1X,EVDO
   2881             index: Index of neighbor cell
   2882 
   2883         Returns:
   2884             neighbor cell routing area code
   2885         """
   2886         cmd = "NCRAC {},{},{}".format(system, index, self._bts_number)
   2887         return self._anritsu.send_query(cmd)
   2888 
   2889     @property
   2890     def primary_scrambling_code(self):
   2891         """ Gets the primary scrambling code for WCDMA cell
   2892 
   2893         Args:
   2894             None
   2895 
   2896         Returns:
   2897             primary scrambling code
   2898         """
   2899         cmd = "PRISCRCODE? " + self._bts_number
   2900         return self._anritsu.send_query(cmd)
   2901 
   2902     @primary_scrambling_code.setter
   2903     def primary_scrambling_code(self, psc):
   2904         """ Sets the primary scrambling code for WCDMA cell
   2905 
   2906         Args:
   2907             psc: primary scrambling code
   2908 
   2909         Returns:
   2910             None
   2911         """
   2912         cmd = "PRISCRCODE {},{}".format(psc, self._bts_number)
   2913         self._anritsu.send_command(cmd)
   2914 
   2915     @property
   2916     def tac(self):
   2917         """ Gets the Tracking Area Code of the LTE cell
   2918 
   2919         Args:
   2920             None
   2921 
   2922         Returns:
   2923             Tracking Area Code of the LTE cell
   2924         """
   2925         cmd = "TAC? " + self._bts_number
   2926         return self._anritsu.send_query(cmd)
   2927 
   2928     @tac.setter
   2929     def tac(self, tac):
   2930         """ Sets the Tracking Area Code of the LTE cell
   2931 
   2932         Args:
   2933             tac: Tracking Area Code of the LTE cell
   2934 
   2935         Returns:
   2936             None
   2937         """
   2938         cmd = "TAC {},{}".format(tac, self._bts_number)
   2939         self._anritsu.send_command(cmd)
   2940 
   2941     @property
   2942     def cell(self):
   2943         """ Gets the current cell for BTS
   2944 
   2945         Args:
   2946             None
   2947 
   2948         Returns:
   2949             current cell for BTS
   2950         """
   2951         cmd = "CELLSEL? {}".format(self._bts_number)
   2952         return self._anritsu.send_query(cmd)
   2953 
   2954     @cell.setter
   2955     def cell(self, cell_name):
   2956         """ sets the  cell for BTS
   2957         Args:
   2958             cell_name: cell name
   2959 
   2960         Returns:
   2961             None
   2962         """
   2963         cmd = "CELLSEL {},{}".format(self._bts_number, cell_name)
   2964         return self._anritsu.send_command(cmd)
   2965 
   2966     @property
   2967     def gsm_cbch(self):
   2968         """ Gets the GSM CBCH enable/disable status
   2969 
   2970         Args:
   2971             None
   2972 
   2973         Returns:
   2974             one of CBCHSetup values
   2975         """
   2976         cmd = "CBCHPARAMSETUP? " + self._bts_number
   2977         return self._anritsu.send_query(cmd)
   2978 
   2979     @gsm_cbch.setter
   2980     def gsm_cbch(self, enable):
   2981         """ Sets the GSM CBCH enable/disable status
   2982 
   2983         Args:
   2984             enable: GSM CBCH enable/disable status
   2985 
   2986         Returns:
   2987             None
   2988         """
   2989         cmd = "CBCHPARAMSETUP {},{}".format(enable.value, self._bts_number)
   2990         self._anritsu.send_command(cmd)
   2991 
   2992 
   2993 class _VirtualPhone(object):
   2994     '''Class to interact with virtual phone supported by MD8475 '''
   2995 
   2996     def __init__(self, anritsu):
   2997         self._anritsu = anritsu
   2998         self.log = anritsu.log
   2999 
   3000     @property
   3001     def id(self):
   3002         """ Gets the virtual phone ID
   3003 
   3004         Args:
   3005             None
   3006 
   3007         Returns:
   3008             virtual phone ID
   3009         """
   3010         cmd = "VPID? "
   3011         return self._anritsu.send_query(cmd)
   3012 
   3013     @id.setter
   3014     def id(self, phonenumber):
   3015         """ Sets the virtual phone ID
   3016 
   3017         Args:
   3018             phonenumber: virtual phone ID
   3019 
   3020         Returns:
   3021             None
   3022         """
   3023         cmd = "VPID {}".format(phonenumber)
   3024         self._anritsu.send_command(cmd)
   3025 
   3026     @property
   3027     def id_c2k(self):
   3028         """ Gets the virtual phone ID for CDMA 1x
   3029 
   3030         Args:
   3031             None
   3032 
   3033         Returns:
   3034             virtual phone ID
   3035         """
   3036         cmd = "VPIDC2K? "
   3037         return self._anritsu.send_query(cmd)
   3038 
   3039     @id_c2k.setter
   3040     def id_c2k(self, phonenumber):
   3041         """ Sets the virtual phone ID for CDMA 1x
   3042 
   3043         Args:
   3044             phonenumber: virtual phone ID
   3045 
   3046         Returns:
   3047             None
   3048         """
   3049         cmd = "VPIDC2K {}".format(phonenumber)
   3050         self._anritsu.send_command(cmd)
   3051 
   3052     @property
   3053     def auto_answer(self):
   3054         """ Gets the auto answer status of virtual phone
   3055 
   3056         Args:
   3057             None
   3058 
   3059         Returns:
   3060             auto answer status, ON/OFF
   3061         """
   3062         cmd = "VPAUTOANSWER? "
   3063         return self._anritsu.send_query(cmd)
   3064 
   3065     @auto_answer.setter
   3066     def auto_answer(self, option):
   3067         """ Sets the auto answer feature
   3068 
   3069         Args:
   3070             option: tuple with two items for turning on Auto Answer
   3071                     (OFF or (ON, timetowait))
   3072 
   3073         Returns:
   3074             None
   3075         """
   3076         enable = "OFF"
   3077         time = 5
   3078 
   3079         try:
   3080             enable, time = option
   3081         except ValueError:
   3082             if enable != "OFF":
   3083                 raise ValueError("Pass a tuple with two items for"
   3084                                  " Turning on Auto Answer")
   3085         cmd = "VPAUTOANSWER {},{}".format(enable.value, time)
   3086         self._anritsu.send_command(cmd)
   3087 
   3088     @property
   3089     def calling_mode(self):
   3090         """ Gets the calling mode of virtual phone
   3091 
   3092         Args:
   3093             None
   3094 
   3095         Returns:
   3096             calling mode of virtual phone
   3097         """
   3098         cmd = "VPCALLINGMODE? "
   3099         return self._anritsu.send_query(cmd)
   3100 
   3101     @calling_mode.setter
   3102     def calling_mode(self, calling_mode):
   3103         """ Sets the calling mode of virtual phone
   3104 
   3105         Args:
   3106             calling_mode: calling mode of virtual phone
   3107 
   3108         Returns:
   3109             None
   3110         """
   3111         cmd = "VPCALLINGMODE {}".format(calling_mode)
   3112         self._anritsu.send_command(cmd)
   3113 
   3114     def set_voice_off_hook(self):
   3115         """ Set the virtual phone operating mode to Voice Off Hook
   3116 
   3117         Args:
   3118             None
   3119 
   3120         Returns:
   3121             None
   3122         """
   3123         cmd = "OPERATEVPHONE 0"
   3124         return self._anritsu.send_command(cmd)
   3125 
   3126     def set_voice_on_hook(self):
   3127         """ Set the virtual phone operating mode to Voice On Hook
   3128 
   3129         Args:
   3130             None
   3131 
   3132         Returns:
   3133             None
   3134         """
   3135         cmd = "OPERATEVPHONE 1"
   3136         return self._anritsu.send_command(cmd)
   3137 
   3138     def set_video_off_hook(self):
   3139         """ Set the virtual phone operating mode to Video Off Hook
   3140 
   3141         Args:
   3142             None
   3143 
   3144         Returns:
   3145             None
   3146         """
   3147         cmd = "OPERATEVPHONE 2"
   3148         return self._anritsu.send_command(cmd)
   3149 
   3150     def set_video_on_hook(self):
   3151         """ Set the virtual phone operating mode to Video On Hook
   3152 
   3153         Args:
   3154             None
   3155 
   3156         Returns:
   3157             None
   3158         """
   3159         cmd = "OPERATEVPHONE 3"
   3160         return self._anritsu.send_command(cmd)
   3161 
   3162     def set_call_waiting(self):
   3163         """ Set the virtual phone operating mode to Call waiting
   3164 
   3165         Args:
   3166             None
   3167 
   3168         Returns:
   3169             None
   3170         """
   3171         cmd = "OPERATEVPHONE 4"
   3172         return self._anritsu.send_command(cmd)
   3173 
   3174     @property
   3175     def status(self):
   3176         """ Gets the virtual phone status
   3177 
   3178         Args:
   3179             None
   3180 
   3181         Returns:
   3182             virtual phone status
   3183         """
   3184         cmd = "VPSTAT?"
   3185         status = self._anritsu.send_query(cmd)
   3186         return _VP_STATUS[status]
   3187 
   3188     def sendSms(self, phoneNumber, message):
   3189         """ Sends the SMS data from Anritsu to UE
   3190 
   3191         Args:
   3192             phoneNumber: sender of SMS
   3193             message: message text
   3194 
   3195         Returns:
   3196             None
   3197         """
   3198         cmd = ("SENDSMS /?PhoneNumber=001122334455&Sender={}&Text={}"
   3199                "&DCS=00").format(phoneNumber, AnritsuUtils.gsm_encode(message))
   3200         return self._anritsu.send_command(cmd)
   3201 
   3202     def sendSms_c2k(self, phoneNumber, message):
   3203         """ Sends the SMS data from Anritsu to UE (in CDMA)
   3204 
   3205         Args:
   3206             phoneNumber: sender of SMS
   3207             message: message text
   3208 
   3209         Returns:
   3210             None
   3211         """
   3212         cmd = ("C2KSENDSMS System=CDMA\&Originating_Address={}\&UserData={}"
   3213                ).format(phoneNumber, AnritsuUtils.cdma_encode(message))
   3214         return self._anritsu.send_command(cmd)
   3215 
   3216     def receiveSms(self):
   3217         """ Receives SMS messages sent by the UE in an external application
   3218 
   3219         Args:
   3220             None
   3221 
   3222         Returns:
   3223             None
   3224         """
   3225         return self._anritsu.send_query("RECEIVESMS?")
   3226 
   3227     def receiveSms_c2k(self):
   3228         """ Receives SMS messages sent by the UE(in CDMA) in an external application
   3229 
   3230         Args:
   3231             None
   3232 
   3233         Returns:
   3234             None
   3235         """
   3236         return self._anritsu.send_query("C2KRECEIVESMS?")
   3237 
   3238     def setSmsStatusReport(self, status):
   3239         """ Set the Status Report value of the SMS
   3240 
   3241         Args:
   3242             status: status code
   3243 
   3244         Returns:
   3245             None
   3246         """
   3247         cmd = "SMSSTATUSREPORT {}".format(status)
   3248         return self._anritsu.send_command(cmd)
   3249 
   3250 
   3251 class _PacketDataNetwork(object):
   3252     '''Class to configure PDN parameters'''
   3253 
   3254     def __init__(self, anritsu, pdnnumber):
   3255         self._pdn_number = pdnnumber
   3256         self._anritsu = anritsu
   3257         self.log = anritsu.log
   3258 
   3259     @property
   3260     def ue_address_iptype(self):
   3261         """ Gets IP type of UE for particular PDN
   3262 
   3263         Args:
   3264             None
   3265 
   3266         Returns:
   3267             IP type of UE for particular PDN
   3268         """
   3269         cmd = "PDNIPTYPE? " + self._pdn_number
   3270         return self._anritsu.send_query(cmd)
   3271 
   3272     @ue_address_iptype.setter
   3273     def ue_address_iptype(self, ip_type):
   3274         """ Set IP type of UE for particular PDN
   3275 
   3276         Args:
   3277             ip_type: IP type of UE
   3278 
   3279         Returns:
   3280             None
   3281         """
   3282         if not isinstance(ip_type, IPAddressType):
   3283             raise ValueError(
   3284                 ' The parameter should be of type "IPAddressType"')
   3285         cmd = "PDNIPTYPE {},{}".format(self._pdn_number, ip_type.value)
   3286         self._anritsu.send_command(cmd)
   3287 
   3288     @property
   3289     def ue_address_ipv4(self):
   3290         """ Gets UE IPv4 address
   3291 
   3292         Args:
   3293             None
   3294 
   3295         Returns:
   3296             UE IPv4 address
   3297         """
   3298         cmd = "PDNIPV4? " + self._pdn_number
   3299         return self._anritsu.send_query(cmd)
   3300 
   3301     @ue_address_ipv4.setter
   3302     def ue_address_ipv4(self, ip_address):
   3303         """ Set UE IPv4 address
   3304 
   3305         Args:
   3306             ip_address: UE IPv4 address
   3307 
   3308         Returns:
   3309             None
   3310         """
   3311         cmd = "PDNIPV4 {},{}".format(self._pdn_number, ip_address)
   3312         self._anritsu.send_command(cmd)
   3313 
   3314     @property
   3315     def ue_address_ipv6(self):
   3316         """ Gets UE IPv6 address
   3317 
   3318         Args:
   3319             None
   3320 
   3321         Returns:
   3322             UE IPv6 address
   3323         """
   3324         cmd = "PDNIPV6? " + self._pdn_number
   3325         return self._anritsu.send_query(cmd)
   3326 
   3327     @ue_address_ipv6.setter
   3328     def ue_address_ipv6(self, ip_address):
   3329         """ Set UE IPv6 address
   3330 
   3331         Args:
   3332             ip_address: UE IPv6 address
   3333 
   3334         Returns:
   3335             None
   3336         """
   3337         cmd = "PDNIPV6 {},{}".format(self._pdn_number, ip_address)
   3338         self._anritsu.send_command(cmd)
   3339 
   3340     @property
   3341     def primary_dns_address_ipv4(self):
   3342         """ Gets Primary DNS server IPv4 address
   3343 
   3344         Args:
   3345             None
   3346 
   3347         Returns:
   3348             Primary DNS server IPv4 address
   3349         """
   3350         cmd = "PDNDNSIPV4PRI? " + self._pdn_number
   3351         return self._anritsu.send_query(cmd)
   3352 
   3353     @primary_dns_address_ipv4.setter
   3354     def primary_dns_address_ipv4(self, ip_address):
   3355         """ Set Primary DNS server IPv4 address
   3356 
   3357         Args:
   3358             ip_address: Primary DNS server IPv4 address
   3359 
   3360         Returns:
   3361             None
   3362         """
   3363         cmd = "PDNDNSIPV4PRI {},{}".format(self._pdn_number, ip_address)
   3364         self._anritsu.send_command(cmd)
   3365 
   3366     @property
   3367     def secondary_dns_address_ipv4(self):
   3368         """ Gets secondary DNS server IPv4 address
   3369 
   3370         Args:
   3371             None
   3372 
   3373         Returns:
   3374             secondary DNS server IPv4 address
   3375         """
   3376         cmd = "PDNDNSIPV4SEC? " + self._pdn_number
   3377         return self._anritsu.send_query(cmd)
   3378 
   3379     @secondary_dns_address_ipv4.setter
   3380     def secondary_dns_address_ipv4(self, ip_address):
   3381         """ Set secondary DNS server IPv4 address
   3382 
   3383         Args:
   3384             ip_address: secondary DNS server IPv4 address
   3385 
   3386         Returns:
   3387             None
   3388         """
   3389         cmd = "PDNDNSIPV4SEC {},{}".format(self._pdn_number, ip_address)
   3390         self._anritsu.send_command(cmd)
   3391 
   3392     @property
   3393     def dns_address_ipv6(self):
   3394         """ Gets DNS server IPv6 address
   3395 
   3396         Args:
   3397             None
   3398 
   3399         Returns:
   3400             DNS server IPv6 address
   3401         """
   3402         cmd = "PDNDNSIPV6? " + self._pdn_number
   3403         return self._anritsu.send_query(cmd)
   3404 
   3405     @dns_address_ipv6.setter
   3406     def dns_address_ipv6(self, ip_address):
   3407         """ Set DNS server IPv6 address
   3408 
   3409         Args:
   3410             ip_address: DNS server IPv6 address
   3411 
   3412         Returns:
   3413             None
   3414         """
   3415         cmd = "PDNDNSIPV6 {},{}".format(self._pdn_number, ip_address)
   3416         self._anritsu.send_command(cmd)
   3417 
   3418     @property
   3419     def cscf_address_ipv4(self):
   3420         """ Gets Secondary P-CSCF IPv4 address
   3421 
   3422         Args:
   3423             None
   3424 
   3425         Returns:
   3426             Secondary P-CSCF IPv4 address
   3427         """
   3428         cmd = "PDNPCSCFIPV4? " + self._pdn_number
   3429         return self._anritsu.send_query(cmd)
   3430 
   3431     @cscf_address_ipv4.setter
   3432     def cscf_address_ipv4(self, ip_address):
   3433         """ Set Secondary P-CSCF IPv4 address
   3434 
   3435         Args:
   3436             ip_address: Secondary P-CSCF IPv4 address
   3437 
   3438         Returns:
   3439             None
   3440         """
   3441         cmd = "PDNPCSCFIPV4 {},{}".format(self._pdn_number, ip_address)
   3442         self._anritsu.send_command(cmd)
   3443 
   3444     @property
   3445     def cscf_address_ipv6(self):
   3446         """ Gets P-CSCF IPv6 address
   3447 
   3448         Args:
   3449             None
   3450 
   3451         Returns:
   3452             P-CSCF IPv6 address
   3453         """
   3454         cmd = "PDNPCSCFIPV6? " + self._pdn_number
   3455         return self._anritsu.send_query(cmd)
   3456 
   3457     @cscf_address_ipv6.setter
   3458     def cscf_address_ipv6(self, ip_address):
   3459         """ Set P-CSCF IPv6 address
   3460 
   3461         Args:
   3462             ip_address: P-CSCF IPv6 address
   3463 
   3464         Returns:
   3465             None
   3466         """
   3467         cmd = "PDNPCSCFIPV6 {},{}".format(self._pdn_number, ip_address)
   3468         self._anritsu.send_command(cmd)
   3469 
   3470     @property
   3471     def pdn_ims(self):
   3472         """ Get PDN IMS VNID binding status
   3473 
   3474         Args:
   3475             None
   3476 
   3477         Returns:
   3478             PDN IMS VNID binding status
   3479         """
   3480         cmd = "PDNIMS? " + self._pdn_number
   3481         return self._anritsu.send_query(cmd)
   3482 
   3483     @pdn_ims.setter
   3484     def pdn_ims(self, switch):
   3485         """ Set PDN IMS VNID binding Enable/Disable
   3486 
   3487         Args:
   3488             switch: "ENABLE/DISABLE"
   3489 
   3490         Returns:
   3491             None
   3492         """
   3493         if not isinstance(switch, Switch):
   3494             raise ValueError(' The parameter should be of type'
   3495                              ' "Switch", ie, ENABLE or DISABLE ')
   3496         cmd = "PDNIMS {},{}".format(self._pdn_number, switch.value)
   3497         self._anritsu.send_command(cmd)
   3498 
   3499     @property
   3500     def pdn_vnid(self):
   3501         """ Get PDN IMS VNID
   3502 
   3503         Args:
   3504             None
   3505 
   3506         Returns:
   3507             PDN IMS VNID
   3508         """
   3509         cmd = "PDNVNID? " + self._pdn_number
   3510         return self._anritsu.send_query(cmd)
   3511 
   3512     @pdn_vnid.setter
   3513     def pdn_vnid(self, vnid):
   3514         """ Set PDN IMS VNID
   3515 
   3516         Args:
   3517             vnid: 1~99
   3518 
   3519         Returns:
   3520             None
   3521         """
   3522         cmd = "PDNVNID {},{}".format(self._pdn_number, vnid)
   3523         self._anritsu.send_command(cmd)
   3524 
   3525     @property
   3526     def pdn_apn_name(self):
   3527         """ Get PDN APN NAME
   3528 
   3529         Args:
   3530             None
   3531 
   3532         Returns:
   3533             PDN APN NAME
   3534         """
   3535         cmd = "PDNCHECKAPN? " + self._pdn_number
   3536         return self._anritsu.send_query(cmd)
   3537 
   3538     @pdn_apn_name.setter
   3539     def pdn_apn_name(self, name):
   3540         """ Set PDN APN NAME
   3541 
   3542         Args:
   3543             name: fast.t-mobile.com, ims
   3544 
   3545         Returns:
   3546             None
   3547         """
   3548         cmd = "PDNCHECKAPN {},{}".format(self._pdn_number, name)
   3549         self._anritsu.send_command(cmd)
   3550 
   3551     @property
   3552     def pdn_qci(self):
   3553         """ Get PDN QCI Value
   3554 
   3555         Args:
   3556             None
   3557 
   3558         Returns:
   3559             PDN QCI Value
   3560         """
   3561         cmd = "PDNQCIDEFAULT? " + self._pdn_number
   3562         return self._anritsu.send_query(cmd)
   3563 
   3564     @pdn_qci.setter
   3565     def pdn_qci(self, qci_value):
   3566         """ Set PDN QCI Value
   3567 
   3568         Args:
   3569             qci_value: 5, 9
   3570 
   3571         Returns:
   3572             None
   3573         """
   3574         cmd = "PDNQCIDEFAULT {},{}".format(self._pdn_number, qci_value)
   3575         self._anritsu.send_command(cmd)
   3576 
   3577 
   3578 class _TriggerMessage(object):
   3579     '''Class to interact with trigger message handling supported by MD8475 '''
   3580 
   3581     def __init__(self, anritsu):
   3582         self._anritsu = anritsu
   3583         self.log = anritsu.log
   3584 
   3585     def set_reply_type(self, message_id, reply_type):
   3586         """ Sets the reply type of the trigger information
   3587 
   3588         Args:
   3589             message_id: trigger information message Id
   3590             reply_type: reply type of the trigger information
   3591 
   3592         Returns:
   3593             None
   3594         """
   3595         if not isinstance(message_id, TriggerMessageIDs):
   3596             raise ValueError(' The parameter should be of type'
   3597                              ' "TriggerMessageIDs"')
   3598         if not isinstance(reply_type, TriggerMessageReply):
   3599             raise ValueError(' The parameter should be of type'
   3600                              ' "TriggerMessageReply"')
   3601 
   3602         cmd = "REJECTTYPE {},{}".format(message_id.value, reply_type.value)
   3603         self._anritsu.send_command(cmd)
   3604 
   3605     def set_reject_cause(self, message_id, cause):
   3606         """ Sets the reject cause of the trigger information
   3607 
   3608         Args:
   3609             message_id: trigger information message Id
   3610             cause: cause for reject
   3611 
   3612         Returns:
   3613             None
   3614         """
   3615         if not isinstance(message_id, TriggerMessageIDs):
   3616             raise ValueError(' The parameter should be of type'
   3617                              ' "TriggerMessageIDs"')
   3618 
   3619         cmd = "REJECTCAUSE {},{}".format(message_id.value, cause)
   3620         self._anritsu.send_command(cmd)
   3621 
   3622 
   3623 class _IMS_Services(object):
   3624     '''Class to configure and operate IMS Services'''
   3625 
   3626     def __init__(self, anritsu, vnid):
   3627         self._vnid = vnid
   3628         self._anritsu = anritsu
   3629         self.log = anritsu.log
   3630 
   3631     @property
   3632     def sync(self):
   3633         """ Gets Sync Enable status
   3634 
   3635         Args:
   3636             None
   3637 
   3638         Returns:
   3639             VNID Sync Enable status
   3640         """
   3641         cmd = "IMSSYNCENABLE? " + self._vnid
   3642         return self._anritsu.send_query(cmd)
   3643 
   3644     @sync.setter
   3645     def sync(self, switch):
   3646         """ Set Sync Enable or Disable
   3647 
   3648         Args:
   3649             sync: ENABLE/DISABLE
   3650 
   3651         Returns:
   3652             None
   3653         """
   3654         if not isinstance(switch, Switch):
   3655             raise ValueError(' The parameter should be of type "Switch"')
   3656         cmd = "IMSSYNCENABLE {},{}".format(self._vnid, switch.value)
   3657         self._anritsu.send_command(cmd)
   3658 
   3659     @property
   3660     def cscf_address_ipv4(self):
   3661         """ Gets CSCF IPv4 address
   3662 
   3663         Args:
   3664             None
   3665 
   3666         Returns:
   3667             CSCF IPv4 address
   3668         """
   3669         cmd = "IMSCSCFIPV4? " + self._vnid
   3670         return self._anritsu.send_query(cmd)
   3671 
   3672     @cscf_address_ipv4.setter
   3673     def cscf_address_ipv4(self, ip_address):
   3674         """ Set CSCF IPv4 address
   3675 
   3676         Args:
   3677             ip_address: CSCF IPv4 address
   3678 
   3679         Returns:
   3680             None
   3681         """
   3682         cmd = "IMSCSCFIPV4 {},{}".format(self._vnid, ip_address)
   3683         self._anritsu.send_command(cmd)
   3684 
   3685     @property
   3686     def cscf_address_ipv6(self):
   3687         """ Gets CSCF IPv6 address
   3688 
   3689         Args:
   3690             None
   3691 
   3692         Returns:
   3693             CSCF IPv6 address
   3694         """
   3695         cmd = "IMSCSCFIPV6? " + self._vnid
   3696         return self._anritsu.send_query(cmd)
   3697 
   3698     @cscf_address_ipv6.setter
   3699     def cscf_address_ipv6(self, ip_address):
   3700         """ Set CSCF IPv6 address
   3701 
   3702         Args:
   3703             ip_address: CSCF IPv6 address
   3704 
   3705         Returns:
   3706             None
   3707         """
   3708         cmd = "IMSCSCFIPV6 {},{}".format(self._vnid, ip_address)
   3709         self._anritsu.send_command(cmd)
   3710 
   3711     @property
   3712     def imscscf_iptype(self):
   3713         """ Gets CSCF IP Type
   3714 
   3715         Args:
   3716             None
   3717 
   3718         Returns:
   3719             CSCF IP Type
   3720         """
   3721         cmd = "IMSCSCFIPTYPE? " + self._vnid
   3722         return self._anritsu.send_query(cmd)
   3723 
   3724     @imscscf_iptype.setter
   3725     def imscscf_iptype(self, iptype):
   3726         """ Set CSCF IP Type
   3727 
   3728         Args:
   3729             iptype: IPV4, IPV6, IPV4V6
   3730 
   3731         Returns:
   3732             None
   3733         """
   3734         cmd = "IMSCSCFIPTYPE {},{}".format(self._vnid, iptype)
   3735         self._anritsu.send_command(cmd)
   3736 
   3737     @property
   3738     def cscf_monitoring_ua(self):
   3739         """ Get CSCF Monitoring UA URI
   3740 
   3741         Args:
   3742             None
   3743 
   3744         Returns:
   3745             CSCF Monitoring UA URI
   3746         """
   3747         cmd = "IMSCSCFUAURI? " + self._vnid
   3748         return self._anritsu.send_query(cmd)
   3749 
   3750     @cscf_monitoring_ua.setter
   3751     def cscf_monitoring_ua(self, ua_uri):
   3752         """ Set CSCF Monitoring UA URI
   3753 
   3754         Args:
   3755             ua_uri: CSCF Monitoring UA URI
   3756 
   3757         Returns:
   3758             None
   3759         """
   3760         cmd = "IMSCSCFUAURI {},{}".format(self._vnid, ua_uri)
   3761         self._anritsu.send_command(cmd)
   3762 
   3763     @property
   3764     def cscf_host_name(self):
   3765         """ Get CSCF Host Name
   3766 
   3767         Args:
   3768             None
   3769 
   3770         Returns:
   3771             CSCF Host Name
   3772         """
   3773         cmd = "IMSCSCFNAME? " + self._vnid
   3774         return self._anritsu.send_query(cmd)
   3775 
   3776     @cscf_host_name.setter
   3777     def cscf_host_name(self, host_name):
   3778         """ Set CSCF Host Name
   3779 
   3780         Args:
   3781             host_name: CSCF Host Name
   3782 
   3783         Returns:
   3784             None
   3785         """
   3786         cmd = "IMSCSCFNAME {},{}".format(self._vnid, host_name)
   3787         self._anritsu.send_command(cmd)
   3788 
   3789     @property
   3790     def cscf_ims_authentication(self):
   3791         """ Get CSCF IMS Auth Value
   3792 
   3793         Args:
   3794             None
   3795 
   3796         Returns:
   3797             CSCF IMS Auth
   3798         """
   3799         cmd = "IMSCSCFAUTH? " + self._vnid
   3800         return self._anritsu.send_query(cmd)
   3801 
   3802     @cscf_ims_authentication.setter
   3803     def cscf_ims_authentication(self, on_off):
   3804         """ Set CSCF IMS Auth Value
   3805 
   3806         Args:
   3807             on_off: CSCF IMS Auth ENABLE/DISABLE
   3808 
   3809         Returns:
   3810             None
   3811         """
   3812         cmd = "IMSCSCFAUTH {},{}".format(self._vnid, on_off)
   3813         self._anritsu.send_command(cmd)
   3814 
   3815     @property
   3816     def cscf_virtual_ua(self):
   3817         """ Get CSCF Virtual UA URI
   3818 
   3819         Args:
   3820             None
   3821 
   3822         Returns:
   3823             CSCF Virtual UA URI
   3824         """
   3825         cmd = "IMSCSCFVUAURI? " + self._vnid
   3826         return self._anritsu.send_query(cmd)
   3827 
   3828     @cscf_virtual_ua.setter
   3829     def cscf_virtual_ua(self, ua_uri):
   3830         """ Set CSCF Virtual UA URI
   3831 
   3832         Args:
   3833             ua_uri: CSCF Virtual UA URI
   3834 
   3835         Returns:
   3836             None
   3837         """
   3838         cmd = "IMSCSCFVUAURI {},{}".format(self._vnid, ua_uri)
   3839         self._anritsu.send_command(cmd)
   3840 
   3841     @property
   3842     def tmo_cscf_userslist_add(self):
   3843         """ Get CSCF USERLIST
   3844 
   3845         Args:
   3846             None
   3847 
   3848         Returns:
   3849             CSCF USERLIST
   3850         """
   3851         cmd = "IMSCSCFUSERSLIST? " + self._vnid
   3852         return self._anritsu.send_query(cmd)
   3853 
   3854     @tmo_cscf_userslist_add.setter
   3855     def tmo_cscf_userslist_add(self, username):
   3856         """ Set CSCF USER to USERLIST
   3857             This is needed if IMS AUTH is enabled
   3858 
   3859         Args:
   3860             username: CSCF Username
   3861 
   3862         Returns:
   3863             None
   3864         """
   3865         cmd = "IMSCSCFUSERSLISTADD {},{},00112233445566778899AABBCCDDEEFF,TS34108,AKAV1_MD5,\
   3866         OPC,00000000000000000000000000000000,8000,TRUE,FALSE,0123456789ABCDEF0123456789ABCDEF,\
   3867         54CDFEAB9889000001326754CDFEAB98,6754CDFEAB9889BAEFDC457623100132,\
   3868         326754CDFEAB9889BAEFDC4576231001,TRUE,TRUE,TRUE".format(
   3869             self._vnid, username)
   3870         self._anritsu.send_command(cmd)
   3871 
   3872     @property
   3873     def vzw_cscf_userslist_add(self):
   3874         """ Get CSCF USERLIST
   3875 
   3876         Args:
   3877             None
   3878 
   3879         Returns:
   3880             CSCF USERLIST
   3881         """
   3882         cmd = "IMSCSCFUSERSLIST? " + self._vnid
   3883         return self._anritsu.send_query(cmd)
   3884 
   3885     @vzw_cscf_userslist_add.setter
   3886     def vzw_cscf_userslist_add(self, username):
   3887         """ Set CSCF USER to USERLIST
   3888             This is needed if IMS AUTH is enabled
   3889 
   3890         Args:
   3891             username: CSCF Username
   3892 
   3893         Returns:
   3894             None
   3895         """
   3896         cmd = "IMSCSCFUSERSLISTADD {},{},465B5CE8B199B49FAA5F0A2EE238A6BC,MILENAGE,AKAV1_MD5,\
   3897         OP,5F1D289C5D354D0A140C2548F5F3E3BA,8000,TRUE,FALSE,0123456789ABCDEF0123456789ABCDEF,\
   3898         54CDFEAB9889000001326754CDFEAB98,6754CDFEAB9889BAEFDC457623100132,\
   3899         326754CDFEAB9889BAEFDC4576231001,TRUE,TRUE,TRUE".format(
   3900             self._vnid, username)
   3901         self._anritsu.send_command(cmd)
   3902 
   3903     @property
   3904     def dns(self):
   3905         """ Gets DNS Enable status
   3906 
   3907         Args:
   3908             None
   3909 
   3910         Returns:
   3911             VNID DNS Enable status
   3912         """
   3913         cmd = "IMSDNS? " + self._vnid
   3914         return self._anritsu.send_query(cmd)
   3915 
   3916     @dns.setter
   3917     def dns(self, switch):
   3918         """ Set DNS Enable or Disable
   3919 
   3920         Args:
   3921             sync: ENABLE/DISABLE
   3922 
   3923         Returns:
   3924             None
   3925         """
   3926         if not isinstance(switch, Switch):
   3927             raise ValueError(' The parameter should be of type "Switch"')
   3928         cmd = "IMSDNS {},{}".format(self._vnid, switch.value)
   3929         self._anritsu.send_command(cmd)
   3930 
   3931     @property
   3932     def ndp_nic(self):
   3933         """ Gets NDP Network Interface name
   3934 
   3935         Args:
   3936             None
   3937 
   3938         Returns:
   3939             NDP NIC name
   3940         """
   3941         cmd = "IMSNDPNIC? " + self._vnid
   3942         return self._anritsu.send_query(cmd)
   3943 
   3944     @ndp_nic.setter
   3945     def ndp_nic(self, nic_name):
   3946         """ Set NDP Network Interface name
   3947 
   3948         Args:
   3949             nic_name: NDP Network Interface name
   3950 
   3951         Returns:
   3952             None
   3953         """
   3954         cmd = "IMSNDPNIC {},{}".format(self._vnid, nic_name)
   3955         self._anritsu.send_command(cmd)
   3956 
   3957     @property
   3958     def ndp_prefix(self):
   3959         """ Gets NDP IPv6 Prefix
   3960 
   3961         Args:
   3962             None
   3963 
   3964         Returns:
   3965             NDP IPv6 Prefix
   3966         """
   3967         cmd = "IMSNDPPREFIX? " + self._vnid
   3968         return self._anritsu.send_query(cmd)
   3969 
   3970     @ndp_prefix.setter
   3971     def ndp_prefix(self, prefix_addr):
   3972         """ Set NDP IPv6 Prefix
   3973 
   3974         Args:
   3975             prefix_addr: NDP IPV6 Prefix Addr
   3976 
   3977         Returns:
   3978             None
   3979         """
   3980         cmd = "IMSNDPPREFIX {},{},64".format(self._vnid, prefix_addr)
   3981         self._anritsu.send_command(cmd)
   3982 
   3983     @property
   3984     def psap(self):
   3985         """ Gets PSAP Enable status
   3986 
   3987         Args:
   3988             None
   3989 
   3990         Returns:
   3991             VNID PSAP Enable status
   3992         """
   3993         cmd = "IMSPSAP? " + self._vnid
   3994         return self._anritsu.send_query(cmd)
   3995 
   3996     @psap.setter
   3997     def psap(self, switch):
   3998         """ Set PSAP Enable or Disable
   3999 
   4000         Args:
   4001             switch: ENABLE/DISABLE
   4002 
   4003         Returns:
   4004             None
   4005         """
   4006         if not isinstance(switch, Switch):
   4007             raise ValueError(' The parameter should be of type "Switch"')
   4008         cmd = "IMSPSAP {},{}".format(self._vnid, switch.value)
   4009         self._anritsu.send_command(cmd)
   4010 
   4011     @property
   4012     def psap_auto_answer(self):
   4013         """ Gets PSAP Auto Answer status
   4014 
   4015         Args:
   4016             None
   4017 
   4018         Returns:
   4019             VNID PSAP Auto Answer status
   4020         """
   4021         cmd = "IMSPSAPAUTOANSWER? " + self._vnid
   4022         return self._anritsu.send_query(cmd)
   4023 
   4024     @psap_auto_answer.setter
   4025     def psap_auto_answer(self, switch):
   4026         """ Set PSAP Auto Answer Enable or Disable
   4027 
   4028         Args:
   4029             switch: ENABLE/DISABLE
   4030 
   4031         Returns:
   4032             None
   4033         """
   4034         if not isinstance(switch, Switch):
   4035             raise ValueError(' The parameter should be of type "Switch"')
   4036         cmd = "IMSPSAPAUTOANSWER {},{}".format(self._vnid, switch.value)
   4037         self._anritsu.send_command(cmd)
   4038 
   4039     def start_virtual_network(self):
   4040         """ Start the specified Virtual Network (IMS service)
   4041 
   4042         Args:
   4043             None
   4044 
   4045         Returns:
   4046             None
   4047         """
   4048         cmd = "IMSSTARTVN " + self._vnid
   4049         return self._anritsu.send_command(cmd)
   4050