コード例 #1
0
        internal static IrrigationSystemStatusReport Parse(byte[] message)
        {
            var systemStatus = new IrrigationSystemStatusReport
            {
                SystemVoltage = message[2],
                SensorStatus  = (IrrigationSystemSensorStatusMask)message[3]
            };
            var flowValueOffset = 4;
            var flowValue       = ZWaveValue.ExtractValueFromBytes(message, flowValueOffset + 1);

            systemStatus.Flow = flowValue.Value;

            var pressureValueOffset = flowValueOffset + 1 + flowValue.Size;
            var pressureValue       = ZWaveValue.ExtractValueFromBytes(message, pressureValueOffset + 1);

            systemStatus.Pressure = pressureValue.Value;

            var shutOffDurationOffset = pressureValueOffset + 1 + pressureValue.Size;

            systemStatus.ShutoffDuration   = message[shutOffDurationOffset];
            systemStatus.SystemErrorStatus = (IrrigationSystemErrorMask)message[shutOffDurationOffset + 1];
            systemStatus.IsMasterValveOpen = message[shutOffDurationOffset + 2] == 1;
            systemStatus.ValveId           = message[shutOffDurationOffset + 3];

            return(systemStatus);
        }
コード例 #2
0
        internal static IrrigationValveConfig Parse(byte[] message)
        {
            var valveConfig = new IrrigationValveConfig
            {
                UseMasterValve = message[2] == 1,
                ValveId        = message[3],
                NominalCurrentHighThreshold = message[4],
                NominalCurrentLowThreshold  = message[5]
            };

            var maximumFlowValueOffset = 6;
            var maximumFlowValue       = ZWaveValue.ExtractValueFromBytes(message, maximumFlowValueOffset + 1);

            valveConfig.MaximumFlow = maximumFlowValue.Value;

            var flowHighThresholdValueOffset = maximumFlowValueOffset + 1 + maximumFlowValue.Size;
            var flowHighThresholdValue       = ZWaveValue.ExtractValueFromBytes(message, flowHighThresholdValueOffset + 1);

            valveConfig.FlowHighThreshold = flowHighThresholdValue.Value;

            var flowLowThresholdValueOffset = flowHighThresholdValueOffset + 1 + flowHighThresholdValue.Size;
            var flowLowThresholdValue       = ZWaveValue.ExtractValueFromBytes(message, flowLowThresholdValueOffset + 1);

            valveConfig.FlowLowThreshold = flowLowThresholdValue.Value;

            var sensorUsageOffset = flowLowThresholdValueOffset + 1 + flowLowThresholdValue.Size;
            var sensors           = message[sensorUsageOffset];

            valveConfig.UseRainSensor     = (sensors & 0x01) == 1;
            valveConfig.UseMoistureSensor = (sensors & 0x02) == 2;

            return(valveConfig);
        }
コード例 #3
0
        public byte[] ToByteArray()
        {
            var commandBytes = new List <byte> {
                MasterValveDelay
            };

            commandBytes.AddRange(ZWaveValue.GetValueBytes(PressureHighThreshold, 0x00));
            commandBytes.AddRange(ZWaveValue.GetValueBytes(PressureLowThreshold, 0x00));
            commandBytes.Add((byte)SensorPolarity);
            return(commandBytes.ToArray());
        }
コード例 #4
0
ファイル: Thermostat.cs プロジェクト: eburud/HomeGenie
        // all Thermostat command classes use
        //    0x01 for the "set" command (same as Command.BasicSet)
        //    0x02 for the "get" command (same as Command.BasicGet)
        //    0x03 value for the "report" command (that is the same as Command.BasicReport)

        public static ZWaveEvent GetEvent(ZWaveNode node, byte[] message)
        {
            ZWaveEvent nodeEvent = null;
            byte       cmdClass  = message[7];
            byte       cmdType   = message[8];

            if (cmdType == (byte)Command.BasicReport)
            {
                switch (cmdClass)
                {
                case (byte)CommandClass.ThermostatMode:
                    nodeEvent = new ZWaveEvent(node, EventParameter.ThermostatMode, (Thermostat.Mode)message[9], 0);
                    break;

                case (byte)CommandClass.ThermostatOperatingState:
                    nodeEvent = new ZWaveEvent(node, EventParameter.ThermostatOperatingState, message[9], 0);
                    break;

                case (byte)CommandClass.ThermostatFanMode:
                    nodeEvent = new ZWaveEvent(node, EventParameter.ThermostatFanMode, message[9], 0);
                    break;

                case (byte)CommandClass.ThermostatFanState:
                    nodeEvent = new ZWaveEvent(node, EventParameter.ThermostatFanState, message[9], 0);
                    break;

                case (byte)CommandClass.ThermostatHeating:
                    nodeEvent = new ZWaveEvent(node, EventParameter.ThermostatHeating, message[9], 0);
                    break;

                case (byte)CommandClass.ThermostatSetBack:
                    nodeEvent = new ZWaveEvent(node, EventParameter.ThermostatSetBack, message[9], 0);
                    break;

                case (byte)CommandClass.ThermostatSetPoint:
                    ZWaveValue zvalue   = ZWaveValue.ExtractValueFromBytes(message, 11);
                    var        setPoint = GetSetPointData(node);
                    setPoint.Precision = zvalue.Precision;
                    setPoint.Scale     = zvalue.Scale;
                    setPoint.Size      = zvalue.Size;
                    setPoint.Value     = zvalue.Value;
                    dynamic ptype = new ExpandoObject();
                    ptype.Type = (SetPointType)message[9];
                    // convert from Fahrenheit to Celsius if needed
                    ptype.Value = (zvalue.Scale == (int)ZWaveTemperatureScaleType.Fahrenheit ? SensorValue.FahrenheitToCelsius(zvalue.Value) : zvalue.Value);
                    nodeEvent   = new ZWaveEvent(node, EventParameter.ThermostatSetPoint, ptype, 0);
                    break;
                }
            }
            return(nodeEvent);
        }
コード例 #5
0
        public static ZWaveMessage Set(ZWaveNode node, Value ptype, double temperature)
        {
            List <byte> message = new List <byte>();

            message.AddRange(new byte[] {
                (byte)CommandClass.ThermostatSetPoint,
                (byte)Command.ThermostatSetPointSet,
                (byte)ptype
            });
            var setPoint = ThermostatSetPoint.GetSetPointData(node);

            message.AddRange(ZWaveValue.GetValueBytes(temperature, setPoint.Precision, setPoint.Scale, setPoint.Size));
            return(node.SendDataRequest(message.ToArray()));
        }
コード例 #6
0
        public byte[] ToByteArray()
        {
            var commandBytes = new List <byte>
            {
                Convert.ToByte(UseMasterValve),
                UseMasterValve ? (byte)1 : ValveId,
                NominalCurrentHighThreshold,
                NominalCurrentLowThreshold
            };

            commandBytes.AddRange(ZWaveValue.GetValueBytes(MaximumFlow, 0x00));
            commandBytes.AddRange(ZWaveValue.GetValueBytes(FlowHighThreshold, 0x00));
            commandBytes.AddRange(ZWaveValue.GetValueBytes(FlowLowThreshold, 0x00));
            commandBytes.Add((byte)(Convert.ToByte(UseRainSensor) + (Convert.ToByte(UseMoistureSensor) << 1)));
            return(commandBytes.ToArray());
        }
コード例 #7
0
        public NodeEvent GetEvent(ZWaveNode node, byte[] message)
        {
            ZWaveValue zvalue   = ZWaveValue.ExtractValueFromBytes(message, 4);
            var        setPoint = GetSetPointData(node);

            setPoint.Precision = zvalue.Precision;
            setPoint.Scale     = zvalue.Scale;
            setPoint.Size      = zvalue.Size;
            setPoint.Value     = zvalue.Value;
            // convert from Fahrenheit to Celsius if needed
            var ptype = new {
                Type  = (Value)message[2],
                Value = (zvalue.Scale == (int)ZWaveTemperatureScaleType.Fahrenheit ? SensorValue.FahrenheitToCelsius(zvalue.Value) : zvalue.Value)
            };

            return(new NodeEvent(node, EventParameter.ThermostatSetPoint, ptype, 0));
        }
コード例 #8
0
        internal static IrrigationSystemConfig Parse(byte[] message)
        {
            var systemconfig = new IrrigationSystemConfig
            {
                MasterValveDelay = message[2]
            };
            var highPressureThresholdValueOffset = 3;
            var highPressureThresholdValue       = ZWaveValue.ExtractValueFromBytes(message, highPressureThresholdValueOffset + 1);

            systemconfig.PressureHighThreshold = highPressureThresholdValue.Value;

            var lowPressureThresholdValueOffset = highPressureThresholdValueOffset + 1 + highPressureThresholdValue.Size;
            var lowPressureThresholdValue       = ZWaveValue.ExtractValueFromBytes(message, lowPressureThresholdValueOffset + 1);

            systemconfig.PressureLowThreshold = lowPressureThresholdValue.Value;

            var sensorPolarityOffset = lowPressureThresholdValueOffset + 1 + lowPressureThresholdValue.Size;

            systemconfig.SensorPolarity = (IrrigationSensorPolarityMask)message[sensorPolarityOffset];

            return(systemconfig);
        }