Hello all, I am somewhat ne w to ignition and am having trouble getting a gateway script to work correctly. I wrote and tested the script in the script console where it worked fine. I then copied and pasted the script into a function, then called the function from a gateway timer script. When this evaluates in the gateway script, the script returns different results then when run in the script console.
Basically I am reading in strings from a PLC tag. One set of string tags is populated by a P&F RFID read into an Allen Bradley PLC. These are referenced to in the logs and script as "on arm" tags or STAT tags. The second set of tags is written from ignition to the PLC earlier inthe process, then I read them back for a quick comparision to see if any of the informtion has been updated. In the logs and scripting they are refered to as "in database" or CMD tags.
When the gateway script runs, the tags generated from the RFID read all have multiple question marks after the data as shown in the Wrapper log attached. in the code also shown below, you can see that I have attempted 3 different methods manipulating this informtion on the read including stripping the extra characters as a seperate step. Unfortunatly this does not work and causes by compares to evaluate incorrectly.
Can anyone tell me why these extra characters show up in the gateway execution and not the script console execution? More importantly can anyone tell me how to get rid of the extra characters?
Below you should find the ignition code running, an except from the wrapper log showing one evaluation of the code and an except from the gateway log showing a different evaluation of the same code for the same event.
Thanks in advance.
STAT_RFID = system.tag.read("[default]" + ASRS + "/ASRS_SystemCMD/STAT_MoldData/RFID").value
log.info("RFID on arm = " + str(STAT_RFID))
STAT_PartNumber = str(system.tag.read("[default]" + ASRS + "/ASRS_SystemCMD/STAT_MoldData/PartNumber").value)
log.info("Part number on arm = " + str(STAT_PartNumber))
STAT_JobNumber = str(system.tag.read("[default]" + ASRS + "/ASRS_SystemCMD/STAT_MoldData/JobNumber").value)
STAT_JobNumber = STAT_JobNumber.rstrip("?")
log.info("Job number on arm = " + str(STAT_JobNumber))
STAT_SpecialLotNumber = system.tag.read("[default]" + ASRS + "/ASRS_SystemCMD/STAT_MoldData/SpecialLotNumber").value.rstrip("?")
log.info("Special lot number on arm = " + str(STAT_SpecialLotNumber))
log.info("")
CMD_RFID = system.tag.read("[default]" + ASRS + "/ASRS_SystemCMD/CMD_MoldData/RFID").value
log.info("RFID in database = " + str(CMD_RFID))
CMD_PartNumber = system.tag.read("[default]" + ASRS + "/ASRS_SystemCMD/CMD_MoldData/PartNumber").value
log.info("Part number in datasbase = " + str(CMD_PartNumber))
CMD_JobNumber = system.tag.read("[default]" + ASRS + "/ASRS_SystemCMD/CMD_MoldData/JobNumber").value
log.info("Job number in datasbase = " + str(CMD_JobNumber))
CMD_SpecialLotNumber = system.tag.read("[default]" + ASRS + "/ASRS_SystemCMD/CMD_MoldData/SpecialLotNumber").value
log.info("Special lot number in datasbase = " + str(CMD_SpecialLotNumber))
log.info("")
write = 0
if STAT_RFID == CMD_RFID:
if STAT_PartNumber != CMD_PartNumber:
write = 1
if STAT_JobNumber != CMD_JobNumber:
write = 1
if STAT_SpecialLotNumber != CMD_SpecialLotNumber:
write = 1
#print "Write = " + str(write)
if write == 1:
if len(CMD_SpecialLotNumber) == 0:
#system.tag.writeBlocking(["[default]" + ASRS + "/ASRS_SystemCMD/CMD_MoldData/SpecialDipProfile"],[0])
log.info("Special dip profile = 0")
else:
#system.tag.writeBlocking(["[default]" + ASRS + "/ASRS_SystemCMD/CMD_MoldData/SpecialDipProfile"],[-1])
log.info("Special dip profile = -1")
#system.tag.writeBlocking(["[default]" + ASRS + "/ASRS_SystemCMD/CMD_RFID_Write"],[1])
log.info("Updating RFID tag")
else:
log.info("RFID tag update not required")
else:
log.info("Mold RFID does not match expected RFID")