Hi dear Ignited,
I am troubleshooting problem with script. We have set of machines that have ever-growing counter (it resets only on very rare occasions). On several occassions, the script has apparently ran twice at the same time. One run was legit but the other (given the bogus data in database) seems to return values tens of hours old. Let me demonstrate:
dbconn = system.tag.read('Globals/IgnitionRuntimeConnection').value import datetime t_sql = """ INSERT INTO [dbo].[x56_PROCESS_MAC_MONITORING](machineid, timestamp, alive, totalcounter) VALueS (?,?,?,?) """ for i in range(13,29): tc = system.tag.read('x56_Process/Machine'+str(i)+'/Statistics/TotalCounter').value alive = True if tc is not None else False system.db.runPrepUpdate(t_sql, [i, datetime.datetime.now(), alive, tc], dbconn)
Script above runs every second and writes current value of one tag to database table for troubleshooting purposes for each machine. How come it is able to write 2 different values for one and the same second for one individual machine? The first value is correct (number is OK in accordance to ever-growing TotalCounter), but the other value written at the very same second must be at least 12 hours old. I can’t get my head around why this can happen. In general, there shouldn’t be more than 1 row per one machine per 1 second, yet there is.
Thanks for your feedback, SZ