Added PD99_tel
This commit is contained in:
85
PD99_tel.py
Executable file
85
PD99_tel.py
Executable file
@@ -0,0 +1,85 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
__author__ = "Michael Rest"
|
||||
__date__ = "2016/09/01"
|
||||
__email__ = "mr@mir.systems"
|
||||
__version__ = "$Revision: 1.1 $"[11:-2]
|
||||
|
||||
|
||||
from telegram import TELEGRAM, TEL_PD99
|
||||
from telegram import tsdecode
|
||||
from states import *
|
||||
from parts import *
|
||||
|
||||
def fromstring (data):
|
||||
"""
|
||||
Decode the binary representation of a PD_tel from the given
|
||||
parameter and note the data in the instance of the object.
|
||||
|
||||
Parameters:
|
||||
data: The binary form of the TELEGRAM
|
||||
"""
|
||||
tel = TEL_PD99 ()
|
||||
try:
|
||||
tel.attrib['nr'] = (data [0] << 8) + data [1]
|
||||
except:
|
||||
print ("Debug-Nr", data[0], data[1])
|
||||
tel.attrib['src'] = data [2:4].decode ()
|
||||
tel.attrib['dst'] = data [4:6].decode ()
|
||||
tel.attrib['type'] = data [6:10].decode ()
|
||||
tel.attrib['dmc'] = (data [10:38]).decode ().rstrip (' \x00')
|
||||
tel.attrib['startts'] = tsdecode (data [38:52].decode ())
|
||||
tel.attrib['endts'] = tsdecode (data [52:66].decode ())
|
||||
#66-70 Varianten daten
|
||||
# Bitarray other Byte Order !!
|
||||
tel.attrib['variante'] = variante.get ((data [69] << 8) + data [68], '')
|
||||
tel.attrib['bauteilstatus'] = bauteilstatus.get (chr (data [70]), '') #0 - unbearbeitet; 1 - iO; 2 - niO
|
||||
try:
|
||||
tel.attrib['chiron'] = (data [90] << 8) + data [91]
|
||||
except:
|
||||
print ("Debug-aufnahme", data[90], data[91])
|
||||
|
||||
tel.attrib['ladungstraeger'] = data [92:93].decode ()
|
||||
return tel
|
||||
|
||||
|
||||
class TEL_PD99 (TELEGRAM):
|
||||
def __init__ (self, nr = 0, src = '99', dst = 'PC', *args, **args2):
|
||||
TELEGRAM.__init__(self)
|
||||
self.code = TEL_PD99
|
||||
self.attrib['nr'] = nr
|
||||
self.attrib['src'] = src
|
||||
self.attrib['dst'] = dst
|
||||
self.attrib['type'] = 'PD99'
|
||||
self.attrib['startts'] = '2000-01-01 01:01:01'
|
||||
self.attrib['endts'] = '2000-02-02 02:02:02'
|
||||
self.attrib['dmc'] = '1234'
|
||||
self.attrib['bauteilstatus'] = '0'
|
||||
self.attrib['ladungstrager'] = '0'
|
||||
self.attrib['aufnahme'] = 0
|
||||
|
||||
self.len = 2220907
|
||||
return
|
||||
|
||||
def identify (self):
|
||||
"""
|
||||
This method can be used to identify a TELEGRAM by string.
|
||||
"""
|
||||
return "PD02 TELEGRAM"
|
||||
|
||||
|
||||
def __repr__ (self):
|
||||
"""
|
||||
Print a representation of the TPDU. Use this method via
|
||||
`-pair to transfer it over the wire. This will just return
|
||||
the header data and not the real data!
|
||||
"""
|
||||
# Note that the data is not included in the length
|
||||
return "%c%c%c" % (2, self.code << 4, self.number) + self.data
|
||||
|
||||
def __str__ (self):
|
||||
"""
|
||||
Return a readable and quite verbose overview of the TPDU instance.
|
||||
Use this for debugging purposes or if you're just curious.
|
||||
"""
|
||||
return "Packet: %s Data: %s" % (self.identify (), repr (self.attrib))
|
||||
Reference in New Issue
Block a user