I’m using Tag History to get a motor’s bool “running” tag’s DURATION ON to obtain an “Equipment Runtime” for a PM schedule. A “Reset” simply writes to separate DB table (MaintResets) and associates a timestamp with the equipment name. The Tag History binding uses the last equipment reset as described below.
The first binding in the root’s custom properties (custom.LastReset) looks for the last reset in the Reset Table: “SELECT TOP 1 Timestamp FROM MaintResets WHERE EquipName = ‘EquipName’ ORDER BY Timestamp DESC”. Other code in the script binding will take care of any cases a record isn’t found, and a date is always returned.
The second binding, also in the root (custom.HourMeter), is set up as the Tag History binding, and uses custom.LastReset (above) as the Start Date, and ‘now(0)’ as the End Date.
These both behave exactly as designed, when the bindings are opened and closed. When a session is launched, however, they disappoint. After maintenance fills out a small popup with information about the PM, they can click the SAVE button, which triggers a sendMessage() with the equipment name and the information entered by Maintenance. The onMessageReceived functions properly, using the payload to fill out and trigger the entry for the MaintReset table.
Now comes the headache: using perspective.print() I have determined the binding custom.LastReset is updating correctly, but the Tag History binding custom.HourMeter is returning “None”. If I click “save”, or even Update Project in the designer, the custom.HourMeter will show correctly. I added a button to sendMessage() to the view, in an attempt to use self.refreshBinding(“custom.HourMeter”), but I continue to get “None”. Same with a perspective.refresh().
What am I missing that jukes my Tag History binding? I thought it would automatically refresh when the custom.LastReset changed, since that is an input into the binding. I thought refreshBinding would work, too.