Screen help

Attached please find a screen shot of something I am trying to work on. The top box is a text box which obtains the job number dynamically from a data set. The table itself used this value to find all machine numbers that are currently running that job number. So far this works out quite well. But I need some other ideas or some ideas on how to complete what I would like. In the second column I would like to place the current running totals from that machine. The totals are actually in SQL Tags. The only thing I am not quite sure of is how to add a SQL tag to a query so that it will display the proper data. Looking for ideas and/or suggestions.

Here is what would be an example. In the screen shot show you see machine 43 is running the job which is shown at the top. In the column next to the machine number I would like the SQL tag count43 which just so happens to be the SQL tag that contains the live count. In some cases we might have as many as 6 machine running the same job so you would see all 6 machines with their running totals, then maybe as an added bonus show the accumulated total at the bottom.

Thanks and have a great day.

Well, it is a bit awkward to combine the results of a SQL query with sqltag values. I would do it in a script. The way this would work is you would disconnect your SQL Query binding on the Table’s data property, and add a propertyChange event script to the text box:

Here is a skeleton:

if event.propertyName == 'text': jobNum = event.source.text machines = fpmi.db.runQuery("SELECT mach_num, task FROM mytable WHERE job = %s" % jobNum) newData = [] for row in machines: mach_num = row['mach_num'] total = fpmi.tag.getTagValue('[]Path/To/count%d' % mach_num) newData.append([mach_num, row['task'], total]) table = event.source.parent.getComponent('Table') table.data = fpmi.db.toDataSet(['mach_num', 'task', 'count'], newData)

To show an accumulated total, simply use a Label bound to an expression using the sum function.

Hope this helps,

Carl, let me see if I have this correct. The first line in the sample code you provided give a true statement all the time if you put it in a text box. Is that correct? So if by doing this it would run all the time that their is text in the text box. Or am I incorrect?

The rest of the code I somewhat understand and it would have been my next choice should I have gotten to that chapter in the book I am reading. Thus far with making the modification I have been able to get the data to come thru and be displayed in the table it is just that right now it is not updating as the data is updating. Am working on it.

Anyway much thanks and have a great day.

No. The first line will only be true when the text property changes. This is a propertyChange event script. You can read more about this event type in the user manual here inductiveautomation.com/prod … ertyChange

A little update after talking to Martin on the phone, he wanted to run this update whenever one of a number of SQLTags changed value (such as the Job Number text box on top).

I recommended that he:

  1. Create a dynamic property on an object on the window.
  2. Bind the object to an expression containing relevant SQLTag(s)
  3. Run the script on the PropertyChange event of that dynamic property

On a (hopefully) overcomplicated note: If the basis of the update is meant to be on value change from an arbitrary number of SQLTags (from the result query) then you’re getting into a tough situation - I don’t think you’ll be able to, on Job Number value change, dynamically monitor an arbitrary number of SQLTags values for change. In this case I’d use a Global timer script or some other method of periodic polling - don’t have it update components unless values change. Remember that SQLTags are stored in the database, so you should be able to read them with a single query rather than looping and reading individual tags.