7 Replies Latest reply on Aug 31, 2017 7:20 PM by gregor Branched to a new discussion.

    PI Point data getting disappeared after adding through AFSDK

    AniketAmrutkar

      I am trying to upload data to PI Database from a CSV file.

      I have created  a new database, Element Template, Attribute Template

       

      While creating the attribute template...

       

      myAttrTemplate.DataReferencePlugIn = myDB.PISystem.DataReferencePlugIns[“PI Point”];
      myAttrTemplate.ConfigString = $“%Server%.{databaseName}.%Element%.%Attribute%;ReadOnly=False;ptclassname=classic;pointtype=Float64";
      myAttrTemplate.ElementTemplate.CheckIn();
      
      For each row(i)
      {
               While creating the Elements...
               AFElement myElement = myDB.Elements.Add(element1);
      
               For each column of CSV
               {
                         Creating the PI point...
                        AFAttribute myAttribute = myElement.Attributes[i];
                        myAttribute.DataReference.CreateConfig();
                        myAttribute.Data.UpdateValue((new AFValue(value[i], dtDateTime)),AFUpdateOption.Insert);
               }
      }
      
      myDB.Checkin();
      

       

       

      The problem I am facing is the data Time series data disappears after sometime only the last uploaded data remains.

        • Re: PI Point data getting disappeared after adding through AFSDK
          Rick Davin

          Hi Aniket,

           

          What do you mean disappeared?  Was there historical data before you called CreateConfig, and now it's gone?  If so, please refer to:

           

          1349OSI8 - How to change PI Point Type in the PI Server and retain history

           

          I question the use of pointtype=Float64.  I'd recommend changing that to Float32.

            • Re: PI Point data getting disappeared after adding through AFSDK
              AniketAmrutkar

              After I looped through the whole CSV file, and update the value using UpdateValue, data was there.

              But when I checked after some time, I only found the last data point in the PITag.

                • Re: PI Point data getting disappeared after adding through AFSDK
                  Rick Davin

                  Tell me more about your CSV file. 

                   

                  I presume each row begins with a timestamp in the first column.  What does the timestamp string look like?  Is it local or does it have timezone info in the string?  Is your dtDateTime variable a DateTime or AFTime object?  If it's a DateTime object, have your correctly set the Kind?

                   

                  Could you show a few sample rows of your CSV?  By all means obfuscate the attribute or tag names if you must.

                   

                  Granted your code snippet is Psuedo-Code, but I don't see where you set columns.  You use index variable [i] for each row to set the attribute as well as value.  Where's the column index set?

                   

                  It could also help if you could post the actual relevant code.

                    • Re: PI Point data getting disappeared after adding through AFSDK
                      AniketAmrutkar

                      Here are some rows from my CSV file

                       

                      time,bus,L1,L2,L3

                      2011-01-03T18:16:00Z,bus1,8.95,37.96,42.91

                      2011-01-03T21:57:00Z,bus2,9.75,32.46,52.91

                       

                      Time is in DateTime format, local time zone. i stands for row number

                      value contains all column of row

                       

                      For each row(i) 

                              While creating the Elements... 

                              AFElement myElement = myDB.Elements.Add(value[1]);  //value[1]-> bus1,bus2...

                       

                              For each column of CSV  (j-> 2 to 4)

                              { 

                                       //Creating the PI point... 

                                       var dtDateTime = DateTime.ParseExact(value[0], “yyyy-MM-ddTHH:mm:ssZ”, System.Globalization.CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind);

                                       AFAttribute myAttribute = myElement.Attributes[j-2]; 

                                       myAttribute.DataReference.CreateConfig(); 

                                       myAttribute.Data.UpdateValue((new AFValue(value[j], dtDateTime)),AFUpdateOption.Insert);   //value[j]-> attribute values .e. 8.95,37.96

                              } 

                      }

                        • Re: PI Point data getting disappeared after adding through AFSDK
                          gregor

                          Hello Aniket,

                           

                          PI Archive Subsystem doesn't have a target for the data you are sending if there is no archive registered covering the event timestamps. This is a common issue where you would see the data flowing e.g. using at a trend in PI ProcessBook but afterwards disappearing. In this scenario PI ProcessBook receives its updates through a sign-up with PI Update Manager for snapshot updates. The data is received by PI Network Manager, processed by PI Snapshot Subsystem which shares the "news" with PI Update Manager to allow efficient client updates. However, PI Archive Subsystem needs to drop the events with no archive file online and this is why you would see the values disappearing e.g. when refreshing the display.

                           

                          Can you please verify if the above described scenario is what you are experiencing?

                          1 of 1 people found this helpful