Files
storage_fresco/TQUI_tel.py
2019-05-23 13:36:01 +00:00

133 lines
5.2 KiB
Python
Executable File

#!/usr/bin/python
"""
transport result (TQUI) - Telegram
.. module:: TQUI
.. _tqui-content:
Transport result
================
=============== ======== ======== ============================= ========================================================
ID Byte-Pos Type Value Description
=============== ======== ======== ============================= ========================================================
Sequence-Nr 0:2 SINT16 0..32767 Telegramcounter
Tel-Source 2:4 CHAR[2] ['TP','LV'] Source of Telegram (to be removed in next versions)
Tel-Destination 4:6 CHAR[2] ['TP','LV'] Destination of Telegram (to be removed in next versions)
Tel-Type 6:10 CHAR[4] 'TQUI' Ident of Telegram (prepared to multiplex Channels)
BoxNr 10:30 CHAR[20] '2147483647' BoxNr - PLC uses UINT32 by now so Max=2147483647
Positon 30:34 CHAR[4] 'I001', 'RFZ1' Position for executing Transport
Source 34:38 CHAR[4] 'I001', 'RFZ1', 'S001','T001' Sourcearea (I-Point, RFZ1, Storage) for Transport
SourceXX 38:40 CHAR[2] '00' Source-Coordinates X where neccersary
SourceYY 40:42 CHAR[2] '00' Source-Coordinates Y where neccersary
SourceZZ 42:44 CHAR[2] '00' Source-Coordinates Z where neccersary
Destination 44:48 CHAR[4] 'S001', 'T001' DestinationArea (Storage, Outfeedposition) for Transport
DestinationXX 48:50 CHAR[2] '00' Destination-Coordinates X where neccersary
DestinationYY 50:52 CHAR[2] '00' Destination-Coordinates Y where neccersary
DestinationZZ 52:54 CHAR[2] '00' Destination-Coordinates Z where neccersary
State 54:56 CHAR[2] '00' State of Transport - Result
=============== ======== ======== ============================= ========================================================
.. _tqui-results:
Transport results
=================
Every Transport of a Shelf access equipment returns a TQUI with the following states
- 01: Order complete - box was transported correctly
- 02: Order aborted - no transport happened
- 03: No crate - there was no box in the source of the Transport may cause dummybox transport
- 04: Destination occupied - there is no place for the box in destination
- 05: Wrong box loaded - generate alternate Transport
- 11: Order complete Dummy - detected dummy and return it to depot
"""
__author__ = "Michael Rest"
__date__ = "2006/02/15"
__email__ = "michi@rosstein.de"
__version__ = "$Revision: 1.1 $"[11:-2]
from telegram import TELEGRAM, TEL_TQUI
# String representation for a DT TPDU
DT_STRING = \
"""\
Length: %d
Number: 0x%02x
Contained Data: %s
"""
def fromstring (data):
"""
Decode the binary representation of a TQUI from the given
parameter and note the data in the instance of the object.
Parameters:
data: The binary form of the TELEGRAM
"""
tel = TEL_TQUI ()
tel.attrib['nr'] = (ord (data [0]) << 8) + ord (data [1])
tel.attrib['src'] = data [2:4]
tel.attrib['dst'] = data [4:6]
tel.attrib['type'] = data [6:10]
#tel.attrib['box_nr'] =data [10:30]
tel.attrib['box_nr'] = data [12:12 + ord (data [11])]
tel.attrib['location'] = data [22:26]
tel.attrib['src_id'] = data [26:30]
tel.attrib['src_xx'] = data [30:32]
tel.attrib['src_yy'] = data [32:34]
tel.attrib['src_zz'] = data [34:36]
tel.attrib['dst_id'] = data [36:40]
tel.attrib['dst_xx'] = data [40:42]
tel.attrib['dst_yy'] = data [42:44]
tel.attrib['dst_zz'] = data [44:46]
tel.attrib['state'] = data [46:len(data)]
return tel
class TEL_TQUI (TELEGRAM):
def __init__ (self, nr = 0, src = 'LV', dst = 'TP', state='00', *args, **args2):
TELEGRAM.__init__(self)
self.code = TEL_TQUI
self.attrib['nr'] = nr
self.attrib['src'] = src
self.attrib['dst'] = dst
self.attrib['type'] = 'TQUI'
self.attrib['state'] = state
self.__recalclen ()
return
def identify (self):
"""
This method can be used to identify a TELEGRAM by string.
"""
return "TQUI TELEGRAM\n"
def __recalclen (self):
"""
Return the length of the TPDU. This function is for
internal use only!
"""
self.len = 2 + 4l
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.
"""
print self.attrib
string = self.identify () #+ DT_STRING % (self.len, self.number, self.data)
return string