DSmith1

C# Basic question on checking PI Point Values

Discussion created by DSmith1 on Apr 20, 2012
Latest reply on Apr 23, 2012 by hanyong

Hi guys,

 

So I've written code for a simple PI application that is supposed to:

  1.  Retrieve a specified point from the PIServer,
  2. Check it's value 
  3. Output a number if it's a certain value.

I've gotten up to part 2, but I can't seem to hammer down part 3 (which is silly  because it seems basic). The problem is when I try to check the PI value, I get a bunch of different errors because the PIValue is dynamic, and I can't read it. Code snippet:

 
// Query to get the deviceA from PI
                    _myPIPoint = _destinationServer.PIPoints[tagA];

                    // Set the timerange (now - specified number of minutes)
                    string _timeRange = "*-" + (timeRange * 60) + "s";       

                    // Get the values
                    var mp = _myPIPoint.Data.Snapshot;
                    var myPIValues = _myPIPoint.Data.RecordedValues(_timeRange, "*");

                    // If one value in that time range is a fault, return the location
                    foreach (PIValue value in myPIValues)
                    {
                        string result = "";
                        if (result.Equals("fault"))
                        {
                            _singleReturnValue += 1;
                            break;
                        }
                        else { }
                    }

 

 

Can someone help me? How am I supposed to check the value and compare it to a string?

Outcomes