Evaluate expression in scripting

I’ve done some searching and I have found some things regarding this but as far as I could tell, no one really solved it.

I’m trying to evaluate bound alarm properties, in particular ones like enabled and priority that we often have bound to another tag (in the UDT structure that the alarm itself is in). I’m able to dig down to the BoundAlarmProperty (browseConfiguration -> getAlarms -> getBoundProperty) and can see the binding in text. But I need to evaluate that expression relative to the path of the tag (an example of the binding: “[.]…/Config/Alarm Priority”). It looks like I can use compile() on the BoundAlarmProperty, but I need an ExpressionParseContext… that I have no idea how to get.

Any ideas on getting this ExpressionParseContext?

Heres my test code, where path is defined earlier:

bc = system.tag.browseConfiguration(path, False)
alarms = bc[0].getAlarms()

print alarms
for a in alarms:
	print a.getName()
	for p in a.getProperties():
		print str(p), a.get(p), str(type(p))
		if a.isPropertyBound(p):
			print "   bound prop text : %s" % a.getBoundProperty(p)

I’ve seen this in particular where the solution is a custom module… not something I can accomplish at the moment.

I’ve looked under the hood, and I’m not sure how I’d do it with a custom module. /-:

1 Like

Aw well thats not a good sign :confused: I found this too but I’m not sure if you can do the same thing he does in Jython instead of Java. Or if that kind of thing would even work for my purposes.

It just seems so odd that something so seemingly simple, that happens so often, is such a tough thing to use. But of course, there are many more considerations than I can understand as an outsider :slight_smile: