wpurrer

Snippet / Delete all PT - Created Values from Snapshot/Archive

Discussion created by wpurrer on Aug 16, 2011
Latest reply on Jan 16, 2012 by mhamel

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PISDK;


namespace PIMS_RemovePTCreated
{
    class Program
    {
        static void Main(string[] args)
        {
            PISDK.PISDK g_SDK;
            g_SDK = new PISDK.PISDKClass();
            PISDK.Server _Server = g_SDK.Servers["xxxx"];

            PointList points = _Server.GetPoints("Tag='*'");

              int count = points.Count;

              for (int i = 1; i <= count; i++)
              {
                  PIPoint po = points [ i ] ;

                  PIValue pv = po.Data.Snapshot;
                  

                  string sValue;

                  if (pv.Value is PISDK.DigitalState)
                  {
                      sValue = ((PISDK.DigitalState)pv.Value).Name;

                      Console.WriteLine(po.Name + " " + sValue);

                      if (sValue == "Pt Created")
                      {
                          po.Data.RemoveValues(pv.TimeStamp, pv.TimeStamp, DataRemovalConstants.drRemoveFirstOnly);
                      
                      }

                  }
                  else
                  {
                      sValue = pv.Value.ToString();
                      Console.WriteLine(po.Name + " " + sValue);
                  }

                  
              }
        }
    }
}

 

Outcomes