204 lines
8.9 KiB
Python
204 lines
8.9 KiB
Python
#!/usr/bin/python
|
|
"""
|
|
transport (TAUF) - Telegram
|
|
.. module:: TAUF
|
|
|
|
.. _tauf-content:
|
|
|
|
Transport content
|
|
-----------------
|
|
|
|
=============== ======== ======== ============================= ========================================================
|
|
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] 'TAUF' 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
|
|
=============== ======== ======== ============================= ========================================================
|
|
|
|
Positions
|
|
---------
|
|
Valid positions for Transports Indices may differ.
|
|
|
|
In case Source is a Storage, the fine Sources (XX, YY, ZZ) will also beused.
|
|
|
|
+---------+---------------------+-------+------------------------------------------------------+
|
|
|Position |Pos Type |Source |Action |
|
|
+=========+=====================+=======+======================================================+
|
|
|I001 |I-Point |I001 | | Start Box |
|
|
| | | | | DestinationXX finedestination put in PLC Hashtable |
|
|
| | | | | DestinationZZ errorcodes (see later) |
|
|
+---------+---------------------+-------+------------------------------------------------------+
|
|
|RFZ1 |Storage retrival eqm.| | I001| | Transport generated by an Scanner telegram on RFZ |
|
|
| | | | | | for inserting a box from an Pickup position |
|
|
| | | | RFZ1| | Alternative Transport (in case of overfill e.g.) |
|
|
| | | | T,S | | Automatic transport from a storage (refill, move) |
|
|
+---------+---------------------+-------+------------------------------------------------------+
|
|
|PU01 |Pusher |P001 | | Duouble function |
|
|
| | | | | DestinationXX finedestination put in PLC Hashtable |
|
|
| | | | | DestinationYY Unlock (0) Wait injection (1) |
|
|
+---------+---------------------+-------+------------------------------------------------------+
|
|
|O001 |Outpoint |O001 | | Indicate a new Order |
|
|
+---------+---------------------+-------+------------------------------------------------------+
|
|
|
|
Destinations
|
|
------------
|
|
The destinations for Transports are
|
|
|
|
+---------+---------------------+-----------------------------------------+
|
|
|T001 |Troughfeedshelf |Using fine Destinations (XX, YY, ZZ) |
|
|
+=========+=====================+=========================================+
|
|
|S002 |Single-Place-shelf | | Using fine Destinations (XX, YY, ZZ) |
|
|
| | | | ZZ == 1, will be used inf future |
|
|
+---------+---------------------+-----------------------------------------+
|
|
|C001 |Commisioning-shelf |Using fine Destinations (XX, YY, ZZ) |
|
|
+---------+---------------------+-----------------------------------------+
|
|
|O001 |Outfeedposition | | XX : Destination for PLC Hashtable |
|
|
| | | | Multiplexing 50 + |
|
|
| | | | ZZ : Order in ordered Outqueue |
|
|
+---------+---------------------+-----------------------------------------+
|
|
|
|
|
|
I-Point Errorcodes (in DestZZ)
|
|
------------------------------
|
|
|
|
Errorcodes handled (displayed) on the PLC
|
|
|
|
- 90 : Bad Weight (weightcheck active)
|
|
- 91 : Article not defined in articlemaster
|
|
- 92 : No place in storage
|
|
- 93 : Lotcheck failed (FIFO error)
|
|
- 94 : Box already in system
|
|
- 99 : Invalid BoxNr
|
|
|
|
Return Codes
|
|
------------
|
|
|
|
Transport specific Codes extenging the overall valid Codes
|
|
|
|
- 20 : Invalid source (main or finesource) in Transport
|
|
- 30 : Invalid destination (main or finedest) in Transport
|
|
- 5x : RFZx Occupied - Transport will be resent later
|
|
|
|
"""
|
|
__date__ = "2006/02/15"
|
|
__email__ = "michi@rosstein.de"
|
|
__version__ = "$Revision: 1.1 $"[11:-2]
|
|
|
|
|
|
from telegram import TELEGRAM, TEL_TAUF
|
|
from utility import *
|
|
|
|
# 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 TAUF from the given
|
|
parameter and note the data in the instance of the object.
|
|
|
|
Parameters:
|
|
data: The binary form of the TELEGRAM
|
|
"""
|
|
tel = TEL_TAUF ()
|
|
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['state'] = (ord (data [10]) << 8) + ord (data [11])
|
|
return tel
|
|
|
|
|
|
class TEL_TAUF (TELEGRAM):
|
|
def __init__ (self, nr = 0, src = 'LV', dst = 'TP', boxnr = 20 * ['0'], position = 'XXXX', source = 'XXXX', srcx = 'XX', srcy = 'YY', srcz = 'ZZ', dest = 'DDDD', destx = 'XX', desty = 'YY',destz = 'ZZ', *args, **args2):
|
|
TELEGRAM.__init__(self)
|
|
self.code = TEL_TAUF
|
|
self.data = ''
|
|
self.attrib['nr'] = nr
|
|
self.attrib['src'] = str (src)
|
|
self.attrib['dst'] = str (dst)
|
|
self.attrib['type'] = 'TAUF'
|
|
self.attrib['boxnr'] = str (boxnr)
|
|
self.attrib['position'] = str (position)
|
|
self.attrib['source'] = str (source)
|
|
self.attrib['srcx'] = str (srcx)
|
|
self.attrib['srcy'] = str (srcy)
|
|
self.attrib['srcz'] = str (srcz)
|
|
self.attrib['dest'] = str (dest)
|
|
self.attrib['destx'] = str (destx)
|
|
self.attrib['desty'] = str (desty)
|
|
self.attrib['destz'] = str (destz)
|
|
|
|
self.__buildstring ()
|
|
self.__recalclen ()
|
|
return
|
|
|
|
def identify (self):
|
|
"""
|
|
This method can be used to identify a TELEGRAM by string.
|
|
"""
|
|
return "TAUF TELEGRAM\n"
|
|
|
|
def __buildstring (self):
|
|
"""
|
|
Creates Datastring from Attributes
|
|
chr (len (str (self.attrib['boxnr']))) +\
|
|
"""
|
|
self.data = chr ((self.attrib['nr'] >> 8) & 0xFF) + chr (self.attrib['nr'] & 0xFF) +\
|
|
self.attrib['src'] +\
|
|
self.attrib['dst'] +\
|
|
self.attrib['type'] +\
|
|
chr (10) +\
|
|
chr (10) +\
|
|
fillchar (str (self.attrib['boxnr']), 10) +\
|
|
self.attrib['position'] +\
|
|
self.attrib['source'] +\
|
|
doublechar (self.attrib['srcx']) +\
|
|
doublechar (self.attrib['srcy']) +\
|
|
doublechar (self.attrib['srcz']) +\
|
|
self.attrib['dest'] +\
|
|
doublechar (self.attrib['destx']) +\
|
|
doublechar (self.attrib['desty']) +\
|
|
doublechar (self.attrib['destz'])
|
|
|
|
|
|
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.
|
|
"""
|
|
string = self.identify () #+ DT_STRING % (self.len, self.number, self.data)
|
|
return string
|