Mango not saving historic datalogger data to mango database by using scripting datasource
-
Dear community,
I am having trouble saving historic data to the mango database using scripting data source.
I have written a simple script which refreshes my defined modbus datapoint (120 register bulk in UTF-16) and then by decoding the register data saves it to the mango database on specific points at specific time.
( Actually right now we want to use mango as a testing system for our own new device as it is much more convienient to use Mango for testing and we have an upcoming project where this functionality would come handy for us to use mango as a system to get datalogger data from the device and then downloading it by using mango).
If I activate my script I can see that it is working correctly as it should, i.e while validating the script while it has been activated i can see validation response below
1527013950000 Setting point TEMPERATUREMEM to 25.093955078125 @22/05/2018 21:32:30 Setting point HUMIDITYMEM to 30.07940673828125 @22/05/2018 21:32:30 Setting point CO2MEM to 397.0 @22/05/2018 21:32:30 1527013960000 Setting point TEMPERATUREMEM to 25.126130371093744 @22/05/2018 21:32:40 Setting point HUMIDITYMEM to 30.07940673828125 @22/05/2018 21:32:40 Setting point CO2MEM to 397.0 @22/05/2018 21:32:40 1527013970000 Setting point TEMPERATUREMEM to 25.104680175781247 @22/05/2018 21:32:50 Setting point HUMIDITYMEM to 30.07940673828125 @22/05/2018 21:32:50 Setting point CO2MEM to 397.0 @22/05/2018 21:32:50 1527013980000 Setting point TEMPERATUREMEM to 25.093955078125 @22/05/2018 21:33:00 Setting point HUMIDITYMEM to 30.07940673828125 @22/05/2018 21:33:00 Setting point CO2MEM to 396.0 @22/05/2018 21:33:00 1527013990000 Setting point TEMPERATUREMEM to 25.08322998046875 @22/05/2018 21:33:10 Setting point HUMIDITYMEM to 30.12518310546875 @22/05/2018 21:33:10 Setting point CO2MEM to 396.0 @22/05/2018 21:33:10 OOOH OKAYY 1527014000000 Setting point TEMPERATUREMEM to 25.05105468749999 @22/05/2018 21:33:20 Setting point HUMIDITYMEM to 30.163330078125 @22/05/2018 21:33:20 Setting point CO2MEM to 396.0 @22/05/2018 21:33:20 1527014010000 Setting point TEMPERATUREMEM to 25.061779785156254 @22/05/2018 21:33:30 Setting point HUMIDITYMEM to 30.163330078125 @22/05/2018 21:33:30 Setting point CO2MEM to 396.0 @22/05/2018 21:33:30 1527014020000 Setting point TEMPERATUREMEM to 25.061779785156254 @22/05/2018 21:33:40 Setting point HUMIDITYMEM to 30.20147705078125 @22/05/2018 21:33:40 Setting point CO2MEM to 396.0 @22/05/2018 21:33:40 1527014030000 Setting point TEMPERATUREMEM to 25.093955078125 @22/05/2018 21:33:50 Setting point HUMIDITYMEM to 30.163330078125 @22/05/2018 21:33:50 Setting point CO2MEM to 396.0 @22/05/2018 21:33:50 1527014040000 Setting point TEMPERATUREMEM to 25.126130371093744 @22/05/2018 21:34:00 Setting point HUMIDITYMEM to 30.12518310546875 @22/05/2018 21:34:00 Setting point CO2MEM to 396.0 @22/05/2018 21:34:00 1527014050000 Setting point TEMPERATUREMEM to 25.104680175781247 @22/05/2018 21:34:10 Setting point HUMIDITYMEM to 30.07940673828125 @22/05/2018 21:34:10 Setting point CO2MEM to 397.0 @22/05/2018 21:34:10 1527014060000 Setting point TEMPERATUREMEM to 25.136855468749992 @22/05/2018 21:34:20 Setting point HUMIDITYMEM to 30.07940673828125 @22/05/2018 21:34:20 Setting point CO2MEM to 397.0 @22/05/2018 21:34:20 1527014070000 Setting point TEMPERATUREMEM to 25.126130371093744 @22/05/2018 21:34:30 Setting point HUMIDITYMEM to 30.07940673828125 @22/05/2018 21:34:30 Setting point CO2MEM to 397.0 @22/05/2018 21:34:30 1527014080000 Setting point TEMPERATUREMEM to 25.115405273437496 @22/05/2018 21:34:40 Setting point HUMIDITYMEM to 30.07940673828125 @22/05/2018 21:34:40 Setting point CO2MEM to 397.0 @22/05/2018 21:34:40 1527014090000 Setting point TEMPERATUREMEM to 25.08322998046875 @22/05/2018 21:34:50 Setting point HUMIDITYMEM to 30.07940673828125 @22/05/2018 21:34:50 Setting point CO2MEM to 397.0 @22/05/2018 21:34:50
This ensures that the script is working correctly and saves the read data from the device as I have saved the data on the datalogger every 10 seconds..., time is correct and point value is correct but in reality Mango does not save the historic data to the database and only saves the first sequence of the scripting sequence, and that is also not quite saved as it should.
This is seen on the datapoint page as we can see that the scripted values do not appear in the datapoint but they should if take the validation into account.
The number on top of the setting point is the epoch for the date i am using for set point function, i.e.
pointname.set(value,epoch);
Can someone help me by pointing me to the right direction on what may be wrong ?
Mango core: 3.2.2+20171009170034
Thanks,
Thomas -
Hi Thomas,
My first thought is to ask, "Have you enabled "Saves historic" on the scripting data source in question?"
If not, then the sets are subject to the data point's logging type. The definitive place to see what's going on is the code, starting with the savePointValue method: https://github.com/infiniteautomation/ma-core-public/blob/main/Core/src/com/serotonin/m2m2/rt/dataImage/DataPointRT.java#L243 In brief, only logging type ALL will log backdated values going through that method.
However, if you have set "Saves historic" on the scripting data source then you will bypass all of that logic and save the value (or present an error of some sort, like setting a numeric point to "asdf." I would guess, then, that your script does not have sufficient set permissions to the points. If the script doesn't have a script data point set permission of superadmin, you could try adding that. Or, perhaps the points are not settable? Looking at it, the "Saves historic" setting probably does not set values as intended for points that are not settable. You could look up some of the examples on the forum of using a point value dao to save values, that would be the option that doesn't require updating. I will change things such that "Saves historic" will work for points that are not settable, as perhaps it may have in the past.
Using the point value dao directly is discussed some here: https://forum.infiniteautomation.com/topic/3129/question-about-scripting-data-source
-
Hi Phil,
Thanks for pointing me to the right direction. By changing logging type mango started logging backdated values nicely.
Many thanks!
Thomas