Hello everyone,

I am new to Ignition/Scripting so any help extended would be greatly appreciated!

The complete cycle time on a part consists of 8 individual cuts. I am trying to calculate the cycle times for each of these 8 cuts and then historize them.

The resources I have been given are:

- Current_cut tag that updates for each of the 8 cuts. This tag contains the cut times in Hr:Min:Sec for each cut. The issue is that it constantly updates and does not tell you which of these 8 cuts it is on currently.
- Cut_status tag that ranges from 0-7. This tells me which of the 8 cuts are currently running.

I have attempted to use a tag event script to write the cut times to memory tags that I have created based on the Cut_Status. However, I have found that this only writes once, when the tag value changes even though I put a loop in there to write continuously(*code only show the if statements).

Here is the code that I wrote:

status = currentValue.value

sec = system.readBlocking([â€ś[.]â€¦/Springer/BUI_Cycle_Data_0_/Cut_Cycle_Time_Secsâ€ť])[0].value

min = system.readBlocking([â€ś[.]â€¦/Springer/BUI_Cycle_Data_0_/Cut_Cycle_Time_Minsâ€ť])[0].value

hr = system.readBlocking([â€ś[.]â€¦/Springer/BUI_Cycle_Data_0_/Cut_Cycle_Time_Hoursâ€ť])[0].value

```
if status == 0:
system.writeBlocking(["[.]../Cut_Times/Rough_Wing_Suction/Sec"],[sec])
system.writeBlocking(["[.]../Cut_Times/Rough_Wing_Suction/Min"],[min])
system.writeBlocking(["[.]../Cut_Times/Rough_Wing_Suction/Hr"],[hr])
if status == 1:
system.writeBlocking(["[.]../Cut_Times/Rough_Long_Suction/Sec"],[sec])
system.writeBlocking(["[.]../Cut_Times/Rough_Long_Suction/Min"],[min])
system.writeBlocking(["[.]../Cut_Times/Rough_Long_Suction/Hr"],[hr])
if status == 2:
system.writeBlocking(["[.]../Cut_Times/Finish_Wing_Suction/Sec"],[sec])
system.writeBlocking(["[.]../Cut_Times/Finish_Wing_Suction/Min"],[min])
system.writeBlocking(["[.]../Cut_Times/Finish_Wing_Suction/Hr"],[hr])
if status == 3:
system.writeBlocking(["[.]../Cut_Times/Finish_Long_Suction/Sec"],[sec])
system.writeBlocking(["[.]../Cut_Times/Finish_Long_Suction/Min"],[min])
system.writeBlocking(["[.]../Cut_Times/Finish_Long_Suction/Hr"],[hr])
if status == 4:
system.writeBlocking(["[.]../Cut_Times/Rough_Wing_Pressure/Sec"],[sec])
system.writeBlocking(["[.]../Cut_Times/Rough_Wing_Pressure/Min"],[min])
system.writeBlocking(["[.]../Cut_Times/Rough_Wing_Pressure/Hr"],[hr])
if status == 5:
system.writeBlocking(["[.]../Cut_Times/Rough_Long_Pressure/Sec"],[sec])
system.writeBlocking(["[.]../Cut_Times/Rough_Long_Pressure/Min"],[min])
system.writeBlocking(["[.]../Cut_Times/Rough_Long_Pressure/Hr"],[hr])
if status == 6:
system.writeBlocking(["[.]../Cut_Times/Finish_Wing_Pressure/Sec"],[sec])
system.writeBlocking(["[.]../Cut_Times/Finish_Wing_Pressure/Min"],[min])
system.writeBlocking(["[.]../Cut_Times/Finish_Wing_Pressure/Hr"],[hr])
if status == 7:
system.writeBlocking(["[.]../Cut_Times/Finish_Long_Pressure/Sec"],[sec])
system.writeBlocking(["[.]../Cut_Times/Finish_Long_Pressure/Min"],[min])
system.writeBlocking(["[.]../Cut_Times/Finish_Long_Pressure/Hr"],[hr])
else:
print("Unable to calculate values")
```

My questions are:

- Is this the correct approach?
- Is there a simpler way to do this?
- The script only writes once - when the value changes. How can I constantly write to the tag as long as the â€śIf conditionâ€ť is true?

Thank you!