Backfilling Data

Hi all,

I’m importing logged data from another system into ignition using the system.tag.storeTagHistory() function. In order to make system maintenance as easy as possible, I wrote a gateway script to watch a SQL table, and when new tags appear in the third party system, I create new tags in Ignition and start importing all the available history from the 3rd party system.

The functions all perform as expected, except that when Ignition creates these new tags, it also starts creating duplicate tags when I start importing data earlier than the tag creation date. This isn’t a problem as such, except that when I trend historical tag data, the history associated with these duplicate tags do not trend. In effect, I’ve imported data into the tag historian, but I can’t access it, or Ignition doesn’t know that it belongs to the tag I’m working with.

In the sqlth_te table, a single tag appears as follows:
±----±---------------------±-----±---------±----------±-------------------------±-------------------------+
| id | tagpath | scid | datatype | querymode | created | retired |
±----±---------------------±-----±---------±----------±-------------------------±-------------------------+
| 3 | flotron/…/level_mm | 3 | 1 | 3 | 2018-05-09 18:25:31.1680 | NULL |
| 371 | flotron/…/level_mm | 2 | 1 | 3 | 2018-05-05 15:26:46.0000 | 2018-05-09 18:51:59.1640 |
| 395 | flotron/…/level_mm | 2 | 1 | 3 | 2018-05-07 06:00:00.0000 | 2018-05-09 18:55:19.5810 |
±----±---------------------±-----±---------±----------±-------------------------±-------------------------+

and tag data appears as follows:
±-------------------------±------±---------------+
| datetime | tagid | floatvalue |
±-------------------------±------±---------------+
| 2018-05-09 18:35:31.1720 | 3 | 4881.580078125 |
| 2018-05-09 19:30:00.0000 | 3 | 4828.95 |
| 2018-05-09 20:00:00.0000 | 3 | 4881.58 |
| 2018-05-05 15:26:46.0000 | 371 | 434.211 |
| 2018-05-05 15:30:00.0000 | 371 | 447.368 |
| 2018-05-05 15:30:01.0000 | 371 | 447.368 |

| 2018-05-07 06:00:00.0000 | 395 | 3778.95 |
| 2018-05-07 06:30:00.0000 | 395 | 3719.74 |
| 2018-05-07 07:00:00.0000 | 395 | 3644.74 |
±-------------------------±------±---------------+

Anything earlier is marked as tagid 3. My objective is to load history for newly created tags with timestamps that predate the tag. This seems to be the problem I’m running up against. I’ve gone as far as manually adjusting the creation times of the tags before I store the history, but it seems these creation times are cached somewhere so that my changes have no effect.

Any advice on either the operation of the historian or how to achieve my goals would be greatly appreciated.

J

1 Like