4 Replies Latest reply on Sep 19, 2013 2:04 PM by jamliu

    PISDK - write historical value into PI Points and trigger the associated Alarm Tag

    jamliu

      Hi guys,

       

      I am working on a code to insert the historical value into PI tags, but need to trigger the associated Alarm Tags to be updated when a new "historical" value inserted. Does anyone know how can I insert the historical value through the snapshot so the Alarm Tag can be triggered even though the value's timestamp is older than the current time. From the PI SDK help doc, i found the following description for the UpdateValues(), but not very sure if this is the best way to do this, or should I just update the alarm tag's value through the code whenever a value is inserted to the source tag and be done with it?

       

      Send one or more values (snapshot or archive) to the PI Server.

       

      Thank you.

        • Re: PISDK - write historical value into PI Points and trigger the associated Alarm Tag
          Marcos Vainer Loeff

          Hello James,

           

          To insert a trigger associated to PI Points you need to use Event Pipes. This way, when a snapshot is received an event is raised. Please refer this thread or this one for some examples.

           

          If you want to send a value to PI, you should use the UpdateValue or UpdateValues from PIData object. Below you can find an example:

           
                      PISDK.PISDK sdkroot = new PISDK.PISDK();
                      Server myPIServer = sdkroot.Servers["MARC-PI2012"];
                      PIPoint myPoint = myPIServer.PIPoints["sinusoid"];
                      myPoint.Data.UpdateValue(-10, "*");
          

           

           

          The UpdateValue sends just one value to the PI Server while the UpdateValues can send many values with just a single call. Please refer to the PI SDK Programming reference for the syntax of both methods.

           

          Hope this helps!

            • Re: PISDK - write historical value into PI Points and trigger the associated Alarm Tag
              jamliu

              Hi Marcos,

               

              Thanks for your feedback. It seems I cannot use UpdateValues() to insert the values to the tag where the values' timestamps are prior to the tag's creation time. Is this what I should expected on PI server v1.4.2.445? I thought version 3.4.390+ will take care of the writing the value to the tags prior to the tag's creation time without reprocess the archive?

               

                

               

               

               
              PIValues newPIValues = new PIValues();
              PIErrors pointUpdateError = new PIErrors();  
              PIPoint targetPoint = _myPIServer.PIPoints[tagName];
              
              if (targetPoint != null)
              {
                  newPIValues.ReadOnly = false;
                  for (int x = 0; x < valueList.Count; x++)
                  {
                         newPIValues.Add(valueList[x].timestamp, valueList[x].value.Trim(), null);
                   }
                   newPIValues.ReadOnly = true;
                   pointUpdateError = targetPoint.Data.UpdateValues(newPIValues, DataMergeConstants.dmReplaceDuplicates, null);
              }