• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
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"""
17Controller interface for Anritsu Signalling Tester MD8475A.
18"""
19
20import logging
21import time
22import socket
23from enum import Enum
24from enum import IntEnum
25
26from acts.controllers.anritsu_lib._anritsu_utils import AnritsuError
27from acts.controllers.anritsu_lib._anritsu_utils import AnritsuUtils
28from acts.controllers.anritsu_lib._anritsu_utils import NO_ERROR
29from acts.controllers.anritsu_lib._anritsu_utils import OPERATION_COMPLETE
30
31from acts import tracelogger
32
33TERMINATOR = "\0"
34
35# The following wait times (except COMMUNICATION_STATE_WAIT_TIME) are actually
36# the times for socket to time out. Increasing them is to make sure there is
37# enough time for MD8475A operation to be completed in some cases.
38# It won't increase test execution time.
39SMARTSTUDIO_LAUNCH_WAIT_TIME = 300  # was 90
40SMARTSTUDIO_SIMULATION_START_WAIT_TIME = 300  # was 120
41REGISTRATION_STATE_WAIT_TIME = 240
42LOAD_SIMULATION_PARAM_FILE_WAIT_TIME = 30
43COMMUNICATION_STATE_WAIT_TIME = 240
44ANRITSU_SOCKET_BUFFER_SIZE = 8192
45COMMAND_COMPLETE_WAIT_TIME = 180  # was 90
46SETTLING_TIME = 1
47WAIT_TIME_IDENTITY_RESPONSE = 5
48IDLE_STATE_WAIT_TIME = 240
49
50IMSI_READ_USERDATA_WCDMA = "081501"
51IMEI_READ_USERDATA_WCDMA = "081502"
52IMEISV_READ_USERDATA_WCDMA = "081503"
53IMSI_READ_USERDATA_LTE = "075501"
54IMEI_READ_USERDATA_LTE = "075502"
55IMEISV_READ_USERDATA_LTE = "075503"
56IMSI_READ_USERDATA_GSM = "081501"
57IMEI_READ_USERDATA_GSM = "081502"
58IMEISV_READ_USERDATA_GSM = "081503"
59IDENTITY_REQ_DATA_LEN = 24
60SEQ_LOG_MESSAGE_START_INDEX = 60
61
62WCDMA_BANDS = {
63    "I": "1",
64    "II": "2",
65    "III": "3",
66    "IV": "4",
67    "V": "5",
68    "VI": "6",
69    "VII": "7",
70    "VIII": "8",
71    "IX": "9",
72    "X": "10",
73    "XI": "11",
74    "XII": "12",
75    "XIII": "13",
76    "XIV": "14"
77}
78
79
80def create(configs):
81    objs = []
82    for c in configs:
83        ip_address = c["ip_address"]
84        objs.append(MD8475A(ip_address))
85    return objs
86
87
88def destroy(objs):
89    return
90
91
92class ProcessingStatus(Enum):
93    ''' MD8475A processing status for UE,Packet,Voice,Video,SMS,
94        PPP, PWS '''
95    PROCESS_STATUS_NONE = "NONE"
96    PROCESS_STATUS_NOTRUN = "NOTRUN"
97    PROCESS_STATUS_POWEROFF = "POWEROFF"
98    PROCESS_STATUS_REGISTRATION = "REGISTRATION"
99    PROCESS_STATUS_DETACH = "DETACH"
100    PROCESS_STATUS_IDLE = "IDLE"
101    PROCESS_STATUS_ORIGINATION = "ORIGINATION"
102    PROCESS_STATUS_HANDOVER = "HANDOVER"
103    PROCESS_STATUS_UPDATING = "UPDATING"
104    PROCESS_STATUS_TERMINATION = "TERMINATION"
105    PROCESS_STATUS_COMMUNICATION = "COMMUNICATION"
106    PROCESS_STATUS_UERELEASE = "UERELEASE"
107    PROCESS_STATUS_NWRELEASE = "NWRELEASE"
108
109
110class BtsNumber(Enum):
111    '''ID number for MD8475A supported BTS '''
112    BTS1 = "BTS1"
113    BTS2 = "BTS2"
114    BTS3 = "BTS3"
115    BTS4 = "BTS4"
116    BTS5 = "BTS5"
117
118
119class BtsTechnology(Enum):
120    ''' BTS system technology'''
121    LTE = "LTE"
122    WCDMA = "WCDMA"
123    TDSCDMA = "TDSCDMA"
124    GSM = "GSM"
125    CDMA1X = "CDMA1X"
126    EVDO = "EVDO"
127
128
129class BtsBandwidth(Enum):
130    ''' Values for Cell Bandwidth '''
131    LTE_BANDWIDTH_1dot4MHz = "1.4MHz"
132    LTE_BANDWIDTH_3MHz = "3MHz"
133    LTE_BANDWIDTH_5MHz = "5MHz"
134    LTE_BANDWIDTH_10MHz = "10MHz"
135    LTE_BANDWIDTH_15MHz = "15MHz"
136    LTE_BANDWIDTH_20MHz = "20MHz"
137
138    def get_float_value(bts_bandwidth):
139        """ Returns a float representing the bandwidth in MHz.
140
141        Args:
142            bts_bandwidth: a BtsBandwidth enum or a string matching one of the
143            values in the BtsBandwidth enum.
144        """
145
146        if isinstance(bts_bandwidth, BtsBandwidth):
147            bandwidth_str = bts_bandwidth.value
148        elif isinstance(bts_bandwidth, str):
149            bandwidth_str = bts_bandwidth
150        else:
151            raise TypeError('bts_bandwidth should be an instance of string or '
152                            'BtsBandwidth. ')
153
154        if bandwidth_str == BtsBandwidth.LTE_BANDWIDTH_20MHz.value:
155            return 20
156        elif bandwidth_str == BtsBandwidth.LTE_BANDWIDTH_15MHz.value:
157            return 15
158        elif bandwidth_str == BtsBandwidth.LTE_BANDWIDTH_10MHz.value:
159            return 10
160        elif bandwidth_str == BtsBandwidth.LTE_BANDWIDTH_5MHz.value:
161            return 5
162        elif bandwidth_str == BtsBandwidth.LTE_BANDWIDTH_3MHz.value:
163            return 3
164        elif bandwidth_str == BtsBandwidth.LTE_BANDWIDTH_1dot4MHz.value:
165            return 1.4
166        else:
167            raise ValueError(
168                'Could not map {} to a bandwidth value.'.format(bandwidth_str))
169
170
171MAX_NRB_FOR_BANDWIDTH = {
172    BtsBandwidth.LTE_BANDWIDTH_1dot4MHz.value: 6,
173    BtsBandwidth.LTE_BANDWIDTH_3MHz.value: 15,
174    BtsBandwidth.LTE_BANDWIDTH_5MHz.value: 25,
175    BtsBandwidth.LTE_BANDWIDTH_10MHz.value: 50,
176    BtsBandwidth.LTE_BANDWIDTH_15MHz.value: 75,
177    BtsBandwidth.LTE_BANDWIDTH_20MHz.value: 100
178}
179
180
181class LteMimoMode(Enum):
182    """ Values for LTE MIMO modes. """
183    NONE = "MIMONOT"
184    MIMO_2X2 = "MIMO2X2"
185    MIMO_4X4 = "MIMO4X4"
186
187
188class BtsGprsMode(Enum):
189    ''' Values for Gprs Modes '''
190    NO_GPRS = "NO_GPRS"
191    GPRS = "GPRS"
192    EGPRS = "EGPRS"
193
194
195class BtsPacketRate(Enum):
196    ''' Values for Cell Packet rate '''
197    LTE_MANUAL = "MANUAL"
198    LTE_BESTEFFORT = "BESTEFFORT"
199    WCDMA_DL384K_UL64K = "DL384K_UL64K"
200    WCDMA_DLHSAUTO_REL7_UL384K = "DLHSAUTO_REL7_UL384K"
201    WCDMA_DL18_0M_UL384K = "DL18_0M_UL384K"
202    WCDMA_DL21_6M_UL384K = "DL21_6M_UL384K"
203    WCDMA_DLHSAUTO_REL7_ULHSAUTO = "DLHSAUTO_REL7_ULHSAUTO"
204    WCDMA_DL18_0M_UL1_46M = "DL18_0M_UL1_46M"
205    WCDMA_DL18_0M_UL2_0M = "DL18_0M_UL2_0M"
206    WCDMA_DL18_0M_UL5_76M = "DL18_0M_UL5_76M"
207    WCDMA_DL21_6M_UL1_46M = "DL21_6M_UL1_46M"
208    WCDMA_DL21_6M_UL2_0M = "DL21_6M_UL2_0M"
209    WCDMA_DL21_6M_UL5_76M = "DL21_6M_UL5_76M"
210    WCDMA_DLHSAUTO_REL8_UL384K = "DLHSAUTO_REL8_UL384K"
211    WCDMA_DL23_4M_UL384K = "DL23_4M_UL384K"
212    WCDMA_DL28_0M_UL384K = "DL28_0M_UL384K"
213    WCDMA_DL36_0M_UL384K = "DL36_0M_UL384K"
214    WCDMA_DL43_2M_UL384K = "DL43_2M_UL384K"
215    WCDMA_DLHSAUTO_REL8_ULHSAUTO = "DLHSAUTO_REL8_ULHSAUTO"
216    WCDMA_DL23_4M_UL1_46M = "DL23_4M_UL1_46M"
217    WCDMA_DL23_4M_UL2_0M = "DL23_4M_UL2_0M"
218    WCDMA_DL23_4M_UL5_76M = "DL23_4M_UL5_76M"
219    WCDMA_DL28_0M_UL1_46M = "DL28_0M_UL1_46M"
220    WCDMA_DL28_0M_UL2_0M = "DL28_0M_UL2_0M"
221    WCDMA_DL28_0M_UL5_76M = "L28_0M_UL5_76M"
222    WCDMA_DL36_0M_UL1_46M = "DL36_0M_UL1_46M"
223    WCDMA_DL36_0M_UL2_0M = "DL36_0M_UL2_0M"
224    WCDMA_DL36_0M_UL5_76M = "DL36_0M_UL5_76M"
225    WCDMA_DL43_2M_UL1_46M = "DL43_2M_UL1_46M"
226    WCDMA_DL43_2M_UL2_0M = "DL43_2M_UL2_0M"
227    WCDMA_DL43_2M_UL5_76M = "DL43_2M_UL5_76M"
228
229
230class BtsPacketWindowSize(Enum):
231    ''' Values for Cell Packet window size '''
232    WINDOW_SIZE_1 = 1
233    WINDOW_SIZE_8 = 8
234    WINDOW_SIZE_16 = 16
235    WINDOW_SIZE_32 = 32
236    WINDOW_SIZE_64 = 64
237    WINDOW_SIZE_128 = 128
238    WINDOW_SIZE_256 = 256
239    WINDOW_SIZE_512 = 512
240    WINDOW_SIZE_768 = 768
241    WINDOW_SIZE_1024 = 1024
242    WINDOW_SIZE_1536 = 1536
243    WINDOW_SIZE_2047 = 2047
244
245
246class BtsServiceState(Enum):
247    ''' Values for BTS service state '''
248    SERVICE_STATE_IN = "IN"
249    SERVICE_STATE_OUT = "OUT"
250
251
252class BtsCellBarred(Enum):
253    ''' Values for Cell barred parameter '''
254    NOTBARRED = "NOTBARRED"
255    BARRED = "BARRED"
256
257
258class BtsAccessClassBarred(Enum):
259    ''' Values for Access class barred parameter '''
260    NOTBARRED = "NOTBARRED"
261    EMERGENCY = "EMERGENCY"
262    BARRED = "BARRED"
263    USERSPECIFIC = "USERSPECIFIC"
264
265
266class BtsLteEmergencyAccessClassBarred(Enum):
267    ''' Values for Lte emergency access class barred parameter '''
268    NOTBARRED = "NOTBARRED"
269    BARRED = "BARRED"
270
271
272class BtsNwNameEnable(Enum):
273    ''' Values for BT network name enable parameter '''
274    NAME_ENABLE = "ON"
275    NAME_DISABLE = "OFF"
276
277
278class IPAddressType(Enum):
279    ''' Values for IP address type '''
280    IPV4 = "IPV4"
281    IPV6 = "IPV6"
282    IPV4V6 = "IPV4V6"
283
284
285class TriggerMessageIDs(Enum):
286    ''' ID for Trigger messages  '''
287    RRC_CONNECTION_REQ = 111101
288    RRC_CONN_REESTABLISH_REQ = 111100
289    ATTACH_REQ = 141141
290    DETACH_REQ = 141145
291    MM_LOC_UPDATE_REQ = 221108
292    GMM_ATTACH_REQ = 241101
293    GMM_RA_UPDATE_REQ = 241108
294    IDENTITY_REQUEST_LTE = 141155
295    IDENTITY_REQUEST_WCDMA = 241115
296    IDENTITY_REQUEST_GSM = 641115
297    UE_CAPABILITY_ENQUIRY = 111167
298
299
300class TriggerMessageReply(Enum):
301    ''' Values for Trigger message reply parameter '''
302    ACCEPT = "ACCEPT"
303    REJECT = "REJECT"
304    IGNORE = "IGNORE"
305    NONE = "NONE"
306    ILLEGAL = "ILLEGAL"
307
308
309class TestProcedure(Enum):
310    ''' Values for different Test procedures in MD8475A '''
311    PROCEDURE_BL = "BL"
312    PROCEDURE_SELECTION = "SELECTION"
313    PROCEDURE_RESELECTION = "RESELECTION"
314    PROCEDURE_REDIRECTION = "REDIRECTION"
315    PROCEDURE_HO = "HO"
316    PROCEDURE_HHO = "HHO"
317    PROCEDURE_SHO = "SHO"
318    PROCEDURE_MEASUREMENT = "MEASUREMENT"
319    PROCEDURE_CELLCHANGE = "CELLCHANGE"
320    PROCEDURE_MULTICELL = "MULTICELL"
321
322
323class TestPowerControl(Enum):
324    ''' Values for power control in test procedure '''
325    POWER_CONTROL_ENABLE = "ENABLE"
326    POWER_CONTROL_DISABLE = "DISABLE"
327
328
329class TestMeasurement(Enum):
330    ''' Values for mesaurement in test procedure '''
331    MEASUREMENT_ENABLE = "ENABLE"
332    MEASUREMENT_DISABLE = "DISABLE"
333
334
335'''MD8475A processing states'''
336_PROCESS_STATES = {
337    "NONE": ProcessingStatus.PROCESS_STATUS_NONE,
338    "NOTRUN": ProcessingStatus.PROCESS_STATUS_NOTRUN,
339    "POWEROFF": ProcessingStatus.PROCESS_STATUS_POWEROFF,
340    "REGISTRATION": ProcessingStatus.PROCESS_STATUS_REGISTRATION,
341    "DETACH": ProcessingStatus.PROCESS_STATUS_DETACH,
342    "IDLE": ProcessingStatus.PROCESS_STATUS_IDLE,
343    "ORIGINATION": ProcessingStatus.PROCESS_STATUS_ORIGINATION,
344    "HANDOVER": ProcessingStatus.PROCESS_STATUS_HANDOVER,
345    "UPDATING": ProcessingStatus.PROCESS_STATUS_UPDATING,
346    "TERMINATION": ProcessingStatus.PROCESS_STATUS_TERMINATION,
347    "COMMUNICATION": ProcessingStatus.PROCESS_STATUS_COMMUNICATION,
348    "UERELEASE": ProcessingStatus.PROCESS_STATUS_UERELEASE,
349    "NWRELEASE": ProcessingStatus.PROCESS_STATUS_NWRELEASE,
350}
351
352
353class ImsCscfStatus(Enum):
354    """ MD8475A ims cscf status for UE
355    """
356    OFF = "OFF"
357    SIPIDLE = "SIPIDLE"
358    CONNECTED = "CONNECTED"
359    CALLING = "CALLING"
360    RINGING = "RINGING"
361    UNKNOWN = "UNKNOWN"
362
363
364class ImsCscfCall(Enum):
365    """ MD8475A ims cscf call action
366    """
367    MAKE = "MAKE"
368    END = "END"
369    MAKEVIDEO = "MAKEVIDEO"
370    MAKE2ND = "MAKE2ND"
371    END2ND = "END2ND"
372    ANSWER = "ANSWER"
373    HOLD = "HOLD"
374    RESUME = "RESUME"
375
376
377class VirtualPhoneStatus(IntEnum):
378    ''' MD8475A virtual phone status for UE voice and UE video
379        PPP, PWS '''
380    STATUS_IDLE = 0
381    STATUS_VOICECALL_ORIGINATION = 1
382    STATUS_VOICECALL_INCOMING = 2
383    STATUS_VOICECALL_INPROGRESS = 3
384    STATUS_VOICECALL_DISCONNECTING = 4
385    STATUS_VOICECALL_DISCONNECTED = 5
386    STATUS_VIDEOCALL_ORIGINATION = 6
387    STATUS_VIDEOCALL_INCOMING = 7
388    STATUS_VIDEOCALL_INPROGRESS = 8
389    STATUS_VIDEOCALL_DISCONNECTING = 9
390    STATUS_VIDEOCALL_DISCONNECTED = 10
391
392
393'''Virtual Phone Status '''
394_VP_STATUS = {
395    "0": VirtualPhoneStatus.STATUS_IDLE,
396    "1": VirtualPhoneStatus.STATUS_VOICECALL_ORIGINATION,
397    "2": VirtualPhoneStatus.STATUS_VOICECALL_INCOMING,
398    "3": VirtualPhoneStatus.STATUS_VOICECALL_INPROGRESS,
399    "4": VirtualPhoneStatus.STATUS_VOICECALL_DISCONNECTING,
400    "5": VirtualPhoneStatus.STATUS_VOICECALL_DISCONNECTED,
401    "6": VirtualPhoneStatus.STATUS_VIDEOCALL_ORIGINATION,
402    "7": VirtualPhoneStatus.STATUS_VIDEOCALL_INCOMING,
403    "8": VirtualPhoneStatus.STATUS_VIDEOCALL_INPROGRESS,
404    "9": VirtualPhoneStatus.STATUS_VIDEOCALL_DISCONNECTING,
405    "10": VirtualPhoneStatus.STATUS_VIDEOCALL_DISCONNECTED,
406}
407
408
409class VirtualPhoneAutoAnswer(Enum):
410    ''' Virtual phone auto answer enable values'''
411    ON = "ON"
412    OFF = "OFF"
413
414
415class CsfbType(Enum):
416    ''' CSFB Type values'''
417    CSFB_TYPE_REDIRECTION = "REDIRECTION"
418    CSFB_TYPE_HANDOVER = "HO"
419
420
421class ReturnToEUTRAN(Enum):
422    '''Return to EUTRAN setting values '''
423    RETEUTRAN_ENABLE = "ENABLE"
424    RETEUTRAN_DISABLE = "DISABLE"
425
426
427class CTCHSetup(Enum):
428    '''CTCH setting values '''
429    CTCH_ENABLE = "ENABLE"
430    CTCH_DISABLE = "DISABLE"
431
432
433class UEIdentityType(Enum):
434    '''UE Identity type values '''
435    IMSI = "IMSI"
436    IMEI = "IMEI"
437    IMEISV = "IMEISV"
438
439
440class CBCHSetup(Enum):
441    '''CBCH setting values '''
442    CBCH_ENABLE = "ENABLE"
443    CBCH_DISABLE = "DISABLE"
444
445
446class Switch(Enum):
447    ''' Values for ENABLE or DISABLE '''
448    ENABLE = "ENABLE"
449    DISABLE = "DISABLE"
450
451
452class ModulationType(Enum):
453    """Supported Modulation Types."""
454    Q16 = '16QAM'
455    Q64 = '64QAM'
456    Q256 = '256QAM'
457
458
459class MD8475A(object):
460    """Class to communicate with Anritsu MD8475A Signalling Tester.
461       This uses GPIB command to interface with Anritsu MD8475A """
462    def __init__(self, ip_address, wlan=False, md8475_version="A"):
463        self._error_reporting = True
464        self._ipaddr = ip_address
465        self.log = tracelogger.TraceLogger(logging.getLogger())
466        self._wlan = wlan
467        port_number = 28002
468        self._md8475_version = md8475_version
469        if md8475_version == "B":
470            global TERMINATOR
471            TERMINATOR = "\n"
472            port_number = 5025
473
474        # Open socket connection to Signaling Tester
475        self.log.info("Opening Socket Connection with "
476                      "Signaling Tester ({}) ".format(self._ipaddr))
477        try:
478            self._sock = socket.create_connection((self._ipaddr, port_number),
479                                                  timeout=120)
480            self.send_query("*IDN?", 60)
481            self.log.info("Communication with Signaling Tester OK.")
482            self.log.info("Opened Socket connection to ({})"
483                          "with handle ({})".format(self._ipaddr, self._sock))
484            # launching Smart Studio Application needed for the simulation
485            ret = self.launch_smartstudio()
486        except socket.timeout:
487            raise AnritsuError("Timeout happened while conencting to"
488                               " Anritsu MD8475A")
489        except socket.error:
490            raise AnritsuError("Socket creation error")
491
492    def get_BTS(self, btsnumber):
493        """ Returns the BTS object based on the BTS number provided
494
495        Args:
496            btsnumber: BTS number (BTS1, BTS2)
497
498        Returns:
499            BTS object
500        """
501        return _BaseTransceiverStation(self, btsnumber)
502
503    def get_AnritsuTestCases(self):
504        """ Returns the Anritsu Test Case Module Object
505
506        Args:
507            None
508
509        Returns:
510            Anritsu Test Case Module Object
511        """
512        return _AnritsuTestCases(self)
513
514    def get_VirtualPhone(self):
515        """ Returns the Anritsu Virtual Phone Module Object
516
517        Args:
518            None
519
520        Returns:
521            Anritsu Virtual Phone Module Object
522        """
523        return _VirtualPhone(self)
524
525    def get_PDN(self, pdn_number):
526        """ Returns the PDN Module Object
527
528        Args:
529            None
530
531        Returns:
532            Anritsu PDN Module Object
533        """
534        return _PacketDataNetwork(self, pdn_number)
535
536    def get_TriggerMessage(self):
537        """ Returns the Anritsu Trigger Message Module Object
538
539        Args:
540            None
541
542        Returns:
543            Anritsu Trigger Message Module Object
544        """
545        return _TriggerMessage(self)
546
547    def get_IMS(self, vnid):
548        """ Returns the IMS Module Object with VNID
549
550        Args:
551            vnid: Virtual Network ID
552
553        Returns:
554            Anritsu IMS VNID Module Object
555        """
556        return _IMS_Services(self, vnid)
557
558    def get_ims_cscf_status(self, virtual_network_id):
559        """ Get the IMS CSCF Status of virtual network
560
561        Args:
562            virtual_network_id: virtual network id
563
564        Returns:
565            IMS CSCF status
566        """
567        cmd = "IMSCSCFSTAT? {}".format(virtual_network_id)
568        return self.send_query(cmd)
569
570    def ims_cscf_call_action(self, virtual_network_id, action):
571        """ IMS CSCF Call action
572
573        Args:
574            virtual_network_id: virtual network id
575            action: action to make
576
577        Returns:
578            None
579        """
580        cmd = "IMSCSCFCALL {},{}".format(virtual_network_id, action)
581        self.send_command(cmd)
582
583    def send_query(self, query, sock_timeout=120):
584        """ Sends a Query message to Anritsu and return response
585
586        Args:
587            query - Query string
588
589        Returns:
590            query response
591        """
592        self.log.info("--> {}".format(query))
593        querytoSend = (query + TERMINATOR).encode('utf-8')
594        self._sock.settimeout(sock_timeout)
595        try:
596            self._sock.send(querytoSend)
597            result = self._sock.recv(ANRITSU_SOCKET_BUFFER_SIZE).rstrip(
598                TERMINATOR.encode('utf-8'))
599            response = result.decode('utf-8')
600            self.log.info('<-- {}'.format(response))
601            return response
602        except socket.timeout:
603            raise AnritsuError("Timeout: Response from Anritsu")
604        except socket.error:
605            raise AnritsuError("Socket Error")
606
607    def send_command(self, command, sock_timeout=120):
608        """ Sends a Command message to Anritsu
609
610        Args:
611            command - command string
612
613        Returns:
614            None
615        """
616        self.log.info("--> {}".format(command))
617        if self._error_reporting:
618            cmdToSend = (command + ";ERROR?" + TERMINATOR).encode('utf-8')
619            self._sock.settimeout(sock_timeout)
620            try:
621                self._sock.send(cmdToSend)
622                err = self._sock.recv(ANRITSU_SOCKET_BUFFER_SIZE).rstrip(
623                    TERMINATOR.encode('utf-8'))
624                error = int(err.decode('utf-8'))
625                if error != NO_ERROR:
626                    raise AnritsuError(error, command)
627            except socket.timeout:
628                raise AnritsuError("Timeout for Command Response from Anritsu")
629            except socket.error:
630                raise AnritsuError("Socket Error for Anritsu command")
631            except Exception as e:
632                raise AnritsuError(e, command)
633        else:
634            cmdToSend = (command + TERMINATOR).encode('utf-8')
635            try:
636                self._sock.send(cmdToSend)
637            except socket.error:
638                raise AnritsuError("Socket Error", command)
639            return
640
641    def launch_smartstudio(self):
642        """ launch the Smart studio application
643            This should be done before stating simulation
644
645        Args:
646            None
647
648        Returns:
649            None
650        """
651        # check the Smart Studio status . If Smart Studio doesn't exist ,
652        # start it.if it is running, stop it. Smart Studio should be in
653        # NOTRUN (Simulation Stopped) state to start new simulation
654        stat = self.send_query("STAT?", 30)
655        if stat == "NOTEXIST":
656            self.log.info("Launching Smart Studio Application,"
657                          "it takes about a minute.")
658            time_to_wait = SMARTSTUDIO_LAUNCH_WAIT_TIME
659            sleep_interval = 15
660            waiting_time = 0
661
662            err = self.send_command("RUN", SMARTSTUDIO_LAUNCH_WAIT_TIME)
663            stat = self.send_query("STAT?")
664            while stat != "NOTRUN":
665                time.sleep(sleep_interval)
666                waiting_time = waiting_time + sleep_interval
667                if waiting_time <= time_to_wait:
668                    stat = self.send_query("STAT?")
669                else:
670                    raise AnritsuError("Timeout: Smart Studio launch")
671        elif stat == "RUNNING":
672            # Stop simulation if necessary
673            self.send_command("STOP", 60)
674            stat = self.send_query("STAT?")
675
676        # The state of the Smart Studio should be NOTRUN at this point
677        # after the one of the steps from above
678        if stat != "NOTRUN":
679            self.log.info(
680                "Can not launch Smart Studio, "
681                "please shut down all the Smart Studio SW components")
682            raise AnritsuError("Could not run SmartStudio")
683
684    def close_smartstudio(self):
685        """ Closes the Smart studio application
686
687        Args:
688            None
689
690        Returns:
691            None
692        """
693        self.stop_simulation()
694        self.send_command("EXIT", 60)
695
696    def get_smartstudio_status(self):
697        """ Gets the Smart studio status
698
699        Args:
700            None
701
702        Returns:
703            Smart studio status
704        """
705        return self.send_query("STAT?")
706
707    def start_simulation(self):
708        """ Starting the simulation of the network model.
709            simulation model or simulation parameter file
710            should be set before starting the simulation
711
712        Args:
713          None
714
715        Returns:
716            None
717        """
718        time_to_wait = SMARTSTUDIO_SIMULATION_START_WAIT_TIME
719        sleep_interval = 2
720        waiting_time = 0
721
722        self.send_command("START", SMARTSTUDIO_SIMULATION_START_WAIT_TIME)
723
724        self.log.info("Waiting for CALLSTAT=POWEROFF")
725        callstat = self.send_query("CALLSTAT? BTS1").split(",")
726        while callstat[0] != "POWEROFF":
727            time.sleep(sleep_interval)
728            waiting_time += sleep_interval
729            if waiting_time <= time_to_wait:
730                callstat = self.send_query("CALLSTAT? BTS1").split(",")
731            else:
732                raise AnritsuError("Timeout: Starting simulation")
733
734    def stop_simulation(self):
735        """ Stop simulation operation
736
737        Args:
738          None
739
740        Returns:
741            None
742        """
743        # Stop virtual network (IMS) #1 if still running
744        # this is needed before Sync command is supported in 6.40a
745        if self.send_query("IMSVNSTAT? 1") == "RUNNING":
746            self.send_command("IMSSTOPVN 1")
747        if self.send_query("IMSVNSTAT? 2") == "RUNNING":
748            self.send_command("IMSSTOPVN 2")
749        stat = self.send_query("STAT?")
750        # Stop simulation if its is RUNNING
751        if stat == "RUNNING":
752            self.send_command("STOP", 60)
753            stat = self.send_query("STAT?")
754            if stat != "NOTRUN":
755                self.log.info("Failed to stop simulation")
756                raise AnritsuError("Failed to stop simulation")
757
758    def reset(self):
759        """ reset simulation parameters
760
761        Args:
762          None
763
764        Returns:
765            None
766        """
767        self.send_command("*RST", COMMAND_COMPLETE_WAIT_TIME)
768
769    def load_simulation_paramfile(self, filepath):
770        """ loads simulation model parameter file
771        Args:
772          filepath : simulation model parameter file path
773
774        Returns:
775            None
776        """
777        self.stop_simulation()
778        cmd = "LOADSIMPARAM \"" + filepath + '\";ERROR?'
779        self.send_query(cmd, LOAD_SIMULATION_PARAM_FILE_WAIT_TIME)
780
781    def load_cell_paramfile(self, filepath):
782        """ loads cell model parameter file
783
784        Args:
785          filepath : cell model parameter file path
786
787        Returns:
788            None
789        """
790        self.stop_simulation()
791        cmd = "LOADCELLPARAM \"" + filepath + '\";ERROR?'
792        status = int(self.send_query(cmd))
793        if status != NO_ERROR:
794            raise AnritsuError(status, cmd)
795
796    def _set_simulation_model(self, sim_model, reset=True):
797        """ Set simulation model and valid the configuration
798
799        Args:
800            sim_model: simulation model
801            reset: if True, reset the simulation after setting the new
802            simulation model
803        Returns:
804            True/False
805        """
806        error = int(
807            self.send_query("SIMMODEL %s;ERROR?" % sim_model,
808                            COMMAND_COMPLETE_WAIT_TIME))
809        if error:  # Try again if first set SIMMODEL fails
810            time.sleep(3)
811            if "WLAN" in sim_model:
812                new_sim_model = sim_model[:-5]
813                error = int(
814                    self.send_query("SIMMODEL %s;ERROR?" % new_sim_model,
815                                    COMMAND_COMPLETE_WAIT_TIME))
816                time.sleep(3)
817            error = int(
818                self.send_query("SIMMODEL %s;ERROR?" % sim_model,
819                                COMMAND_COMPLETE_WAIT_TIME))
820            if error:
821                return False
822        if reset:
823            # Reset might be necessary because SIMMODEL will load
824            # some of the contents from previous parameter files.
825            self.reset()
826        return True
827
828    def set_simulation_model(self, *bts_rats, reset=True):
829        """ Stops the simulation and then sets the simulation model.
830
831        Args:
832            *bts_rats: base station rats for BTS 1 to 5.
833            reset: if True, reset the simulation after setting the new
834            simulation model
835        Returns:
836            True or False
837        """
838        self.stop_simulation()
839        if len(bts_rats) not in range(1, 6):
840            raise ValueError(
841                "set_simulation_model requires 1 to 5 BTS values.")
842        simmodel = ",".join(bts_rat.value for bts_rat in bts_rats)
843        if self._wlan:
844            simmodel = simmodel + "," + "WLAN"
845        return self._set_simulation_model(simmodel, reset)
846
847    def get_simulation_model(self):
848        """ Gets the simulation model
849
850        Args:
851            None
852
853        Returns:
854            Current simulation model
855        """
856        cmd = "SIMMODEL?"
857        return self.send_query(cmd)
858
859    def get_lte_rrc_status_change(self):
860        """ Gets the LTE RRC status change function state
861
862        Returns:
863            Boolean: True is Enabled / False is Disabled
864        """
865        cmd = "L_RRCSTAT?"
866        return self.send_query(cmd) == "ENABLE"
867
868    def set_lte_rrc_status_change(self, status_change):
869        """ Enables or Disables the LTE RRC status change function
870
871        Returns:
872            None
873        """
874        cmd = "L_RRCSTAT "
875        if status_change:
876            cmd += "ENABLE"
877        else:
878            cmd += "DISABLE"
879        self.send_command(cmd)
880
881    def get_lte_rrc_status_change_timer(self):
882        """ Gets the LTE RRC Status Change Timer
883
884        Returns:
885            returns a status change timer integer value
886        """
887        cmd = "L_STATTMR?"
888        return self.send_query(cmd)
889
890    def set_lte_rrc_status_change_timer(self, time):
891        """ Sets the LTE RRC Status Change Timer parameter
892
893        Returns:
894            None
895        """
896        cmd = "L_STATTMR %s" % time
897        self.send_command(cmd)
898
899    def set_umts_rrc_status_change(self, status_change):
900        """ Enables or Disables the UMTS RRC status change function
901
902        Returns:
903            None
904        """
905        cmd = "W_RRCSTAT "
906        if status_change:
907            cmd += "ENABLE"
908        else:
909            cmd += "DISABLE"
910        self.send_command(cmd)
911
912    def get_umts_rrc_status_change(self):
913        """ Gets the UMTS RRC Status Change
914
915        Returns:
916            Boolean: True is Enabled / False is Disabled
917        """
918        cmd = "W_RRCSTAT?"
919        return self.send_query(cmd)
920
921    def set_umts_dch_stat_timer(self, timer_seconds):
922        """ Sets the UMTS RRC DCH timer
923
924        Returns:
925            None
926        """
927        cmd = "W_STATTMRDCH %s" % timer_seconds
928        self.send_command(cmd)
929
930    def set_simulation_state_to_poweroff(self):
931        """ Sets the simulation state to POWER OFF
932
933        Args:
934          None
935
936        Returns:
937            None
938        """
939        self.send_command("RESETSIMULATION POWEROFF")
940        time_to_wait = 30
941        sleep_interval = 2
942        waiting_time = 0
943
944        self.log.info("Waiting for CALLSTAT=POWEROFF")
945        callstat = self.send_query("CALLSTAT?").split(",")
946        while callstat[0] != "POWEROFF":
947            time.sleep(sleep_interval)
948            waiting_time = waiting_time + sleep_interval
949            if waiting_time <= time_to_wait:
950                callstat = self.send_query("CALLSTAT?").split(",")
951            else:
952                break
953
954    def set_simulation_state_to_idle(self, btsnumber):
955        """ Sets the simulation state to IDLE
956
957        Args:
958          None
959
960        Returns:
961            None
962        """
963        if not isinstance(btsnumber, BtsNumber):
964            raise ValueError(' The parameter should be of type "BtsNumber" ')
965        cmd = "RESETSIMULATION IDLE," + btsnumber.value
966        self.send_command(cmd)
967        time_to_wait = 30
968        sleep_interval = 2
969        waiting_time = 0
970
971        self.log.info("Waiting for CALLSTAT=IDLE")
972        callstat = self.send_query("CALLSTAT?").split(",")
973        while callstat[0] != "IDLE":
974            time.sleep(sleep_interval)
975            waiting_time = waiting_time + sleep_interval
976            if waiting_time <= time_to_wait:
977                callstat = self.send_query("CALLSTAT?").split(",")
978            else:
979                break
980
981    def set_trigger_message_mode(self, msg_id):
982        """ Sets the Message Mode of the trigger
983
984        Args:
985            msg_id: The hex value of the identity of an RRC/NAS message.
986
987        Returns:
988            None
989        """
990
991        if isinstance(msg_id, TriggerMessageIDs):
992            msg_id = msg_id.value
993
994        cmd = "TMMESSAGEMODE {},USERDATA".format(msg_id)
995        self.send_command(cmd)
996
997    def set_data_of_trigger_message(self, msg_id, user_data):
998        """ Sets the User Data of the trigger message
999
1000        Args:
1001            msg_id: The hex value of the identity of an RRC/NAS message.
1002            user_data: Hex data
1003
1004        Returns:
1005            None
1006        """
1007
1008        if isinstance(msg_id, TriggerMessageIDs):
1009            msg_id = msg_id.value
1010
1011        data_len = len(user_data) * 4
1012
1013        cmd = "TMUSERDATA {}, {}, {}".format(msg_id, user_data, data_len)
1014        self.send_command(cmd)
1015
1016    def send_trigger_message(self, msg_id):
1017        """ Sends the User Data of the trigger information
1018
1019        Args:
1020            msg_id: The hex value of the identity of an RRC/NAS message.
1021
1022        Returns:
1023            None
1024        """
1025
1026        if isinstance(msg_id, TriggerMessageIDs):
1027            msg_id = msg_id.value
1028
1029        cmd = "TMSENDUSERMSG {}".format(msg_id)
1030        self.send_command(cmd)
1031
1032    def wait_for_registration_state(self,
1033                                    bts=1,
1034                                    time_to_wait=REGISTRATION_STATE_WAIT_TIME):
1035        """ Waits for UE registration state on Anritsu
1036
1037        Args:
1038          bts: index of MD8475A BTS, eg 1, 2
1039          time_to_wait: time to wait for the phone to get to registration state
1040
1041        Returns:
1042            None
1043        """
1044        self.log.info("wait for IDLE/COMMUNICATION state on anritsu.")
1045
1046        sleep_interval = 1
1047        sim_model = (self.get_simulation_model()).split(",")
1048        # wait 1 more round for GSM because of PS attach
1049        registration_check_iterations = 2 if sim_model[bts - 1] == "GSM" else 1
1050        for _ in range(registration_check_iterations):
1051            waiting_time = 0
1052            while waiting_time <= time_to_wait:
1053                callstat = self.send_query(
1054                    "CALLSTAT? BTS{}".format(bts)).split(",")
1055                if callstat[0] == "IDLE" or callstat[1] == "COMMUNICATION":
1056                    break
1057                time.sleep(sleep_interval)
1058                waiting_time += sleep_interval
1059            else:
1060                raise AnritsuError(
1061                    "UE failed to register in {} seconds".format(time_to_wait))
1062            time.sleep(sleep_interval)
1063
1064    def wait_for_communication_state(
1065            self, time_to_wait=COMMUNICATION_STATE_WAIT_TIME):
1066        """ Waits for UE communication state on Anritsu
1067
1068        Args:
1069          time_to_wait: time to wait for the phone to get to communication state
1070
1071        Returns:
1072            None
1073        """
1074        self.log.info("wait for COMMUNICATION state on anritsu")
1075        sleep_interval = 1
1076        waiting_time = 0
1077
1078        self.log.info("Waiting for CALLSTAT=COMMUNICATION")
1079        callstat = self.send_query("CALLSTAT? BTS1").split(",")
1080        while callstat[1] != "COMMUNICATION":
1081            time.sleep(sleep_interval)
1082            waiting_time += sleep_interval
1083            if waiting_time <= time_to_wait:
1084                callstat = self.send_query("CALLSTAT? BTS1").split(",")
1085            else:
1086                raise AnritsuError("UE failed to register on network")
1087
1088    def wait_for_idle_state(self, time_to_wait=IDLE_STATE_WAIT_TIME):
1089        """ Waits for UE idle state on Anritsu
1090
1091        Args:
1092          time_to_wait: time to wait for the phone to get to idle state
1093
1094        Returns:
1095            None
1096        """
1097        self.log.info("wait for IDLE state on anritsu.")
1098
1099        sleep_interval = 1
1100        waiting_time = 0
1101
1102        callstat = self.send_query("CALLSTAT? BTS1").split(",")
1103        while callstat[0] != "IDLE":
1104            time.sleep(sleep_interval)
1105            waiting_time += sleep_interval
1106            if waiting_time <= time_to_wait:
1107                callstat = self.send_query("CALLSTAT? BTS1").split(",")
1108            else:
1109                raise AnritsuError("UE failed to go on idle state")
1110
1111    def get_camping_cell(self):
1112        """ Gets the current camping cell information
1113
1114        Args:
1115          None
1116
1117        Returns:
1118            returns a tuple (BTS number, RAT Technology) '
1119        """
1120        bts_number, rat_info = self.send_query("CAMPINGCELL?").split(",")
1121        return bts_number, rat_info
1122
1123    def get_supported_bands(self, rat):
1124        """ Gets the supported bands from UE capability information
1125
1126        Args:
1127          rat: LTE or WCDMA
1128
1129        Returns:
1130            returns a list of bnads
1131        """
1132        cmd = "UEINFO? "
1133        if rat == "LTE":
1134            cmd += "L"
1135        elif rat == "WCDMA":
1136            cmd += "W"
1137        else:
1138            raise ValueError('The rat argument needs to be "LTE" or "WCDMA"')
1139        cmd += "_SupportedBand"
1140        result = self.send_query(cmd).split(",")
1141        if result == "NONE":
1142            return None
1143        if rat == "WCDMA":
1144            bands = []
1145            for band in result:
1146                bands.append(WCDMA_BANDS[band])
1147            return bands
1148        else:
1149            return result
1150
1151    def start_testcase(self):
1152        """ Starts a test case on Anritsu
1153
1154        Args:
1155          None
1156
1157        Returns:
1158            None
1159        """
1160        self.send_command("STARTTEST")
1161
1162    def get_testcase_status(self):
1163        """ Gets the current test case status on Anritsu
1164
1165        Args:
1166          None
1167
1168        Returns:
1169            current test case status
1170        """
1171        return self.send_query("TESTSTAT?")
1172
1173    def start_ip_traffic(self, pdn='1'):
1174        """ Starts IP data traffic with the selected PDN.
1175
1176        Args:
1177            pdn: the pdn to be used for data traffic. Defaults to '1'.
1178        """
1179        self.send_command('OPERATEIPTRAFFIC START,' + pdn)
1180
1181    def stop_ip_traffic(self, pdn='1'):
1182        """ Stops IP data traffic with the selected PDN.
1183
1184         Args:
1185            pdn: pdn for which data traffic has to be stopped. Defaults to '1'.
1186        """
1187        self.send_command('OPERATEIPTRAFFIC STOP,' + pdn)
1188
1189    def set_carrier_aggregation_enabled(self, enabled=True):
1190        """ Enables or disables de carrier aggregation option.
1191
1192        Args:
1193            enabled: enables CA if True and disables CA if False.
1194        """
1195        cmd = 'CA ' + 'ENABLE' if enabled else 'DISABLE'
1196        self.send_command(cmd)
1197
1198    # Common Default Gateway:
1199    @property
1200    def gateway_ipv4addr(self):
1201        """ Gets the IPv4 address of the default gateway
1202
1203        Args:
1204          None
1205
1206        Returns:
1207            current UE status
1208        """
1209        return self.send_query("DGIPV4?")
1210
1211    @gateway_ipv4addr.setter
1212    def gateway_ipv4addr(self, ipv4_addr):
1213        """ sets the IPv4 address of the default gateway
1214        Args:
1215            ipv4_addr: IPv4 address of the default gateway
1216
1217        Returns:
1218            None
1219        """
1220        cmd = "DGIPV4 " + ipv4_addr
1221        self.send_command(cmd)
1222
1223    @property
1224    def gateway_ipv6addr(self):
1225        """ Gets the IPv6 address of the default gateway
1226
1227        Args:
1228          None
1229
1230        Returns:
1231            current UE status
1232        """
1233        return self.send_query("DGIPV6?")
1234
1235    @gateway_ipv6addr.setter
1236    def gateway_ipv6addr(self, ipv6_addr):
1237        """ sets the IPv6 address of the default gateway
1238        Args:
1239            ipv6_addr: IPv6 address of the default gateway
1240
1241        Returns:
1242            None
1243        """
1244        cmd = "DGIPV6 " + ipv6_addr
1245        self.send_command(cmd)
1246
1247    @property
1248    def usim_key(self):
1249        """ Gets the USIM Security Key
1250
1251        Args:
1252          None
1253
1254        Returns:
1255            USIM Security Key
1256        """
1257        return self.send_query("USIMK?")
1258
1259    @usim_key.setter
1260    def usim_key(self, usimk):
1261        """ sets the USIM Security Key
1262        Args:
1263            usimk: USIM Security Key, eg "000102030405060708090A0B0C0D0E0F"
1264
1265        Returns:
1266            None
1267        """
1268        cmd = "USIMK " + usimk
1269        self.send_command(cmd)
1270
1271    def get_ue_status(self):
1272        """ Gets the current UE status on Anritsu
1273
1274        Args:
1275          None
1276
1277        Returns:
1278            current UE status
1279        """
1280        UE_STATUS_INDEX = 0
1281        ue_status = self.send_query("CALLSTAT?").split(",")[UE_STATUS_INDEX]
1282        return _PROCESS_STATES[ue_status]
1283
1284    def get_packet_status(self):
1285        """ Gets the current Packet status on Anritsu
1286
1287        Args:
1288          None
1289
1290        Returns:
1291            current Packet status
1292        """
1293        PACKET_STATUS_INDEX = 1
1294        packet_status = self.send_query("CALLSTAT?").split(
1295            ",")[PACKET_STATUS_INDEX]
1296        return _PROCESS_STATES[packet_status]
1297
1298    def disconnect(self):
1299        """ Disconnect the Anritsu box from test PC
1300
1301        Args:
1302          None
1303
1304        Returns:
1305            None
1306        """
1307        # no need to # exit smart studio application
1308        # self.close_smartstudio()
1309        self._sock.close()
1310
1311    def machine_reboot(self):
1312        """ Reboots the Anritsu Machine
1313
1314        Args:
1315          None
1316
1317        Returns:
1318            None
1319        """
1320        self.send_command("REBOOT")
1321
1322    def save_sequence_log(self, fileName):
1323        """ Saves the Anritsu Sequence logs to file
1324
1325        Args:
1326          fileName: log file name
1327
1328        Returns:
1329            None
1330        """
1331        cmd = 'SAVESEQLOG "{}"'.format(fileName)
1332        self.send_command(cmd)
1333
1334    def clear_sequence_log(self):
1335        """ Clears the Anritsu Sequence logs
1336
1337        Args:
1338          None
1339
1340        Returns:
1341            None
1342        """
1343        self.send_command("CLEARSEQLOG")
1344
1345    def save_message_log(self, fileName):
1346        """ Saves the Anritsu Message logs to file
1347
1348        Args:
1349          fileName: log file name
1350
1351        Returns:
1352            None
1353        """
1354        cmd = 'SAVEMSGLOG "{}"'.format(fileName)
1355        self.send_command(cmd)
1356
1357    def clear_message_log(self):
1358        """ Clears the Anritsu Message logs
1359
1360        Args:
1361          None
1362
1363        Returns:
1364            None
1365        """
1366        self.send_command("CLEARMSGLOG")
1367
1368    def save_trace_log(self, fileName, fileType, overwrite, start, end):
1369        """ Saves the Anritsu Trace logs
1370
1371        Args:
1372          fileName: log file name
1373          fileType: file type (BINARY, TEXT, H245,PACKET, CPLABE)
1374          overwrite: whether to over write
1375          start: starting trace number
1376          end: ending trace number
1377
1378        Returns:
1379            None
1380        """
1381        cmd = 'SAVETRACELOG "{}",{},{},{},{}'.format(fileName, fileType,
1382                                                     overwrite, start, end)
1383        self.send_command(cmd)
1384
1385    def send_cmas_lte_wcdma(self, serialNo, messageID, warningMessage):
1386        """ Sends a CMAS message
1387
1388        Args:
1389          serialNo: serial number of CMAS message
1390          messageID: CMAS message ID
1391          warningMessage:  CMAS Warning message
1392
1393        Returns:
1394            None
1395        """
1396        cmd = ('PWSSENDWM 3GPP,"BtsNo=1&WarningSystem=CMAS&SerialNo={}'
1397               '&MessageID={}&wm={}"').format(serialNo, messageID,
1398                                              warningMessage)
1399        self.send_command(cmd)
1400
1401    def send_etws_lte_wcdma(self, serialNo, messageID, warningType,
1402                            warningMessage, userAlertenable, popUpEnable):
1403        """ Sends a ETWS message
1404
1405        Args:
1406          serialNo: serial number of CMAS message
1407          messageID: CMAS message ID
1408          warningMessage:  CMAS Warning message
1409
1410        Returns:
1411            None
1412        """
1413        cmd = (
1414            'PWSSENDWM 3GPP,"BtsNo=1&WarningSystem=ETWS&SerialNo={}&'
1415            'Primary=ON&PrimaryMessageID={}&Secondary=ON&SecondaryMessageID={}'
1416            '&WarningType={}&wm={}&UserAlert={}&Popup={}&dcs=0x10&LanguageCode=en"'
1417        ).format(serialNo, messageID, messageID, warningType, warningMessage,
1418                 userAlertenable, popUpEnable)
1419        self.send_command(cmd)
1420
1421    def send_cmas_etws_cdma1x(self, message_id, service_category, alert_ext,
1422                              response_type, severity, urgency, certainty):
1423        """ Sends a CMAS/ETWS message on CDMA 1X
1424
1425        Args:
1426          serviceCategory: service category of alert
1427          messageID: message ID
1428          alertText: Warning message
1429
1430        Returns:
1431            None
1432        """
1433        cmd = (
1434            'PWSSENDWM 3GPP2,"BtsNo=1&ServiceCategory={}&MessageID={}&AlertText={}&'
1435            'CharSet=ASCII&ResponseType={}&Severity={}&Urgency={}&Certainty={}"'
1436        ).format(service_category, message_id, alert_ext, response_type,
1437                 severity, urgency, certainty)
1438        self.send_command(cmd)
1439
1440    @property
1441    def csfb_type(self):
1442        """ Gets the current CSFB type
1443
1444        Args:
1445            None
1446
1447        Returns:
1448            current CSFB type
1449        """
1450        return self.send_query("SIMMODELEX? CSFB")
1451
1452    @csfb_type.setter
1453    def csfb_type(self, csfb_type):
1454        """ sets the CSFB type
1455        Args:
1456            csfb_type: CSFB type
1457
1458        Returns:
1459            None
1460        """
1461        if not isinstance(csfb_type, CsfbType):
1462            raise ValueError('The parameter should be of type "CsfbType" ')
1463        cmd = "SIMMODELEX CSFB," + csfb_type.value
1464        self.send_command(cmd)
1465
1466    @property
1467    def csfb_return_to_eutran(self):
1468        """ Gets the current return to EUTRAN status
1469
1470        Args:
1471            None
1472
1473        Returns:
1474            current return to EUTRAN status
1475        """
1476        return self.send_query("SIMMODELEX? RETEUTRAN")
1477
1478    @csfb_return_to_eutran.setter
1479    def csfb_return_to_eutran(self, enable):
1480        """ sets the return to EUTRAN feature
1481        Args:
1482            enable: enable/disable return to EUTRAN feature
1483
1484        Returns:
1485            None
1486        """
1487        if not isinstance(enable, ReturnToEUTRAN):
1488            raise ValueError(
1489                'The parameter should be of type "ReturnToEUTRAN"')
1490        cmd = "SIMMODELEX RETEUTRAN," + enable.value
1491        self.send_command(cmd)
1492
1493    def set_packet_preservation(self):
1494        """ Set packet state to Preservation
1495
1496        Args:
1497            None
1498
1499        Returns:
1500            None
1501        """
1502        cmd = "OPERATEPACKET PRESERVATION"
1503        self.send_command(cmd)
1504
1505    def set_packet_dormant(self):
1506        """ Set packet state to Dormant
1507
1508        Args:
1509            None
1510
1511        Returns:
1512            None
1513        """
1514        cmd = "OPERATEPACKET DORMANT"
1515        self.send_command(cmd)
1516
1517    def get_ue_identity(self, identity_type):
1518        """ Get the UE identity IMSI, IMEI, IMEISV
1519
1520        Args:
1521            identity_type : IMSI/IMEI/IMEISV
1522
1523        Returns:
1524            IMSI/IMEI/IMEISV value
1525        """
1526        bts, rat = self.get_camping_cell()
1527        if rat == BtsTechnology.LTE.value:
1528            identity_request = TriggerMessageIDs.IDENTITY_REQUEST_LTE.value
1529            if identity_type == UEIdentityType.IMSI:
1530                userdata = IMSI_READ_USERDATA_LTE
1531            elif identity_type == UEIdentityType.IMEI:
1532                userdata = IMEI_READ_USERDATA_LTE
1533            elif identity_type == UEIdentityType.IMEISV:
1534                userdata = IMEISV_READ_USERDATA_LTE
1535            else:
1536                return None
1537        elif rat == BtsTechnology.WCDMA.value:
1538            identity_request = TriggerMessageIDs.IDENTITY_REQUEST_WCDMA.value
1539            if identity_type == UEIdentityType.IMSI:
1540                userdata = IMSI_READ_USERDATA_WCDMA
1541            elif identity_type == UEIdentityType.IMEI:
1542                userdata = IMEI_READ_USERDATA_WCDMA
1543            elif identity_type == UEIdentityType.IMEISV:
1544                userdata = IMEISV_READ_USERDATA_WCDMA
1545            else:
1546                return None
1547        elif rat == BtsTechnology.GSM.value:
1548            identity_request = TriggerMessageIDs.IDENTITY_REQUEST_GSM.value
1549            if identity_type == UEIdentityType.IMSI:
1550                userdata = IMSI_READ_USERDATA_GSM
1551            elif identity_type == UEIdentityType.IMEI:
1552                userdata = IMEI_READ_USERDATA_GSM
1553            elif identity_type == UEIdentityType.IMEISV:
1554                userdata = IMEISV_READ_USERDATA_GSM
1555            else:
1556                return None
1557        else:
1558            return None
1559
1560        self.send_command("TMMESSAGEMODE {},USERDATA".format(identity_request))
1561        time.sleep(SETTLING_TIME)
1562        self.send_command("TMUSERDATA {}, {}, {}".format(
1563            identity_request, userdata, IDENTITY_REQ_DATA_LEN))
1564        time.sleep(SETTLING_TIME)
1565        self.send_command("TMSENDUSERMSG {}".format(identity_request))
1566        time.sleep(WAIT_TIME_IDENTITY_RESPONSE)
1567        # Go through sequence log and find the identity response message
1568        target = '"{}"'.format(identity_type.value)
1569        seqlog = self.send_query("SEQLOG?").split(",")
1570        while (target not in seqlog):
1571            index = int(seqlog[0]) - 1
1572            if index < SEQ_LOG_MESSAGE_START_INDEX:
1573                self.log.error("Can not find " + target)
1574                return None
1575            seqlog = self.send_query("SEQLOG? %d" % index).split(",")
1576        return (seqlog[-1])
1577
1578    def trigger_ue_capability_enquiry(self, requested_bands):
1579        """ Triggers LTE RRC UE capability enquiry from callbox.
1580
1581        Args:
1582            requested_bands: User data in hex format
1583        """
1584        self.set_trigger_message_mode(TriggerMessageIDs.UE_CAPABILITY_ENQUIRY)
1585        time.sleep(SETTLING_TIME)
1586        self.set_data_of_trigger_message(
1587            TriggerMessageIDs.UE_CAPABILITY_ENQUIRY, requested_bands)
1588        time.sleep(SETTLING_TIME)
1589        self.send_trigger_message(TriggerMessageIDs.UE_CAPABILITY_ENQUIRY)
1590        time.sleep(SETTLING_TIME)
1591
1592    def get_measured_pusch_power(self):
1593        """ Queries the PUSCH power.
1594
1595        Returns:
1596            A string indicating PUSCH power in each input port.
1597        """
1598        return self.send_query("MONITOR? UL_PUSCH")
1599
1600    def select_usim(self, usim):
1601        """ Select pre-defined Anritsu USIM models
1602
1603        Args:
1604            usim: any of P0035Bx, P0135Ax, P0250Ax, P0260Ax
1605
1606        Returns:
1607            None
1608        """
1609        cmd = "SELECTUSIM {}".format(usim)
1610        self.send_command(cmd)
1611
1612
1613class _AnritsuTestCases(object):
1614    '''Class to interact with the MD8475 supported test procedures '''
1615    def __init__(self, anritsu):
1616        self._anritsu = anritsu
1617        self.log = anritsu.log
1618
1619    @property
1620    def procedure(self):
1621        """ Gets the current Test Procedure type
1622
1623        Args:
1624            None
1625
1626        Returns:
1627            One of TestProcedure type values
1628        """
1629        return self._anritsu.send_query("TESTPROCEDURE?")
1630
1631    @procedure.setter
1632    def procedure(self, procedure):
1633        """ sets the Test Procedure type
1634        Args:
1635            procedure: One of TestProcedure type values
1636
1637        Returns:
1638            None
1639        """
1640        if not isinstance(procedure, TestProcedure):
1641            raise ValueError(
1642                'The parameter should be of type "TestProcedure" ')
1643        cmd = "TESTPROCEDURE " + procedure.value
1644        self._anritsu.send_command(cmd)
1645
1646    @property
1647    def bts_direction(self):
1648        """ Gets the current Test direction
1649
1650         Args:
1651            None
1652
1653        Returns:
1654            Current Test direction eg:BTS2,BTS1
1655        """
1656        return self._anritsu.send_query("TESTBTSDIRECTION?")
1657
1658    @bts_direction.setter
1659    def bts_direction(self, direction):
1660        """ sets the Test direction  eg: BTS1 to BTS2 '''
1661
1662        Args:
1663            direction: tuple (from-bts,to_bts) of type BtsNumber
1664
1665        Returns:
1666            None
1667        """
1668        if not isinstance(direction, tuple) or len(direction) != 2:
1669            raise ValueError("Pass a tuple with two items")
1670        from_bts, to_bts = direction
1671        if (isinstance(from_bts, BtsNumber) and isinstance(to_bts, BtsNumber)):
1672            cmd = "TESTBTSDIRECTION {},{}".format(from_bts.value, to_bts.value)
1673            self._anritsu.send_command(cmd)
1674        else:
1675            raise ValueError(' The parameters should be of type "BtsNumber" ')
1676
1677    @property
1678    def registration_timeout(self):
1679        """ Gets the current Test registration timeout
1680
1681        Args:
1682            None
1683
1684        Returns:
1685            Current test registration timeout value
1686        """
1687        return self._anritsu.send_query("TESTREGISTRATIONTIMEOUT?")
1688
1689    @registration_timeout.setter
1690    def registration_timeout(self, timeout_value):
1691        """ sets the Test registration timeout value
1692        Args:
1693            timeout_value: test registration timeout value
1694
1695        Returns:
1696            None
1697        """
1698        cmd = "TESTREGISTRATIONTIMEOUT " + str(timeout_value)
1699        self._anritsu.send_command(cmd)
1700
1701    @property
1702    def power_control(self):
1703        """ Gets the power control enabled/disabled status for test case
1704
1705        Args:
1706            None
1707
1708        Returns:
1709            current power control enabled/disabled status
1710        """
1711        return self._anritsu.send_query("TESTPOWERCONTROL?")
1712
1713    @power_control.setter
1714    def power_control(self, enable):
1715        """ Sets the power control enabled/disabled status for test case
1716
1717        Args:
1718            enable:  enabled/disabled
1719
1720        Returns:
1721            None
1722        """
1723        if not isinstance(enable, TestPowerControl):
1724            raise ValueError(' The parameter should be of type'
1725                             ' "TestPowerControl" ')
1726        cmd = "TESTPOWERCONTROL " + enable.value
1727        self._anritsu.send_command(cmd)
1728
1729    @property
1730    def measurement_LTE(self):
1731        """ Checks measurement status for LTE test case
1732
1733        Args:
1734            None
1735
1736        Returns:
1737            Enabled/Disabled
1738        """
1739        return self._anritsu.send_query("TESTMEASUREMENT? LTE")
1740
1741    @measurement_LTE.setter
1742    def measurement_LTE(self, enable):
1743        """ Sets the measurement enabled/disabled status for LTE test case
1744
1745        Args:
1746            enable:  enabled/disabled
1747
1748        Returns:
1749            None
1750        """
1751        if not isinstance(enable, TestMeasurement):
1752            raise ValueError(' The parameter should be of type'
1753                             ' "TestMeasurement" ')
1754        cmd = "TESTMEASUREMENT LTE," + enable.value
1755        self._anritsu.send_command(cmd)
1756
1757    @property
1758    def measurement_WCDMA(self):
1759        """ Checks measurement status for WCDMA test case
1760
1761        Args:
1762            None
1763
1764        Returns:
1765            Enabled/Disabled
1766        """
1767        return self._anritsu.send_query("TESTMEASUREMENT? WCDMA")
1768
1769    @measurement_WCDMA.setter
1770    def measurement_WCDMA(self, enable):
1771        """ Sets the measurement enabled/disabled status for WCDMA test case
1772
1773        Args:
1774            enable:  enabled/disabled
1775
1776        Returns:
1777            None
1778        """
1779        if not isinstance(enable, TestMeasurement):
1780            raise ValueError(' The parameter should be of type'
1781                             ' "TestMeasurement" ')
1782        cmd = "TESTMEASUREMENT WCDMA," + enable.value
1783        self._anritsu.send_command(cmd)
1784
1785    @property
1786    def measurement_TDSCDMA(self):
1787        """ Checks measurement status for TDSCDMA test case
1788
1789        Args:
1790            None
1791
1792        Returns:
1793            Enabled/Disabled
1794        """
1795        return self._anritsu.send_query("TESTMEASUREMENT? TDSCDMA")
1796
1797    @measurement_TDSCDMA.setter
1798    def measurement_WCDMA(self, enable):
1799        """ Sets the measurement enabled/disabled status for TDSCDMA test case
1800
1801        Args:
1802            enable:  enabled/disabled
1803
1804        Returns:
1805            None
1806        """
1807        if not isinstance(enable, TestMeasurement):
1808            raise ValueError(' The parameter should be of type'
1809                             ' "TestMeasurement" ')
1810        cmd = "TESTMEASUREMENT TDSCDMA," + enable.value
1811        self._anritsu.send_command(cmd)
1812
1813    def set_pdn_targeteps(self, pdn_order, pdn_number=1):
1814        """ Sets PDN to connect as a target when performing the
1815           test case for packet handover
1816
1817        Args:
1818            pdn_order:  PRIORITY/USER
1819            pdn_number: Target PDN number
1820
1821        Returns:
1822            None
1823        """
1824        cmd = "TESTPDNTARGETEPS " + pdn_order
1825        if pdn_order == "USER":
1826            cmd = cmd + "," + str(pdn_number)
1827        self._anritsu.send_command(cmd)
1828
1829
1830class _BaseTransceiverStation(object):
1831    '''Class to interact different BTS supported by MD8475 '''
1832    def __init__(self, anritsu, btsnumber):
1833        if not isinstance(btsnumber, BtsNumber):
1834            raise ValueError(' The parameter should be of type "BtsNumber" ')
1835        self._bts_number = btsnumber.value
1836        self._anritsu = anritsu
1837        self.log = anritsu.log
1838
1839    @property
1840    def output_level(self):
1841        """ Gets the Downlink power of the cell
1842
1843        Args:
1844            None
1845
1846        Returns:
1847            DL Power level
1848        """
1849        cmd = "OLVL? " + self._bts_number
1850        return self._anritsu.send_query(cmd)
1851
1852    @output_level.setter
1853    def output_level(self, level):
1854        """ Sets the Downlink power of the cell
1855
1856        Args:
1857            level: Power level
1858
1859        Returns:
1860            None
1861        """
1862        counter = 1
1863        while float(level) != float(self.output_level):
1864            if counter > 3:
1865                raise AnritsuError("Fail to set output level in 3 tries!")
1866            cmd = "OLVL {},{}".format(level, self._bts_number)
1867            self._anritsu.send_command(cmd)
1868            counter += 1
1869            time.sleep(1)
1870
1871    @property
1872    def input_level(self):
1873        """ Gets the reference power of the cell
1874
1875        Args:
1876            None
1877
1878        Returns:
1879            Reference Power level
1880        """
1881        cmd = "RFLVL? " + self._bts_number
1882        return self._anritsu.send_query(cmd)
1883
1884    @input_level.setter
1885    def input_level(self, level):
1886        """ Sets the reference power of the cell
1887
1888        Args:
1889            level: Power level
1890
1891        Returns:
1892            None
1893        """
1894        counter = 1
1895        while float(level) != float(self.input_level):
1896            if counter > 3:
1897                raise AnritsuError("Fail to set intput level in 3 tries!")
1898            cmd = "RFLVL {},{}".format(level, self._bts_number)
1899            self._anritsu.send_command(cmd)
1900            counter += 1
1901            time.sleep(1)
1902
1903    @property
1904    def band(self):
1905        """ Gets the Band of the cell
1906
1907        Args:
1908            None
1909
1910        Returns:
1911            Cell band
1912        """
1913        cmd = "BAND? " + self._bts_number
1914        return self._anritsu.send_query(cmd)
1915
1916    @band.setter
1917    def band(self, band):
1918        """ Sets the Band of the cell
1919
1920        Args:
1921            band: Band of the cell
1922
1923        Returns:
1924            None
1925        """
1926        cmd = "BAND {},{}".format(band, self._bts_number)
1927        self._anritsu.send_command(cmd)
1928
1929    @property
1930    def transmode(self):
1931        """ Gets the Transmission Mode of the cell
1932
1933        Args:
1934            None
1935
1936        Returns:
1937            Transmission mode
1938        """
1939        cmd = "TRANSMODE? " + self._bts_number
1940        return self._anritsu.send_query(cmd)
1941
1942    @transmode.setter
1943    def transmode(self, tm_mode):
1944        """ Sets the TM of the cell
1945
1946        Args:
1947            TM: TM of the cell
1948
1949        Returns:
1950            None
1951        """
1952        cmd = "TRANSMODE {},{}".format(tm_mode, self._bts_number)
1953        self._anritsu.send_command(cmd)
1954
1955    @property
1956    def duplex_mode(self):
1957        """ Gets the Duplex Mode of the cell
1958
1959        Args:
1960            None
1961
1962        Returns:
1963            Duplex mode
1964        """
1965        cmd = "DUPLEXMODE? " + self._bts_number
1966        return self._anritsu.send_query(cmd)
1967
1968    @duplex_mode.setter
1969    def duplex_mode(self, mode):
1970        """ Sets the duplex mode for the cell
1971
1972        Args:
1973            mode: string indicating FDD or TDD
1974
1975        Returns:
1976            None
1977        """
1978        cmd = "DUPLEXMODE {},{}".format(mode, self._bts_number)
1979        self._anritsu.send_command(cmd)
1980
1981    @property
1982    def uldl_configuration(self):
1983        """ Gets the UL/DL pattern configuration for TDD bands
1984
1985        Args:
1986            None
1987
1988        Returns:
1989            Configuration number
1990        """
1991        cmd = "ULDLCONFIGURATION? " + self._bts_number
1992        return self._anritsu.send_query(cmd)
1993
1994    @uldl_configuration.setter
1995    def uldl_configuration(self, configuration):
1996        """ Sets the UL/DL pattern configuration for TDD bands
1997
1998        Args:
1999            configuration: configuration number, [ 0, 6 ] inclusive
2000
2001        Returns:
2002            None
2003
2004        Raises:
2005            ValueError: Frame structure has to be [ 0, 6 ] inclusive
2006        """
2007        if configuration not in range(0, 7):
2008            raise ValueError("The frame structure configuration has to be a "
2009                             "number between 0 and 6 inclusive")
2010
2011        cmd = "ULDLCONFIGURATION {},{}".format(configuration, self._bts_number)
2012        self._anritsu.send_command(cmd)
2013
2014    @property
2015    def cfi(self):
2016        """ Gets the Control Format Indicator for this base station.
2017
2018        Args:
2019            None
2020
2021        Returns:
2022            The CFI number.
2023        """
2024        cmd = "CFI? " + self._bts_number
2025        return self._anritsu.send_query(cmd)
2026
2027    @cfi.setter
2028    def cfi(self, cfi):
2029        """ Sets the Control Format Indicator for this base station.
2030
2031        Args:
2032            cfi: one of BESTEFFORT, AUTO, 1, 2 or 3.
2033
2034        Returns:
2035            None
2036
2037        Raises:
2038            ValueError: if cfi's value is invalid
2039        """
2040
2041        cfi = str(cfi)
2042
2043        valid_values = {'BESTEFFORT', 'AUTO', '1', '2', '3'}
2044        if cfi not in valid_values:
2045            raise ValueError('Valid values for CFI are %r' % valid_values)
2046
2047        cmd = "CFI {},{}".format(cfi, self._bts_number)
2048        self._anritsu.send_command(cmd)
2049
2050    @property
2051    def paging_duration(self):
2052        """ Gets the paging cycle duration for this base station.
2053
2054        Args:
2055            None
2056
2057        Returns:
2058            The paging cycle duration in milliseconds.
2059        """
2060        cmd = "PCYCLE? " + self._bts_number
2061        return self._anritsu.send_query(cmd)
2062
2063    @paging_duration.setter
2064    def paging_duration(self, duration):
2065        """ Sets the paging cycle duration for this base station.
2066
2067        Args:
2068            duration: the paging cycle duration in milliseconds.
2069
2070        Returns:
2071            None
2072
2073        Raises:
2074            ValueError: if duration's value is invalid
2075        """
2076
2077        duration = int(duration)
2078
2079        valid_values = {320, 640, 1280, 2560}
2080        if duration not in valid_values:
2081            raise ValueError('Valid values for the paging cycle duration are '
2082                             '%r.' % valid_values)
2083
2084        cmd = "PCYCLE {},{}".format(duration, self._bts_number)
2085        self._anritsu.send_command(cmd)
2086
2087    @property
2088    def phich_resource(self):
2089        """ Gets the PHICH Resource setting for this base station.
2090
2091        Args:
2092            None
2093
2094        Returns:
2095            The PHICH Resource setting.
2096        """
2097        cmd = "PHICHRESOURCE? " + self._bts_number
2098        return self._anritsu.send_query(cmd)
2099
2100    @phich_resource.setter
2101    def phich_resource(self, phich):
2102        """ Sets the PHICH Resource setting for this base station.
2103
2104        Args:
2105            phich: one of 1/6, 1/2, 1, 2.
2106
2107        Returns:
2108            None
2109
2110        Raises:
2111            ValueError: if phich's value is invalid
2112        """
2113
2114        phich = str(phich)
2115
2116        valid_values = ['1/6', '1/2', '1', '2']
2117        if phich not in valid_values:
2118            raise ValueError('Valid values for PHICH Resource are %r' %
2119                             valid_values)
2120
2121        cmd = "PHICHRESOURCE {},{}".format(phich, self._bts_number)
2122        self._anritsu.send_command(cmd)
2123
2124    @property
2125    def tdd_special_subframe(self):
2126        """ Gets SPECIALSUBFRAME of cell.
2127
2128        Args:
2129            None
2130
2131        Returns:
2132            tdd_special_subframe: integer between 0,9 inclusive
2133        """
2134        cmd = "SPECIALSUBFRAME? " + self._bts_number
2135        tdd_special_subframe = int(self._anritsu.send_query(cmd))
2136        return tdd_special_subframe
2137
2138    @tdd_special_subframe.setter
2139    def tdd_special_subframe(self, tdd_special_subframe):
2140        """ Sets SPECIALSUBFRAME of cell.
2141
2142        Args:
2143            tdd_special_subframe: int between 0,9 inclusive
2144
2145        Returns:
2146            None
2147
2148        Raises:
2149            ValueError: tdd_special_subframe has to be between 0,9 inclusive
2150        """
2151        if tdd_special_subframe not in range(0, 10):
2152            raise ValueError("The special subframe config is not [0,9]")
2153        cmd = "SPECIALSUBFRAME {},{}".format(tdd_special_subframe,
2154                                             self._bts_number)
2155        self._anritsu.send_command(cmd)
2156
2157    @property
2158    def dl_antenna(self):
2159        """ Gets the DL ANTENNA count of the cell
2160
2161        Args:
2162            None
2163
2164        Returns:
2165            No of DL Antenna
2166        """
2167        cmd = "ANTENNAS? " + self._bts_number
2168        return self._anritsu.send_query(cmd)
2169
2170    @dl_antenna.setter
2171    def dl_antenna(self, num_antenna):
2172        """ Sets the DL ANTENNA of the cell
2173
2174        Args:
2175            c: DL ANTENNA of the cell
2176
2177        Returns:
2178            None
2179        """
2180        cmd = "ANTENNAS {},{}".format(num_antenna, self._bts_number)
2181        self._anritsu.send_command(cmd)
2182
2183    @property
2184    def bandwidth(self):
2185        """ Gets the channel bandwidth of the cell
2186
2187        Args:
2188            None
2189
2190        Returns:
2191            channel bandwidth
2192        """
2193        cmd = "BANDWIDTH? " + self._bts_number
2194        return self._anritsu.send_query(cmd)
2195
2196    @bandwidth.setter
2197    def bandwidth(self, bandwidth):
2198        """ Sets the channel bandwidth of the cell
2199
2200        Args:
2201            bandwidth: channel bandwidth  of the cell
2202
2203        Returns:
2204            None
2205        """
2206        if not isinstance(bandwidth, BtsBandwidth):
2207            raise ValueError(' The parameter should be of type "BtsBandwidth"')
2208        cmd = "BANDWIDTH {},{}".format(bandwidth.value, self._bts_number)
2209        self._anritsu.send_command(cmd)
2210
2211    @property
2212    def dl_bandwidth(self):
2213        """ Gets the downlink bandwidth of the cell
2214
2215        Args:
2216            None
2217
2218        Returns:
2219            downlink bandwidth
2220        """
2221        cmd = "DLBANDWIDTH? " + self._bts_number
2222        return self._anritsu.send_query(cmd)
2223
2224    @dl_bandwidth.setter
2225    def dl_bandwidth(self, bandwidth):
2226        """ Sets the downlink bandwidth of the cell
2227
2228        Args:
2229            bandwidth: downlink bandwidth of the cell
2230
2231        Returns:
2232            None
2233        """
2234        if not isinstance(bandwidth, BtsBandwidth):
2235            raise ValueError(' The parameter should be of type "BtsBandwidth"')
2236        cmd = "DLBANDWIDTH {},{}".format(bandwidth.value, self._bts_number)
2237        self._anritsu.send_command(cmd)
2238
2239    @property
2240    def ul_bandwidth(self):
2241        """ Gets the uplink bandwidth of the cell
2242
2243        Args:
2244            None
2245
2246        Returns:
2247            uplink bandwidth
2248        """
2249        cmd = "ULBANDWIDTH? " + self._bts_number
2250        return self._anritsu.send_query(cmd)
2251
2252    @ul_bandwidth.setter
2253    def ul_bandwidth(self, bandwidth):
2254        """ Sets the uplink bandwidth of the cell
2255
2256        Args:
2257            bandwidth: uplink bandwidth of the cell
2258
2259        Returns:
2260            None
2261        """
2262        if not isinstance(bandwidth, BtsBandwidth):
2263            raise ValueError(
2264                ' The parameter should be of type "BtsBandwidth" ')
2265        cmd = "ULBANDWIDTH {},{}".format(bandwidth.value, self._bts_number)
2266        self._anritsu.send_command(cmd)
2267
2268    @property
2269    def packet_rate(self):
2270        """ Gets the packet rate of the cell
2271
2272        Args:
2273            None
2274
2275        Returns:
2276            packet rate
2277        """
2278        cmd = "PACKETRATE? " + self._bts_number
2279        return self._anritsu.send_query(cmd)
2280
2281    @packet_rate.setter
2282    def packet_rate(self, packetrate):
2283        """ Sets the packet rate of the cell
2284
2285        Args:
2286            packetrate: packet rate of the cell
2287
2288        Returns:
2289            None
2290        """
2291        if not isinstance(packetrate, BtsPacketRate):
2292            raise ValueError(' The parameter should be of type'
2293                             ' "BtsPacketRate" ')
2294        cmd = "PACKETRATE {},{}".format(packetrate.value, self._bts_number)
2295        self._anritsu.send_command(cmd)
2296
2297    @property
2298    def ul_windowsize(self):
2299        """ Gets the uplink window size of the cell
2300
2301        Args:
2302            None
2303
2304        Returns:
2305            uplink window size
2306        """
2307        cmd = "ULWINSIZE? " + self._bts_number
2308        return self._anritsu.send_query(cmd)
2309
2310    @ul_windowsize.setter
2311    def ul_windowsize(self, windowsize):
2312        """ Sets the uplink window size of the cell
2313
2314        Args:
2315            windowsize: uplink window size of the cell
2316
2317        Returns:
2318            None
2319        """
2320        if not isinstance(windowsize, BtsPacketWindowSize):
2321            raise ValueError(' The parameter should be of type'
2322                             ' "BtsPacketWindowSize" ')
2323        cmd = "ULWINSIZE {},{}".format(windowsize.value, self._bts_number)
2324        self._anritsu.send_command(cmd)
2325
2326    @property
2327    def dl_windowsize(self):
2328        """ Gets the downlink window size of the cell
2329
2330        Args:
2331            None
2332
2333        Returns:
2334            downlink window size
2335        """
2336        cmd = "DLWINSIZE? " + self._bts_number
2337        return self._anritsu.send_query(cmd)
2338
2339    @dl_windowsize.setter
2340    def dl_windowsize(self, windowsize):
2341        """ Sets the downlink window size of the cell
2342
2343        Args:
2344            windowsize: downlink window size of the cell
2345
2346        Returns:
2347            None
2348        """
2349        if not isinstance(windowsize, BtsPacketWindowSize):
2350            raise ValueError(' The parameter should be of type'
2351                             ' "BtsPacketWindowSize" ')
2352        cmd = "DLWINSIZE {},{}".format(windowsize.value, self._bts_number)
2353        self._anritsu.send_command(cmd)
2354
2355    @property
2356    def service_state(self):
2357        """ Gets the service state of BTS
2358
2359        Args:
2360            None
2361
2362        Returns:
2363            service state IN/OUT
2364        """
2365        cmd = "OUTOFSERVICE? " + self._bts_number
2366        return self._anritsu.send_query(cmd)
2367
2368    @service_state.setter
2369    def service_state(self, service_state):
2370        """ Sets the service state of BTS
2371
2372        Args:
2373            service_state: service state of BTS , IN/OUT
2374
2375        Returns:
2376            None
2377        """
2378        if not isinstance(service_state, BtsServiceState):
2379            raise ValueError(' The parameter should be of type'
2380                             ' "BtsServiceState" ')
2381        cmd = "OUTOFSERVICE {},{}".format(service_state.value,
2382                                          self._bts_number)
2383        self._anritsu.send_command(cmd)
2384
2385    @property
2386    def cell_barred(self):
2387        """ Gets the Cell Barred state of the cell
2388
2389        Args:
2390            None
2391
2392        Returns:
2393            one of BtsCellBarred value
2394        """
2395        cmd = "CELLBARRED?" + self._bts_number
2396        return self._anritsu.send_query(cmd)
2397
2398    @cell_barred.setter
2399    def cell_barred(self, barred_option):
2400        """ Sets the Cell Barred state of the cell
2401
2402        Args:
2403            barred_option: Cell Barred state of the cell
2404
2405        Returns:
2406            None
2407        """
2408        if not isinstance(barred_option, BtsCellBarred):
2409            raise ValueError(' The parameter should be of type'
2410                             ' "BtsCellBarred" ')
2411        cmd = "CELLBARRED {},{}".format(barred_option.value, self._bts_number)
2412        self._anritsu.send_command(cmd)
2413
2414    @property
2415    def accessclass_barred(self):
2416        """ Gets the Access Class Barred state of the cell
2417
2418        Args:
2419            None
2420
2421        Returns:
2422            one of BtsAccessClassBarred value
2423        """
2424        cmd = "ACBARRED? " + self._bts_number
2425        return self._anritsu.send_query(cmd)
2426
2427    @accessclass_barred.setter
2428    def accessclass_barred(self, barred_option):
2429        """ Sets the Access Class Barred state of the cell
2430
2431        Args:
2432            barred_option: Access Class Barred state of the cell
2433
2434        Returns:
2435            None
2436        """
2437        if not isinstance(barred_option, BtsAccessClassBarred):
2438            raise ValueError(' The parameter should be of type'
2439                             ' "BtsAccessClassBarred" ')
2440        cmd = "ACBARRED {},{}".format(barred_option.value, self._bts_number)
2441        self._anritsu.send_command(cmd)
2442
2443    @property
2444    def lteemergency_ac_barred(self):
2445        """ Gets the LTE emergency Access Class Barred state of the cell
2446
2447        Args:
2448            None
2449
2450        Returns:
2451            one of BtsLteEmergencyAccessClassBarred value
2452        """
2453        cmd = "LTEEMERGENCYACBARRED? " + self._bts_number
2454        return self._anritsu.send_query(cmd)
2455
2456    @lteemergency_ac_barred.setter
2457    def lteemergency_ac_barred(self, barred_option):
2458        """ Sets the LTE emergency Access Class Barred state of the cell
2459
2460        Args:
2461            barred_option: Access Class Barred state of the cell
2462
2463        Returns:
2464            None
2465        """
2466        if not isinstance(barred_option, BtsLteEmergencyAccessClassBarred):
2467            raise ValueError(' The parameter should be of type'
2468                             ' "BtsLteEmergencyAccessClassBarred" ')
2469        cmd = "LTEEMERGENCYACBARRED {},{}".format(barred_option.value,
2470                                                  self._bts_number)
2471        self._anritsu.send_command(cmd)
2472
2473    @property
2474    def mcc(self):
2475        """ Gets the MCC of the cell
2476
2477        Args:
2478            None
2479
2480        Returns:
2481            MCC of the cell
2482        """
2483        cmd = "MCC? " + self._bts_number
2484        return self._anritsu.send_query(cmd)
2485
2486    @mcc.setter
2487    def mcc(self, mcc_code):
2488        """ Sets the MCC of the cell
2489
2490        Args:
2491            mcc_code: MCC of the cell
2492
2493        Returns:
2494            None
2495        """
2496        cmd = "MCC {},{}".format(mcc_code, self._bts_number)
2497        self._anritsu.send_command(cmd)
2498
2499    @property
2500    def mnc(self):
2501        """ Gets the MNC of the cell
2502
2503        Args:
2504            None
2505
2506        Returns:
2507            MNC of the cell
2508        """
2509        cmd = "MNC? " + self._bts_number
2510        return self._anritsu.send_query(cmd)
2511
2512    @mnc.setter
2513    def mnc(self, mnc_code):
2514        """ Sets the MNC of the cell
2515
2516        Args:
2517            mnc_code: MNC of the cell
2518
2519        Returns:
2520            None
2521        """
2522        cmd = "MNC {},{}".format(mnc_code, self._bts_number)
2523        self._anritsu.send_command(cmd)
2524
2525    @property
2526    def nw_fullname_enable(self):
2527        """ Gets the network full name enable status
2528
2529        Args:
2530            None
2531
2532        Returns:
2533            one of BtsNwNameEnable value
2534        """
2535        cmd = "NWFNAMEON? " + self._bts_number
2536        return self._anritsu.send_query(cmd)
2537
2538    @nw_fullname_enable.setter
2539    def nw_fullname_enable(self, enable):
2540        """ Sets the network full name enable status
2541
2542        Args:
2543            enable: network full name enable status
2544
2545        Returns:
2546            None
2547        """
2548        if not isinstance(enable, BtsNwNameEnable):
2549            raise ValueError(' The parameter should be of type'
2550                             ' "BtsNwNameEnable" ')
2551        cmd = "NWFNAMEON {},{}".format(enable.value, self._bts_number)
2552        self._anritsu.send_command(cmd)
2553
2554    @property
2555    def nw_fullname(self):
2556        """ Gets the network full name
2557
2558        Args:
2559            None
2560
2561        Returns:
2562            Network fulll name
2563        """
2564        cmd = "NWFNAME? " + self._bts_number
2565        return self._anritsu.send_query(cmd)
2566
2567    @nw_fullname.setter
2568    def nw_fullname(self, fullname):
2569        """ Sets the network full name
2570
2571        Args:
2572            fullname: network full name
2573
2574        Returns:
2575            None
2576        """
2577        cmd = "NWFNAME {},{}".format(fullname, self._bts_number)
2578        self._anritsu.send_command(cmd)
2579
2580    @property
2581    def nw_shortname_enable(self):
2582        """ Gets the network short name enable status
2583
2584        Args:
2585            None
2586
2587        Returns:
2588            one of BtsNwNameEnable value
2589        """
2590        cmd = "NWSNAMEON? " + self._bts_number
2591        return self._anritsu.send_query(cmd)
2592
2593    @nw_shortname_enable.setter
2594    def nw_shortname_enable(self, enable):
2595        """ Sets the network short name enable status
2596
2597        Args:
2598            enable: network short name enable status
2599
2600        Returns:
2601            None
2602        """
2603        if not isinstance(enable, BtsNwNameEnable):
2604            raise ValueError(' The parameter should be of type'
2605                             ' "BtsNwNameEnable" ')
2606        cmd = "NWSNAMEON {},{}".format(enable.value, self._bts_number)
2607        self._anritsu.send_command(cmd)
2608
2609    @property
2610    def nw_shortname(self):
2611        """ Gets the network short name
2612
2613        Args:
2614            None
2615
2616        Returns:
2617            Network short name
2618        """
2619        cmd = "NWSNAME? " + self._bts_number
2620        return self._anritsu.send_query(cmd)
2621
2622    @nw_shortname.setter
2623    def nw_shortname(self, shortname):
2624        """ Sets the network short name
2625
2626        Args:
2627            shortname: network short name
2628
2629        Returns:
2630            None
2631        """
2632        cmd = "NWSNAME {},{}".format(shortname, self._bts_number)
2633        self._anritsu.send_command(cmd)
2634
2635    def apply_parameter_changes(self):
2636        """ apply the parameter changes at run time
2637
2638        Args:
2639            None
2640
2641        Returns:
2642            None
2643        """
2644        cmd = "APPLYPARAM"
2645        self._anritsu.send_command(cmd)
2646
2647    @property
2648    def wcdma_ctch(self):
2649        """ Gets the WCDMA CTCH enable/disable status
2650
2651        Args:
2652            None
2653
2654        Returns:
2655            one of CTCHSetup values
2656        """
2657        cmd = "CTCHPARAMSETUP? " + self._bts_number
2658        return self._anritsu.send_query(cmd)
2659
2660    @wcdma_ctch.setter
2661    def wcdma_ctch(self, enable):
2662        """ Sets the WCDMA CTCH enable/disable status
2663
2664        Args:
2665            enable: WCDMA CTCH enable/disable status
2666
2667        Returns:
2668            None
2669        """
2670        cmd = "CTCHPARAMSETUP {},{}".format(enable.value, self._bts_number)
2671        self._anritsu.send_command(cmd)
2672
2673    @property
2674    def lac(self):
2675        """ Gets the Location Area Code of the cell
2676
2677        Args:
2678            None
2679
2680        Returns:
2681            LAC value
2682        """
2683        cmd = "LAC? " + self._bts_number
2684        return self._anritsu.send_query(cmd)
2685
2686    @lac.setter
2687    def lac(self, lac):
2688        """ Sets the Location Area Code of the cell
2689
2690        Args:
2691            lac: Location Area Code of the cell
2692
2693        Returns:
2694            None
2695        """
2696        cmd = "LAC {},{}".format(lac, self._bts_number)
2697        self._anritsu.send_command(cmd)
2698
2699    @property
2700    def rac(self):
2701        """ Gets the Routing Area Code of the cell
2702
2703        Args:
2704            None
2705
2706        Returns:
2707            RAC value
2708        """
2709        cmd = "RAC? " + self._bts_number
2710        return self._anritsu.send_query(cmd)
2711
2712    @rac.setter
2713    def rac(self, rac):
2714        """ Sets the Routing Area Code of the cell
2715
2716        Args:
2717            rac: Routing Area Code of the cell
2718
2719        Returns:
2720            None
2721        """
2722        cmd = "RAC {},{}".format(rac, self._bts_number)
2723        self._anritsu.send_command(cmd)
2724
2725    @property
2726    def dl_channel(self):
2727        """ Gets the downlink channel number of the cell
2728
2729        Args:
2730            None
2731
2732        Returns:
2733            RAC value
2734        """
2735        cmd = "DLCHAN? " + self._bts_number
2736        return self._anritsu.send_query(cmd)
2737
2738    @dl_channel.setter
2739    def dl_channel(self, channel):
2740        """ Sets the downlink channel number of the cell
2741
2742        Args:
2743            channel: downlink channel number of the cell
2744
2745        Returns:
2746            None
2747        """
2748        cmd = "DLCHAN {},{}".format(channel, self._bts_number)
2749        self._anritsu.send_command(cmd)
2750
2751    @property
2752    def dl_cc_enabled(self):
2753        """ Checks if component carrier is enabled or disabled
2754
2755        Args:
2756            None
2757
2758        Returns:
2759            True if enabled, False if disabled
2760        """
2761        return (self._anritsu.send_query("TESTDLCC?" +
2762                                         self._bts_number) == "ENABLE")
2763
2764    @dl_cc_enabled.setter
2765    def dl_cc_enabled(self, enabled):
2766        """ Enables or disables the component carrier
2767
2768        Args:
2769            enabled: True if it should be enabled, False if disabled
2770
2771        Returns:
2772            None
2773        """
2774        cmd = "TESTDLCC {},{}".format("ENABLE" if enabled else "DISABLE",
2775                                      self._bts_number)
2776        self._anritsu.send_command(cmd)
2777
2778    @property
2779    def sector1_mcc(self):
2780        """ Gets the sector 1 MCC of the CDMA cell
2781
2782        Args:
2783            None
2784
2785        Returns:
2786            sector 1 mcc
2787        """
2788        cmd = "S1MCC? " + self._bts_number
2789        return self._anritsu.send_query(cmd)
2790
2791    @sector1_mcc.setter
2792    def sector1_mcc(self, mcc):
2793        """ Sets the sector 1 MCC of the CDMA cell
2794
2795        Args:
2796            mcc: sector 1 MCC of the CDMA cell
2797
2798        Returns:
2799            None
2800        """
2801        cmd = "S1MCC {},{}".format(mcc, self._bts_number)
2802        self._anritsu.send_command(cmd)
2803
2804    @property
2805    def sector1_sid(self):
2806        """ Gets the sector 1 system ID of the CDMA cell
2807
2808        Args:
2809            None
2810
2811        Returns:
2812            sector 1 system Id
2813        """
2814        cmd = "S1SID? " + self._bts_number
2815        return self._anritsu.send_query(cmd)
2816
2817    @sector1_sid.setter
2818    def sector1_sid(self, sid):
2819        """ Sets the sector 1 system ID of the CDMA cell
2820
2821        Args:
2822            sid: sector 1 system ID of the CDMA cell
2823
2824        Returns:
2825            None
2826        """
2827        cmd = "S1SID {},{}".format(sid, self._bts_number)
2828        self._anritsu.send_command(cmd)
2829
2830    @property
2831    def sector1_nid(self):
2832        """ Gets the sector 1 network ID of the CDMA cell
2833
2834        Args:
2835            None
2836
2837        Returns:
2838            sector 1 network Id
2839        """
2840        cmd = "S1NID? " + self._bts_number
2841        return self._anritsu.send_query(cmd)
2842
2843    @sector1_nid.setter
2844    def sector1_nid(self, nid):
2845        """ Sets the sector 1 network ID of the CDMA cell
2846
2847        Args:
2848            nid: sector 1 network ID of the CDMA cell
2849
2850        Returns:
2851            None
2852        """
2853        cmd = "S1NID {},{}".format(nid, self._bts_number)
2854        self._anritsu.send_command(cmd)
2855
2856    @property
2857    def sector1_baseid(self):
2858        """ Gets the sector 1 Base ID of the CDMA cell
2859
2860        Args:
2861            None
2862
2863        Returns:
2864            sector 1 Base Id
2865        """
2866        cmd = "S1BASEID? " + self._bts_number
2867        return self._anritsu.send_query(cmd)
2868
2869    @sector1_baseid.setter
2870    def sector1_baseid(self, baseid):
2871        """ Sets the sector 1 Base ID of the CDMA cell
2872
2873        Args:
2874            baseid: sector 1 Base ID of the CDMA cell
2875
2876        Returns:
2877            None
2878        """
2879        cmd = "S1BASEID {},{}".format(baseid, self._bts_number)
2880        self._anritsu.send_command(cmd)
2881
2882    @property
2883    def sector1_latitude(self):
2884        """ Gets the sector 1 latitude of the CDMA cell
2885
2886        Args:
2887            None
2888
2889        Returns:
2890            sector 1 latitude
2891        """
2892        cmd = "S1LATITUDE? " + self._bts_number
2893        return self._anritsu.send_query(cmd)
2894
2895    @sector1_latitude.setter
2896    def sector1_latitude(self, latitude):
2897        """ Sets the sector 1 latitude of the CDMA cell
2898
2899        Args:
2900            latitude: sector 1 latitude of the CDMA cell
2901
2902        Returns:
2903            None
2904        """
2905        cmd = "S1LATITUDE {},{}".format(latitude, self._bts_number)
2906        self._anritsu.send_command(cmd)
2907
2908    @property
2909    def sector1_longitude(self):
2910        """ Gets the sector 1 longitude of the CDMA cell
2911
2912        Args:
2913            None
2914
2915        Returns:
2916            sector 1 longitude
2917        """
2918        cmd = "S1LONGITUDE? " + self._bts_number
2919        return self._anritsu.send_query(cmd)
2920
2921    @sector1_longitude.setter
2922    def sector1_longitude(self, longitude):
2923        """ Sets the sector 1 longitude of the CDMA cell
2924
2925        Args:
2926            longitude: sector 1 longitude of the CDMA cell
2927
2928        Returns:
2929            None
2930        """
2931        cmd = "S1LONGITUDE {},{}".format(longitude, self._bts_number)
2932        self._anritsu.send_command(cmd)
2933
2934    @property
2935    def evdo_sid(self):
2936        """ Gets the Sector ID of the EVDO cell
2937
2938        Args:
2939            None
2940
2941        Returns:
2942            Sector Id
2943        """
2944        cmd = "S1SECTORID? " + self._bts_number
2945        return self._anritsu.send_query(cmd)
2946
2947    @evdo_sid.setter
2948    def evdo_sid(self, sid):
2949        """ Sets the Sector ID of the EVDO cell
2950
2951        Args:
2952            sid: Sector ID of the EVDO cell
2953
2954        Returns:
2955            None
2956        """
2957        cmd = "S1SECTORID {},{}".format(sid, self._bts_number)
2958        self._anritsu.send_command(cmd)
2959
2960    @property
2961    def cell_id(self):
2962        """ Gets the cell identity of the cell
2963
2964        Args:
2965            None
2966
2967        Returns:
2968            cell identity
2969        """
2970        cmd = "CELLID? " + self._bts_number
2971        return self._anritsu.send_query(cmd)
2972
2973    @cell_id.setter
2974    def cell_id(self, cell_id):
2975        """ Sets the cell identity of the cell
2976
2977        Args:
2978            cell_id: cell identity of the cell
2979
2980        Returns:
2981            None
2982        """
2983        cmd = "CELLID {},{}".format(cell_id, self._bts_number)
2984        self._anritsu.send_command(cmd)
2985
2986    @property
2987    def physical_cellid(self):
2988        """ Gets the physical cell id of the cell
2989
2990        Args:
2991            None
2992
2993        Returns:
2994            physical cell id
2995        """
2996        cmd = "PHYCELLID? " + self._bts_number
2997        return self._anritsu.send_query(cmd)
2998
2999    @physical_cellid.setter
3000    def physical_cellid(self, physical_cellid):
3001        """ Sets the physical cell id of the cell
3002
3003        Args:
3004            physical_cellid: physical cell id of the cell
3005
3006        Returns:
3007            None
3008        """
3009        cmd = "PHYCELLID {},{}".format(physical_cellid, self._bts_number)
3010        self._anritsu.send_command(cmd)
3011
3012    @property
3013    def gsm_mcs_dl(self):
3014        """ Gets the Modulation and Coding scheme (DL) of the GSM cell
3015
3016        Args:
3017            None
3018
3019        Returns:
3020            DL MCS
3021        """
3022        cmd = "DLMCS? " + self._bts_number
3023        return self._anritsu.send_query(cmd)
3024
3025    @gsm_mcs_dl.setter
3026    def gsm_mcs_dl(self, mcs_dl):
3027        """ Sets the Modulation and Coding scheme (DL) of the GSM cell
3028
3029        Args:
3030            mcs_dl: Modulation and Coding scheme (DL) of the GSM cell
3031
3032        Returns:
3033            None
3034        """
3035        cmd = "DLMCS {},{}".format(mcs_dl, self._bts_number)
3036        self._anritsu.send_command(cmd)
3037
3038    @property
3039    def gsm_mcs_ul(self):
3040        """ Gets the Modulation and Coding scheme (UL) of the GSM cell
3041
3042        Args:
3043            None
3044
3045        Returns:
3046            UL MCS
3047        """
3048        cmd = "ULMCS? " + self._bts_number
3049        return self._anritsu.send_query(cmd)
3050
3051    @gsm_mcs_ul.setter
3052    def gsm_mcs_ul(self, mcs_ul):
3053        """ Sets the Modulation and Coding scheme (UL) of the GSM cell
3054
3055        Args:
3056            mcs_ul:Modulation and Coding scheme (UL) of the GSM cell
3057
3058        Returns:
3059            None
3060        """
3061        cmd = "ULMCS {},{}".format(mcs_ul, self._bts_number)
3062        self._anritsu.send_command(cmd)
3063
3064    @property
3065    def lte_scheduling_mode(self):
3066        """ Gets the Scheduling mode of the LTE cell
3067
3068        Args:
3069            None
3070
3071        Returns:
3072            Scheduling mode
3073        """
3074        cmd = "SCHEDULEMODE? " + self._bts_number
3075        return self._anritsu.send_query(cmd)
3076
3077    @lte_scheduling_mode.setter
3078    def lte_scheduling_mode(self, mode):
3079        """ Sets the Scheduling mode of the LTE cell
3080
3081        Args:
3082            mode: STATIC (default) or DYNAMIC
3083
3084        Returns:
3085            None
3086        """
3087        counter = 1
3088        while mode != self.lte_scheduling_mode:
3089            if counter > 3:
3090                raise AnritsuError("Fail to set scheduling mode in 3 tries!")
3091            cmd = "SCHEDULEMODE {},{}".format(mode, self._bts_number)
3092            self._anritsu.send_command(cmd)
3093            counter += 1
3094            time.sleep(1)
3095
3096    @property
3097    def tbs_pattern(self):
3098        """ Gets the TBS Pattern setting for the LTE cell
3099
3100        Args:
3101            None
3102
3103        Returns:
3104            TBS Pattern setting
3105        """
3106        cmd = "TBSPATTERN? " + self._bts_number
3107        return self._anritsu.send_query(cmd)
3108
3109    @tbs_pattern.setter
3110    def tbs_pattern(self, pattern):
3111        """ Sets the TBS Pattern setting for the LTE cell
3112
3113        Args:
3114            mode: "FULLALLOCATION" or "OFF"
3115
3116        Returns:
3117            None
3118        """
3119        cmd = "TBSPATTERN {}, {}".format(pattern, self._bts_number)
3120        self._anritsu.send_command(cmd)
3121
3122    @property
3123    def drx_connected_mode(self):
3124        """ Gets the Connected DRX LTE cell parameter
3125
3126        Args:
3127            None
3128
3129        Returns:
3130            DRX connected mode (OFF, AUTO, MANUAL)
3131        """
3132        cmd = "DRXCONN? " + self._bts_number
3133        return self._anritsu.send_query(cmd)
3134
3135    @drx_connected_mode.setter
3136    def drx_connected_mode(self, mode):
3137        """  Sets the Connected DRX LTE cell parameter
3138
3139        Args:
3140            mode: OFF, AUTO, MANUAL
3141
3142        Returns:
3143            None
3144        """
3145        cmd = "DRXCONN {}, {}".format(mode, self._bts_number)
3146        self._anritsu.send_command(cmd)
3147
3148    @property
3149    def drx_on_duration_timer(self):
3150        """ Gets the amount of PDCCH subframes to wait for data after
3151            waking up from a DRX cycle
3152
3153        Args:
3154            None
3155
3156        Returns:
3157            DRX mode duration timer
3158        """
3159        cmd = "DRXDURATIONTIME? " + self._bts_number
3160        return self._anritsu.send_query(cmd)
3161
3162    @drx_on_duration_timer.setter
3163    def drx_on_duration_timer(self, time):
3164        """ Sets the amount of PDCCH subframes to wait for data after
3165            waking up from a DRX cycle
3166
3167        Args:
3168            timer: Amount of PDCCH subframes to wait for user data
3169                to be transmitted
3170
3171        Returns:
3172            None
3173        """
3174        cmd = "DRXDURATIONTIME PSF{}, {}".format(time, self._bts_number)
3175        self._anritsu.send_command(cmd)
3176
3177    @property
3178    def drx_inactivity_timer(self):
3179        """ Gets the number of PDCCH subframes to wait before entering DRX mode
3180
3181        Args:
3182            None
3183
3184        Returns:
3185            DRX mode inactivity timer
3186        """
3187        cmd = "DRXINACTIVITYTIME? " + self._bts_number
3188        return self._anritsu.send_query(cmd)
3189
3190    @drx_inactivity_timer.setter
3191    def drx_inactivity_timer(self, time):
3192        """ Sets the number of PDCCH subframes to wait before entering DRX mode
3193
3194        Args:
3195            timer: Length of the interval to wait
3196
3197        Returns:
3198            None
3199        """
3200        cmd = "DRXINACTIVITYTIME PSF{}, {}".format(time, self._bts_number)
3201        self._anritsu.send_command(cmd)
3202
3203    @property
3204    def drx_retransmission_timer(self):
3205        """ Gets the number of consecutive PDCCH subframes to wait
3206        for retransmission
3207
3208        Args:
3209            None
3210
3211        Returns:
3212            Number of PDCCH subframes to wait for retransmission
3213        """
3214        cmd = "DRXRETRANSTIME? " + self._bts_number
3215        return self._anritsu.send_query(cmd)
3216
3217    @drx_retransmission_timer.setter
3218    def drx_retransmission_timer(self, time):
3219        """ Sets the number of consecutive PDCCH subframes to wait
3220        for retransmission
3221
3222        Args:
3223            time: Number of PDCCH subframes to wait
3224            for retransmission
3225
3226        Returns:
3227            None
3228        """
3229        cmd = "DRXRETRANSTIME PSF{}, {}".format(time, self._bts_number)
3230        self._anritsu.send_command(cmd)
3231
3232    @property
3233    def drx_long_cycle(self):
3234        """ Gets the amount of subframes representing a DRX long cycle
3235
3236        Args:
3237            None
3238
3239        Returns:
3240            The amount of subframes representing one long DRX cycle.
3241            One cycle consists of DRX sleep + DRX on duration
3242        """
3243        cmd = "DRXLONGCYCLE? " + self._bts_number
3244        return self._anritsu.send_query(cmd)
3245
3246    @drx_long_cycle.setter
3247    def drx_long_cycle(self, time):
3248        """ Sets the amount of subframes representing a DRX long cycle
3249
3250        Args:
3251            long_cycle: The amount of subframes representing one long DRX cycle.
3252                One cycle consists of DRX sleep + DRX on duration
3253
3254        Returns:
3255            None
3256        """
3257        cmd = "DRXLONGCYCLE SF{}, {}".format(time, self._bts_number)
3258        self._anritsu.send_command(cmd)
3259
3260    @property
3261    def drx_long_cycle_offset(self):
3262        """ Gets the offset used to determine long cycle starting
3263        subframe
3264
3265        Args:
3266            None
3267
3268        Returns:
3269            Long cycle offset
3270        """
3271        cmd = "DRXLONGCYCLESTARTOFFSET? " + self._bts_number
3272        return self._anritsu.send_query(cmd)
3273
3274    @drx_long_cycle_offset.setter
3275    def drx_long_cycle_offset(self, offset):
3276        """ Sets the offset used to determine long cycle starting
3277        subframe
3278
3279        Args:
3280            offset: Number in range 0...(long cycle - 1)
3281        """
3282        cmd = "DRXLONGCYCLESTARTOFFSET {}, {}".format(offset, self._bts_number)
3283        self._anritsu.send_command(cmd)
3284
3285    @property
3286    def lte_mcs_dl(self):
3287        """ Gets the Modulation and Coding scheme (DL) of the LTE cell
3288
3289        Args:
3290            None
3291
3292        Returns:
3293            DL MCS
3294        """
3295        cmd = "DLIMCS? " + self._bts_number
3296        return self._anritsu.send_query(cmd)
3297
3298    @lte_mcs_dl.setter
3299    def lte_mcs_dl(self, mcs_dl):
3300        """ Sets the Modulation and Coding scheme (DL) of the LTE cell
3301
3302        Args:
3303            mcs_dl: Modulation and Coding scheme (DL) of the LTE cell
3304
3305        Returns:
3306            None
3307        """
3308        cmd = "DLIMCS {},{}".format(mcs_dl, self._bts_number)
3309        self._anritsu.send_command(cmd)
3310
3311    @property
3312    def lte_mcs_ul(self):
3313        """ Gets the Modulation and Coding scheme (UL) of the LTE cell
3314
3315        Args:
3316            None
3317
3318        Returns:
3319            UL MCS
3320        """
3321        cmd = "ULIMCS? " + self._bts_number
3322        return self._anritsu.send_query(cmd)
3323
3324    @lte_mcs_ul.setter
3325    def lte_mcs_ul(self, mcs_ul):
3326        """ Sets the Modulation and Coding scheme (UL) of the LTE cell
3327
3328        Args:
3329            mcs_ul: Modulation and Coding scheme (UL) of the LTE cell
3330
3331        Returns:
3332            None
3333        """
3334        cmd = "ULIMCS {},{}".format(mcs_ul, self._bts_number)
3335        self._anritsu.send_command(cmd)
3336
3337    @property
3338    def lte_dl_modulation_order(self):
3339        """ Gets the DL modulation order of the LTE cell
3340
3341        Args:
3342            None
3343
3344        Returns:
3345            The DL modulation order
3346        """
3347        cmd = "DLRMC_MOD? " + self._bts_number
3348        return self._anritsu.send_query(cmd)
3349
3350    @lte_dl_modulation_order.setter
3351    def lte_dl_modulation_order(self, order):
3352        """ Sets the DL modulation order of the LTE cell
3353
3354        Args:
3355            order: the DL modulation order of the LTE cell
3356
3357        Returns:
3358            None
3359        """
3360        if isinstance(order, ModulationType):
3361            order = order.value
3362        cmd = "DLRMC_MOD {},{}".format(order, self._bts_number)
3363        self._anritsu.send_command(cmd)
3364
3365    @property
3366    def lte_ul_modulation_order(self):
3367        """ Gets the UL modulation order of the LTE cell
3368
3369        Args:
3370            None
3371
3372        Returns:
3373            The UL modulation order
3374        """
3375        cmd = "ULRMC_MOD? " + self._bts_number
3376        return self._anritsu.send_query(cmd)
3377
3378    @lte_ul_modulation_order.setter
3379    def lte_ul_modulation_order(self, order):
3380        """ Sets the UL modulation order of the LTE cell
3381
3382        Args:
3383            order: the UL modulation order of the LTE cell
3384
3385        Returns:
3386            None
3387        """
3388        if isinstance(order, ModulationType):
3389            order = order.value
3390        cmd = "ULRMC_MOD {},{}".format(order, self._bts_number)
3391        self._anritsu.send_command(cmd)
3392
3393    @property
3394    def nrb_dl(self):
3395        """ Gets the Downlink N Resource Block of the cell
3396
3397        Args:
3398            None
3399
3400        Returns:
3401            Downlink NRB
3402        """
3403        cmd = "DLNRB? " + self._bts_number
3404        return self._anritsu.send_query(cmd)
3405
3406    @nrb_dl.setter
3407    def nrb_dl(self, blocks):
3408        """ Sets the Downlink N Resource Block of the cell
3409
3410        Args:
3411            blocks: Downlink N Resource Block of the cell
3412
3413        Returns:
3414            None
3415        """
3416        cmd = "DLNRB {},{}".format(blocks, self._bts_number)
3417        self._anritsu.send_command(cmd)
3418
3419    @property
3420    def nrb_ul(self):
3421        """ Gets the uplink N Resource Block of the cell
3422
3423        Args:
3424            None
3425
3426        Returns:
3427            uplink NRB
3428        """
3429        cmd = "ULNRB? " + self._bts_number
3430        return self._anritsu.send_query(cmd)
3431
3432    @nrb_ul.setter
3433    def nrb_ul(self, blocks):
3434        """ Sets the uplink N Resource Block of the cell
3435
3436        Args:
3437            blocks: uplink N Resource Block of the cell
3438
3439        Returns:
3440            None
3441        """
3442        cmd = "ULNRB {},{}".format(blocks, self._bts_number)
3443        self._anritsu.send_command(cmd)
3444
3445    @property
3446    def max_nrb_ul(self):
3447        ul_bandwidth = self.ul_bandwidth
3448        if ul_bandwidth == 'SAMEASDL':
3449            ul_bandwidth = self.dl_bandwidth
3450        max_nrb = MAX_NRB_FOR_BANDWIDTH.get(ul_bandwidth, None)
3451        if not max_nrb:
3452            raise ValueError('Could not get maximum RB allocation'
3453                             'for bandwidth: {}'.format(ul_bandwidth))
3454        return max_nrb
3455
3456    @property
3457    def mimo_support(self):
3458        """ Gets the maximum supported MIMO mode for the LTE bases tation.
3459
3460        Returns:
3461            the MIMO mode as a string
3462        """
3463        cmd = "LTEMIMO? " + self._bts_number
3464        return self._anritsu.send_query(cmd)
3465
3466    @mimo_support.setter
3467    def mimo_support(self, mode):
3468        """ Sets the maximum supported MIMO mode for the LTE base station.
3469
3470        Args:
3471            mode: a string or an object of the LteMimoMode class.
3472        """
3473
3474        if isinstance(mode, LteMimoMode):
3475            mode = mode.value
3476
3477        cmd = "LTEMIMO {},{}".format(self._bts_number, mode)
3478        self._anritsu.send_command(cmd)
3479
3480    @property
3481    def neighbor_cell_mode(self):
3482        """ Gets the neighbor cell mode
3483
3484        Args:
3485            None
3486
3487        Returns:
3488            current neighbor cell mode
3489        """
3490        cmd = "NCLIST? " + self._bts_number
3491        return self._anritsu.send_query(cmd)
3492
3493    @neighbor_cell_mode.setter
3494    def neighbor_cell_mode(self, mode):
3495        """ Sets the neighbor cell mode
3496
3497        Args:
3498            mode: neighbor cell mode , DEFAULT/ USERDATA
3499
3500        Returns:
3501            None
3502        """
3503        cmd = "NCLIST {},{}".format(mode, self._bts_number)
3504        self._anritsu.send_command(cmd)
3505
3506    def get_neighbor_cell_type(self, system, index):
3507        """ Gets the neighbor cell type
3508
3509        Args:
3510            system: simulation model of neighbor cell
3511                    LTE, WCDMA, TDSCDMA, GSM, CDMA1X,EVDO
3512            index: Index of neighbor cell
3513
3514        Returns:
3515            neighbor cell type
3516        """
3517        cmd = "NCTYPE? {},{},{}".format(system, index, self._bts_number)
3518        return self._anritsu.send_query(cmd)
3519
3520    def set_neighbor_cell_type(self, system, index, cell_type):
3521        """ Sets the neighbor cell type
3522
3523        Args:
3524            system: simulation model of neighbor cell
3525                   LTE, WCDMA, TDSCDMA, GSM, CDMA1X,EVDO
3526            index: Index of neighbor cell
3527            cell_type: cell type
3528                BTS1, BTS2, BTS3, BTS4,CELLNAME, DISABLE
3529
3530        Returns:
3531            None
3532        """
3533        cmd = "NCTYPE {},{},{},{}".format(system, index, cell_type,
3534                                          self._bts_number)
3535        self._anritsu.send_command(cmd)
3536
3537    def get_neighbor_cell_name(self, system, index):
3538        """ Gets the neighbor cell name
3539
3540        Args:
3541            system: simulation model of neighbor cell
3542                    LTE, WCDMA, TDSCDMA, GSM, CDMA1X,EVDO
3543            index: Index of neighbor cell
3544
3545        Returns:
3546            neighbor cell name
3547        """
3548        cmd = "NCCELLNAME? {},{},{}".format(system, index, self._bts_number)
3549        return self._anritsu.send_query(cmd)
3550
3551    def set_neighbor_cell_name(self, system, index, name):
3552        """ Sets the neighbor cell name
3553
3554        Args:
3555            system: simulation model of neighbor cell
3556                   LTE, WCDMA, TDSCDMA, GSM, CDMA1X,EVDO
3557            index: Index of neighbor cell
3558            name: cell name
3559
3560        Returns:
3561            None
3562        """
3563        cmd = "NCCELLNAME {},{},{},{}".format(system, index, name,
3564                                              self._bts_number)
3565        self._anritsu.send_command(cmd)
3566
3567    def get_neighbor_cell_mcc(self, system, index):
3568        """ Gets the neighbor cell mcc
3569
3570        Args:
3571            system: simulation model of neighbor cell
3572                    LTE, WCDMA, TDSCDMA, GSM, CDMA1X,EVDO
3573            index: Index of neighbor cell
3574
3575        Returns:
3576            neighbor cell mcc
3577        """
3578        cmd = "NCMCC? {},{},{}".format(system, index, self._bts_number)
3579        return self._anritsu.send_query(cmd)
3580
3581    def get_neighbor_cell_mnc(self, system, index):
3582        """ Gets the neighbor cell mnc
3583
3584        Args:
3585            system: simulation model of neighbor cell
3586                    LTE, WCDMA, TDSCDMA, GSM, CDMA1X,EVDO
3587            index: Index of neighbor cell
3588
3589        Returns:
3590            neighbor cell mnc
3591        """
3592        cmd = "NCMNC? {},{},{}".format(system, index, self._bts_number)
3593        return self._anritsu.send_query(cmd)
3594
3595    def get_neighbor_cell_id(self, system, index):
3596        """ Gets the neighbor cell id
3597
3598        Args:
3599            system: simulation model of neighbor cell
3600                    LTE, WCDMA, TDSCDMA, GSM, CDMA1X,EVDO
3601            index: Index of neighbor cell
3602
3603        Returns:
3604            neighbor cell id
3605        """
3606        cmd = "NCCELLID? {},{},{}".format(system, index, self._bts_number)
3607        return self._anritsu.send_query(cmd)
3608
3609    def get_neighbor_cell_tac(self, system, index):
3610        """ Gets the neighbor cell tracking area code
3611
3612        Args:
3613            system: simulation model of neighbor cell
3614                    LTE, WCDMA, TDSCDMA, GSM, CDMA1X,EVDO
3615            index: Index of neighbor cell
3616
3617        Returns:
3618            neighbor cell tracking area code
3619        """
3620        cmd = "NCTAC? {},{},{}".format(system, index, self._bts_number)
3621        return self._anritsu.send_query(cmd)
3622
3623    def get_neighbor_cell_dl_channel(self, system, index):
3624        """ Gets the neighbor cell downlink channel
3625
3626        Args:
3627            system: simulation model of neighbor cell
3628                    LTE, WCDMA, TDSCDMA, GSM, CDMA1X,EVDO
3629            index: Index of neighbor cell
3630
3631        Returns:
3632            neighbor cell tracking downlink channel
3633        """
3634        cmd = "NCDLCHAN? {},{},{}".format(system, index, self._bts_number)
3635        return self._anritsu.send_query(cmd)
3636
3637    def get_neighbor_cell_dl_bandwidth(self, system, index):
3638        """ Gets the neighbor cell downlink bandwidth
3639
3640        Args:
3641            system: simulation model of neighbor cell
3642                    LTE, WCDMA, TDSCDMA, GSM, CDMA1X,EVDO
3643            index: Index of neighbor cell
3644
3645        Returns:
3646            neighbor cell tracking downlink bandwidth
3647        """
3648        cmd = "NCDLBANDWIDTH {},{},{}".format(system, index, self._bts_number)
3649        return self._anritsu.send_query(cmd)
3650
3651    def get_neighbor_cell_pcid(self, system, index):
3652        """ Gets the neighbor cell physical cell id
3653
3654        Args:
3655            system: simulation model of neighbor cell
3656                    LTE, WCDMA, TDSCDMA, GSM, CDMA1X,EVDO
3657            index: Index of neighbor cell
3658
3659        Returns:
3660            neighbor cell physical cell id
3661        """
3662        cmd = "NCPHYCELLID {},{},{}".format(system, index, self._bts_number)
3663        return self._anritsu.send_query(cmd)
3664
3665    def get_neighbor_cell_lac(self, system, index):
3666        """ Gets the neighbor cell location area code
3667
3668        Args:
3669            system: simulation model of neighbor cell
3670                    LTE, WCDMA, TDSCDMA, GSM, CDMA1X,EVDO
3671            index: Index of neighbor cell
3672
3673        Returns:
3674            neighbor cell location area code
3675        """
3676        cmd = "NCLAC {},{},{}".format(system, index, self._bts_number)
3677        return self._anritsu.send_query(cmd)
3678
3679    def get_neighbor_cell_rac(self, system, index):
3680        """ Gets the neighbor cell routing area code
3681
3682        Args:
3683            system: simulation model of neighbor cell
3684                    LTE, WCDMA, TDSCDMA, GSM, CDMA1X,EVDO
3685            index: Index of neighbor cell
3686
3687        Returns:
3688            neighbor cell routing area code
3689        """
3690        cmd = "NCRAC {},{},{}".format(system, index, self._bts_number)
3691        return self._anritsu.send_query(cmd)
3692
3693    @property
3694    def primary_scrambling_code(self):
3695        """ Gets the primary scrambling code for WCDMA cell
3696
3697        Args:
3698            None
3699
3700        Returns:
3701            primary scrambling code
3702        """
3703        cmd = "PRISCRCODE? " + self._bts_number
3704        return self._anritsu.send_query(cmd)
3705
3706    @primary_scrambling_code.setter
3707    def primary_scrambling_code(self, psc):
3708        """ Sets the primary scrambling code for WCDMA cell
3709
3710        Args:
3711            psc: primary scrambling code
3712
3713        Returns:
3714            None
3715        """
3716        cmd = "PRISCRCODE {},{}".format(psc, self._bts_number)
3717        self._anritsu.send_command(cmd)
3718
3719    @property
3720    def tac(self):
3721        """ Gets the Tracking Area Code of the LTE cell
3722
3723        Args:
3724            None
3725
3726        Returns:
3727            Tracking Area Code of the LTE cell
3728        """
3729        cmd = "TAC? " + self._bts_number
3730        return self._anritsu.send_query(cmd)
3731
3732    @tac.setter
3733    def tac(self, tac):
3734        """ Sets the Tracking Area Code of the LTE cell
3735
3736        Args:
3737            tac: Tracking Area Code of the LTE cell
3738
3739        Returns:
3740            None
3741        """
3742        cmd = "TAC {},{}".format(tac, self._bts_number)
3743        self._anritsu.send_command(cmd)
3744
3745    @property
3746    def cell(self):
3747        """ Gets the current cell for BTS
3748
3749        Args:
3750            None
3751
3752        Returns:
3753            current cell for BTS
3754        """
3755        cmd = "CELLSEL? {}".format(self._bts_number)
3756        return self._anritsu.send_query(cmd)
3757
3758    @cell.setter
3759    def cell(self, cell_name):
3760        """ sets the  cell for BTS
3761        Args:
3762            cell_name: cell name
3763
3764        Returns:
3765            None
3766        """
3767        cmd = "CELLSEL {},{}".format(self._bts_number, cell_name)
3768        return self._anritsu.send_command(cmd)
3769
3770    @property
3771    def gsm_cbch(self):
3772        """ Gets the GSM CBCH enable/disable status
3773
3774        Args:
3775            None
3776
3777        Returns:
3778            one of CBCHSetup values
3779        """
3780        cmd = "CBCHPARAMSETUP? " + self._bts_number
3781        return self._anritsu.send_query(cmd)
3782
3783    @gsm_cbch.setter
3784    def gsm_cbch(self, enable):
3785        """ Sets the GSM CBCH enable/disable status
3786
3787        Args:
3788            enable: GSM CBCH enable/disable status
3789
3790        Returns:
3791            None
3792        """
3793        cmd = "CBCHPARAMSETUP {},{}".format(enable.value, self._bts_number)
3794        self._anritsu.send_command(cmd)
3795
3796    @property
3797    def gsm_gprs_mode(self):
3798        """ Gets the GSM connection mode
3799
3800        Args:
3801            None
3802
3803        Returns:
3804            A string indicating if connection is EGPRS, GPRS or non-GPRS
3805        """
3806        cmd = "GPRS? " + self._bts_number
3807        return self._anritsu.send_query(cmd)
3808
3809    @gsm_gprs_mode.setter
3810    def gsm_gprs_mode(self, mode):
3811        """ Sets the GPRS connection mode
3812
3813        Args:
3814            mode: GPRS connection mode
3815
3816        Returns:
3817            None
3818        """
3819
3820        if not isinstance(mode, BtsGprsMode):
3821            raise ValueError(' The parameter should be of type "BtsGprsMode"')
3822        cmd = "GPRS {},{}".format(mode.value, self._bts_number)
3823
3824        self._anritsu.send_command(cmd)
3825
3826    @property
3827    def gsm_slots(self):
3828        """ Gets the GSM slot assignment
3829
3830        Args:
3831            None
3832
3833        Returns:
3834            A tuple indicating DL and UL slots.
3835        """
3836
3837        cmd = "MLTSLTCFG? " + self._bts_number
3838
3839        response = self._anritsu.send_query(cmd)
3840        split_response = response.split(',')
3841
3842        if not len(split_response) == 2:
3843            raise ValueError(response)
3844
3845        return response[0], response[1]
3846
3847    @gsm_slots.setter
3848    def gsm_slots(self, slots):
3849        """ Sets the number of downlink / uplink slots for GSM
3850
3851        Args:
3852            slots: a tuple containing two ints indicating (DL,UL)
3853
3854        Returns:
3855            None
3856        """
3857
3858        try:
3859            dl, ul = slots
3860            dl = int(dl)
3861            ul = int(ul)
3862        except:
3863            raise ValueError(
3864                'The parameter slot has to be a tuple containing two ints '
3865                'indicating (dl,ul) slots.')
3866
3867        # Validate
3868        if dl < 1 or ul < 1 or dl + ul > 5:
3869            raise ValueError(
3870                'DL and UL slots have to be >= 1 and the sum <= 5.')
3871
3872        cmd = "MLTSLTCFG {},{},{}".format(dl, ul, self._bts_number)
3873
3874        self._anritsu.send_command(cmd)
3875
3876
3877class _VirtualPhone(object):
3878    '''Class to interact with virtual phone supported by MD8475 '''
3879    def __init__(self, anritsu):
3880        self._anritsu = anritsu
3881        self.log = anritsu.log
3882
3883    @property
3884    def id(self):
3885        """ Gets the virtual phone ID
3886
3887        Args:
3888            None
3889
3890        Returns:
3891            virtual phone ID
3892        """
3893        cmd = "VPID? "
3894        return self._anritsu.send_query(cmd)
3895
3896    @id.setter
3897    def id(self, phonenumber):
3898        """ Sets the virtual phone ID
3899
3900        Args:
3901            phonenumber: virtual phone ID
3902
3903        Returns:
3904            None
3905        """
3906        cmd = "VPID {}".format(phonenumber)
3907        self._anritsu.send_command(cmd)
3908
3909    @property
3910    def id_c2k(self):
3911        """ Gets the virtual phone ID for CDMA 1x
3912
3913        Args:
3914            None
3915
3916        Returns:
3917            virtual phone ID
3918        """
3919        cmd = "VPIDC2K? "
3920        return self._anritsu.send_query(cmd)
3921
3922    @id_c2k.setter
3923    def id_c2k(self, phonenumber):
3924        """ Sets the virtual phone ID for CDMA 1x
3925
3926        Args:
3927            phonenumber: virtual phone ID
3928
3929        Returns:
3930            None
3931        """
3932        cmd = "VPIDC2K {}".format(phonenumber)
3933        self._anritsu.send_command(cmd)
3934
3935    @property
3936    def auto_answer(self):
3937        """ Gets the auto answer status of virtual phone
3938
3939        Args:
3940            None
3941
3942        Returns:
3943            auto answer status, ON/OFF
3944        """
3945        cmd = "VPAUTOANSWER? "
3946        return self._anritsu.send_query(cmd)
3947
3948    @auto_answer.setter
3949    def auto_answer(self, option):
3950        """ Sets the auto answer feature
3951
3952        Args:
3953            option: tuple with two items for turning on Auto Answer
3954                    (OFF or (ON, timetowait))
3955
3956        Returns:
3957            None
3958        """
3959        enable = "OFF"
3960        time = 5
3961
3962        try:
3963            enable, time = option
3964        except ValueError:
3965            if enable != "OFF":
3966                raise ValueError("Pass a tuple with two items for"
3967                                 " Turning on Auto Answer")
3968        cmd = "VPAUTOANSWER {},{}".format(enable.value, time)
3969        self._anritsu.send_command(cmd)
3970
3971    @property
3972    def calling_mode(self):
3973        """ Gets the calling mode of virtual phone
3974
3975        Args:
3976            None
3977
3978        Returns:
3979            calling mode of virtual phone
3980        """
3981        cmd = "VPCALLINGMODE? "
3982        return self._anritsu.send_query(cmd)
3983
3984    @calling_mode.setter
3985    def calling_mode(self, calling_mode):
3986        """ Sets the calling mode of virtual phone
3987
3988        Args:
3989            calling_mode: calling mode of virtual phone
3990
3991        Returns:
3992            None
3993        """
3994        cmd = "VPCALLINGMODE {}".format(calling_mode)
3995        self._anritsu.send_command(cmd)
3996
3997    def set_voice_off_hook(self):
3998        """ Set the virtual phone operating mode to Voice Off Hook
3999
4000        Args:
4001            None
4002
4003        Returns:
4004            None
4005        """
4006        cmd = "OPERATEVPHONE 0"
4007        return self._anritsu.send_command(cmd)
4008
4009    def set_voice_on_hook(self):
4010        """ Set the virtual phone operating mode to Voice On Hook
4011
4012        Args:
4013            None
4014
4015        Returns:
4016            None
4017        """
4018        cmd = "OPERATEVPHONE 1"
4019        return self._anritsu.send_command(cmd)
4020
4021    def set_video_off_hook(self):
4022        """ Set the virtual phone operating mode to Video Off Hook
4023
4024        Args:
4025            None
4026
4027        Returns:
4028            None
4029        """
4030        cmd = "OPERATEVPHONE 2"
4031        return self._anritsu.send_command(cmd)
4032
4033    def set_video_on_hook(self):
4034        """ Set the virtual phone operating mode to Video On Hook
4035
4036        Args:
4037            None
4038
4039        Returns:
4040            None
4041        """
4042        cmd = "OPERATEVPHONE 3"
4043        return self._anritsu.send_command(cmd)
4044
4045    def set_call_waiting(self):
4046        """ Set the virtual phone operating mode to Call waiting
4047
4048        Args:
4049            None
4050
4051        Returns:
4052            None
4053        """
4054        cmd = "OPERATEVPHONE 4"
4055        return self._anritsu.send_command(cmd)
4056
4057    @property
4058    def status(self):
4059        """ Gets the virtual phone status
4060
4061        Args:
4062            None
4063
4064        Returns:
4065            virtual phone status
4066        """
4067        cmd = "VPSTAT?"
4068        status = self._anritsu.send_query(cmd)
4069        return _VP_STATUS[status]
4070
4071    def sendSms(self, phoneNumber, message):
4072        """ Sends the SMS data from Anritsu to UE
4073
4074        Args:
4075            phoneNumber: sender of SMS
4076            message: message text
4077
4078        Returns:
4079            None
4080        """
4081        cmd = ("SENDSMS /?PhoneNumber=001122334455&Sender={}&Text={}"
4082               "&DCS=00").format(phoneNumber, AnritsuUtils.gsm_encode(message))
4083        return self._anritsu.send_command(cmd)
4084
4085    def sendSms_c2k(self, phoneNumber, message):
4086        """ Sends the SMS data from Anritsu to UE (in CDMA)
4087
4088        Args:
4089            phoneNumber: sender of SMS
4090            message: message text
4091
4092        Returns:
4093            None
4094        """
4095        cmd = ("C2KSENDSMS System=CDMA\&Originating_Address={}\&UserData={}"
4096               ).format(phoneNumber, AnritsuUtils.cdma_encode(message))
4097        return self._anritsu.send_command(cmd)
4098
4099    def receiveSms(self):
4100        """ Receives SMS messages sent by the UE in an external application
4101
4102        Args:
4103            None
4104
4105        Returns:
4106            None
4107        """
4108        return self._anritsu.send_query("RECEIVESMS?")
4109
4110    def receiveSms_c2k(self):
4111        """ Receives SMS messages sent by the UE(in CDMA) in an external application
4112
4113        Args:
4114            None
4115
4116        Returns:
4117            None
4118        """
4119        return self._anritsu.send_query("C2KRECEIVESMS?")
4120
4121    def setSmsStatusReport(self, status):
4122        """ Set the Status Report value of the SMS
4123
4124        Args:
4125            status: status code
4126
4127        Returns:
4128            None
4129        """
4130        cmd = "SMSSTATUSREPORT {}".format(status)
4131        return self._anritsu.send_command(cmd)
4132
4133
4134class _PacketDataNetwork(object):
4135    '''Class to configure PDN parameters'''
4136    def __init__(self, anritsu, pdnnumber):
4137        self._pdn_number = pdnnumber
4138        self._anritsu = anritsu
4139        self.log = anritsu.log
4140
4141    # Default Gateway Selection
4142    @property
4143    def pdn_DG_selection(self):
4144        """ Gets the default gateway for the PDN
4145
4146        Args:
4147          None
4148
4149        Returns:
4150          Current UE status
4151        """
4152        cmd = "PDNDEFAULTGATEWAY? " + self._pdn_number
4153        return self._anritsu.send_query(cmd)
4154
4155    @pdn_DG_selection.setter
4156    def pdn_DG_selection(self, selection):
4157        """ Sets the default gateway selection for the PDN
4158
4159        Args:
4160          Selection: COMMON or USER
4161
4162        Returns:
4163          None
4164        """
4165        cmd = "PDNDEFAULTGATEWAY {},{}".format(self._pdn_number, selection)
4166        self._anritsu.send_command(cmd)
4167
4168    # PDN specific Default Gateway:
4169    @property
4170    def pdn_gateway_ipv4addr(self):
4171        """ Gets the IPv4 address of the default gateway
4172
4173        Args:
4174          None
4175
4176        Returns:
4177            current UE status
4178        """
4179        cmd = "PDNDGIPV4? " + self._pdn_number
4180        return self._anritsu.send_query(cmd)
4181
4182    @pdn_gateway_ipv4addr.setter
4183    def pdn_gateway_ipv4addr(self, ipv4_addr):
4184        """ sets the IPv4 address of the default gateway
4185
4186        Args:
4187            ipv4_addr: IPv4 address of the default gateway
4188
4189        Returns:
4190            None
4191        """
4192        cmd = "PDNDGIPV4 {},{}".format(self._pdn_number, ipv4_addr)
4193        self._anritsu.send_command(cmd)
4194
4195    @property
4196    def pdn_gateway_ipv6addr(self):
4197        """ Gets the IPv6 address of the default gateway
4198
4199        Args:
4200          None
4201
4202        Returns:
4203            current UE status
4204        """
4205        cmd = "PDNDGIPV6? " + self._pdn_number
4206        return self._anritsu.send_query(cmd)
4207
4208    @pdn_gateway_ipv6addr.setter
4209    def pdn_gateway_ipv6addr(self, ipv6_addr):
4210        """ sets the IPv6 address of the default gateway
4211
4212        Args:
4213            ipv6_addr: IPv6 address of the default gateway
4214
4215        Returns:
4216            None
4217        """
4218        cmd = "PDNDGIPV6 {},{}".format(self._pdn_number, ipv6_addr)
4219        self._anritsu.send_command(cmd)
4220
4221    @property
4222    def ue_address_iptype(self):
4223        """ Gets IP type of UE for particular PDN
4224
4225        Args:
4226            None
4227
4228        Returns:
4229            IP type of UE for particular PDN
4230        """
4231        cmd = "PDNIPTYPE? " + self._pdn_number
4232        return self._anritsu.send_query(cmd)
4233
4234    @ue_address_iptype.setter
4235    def ue_address_iptype(self, ip_type):
4236        """ Set IP type of UE for particular PDN
4237
4238        Args:
4239            ip_type: IP type of UE
4240
4241        Returns:
4242            None
4243        """
4244        if not isinstance(ip_type, IPAddressType):
4245            raise ValueError(
4246                ' The parameter should be of type "IPAddressType"')
4247        cmd = "PDNIPTYPE {},{}".format(self._pdn_number, ip_type.value)
4248        self._anritsu.send_command(cmd)
4249
4250    @property
4251    def ue_address_ipv4(self):
4252        """ Gets UE IPv4 address
4253
4254        Args:
4255            None
4256
4257        Returns:
4258            UE IPv4 address
4259        """
4260        cmd = "PDNIPV4? " + self._pdn_number
4261        return self._anritsu.send_query(cmd)
4262
4263    @ue_address_ipv4.setter
4264    def ue_address_ipv4(self, ip_address):
4265        """ Set UE IPv4 address
4266
4267        Args:
4268            ip_address: UE IPv4 address
4269
4270        Returns:
4271            None
4272        """
4273        cmd = "PDNIPV4 {},{}".format(self._pdn_number, ip_address)
4274        self._anritsu.send_command(cmd)
4275
4276    @property
4277    def ue_address_ipv6(self):
4278        """ Gets UE IPv6 address
4279
4280        Args:
4281            None
4282
4283        Returns:
4284            UE IPv6 address
4285        """
4286        cmd = "PDNIPV6? " + self._pdn_number
4287        return self._anritsu.send_query(cmd)
4288
4289    @ue_address_ipv6.setter
4290    def ue_address_ipv6(self, ip_address):
4291        """ Set UE IPv6 address
4292
4293        Args:
4294            ip_address: UE IPv6 address
4295
4296        Returns:
4297            None
4298        """
4299        cmd = "PDNIPV6 {},{}".format(self._pdn_number, ip_address)
4300        self._anritsu.send_command(cmd)
4301
4302    @property
4303    def primary_dns_address_ipv4(self):
4304        """ Gets Primary DNS server IPv4 address
4305
4306        Args:
4307            None
4308
4309        Returns:
4310            Primary DNS server IPv4 address
4311        """
4312        cmd = "PDNDNSIPV4PRI? " + self._pdn_number
4313        return self._anritsu.send_query(cmd)
4314
4315    @primary_dns_address_ipv4.setter
4316    def primary_dns_address_ipv4(self, ip_address):
4317        """ Set Primary DNS server IPv4 address
4318
4319        Args:
4320            ip_address: Primary DNS server IPv4 address
4321
4322        Returns:
4323            None
4324        """
4325        cmd = "PDNDNSIPV4PRI {},{}".format(self._pdn_number, ip_address)
4326        self._anritsu.send_command(cmd)
4327
4328    @property
4329    def secondary_dns_address_ipv4(self):
4330        """ Gets secondary DNS server IPv4 address
4331
4332        Args:
4333            None
4334
4335        Returns:
4336            secondary DNS server IPv4 address
4337        """
4338        cmd = "PDNDNSIPV4SEC? " + self._pdn_number
4339        return self._anritsu.send_query(cmd)
4340
4341    @secondary_dns_address_ipv4.setter
4342    def secondary_dns_address_ipv4(self, ip_address):
4343        """ Set secondary DNS server IPv4 address
4344
4345        Args:
4346            ip_address: secondary DNS server IPv4 address
4347
4348        Returns:
4349            None
4350        """
4351        cmd = "PDNDNSIPV4SEC {},{}".format(self._pdn_number, ip_address)
4352        self._anritsu.send_command(cmd)
4353
4354    @property
4355    def dns_address_ipv6(self):
4356        """ Gets DNS server IPv6 address
4357
4358        Args:
4359            None
4360
4361        Returns:
4362            DNS server IPv6 address
4363        """
4364        cmd = "PDNDNSIPV6? " + self._pdn_number
4365        return self._anritsu.send_query(cmd)
4366
4367    @dns_address_ipv6.setter
4368    def dns_address_ipv6(self, ip_address):
4369        """ Set DNS server IPv6 address
4370
4371        Args:
4372            ip_address: DNS server IPv6 address
4373
4374        Returns:
4375            None
4376        """
4377        cmd = "PDNDNSIPV6 {},{}".format(self._pdn_number, ip_address)
4378        self._anritsu.send_command(cmd)
4379
4380    @property
4381    def cscf_address_ipv4(self):
4382        """ Gets Secondary P-CSCF IPv4 address
4383
4384        Args:
4385            None
4386
4387        Returns:
4388            Secondary P-CSCF IPv4 address
4389        """
4390        cmd = "PDNPCSCFIPV4? " + self._pdn_number
4391        return self._anritsu.send_query(cmd)
4392
4393    @cscf_address_ipv4.setter
4394    def cscf_address_ipv4(self, ip_address):
4395        """ Set Secondary P-CSCF IPv4 address
4396
4397        Args:
4398            ip_address: Secondary P-CSCF IPv4 address
4399
4400        Returns:
4401            None
4402        """
4403        cmd = "PDNPCSCFIPV4 {},{}".format(self._pdn_number, ip_address)
4404        self._anritsu.send_command(cmd)
4405
4406    @property
4407    def cscf_address_ipv6(self):
4408        """ Gets P-CSCF IPv6 address
4409
4410        Args:
4411            None
4412
4413        Returns:
4414            P-CSCF IPv6 address
4415        """
4416        cmd = "PDNPCSCFIPV6? " + self._pdn_number
4417        return self._anritsu.send_query(cmd)
4418
4419    @cscf_address_ipv6.setter
4420    def cscf_address_ipv6(self, ip_address):
4421        """ Set P-CSCF IPv6 address
4422
4423        Args:
4424            ip_address: P-CSCF IPv6 address
4425
4426        Returns:
4427            None
4428        """
4429        cmd = "PDNPCSCFIPV6 {},{}".format(self._pdn_number, ip_address)
4430        self._anritsu.send_command(cmd)
4431
4432    @property
4433    def pdn_ims(self):
4434        """ Get PDN IMS VNID binding status
4435
4436        Args:
4437            None
4438
4439        Returns:
4440            PDN IMS VNID binding status
4441        """
4442        cmd = "PDNIMS? " + self._pdn_number
4443        return self._anritsu.send_query(cmd)
4444
4445    @pdn_ims.setter
4446    def pdn_ims(self, switch):
4447        """ Set PDN IMS VNID binding Enable/Disable
4448
4449        Args:
4450            switch: "ENABLE/DISABLE"
4451
4452        Returns:
4453            None
4454        """
4455        if not isinstance(switch, Switch):
4456            raise ValueError(' The parameter should be of type'
4457                             ' "Switch", ie, ENABLE or DISABLE ')
4458        cmd = "PDNIMS {},{}".format(self._pdn_number, switch.value)
4459        self._anritsu.send_command(cmd)
4460
4461    @property
4462    def pdn_vnid(self):
4463        """ Get PDN IMS VNID
4464
4465        Args:
4466            None
4467
4468        Returns:
4469            PDN IMS VNID
4470        """
4471        cmd = "PDNVNID? " + self._pdn_number
4472        return self._anritsu.send_query(cmd)
4473
4474    @pdn_vnid.setter
4475    def pdn_vnid(self, vnid):
4476        """ Set PDN IMS VNID
4477
4478        Args:
4479            vnid: 1~99
4480
4481        Returns:
4482            None
4483        """
4484        cmd = "PDNVNID {},{}".format(self._pdn_number, vnid)
4485        self._anritsu.send_command(cmd)
4486
4487    @property
4488    def pdn_apn_name(self):
4489        """ Get PDN APN NAME
4490
4491        Args:
4492            None
4493
4494        Returns:
4495            PDN APN NAME
4496        """
4497        cmd = "PDNCHECKAPN? " + self._pdn_number
4498        return self._anritsu.send_query(cmd)
4499
4500    @pdn_apn_name.setter
4501    def pdn_apn_name(self, name):
4502        """ Set PDN APN NAME
4503
4504        Args:
4505            name: fast.t-mobile.com, ims
4506
4507        Returns:
4508            None
4509        """
4510        cmd = "PDNCHECKAPN {},{}".format(self._pdn_number, name)
4511        self._anritsu.send_command(cmd)
4512
4513    @property
4514    def pdn_qci(self):
4515        """ Get PDN QCI Value
4516
4517        Args:
4518            None
4519
4520        Returns:
4521            PDN QCI Value
4522        """
4523        cmd = "PDNQCIDEFAULT? " + self._pdn_number
4524        return self._anritsu.send_query(cmd)
4525
4526    @pdn_qci.setter
4527    def pdn_qci(self, qci_value):
4528        """ Set PDN QCI Value
4529
4530        Args:
4531            qci_value: 5, 9
4532
4533        Returns:
4534            None
4535        """
4536        cmd = "PDNQCIDEFAULT {},{}".format(self._pdn_number, qci_value)
4537        self._anritsu.send_command(cmd)
4538
4539
4540class _TriggerMessage(object):
4541    '''Class to interact with trigger message handling supported by MD8475 '''
4542    def __init__(self, anritsu):
4543        self._anritsu = anritsu
4544        self.log = anritsu.log
4545
4546    def set_reply_type(self, message_id, reply_type):
4547        """ Sets the reply type of the trigger information
4548
4549        Args:
4550            message_id: trigger information message Id
4551            reply_type: reply type of the trigger information
4552
4553        Returns:
4554            None
4555        """
4556        if not isinstance(message_id, TriggerMessageIDs):
4557            raise ValueError(' The parameter should be of type'
4558                             ' "TriggerMessageIDs"')
4559        if not isinstance(reply_type, TriggerMessageReply):
4560            raise ValueError(' The parameter should be of type'
4561                             ' "TriggerMessageReply"')
4562
4563        cmd = "REJECTTYPE {},{}".format(message_id.value, reply_type.value)
4564        self._anritsu.send_command(cmd)
4565
4566    def set_reject_cause(self, message_id, cause):
4567        """ Sets the reject cause of the trigger information
4568
4569        Args:
4570            message_id: trigger information message Id
4571            cause: cause for reject
4572
4573        Returns:
4574            None
4575        """
4576        if not isinstance(message_id, TriggerMessageIDs):
4577            raise ValueError(' The parameter should be of type'
4578                             ' "TriggerMessageIDs"')
4579
4580        cmd = "REJECTCAUSE {},{}".format(message_id.value, cause)
4581        self._anritsu.send_command(cmd)
4582
4583
4584class _IMS_Services(object):
4585    '''Class to configure and operate IMS Services'''
4586    def __init__(self, anritsu, vnid):
4587        self._vnid = vnid
4588        self._anritsu = anritsu
4589        self.log = anritsu.log
4590
4591    @property
4592    def sync(self):
4593        """ Gets Sync Enable status
4594
4595        Args:
4596            None
4597
4598        Returns:
4599            VNID Sync Enable status
4600        """
4601        cmd = "IMSSYNCENABLE? " + self._vnid
4602        return self._anritsu.send_query(cmd)
4603
4604    @sync.setter
4605    def sync(self, switch):
4606        """ Set Sync Enable or Disable
4607
4608        Args:
4609            sync: ENABLE/DISABLE
4610
4611        Returns:
4612            None
4613        """
4614        if not isinstance(switch, Switch):
4615            raise ValueError(' The parameter should be of type "Switch"')
4616        cmd = "IMSSYNCENABLE {},{}".format(self._vnid, switch.value)
4617        self._anritsu.send_command(cmd)
4618
4619    @property
4620    def cscf_address_ipv4(self):
4621        """ Gets CSCF IPv4 address
4622
4623        Args:
4624            None
4625
4626        Returns:
4627            CSCF IPv4 address
4628        """
4629        cmd = "IMSCSCFIPV4? " + self._vnid
4630        return self._anritsu.send_query(cmd)
4631
4632    @cscf_address_ipv4.setter
4633    def cscf_address_ipv4(self, ip_address):
4634        """ Set CSCF IPv4 address
4635
4636        Args:
4637            ip_address: CSCF IPv4 address
4638
4639        Returns:
4640            None
4641        """
4642        cmd = "IMSCSCFIPV4 {},{}".format(self._vnid, ip_address)
4643        self._anritsu.send_command(cmd)
4644
4645    @property
4646    def cscf_address_ipv6(self):
4647        """ Gets CSCF IPv6 address
4648
4649        Args:
4650            None
4651
4652        Returns:
4653            CSCF IPv6 address
4654        """
4655        cmd = "IMSCSCFIPV6? " + self._vnid
4656        return self._anritsu.send_query(cmd)
4657
4658    @cscf_address_ipv6.setter
4659    def cscf_address_ipv6(self, ip_address):
4660        """ Set CSCF IPv6 address
4661
4662        Args:
4663            ip_address: CSCF IPv6 address
4664
4665        Returns:
4666            None
4667        """
4668        cmd = "IMSCSCFIPV6 {},{}".format(self._vnid, ip_address)
4669        self._anritsu.send_command(cmd)
4670
4671    @property
4672    def imscscf_iptype(self):
4673        """ Gets CSCF IP Type
4674
4675        Args:
4676            None
4677
4678        Returns:
4679            CSCF IP Type
4680        """
4681        cmd = "IMSCSCFIPTYPE? " + self._vnid
4682        return self._anritsu.send_query(cmd)
4683
4684    @imscscf_iptype.setter
4685    def imscscf_iptype(self, iptype):
4686        """ Set CSCF IP Type
4687
4688        Args:
4689            iptype: IPV4, IPV6, IPV4V6
4690
4691        Returns:
4692            None
4693        """
4694        cmd = "IMSCSCFIPTYPE {},{}".format(self._vnid, iptype)
4695        self._anritsu.send_command(cmd)
4696
4697    @property
4698    def cscf_monitoring_ua(self):
4699        """ Get CSCF Monitoring UA URI
4700
4701        Args:
4702            None
4703
4704        Returns:
4705            CSCF Monitoring UA URI
4706        """
4707        cmd = "IMSCSCFUAURI? " + self._vnid
4708        return self._anritsu.send_query(cmd)
4709
4710    @cscf_monitoring_ua.setter
4711    def cscf_monitoring_ua(self, ua_uri):
4712        """ Set CSCF Monitoring UA URI
4713
4714        Args:
4715            ua_uri: CSCF Monitoring UA URI
4716
4717        Returns:
4718            None
4719        """
4720        cmd = "IMSCSCFUAURI {},{}".format(self._vnid, ua_uri)
4721        self._anritsu.send_command(cmd)
4722
4723    @property
4724    def cscf_host_name(self):
4725        """ Get CSCF Host Name
4726
4727        Args:
4728            None
4729
4730        Returns:
4731            CSCF Host Name
4732        """
4733        cmd = "IMSCSCFNAME? " + self._vnid
4734        return self._anritsu.send_query(cmd)
4735
4736    @cscf_host_name.setter
4737    def cscf_host_name(self, host_name):
4738        """ Set CSCF Host Name
4739
4740        Args:
4741            host_name: CSCF Host Name
4742
4743        Returns:
4744            None
4745        """
4746        cmd = "IMSCSCFNAME {},{}".format(self._vnid, host_name)
4747        self._anritsu.send_command(cmd)
4748
4749    @property
4750    def cscf_ims_authentication(self):
4751        """ Get CSCF IMS Auth Value
4752
4753        Args:
4754            None
4755
4756        Returns:
4757            CSCF IMS Auth
4758        """
4759        cmd = "IMSCSCFAUTH? " + self._vnid
4760        return self._anritsu.send_query(cmd)
4761
4762    @cscf_ims_authentication.setter
4763    def cscf_ims_authentication(self, on_off):
4764        """ Set CSCF IMS Auth Value
4765
4766        Args:
4767            on_off: CSCF IMS Auth ENABLE/DISABLE
4768
4769        Returns:
4770            None
4771        """
4772        cmd = "IMSCSCFAUTH {},{}".format(self._vnid, on_off)
4773        self._anritsu.send_command(cmd)
4774
4775    @property
4776    def cscf_precondition(self):
4777        """ Get CSCF IMS Precondition
4778
4779        Args:
4780            None
4781
4782        Returns:
4783            CSCF IMS Precondition
4784        """
4785        cmd = "IMSCSCFPRECONDITION? " + self._vnid
4786        return self._anritsu.send_query(cmd)
4787
4788    @cscf_precondition.setter
4789    def cscf_precondition(self, on_off):
4790        """ Set CSCF IMS Precondition
4791
4792        Args:
4793            on_off: CSCF IMS Precondition ENABLE/DISABLE
4794
4795        Returns:
4796            None
4797        """
4798        cmd = "IMSCSCFPRECONDITION {},{}".format(self._vnid, on_off)
4799        self._anritsu.send_command(cmd)
4800
4801    @property
4802    def cscf_virtual_ua(self):
4803        """ Get CSCF Virtual UA URI
4804
4805        Args:
4806            None
4807
4808        Returns:
4809            CSCF Virtual UA URI
4810        """
4811        cmd = "IMSCSCFVUAURI? " + self._vnid
4812        return self._anritsu.send_query(cmd)
4813
4814    @cscf_virtual_ua.setter
4815    def cscf_virtual_ua(self, ua_uri):
4816        """ Set CSCF Virtual UA URI
4817
4818        Args:
4819            ua_uri: CSCF Virtual UA URI
4820
4821        Returns:
4822            None
4823        """
4824        cmd = "IMSCSCFVUAURI {},{}".format(self._vnid, ua_uri)
4825        self._anritsu.send_command(cmd)
4826
4827    @property
4828    def tmo_cscf_userslist_add(self):
4829        """ Get CSCF USERLIST
4830
4831        Args:
4832            None
4833
4834        Returns:
4835            CSCF USERLIST
4836        """
4837        cmd = "IMSCSCFUSERSLIST? " + self._vnid
4838        return self._anritsu.send_query(cmd)
4839
4840    @tmo_cscf_userslist_add.setter
4841    def tmo_cscf_userslist_add(self, username):
4842        """ Set CSCF USER to USERLIST
4843            This is needed if IMS AUTH is enabled
4844
4845        Args:
4846            username: CSCF Username
4847
4848        Returns:
4849            None
4850        """
4851        cmd = "IMSCSCFUSERSLISTADD {},{},00112233445566778899AABBCCDDEEFF,TS34108,AKAV1_MD5,\
4852        OPC,00000000000000000000000000000000,8000,TRUE,FALSE,0123456789ABCDEF0123456789ABCDEF,\
4853        54CDFEAB9889000001326754CDFEAB98,6754CDFEAB9889BAEFDC457623100132,\
4854        326754CDFEAB9889BAEFDC4576231001,TRUE,TRUE,TRUE".format(
4855            self._vnid, username)
4856        self._anritsu.send_command(cmd)
4857
4858    @property
4859    def fi_cscf_userslist_add(self):
4860        """ Get CSCF USERLIST
4861
4862        Args:
4863            None
4864
4865        Returns:
4866            CSCF USERLIST
4867        """
4868        cmd = "IMSCSCFUSERSLIST? " + self._vnid
4869        return self._anritsu.send_query(cmd)
4870
4871    @fi_cscf_userslist_add.setter
4872    def fi_cscf_userslist_add(self, username):
4873        """ Set CSCF USER to USERLIST
4874            This is needed if IMS AUTH is enabled
4875
4876        Args:
4877            username: CSCF Username
4878
4879        Returns:
4880            None
4881        """
4882        cmd = "IMSCSCFUSERSLISTADD {},{},00112233445566778899AABBCCDDEEFF,TS34108,AKAV1_MD5,\
4883        OPC,00000000000000000000000000000000,8000,TRUE,FALSE,0123456789ABCDEF0123456789ABCDEF,\
4884        54CDFEAB9889000001326754CDFEAB98,6754CDFEAB9889BAEFDC457623100132,\
4885        326754CDFEAB9889BAEFDC4576231001,TRUE,TRUE,TRUE".format(
4886            self._vnid, username)
4887        self._anritsu.send_command(cmd)
4888
4889    @property
4890    def vzw_cscf_userslist_add(self):
4891        """ Get CSCF USERLIST
4892
4893        Args:
4894            None
4895
4896        Returns:
4897            CSCF USERLIST
4898        """
4899        cmd = "IMSCSCFUSERSLIST? " + self._vnid
4900        return self._anritsu.send_query(cmd)
4901
4902    @vzw_cscf_userslist_add.setter
4903    def vzw_cscf_userslist_add(self, username):
4904        """ Set CSCF USER to USERLIST
4905            This is needed if IMS AUTH is enabled
4906
4907        Args:
4908            username: CSCF Username
4909
4910        Returns:
4911            None
4912        """
4913        cmd = "IMSCSCFUSERSLISTADD {},{},465B5CE8B199B49FAA5F0A2EE238A6BC,MILENAGE,AKAV1_MD5,\
4914        OP,5F1D289C5D354D0A140C2548F5F3E3BA,8000,TRUE,FALSE,0123456789ABCDEF0123456789ABCDEF,\
4915        54CDFEAB9889000001326754CDFEAB98,6754CDFEAB9889BAEFDC457623100132,\
4916        326754CDFEAB9889BAEFDC4576231001,TRUE,TRUE,TRUE".format(
4917            self._vnid, username)
4918        self._anritsu.send_command(cmd)
4919
4920    @property
4921    def dns(self):
4922        """ Gets DNS Enable status
4923
4924        Args:
4925            None
4926
4927        Returns:
4928            VNID DNS Enable status
4929        """
4930        cmd = "IMSDNS? " + self._vnid
4931        return self._anritsu.send_query(cmd)
4932
4933    @dns.setter
4934    def dns(self, switch):
4935        """ Set DNS Enable or Disable
4936
4937        Args:
4938            sync: ENABLE/DISABLE
4939
4940        Returns:
4941            None
4942        """
4943        if not isinstance(switch, Switch):
4944            raise ValueError(' The parameter should be of type "Switch"')
4945        cmd = "IMSDNS {},{}".format(self._vnid, switch.value)
4946        self._anritsu.send_command(cmd)
4947
4948    @property
4949    def ndp_nic(self):
4950        """ Gets NDP Network Interface name
4951
4952        Args:
4953            None
4954
4955        Returns:
4956            NDP NIC name
4957        """
4958        cmd = "IMSNDPNIC? " + self._vnid
4959        return self._anritsu.send_query(cmd)
4960
4961    @ndp_nic.setter
4962    def ndp_nic(self, nic_name):
4963        """ Set NDP Network Interface name
4964
4965        Args:
4966            nic_name: NDP Network Interface name
4967
4968        Returns:
4969            None
4970        """
4971        cmd = "IMSNDPNIC {},{}".format(self._vnid, nic_name)
4972        self._anritsu.send_command(cmd)
4973
4974    @property
4975    def ndp_prefix(self):
4976        """ Gets NDP IPv6 Prefix
4977
4978        Args:
4979            None
4980
4981        Returns:
4982            NDP IPv6 Prefix
4983        """
4984        cmd = "IMSNDPPREFIX? " + self._vnid
4985        return self._anritsu.send_query(cmd)
4986
4987    @ndp_prefix.setter
4988    def ndp_prefix(self, prefix_addr):
4989        """ Set NDP IPv6 Prefix
4990
4991        Args:
4992            prefix_addr: NDP IPV6 Prefix Addr
4993
4994        Returns:
4995            None
4996        """
4997        cmd = "IMSNDPPREFIX {},{},64".format(self._vnid, prefix_addr)
4998        self._anritsu.send_command(cmd)
4999
5000    @property
5001    def psap(self):
5002        """ Gets PSAP Enable status
5003
5004        Args:
5005            None
5006
5007        Returns:
5008            VNID PSAP Enable status
5009        """
5010        cmd = "IMSPSAP? " + self._vnid
5011        return self._anritsu.send_query(cmd)
5012
5013    @psap.setter
5014    def psap(self, switch):
5015        """ Set PSAP Enable or Disable
5016
5017        Args:
5018            switch: ENABLE/DISABLE
5019
5020        Returns:
5021            None
5022        """
5023        if not isinstance(switch, Switch):
5024            raise ValueError(' The parameter should be of type "Switch"')
5025        cmd = "IMSPSAP {},{}".format(self._vnid, switch.value)
5026        self._anritsu.send_command(cmd)
5027
5028    @property
5029    def psap_auto_answer(self):
5030        """ Gets PSAP Auto Answer status
5031
5032        Args:
5033            None
5034
5035        Returns:
5036            VNID PSAP Auto Answer status
5037        """
5038        cmd = "IMSPSAPAUTOANSWER? " + self._vnid
5039        return self._anritsu.send_query(cmd)
5040
5041    @psap_auto_answer.setter
5042    def psap_auto_answer(self, switch):
5043        """ Set PSAP Auto Answer Enable or Disable
5044
5045        Args:
5046            switch: ENABLE/DISABLE
5047
5048        Returns:
5049            None
5050        """
5051        if not isinstance(switch, Switch):
5052            raise ValueError(' The parameter should be of type "Switch"')
5053        cmd = "IMSPSAPAUTOANSWER {},{}".format(self._vnid, switch.value)
5054        self._anritsu.send_command(cmd)
5055
5056    def start_virtual_network(self):
5057        """ Start the specified Virtual Network (IMS service)
5058
5059        Args:
5060            None
5061
5062        Returns:
5063            None
5064        """
5065        cmd = "IMSSTARTVN " + self._vnid
5066        return self._anritsu.send_command(cmd)
5067