def AddInputLabel(self, DicoLine): # label format is set with FORMAT field if not empty if DicoLine["FORMAT"]: label_format = DicoLine["FORMAT"] # else in FWC BDS file an empty FORMAT is considered as a DW (Discrete Word) label else: label_format = "DW" LabelObj = A429Label(DicoLine["LABEL IN"], DicoLine["SDI IN"], label_format, DicoLine["NATURE"], DicoLine["SYSTEM"]) LabelObj.input_trans_rate = DicoLine["INPUT TRANSMIT INTERVAL MIN/MAX"] LabelObj.originATA = DicoLine["ORIGIN ATA"] LabelObj.pins = DicoLine["INPUT PINS"] LabelObj.source = DicoLine["SOURCE OR UPSTREAM COMPUTER NAME"].replace("/", "_") LabelObj.source = re.sub(r'\.', '_', LabelObj.source) self.SetLabelFormattedName(LabelObj) return LabelObj
def ParseLine(self, DicoLine): # # treatment for "normal" label (BNR, DIS etc...) # if DicoLine["TYPE_UTIL_CONT"] == "NORMAL": if int(DicoLine["NOM_BLOC"]) != 1: return None LabelObj = A429Label(DicoLine["LABEL"], DicoLine["SDI"], DicoLine["FORMAT_BLOC"], DicoLine["SENS"], DicoLine["NOM_SOUS_ENS"]) LabelObj.input_trans_rate = DicoLine["FREQU_CONT"] LabelObj.source = DicoLine["NOM_SUPP"] LabelObj = self.add_Label(LabelObj) SetLabelFormattedName(LabelObj) if DicoLine['FORMAT_PARAM'] == "BNR": ParamObj = A429ParamBNR(DicoLine["NOM_PARAM"], DicoLine["SENS"], LabelObj.number, DicoLine["POSITION"], DicoLine["TAILLE"], DicoLine["ECHEL"], self.ComputeResolutionBNR(DicoLine["TAILLE"], DicoLine["ECHEL"])) ParamObj.signed = DicoLine["SIGNE"] elif DicoLine['FORMAT_PARAM'] == "BCD": ParamObj = A429ParamBCD(DicoLine["NOM_PARAM"], DicoLine["SENS"], LabelObj.number, DicoLine["POSITION"], DicoLine["TAILLE"], DicoLine["ECHEL"], self.ComputeResolutionBCD(DicoLine["TAILLE"], DicoLine["ECHEL"])) ParamObj.signed = DicoLine["SIGNE"] elif DicoLine['FORMAT_PARAM'] == "DW": ParamObj = A429ParamDIS(DicoLine["NOM_PARAM"], DicoLine["SENS"], LabelObj.number) ParamObj.BitNumber = DicoLine["POSITION"] ParamObj.state0 = DicoLine["ETAT0"] ParamObj.state1 = DicoLine["ETAT1"] elif DicoLine['FORMAT_PARAM'] == "ISO5": ParamObj = A429ParamISO5(DicoLine["NOM_PARAM"], DicoLine["SENS"], LabelObj.number, DicoLine["POSITION"], DicoLine["TAILLE"]) elif DicoLine['FORMAT_PARAM'] == "Opaque": ParamObj = A429ParamOpaque(DicoLine["NOM_PARAM"], DicoLine["SENS"], LabelObj.number, DicoLine["POSITION"], DicoLine["TAILLE"]) else: #print ("[BDS_EIS][ParseLine] Type non reconnu: " + DicoLine['FORMAT_PARAM']) return LabelObj ParamObj.formatparam = DicoLine['FORMAT_PARAM'] ParamObj.nombloc = DicoLine["NOM_BLOC"] ParamObj.libbloc = DicoLine["LIB_BLOC"] ParamObj.comments = DicoLine["LIB_PARAM"] ParamObj.parameter_def = DicoLine["LIB_PARAM"] ParamObj.unit = DicoLine["UNITE"] LabelObj.refParameter(ParamObj) SetParameterPreFormattedName(ParamObj) return LabelObj # # Treatment of frame label # elif DicoLine["TYPE_UTIL_CONT"] == "TRAME": # # create label object type = "Frame" # LabelObj = A429Label(DicoLine["LABEL"], DicoLine["SDI"], "Frame", DicoLine["SENS"], DicoLine["NOM_SOUS_ENS"]) LabelObj.input_trans_rate = DicoLine["FREQU_CONT"] LabelObj.source = DicoLine["NOM_SUPP"] LabelObj = self.add_Label(LabelObj) SetLabelFormattedName(LabelObj) # # create parameter object type = opaque # Parameter name is set to "BUFFER" because field is empty on BDS EIS. # We assume that all label content is used => position = bit 29 / size = 18 ParamObj = A429ParamOpaque("BUFFER", DicoLine["SENS"], LabelObj.number, 29, 18) ParamObj.formatparam = "Opaque" # ParamObj.nombloc = DicoLine["NOM_BLOC"] # ParamObj.libbloc = DicoLine["LIB_BLOC"] # ParamObj.comments = DicoLine["LIB_PARAM"] ParamObj.parameter_def = DicoLine["LIB_PARAM"] # ParamObj.unit = DicoLine["UNITE"] LabelObj.refParameter(ParamObj) SetParameterPreFormattedName(ParamObj) LabelObj.print(DisplayParam=True) return LabelObj else: return None
def ParseLine(self, DicoLine): LabelObj = A429Label(DicoLine["LABEL"], DicoLine["SDI"], DicoLine["FORMAT_BLOC"], DicoLine["SENS"], DicoLine["NOM_SOUS_ENS"]) LabelObj.input_trans_rate = DicoLine["FREQU_CONT"] LabelObj.source = DicoLine["NOM_SUPP"] LabelObj = self.add_Label(LabelObj) SetLabelFormattedName(LabelObj) if DicoLine['FORMAT_PARAM'] == "BNR": ParamObj = A429ParamBNR( DicoLine["NOM_PARAM"], DicoLine["SENS"], LabelObj.number, DicoLine["POSITION"], DicoLine["TAILLE"], DicoLine["ECHEL"], self.ComputeResolutionBNR(DicoLine["TAILLE"], DicoLine["ECHEL"])) ParamObj.signed = DicoLine["SIGNE"] elif DicoLine['FORMAT_PARAM'] == "BCD": ParamObj = A429ParamBCD( DicoLine["NOM_PARAM"], DicoLine["SENS"], LabelObj.number, DicoLine["POSITION"], DicoLine["TAILLE"], DicoLine["ECHEL"], self.ComputeResolutionBCD(DicoLine["TAILLE"], DicoLine["ECHEL"])) ParamObj.signed = DicoLine["SIGNE"] elif DicoLine['FORMAT_PARAM'] == "DW": ParamObj = A429ParamDIS(DicoLine["NOM_PARAM"], DicoLine["SENS"], LabelObj.number) ParamObj.BitNumber = DicoLine["POSITION"] ParamObj.state0 = DicoLine["ETAT0"] ParamObj.state1 = DicoLine["ETAT1"] elif DicoLine['FORMAT_PARAM'] == "ISO5": ParamObj = A429ParamISO5(DicoLine["NOM_PARAM"], DicoLine["SENS"], LabelObj.number, DicoLine["POSITION"], DicoLine["TAILLE"]) elif DicoLine['FORMAT_PARAM'] == "Opaque": ParamObj = A429ParamOpaque(DicoLine["NOM_PARAM"], DicoLine["SENS"], LabelObj.number, DicoLine["POSITION"], DicoLine["TAILLE"]) else: #print ("[BDS_EIS][ParseLine] Type non reconnu: " + DicoLine['FORMAT_PARAM']) return LabelObj ParamObj.formatparam = DicoLine['FORMAT_PARAM'] ParamObj.nombloc = DicoLine["NOM_BLOC"] ParamObj.libbloc = DicoLine["LIB_BLOC"] ParamObj.comments = DicoLine["LIB_PARAM"] ParamObj.parameter_def = DicoLine["LIB_PARAM"] ParamObj.unit = DicoLine["UNITE"] LabelObj.refParameter(ParamObj) SetParameterPreFormattedName(ParamObj) return LabelObj
def __init__(self, path_name, new=False): """ Attributes are: _ path name of the file """ self.new = new self.PathName = path_name self.Workbook = None self.SheetAndIndex = {} # heritage of BDS class super().__init__() if self.new is True: for sheet in BDSXLS.file_structure.keys(): self.SheetAndIndex[sheet] = {} self.SheetAndIndex[sheet]['ColIndex'] = 0 self.SheetAndIndex[sheet]['ColNbr'] = len( list(BDSXLS.file_structure[sheet])) self.SheetAndIndex[sheet]['RowIndex'] = 0 self.SheetAndIndex[sheet]['RowNbr'] = 0 self.SheetAndIndex[sheet]['Header'] = list( BDSXLS.file_structure[sheet]) self.SheetAndIndex[sheet]['XlsSheet'] = None self.createemptyfile() # open an existing file else: self._Workbook = xlrd.open_workbook(self.PathName) for _sheetname in self._Workbook.sheet_names(): _testOnSheetNameFUNIN = match(r'IN', _sheetname) _testOnSheetNameFUNOUT = match(r'OUT', _sheetname) # sheet name match *_IN => it's a FUN_IN sheet name # this test is usefull in case of multiple input port sheets if _testOnSheetNameFUNIN: _sheet = "IN" elif _testOnSheetNameFUNOUT: _sheet = "OUT" else: continue _worksheet = self._Workbook.sheet_by_name(_sheetname) self.SheetAndIndex[_sheetname] = {} self.SheetAndIndex[_sheetname]['ColIndex'] = 0 self.SheetAndIndex[_sheetname]['ColNbr'] = _worksheet.ncols self.SheetAndIndex[_sheetname]['RowIndex'] = 0 self.SheetAndIndex[_sheetname]['RowNbr'] = _worksheet.nrows self.SheetAndIndex[_sheetname][ 'Header'] = _worksheet.row_values(0) self.SheetAndIndex[_sheetname]['XlsSheet'] = None _fieldList = BDSXLS.file_structure[_sheet] for _rowidx in range(1, _worksheet.nrows): # Iterate through rows _line = _worksheet.row_values(_rowidx) _labelNumber = str( "%.3d" % int(_line[_fieldList.index("Label Number")])) LabelObj = A429Label(_labelNumber, _line[_fieldList.index("SDI")], _line[_fieldList.index("Label type")], _sheet, _line[_fieldList.index("System")]) LabelObj.source = _line[_fieldList.index("From")] LabelObj.ssmtype = _line[_fieldList.index("Ssm Type")] # ref this labelObject on BDSXLS Obj LabelObj = self.add_Label(LabelObj) LabelObj.SimuFormattedName = _line[_fieldList.index( "A429 Label Name")] if _line[_fieldList.index("Parameter Format")] == "BNR": ParamObj = A429ParamBNR( _line[_fieldList.index("Parameter Name")], _sheet, _labelNumber, _line[_fieldList.index("Parameter MSB")], _line[_fieldList.index("Size")], _line[_fieldList.index("Range")], self.ComputeResolutionBNR( _line[_fieldList.index("Size")], _line[_fieldList.index("Range")])) ParamObj.signed = _line[_fieldList.index("Signed")] elif _line[_fieldList.index("Parameter Format")] == "BCD": ParamObj = A429ParamBCD( _line[_fieldList.index("Parameter Name")], _sheet, _labelNumber, _line[_fieldList.index("Parameter MSB")], _line[_fieldList.index("Size")], _line[_fieldList.index("Range")], self.ComputeResolutionBCD( _line[_fieldList.index("Size")], _line[_fieldList.index("Range")])) ParamObj.signed = _line[_fieldList.index("Signed")] elif _line[_fieldList.index("Parameter Format")] == "DW": ParamObj = A429ParamDIS( _line[_fieldList.index("Parameter Name")], _sheet, _labelNumber) ParamObj.BitNumber = _line[_fieldList.index( "Parameter MSB")] ParamObj.state0 = _line[_fieldList.index( "Bool False Def")] ParamObj.state1 = _line[_fieldList.index( "Bool True Def")] elif _line[_fieldList.index("Parameter Format")] == "ISO5": ParamObj = A429ParamISO5( _line[_fieldList.index("Parameter Name")], _sheet, _labelNumber, _line[_fieldList.index("Parameter MSB")], _line[_fieldList.index("Size")]) elif _line[_fieldList.index( "Parameter Format")] == "Opaque": ParamObj = A429ParamOpaque( _line[_fieldList.index("Parameter Name")], _sheet, _labelNumber, _line[_fieldList.index("Parameter MSB")], _line[_fieldList.index("Size")]) else: pass # print ("[BDS_EIS][ParseLine] Type non reconnu: " + DicoLine['FORMAT_PARAM']) ParamObj.formatparam = _line[_fieldList.index( "Parameter Format")] ParamObj.comments = _line[_fieldList.index("Comments")] ParamObj.parameter_def = _line[_fieldList.index( "Description")] ParamObj.unit = _line[_fieldList.index("Unit")] ParamObj.codingtype = _line[_fieldList.index("Type")] ParamObj.SimuPreFormattedName = _line[_fieldList.index( "Port Name")] # reference parameter on current labelObj LabelObj.refParameter(ParamObj)