I can check the PISDK.PIValue object to see if it's good, but how do I convert the value from something like -2147219947 to a string digital set?
The Digital State in PI SMT cannot be set up as minus values, so you cannot convert your minus value to a string via Digital tags. However, you could use PI PE to do this function via if ... else ... clause
If you are looking at it in PI SMT or other PI Client tools, is the bad value that you are getting something in the System Digital State? -2147219947 looks like a COM error code instead, but if you are sure that the bad value is a System Digital State value, you can cast the value of the PIValue to a DigitalState class in PI SDK to get the digital state string:
DigitalState ds = (DigitalState)pivalue.Value; // where pivalue is of PIValue class
string statestring = ds.Name;
Hope this helps
Unfortunately, it didn't work. The error message I get is "Unable to cast COM object of type 'System.__ComObject' to interface type 'PISDK.DigitalState'..." The error goes on to say that the QueryInterface call on the COM component failed because no such interface was supported.
I'm using PISDK version 184.108.40.2068, Visual Studio 2008 C#.
So far I have used this application on our test PI server and our prodution PI server. On the test PI server the value in question is reported as "snapfix" by PI-Datalink. On the production server the same tag, same event, same "value" of -2147219947 is reported as "Calc Failed" by PI-Datalink.
Note that the PISDK.PIValue class does not have a status property or a getStatus() method. It does have a IsGood() method which I am using. But rather than return "Bad Value" for every anomoly, I wanted to return the actual status of the value which is stored in the PI archive.
@David: Are you performing an aggregation calculation from the Summary method and collect the result into this PIValue object?
I remember having seen this before where the PIValue object took the value of one of the trappable errors. One of them is the pseCALCFAILED (-2147219947). You can find these errors with the help associated with the Summary method.
If it is the case, a try...catch block with a validation against COMException exception would intercept the problem. The Description property of the exception would tell you why.
David M. Fairchildhow do I convert the value from something like -2147219947 to a string digital set
-2147219947 isn't a Digital State. We do support up to 32k states but what you get is an error number. I have used PISDKUtility -> Error Lookup to translate it:
0x80040615 (-2147219947) Calculation failed.
Retrieving data ...