def binary_read(self, fh): """ Given an open file handle, interpret it in the context of a subsystem_status_struct C structure and update the Python instance accordingly. """ ## They are the same size so this really doesn't matter sssStruct = parse_c_struct(SUBSYSTEM_STATUS_STRUCT, endianness='little') fh.readinto(sssStruct) self.summary = sssStruct.summary self.info = sssStruct.info ts, tu = sssStruct.tv self.time = ts + tu / 1.0e6
def binary_read(self, fh): """ Given an open file handle, interpret it in the context of a station_settings_struct C structure and update the Python instance accordingly. """ # Figure out what to do ssStruct = parse_c_struct(STATION_SETTINGS_STRUCT, endianness='little') # Read fh.readinto(ssStruct) # Parse and save ## Common self.report['ASP'] = ssStruct.mrp_asp self.report['DP_'] = ssStruct.mrp_dp self.report['DR1'] = ssStruct.mrp_dr1 self.report['DR2'] = ssStruct.mrp_dr2 self.report['DR3'] = ssStruct.mrp_dr3 self.report['DR4'] = ssStruct.mrp_dr4 self.report['DR5'] = ssStruct.mrp_dr5 self.report['SHL'] = ssStruct.mrp_shl self.report['MCS'] = ssStruct.mrp_mcs self.update['ASP'] = ssStruct.mup_asp self.update['DP_'] = ssStruct.mup_dp self.update['DR1'] = ssStruct.mup_dr1 self.update['DR2'] = ssStruct.mup_dr2 self.update['DR3'] = ssStruct.mup_dr3 self.update['DR4'] = ssStruct.mup_dr4 self.update['DR5'] = ssStruct.mup_dr5 self.update['SHL'] = ssStruct.mup_shl self.update['MCS'] = ssStruct.mup_mcs self.fee_power = flat_to_multi(ssStruct.fee, *ssStruct.dims['fee']) self.asp_filter = list(ssStruct.asp_flt) self.asp_atten_1 = list(ssStruct.asp_at1) self.asp_atten_2 = list(ssStruct.asp_at2) self.asp_atten_split = list(ssStruct.asp_ats) self.tbn_gain = ssStruct.tbn_gain self.drx_gain = ssStruct.drx_gain
def parse_sdm(filename): """ Given a filename, read the file's contents into the SDM instance and return that instance. """ # Open the file with open(filename, 'rb') as fh: # Create a new SDM instance dynamic = SDM() # Sub-system status sections dynamic.station.binary_read(fh) dynamic.shl.binary_read(fh) dynamic.asp.binary_read(fh) dynamic.dp.binary_read(fh) for n in range(ME_MAX_NDR): dynamic.dr[n].binary_read(fh) # Sub-sub-system status section dynamic.status.binary_read(fh) # Antenna status and data path status adpsStruct = parse_c_struct(""" int ant_stat[ME_MAX_NSTD][2]; /* corresponds to sc.Stand[i].Ant[k].iSS, but dynamically updated */ int dpo_stat[ME_MAX_NDR]; /* corresponds to sc.DPO[i].iStat, but dynamically updated */ """, endianness='little') fh.readinto(adpsStruct) dynamic.ant_status = flat_to_multi(adpsStruct.ant_stat, *adpsStruct.dims['ant_stat']) dynamic.dpo_status = flat_to_multi(adpsStruct.dpo_stat, *adpsStruct.dims['dpo_stat']) # Station settings section dynamic.settings.binary_read(fh) return dynamic
def binary_read(self, fh): """ Given an open file handle, interpret it in the context of a subsubsystem_status_struct C structure and update the Python instance accordingly. """ # Figure out what to do ssssStruct = parse_c_struct(SUBSUBSYSTEM_STATUS_STRUCT, endianness='little') # Read fh.readinto(ssssStruct) # Parse and save self.fee = list(ssssStruct.eFEEStat) self.rpd = list(ssssStruct.eRPDStat) self.sep = list(ssssStruct.eSEPStat) self.arb = flat_to_multi(ssssStruct.eARBStat, *ssssStruct.dims['eARBStat']) self.dp1 = flat_to_multi(ssssStruct.eDP1Stat, *ssssStruct.dims['eDP1Stat']) self.dp2 = list(ssssStruct.eDP2Stat) self.dr = list(ssssStruct.eDRStat)