Yea I did see it had to be a list. I am pretty sure I have everything correct but still not working.
Backend tag event script is creating the call of the messagehandler on the frontend.
Frontend project is called ‘PW_BladeSide’, frontend gateway is ‘Ignition-BladeSide-Frontend’.
When cycle_complete bit goes high it builds the call and then sends out the message.
Here is revised code for tag event script:
The gateway message handler on the frontend is:
It is supposed to call ReportControl script in the frontend gateway scripting and execute code that creates a folder if one is not already created, save the report as a pdf and save it in that folder, and also print the report out. It is not even creating the folder.
Here is the code within ReportControl. I know this part of the code works when I was able to do it without using a messagehandler:
def create_report_folders():
"""Create report folders if they do not exist."""
import os
base_dir = 'C:\Reports'
dirs = [base_dir]
for furnace_number in ['548642', '548643', '548644', '548645', '548646', '548647']:
dirs.append('{}\BT{}'.format(base_dir, furnace_number))
for dir in dirs:
if not os.path.isdir(dir):
os.mkdir(dir)
def create_report(furnace_brass_tag_num, command='save'):
"""Generate report for furnace.
Params:
furnace_brass_tag_num (str): Brass tag number of furnace
command (str): One of 'save' or 'print'
"""
furnace_cycle_id = system.tag.read('[BladesideSR]BS/FurnaceBT{}/Recipe/Lots/furnace_cycle_id'.format(furnace_brass_tag_num)).value
params = {'FurnaceCycleID': furnace_cycle_id}
if command == 'save':
create_report_folders()
date = system.date.format(system.date.now(), 'yyyy-MM-dd HH-mm-ss')
filename = 'BT{} {}.pdf'.format(furnace_brass_tag_num, date)
path = 'C:\Reports\BT{}'.format(furnace_brass_tag_num)
settings = {'path': path, 'fileName': filename, 'format': 'pdf'}
system.report.executeAndDistribute(path='FurnaceCycle', parameters=params, action='save', actionSettings=settings)
elif command == 'print':
settings = {'primaryPrinterName': 'HP LaserJet M608 [847294]', 'backupPrinterName': 'none', 'copies': 1, 'printBothSides': True,
'collate': True, 'useRaster': False, 'rasterDPI': 1200, 'useAutoLandscape': False, 'pageOrientation': 'portrait'}
system.report.executeAndDistribute(path='FurnaceCycle', parameters=params, action='print', actionSettings=settings)
I am not getting to do anything yet so far…is there anything obvious I am doing wrong as to why its not working?
Also BrassTagNum is a string parameter within the UDT.