BNA8/.resources/095df32214e4ed335924cca80d6213ca400031b135cca9eb5d86fd6a2bf50235

63 lines
2.3 KiB
Plaintext

################################################################
################################################################
## Version: 1.0 / Author: Dillon Uzar
##
## DESC: For use in WCS Sorting Lane Lookup & Recording
## WARN: Modifying code may cause system to function incorrectly
################################################################
################################################################
import time
#######################################################
#######################################################
#######################################################
#### Constants
#######################################################
# Logger:
LOG = system.util.logger("GL BreakCount Handler")
# For inserting data into database:
CONFIRM_INSERT_QUERY = "INSERT IGNORE INTO gl_history (gaylord_id,count) VALUES (?,?)"
#######################################################
#######################################################
#######################################################
#### Parsing Utils
#######################################################
def logTime(title, trackID, seconds):
millisec = round(seconds * 1000, 1)
if millisec > 4:
LOG.info("%s[ID=%s] took longer than expected (%sms to process)" % (title, trackID, millisec))
#######################################################
#######################################################
#######################################################
#### PLC Event Handling
#######################################################
def processBreak(gaylordID, count):
# This function handles confirm events, and logs the event in SQL
# Ensure ID is valid
if count > 0:
start_time = time.time()
# Log confirm event in SQL:
# Insert into Package History:
system.db.runPrepUpdate(CONFIRM_INSERT_QUERY, [gaylordID, count])
logTime("GL_BREAK[DB_INSERT]", gaylordID, time.time() - start_time)
def processBreakAsync(gaylordID, count):
# This function handles confirm events, and logs the event in SQL
# Ensure ID is valid
if count > 0:
def processConfirmInner():
start_time = time.time()
# Log confirm event in SQL:
# Insert into Package History:
system.db.runPrepUpdate(CONFIRM_INSERT_QUERY, [gaylordID, count])
logTime("GL_BREAK[DB_INSERT]", gaylordID, time.time() - start_time)
system.util.invokeAsynchronous(processConfirmInner)