Beispiel #1
0
        private void CycleMeasureCurrent(CancellationToken cancellationToken)
        {
            transport = new Transport(ip, Port);
            transport.Connect();
            commands = new SDM_Commands(transport);


            commands.SetCurrentRange(CurrentType, Range, Units);
            // commands.SetSamples(1);
            // commands.SetIntegration(10);
            // commands.CurrentFiltrOff();

            commands.InitCommand();

            StateConnect = true;
            ConnectEvent?.Invoke(this, new EventArgs());
            while (!cancellationToken.IsCancellationRequested)
            {
                // for(int i = 0; i < 4; i++)
                Current   = commands.ReadMeasValue(5) * multipler;
                Timestamp = (long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
                UpdMeasureResult?.Invoke(this, new EventArgs());
                Thread.Sleep(300);
                //commands.InitCommand();
            }
        }
 private void CycleMeasureCurrent()
 {
     while (!cancellationToken.IsCancellationRequested)
     {
         // Симуляция аварии
         //i++;
         //if (i >= 10)
         //      throw new SDM_ErrException("Прервана связь с прибором АКИП 2101");
         Thread.Sleep(1000);
         //cancellationToken.ThrowIfCancellationRequested();
         double shift = absoluteType ? pressSystem.PressSystemVariables.Barometr * (-1) : rangeMin;
         double span  = rangeMax - rangeMin;
         double point = pressSystem.ConnectState ? (pressSystem.PressSystemVariables.Pressure - shift) / span : shift / span;
         double error = (2 * random.NextDouble() * precision - precision) / 100;
         Current   = (point + error) * 16 + 4;
         Timestamp = (long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
         UpdMeasureResult?.Invoke(this, new EventArgs());
     }
 }