AnsweredAssumed Answered

Writing an array to a PI Point

Question asked by PabloSatler on Apr 30, 2017
Latest reply on Apr 30, 2017 by PabloSatler



I have a PI Point which I defined its Value Type as Double Array, as shown below.



What I'm trying to do next is to write an array of doubles, which is a result of a matlab calculation, to this PI Point. This array can vary in size, depending on the output of the calculation. Below, it's the part of the code where I get the error.


            int size= tam[0];
            double[] resultArray = new double[size];
            int v = 0;
            for(v=0;v < size; v++)
                resultArray[v] = (double)(MWNumericArray)saida[v + 1][1];
            //trying to write back to PI
            var elem = elements["Testes"];
            var attribElem = elem.Attributes["Analysis1_Output_C#"];
            AFValue resultMatlab = new AFValue();
            resultMatlab.Value = resultArray;
            resultMatlab.Timestamp = AFTime.Now;



At the "SetValue method" line (line 14 above) I get the following exception:

An unhandled exception of type 'System.InvalidOperationException' occurred in OSIsoft.AFSDK.dll

Additional information: Cannot convert value to a PI equivalent type for writing.


Note: I was able to successfully store the result in PI using an attribute that doesn't have a data reference assigned (<None> DR), but when I try to do the same with a PI Point data reference, I'm getting the exception above.


Any idea on how to solve this?


Thanks in advance!


Version Information:

PI System Explorer 2016 R2 SP1

PI AF Server version

AF SDK version

Explorer version