def logPassStd256MB(self, f): """This 'standard' file is 256MB of log data with 1024 channels, single sampled. There are 65536 frames with a frame spacing of 1/10 ft. There are 128 frames per logical record.""" numCh = 1023 lisBytesPerCh = 4 sampPerCh = 1 numFr = 64*1024 frPerLr = 128 myF = self._retStdFile(f, prLen=PhysRec.PR_MAX_LENGTH) self._writeDefaultMarkerHead(myF) myEbs = LogiRec.EntryBlockSet() # Set entry blocks to make frame spacing 12 b'.1IN' i.e. 10 frames/foot # Block 8 myEbs.setEntryBlock(LogiRec.EntryBlock(LogiRec.EB_TYPE_FRAME_SPACE, 1, 66, 12)) # Block 9 myEbs.setEntryBlock(LogiRec.EntryBlock(LogiRec.EB_TYPE_FRAME_SPACE_UNITS, 4, 65, b'.1IN')) myChList = [ LisGen.Channel( LisGen.ChannelSpec( bytes('{:04d}'.format(i), 'ascii'), b'ServID', b'ServOrdN', b'FEET', 45310011, 256, lisBytesPerCh, sampPerCh, 68 ), LisGen.ChValsConst(fOffs=0, waveLen=4, mid=0.0, amp=1.0, numSa=1, noise=12.0), ) for i in range(numCh) ] # Start at 10,000 feet i.e. 10000*120 .1IN myLpg = LisGen.LogPassGen(myEbs, myChList, xStart=10000.0*120, xRepCode=68, xNoise=None) # DFSR myF.write(myLpg.lrBytesDFSR()) for i in range(0, numFr, frPerLr): myF.write(myLpg.lrBytes(i, frPerLr)) self._writeDefaultMarkerTail(myF) return os.path.getsize(myF.fileId)
def _logPass(self, theF, numCh, lisBytesPerCh, sampPerCh, numFr, frPerLr): myEbs = LogiRec.EntryBlockSet() # Set entry blocks to make frame spacing 0.5 b'FEET' # Block 8 myEbs.setEntryBlock( LogiRec.EntryBlock(LogiRec.EB_TYPE_FRAME_SPACE, 4, 68, 0.5)) # Block 9 myEbs.setEntryBlock( LogiRec.EntryBlock(LogiRec.EB_TYPE_FRAME_SPACE_UNITS, 4, 65, b'FEET')) myChList = [ LisGen.Channel( LisGen.ChannelSpec(bytes('{:04d}'.format(i), 'ascii'), b'ServID', b'ServOrdN', b'FEET', 45310011, 256, lisBytesPerCh, sampPerCh, 68), LisGen.ChValsConst(fOffs=0, waveLen=4, mid=0.0, amp=1.0, numSa=1, noise=36.0), ) for i in range(numCh) ] # Start at 10,000 feet myLpg = LisGen.LogPassGen(myEbs, myChList, xStart=10000.0, xRepCode=68, xNoise=None) # DFSR theF.write(myLpg.lrBytesDFSR()) for i in range(0, numFr, frPerLr): theF.write(myLpg.lrBytes(i, frPerLr))
def _retLogPassGen(self): #print() myEbs = LogiRec.EntryBlockSet() myEbs.setEntryBlock( LogiRec.EntryBlock(LogiRec.EB_TYPE_FRAME_SIZE, 1, 66, 4 * 4)) myEbs.setEntryBlock( LogiRec.EntryBlock(LogiRec.EB_TYPE_FRAME_SPACE, 1, 66, 60)) myEbs.setEntryBlock( LogiRec.EntryBlock(LogiRec.EB_TYPE_FRAME_SPACE_UNITS, 4, 65, b'.1IN')) #print('myEbs.lisByteList()') #pprint.pprint(myEbs.lisByteList()) myLp = LisGen.LogPassGen( myEbs, # Channel list [ LisGen.Channel( LisGen.ChannelSpec(b'TEST', b'ServID', b'ServOrdN', b'FEET', 45310011, 256, 16, 4, 68), LisGen.ChValsConst(fOffs=0, waveLen=4, mid=0.0, amp=1.0, numSa=1, noise=None), ), ], xStart=10000.0 * 120, xRepCode=68, xNoise=None, ) return myLp
def logPassSmall(self, f): myF = self._retStdFile(f) self._writeDefaultMarkerHead(myF) myEbs = LogiRec.EntryBlockSet() #myEbs.setEntryBlock(LogiRec.EntryBlock(LogiRec.EB_TYPE_FRAME_SIZE, 1, 66, 4*4)) myLpg = LisGen.LogPassGen( myEbs, # Channel list [ LisGen.Channel( LisGen.ChannelSpec(b'TEST', b'ServID', b'ServOrdN', b'FEET', 45310011, 256, 16, 4, 68), LisGen.ChValsConst(fOffs=0, waveLen=4, mid=0.0, amp=1.0, numSa=1, noise=None), ), ], xStart=10000.0, xRepCode=68, xNoise=None, ) # DFSR myF.write(myLpg.lrBytesDFSR()) # Logical data records for i in range(0, 1024, 128): myF.write(myLpg.lrBytes(i, 128)) self._writeDefaultMarkerTail(myF) return os.path.getsize(myF.fileId)
def _retCbBytes(self, typ, mnem, v, units): myCb = LogiRec.CbEngVal() myCb.type = typ myCb.category = 0 myCb.mnem = mnem myCb.units = units if isinstance(v, int): # Convert to type 73, 32bit integer myCb.rc = 73 myCb.size = 4 elif isinstance(v, float): # Convert to type 68 myCb.rc = 68 myCb.size = 4 else: # Treat as bytes and use type 65 if not isinstance(v, bytes): # Stringify and byteify v = bytes(str(v), 'ascii') # Treat as type 65, 'string' myCb.rc = 65 myCb.size = len(v) myCb.setValue(v) #print('myCb', myCb) return myCb.lisBytes()
def __init__(self, tell, lrType, theF, xAxisIndex=0): super().__init__(tell, lrType, theF) assert (self._typ == LogiRec.LR_TYPE_DATA_FORMAT) # Have to rewind for DFSR creation theF.seekCurrentLrStart() # Create a DFSR and thus a Log Pass self._logPass = LogPass.LogPass(LogiRec.LrDFSRRead(theF), self._fileId, xAxisIndex) theF.skipToNextLr()
def _retCONSRecS(self, theFi, thePrs): """Returns a list of CONS Logical Records or None is no API header required.""" assert (thePrs) if self._apiHeader: consRecS = [] for t in thePrs.tellConsS: theFi.seekLr(t) consRecS.append(LogiRec.LrTableRead(theFi)) return consRecS
def _retPlotFromPlotRecordSet(self, theFi, thePrs): """Returns a Plot.PlotReadLIS, a LogPass and a list of CONS records from the PlotRecordSet.""" assert (thePrs) theFi.seekLr(thePrs.tellFilm) myLrFilm = LogiRec.LrTableRead(theFi) theFi.seekLr(thePrs.tellPres) myLrPres = LogiRec.LrTableRead(theFi) if thePrs.tellArea is not None: theFi.seekLr(thePrs.tellArea) myLrArea = LogiRec.LrTableRead(theFi) else: myLrArea = None if thePrs.tellPip is not None: theFi.seekLr(thePrs.tellPip) myLrPip = LogiRec.LrTableRead(theFi) else: myLrPip = None myPlot = Plot.PlotReadLIS(myLrFilm, myLrPres, myLrArea, myLrPip) return myPlot, thePrs.logPass, self._retCONSRecS(theFi, thePrs)
def _processFile(fp, keepGoing, tabMtch, theCntr): assert (os.path.isfile(fp)) logging.info('PlotLogPasses._processFile(): {:s}'.format(fp)) assert (os.path.isfile(fp)) try: myFi = File.FileRead(fp, theFileId=fp, keepGoing=keepGoing) myIdx = FileIndexer.FileIndex(myFi) except ExceptionTotalDepthLIS as err: logging.error('Can not read LIS file {:s} with error: {:s}'.format( fp, err)) else: # print(' Index longDesc() '.center(75, '=')) # print(myIdx.longDesc()) # print(' Index longDesc() DONE '.center(75, '=')) # Iterate through the FileIndexer object retVal = False for anIo in myIdx.genAll(): # print('anIdxObj:', anIo) if anIo.lrType in LogiRec.LR_TYPE_TABLE_DATA \ and tabMtch.lrTypeMatch(anIo.lrType) \ and tabMtch.nameTableMatch(anIo.name): # Read the whole table logical record myFi.seekLr(anIo.tell) try: myLrTable = LogiRec.LrTableRead(myFi) except Exception as err: logging.error( 'Can not create Logical Record, error: {:s}'.format( err)) else: # print('myLrTable', myLrTable) for aRow in myLrTable.genRows(): theCntr.incRow(anIo.lrType, anIo.name, aRow.value) if tabMtch.nameRowMatch(aRow.value): for aCell in aRow.genCells(): theCntr.incCol(anIo.lrType, anIo.name, aCell.mnem) if tabMtch.nameColMatch(aCell.mnem): theCntr.incAll( tabMtch, anIo.lrType, anIo.name, aRow.value, aCell.mnem, aCell.engVal.value, ) # if aCell.mnem == b'TYPE' and aCell.engVal.value == b'CONS': # retVal = True return retVal
def _hdrTrippleToLogicalRecord(theData): # Record header myB = [ bytes([34, 0]), bytes([73, 65, 4, 0]), bytes('TYPE', 'ascii'), bytes(' ', 'ascii'), bytes('CONS', 'ascii'), ] # Insert record contents CODE_INT = 73 CODE_FLOAT = 68 for m, v, u in theData: if u is None: u = b' ' myB.append(bytes([0, 65, 4, 0])) myB.append(b'MNEM') # Mnem myB.append(b' ') # Units myB.append(m) myB.append(bytes([69, 65, 4, 0])) myB.append(b'STAT') myB.append(b' ') myB.append(b'ALLO') myB.append(bytes([69, 65, 4, 0])) myB.append(b'PUNI') myB.append(b' ') myB.append(u) myB.append(bytes([69, 65, 4, 0])) myB.append(b'TUNI') myB.append(b' ') myB.append(u) assert (type(v) in (bytes, int, float)) if isinstance(v, bytes): myB.append(bytes([69, 65, len(v), 0])) myB.append(b'VALU') myB.append(u) myB.append(v) elif isinstance(v, int): myB.append(bytes([69, CODE_INT, RepCode.lisSize(CODE_INT), 0])) myB.append(b'VALU') myB.append(u) myB.append(RepCode.writeBytes(v, CODE_INT)) elif isinstance(v, float): myB.append(bytes([69, CODE_FLOAT, RepCode.lisSize(CODE_FLOAT), 0])) myB.append(b'VALU') myB.append(u) myB.append(RepCode.writeBytes(v, CODE_FLOAT)) # Use self._retFilePrS() as size could be large myBaseFile = BaseTestClasses.TestBaseFile() myF = myBaseFile._retFilePrS(b''.join(myB)) return LogiRec.LrTableRead(myF)
def test_02(self): """TestFILMRead_Fail.test_02(): Constructor - not a FILM table.""" myByFilm = b'"\x00' \ + b'IA\x04\x00TYPE NOTF' \ + b'\x00A\x04\x00MNEM 1\x00\x00\x00' \ + b'EA\x04\x00GCOD E20 ' \ + b'EA\x04\x00GDEC -4--' \ + b'EA\x04\x00DEST PF1 ' \ + b'EA\x04\x00DSCA D200' \ + b'\x00A\x04\x00MNEM 2\x00\x00\x00' \ + b'EA\x04\x00GCOD EEE ' \ + b'EA\x04\x00GDEC ----' \ + b'EA\x04\x00DEST PF2 ' \ + b'EA\x04\x00DSCA D200' myFi = self._retFileSinglePr(myByFilm) self.assertRaises(FILMCfg.ExceptionFilmCfgLISRead, FILMCfg.FilmCfgLISRead, LogiRec.LrTableRead(myFi))
def setUp(self): """Set up Typical FILM record Table record (type 34) type: FILM MNEM GCOD GDEC DEST DSCA ----------------------------- A LLLL 1111 PFA D200 """ myByFilm = b'"\x00' \ + b'IA\x04\x00TYPE FILM' \ + b'\x00A\x04\x00MNEM A\x00\x00\x00' \ + b'EA\x04\x00GCOD LLLL' \ + b'EA\x04\x00GDEC 1111' \ + b'EA\x04\x00DEST PFA ' \ + b'EA\x04\x00DSCA D200' myFi = self._retFileSinglePr(myByFilm) self._fc = FILMCfg.FilmCfgLISRead(LogiRec.LrTableRead(myFi)) self.assertTrue(Mnem.Mnem(b'A ') in self._fc) self.assertFalse(Mnem.Mnem(b'B ') in self._fc)
def scanFile(fp, isVerbose, keepGoing, theS=sys.stdout): try: myFile = File.FileRead(fp, fp, keepGoing) except File.ExceptionFile as err: print('Can not open file, error: %s' % str(err)) return myFactory = LogiRec.LrFactoryRead() while not myFile.isEOF: myTellLr = myFile.tellLr() try: myLr = myFactory.retLrFromFile(myFile) if myLr is not None: print('0x{:08x}'.format(myTellLr), str(myLr)) if isVerbose: dumpLr(myLr) except LogiRec.ExceptionLr as err: pass #logging.error('LR at 0x{:08x}: {:s}'.format(myTellLr, err)) myFile.skipToNextLr()
def test_23(self): """TestLogHeader.test_23(): Fails with Logical Record that is missing 'VALU' column.""" myB = [ bytes([34, 0]), bytes([73, 65, 4, 0]), bytes('TYPE', 'ascii'), bytes(' ', 'ascii'), bytes('CONS', 'ascii'), ] myB.append(bytes([0, 65, 4, 0])) myB.append(b'MNEM') myB.append(b' ') myB.append(b'HIDE') myB.append(bytes([69, 65, 4, 0])) myB.append(b'valu') myB.append(b' ') myB.append(b'Well') myF = self._retFilePrS(b''.join(myB)) myLrCONS = LogiRec.LrTableRead(myF) myLh = LogHeader.APIHeaderLIS(isTopOfLog=False) tl = Coord.Pt(Coord.Dim(0.0, 'in'), Coord.Dim(0.0, 'in')) self.assertRaises(LogHeader.ExceptionLogHeader, myLh.plot, None, tl, [myLrCONS,])
def setup(self): myT = LogiRec.LrTableWrite( 34, b'PRES', ( b'MNEM', b'OUTP', b'STAT', b'TRAC', b'CODI', b'DEST', b'MODE', b'FILT', b'LEDG', b'REDG', ), ( (b'40 ', b'TEST', b'ALLO', b'T1 ', b'LLIN', b'2 ', b'SHIF', 0.5, (-40.0, b'MV '), (40.0, b'MV ')), (b'20 ', b'TEST', b'ALLO', b'T2 ', b'HDAS', b'2 ', b'SHIF', 0.5, (-20.0, b'MV '), (20.0, b'MV ')), (b'10 ', b'TEST', b'ALLO', b'T3 ', b'LGAP', b'2 ', b'WRAP', 0.5, (-10.0, b'MV '), (10.0, b'MV ')), (b'5 ', b'TEST', b'ALLO', b'T2 ', b'HSPO', b'2 ', b'WRAP', 0.5, (-5.0, b'MV '), (5.0, b'MV ')), (b'2.5 ', b'TEST', b'ALLO', b'T3 ', b'LSPO', b'2 ', b'WRAP', 0.5, (-2.5, b'MV '), (2.5, b'MV ')), ), ) ba = bytearray([34, 0]) for b in myT.genLisBytes(): ba += b file_obj = write_logical_data_to_physical_records([bytes(ba)]) self.file_read = File.FileRead(theFile=file_obj, theFileId='MyFile', keepGoing=True)
def setUp(self): """Set up Typical FILM record Table record (type 34) type: FILM MNEM GCOD GDEC DEST DSCA ----------------------------- 1 E20 -4-- PF1 D200 2 E2E -4-- PF2 D200 """ myByFilm = b'"\x00' \ + b'IA\x04\x00TYPE FILM' \ + b'\x00A\x04\x00MNEM 1\x00\x00\x00' \ + b'EA\x04\x00GCOD E20 ' \ + b'EA\x04\x00GDEC -4--' \ + b'EA\x04\x00DEST PF1 ' \ + b'EA\x04\x00DSCA D200' \ + b'\x00A\x04\x00MNEM 2\x00\x00\x00' \ + b'EA\x04\x00GCOD EEE ' \ + b'EA\x04\x00GDEC ----' \ + b'EA\x04\x00DEST PF2 ' \ + b'EA\x04\x00DSCA D200' myFi = self._retFileSinglePr(myByFilm) self._fc = FILMCfg.FilmCfgLISRead(LogiRec.LrTableRead(myFi)) self.assertTrue(Mnem.Mnem(b'1 ') in self._fc) self.assertFalse(Mnem.Mnem(b'10 ') in self._fc)
def test_02(self): """TestXMLMatchesRHDT.test_01(): Which XML LgFormat files with RPS1 (RepCode 130, 80 bytes) channel and a LIS LogPass.""" # DIPMETER_EDIT_TAPE_REP_CODE myF = self._retFileSinglePr( # LRH for DFSR bytes([64, 0]) # EB 4, up/down value 0 (down) + bytes([4, 1, 66, 0]) # EB 12, absent value -153.0 + bytes([12, 4, 68]) + b'\xbb\xb3\x80\x00' # EB 0 terminates read + bytes([0, 1, 66, 0]) # # Sensor 0 # Mnemonic Service ID Serv ord No Units API 45,310,01,1 File No: 256 + b'DEPT' + b'ServID' + b'ServOrdN' + b'FEET' + b'\x02\xb3\x60\x3b' + bytes([1, 0]) # 4 LIS bytes Pad 1 super Rep code Process indicators + bytes([0, 4]) + b'000' + b'\x01' + bytes([ 68, ]) + bytes([0, 1, 2, 3, 4]) # Sensor 1 + b'RPS1' + b'ServID' + b'ServOrdN' + b' ' + b'\x02\xb3\x60\x3b' + bytes([1, 0]) + bytes([0, 80]) + b'000' + b'\x01' + bytes([ 130, ]) + bytes([0, 1, 2, 3, 4]) # Sensor 2 + b'P1AZ' + b'ServID' + b'ServOrdN' + b' ' + b'\x02\xb3\x60\x3b' + bytes([1, 0]) + bytes([0, 4]) + b'000' + b'\x01' + bytes([ 68, ]) + bytes([0, 1, 2, 3, 4]) # Sensor 3 + b'DEVI' + b'ServID' + b'ServOrdN' + b' ' + b'\x02\xb3\x60\x3b' + bytes([1, 0]) + bytes([0, 4]) + b'000' + b'\x01' + bytes([ 68, ]) + bytes([0, 1, 2, 3, 4]) # Sensor 4 + b'HAZI' + b'ServID' + b'ServOrdN' + b' ' + b'\x02\xb3\x60\x3b' + bytes([1, 0]) + bytes([0, 4]) + b'000' + b'\x01' + bytes([ 68, ]) + bytes([0, 1, 2, 3, 4]) # Sensor 5 + b'C1 ' + b'ServID' + b'ServOrdN' + b' ' + b'\x02\xb3\x60\x3b' + bytes([1, 0]) + bytes([0, 4]) + b'000' + b'\x01' + bytes([ 68, ]) + bytes([0, 1, 2, 3, 4]) # Sensor 6 + b'C2 ' + b'ServID' + b'ServOrdN' + b' ' + b'\x02\xb3\x60\x3b' + bytes([1, 0]) + bytes([0, 4]) + b'000' + b'\x01' + bytes([ 68, ]) + bytes([0, 1, 2, 3, 4]) # Sensor 7 + b'FEP ' + b'ServID' + b'ServOrdN' + b' ' + b'\x02\xb3\x60\x3b' + bytes([1, 0]) + bytes([0, 4]) + b'000' + b'\x01' + bytes([ 68, ]) + bytes([0, 1, 2, 3, 4]) # Sensor 8 + b'RB ' + b'ServID' + b'ServOrdN' + b' ' + b'\x02\xb3\x60\x3b' + bytes([1, 0]) + bytes([0, 4]) + b'000' + b'\x01' + bytes([ 68, ]) + bytes([0, 1, 2, 3, 4])) myLp = LogPass.LogPass(LogiRec.LrDFSRRead(myF), 'FileID') myFilmCfg = FILMCfgXML.FilmCfgXMLRead('') myFilmCfg.addXMLRoot(etree.fromstring( TestLgFormatXMLData.LGFORMAT_HDT)) filmMap = XMLMatches.fileCurveMapFromFILM(myLp, myFilmCfg) # print() # print('myLp._chMap:') # pprint.pprint(myLp._chMap) # print(myLp.longStr()) # pprint.pprint(sorted(myLp.outpMnemS())) # print('filmMap:') # pprint.pprint(filmMap) # pprint.pprint(sorted(filmMap['HDT'])) self.assertEqual( [ Mnem.Mnem(b'C1\x00\x00'), Mnem.Mnem(b'C2\x00\x00'), Mnem.Mnem(b'DEPT'), Mnem.Mnem(b'DEVI'), # Mnem.Mnem(b'EMEX'), Mnem.Mnem(b'FC0\x00'), Mnem.Mnem(b'FC1\x00'), Mnem.Mnem(b'FC2\x00'), Mnem.Mnem(b'FC3\x00'), Mnem.Mnem(b'FC4\x00'), Mnem.Mnem(b'FEP\x00'), # Mnem.Mnem(b'FEP1'), # Mnem.Mnem(b'FEP2'), Mnem.Mnem(b'HAZI'), Mnem.Mnem(b'P1AZ'), # Mnem.Mnem(b'PADP'), # Mnem.Mnem(b'RAC1'), # Mnem.Mnem(b'RAC2'), Mnem.Mnem(b'RB\x00\x00'), # Mnem.Mnem(b'REF\x00'), # Mnem.Mnem(b'REFC'), # Mnem.Mnem(b'STAT'), # Mnem.Mnem(b'TEMP'), ], sorted(myLp.outpMnemS()), ) self.assertEqual(1, len(filmMap)) self.assertTrue('HDT' in filmMap) self.assertEqual([ Mnem.Mnem(b'C1\x00\x00'), Mnem.Mnem(b'C2\x00\x00'), Mnem.Mnem(b'DEVI'), Mnem.Mnem(b'FC0\x00'), Mnem.Mnem(b'FC1\x00'), Mnem.Mnem(b'FC2\x00'), Mnem.Mnem(b'FC3\x00'), Mnem.Mnem(b'FC4\x00'), Mnem.Mnem(b'HAZI'), Mnem.Mnem(b'P1AZ'), Mnem.Mnem(b'RB\x00\x00'), ], sorted(filmMap['HDT']))
def time_read(self): self.file_read.rewind() LogiRec.LrReelTailRead(self.file_read)
def time_read(self, arg): self.file_read.rewind() LogiRec.LrMiscRead(self.file_read)
def time_read(self): self.file_read.rewind() LogiRec.LrTableRead(self.file_read)
def time_read(self, param): self.file_read.rewind() dfsr = LogiRec.LrDFSRRead(self.file_read)
def time_read(self): self.file_read.rewind() LogiRec.LrDFSRRead(self.file_read)
def isDelimiter(self): """True if this represents a delimiter record e.g. File Head/Tail.""" return LogiRec.isDelimiter(self._typ)
def __init__(self, theF, xAxisIndex=0): self._fileId = theF.fileId self._xAxisIndex = xAxisIndex theF.rewind() # List of indexable objects that are a IndexObjBase example; an IndexLogPass self._idx = [] # Indexes to log pass objects: {0 : None, 1 : None} self._logPassIndexMap = self._resetLogPassIndexMap() # Despatch table for LR type self._despatchLrType = { # The first two should be handled by the LogPass, if not # we ignore them as we can't interpret them LogiRec.LR_TYPE_NORMAL_DATA: None, #IndexNone, LogiRec.LR_TYPE_ALTERNATE_DATA: None, #IndexNone, LogiRec.LR_TYPE_JOB_ID: IndexTable, LogiRec.LR_TYPE_WELL_DATA: IndexTable, LogiRec.LR_TYPE_TOOL_INFO: IndexTable, LogiRec.LR_TYPE_ENCRYPTED_TABLE: IndexNone, LogiRec.LR_TYPE_TABLE_DUMP: IndexNone, LogiRec.LR_TYPE_DATA_FORMAT: IndexLogPass, LogiRec.LR_TYPE_DATA_DESCRIPTOR: IndexNone, LogiRec.LR_TYPE_TU10_BOOT: IndexNone, LogiRec.LR_TYPE_BOOTSTRAP_LOADER: IndexNone, LogiRec.LR_TYPE_CP_KERNEL: IndexNone, LogiRec.LR_TYPE_PROGRAM_FILE_HEAD: IndexNone, LogiRec.LR_TYPE_PROGRAM_OVER_HEAD: IndexNone, LogiRec.LR_TYPE_PROGRAM_OVER_LOAD: IndexNone, LogiRec.LR_TYPE_FILE_HEAD: IndexFileHead, LogiRec.LR_TYPE_FILE_TAIL: IndexFileTail, LogiRec.LR_TYPE_TAPE_HEAD: IndexTapeHead, LogiRec.LR_TYPE_TAPE_TAIL: IndexTapeTail, LogiRec.LR_TYPE_REEL_HEAD: IndexReelHead, LogiRec.LR_TYPE_REEL_TAIL: IndexReelTail, LogiRec.LR_TYPE_EOF: IndexNone, LogiRec.LR_TYPE_BOT: IndexNone, LogiRec.LR_TYPE_EOT: IndexNone, LogiRec.LR_TYPE_EOM: IndexNone, LogiRec.LR_TYPE_OPERATOR_INPUT: IndexUnknownInternalFormat, LogiRec.LR_TYPE_OPERATOR_RESPONSE: IndexUnknownInternalFormat, LogiRec.LR_TYPE_SYSTEM_OUTPUT: IndexUnknownInternalFormat, LogiRec.LR_TYPE_FLIC_COMMENT: IndexUnknownInternalFormat, LogiRec.LR_TYPE_BLANK_RECORD: IndexUnknownInternalFormat, LogiRec.LR_TYPE_PICTURE: IndexUnknownInternalFormat, LogiRec.LR_TYPE_IMAGE: IndexUnknownInternalFormat, } while not theF.isEOF: # Grab the file position t = theF.tellLr() # Read the LRH myBy = theF.readLrBytes(LogiRec.STRUCT_LR_HEAD.size) if not myBy: break lrTy, lrAt = LogiRec.STRUCT_LR_HEAD.unpack(myBy) # If this can be handled by a Log Pass then do so if lrTy in self._logPassIndexMap: if self._logPassIndexMap[lrTy] is not None: # Normal/Alternate data with prior LogPass self._idx[self._logPassIndexMap[lrTy]].add(t, lrTy, theF) else: # Despatch on lrTy fn = self._despatchLrType[lrTy] if fn is None: logging.warning( 'FileIndex.__init__(): Can not handle logical record type {:d}' .format(lrTy)) else: # TODO: Use self._xAxisIndex self._idx.append(fn(t, lrTy, theF)) # Check and fix self._logPassIndexMap if LogiRec.isDelimiter(lrTy): # De-index the LogPass(es) self._logPassIndexMap = self._resetLogPassIndexMap() elif lrTy == LogiRec.LR_TYPE_DATA_FORMAT: # DFSR so update the map to point at the latest index self._logPassIndexMap[self._idx[-1].iflrType()] = len( self._idx) - 1
def time_read(self): self.file_read.rewind() LogiRec.LrFileHeadRead(self.file_read)
def setLogicalRecord(self, theFile): """Sets the logicalRecord property to an LogiRec.LrTable() object.""" if self._lr is None: self._seekFile(theFile) self._lr = LogiRec.LrTableRead(theFile) theFile.skipToNextLr()
def __init__(self, tell, lrType, theF): super().__init__(tell, lrType, theF) # Now read first component block self._cb = LogiRec.CbEngValRead(theF) theF.skipToNextLr()