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

174 lines
7.3 KiB
Python

from time import time
class SCLS:
def scls (self, ret_val):
DB_con = self.connections['DB']
# SCLS Telegram --> act according to Read position
if ret_val ['location'] == 'IPKT':
#IKPT
self.log ( "SCLS at IPKT box %(box_nr)s destiation %(destination)d" % ret_val)
elif ret_val ['location'] in ['RFZ1', 'RFZ2']:
#FiXMe
_quit = 0
#RFZ
_dz = 0
self.log ( "SCLS at %(location)s box %(box_nr)s destiation %(destination)d" % ret_val)
self.message (6, "SCLS at %(location)s box %(box_nr)s destiation %(destination)d" % ret_val)
if ret_val ['destination'] == 0:
#Destination 0 - Box from Pickup Position loaded --> get TAUF
self.message (3, ' DT_handler : SCLS from %s (Box from Pickuppos) --> generate TAUF for RFZ' % ret_val ['location'])
_box = None
sboxnr = int (ret_val['box_nr'])
if sboxnr != 0:
#No NOREAD
_boxes = DB_con.getincomingbox (sboxnr)
if _boxes and len(_boxes):
_box = _boxes [0]
if _box:
self.message (3, ' DT_handler : SCLS Box is in Inqueue search a Place')
_boxes = DB_con.searchbox (sboxnr)
storage = 'NONE'
if _boxes:
self.message (6, ' DT_handler : SCLS Box is already in Storage further checks')
for _rid, _rboxnr, _rarticle, _rlotnr, _rlotnr2, _duedate, _rpieces, _rx, _ry, _rz, _rrfzts in _boxes:
if _rrfzts:
self.log ( " DT_handler : SCLS Box %s is already inserted in Storage %s" % (sboxnr, _rid))
print ("Already in Storage impossible")
raise Warning
else:
self.message (6, " DT_handler : SCLS Box is only reserved in %s" % _rid)
#Just reserved
if len (_boxes) == 1:
self.message (6, " DT_handler : SCLS Box is only reserved (one time) in %s" % _rid)
DB_con.removebox (_rid , sboxnr)
DB_con.deletealltransports (sboxnr)
location, boxnr, article, gtin, lotnr, lotnr2, duedate, pieces, deststorage, destination = _box
#Fixme Zone from Articlebase
_zone = 1
_res = 0
for storage, rfzNr, rfzOut, mode, prio in self.transportmatrix['dstbysrc'][location]:
#Normal article
if (storage == deststorage):
self.message (6, " DT_handler : SCLSTransport for Std Article to %s by RFZ %s with prio %s" % (storage, rfzNr, prio))
_res = self.boxreserve ('RFZ%s' % rfzNr, location, 0, 0, 0, \
boxnr, article, lotnr, lotnr2, duedate, pieces, storage, _zone, noreserve = 0)
if not _res:
print ("Kann nicht sein dass kein Platz ist")
raise Warning
self.generatetransport (ret_val['location'], sboxnr)
else:
print ("Scheisse")
raise Warning
#Box is not in Inqueue
self.log ( "At %(location)s: box %(box_nr)s is not in Inqueue --> try to find Transport or generate Errorslot" % ret_val)
if ret_val ['location'] in self.transportmatrix['errordst']:
_dst, _dstx, _dsty, _prio = self.transportmatrix['errordst'][ret_val ['location']]
DB_con.createtransport (ret_val['box_nr'], ret_val['location'], 'IRFZ', 0, 0, 0, _dst, _dstx, _dsty, 0)
self.generatetransport (ret_val['location'], ret_val['box_nr'])
else:
self.log ( "At %(location)s: Nor Errordestination for this Position - send Takeoff Transport" % ret_val)
DB_con.createtransport (ret_val['box_nr'], ret_val['location'], 'IRFZ', 0, 0, 0, ret_val['location'], 0, 0, 1)
self.generatetransport (ret_val['location'], ret_val['box_nr'])
elif ret_val ['destination'] == 2:
self.message (3, ' DT_handler : SCLS from RFZ1 --> deletebox')
self.log ( "SCLS at RFZ1 box %(box_nr)s destiation %(destination)d" % ret_val)
# Make sure that manual intervention gets rid of the box also
article = None
box = None
if _storage_type != 4:
box = DB_con.searchbox (ret_val['box_nr'], 'Puffer')
if box:
self.removebox ('Puffer', ret_val['box_nr'])
article = box[1]
# space is available
# NewPRIO
#if article:
# self.checkspaceandmove (article)
elif ret_val ['location'] == 'HBCL1':
_quit = 0
self.message (3, ' DT_handler : SCLS from HBCL1 --> delete Boxes from Storage')
self.log ( "SCLS at HBCL1 box %(box_nr)s destination %(destination)d " % ret_val)
try:
_boxnr = int (ret_val['box_nr'])
_dest = ret_val['destination']
if int (_dest) > 0:
DB_con.deletetauf ('DEST', _boxnr)
self.createtauf (_boxnr, 'DEST', 'MDES', 0, 0, 0, 'Puffer', 0, 0, _dest)
self.generatetauf ('DEST', _boxnr)
DB_con.deletetauf ('DEST', _boxnr)
except:
_dest = 0
print ('Shit')
raise Warning
# Make sure that manual intervention gets rid of the box also
article = None
box = None
if _storage_type != 4:
box = DB_con.searchbox (ret_val['box_nr'], 'Puffer')
if box:
self.removebox ('Puffer', ret_val['box_nr'])
article = box[1]
if not box:
box = DB_con.searchbox (ret_val['box_nr'], 'Pick')
if box: #DANI return war scheie wg. counter zaehlung
self.log ( "SCLS at HBCL1 box %(box_nr)s was in Pick %(destination)d " % ret_val)
self.removebox ('Pick', ret_val['box_nr'])
article = box[1]
if not box:
box = DB_con.searchbox (ret_val['box_nr'], 'ENESPi')
if box:
self.removebox ('ENESPi' , ret_val['box_nr'])
elif ret_val ['location'] in ['B004', 'B006']:
self.log ("SCLS at %(location)s for box %(box_nr)s with destination %(destination)d Delete from Outqueue" % ret_val)
deletedz = DB_con.removebox ('Outqueue', int (ret_val['box_nr']))
_waitinjection = 0
DB_con.createtransport (int (ret_val['box_nr']), _pusher, _pusher, 0, 0, 0, _pusher, 0, _waitinjection, 0)
self.generatetransport (_pusher, int (ret_val['box_nr']))
_quit = 0
elif ret_val ['location'] in ['B005', 'B007', 'H001', 'H002']:
deletedz = DB_con.removebox ('Outqueue', int (ret_val['box_nr']))
self.log ( "SCLS at %(location)s for box %(box_nr)s with destination %(destination)d Sending TAUF to indicate new Box" % ret_val)
if ret_val ['location'] in ['B005', 'H002']:
_opoint = 'O001'
elif ret_val ['location'] in ['B007', 'H001']:
_opoint = 'O002'
if self.parameter.get ('triggerbox-%s' % _opoint, -1) == int (ret_val['box_nr']):
self.message (3, "SCLS resetting triggerbox for %s" % _opoint)
self.parameter['triggerbox-%s' % _opoint] = 0
elif ret_val ['location'][0] == 'B':
self.log ( "SCLS at %(location)s for box %(box_nr)s with destination %(destination)d " % ret_val)
_quit = 0
elif ret_val ['location'][0] == 'H':
self.log ( "SCLS at %(location)s for box %(box_nr)s with destination %(destination)d " % ret_val)
_quit = 0
else:
self.log ( "SCLS at undefined postion %(location)s for box %(box_nr)s with destination %(destination)d " % ret_val)
_quit = 20
#Return Value for Quit telegram
return _quit