示例#1
0
        public override void ParseData(string command)
        {
            var jObject = JObject.Parse(command);

            if (jObject["alarm"] != null && bool.TryParse(jObject["alarm"].ToString(), out bool alarm))
            {
                if (alarm)
                {
                    OnAlarm?.Invoke(this, new EventArgs());
                }
                else
                {
                    OnAlarmStopped?.Invoke(this, new EventArgs());
                }

                Alarm = alarm;
            }

            if (jObject["density"] != null && float.TryParse(jObject["density"].ToString(), out float h))
            {
                var newDensity = h / 100;

                if (Density != null && Math.Abs(newDensity - Density.Value) > 0.01)
                {
                    OnDensityChange?.Invoke(this, new DensityEventArgs(newDensity));
                }

                Density = newDensity;
            }

            if (jObject["voltage"] != null && float.TryParse(jObject["voltage"].ToString(), out float v))
            {
                Voltage = v / 1000;
            }
        }
示例#2
0
        public override void ParseData(string command)
        {
            var jObject = JObject.Parse(command);

            if (jObject.ParseInt("alarm", out int alarm))
            {
                Alarm = alarm == 1;

                if (Alarm)
                {
                    OnAlarm?.Invoke(this, new EventArgs());
                }
                else
                {
                    OnAlarmStopped?.Invoke(this, new EventArgs());
                }
            }

            if (jObject.ParseFloat("density", out float h))
            {
                var newDensity = h / 100;

                if (Density != null && Math.Abs(newDensity - Density.Value) > 0.01)
                {
                    OnDensityChange?.Invoke(this, new DensityEventArgs(newDensity));
                }

                Density = newDensity;
            }

            Voltage = jObject.ParseVoltage();
        }
示例#3
0
 void m_Timer_Elapsed(object sender, ElapsedEventArgs e)
 {
     if (Active && OnAlarm != null)
     {
         OnAlarm.Invoke(this, EventArgs.Empty);
     }
 }
示例#4
0
        private void Counter()
        {
            Task.Factory.StartNew(() =>
            {
                ShowAlarmTime();

                do
                {
                    ShowCurrentTime();
                    //Sleep for one second
                    Thread.Sleep(1000);
                    //And increment our inner counter
                    _currentTime += 1;

                    if (_alarmTime == _currentTime)
                    {
                        OnAlarm?.Invoke();
                    }
                } while (true);
            });
        }
示例#5
0
 void Alarm()
 {
     OnAlarm?.Invoke(this, new EventArgs());
 }