AnsweredAssumed Answered

c# SDK how to get the time from a specific pi tag value.

Question asked by ohuerta on Nov 20, 2018
Latest reply on Nov 21, 2018 by Eugene Lee

Hello i have the following code and i wanted to know if there is a way to adapt the code to show the time of the tag value that i selected.

  public void BUSQUEDA_TAG(string tag)
            PISDK.PISDK sdk = new PISDK.PISDK();
            PISDK.Server myServer = sdk.Servers["PISERVER"];
            PISDK.PIPoints myPoints = myServer.PIPoints;
            PISDK.PIPoint punto = myPoints[tag];
            String startTime = VariablesGlobales.VariableFecha + " 00:00:00"; //si esto falla cambiar el formato de fecha a mm/dd/aaaa
            String endTime =  VariablesGlobales.VariableFecha + " 23:59:59";
            PISDK.PIValues vals = punto.Data.RecordedValues(startTime, endTime);
            //PISDK.PIValue vals = punto.tim
            double mw_Total = 0, valor;
            String valorT;
            var valueList = new List<double>();

            foreach (PISDK.PIValue val in vals)
                valorT = Convert.ToString(val.Value);
                double t;

                if (double.TryParse(valorT, out t))
                    valor = Convert.ToDouble(valorT);
                    mw_Total = mw_Total + valor / 2;

         string resultado = valueList.Max().ToString();
            VariablesGlobales.Variable1 = resultado;

i want to know if there is a way to show the time on wich the max value was recorded