TIF Marker Handling

TIF Markers

These are 3x32bit big-endian integers at the beginning of each Physical Record.

Word[0]

This is the TIF set type, 0 for a normal TIF set. 1 for an EOF set.

Word[1]

This is the physical file location of the start of the previous set.

Word[2]

This is the physical file location of the start of the next set.

A dump looks like this:

           0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
00000000: 00 00 00 00 00 00 00 00 4A 00 00 00 00 3E 00 00
00000010: 80 00 32 30 30 30 39 39 2E 44 41 54 20 20 20 20
00000020: 20 20 20 20 20 20 20 20 20 20 20 20 39 39 2F 30
00000030: 34 2F 32 39 20 20 31 30 32 34 20 20 20 20 20 20
00000040: 20 20 20 20 20 20 2E 20 20 20 00 00 00 00 00 00
00000050: 00 00 56 04 00 00 04 00 00 01 40 00 01 01 42 00
00000060: 02 01 42 00 03 04 49 00 00 02 34 04 01 42 01 05
...
00000450: 20 20 44 45 47 20 00 00 00 00 4A 00 00 00 62 08
00000460: 00 00 04 00 00 03 00 00 00 00 00 00 00 04 20 20
00000470: 00 01 44 20 20 20 20 20 31 30 41 20 20 20 20 20
...
00000860: 46 4E 00 00 00 00 56 04 00 00 6E 0C 00 00 04 00
00000870: 00 03 4F 52 20 20 20 20 20 20 20 20 20 20 20 20
...
...
...
0016E770: 18 00 BA 83 18 00 00 00 00 00 30 E5 16 00 C0 E7
0016E780: 16 00 00 3E 00 00 81 00 32 30 30 30 39 39 2E 44
...
0016E7B0: 20 20 20 20 20 20 20 20 20 20 20 20 2E 20 20 20
0016E7C0: 01 00 00 00 76 E7 16 00 CC E7 16 00 01 00 00 00
0016E7D0: C0 E7 16 00 D8 E7 16 00                        

Or:

tell()       TIF type           TIF back           TIF next
00000000:    00 00 00 00        00 00 00 00        00 00 00 4A
0000004A:    00 00 00 00        00 00 00 00        00 00 04 56
00000456:    00 00 00 00        00 00 00 4A        00 00 08 62
00000862:    00 00 00 00        00 00 04 56        00 00 0C 6E
...
0016E776:    00 00 00 00        00 16 E5 30        00 16 E7 C0
0016E7C0:    00 00 00 01        00 16 E7 76        00 16 E7 CC
0016E7CC:    00 00 00 01        00 16 E7 C0        00 16 E7 D8
0016E7D8: EOF
exception TotalDepth.LIS.core.TifMarker.ExceptionTifMarker

Specialisation of exception for Physical Records.

TotalDepth.LIS.core.TifMarker.TIF_FIRST_WORD_LIMIT = 65547

The maximum possible size of the first ‘next’ word. If larger than this then the words are written wrongly as little-endian and need to be reversed This is calculated as the maximum PR length + TIF bytes.

TotalDepth.LIS.core.TifMarker.TIF_NUM_WORDS = 3

Number of words in a TIF marker

TotalDepth.LIS.core.TifMarker.TIF_TOTAL_BYTES = 12

Number of bytes in a TIF marker

TotalDepth.LIS.core.TifMarker.TIF_WORD_ALL_FORMAT = <Struct object at 0x10358e298>

struct.Struct() format for a TIF marker

TotalDepth.LIS.core.TifMarker.TIF_WORD_ALL_FORMAT_WRONG_SEX = <Struct object at 0x10358e2d0>

struct.Struct() format for a TIF marker written wrongly as little-endian

TotalDepth.LIS.core.TifMarker.TIF_WORD_BYTES = 4

Number of bytes in a TIF word

TotalDepth.LIS.core.TifMarker.TIF_WORD_FORMAT = <Struct object at 0x10358e228>

struct.Struct() format for a TIF word

TotalDepth.LIS.core.TifMarker.TIF_WORD_FORMAT_WRONG_SEX = <Struct object at 0x10358e260>

struct.Struct() format for a TIF word written wrongly as little-endian

class TotalDepth.LIS.core.TifMarker.TifMarkerBase(raiseOnError=True)

Base class for TIF markers.

eof

True if I have encountered a EOF marker.

markers()

Current values of markers as a tuple of three integers.

reportError(theMsg)

Reports the error. I constructed with raiseOnError as True this will raise a ExceptionTifMarker otherwise it will write the error to the log.

reset()

Resets the TIF markers to all zero, this means hasPrevious is False.

strHeader()

Header string for an ASCII dump.

class TotalDepth.LIS.core.TifMarker.TifMarkerRead(theStream, allowPrPadding=False)

Class for reading TIF markers. This will automatically determine if TIF markers are present and automatically correct ill-formed little-endian TIF markers.

theStream - the file stream.

allowPrPadding - If True this will consume spurious padding bytes after the Physical Record tail i.e. the TIF markers determine the Physical Record structure rather than the Physical Record Headers.

hasPrevious

True if a Physical Record has been read, cleared on reset().

read(theStream)

Read TIF markers from a RawStream object. Returns the stream tell() or None of the start of the TIF marker. This is not necessarily the same as the stream tell() seen by the caller as we might consume PR padding.

reset()

Calling reset() means that the caller is probably randomly accessing the file so we can not error check the previous marker in the same way that we can if we are reading the file linearly.

class TotalDepth.LIS.core.TifMarker.TifMarkerWrite

Class for writing TIF markers.

close(theStream)

Write TIF EOF markers.

write(theStream, theLen)

Write TIF markers to a RawStream object. theLen must be the length of the Physical Record including the PRH and PRT.

Table Of Contents

Previous topic

LIS File

Next topic

Physical Record Handler

This Page