I need to build a simple datareference which checks whether Attribute value is below or above a predefined value
There is a whitepaper in the Library on implementing Data References in AF 2.x, as well as example project files that you can download.
The question I would ask though is whether a Notification would better suit here? A Data Reference is intended to retrieve data from or write to an external data source. Once you have checked the attribute value and determined whether it is above or below the predefined value, what do you intend to do with that? A PI Notification based on the Comparison rule would be able to do this check with no coding required, and then create an alert if required.
No there is no requirement of a Notification ..After checking the value I need to write back to an attribute
OK, so I would start then by looking at the whitepaper and accompanying code examples. Should you then have specific questions about the implementation, post back to the forum and someone will answer your questions. Happy coding!
Well said John! Going through the white paper is definitely a good way to get started on AF Data Reference.
@ Viju: I have additional questions for you about what you mean by writing back to an attribute. Do you mean that you are going to write the comparison result to an attribute with PI Point Data Reference, hence writing down to a PI Tag for historizing?
Do you need to run the comparison on a regular interval or when there is a change in value (event triggered), or it is more like a ad hoc calculation that you need to when the user accesses the attribute?
If you need to comparison to occur on regular interval or on event triggered and writing the result to a PI tag , it would seem to me like it would make more sense to have a PI Performance Equation (PE) tag that does the calculation instead, as PI PE Scheduler does allows you to schedule calculations (in this case is a comparison) easily without you writing your own AF Data Reference and also writing something to schedule your calculation.
If the result just need to be access on an ad hoc basis, then you can also consider using a Formula Data Reference for performing the comparison. Again, this can be done easily via configuration, without you writing a custom Data Reference.
These are just some thoughts about how to approach your requirements with other methods, and I am making some assumptions here based on what you have posted. Hopefully this would be helpful to you.
Retrieving data ...