Beispiel #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;
            }
        }
Beispiel #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();
        }