1#!/usr/bin/env python3.4 2# 3# Copyright 2018 - 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. 16from acts.controllers.anritsu_lib.md8475a import BtsGprsMode 17from acts.test_utils.power.tel_simulations.BaseSimulation import BaseSimulation 18from acts.test_utils.tel.anritsu_utils import GSM_BAND_DCS1800 19from acts.test_utils.tel.anritsu_utils import GSM_BAND_EGSM900 20from acts.test_utils.tel.anritsu_utils import GSM_BAND_GSM850 21from acts.test_utils.tel.anritsu_utils import GSM_BAND_RGSM900 22from acts.test_utils.tel.tel_defines import NETWORK_MODE_GSM_ONLY 23 24 25class GsmSimulation(BaseSimulation): 26 """ Simple GSM simulation with only one basestation. 27 28 """ 29 30 # Simulation config files in the callbox computer. 31 # These should be replaced in the future by setting up 32 # the same configuration manually. 33 34 GSM_BASIC_SIM_FILE = ('C:\\Users\MD8475A\Documents\DAN_configs\\' 35 'SIM_default_GSM.wnssp') 36 37 GSM_CELL_FILE = ('C:\\Users\MD8475A\Documents\\DAN_configs\\' 38 'CELL_GSM_config.wnscp') 39 40 # Test name parameters 41 42 PARAM_BAND = "band" 43 PARAM_GPRS = "gprs" 44 PARAM_EGPRS = "edge" 45 PARAM_NO_GPRS = "nogprs" 46 PARAM_SLOTS = "slots" 47 48 bands_parameter_mapping = { 49 '850': GSM_BAND_GSM850, 50 '900': GSM_BAND_EGSM900, 51 '1800': GSM_BAND_DCS1800, 52 '1900': GSM_BAND_RGSM900 53 } 54 55 def __init__(self, anritsu, log, dut, test_config, calibration_table): 56 """ Configures Anritsu system for GSM simulation with 1 basetation 57 58 Loads a simple LTE simulation enviroment with 1 basestation. It also 59 creates the BTS handle so we can change the parameters as desired. 60 61 Args: 62 anritsu: the Anritsu callbox controller 63 log: a logger handle 64 dut: the android device handler 65 test_config: test configuration obtained from the config file 66 calibration_table: a dictionary containing path losses for 67 different bands. 68 69 """ 70 71 super().__init__(anritsu, log, dut, test_config, calibration_table) 72 73 anritsu.load_simulation_paramfile(self.GSM_BASIC_SIM_FILE) 74 self.anritsu.load_cell_paramfile(self.GSM_CELL_FILE) 75 76 if not dut.droid.telephonySetPreferredNetworkTypesForSubscription( 77 NETWORK_MODE_GSM_ONLY, 78 dut.droid.subscriptionGetDefaultSubId()): 79 log.error("Coold not set preferred network type.") 80 else: 81 log.info("Preferred network type set.") 82 83 def parse_parameters(self, parameters): 84 """ Configs a GSM simulation using a list of parameters. 85 86 Calls the parent method first, then consumes parameters specific to GSM. 87 88 Args: 89 parameters: list of parameters 90 """ 91 92 super().parse_parameters(parameters) 93 94 # Setup band 95 96 values = self.consume_parameter(parameters, self.PARAM_BAND, 1) 97 98 if not values: 99 raise ValueError( 100 "The test name needs to include parameter '{}' followed by " 101 "the required band number.".format(self.PARAM_BAND)) 102 103 self.set_band(self.bts1, values[1]) 104 105 # Setup GPRS mode 106 107 if self.consume_parameter(parameters, self.PARAM_GPRS): 108 self.bts1.gsm_gprs_mode = BtsGprsMode.GPRS 109 elif self.consume_parameter(parameters, self.PARAM_EGPRS): 110 self.bts1.gsm_gprs_mode = BtsGprsMode.EGPRS 111 elif self.consume_parameter(parameters, self.PARAM_NO_GPRS): 112 self.bts1.gsm_gprs_mode = BtsGprsMode.NO_GPRS 113 else: 114 raise ValueError( 115 "GPRS mode needs to be indicated in the test name with either " 116 "{}, {} or {}.".format(self.PARAM_GPRS, self.PARAM_EGPRS, 117 self.PARAM_NO_GPRS)) 118 119 # Setup slot allocation 120 121 values = self.consume_parameter(parameters, self.PARAM_SLOTS, 2) 122 123 if not values: 124 raise ValueError( 125 "The test name needs to include parameter {} followed by two " 126 "int values indicating DL and UL slots.".format( 127 self.PARAM_SLOTS)) 128 129 self.bts1.gsm_slots = (int(values[1]), int(values[2])) 130