AnsweredAssumed Answered

Issue writing a matlab dll routine on PI as a custom data reference

Question asked by PabloSatler on Nov 3, 2016
Latest reply on Nov 4, 2016 by rdavin

Hi,

 

I'm writing a matlab dll routine to be executed on PI System Explorer (PSE) as a custom data reference. The goal of the data reference (DR) is to get a range of values from a tag and then feed the matlab routine as an array, which is going to return a value as an answer. This value then should be written on an attribute (that uses the DR), storing both the value itself and its timestamp, so we can have a times series data. The initial idea would be this routine to be called every time a client user hits the "attributes" tab on PSE, and the latest result be visible on that tab, like a snapshot value.

The routine is working, though it always store the same timesstamp (01/01/1970), even when using an AFValue with Timestamp = AFTime.Now. So, what can I do to fix that, so that we have a history of the values stored?

I also would like to know which method is internally called when we hit the "attributes" tab on PSE. Using the "Attach to Process" feature of Visual Studio I noticed that the GetValue method was the one called, so I put my matlab routine there. However, I'm not sure if there is the right place to do so. I also expected the method GetValues (plural) to be called, once I'm using a range (AFTimeRange) to retrieve the values from the input tag, though such method was never called. Is there any way to get a custom method to be called by the PI System whenever a certain event happens, like the user hitting the attributes tab on PSE? 

 

The documentation I am using as reference to build my custom data reference are this white paper and these videos. So, if anyone has any other piece of information about implementing custom data references on AF, please share with me.

 

Thanks,

Outcomes