V8.1-Perspective
What is the easiest way to display the time and date, the last time a tag (integer) equaled a certain value?
I’ve watched EDU videos and I’m still stumped.
V8.1-Perspective
What is the easiest way to display the time and date, the last time a tag (integer) equaled a certain value?
I’ve watched EDU videos and I’m still stumped.
How and where have you stored the tag data?
What are EDU videos?
I have stored the values in my storage provider, a MSSQL DB.
Sorry, the university videos or videos from the manual.
How ... have you stored the tag data?
Are you using the Ignition Historian, transaction groups or tag events?
Historian
OK. Let's see your tag's history configuration.
| Column 1 | Column 2 | Column 3 | Column 4 |
|---|---|---|---|
| History Enabled | true | ||
| Storage Provider | IGNITION_HIST | ||
| Deadband Style | Auto | ||
| Deadband Mode | Absolute | ||
| Historical Deadband | 0.01 | ||
| Sample Mode | OnChange | ||
| Min Time Between Samples | 10 | ||
| Min Time Units | SEC | ||
| Max Time Between Samples | 1 | ||
| Max Time Units | HOUR |
A few notes:
Deadband Style to Discrete.Min Time Between Samples causes records not to be recorded for at least 10 seconds, so any changes that occur will be lost. If what you are trying to achieve is to insure you have a record every 10 seconds, then that would be the Max Time Between Samples setting.The easiest method would be to set up a Tag History Binding with the Aggregation Mode set to Last Value.
Playing around with AI, so haven’t vetted it:
tagPath = "[default]Area1/Motor1/Speed"
start = system.date.addHours(system.date.now(), -1)
end = system.date.now()
data = system.tag.queryTagHistory(
paths=[tagPath],
startDate=start,
endDate=end,
returnSize=-1
)
# Filter occurrences where value == desired value
valueToFind = 1200
matches = [row for row in data if row['value'] == valueToFind]
This aggregate mode simply says, if there are multiple values within the sample period, take the last / most recent value.
For something like this, you probably don't want to aggregate or sample it at all, you want the raw data points (that is, what @robertm has already with returnSize=-1)
I was able to revisit this, finally.
I ended up doing a tag history binding to the props.data property of a table. The configuration for the tag history binding was wide return format, as stored query mode, realtime with an appropriate range needed to see the value, direct historian tag reference.
I then filtered the column with the integer value in it equal to the value I was looking for, formatted the timestamp column with correct time/date format, and made header, pager and value columns invisible/disabled. I then further formatted the remaining cell to look like a display label, which is all I needed.
I was able to then copy this for each tag I needed, making sure to change the column field for each unique tag and it worked great. I had a good comparison from a different HMI and all my time stamps were 2-3s ahead of the other HMI.
I’m sure there is a more elegant way to do this, but this worked for me.