Hello, I'm gonna start out by saying i have have little to no scripting experience.
The issue we have is with a sand mixing system that has editable values for the operator, the value in question is for the sand compactibility setpoint, this usually is a static value of 52 but moving into the winter months this value needs to be manually adjusted throughout the day to keep everything happy.
The problem shows up between shifts when the operators forget to change the value back to 52 from whatever the value was at mid day, causing compactibility to be out of range for start up.
This is a very old modicon system, i cant readily just use a move block in the program to write 52 into the holding register based on system values.
End goal is to change the value of the compactibility setpoint OPC tag based on the time of day, I've created a "time" expression tag that gives a value of 1,100 for 11am, 1,330 for 1:30pm ect.
I just want 52 to be written to my OPC tag at 8PM, how can i accomplish this?
Thank you, the gateway scheduled event is what i wanted to use with this as it will need to work across multiple open projects.
The issue I'm having is my lack of scripting experience, I've gotten by with basic expressions over the last few months, but everything i write seems to have errors as show below now. I'm not quite sure how exactly this code would need to be written to be correct.
Note the use of [lists] for tagnames and values being passed.
One reason that your first scheduled script couldn't have worked is that Python / Jython wouldn't have a clue what to do with [default]UNIT3/AR40502-3. It might look like a tag path to you but not to the interpreter.
Or, since there is only one tag and value, system.tag.writeBlocking(['[default]testingscheduledscript'], [52])
You can get away without the [ ] list brackets when there is only one element but, as far as I know, it's undocumented and could change in future. Just write them as lists.
I appreciate everyone who's contributed to helping me with this, i can see now how i was trying to approach this earlier wasn't going to work, given the examples you've provided and what's outlined in the Docs link i feel i have something now that should work. I have to be missing some critical step somewhere? Both attempts shown below failed to change the value.
Transistior -
I've been trying to test it by setting the time 4mins out from system time, and waiting to see a change.
There are no other scripts/bindings or alarms with this tag, the tag is tied to a numeric text field in two separate projects, one project will be open at multiple locations in the facility.
amarks -
The issue with the shift change is more of a we cant count on people to adjust this value before startup and fill all our our machines with mud.
dkhayes117 -
You're definitely on to something here, i have no scripts listed under any of the tabs on the gateway (the script in question would be the only existing script we have).
What would cause this script to not actually make it to the gateway?
Turns out it was my fault it wasn't showing up or running, i was trying to test it before making it permanent and i hadn't saved the project, once i saved the project the script showed up where it should be. I have it set to try and change the value here in a few minuets.
A little extra information on this. These scripts live and execute on the gateway, so they have gateway scoping. Therefore, they don't exist on the gateway until the project is saved.
Best practice is to create project scripts and call those in the gateway events due to legacy scoping weirdness. I.E. it's best not to write your logic in the event itself.