I'm working on an application similar to the CSV to Tag Converter on the Exchange, but in Perspective.
I keep running into issues using the system.tag.storeTagHistory
function (I'm on v8.1.25 - it was added back in v8.1.8 IIRC). Here is what I'm testing with:
historyprovider = "LocalDB"
tagprovider = "default"
paths = ["[default]test", "[default]test", "[default]test"]
values = [1.23, 4.56, 7.89]
system.tag.storeTagHistory(historyprovider, tagprovider, paths, values)
Here is what I get in the gateway logs:
Any help or guidance is greatly appreciated, I feel like I've been hitting a brick wall for several days now...
I would guess you don't need the [default] on the tag paths.. They aren't used on the documentation system.tag.storeTagHistory - Ignition User Manual 8.1 - Ignition Documentation
You also need to state the tag path multiple times to store more than one data point, in your screenshot you only have 1 path
1 Like
Good catch! That may be one of the problems - yesterday I created a new DB table called TagHistory and used that as the historical tag provider AND IT WORKED?! Now I'm more confused as to why it wasn't working earlier.
The setup I had on the DB side (SQL Server) was a simple testing database I created. I ran the Vision app I got off of the Exchange, where it generated the historical tag records, then deleted all of those tables so I can try again, and it didn't work after that.
I will post the eventual resolution in this thread.
That seems like the root of the problem.
My educated guess:
Standard history storing operations ensure that the tables exist in the database. system.tag.storeTagHistory
may be taking a 'shortcut' code path that does not, so when you manually deleted all the historian tables nothing was putting them back in place. Manually storing history to a new provider 'suddenly' works.
That's the only explanation I can come up with that makes sense for what you've described.
What you're describing seems accurate and is probably what's happening... Is there a way to avoid creating new databases every time I want to run a test? This seems... well, sort of suboptimal, though there is probably a good reason why it happens.
EDIT: Just saw you made changes on the docs page for this function and also noticed that the cache needs to be cleared - just deleting the db tables doesn't reset anything. Is there a way to clear the cache without restarting the Ignition service?
You could simply truncate the sqlth_*
tables, and drop only the sqlt_data_x_timestamp
columns.
1 Like
Just fixing a typo 
Which cache are you referring to?
If you do an edit -> save on the history provider you're targeting it should clear that cache.
1 Like