Hey All,
I have a furnace which takes in 572 tags of operator controlled data from the HMI. The glass stages on the load conveyor and every 30 seconds or longer it gets called into the furnace with an index tag. I am using that tags value changed event to fire a trigger script. In the trigger script I am setting a memory tag to the value of 1 then setting it back to 0. The memory tag is called record_x and it is incremented each time it is called and resets back to 0 once it reaches 9.
Inside the record_x script I am opening a file, looping through the tags and values and writing them to the file_x then closing the file pulling another file from a different machine and adding both files to a main storage file. The other machine gives me the curvature / quality of the glass. So I like to keep the beds separated and that file attached to the bottom of the tag value / record_x code results.
The issue I am having is after 3 record_x scripts trigger and running on top of each other my ignition server practically shuts down. I am running a dual core 2.5 ghz 8gb ram CPU and I believe this is where my problem lies. If I don’t bog the system down the coding performs flawlessly, but all of this entire operation may be inefficient. Looking for wisdom / please enlighten me.
Below is my recording_x script:
# only execute when triggered
if (currentValue.value == 1):
# import required libraries
import os
import time
import sys
# Initialize Some Used Variables
heat_quench_time = system.tag.read("[.]Heat_Quench_Time").value
max_file_size = system.tag.read("[.]Max_File_Size_Ctr").value
total_time_divided = heat_quench_time / 2
file_name_ctr = system.tag.read("[.]File_Name_Ctr").value
tag_names = (["572 tags"])
tag_values = []
tag_name_ctr = 0
file_open = open("C:\\GlassTech_Recording\\Temporary_Recordings\\Temp_Storage" + str(file_name_ctr) + ".txt", 'w')
# for range of total divided sleep 1 and write every second
for sec in range(total_time_divided):
time.sleep(1)
# while inside total time divided loop
# loop through all of tag_read_all_values and write to file_open
for tag_value in tag_read_all_values:
tag_values = tag_value.value
file_open.write("%s = %s\n" % (tag_names[tag_name_ctr], tag_values))
tag_name_ctr += 1
# inside of nested for loop check ctr
if (tag_name_ctr >= 573):
tag_name_ctr = 0
time.sleep(0)
tag_name_ctr = 0
file_open.close()