Ejemplo n.º 1
0
        public static void GetHistory(TimeSeriesBlock tsb)
        {
            Console.WriteLine("Read OPC UA Historical Data:");
            try
            {
                ErrorMessage         = "";
                startTime            = tsb.opcLastTimeStamp;
                endTime              = DateTime.UtcNow + TimeSpan.FromMinutes(120);
                tsb.opcLastTimeStamp = endTime;
                if (session == null)
                {
                    Connect(tsb);
                }
                GetData(tsb);
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
                session?.Close();
                session?.Dispose();
                session = null;
                opc     = null;
            }

            /*
             * session?.Close();
             * session?.Dispose();
             * session = null;
             */
        }
Ejemplo n.º 2
0
 public static void Connect(TimeSeriesBlock tsb)
 {
     if (opc == null)
     {
         opc = new UASampleClient(tsb.sourceAddress, true, 10000, tsb.username, tsb.password);
     }
     opc.ConsoleSampleClient().Wait();
     session = opc.session;
 }