whenever value == true, I get null but i'm not seeing what I'm doing wrong.
Is there anything in the log (gateway web site, Status, Diagnostics, Logs)?
This is a script transform in a style binding, it's completely separate from the log.
I would refactor this script a bit, plus queryStatus is not returning a scalar value, rather a list of alarm events, which can be parsed for individual properties. First of all, run your base script in the script console and verify the results first
# This returns a list of PyAlarmEvent objects
results = system.alarm.queryStatus(state = ['ActiveUnacked'], path = ['*AndonMSK:/tag:Ovens/Alarm*']
for result in results:
print result
Also, the path/source arguments for the function seem to require a search pattern with wildcards?
if value:
# This returns a list of PyAlarmEvent objects
results = system.alarm.queryStatus(state = ['ActiveUnacked'], path = ['*AndonMSK:/tag:Ovens/Alarm*']
if len(results):
# Note that this returns the string value not the integer value
#return results[0].getState()
return 2
return 1
Tim saying to look in the gateway logs for error messages related to the transform.
It looks like Python/Jython to me. My understanding is that no matter which context this is running under that any errors will end up in the gateway log.
If not, this should force some entries into the log
def transform(self, value, quality, timestamp):
logger = system.util.getLogger("MyTransformMethod")
logger.info('starting transform')
try:
if value == true:
logger.info('value is true')
status = system.alarm.queryStatus(state = ['ActiveUnacked'], path = ["[AndonMSK\Ovens/Alarm"])
logger.info('status is {status}'.format(status = status))
if status == 2:
logger.info('status is equal to 2')
return status
else:
logger.info('status is not equal to 2')
return 1
else:
logger.info('value is not true')
return 1
except:
logger.error("transform {stackTrace}".format(stackTrace = str(sys.exc_info())))
Not correct. Gateway and Perspective scopes end up in the gateway log (so, correct for this case). Designer and Vision Client scopes show up in the local log.
Cool. I haven't played with Vision yet... my designer entries end up there but maybe that's because I force them to with the logger.info stuff. And since you guys pointed me to the text file that I can tail it is all a bit easier.
@Christy_Jean Is this Perspective or Vision?
Vision doesn't have transforms, so this must be Perspective.
Perspective
This worked, thank you.