Within a gateway event script I want to write a value to a tag after some other events have completed. Currently having some problems with the timing. I would like to try the system.util.invokeLater function, but receive an attribute error in the console stating the object has no attribute ‘invokeLater’. Any ideas?
[code] def reset():
import system
system.tag.write("Conveyor\Carrier",0)
system.util.invokeLater(reset)[/code]
The system.util.invokeLater function doesn’t exist in the Gateway scope. It has nothing to do with Gateway events. You are not able to use the system.util.invokeLater function in a Gateway Event Script.
The system.util.invokeLater only works with GUI events. Since the Gateway scope has no GUI there is no place for this function in this scope.
This is running on a gateway tag change script. The problem I am having is after the order is completed and is deleted from the table the next tag change still writes the non-existent order to tags. It isn’t until after the second tag change following the order completion that it moves to the next order.
[code]import system
if newValue.value == 1:
#Get next order data
model = system.db.runScalarQuery("SELECT MODEL FROM tblSequence WHERE SortOrder = 1")
orderNumber = system.db.runScalarQuery("SELECT ORDER_NUMBER FROM tblSequence WHERE SortOrder = 1")
sn = system.db.runScalarQuery("SELECT SERIAL_NUMBER FROM tblSequence WHERE SortOrder = 1")
gs = system.db.runScalarQuery("SELECT SEQUENCE_NUMBER FROM tblSequence WHERE SortOrder = 1")
baseMachine = system.db.runScalarQuery("SELECT BASE_MACHINE FROM tblSequence WHERE SortOrder = 1")
description = system.db.runScalarQuery("SELECT MATERIAL_DESCRIPT FROM tblSequence WHERE SortOrder = 1")
#Count carriers within order
carrier = system.tag.read("Conveyor\Carrier").value
count = carrier + 1
totalCarrier = system.db.runScalarQuery("SELECT TOP 1 CARRIER FROM tblLoadUnloadData WHERE MODEL = '%s' ORDER BY CARRIER DESC" % model)
#Get load and unload stations for current carrier within order
load = system.db.runScalarQuery("SELECT LOAD_POINT FROM tblLoadUnloadData WHERE MODEL = '%s' AND CARRIER = %d" % (model, count))
unload1 = system.db.runScalarQuery("SELECT UNLOAD_POINT_1 FROM tblLoadUnloadData WHERE MODEL = '%s' AND CARRIER = %d" % (model, count))
unload2 = system.db.runScalarQuery("SELECT UNLOAD_POINT_2 FROM tblLoadUnloadData WHERE MODEL = '%s' AND CARRIER = %d" % (model, count))
loadDescription = system.db.runScalarQuery("SELECT DESCRIPTION FROM tblLoadUnloadData WHERE MODEL = '%s' AND CARRIER = %d" % (model, count))
#Write carrier data to PLC for carrier at Stop 43
system.tag.write("Conveyor\Model",model)
system.tag.write("Conveyor\Load_Point",load)
system.tag.write("Conveyor\Unload_Point_1",unload1)
system.tag.write("Conveyor\Unload_Point_2",unload2)
system.tag.write("Conveyor\Serial_Number",sn)
system.tag.write("Conveyor\Grand_Sequence",gs)
system.tag.write("Conveyor\Total_Carriers",totalCarrier)
system.tag.write("Conveyor\Order_Number",orderNumber)
system.tag.write("Conveyor\Base_Code",baseMachine)
system.tag.write("Conveyor\Description",description)
system.tag.write("Conveyor\Load_Description",loadDescription)
#When all carriers associated with an order are processed move to next order
if carrier >= totalCarrier:
system.tag.write("Conveyor\Carrier",0)
system.db.runPrepUpdate("DELETE FROM tblSequence WHERE ORDER_NUMBER = ?", [orderNumber])
system.db.runPrepUpdate("UPDATE tblSequence SET SortOrder = SortOrder - 1")
else:
system.tag.write("Conveyor\Carrier",count)[/code]