I’m looking into driving a custom driver and the values for my tags within Ignition are updating, but they are ‘stale’.
From my understanding of the custom driver whitepaper, I need to:
[ul]
[li]- update the tag value and the valuechange
column to the current datetime in sqlt_core[/li]
[li]- update the lastexec' to the current datetime, and
nextexec` to the current datetime plus the scan rate.[/li][/ul]
Example (python) code:
import MySQLdb, datetime, time
try:
conn = MySQLdb.connect ( host = "localhost",
user = "ignition",
passwd = "password",
db = "drivertest")
cursor = conn.cursor()
for x in range(0, 1000):
d = datetime.datetime.now()
now = d.strftime('%Y-%m-%d %H:%M:%S') # timestamp
next = (d + datetime.timedelta(seconds=1)).strftime('%Y-%m-%d %H:%M:%S')
value = x
# update the value
cursor.execute("UPDATE sqlt_core SET intvalue=%d, valuechange='%s' WHERE name='TestTag'" % (x, now) )
print "set intvalue=%d" % x
# update scan class instance
cursor.execute("UPDATE sqlt_sci SET lastexec='%s', lastexecrate=1000, nextexec='%s'" % (now, next))
# wait some
time.sleep(0.1)
except MySQLdb.Error, e:
print "err %d: %s" % (e.args[0], e.args[1])