示例#1
0
        public DigitalOutputInstance(ushort ObjectInstanceId, ushort InstanceId, bool?CurrentState, string ApplicationType)
            : base(ObjectInstanceId, InstanceId)
        {
            this.state = new Lwm2mResourceBoolean("Digital Output State", ObjectInstanceId, InstanceId, 5550, true, false, CurrentState);

            if (ApplicationType != null)
            {
                this.applicationType = new Lwm2mResourceString("Application Type", ObjectInstanceId, InstanceId, 5750, true, true, ApplicationType);
            }

            this.state.OnRemoteUpdate += (sender, e) =>
            {
                this.state.TriggerAll();
                this.TriggerAll();

                try
                {
                    this.OnRemoteUpdate?.Invoke(this, e);
                }
                catch (Exception ex)
                {
                    Log.Critical(ex);
                }
            };

            this.Add(this.state);

            if (this.applicationType != null)
            {
                this.Add(this.applicationType);
            }
        }
示例#2
0
        public AnalogInputInstance(ushort InstanceId, double?CurrentValue, double MinRange, double MaxRange, string ApplicationType, string SensorType)
            : base(3202, InstanceId)
        {
            this.current         = new Lwm2mResourceDouble("Analog Input Current Value", 3202, InstanceId, 5600, false, false, CurrentValue);
            this.min             = new Lwm2mResourceDouble("Min Measured Value", 3202, InstanceId, 5601, false, false, CurrentValue);
            this.max             = new Lwm2mResourceDouble("Max Measured Value", 3202, InstanceId, 5602, false, false, CurrentValue);
            this.minRange        = new Lwm2mResourceDouble("Min Range Value", 3202, InstanceId, 5603, false, false, MinRange);
            this.maxRange        = new Lwm2mResourceDouble("Max Range Value", 3202, InstanceId, 5604, false, false, MaxRange);
            this.resetMinMax     = new Lwm2mResourceCommand("Reset Min and Max Measured Values", 3202, InstanceId, 5605);
            this.applicationType = new Lwm2mResourceString("Application Type", 3202, InstanceId, 5750, true, true, ApplicationType);
            this.sensorType      = new Lwm2mResourceString("Sensor Type", 3202, InstanceId, 5751, false, false, SensorType);

            this.resetMinMax.OnExecute += (sender, e) =>
            {
                this.min.DoubleValue = this.current.DoubleValue;
                this.min.TriggerAll();

                this.max.DoubleValue = this.current.DoubleValue;
                this.max.TriggerAll();

                this.TriggerAll();
            };

            this.Add(this.current);
            this.Add(this.min);
            this.Add(this.max);
            this.Add(this.minRange);
            this.Add(this.maxRange);
            this.Add(this.resetMinMax);
            this.Add(this.applicationType);
            this.Add(this.sensorType);
        }
示例#3
0
        public ActuationInstance(ushort ObjectInstanceId, ushort InstanceId, bool?CurrentState, string ApplicationType)
            : base(ObjectInstanceId, InstanceId)
        {
            this.onOff  = new Lwm2mResourceBoolean("On/Off", ObjectInstanceId, InstanceId, 5850, true, false, CurrentState);
            this.onTime = new Lwm2mResourceInteger("On Time", ObjectInstanceId, InstanceId, 5852, true, false, 0, false);

            if (ApplicationType != null)
            {
                this.applicationType = new Lwm2mResourceString("Application Type", ObjectInstanceId, InstanceId, 5750, true, true, ApplicationType);
            }

            this.onOff.OnRemoteUpdate += (sender, e) =>
            {
                this.onOff.TriggerAll();
                this.TriggerAll();

                try
                {
                    this.OnRemoteUpdate?.Invoke(this, e);
                }
                catch (Exception ex)
                {
                    Log.Critical(ex);
                }
            };

            this.onTime.OnBeforeGet += (sender, e) =>
            {
                if (this.onOff.BooleanValue.HasValue && this.onOff.BooleanValue.Value)
                {
                    this.onTime.IntegerValue = (long)((DateTime.Now - this.lastSet).TotalSeconds + 0.5);
                }
                else
                {
                    this.onTime.IntegerValue = 0;
                }
            };

            this.onTime.OnRemoteUpdate += (sender, e) =>
            {
                if (this.onTime.IntegerValue.HasValue)
                {
                    this.lastSet = DateTime.Now.AddSeconds(-this.onTime.IntegerValue.Value);
                }
                else
                {
                    this.lastSet = DateTime.Now;
                }
            };

            this.Add(this.onOff);
            this.Add(this.onTime);

            if (this.applicationType != null)
            {
                this.Add(this.applicationType);
            }
        }
示例#4
0
        public GenericSensorInstance(ushort ObjectInstanceId, ushort InstanceId, double?CurrentValue, string Unit, double MinRange, double MaxRange, string ApplicationType, string SensorType)
            : base(ObjectInstanceId, InstanceId)
        {
            this.current     = new Lwm2mResourceDouble("Sensor Value", ObjectInstanceId, InstanceId, 5700, false, false, CurrentValue);
            this.unit        = new Lwm2mResourceString("Unit", ObjectInstanceId, InstanceId, 5701, false, false, Unit);
            this.min         = new Lwm2mResourceDouble("Min Measured Value", ObjectInstanceId, InstanceId, 5601, false, false, CurrentValue);
            this.max         = new Lwm2mResourceDouble("Max Measured Value", ObjectInstanceId, InstanceId, 5602, false, false, CurrentValue);
            this.minRange    = new Lwm2mResourceDouble("Min Range Value", ObjectInstanceId, InstanceId, 5603, false, false, MinRange);
            this.maxRange    = new Lwm2mResourceDouble("Max Range Value", ObjectInstanceId, InstanceId, 5604, false, false, MaxRange);
            this.resetMinMax = new Lwm2mResourceCommand("Reset Min and Max Measured Values", ObjectInstanceId, InstanceId, 5605);

            if (ApplicationType != null)
            {
                this.applicationType = new Lwm2mResourceString("Application Type", ObjectInstanceId, InstanceId, 5750, true, true, ApplicationType);
            }

            if (SensorType != null)
            {
                this.sensorType = new Lwm2mResourceString("Sensor Type", ObjectInstanceId, InstanceId, 5751, false, false, SensorType);
            }

            this.resetMinMax.OnExecute += (sender, e) =>
            {
                this.min.DoubleValue = this.current.DoubleValue;
                this.min.TriggerAll();

                this.max.DoubleValue = this.current.DoubleValue;
                this.max.TriggerAll();

                this.TriggerAll();
            };

            this.Add(this.current);
            this.Add(this.unit);
            this.Add(this.min);
            this.Add(this.max);
            this.Add(this.minRange);
            this.Add(this.maxRange);
            this.Add(this.resetMinMax);

            if (this.applicationType != null)
            {
                this.Add(this.applicationType);
            }

            if (this.sensorType != null)
            {
                this.Add(this.sensorType);
            }
        }
示例#5
0
        public DigitalInputInstance(ushort ObjectInstanceId, ushort InstanceId, bool?CurrentState, string ApplicationType, string SensorType)
            : base(ObjectInstanceId, InstanceId)
        {
            this.state        = new Lwm2mResourceBoolean("Digital Input State", ObjectInstanceId, InstanceId, 5500, false, false, CurrentState);
            this.counter      = new Lwm2mResourceInteger("Digital Input Counter", ObjectInstanceId, InstanceId, 5501, false, false, 0, false);
            this.counterReset = new Lwm2mResourceCommand("Digital Input Counter Reset", ObjectInstanceId, InstanceId, 5505);

            if (ApplicationType != null)
            {
                this.applicationType = new Lwm2mResourceString("Application Type", ObjectInstanceId, InstanceId, 5750, true, true, ApplicationType);
            }

            if (SensorType != null)
            {
                this.sensorType = new Lwm2mResourceString("Sensor Type", ObjectInstanceId, InstanceId, 5751, false, false, SensorType);
            }

            this.counterReset.OnExecute += (sender, e) =>
            {
                this.counter.IntegerValue = 0;
                this.counter.TriggerAll();
                this.TriggerAll();
            };

            this.Add(this.state);
            this.Add(this.counter);
            this.Add(this.counterReset);

            if (this.applicationType != null)
            {
                this.Add(this.applicationType);
            }

            if (this.sensorType != null)
            {
                this.Add(this.sensorType);
            }
        }