2 Replies Latest reply on Aug 25, 2014 10:12 AM by MaxStrueverWipro

    How to get the PIValue from a Tag when the value is of type Timestamp.

    anup
      How to get the PIValue from a Tag when the value is of type Timestamp.Since it is throwing an exception "Unable to cast from System.__ComObject  to interface type 'System.IConvertible' ".
        • Re: How to get the PIValue from a Tag when the value is of type Timestamp.
          andreas

          Anup,

           

          you may want to take a look a this discussion.

           

          Here is some sample code in c#

           
                      PISDK.PISDK _myPISDK = new PISDK.PISDK();
                      PISDK.Server _myPIServer = _myPISDK.Servers.DefaultServer;
                      PISDK.PIPoint _myPIPoint = _myPIServer.PIPoints["MyTimeStampPoint"];
          
                      PISDK.PIValue _myPIValue = _myPIPoint.Data.Snapshot;
          
                      if (_myPIValue.Value is PISDK.DigitalState)
                      {
                          MessageBox.Show("Digitalstate");
                      }
                      else
                      {
                          if (_myPIValue.Value is PITimeServer.PITime)
                          {
                              PITimeServer.PITime _myPITime = _myPIValue.Value;
                              MessageBox.Show(_myPITime.LocalDate.ToLongTimeString());
                          }
                          else
                          {
                              MessageBox.Show("anything else");
                          }
                      }