Hi, I have a question/bug report when using a Tag History binding with the following settings:
- Return Format: Wide
- Query Mode: AsStored
- Time Range: Historical
- Tags: Direct with multiple tag paths
- Value Format: Document
Like so:
This results in the following sample data:
[
{ "t_stamp": 1685620800000, "cod_sol": null, "cod_tot": 965 },
{ "t_stamp": 1685620800000, "cod_sol": 333, "cod_tot": 965 },
{ "t_stamp": 1685707200000, "cod_sol": 333, "cod_tot": 506 },
{ "t_stamp": 1685707200000, "cod_sol": 262, "cod_tot": 506 },
{ "t_stamp": 1685966400000, "cod_sol": 262, "cod_tot": 519 },
{ "t_stamp": 1685966400000, "cod_sol": 239, "cod_tot": 519 },
{ "t_stamp": 1686052800000, "cod_sol": 239, "cod_tot": 521 },
{ "t_stamp": 1686052800000, "cod_sol": 180, "cod_tot": 521 },
{ "t_stamp": 1686139200000, "cod_sol": 180, "cod_tot": 956 },
{ "t_stamp": 1686139200000, "cod_sol": 271, "cod_tot": 956 },
{ "t_stamp": 1686225600000, "cod_sol": 271, "cod_tot": 709 },
{ "t_stamp": 1686225600000, "cod_sol": 290, "cod_tot": 709 },
{ "t_stamp": 1686312000000, "cod_sol": 290, "cod_tot": 100 },
{ "t_stamp": 1686312000000, "cod_sol": 267, "cod_tot": 100 },
{ "t_stamp": 1686312001000, "cod_sol": 267, "cod_tot": 459 },
{ "t_stamp": 1686571200000, "cod_sol": 267, "cod_tot": 483 },
{ "t_stamp": 1686571200000, "cod_sol": 220, "cod_tot": 483 },
{ "t_stamp": 1686657600000, "cod_sol": 220, "cod_tot": 966 },
{ "t_stamp": 1686657600000, "cod_sol": 427, "cod_tot": 966 },
{ "t_stamp": 1686744000000, "cod_sol": 427, "cod_tot": 268 },
{ "t_stamp": 1686744000000, "cod_sol": 200, "cod_tot": 268 },
{ "t_stamp": 1686830400000, "cod_sol": 200, "cod_tot": 468 },
{ "t_stamp": 1686830400000, "cod_sol": 275, "cod_tot": 468 },
{ "t_stamp": 1686916800000, "cod_sol": 275, "cod_tot": 421 },
{ "t_stamp": 1686916800000, "cod_sol": 354, "cod_tot": 421 },
{ "t_stamp": 1687176000000, "cod_sol": 354, "cod_tot": 249 },
{ "t_stamp": 1687176000000, "cod_sol": 225, "cod_tot": 249 },
{ "t_stamp": 1687262400000, "cod_sol": 225, "cod_tot": 0 },
{ "t_stamp": 1687262400000, "cod_sol": 0, "cod_tot": 0 }
]
As you can see, for each t_stamp there are two rows. This is expected, and documented behavior: "AsStored: Will return the records as stored in the database. While querying data with this mode, multiple value changes at the same timestamp will result in multiple rows, one row for each unique value."
The problem lies in the way that Ignition carries over values from the previous timestamp into the next one. Let's take a look at the first four rows of the result set:
{ "t_stamp": 1685620800000, "cod_sol": null, "cod_tot": 965 },
{ "t_stamp": 1685620800000, "cod_sol": 333, "cod_tot": 965 },
{ "t_stamp": 1685707200000, "cod_sol": 333, "cod_tot": 506 },
{ "t_stamp": 1685707200000, "cod_sol": 262, "cod_tot": 506 },
- First row only contains a value for
cod_tot
for timestamp1685620800000
. - Second row contains a value for
cod_sol
AND thecod_tot
value from the previous row. Since the previous row represents the same timestamp in this case, this is ok. - Third row represents a new timestamp, and contains a new value for
cod_tot
. It also carried over the old value from the previous row forcod_sol
. This is not ok, sincecod_sol
does not have value "333" stored in the database for t_stamp "1685707200000"! - Fourth row now contains the correct value for both
cod_sol
andcod_tot
.
When this data is plotted as discrete points on a timeseries chart, we are showing incorrect data as you can see here:
Am I missing some configuration or setting that can prevent this behaviour? Or is this simply a bug in the Tag History binding in this particular setup?