Log who change a point value
I want to know if It's possible to log (in alarm menu) if an user change a value manually, or if a script change it.
Thanks in advance,
phildunlap last edited by phildunlap
In general, this should already be getting logged! Are you noticing people are setting values and it's not appearing in the values column of the point values table (would be in parentheses, bold italic)? Where are the users setting the point from?
In the old UI, there was a column for annotation on the data point details page, it has information like this:
But I noticed I had to disable cached values to see the annotations that 'admin' performed the set.
If you're trying to check an annotation and raise an alarm, I would do that in an alphanumeric meta point or script. You can get the annotation so as to examine it from the point like,
//Check if annotation exists on the most recent value... if(p.lastValue(0).isAnnotated()) print(p.lastValue(0).getAnnotation(com.serotonin.m2m2.Common.getTranslations())); //=== 'Script'
and then return whatever is a meaningful alarm message in the Meta point Then create a change detector on the point so that you have an event that will appear in the alarms list. If the annotation doesn't need to raise an alarm, you could then
return UNCHANGED;from the script body (in a Scripting data source you don't return anything, so simply don't set out a value in that case).
@phildunlap Thanks Phil!
I'm using Mango 2.7, and I'm trying to set an annotation, but in a specific timestamp. The idea is to ckeck which script or user write a value.
Could you help me with this script?
phildunlap last edited by
From that statement alone I don't know what you are trying to do.
If you haven't seen it, you can set the annotation and the timestamp with the set value. There are three set functions on context points:
set(value); //set the value at the timestamp that triggered the script //set a value at a timestamp. If the "saves historic" is not checked on the scripting data source, this will // go through the DataPointRT's savePointValue method, which has some logging subtleties set(value, timestamp); set(value, timestamp, annotation); //just like previous, but with annotation as well
So a meta point could have a script like,
my.set(p1.value, p1.time, "custom-annotation"); return UNCHANGED;
Which would have the meta point have the same value at the same time as the context point, but with the custom annotation.