def setUp(self): cbsd_records = [ json.load( open(os.path.join('testcases', 'testdata', 'device_a.json'))), json.load( open(os.path.join('testcases', 'testdata', 'device_b.json'))), json.load( open(os.path.join('testcases', 'testdata', 'device_c.json'))) ] grant_records = [ [ json.load( open(os.path.join('testcases', 'testdata', 'grant_0.json'))) ], [ json.load( open(os.path.join('testcases', 'testdata', 'grant_0.json'))) ], [ json.load( open(os.path.join('testcases', 'testdata', 'grant_0.json'))) ] ] cbsd_fad_records = generateCbsdRecords(cbsd_records, grant_records) pal_record_0 = json.load( open(os.path.join('testcases', 'testdata', 'pal_record_0.json'))) pal_low_frequency = 3550000000 pal_high_frequency = 3560000000 ppa_record_0 = json.load( open(os.path.join('testcases', 'testdata', 'ppa_record_0.json'))) ppa_record_a, pal_records = makePpaAndPalRecordsConsistent( ppa_record_0, [pal_record_0], pal_low_frequency, pal_high_frequency, 'test_user_1') ppa_records = [ppa_record_a] cbsd_reference_ids = [[ generateCbsdReferenceId('test_fcc_id_x', 'test_serial_number_x'), generateCbsdReferenceId('test_fcc_id_y', 'test_serial_number_y') ]] ppa_fad_records = generatePpaRecords(ppa_records, cbsd_reference_ids) esc_fad_records = [ json.load( open( os.path.join('testcases', 'testdata', 'esc_sensor_record_0.json'))) ] self._test_data = [cbsd_fad_records, ppa_fad_records, esc_fad_records]
def generate_FAD_2_default_config(self, filename): """Generates the WinnForum configuration for FAD_2""" # Create the actual config for FAD_2 # Load the esc sensor in SAS Test Harness esc_sensor = json.load( open( os.path.join('testcases', 'testdata', 'esc_sensor_record_0.json'))) # Load the device_c1 with registration in SAS Test Harness device_c1 = json.load( open(os.path.join('testcases', 'testdata', 'device_a.json'))) # Get a latitude and longitude within 40 kms from ESC. latitude, longitude, _ = vincenty.GeodesicPoint( esc_sensor['installationParam']['latitude'], esc_sensor['installationParam']['longitude'], 0.1, 30) # distance of 0.1 km from ESC at 30 degrees # Load the device_c1 in the neighborhood area of the ESC sensor device_c1['installationParam']['latitude'] = latitude device_c1['installationParam']['longitude'] = longitude # Load grant request for device_c1 grant_g1 = json.load( open(os.path.join('testcases', 'testdata', 'grant_0.json'))) grant_g1['operationParam']['maxEirp'] = 20 # Load one ppa in SAS Test Harness pal_record_0 = json.load( open(os.path.join('testcases', 'testdata', 'pal_record_0.json'))) pal_low_frequency = 3550000000 pal_high_frequency = 3560000000 ppa_record_0 = json.load( open(os.path.join('testcases', 'testdata', 'ppa_record_0.json'))) ppa_record_a, pal_records = makePpaAndPalRecordsConsistent( ppa_record_0, [pal_record_0], pal_low_frequency, pal_high_frequency, 'test_user_1') # Load device_c3 in SAS Test Harness device_c3 = json.load( open(os.path.join('testcases', 'testdata', 'device_c.json'))) # Load the device_c3 in the neighborhood area of the PPA device_c3['installationParam']['latitude'] = 38.821322 device_c3['installationParam']['longitude'] = -97.280040 # Load grant request for device_c3 in SAS Test Harness grant_g3 = json.load( open(os.path.join('testcases', 'testdata', 'grant_0.json'))) grant_g3['operationParam']['maxEirp'] = 20 # Update grant_g3 frequency to overlap with PPA zone frequency for C3 device grant_g3['operationParam']['operationFrequencyRange'] = { 'lowFrequency': 3550000000, 'highFrequency': 3555000000 } # Load the device_c2 with registration to SAS UUT device_c2 = json.load( open(os.path.join('testcases', 'testdata', 'device_b.json'))) # Get a latitude and longitude within 40 kms from ESC. latitude, longitude, _ = vincenty.GeodesicPoint( esc_sensor['installationParam']['latitude'], esc_sensor['installationParam']['longitude'], 0.1, 30) # distance of 0.1 km from ESC at 30 degrees device_c2['installationParam']['latitude'] = latitude device_c2['installationParam']['longitude'] = longitude # Creating conditionals for C2 and C4. self.assertEqual(device_c2['cbsdCategory'], 'B') conditional_parameters_c2 = { 'cbsdCategory': device_c2['cbsdCategory'], 'fccId': device_c2['fccId'], 'cbsdSerialNumber': device_c2['cbsdSerialNumber'], 'airInterface': device_c2['airInterface'], 'installationParam': device_c2['installationParam'], 'measCapability': device_c2['measCapability'] } del device_c2['cbsdCategory'] del device_c2['airInterface'] del device_c2['installationParam'] # Load grant request for device_c2 to SAS UUT grant_g2 = json.load( open(os.path.join('testcases', 'testdata', 'grant_0.json'))) grant_g2['operationParam']['maxEirp'] = 30 # Load the device_c4 with registration to SAS UUT. device_c4 = json.load( open(os.path.join('testcases', 'testdata', 'device_d.json'))) # Move device_c4 in the neighborhood area of the PPA device_c4['installationParam']['latitude'] = 38.8363 device_c4['installationParam']['longitude'] = -97.2642 device_c4['installationParam']['antennaBeamwidth'] = 0 # Creating conditionals for Cat B devices. self.assertEqual(device_c4['cbsdCategory'], 'B') conditional_parameters_c4 = { 'cbsdCategory': device_c4['cbsdCategory'], 'fccId': device_c4['fccId'], 'cbsdSerialNumber': device_c4['cbsdSerialNumber'], 'airInterface': device_c4['airInterface'], 'installationParam': device_c4['installationParam'], 'measCapability': device_c4['measCapability'] } del device_c4['cbsdCategory'] del device_c4['airInterface'] del device_c4['installationParam'] # Load grant request for device_c4 to SAS UUT grant_g4 = json.load( open(os.path.join('testcases', 'testdata', 'grant_0.json'))) grant_g4['operationParam']['maxEirp'] = 20 #Update grant_g4 frequency to overlap with PPA zone frequency for C4 device grant_g4['operationParam']['operationFrequencyRange'] = { 'lowFrequency': 3550000000, 'highFrequency': 3555000000 } conditionals = { 'registrationData': [conditional_parameters_c2, conditional_parameters_c4] } cbsd_records = [device_c1, device_c3] grant_record_list = [[grant_g1], [grant_g3]] ppa_records = [ppa_record_a] # Creating CBSD reference IDs of valid format cbsd_reference_id1 = generateCbsdReferenceId('test_fcc_id_x', 'test_serial_number_x') cbsd_reference_id2 = generateCbsdReferenceId('test_fcc_id_y', 'test_serial_number_y') cbsd_reference_ids = [[cbsd_reference_id1, cbsd_reference_id2]] # SAS test harness configuration sas_harness_config = { 'sasTestHarnessName': 'SAS-TH-1', 'hostName': getFqdnLocalhost(), 'port': getUnusedPort(), 'serverCert': getCertFilename('sas.cert'), 'serverKey': getCertFilename('sas.key'), 'caCert': "certs/ca.cert" } # Generate FAD Records for each record type like cbsd,zone and esc_sensor cbsd_fad_records = generateCbsdRecords(cbsd_records, grant_record_list) ppa_fad_records = generatePpaRecords(ppa_records, cbsd_reference_ids) esc_fad_records = [esc_sensor] sas_harness_dump_records = { 'cbsdRecords': cbsd_fad_records, 'ppaRecords': ppa_fad_records, 'escSensorRecords': esc_fad_records } config = { 'registrationRequestC2': device_c2, 'registrationRequestC4': device_c4, 'conditionalRegistrationData': conditionals, 'grantRequestG2': grant_g2, 'grantRequestG4': grant_g4, 'palRecords': pal_records, 'sasTestHarnessConfig': sas_harness_config, 'sasTestHarnessDumpRecords': sas_harness_dump_records } writeConfig(filename, config)
def generate_PPR_3_default_config(self, filename): """High-level description of the default config: SAS UUT has devices B, D; all of which have a PAL grant. SAS TH has devices A, C, E, all of which have a PAL grant. SAS UUT has one PPA, with devices B and D on the cluster list. SAS TH has one PPA, with devices A, C, and E on the cluster list. The PPAs derive from different but adjacent PALs. Both PPAs are on 3620-3630 MHz, as are all grants. """ # Load Devices device_a = json.load( open(os.path.join('testcases', 'testdata', 'device_a.json'))) device_a['installationParam']['latitude'] = 38.842176 device_a['installationParam']['longitude'] = -97.092863 device_b = json.load( open(os.path.join('testcases', 'testdata', 'device_b.json'))) device_b['installationParam']['latitude'] = 38.845323113 device_b['installationParam']['longitude'] = -97.15514587 device_b['installationParam']['antennaBeamwidth'] = 0 device_b['installationParam']['antennaDowntilt'] = 0 device_c = json.load( open(os.path.join('testcases', 'testdata', 'device_c.json'))) device_c['installationParam']['latitude'] = 38.816782 device_c['installationParam']['longitude'] = -97.102965 device_d = json.load( open(os.path.join('testcases', 'testdata', 'device_d.json'))) device_d['installationParam']['latitude'] = 38.846125 device_d['installationParam']['longitude'] = -97.156184 device_d['installationParam']['antennaBeamwidth'] = 0 device_d['installationParam']['antennaDowntilt'] = 0 device_e = json.load( open(os.path.join('testcases', 'testdata', 'device_e.json'))) device_e['installationParam']['latitude'] = 38.761748 device_e['installationParam']['longitude'] = -97.118459 # Pre-load conditionals and remove REG-conditional fields from registration # requests. conditional_keys = [ 'cbsdCategory', 'fccId', 'cbsdSerialNumber', 'airInterface', 'installationParam', 'measCapability' ] reg_conditional_keys = [ 'cbsdCategory', 'airInterface', 'installationParam', 'measCapability' ] conditionals_b = {key: device_b[key] for key in conditional_keys} device_b = { key: device_b[key] for key in device_b if key not in reg_conditional_keys } conditionals_d = {key: device_d[key] for key in conditional_keys} device_d = { key: device_d[key] for key in device_d if key not in reg_conditional_keys } # Load grant requests (default is 3620-3630). grant_a = json.load( open(os.path.join('testcases', 'testdata', 'grant_0.json'))) grant_b = json.load( open(os.path.join('testcases', 'testdata', 'grant_0.json'))) grant_b['operationParam']['maxEirp'] = 30 grant_c = json.load( open(os.path.join('testcases', 'testdata', 'grant_0.json'))) grant_d = json.load( open(os.path.join('testcases', 'testdata', 'grant_0.json'))) grant_d['operationParam']['maxEirp'] = 30 grant_e = json.load( open(os.path.join('testcases', 'testdata', 'grant_0.json'))) # CBSDs in SAS UUT. domain_proxy = { 'registrationRequests': [device_b, device_d], 'grantRequests': [grant_b, grant_d], 'conditionalRegistrationData': [conditionals_b, conditionals_d], 'cert': getCertFilename('domain_proxy.cert'), 'key': getCertFilename('domain_proxy.key') } # One PPA in SAS UUT. pal_low_frequency = 3620000000 pal_high_frequency = 3630000000 pal_record_0 = json.load( open(os.path.join('testcases', 'testdata', 'pal_record_0.json'))) ppa_record_0 = json.load( open(os.path.join('testcases', 'testdata', 'ppa_record_0.json'))) ppa_record_0['zone']['features'][0]['geometry']['coordinates'] = [[[ -97.155, 38.75 ], [-97.155, 38.85], [-97.165, 38.85], [-97.165, 38.75], [-97.155, 38.75]]] ppa_record_0, pal_records_0 = makePpaAndPalRecordsConsistent( ppa_record_0, [pal_record_0], pal_low_frequency, pal_high_frequency, 'test_user_1') device_b['userId'] = 'test_user_1' device_d['userId'] = 'test_user_1' ppa_cluster_list = [0, 1] # One PPA in the peer SAS test harness. pal_record_1 = json.load( open(os.path.join('testcases', 'testdata', 'pal_record_1.json'))) pal_record_1['fipsCode'] = 20041084500 ppa_record_1 = json.load( open(os.path.join('testcases', 'testdata', 'ppa_record_1.json'))) ppa_record_1['zone']['features'][0]['geometry']['coordinates'] = [[[ -97.145, 38.85 ], [-97.145, 38.75], [-97.05, 38.75], [-97.05, 38.85], [-97.145, 38.85]]] ppa_record_1, pal_records_1 = makePpaAndPalRecordsConsistent( ppa_record_1, [pal_record_1], pal_low_frequency, pal_high_frequency, 'test_user_2') # Generate FAD records. cbsd_records = [device_a, device_c, device_e] # Create CBSD reference IDs. cbsd_reference_id_a = generateCbsdReferenceId(device_a['fccId'], device_a['cbsdSerialNumber']) cbsd_reference_id_c = generateCbsdReferenceId(device_c['fccId'], device_c['cbsdSerialNumber']) cbsd_reference_id_e = generateCbsdReferenceId(device_e['fccId'], device_e['cbsdSerialNumber']) cbsd_reference_ids = [[ cbsd_reference_id_a, cbsd_reference_id_c, cbsd_reference_id_e ]] grant_record_list = [[grant_a], [grant_c], [grant_e]] cbsd_records = generateCbsdRecords(cbsd_records, grant_record_list) for cbsd in cbsd_records: for grant in cbsd['grants']: grant['channelType'] = 'PAL' # Create records. sas_harness_dump_records = { 'cbsdRecords': cbsd_records, 'ppaRecords': generatePpaRecords([ppa_record_1], cbsd_reference_ids), } # SAS test harness configuration. sas_harness_config = { 'sasTestHarnessName': 'SAS-TH-1', 'hostName': getFqdnLocalhost(), 'port': getUnusedPort(), 'serverCert': getCertFilename('sas.cert'), 'serverKey': getCertFilename('sas.key'), 'caCert': 'certs/ca.cert' } config = { 'domainProxy': domain_proxy, # Includes registration and grant requests. 'ppaRecord': ppa_record_0, # PPA in SAS UUT. 'ppaClusterList': ppa_cluster_list, # Same format and semantics as SIQ.12. 'palRecords': [pal_records_0[0], pal_records_1[0]], # PALs for both PPAs. 'sasTestHarnessDumpRecords': sas_harness_dump_records, # CBSDs and one PPA. 'sasTestHarnessConfig': sas_harness_config, # Just the config, no records. } writeConfig(filename, config)