I have a situation where I have an OPC tag that I am reading in, however if a certain condition happens, lets just say a boolean tag, I dont want to update the tag from the plc, instead I want to keep the tag value the same until the condition reverses.
Essentially I want to do the following:
IF NOT Condition:
read in OPC tag and update via PLC
ELSE:
dont update the tag and keep the value at its last value
I wasn't sure if there was an easy built in way to do this.
I'd leave this one as is and add another tag that would update based on your condition.
I'm not sure if you can do that with derived or reference tag, you may need an expression tag instead, but I don't have time right now to try and figure this out
Can you clarify something? It sounds like you want to only read an OPC tag when a different tag value = true?
This can be accomplished pretty easily via scripting. Setup a Tag Change script for your boolean variable that you want to monitor and then call system.opc.readValues
to read the other OPC tags that you're interested in.
Something like this:
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
if currentValue:
system.opc.readValues(*opcServer*, *itemPaths*)
Where itemPaths are the OPC tags you want to grab.
This is correct...only read/update the value when a different OPC tag is true. I thought about doing something like that. Would the example you have above mean that once the condition is met where I want to update the value from the plc that it will be done consistently after the condition change happens, in other words would it just happen the one time when the change occurs or would the tag consistently be updated after the tag change happens and the condition to update the tags is met?
The Tag Change script will run once when the value of the tag your are "monitoring" changes (from True --> False or False --> True).
So in that example, the OPC tags are read once when the monitoring tag = true. To then to re-read your OPC tags a second time, you would need the tag to turn false, and then true again.