Assigning old timestamp to data point
-
Hi Bryan,
Here are a few things that should help you understand the Mango Scripting environment a bit better.
http://infiniteautomation.com/wiki/doku.php?id=automation:meta_data_points#context_objects
Script variables are objects. So for example you could do
return p1.value;
and this would return the current value of the point. Or you could do:return p1.time;
This would return the current time stamp of the point.
If you read through the rest of the wiki you'll see all the different properties of the objects
Also see this section on time values: http://infiniteautomation.com/wiki/doku.php?id=automation:meta_data_points#time_values
Let me know if this helps
-
Hello Bryan,
I think what you are looking for is this...
'To explicitly set the timestamp of a value, set the TIMESTAMP context variable before your return statement. The value to which to set this variable must be milliseconds since the epoch (not a native date). For example:
TIMESTAMP = new Date().getTime();
return p.value + 1;*Here's a Meta Script example. In this example I'm monitoring a binary point named TestUpdatePtvalue that updates every 5 secs. This script returns the value of TestUpdatePtValue on every call but if the value is the same as the last time it uses the same timestamp.
if (TestUpdatePt.value)
ReturnValue = true;
else
ReturnValue = false;if ( ReturnValue == my.value ) {
if (my.time >0) TIMESTAMP = my.time;
}
return ReturnValue;Now for the bad news, I just discovered that this script won't work in the 2.6.0 beta. We will get that fixed as soon as possible.
-
Thank you very much for your replies. The script return p####.time works perfectly,
Thank you for the script Woody. For now I will move forward with Joel's suggestion but I will keep the script in mind.
Thank you again
Bryan
-
I have discovered another issue that needs to be solved.
The points that I want to get the timestamp for are in a data source that updates every 2500 milliseconds.
Even if I run the return p####.time script it returns the timestamp of the last update
Is there a way to freeze the timestamp in the data source?
Bryan
-
Hey Bryan,
Yeah that's what the script I wrote above kind of does.
"This script returns the value of TestUpdatePtValue on every call but if the value is the same as the last time it uses the same timestamp."
-
Hi Woody,
Okay. But you mentioned that this script does not work on the current beta version of Mango.
But once that is updated I will try the new script.
Bryan
-
The script above now works in 2.6.0 beta as of build 353
-
I have tried the script but it doesn't work. However if I go in the data point details page for an alarm that is already active it says it become active on aug 10 10:37. Is there a way to export that time to DGLux instead of the current timestamp of the point?
-
Here is a screen shot of the point in question in the point details page:
However if I look at a watch list containing this point it displays the time as now, for example 8:37 am as of writing this
-
DGLux has limited capabilities as far as integrating with alarms and other parts of Mango. Your best path forward is to figure out how to make that script work or why it isn't working. We tested it on Mango 2.5 and it worked. It should work on 2.6 as well but we can take another look and see if the script needs to be modified.
-
Here are some screen shots that might help. First is a watch list containing the point containing the script (Time_Stamp) and the alarm that it is connected to (mal_cp_ol). They have the same time stamp:
Here is the script. Perhaps I am not using it correctly: