Is there any way to get what the alarm thresholds are for a SQLTag? This may be in one of the newer versions as I haven’t had the chance to upgrade past 7.5.4 yet.
I’d like to be able to get this info for use along with the “Moving Analog Indicator” component. Right now all of our on-screen indicators are just shapes with text values in it, but that doesn’t do a good job of conveying normal operating state unless it is flashing during an alarm. We have literally thousands of these types of points, and it’s going to be tedious to convert this as it is, let alone if I’d have to manually set these thresholds on each point.
I could probably grab it with a SQL statement joining the core and alarms table together, but that seems as if it would be horribly inefficient, particularly if there’s a screen with a ton of points on it. What is the best way to grab this type of data and put it into a “Moving Analog Indicator”
It would also be nice to have this information to add as a solid line for graphs so we can more easily visualize this information on trends.
Any suggestions are greatly appreciated!
To my knowledge, this is not even possible in 7.6.
Here is a post from about a month ago talking about it.
http://www.inductiveautomation.com/forum/viewtopic.php?f=70&t=10415&start=0&st=0&sk=t&sd=a&hilit=tags
If they are tags in an SQL database, you could do the join command you referenced.
Or you could create new set point tags for your alarms, then reference the high and/or low setpoints in the process value tag’s alarms with those tags. Those set point tags could go all the way back to a PLC or just be memory tags.
Not sure how you set up your SQLTags thou. If you placed tags in folders, it should be fairly easy. If everything is on the top level, maybe a bit more tricky.
Hope that helps.
Cheers,
Chris
klesher,
We are doing exactly what you are talking about but it in 7.6. the key is that we have UDTs setup with tags for the hh,h,dh,dl,l and ll values. The udt also includes delay and dead band settings also.
We then have template that was built that allows user with valid permissions to click on the Moving analog indicator and adjust the set points. This makes the indicator and the alarms user configurable and we don’t have to edit all those components and alarms.
We do this with several AOI’s that we built in Control logic to handles all this. So alarm setting in PLC and in Ignition are dynamically user configurable.
But you could do similar thing using memory tags for settings if you don’t want them to be pushed to the PLC.
I appreciate the suggestions, but unfortunately I had to figure out a way to do with with our existing tags. We have a few hundred existing temperature sensors (as well as a few hundred voltage/current points we’d like to do this for as well), so it’s not particularly feasible for me to retroactively do this.
Basically I made up a little function to grab a setpointA’s float value based on a SQLTag name, and the “Name” (condition) for a given alarm (all of our tags are uniquely named, so I don’t need the folder pathing), and if it is enabled. Something tells me that I’m overlooking something in my SQL query that would let me grab a float value only if it is enabled, but I couldn’t think of how to do that for the life of me since the name column contains the setpointA designator AND the enabled designator, so I just did it programatically (if anybody has suggestions on how to take care of this, I would appreciate it):
[code]def getFloatSetpointA(tagName, alarmPrefix):
import system
SQL = """SELECT sqlt_alarm_meta.name, sqlt_alarm_meta.intvalue, sqlt_alarm_meta.floatvalue
FROM `sqlt_alarm_meta`
INNER JOIN `sqlt_alarm`
ON `sqlt_alarm_meta`.alarmid = `sqlt_alarm`.id
INNER JOIN `sqlt_core`
ON sqlt_alarm.tagid = sqlt_core.id
AND sqlt_core.name='%s'
AND sqlt_core.deleted='0'
AND sqlt_alarm.name LIKE '%s%%'
AND (sqlt_alarm_meta.`name`='setpointA' OR sqlt_alarm_meta.`name`='enabled')"""
result = system.db.runQuery(SQL %(tagName, alarmPrefix))
floatVal = None
for row in result:
if row["name"] == "enabled":
if row["intvalue"] == 0:
return -1
if row["name"] == "setpointA":
floatVal = row["floatvalue"]
return floatVal
[/code]
Then, I simply call this function through the “High Alarm”/“Low Alarm” property bindings on the Moving Analog Indicator, and get the thresholds dynamically populated as I’m looking for:
tofloat(runScript("app.alarms.getFloatSetpointA('" + {Moving Analog Indicator_Temperature_Vertical.tagName} + "', 'High Temp')",
1800000))
The question is, is there a more elegant way to do this with existing tags? THe SQL query took about .1350 seconds to run, which is sort of on the slow side. It wasn’t much different with using nested SELECT statements either. I want to make sure that I have a solution that isn’t going to kill my system once I have this being displayed on many screens. This query will get run every 30 minutes for each threshold value, though I suppose I could bump it up. Any suggestions on how to improve are greatly appreciated.
The only thing I can think of to speed the query is to split out fetching the tagID instead of using a join. Then you can just reference the tagID from the previous code. This won’t work as-is, but you get the idea:SQL = """SELECT tagid
FROM sqlt_core
WHERE sqlt_core.name='%s'
AND sqlt_core.deleted='0' """
tagids = system.db.runQuery(SQL %(tagName, alarmPrefix))
for tagid in tagids:
SQL = """SELECT sqlt_alarm_meta.name, sqlt_alarm_meta.intvalue, sqlt_alarm_meta.floatvalue
FROM `sqlt_alarm_meta`
INNER JOIN `sqlt_alarm`
ON `sqlt_alarm_meta`.alarmid = `sqlt_alarm`.id
WHERE sqlt_alarm.name LIKE '%s%%'
AND (sqlt_alarm_meta.`name`='setpointA' OR sqlt_alarm_meta.`name`='enabled')"""
result = system.db.runQuery(SQL %(tagName, alarmPrefix))
Also, I think (but you might need to look into it) adding many clauses to the JOIN instead of the WHERE might be slowing it down.