SELKIELogger  1.0.0
SELKIELogger.SLFiles.StateFile Class Reference

Represent a logger state file, caching information as necessary. More...

Public Member Functions

def __init__ (self, filename)
 Create new object. More...
 
def parse (self)
 Read file and extract data. More...
 
def sources (self)
 Retrieve list of sources referenced in this state file, parsing file if necessary. More...
 
def channels (self, source)
 Extract all channels referenced in this state file for a specific source ID. More...
 
def last_source_message (self, source)
 Find most recent message received from a given source and convert to a clocktime value. More...
 
def last_channel_message (self, source, channel)
 Find most recent message received from a channel (specified by source and channel IDs) and convert to a clocktime value. More...
 
def timestamp (self)
 Return latest timestamp from state file, parsing file if required. More...
 
def to_clocktime (self, timestamp)
 Convert logger timestamp to real date/time. More...
 

Private Attributes

 _fn
 File name (and path, if required) for this instance.
 
 _sm
 SourceMap.
 
 _ts
 Last known timestamp.
 
 _vf
 Channel mapping file / VarFile associated with this state file.
 
 _stats
 Source/Channel statistics.
 
 _mtime
 

Detailed Description

Represent a logger state file, caching information as necessary.

Definition at line 548 of file SLFiles.py.

Constructor & Destructor Documentation

◆ __init__()

def SELKIELogger.SLFiles.StateFile.__init__ (   self,
  filename 
)

Create new object.

File is not opened or parsed until requested.

Parameters
filenamePath to state file to be read

Definition at line 551 of file SLFiles.py.

Member Function Documentation

◆ channels()

def SELKIELogger.SLFiles.StateFile.channels (   self,
  source 
)

Extract all channels referenced in this state file for a specific source ID.

Will parse the state file if required.

Parameters
sourceSource ID to extract
Returns
Sorted set of channel IDs

Definition at line 612 of file SLFiles.py.

◆ last_channel_message()

def SELKIELogger.SLFiles.StateFile.last_channel_message (   self,
  source,
  channel 
)

Find most recent message received from a channel (specified by source and channel IDs) and convert to a clocktime value.

Will parse the state file if required.

Parameters
sourceSource ID to be checked
channelChannel ID to be checked
Returns
clocktime, or None on error.

Definition at line 648 of file SLFiles.py.

◆ last_source_message()

def SELKIELogger.SLFiles.StateFile.last_source_message (   self,
  source 
)

Find most recent message received from a given source and convert to a clocktime value.

Will parse the state file if required.

Parameters
sourceSource ID to check
Returns
clocktime, or None on error.

Definition at line 628 of file SLFiles.py.

◆ parse()

def SELKIELogger.SLFiles.StateFile.parse (   self)

Read file and extract data.

Returns
Channel statistics (also stored in _stats)

Definition at line 568 of file SLFiles.py.

◆ sources()

def SELKIELogger.SLFiles.StateFile.sources (   self)

Retrieve list of sources referenced in this state file, parsing file if necessary.

Returns
Sorted set of source IDs

Definition at line 601 of file SLFiles.py.

◆ timestamp()

def SELKIELogger.SLFiles.StateFile.timestamp (   self)

Return latest timestamp from state file, parsing file if required.

Returns
Latest logger timestamp value (ms)

Definition at line 666 of file SLFiles.py.

◆ to_clocktime()

def SELKIELogger.SLFiles.StateFile.to_clocktime (   self,
  timestamp 
)

Convert logger timestamp to real date/time.

Assumes that the most recent message was received at the file's modification time and uses this as an offset.

Parameters
timestampValue to be converted
Returns
Pandas DateTime object

Definition at line 675 of file SLFiles.py.


The documentation for this class was generated from the following file: