pyP2Monitor  1.0.0
Monitor a P2 furnace activity reading data on serial port
 All Data Structures Namespaces Functions Variables Groups Pages
Public Member Functions | Static Public Member Functions | Data Fields | Static Public Attributes
P2Msg Class Reference

The class managing message from the furnace. More...

Public Member Functions

def __init__
 Instanciate a new P2Msg object.
def setHeader
 Set the P2msg header.
def setDataSz
 Set the data size if sizeChk is True and data already set, check for validity.
def setData
 Set the P2Msg data field If sizeChk is True and data size already set check for validity.
def setChecksum
 Set the cheksum If no arguments process the checksum from header and datas if checksum argument set and check is True set the checksum value and check its validity.
def prepare
 Prepare a message to be ready to send.
def resetValid
 Reset the value of the P2Msg::valid flag.
def getDataSz
 Return the data size.
def getChecksum
 Return the checksum.
def getHeader
 Return the header.
def getData
 Return the data.
def __print__
 Alias for P2Msg::getStr()
def getStr
 Return a string representing the message in hexadecimal notation.
def getRaw
 Return the raw str representing the message.
def dump
 Display all the informations on the message.
def dumpData
 Return a string trying to display every printable ASCII character.
def dispInitMsg
 A try to display initialisation message.
def failed
 Return the not valid flag.
def calcChecksum
 Return the checksum as an integer for this message.
def check
 Check the message checksum.

Static Public Member Functions

def str2list
 Cast an ascii string into a list of bytes (type cast only)
def hex2list
 Convert a string with 2 digits hexadecimal numbers into a list of integers.
def formatList
 Format an integer list.

Data Fields

 header
 The message header or command identifier.
 datas
 The message data.
 dataSz
 The data length in bytes.
 checksum
 The message checksum.
 valid
 A flag telling wether the message is in a valid state or not.

Static Public Attributes

int FMT_INT = 1
 Huge integer format.
int FMT_RAW_STR = 2
 Raw string format.
int FMT_HEX_STR = 3
 Hexadecimal representation string.
int FMT_LIST = 4
 Integer list.

Detailed Description

The class managing message from the furnace.

Definition at line 33 of file p2msg.py.

Constructor & Destructor Documentation

def __init__ (   self,
  header = None,
  datas = None 
)

Instanciate a new P2Msg object.

Parameters
headerThe message header (aka command identifier)
datasThe message data

Definition at line 55 of file p2msg.py.

Member Function Documentation

def calcChecksum (   self)

Return the checksum as an integer for this message.

Process and return the current message checksum

Returns
An integer representing the message's checksum

Definition at line 454 of file p2msg.py.

References P2Msg.datas, P2Query.datas, P2Msg.dataSz, and P2Msg.header.

Referenced by P2Msg.setChecksum().

def check (   self)

Check the message checksum.

Process the checksum and check if it is the same than the stored checksum

Returns
A boolean value

Definition at line 467 of file p2msg.py.

References P2Msg.checksum, and P2Msg.getChecksum().

Referenced by P2Msg.getRaw(), and P2Msg.setChecksum().

def dispInitMsg (   self)

A try to display initialisation message.

This functions try to display P2 furnace initialisation message in a more readable format

Definition at line 405 of file p2msg.py.

References P2Msg.datas, P2Query.datas, P2Msg.dumpData(), and P2Msg.header.

def dumpData (   self,
  data,
  chrRange = [' ' 
)

Return a string trying to display every printable ASCII character.

   The returned string represente each data's bytes sperated with a space.
   Printable character are displayed as a single char when other value are displayed in 2 digits hexadecimal notation
Parameters
dataThe data to parse
chrRangeThe character range to display
Returns
A string

Definition at line 393 of file p2msg.py.

Referenced by P2Msg.dispInitMsg().

def failed (   self)

Return the not valid flag.

Returns
the negation of P2Msg::valid

Definition at line 446 of file p2msg.py.

References P2Msg.valid.

Referenced by P2Msg.getRaw().

def formatList (   lst,
  fmt 
)
static

Format an integer list.

Parameters
lstThe list to format
fmtThe wanted data format
Returns
Formated list
See Also
Data format
Exceptions
TypeErrorOn invalid type for parameters

Definition at line 297 of file p2msg.py.

def getChecksum (   self,
  fmt = FMT_INT 
)

Return the checksum.

Parameters
fmtThe wanted data format
Returns
Formated checksum
See Also
Data format
Exceptions
TypeErrorOn invalid type for parameters

Definition at line 271 of file p2msg.py.

References P2Msg.checksum.

Referenced by P2Msg.check(), and P2Msg.getRaw().

def getData (   self,
  fmt = FMT_LIST 
)

Return the data.

Parameters
fmtThe wanted data format
Returns
Formated data
See Also
Data format

Definition at line 331 of file p2msg.py.

References P2Msg.datas, and P2Query.datas.

Referenced by P2Msg.getRaw().

def getDataSz (   self,
  fmt = FMT_INT 
)

Return the data size.

Parameters
fmtThe wanted data format
Returns
Formated data size
See Also
Data format
Exceptions
TypeErrorOn invalid type for parameters

Definition at line 246 of file p2msg.py.

References P2Msg.dataSz.

Referenced by P2Msg.getRaw().

def getHeader (   self,
  fmt = FMT_LIST 
)

Return the header.

Parameters
fmtThe wanted data format
Returns
Formated header
See Also
Data format

Definition at line 321 of file p2msg.py.

References P2Msg.header.

Referenced by P2Msg.getRaw().

def getRaw (   self)

Return the raw str representing the message.

Returns
An ascii string

Definition at line 359 of file p2msg.py.

References P2Msg.check(), P2Msg.failed(), P2Msg.getChecksum(), P2ComError.getData(), P2DbStore.getData(), P2Msg.getData(), P2Msg.getDataSz(), and P2Msg.getHeader().

def getStr (   self)

Return a string representing the message in hexadecimal notation.

Returns
A string with hexadecimal number notation on two hex digits

Definition at line 342 of file p2msg.py.

References P2Msg.checksum, P2Msg.datas, P2Query.datas, and P2Msg.header.

Referenced by P2Msg.__print__(), and P2Msg.setChecksum().

def hex2list (   strArg)
static

Convert a string with 2 digits hexadecimal numbers into a list of integers.

Input string example : "07474E5504"

Parameters
strArgA string with 2 hexadecimal digits integer representation (without space)
Returns
An array of integers

Definition at line 94 of file p2msg.py.

Referenced by p2data.csvOutputData(), p2data.datas2Json(), and P2Datas.fillQuery().

def prepare (   self,
  header = None,
  data = None 
)

Prepare a message to be ready to send.

Parameters
headerSet to None to leave header unchanged
dataSet to None to leave data unchanged
Returns
None

Definition at line 211 of file p2msg.py.

References P2Msg.datas, P2Query.datas, P2Msg.header, P2Msg.setChecksum(), P2Msg.setData(), P2Msg.setDataSz(), P2Msg.setHeader(), and P2Msg.valid.

def resetValid (   self,
  val = True 
)

Reset the value of the P2Msg::valid flag.

Parameters
valThe wanted value for the flag

Definition at line 231 of file p2msg.py.

References P2Msg.valid.

def setChecksum (   self,
  checksum = None,
  check = True 
)

Set the cheksum If no arguments process the checksum from header and datas if checksum argument set and check is True set the checksum value and check its validity.

Parameters
checksumSet to None for checksum processing from P2Msg::header P2Msg::dataSz and P2Msg::datas, else can be a raw sring or an integer array
checkIs a boolean telling if we check or not the validity of the checksum
Returns
P2Msg::valid
Exceptions
TypeErrorOn invalid type for parameters

Definition at line 182 of file p2msg.py.

References P2Msg.calcChecksum(), P2Msg.check(), P2Msg.checksum, P2Msg.getStr(), and P2Msg.valid.

Referenced by P2Msg.prepare().

def setData (   self,
  datas,
  sizeChk = True 
)

Set the P2Msg data field If sizeChk is True and data size already set check for validity.

Parameters
datasA raw string or an integer list representing datas
sizeChkA boolean telling whether we check datas argument size or not
Returns
P2Msg::valid
Exceptions
TypeErrorOn invalid type for parameters
DEACTIVATE TEST !!! TO REACTIVATE LATER
if sizeChk and self.dataSz != len(datas):
        self.valid = False

Definition at line 153 of file p2msg.py.

References P2Msg.datas, P2Query.datas, P2Msg.dataSz, and P2Msg.valid.

Referenced by P2Msg.prepare().

def setDataSz (   self,
  recvBuff,
  sizeChk = True 
)

Set the data size if sizeChk is True and data already set, check for validity.

Parameters
recvBuffIs either a raw string from the furnace begining with the data size (header removed) or an integer representing the data size
sizeChkA boolean telling if we have to check or not the data size (in the case where recvBuff is a raw string from serial port)
Returns
P2Msg::valid
Exceptions
TypeErrorOn invalid type for parameters

Definition at line 130 of file p2msg.py.

References P2Msg.datas, P2Query.datas, P2Msg.dataSz, and P2Msg.valid.

Referenced by P2Msg.prepare().

def setHeader (   self,
  header 
)

Set the P2msg header.

Parameters
headerThe frame header (as string or integer array)
Returns
P2Msg::valid
Exceptions
TypeErrorOn invalid type for header param

Definition at line 108 of file p2msg.py.

References P2Msg.header, and P2Msg.valid.

Referenced by P2Msg.prepare().

def str2list (   strArg)
static

Cast an ascii string into a list of bytes (type cast only)

Parameters
strArgAn ascii string
Returns
An array of integers

Definition at line 81 of file p2msg.py.


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