AnsweredAssumed Answered

PIPoint.UpdateValue could create data, the these data will disappear after a couple minutes...

Question asked by Jiahui07 on Feb 10, 2015
Latest reply on Feb 11, 2015 by Jiahui07

Hi,

Currently I want to transfer some data record from SQL server and create relative PI Tags in PI data archive, and associated values.

Here is the script to create the tags.

                    GasAttributes = new Dictionary<string, object>();
                    GasAttributes.Add("archiving", 1);
                    GasAttributes.Add("pointtype", PIPointType.Float32);
                    GasAttributes.Add("compressing", 0);
                    GasAttributes.Add("compdev", 0);
                    GasAttributes.Add("compdevpercent", 0);
                    GasAttributes.Add("displaydigits", 5);
                    GasAttributes.Add("excdev", 0);
                    GasAttributes.Add("excdevpercent", 0);
                    GasAttributes.Add("step", 0);
                    GasAttributes.Add("span", 1000000);
                    GasAttributes.Add("compmax", 28800);
                    GasAttributes.Add("compmin", 0);
                    GasAttributes.Add("convers", 1);
                    GasAttributes.Add("excmax", 600);
                    GasAttributes.Add("excmin", 0);
                    GasAttributes.Add("filtercode", 0);
                    GasAttributes.Add("location1", 0);
                    GasAttributes.Add("location2", 0);
                    GasAttributes.Add("location3", 0);
                    GasAttributes.Add("location4", 0);
                    GasAttributes.Add("location5", 0);
                    GasAttributes.Add("pointsource", "LAB");
                    GasAttributes.Add("ptclassname", "classic");
                    GasAttributes.Add("scan", 0);
                    GasAttributes.Add("shutdown", 0);
                    GasAttributes.Add("squareroot", 0);
                    GasAttributes.Add("srcptid", 0);
                    GasAttributes.Add("totalcode", 0);
                    GasAttributes.Add("typicalvalue", 50);
                    GasAttributes.Add("userint1", 0);
                    GasAttributes.Add("userint2", 0);
                    GasAttributes.Add("userreal1", 0);
                    GasAttributes.Add("userreal2", 0);
                    GasAttributes.Add("zero", 0);

                    if (!PIPoint.TryFindPIPoint(piServer, GasPITag, out myPIPoint))
                    {
                        myPIPoint = piServer.CreatePIPoint(GasPITag, GasAttributes);
                        Console.WriteLine("PI tag {0} is created!", GasPITag);
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Fail to create PI Point, PI Point {0} already exists!", GasPITag);
                        Console.ResetColor();
                    }

The PI tag can be successfully created, and after I use the following script to transfer the data from SQL to PI, it would work.

               if (PIPoint.TryFindPIPoint(piServer, GasTag, out myPIPoint))
                {
                    AFValue myValue;
                    while (myReader.Read())
                    {
                        myValue = new AFValue(Convert.ToSingle(myReader[tableColName]));
                        DateTime timestamp = Convert.ToDateTime(myReader["SAMPLE_DATE"]);
                        myValue.Timestamp = new AFTime(timestamp.ToUniversalTime());
                        myPIPoint.UpdateValue(myValue, AFUpdateOption.Insert);
                    }
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("PI tag {0} not found!", GasTag);
                    Console.ResetColor();
                    return;
                }

We can see the effectiveness of the script by searching it using SMT.

1.PNG

However after several minutes, the values just disappeared and only the last one exist!!!

2.PNG

 

Anyone have the same problem or have some suggestions? Is it related to some attributes in the PI tags?

Thanks for your help.

Jason

Outcomes