Inductive automation ignition scripting dates
- #INDUCTIVE AUTOMATION IGNITION SCRIPTING DATES UPDATE#
- #INDUCTIVE AUTOMATION IGNITION SCRIPTING DATES CODE#
- #INDUCTIVE AUTOMATION IGNITION SCRIPTING DATES WINDOWS#
Its possible that you could miss this data. I noticed some of the monthly partitions have a very slight amount of data from the previous/next month. It could easily be turned into a function and called in scripting and just pass in the tagpath, a string that is a start date, and a string that is an end date. I worked on this for a while and what I came up with seems to work pretty well. I exported a History Window so you can take a look at it. Query += " AND floatvalue (DATEDIFF(SECOND,'19700101', '" + start + "') - DATEDIFF(SECOND,SYSDATETIMEOFFSET(),GETDATE()))"Į('query', query)īasically, it builds the sql query that I want to run. Query += " AND t_stamp/1000 " + highlimit * Convert the end property to unix time and add a month to it for comparison */ĪND end_time/1000 (DATEDIFF(SECOND,'19700101', '" + start + "') - DATEDIFF(SECOND,SYSDATETIMEOFFSET(),GETDATE()))" Id → Get the tag id from the sqlth_te database by binding the following SQL query SELECT id
#INDUCTIVE AUTOMATION IGNITION SCRIPTING DATES UPDATE#
Update → I toggle this bit to refresh the query therefore the table. Start → bind this to the date from my start popup calendar.Įnd → bind this to the date from my end popup calendar. I leave the load on the SQL server as that is what it is good at.įirst, I created a table with the following custom properties: Here is how I have been accessing the data to show what I want. It is already there, so why not access it. I agree with diat150 about double logging data. I’m pretty sure someone will have a simple solution and I’ll feel dumb for not thinking of it. I’ve been able to highlight the data with the mapped background function, but I cant seem to find a way to “hide” the other data or pull out the data with highlighted cells. I thought this would be the simplest, but I’m finding it hard to query the dataset. I even tried to just pull up a table with all the data between the dates and then try to extract the needed data from the dataset that was generated. I cant query the database directly without knowing what tables to look at, and the dates might span a month (last day of one month to the first day of the next) and that means is will be in two different tables. In the database, its quite simple using a query but from ignition there do not seem to be any tools that allow this.
From this they want to query the history to see how many times they fell below 2psi between the dates. For example, the want a screen that has a start date and an end date entered on the screen, they also have a pressure value, say 2psi. They are logging a pressure on a vessel, and they have an alarm at 0.5 psi, but the would like to have a page that allows them to look at some other low points for the day.
I’m hoping that there is a simple solution that I’m overlooking.
#INDUCTIVE AUTOMATION IGNITION SCRIPTING DATES CODE#
For example, the following code will access the value of a Tag.I have a customer who asked for what I first thought would be a simple query, and after attempting to do it, turns out seems quite hard.
Ignition comes with a group of system functions, called the System Library. Using a system function is simple. For example, if a component on a window is running a script, its values are isolated to the client, and the output will be displayed on the Designer/Client output console. "Client Scope" scripts, however, execute on the running client (and also in Designer when testing, but only in Preview Mode). Additionally, some of the system functions like only work in the "Client Scope," so you will not be able to use them in the script on the Tag.
#INDUCTIVE AUTOMATION IGNITION SCRIPTING DATES WINDOWS#
This means that the script will not be able to access any client level resources such as windows or components that you may have open in the Client. For example, running a script on a Tag is run in the Gateway Scope and the output is sent to the Gateway console (i.e., wrapper.log file) because Tags are stored in the Gateway. This is important because it determines what system functions can be run, what resources the script can interact with, and where the output will be written to. Where a script is run from determines what scope it is running in. Within Ignition, there are different scopes: the Gateway Scope, the Perspective Session scope, and the Client Scope. One important thing to keep in mind before scripting in Ignition, is to understand the concept of scope. Each location has its own events that trigger your scripts to run, and add functionality to your projects in different ways. The most apparent place is in event handlers on components and other objects in Vision Clients and Perspective Sessions. Python is used in many places in Ignition.