AnsweredAssumed Answered

"Pt Created" event error

Question asked by ibidegain on Jul 19, 2019
Latest reply on Jul 20, 2019 by TimCarmichael

I have the following code that generates a APPCRASH :

 

        public List<PuntoPI> ObtenerPuntosPI(string MascaraPNTNAME, string MascaraPointSource, bool incluirPuntosBorrados)
        {
            PISDK.PISDK MyPISDK = null;
            PISDK.Server PIServer = null;
            PointList puntos = null;
            string consulta = null;
            List<PuntoPI> puntosPI = new List<PuntoPI>();
            PuntoPI aux = null;
            PIValue auxValue = null;

            try
            {
                MyPISDK = new PISDK.PISDK();
                PIServer = MyPISDK.Servers.DefaultServer;
                PIServer.Open();

                if (MascaraPNTNAME == "") MascaraPNTNAME = "*";
                if (MascaraPointSource == "") MascaraPointSource = "*";

                consulta = String.Format("tag = '{0}.*' AND pointsource ='{1}'", MascaraPNTNAME, MascaraPointSource);
                if (!incluirPuntosBorrados) consulta += " AND scan=1";
                puntos = PIServer.GetPoints(consulta, null);

                foreach (PIPoint punto in puntos)
                {
                    Console.WriteLine(punto.Name);
                    if (!incluirPuntosBorrados && punto.Name.Contains(".BORR.")) continue;

                    aux = new PuntoPI();
                    aux.Descripcion = punto.PointAttributes["Descriptor"].Value;
                    aux.PNTNAME = punto.Name;
                    aux.PointSource = punto.PointAttributes["pointsource"].Value;

                    auxValue = punto.Data.Snapshot;

                    if (auxValue.IsGood())
                    {
                        if (punto.PointType == PointTypeConstants.pttypDigital)
                            aux.Valor = auxValue.Value.Name;
                        else
                            aux.Valor = auxValue.Value;

                        aux.Fecha = auxValue.TimeStamp.LocalDate;
                    }
                    else aux.IsGood = false;

                    puntosPI.Add(aux);
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (PIServer != null && PIServer.Connected) PIServer.Close();
            }

            return puntosPI;
        }

 

 

The problems is when the code reach a point where the value is "Pt Created", there the appchash error apears and the program close. I try to find a way to check the value, but as soon as I ask for the snapshot value the program explode.

My PISDK is version 1.4.6 Build 494 from date 19/09/2017
Anyone know how to fix this?

Outcomes