In my gateway tag change script, I have a if condition to turn a external indicator on and off, however, I found that the indicator tag will be off after sometimes when it being turn on. The indicator tag cannot hold the on staus for too long, it will be written to 0 ( off) after sometimes, please help to see where I may do wrong.
gateway script:
Please post code - not pictures of code - so we can copy and edit in our answers. Use the </> code formatting button to preserve indents and syntax highlighting.
writeBlocking expects a LIST of tags and a LIST of values to go with those tags. You need to wrap your values in square brackets like you did for the tags paths.
Frankly I'd expect this to not work at all. Check your logs for errors, I'm sure you'll find clues there.
Also, what is IAPI/Missions/MissionSubscriber0/MissionState !=4 ?
Unless this is defined in your project library (but that path says it's not), it will also raise an error as it's not defined anywhere in this script's scope.
hello, after I wrap the values in square brackets and delete the IAPI/Missions/MissionSubscriber0/MissionState !=4, i still have the issue that "Banner/_Banner_/UnitId 1/1_Banner17-1_Banner48/1_Banner46" will switch to 0 after sometimes. This problem raise no error in the log right now.
Similarily, I running into same issue with other scripts that write in the tag Editor.
Basically, when a MissionState equals to 4, it will trigger the LED tag to 2048 to flashing red, however, the value of 2048 can't hold for too long (while MissionState =4) in "Banner/_Banner_/UnitId 1/1_Banner17-1_Banner48/1_Banner46" . I wrote a value changed script in Mission Sate tag editor:
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
if currentValue.value==4:
system.tag.writeBlocking(["[default]Banner/_Banner_/UnitId 1/1_Banner17-1_Banner48/1_Banner46"], [2048])
if currentValue.value!=4:
system.tag.writeBlocking(["[default]Banner/_Banner_/UnitId 1/1_Banner17-1_Banner48/1_Banner46"], [0])
In the log, i got the following error: Error writing tags Error writing to tag '[default]IAPI/Missions/MissionSubscriber0/WatchMissionID': Bad("Bad_DataUnavailable: Expected data is unavailable for the requested time range due to an un-mounted volume.")
hello, after I wrap the values in square brackets and delete the IAPI/Missions/MissionSubscriber0/MissionState !=4, i still have the issue that "Banner/_Banner_/UnitId 1/1_Banner17-1_Banner48/1_Banner46" will switch to 0 after sometimes. This problem raise no error in the log right now.
Similarily, I running into same issue with other scripts that write in the tag Editor.
Basically, when a MissionState equals to 4, it will trigger the LED tag to 2048 to flashing red, however, the value of 2048 can't hold for too long in the tag: "Banner/_Banner_/UnitId 1/1_Banner17-1_Banner48/1_Banner46" . I wrote a value changed script in Mission Sate tag editor:
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
if currentValue.value==4:
system.tag.writeBlocking(["[default]Banner/_Banner_/UnitId 1/1_Banner17-1_Banner48/1_Banner46"], [2048])
if currentValue.value!=4:
system.tag.writeBlocking(["[default]Banner/_Banner_/UnitId 1/1_Banner17-1_Banner48/1_Banner46"], [0])
In the log, i got the following error: Error writing tags Error writing to tag '[default]IAPI/Missions/MissionSubscriber0/WatchMissionID': Bad("Bad_DataUnavailable: Expected data is unavailable for the requested time range due to an un-mounted volume.")
You should call into support and let them look over your shoulder.
This:
Error writing tags Error writing to tag '[default]IAPI/Missions/MissionSubscriber0/WatchMissionID':
Bad("Bad_DataUnavailable: Expected data is unavailable for the requested time range due to an un-mounted volume.")
Seems bad.
Especially considering that tag path is completely different than the one you're working with.
You should first try to find what is trying to write to '[default]IAPI/Missions/MissionSubscriber0/WatchMissionID'.
Then find if anything else is writing to "[default]Banner/_Banner_/UnitId 1/1_Banner17-1_Banner48/1_Banner46".
I'm not sure how to do that.
You can write your value changed script like this to make it clearer what's going on:
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
if currentValue.value == 4:
value = 2048
else:
value = 0
system.tag.writeBlocking(["[default]Banner/_Banner_/UnitId 1/1_Banner17-1_Banner48/1_Banner46"], [value])