In order to print labels for my production environment, I have used a server based print program (Label Matrix) that takes data from a table and can print a label to a networked printer. In order to accomplish this with Ignition I use a Gateway Event to open up a batch file. The batch file contains the print file (.qdf) I want and it invokes the print program to print the specific file.
Here is the Gateway Event script, triggered by the REPRINT_PALLET tag. The GWay_yes tag gives me a signal that the script completed successfully.
if currentValue.value == True:
path = "C:\LMP\EXTR2_PALL.bat"
import subprocess as sp
sp.call([path], shell=True)
system.tag.writeBlocking(['[default]PRECURE/GwayYes'], [True])
else:
system.tag.writeBlocking(['[default]PRECURE/EXTRE/REPRINT_PALLET'], [False])
system.tag.writeBlocking(['[default]PRECURE/EXTRE/REPRINT_PALLET'], [False])
This has successfully printed a label. Here's the batch file:
cd "C:\Program Files (x86)\LABEL MATRIX 2021"
LMWPRINT /L="C:\LMP\EXTR2_X.qdf"
exit
My problem occurs if for whatever reason (printer is down, print program issue, database table design changed) the Gateway Event does not produce a label. It appears that the Ignition Gateway is expecting something from the server and not getting it. I can run the batch file by opening it from the File Explorer after the system seems to have frozen up and it will run and print a label. I have restarted the Ignition Gateway but that did not clear up the problem.
The only way to clear up the no-print problem is to reboot the server. This is not a viable option for production. My question: is there something I can add to the sp.call procedure so that the Gateway Event can be run again even if the printer is temporarily down, or is there something in the batch file I could add to give the Ignition Gateway the "all clear" even if a label was not produced?