Пример #1
0
        /// <summary>
        /// This command allows the irrigation system to be configured accordingly.
        /// </summary>
        /// <param name="node"></param>
        /// <param name="config"></param>
        /// <returns>SDS13781 4.42.8 Irrigation System Config Set Command</returns>
        public static ZWaveMessage SystemConfigSet(ZWaveNode node, IrrigationSystemConfig config)
        {
            var commandBytes = new List <byte>
            {
                (byte)CommandClass.Irrigation,
                (byte)Command.IrrigationSystemConfigSet
            };

            commandBytes.AddRange(config.ToByteArray());
            return(node.SendDataRequest(commandBytes.ToArray()));
        }
Пример #2
0
        public NodeEvent GetEvent(ZWaveNode node, byte[] message)
        {
            NodeEvent nodeEvent = null;
            var       cmdType   = message[1];

            switch (cmdType)
            {
            case (byte)Command.IrrigationSystemInfoReport:
                var value = new IrrigationSystemInfoReport
                {
                    IsMasterValueSupported   = message[2] == 1,
                    TotalNumberOfValves      = message[3],
                    TotalNumberOfValveTables = message[4],
                    ValveTableMaxSize        = message[5]
                };
                nodeEvent = new NodeEvent(node, EventParameter.IrrigationSystemInfoReport, value, 0);
                break;

            case (byte)Command.IrrigationSystemStatusReport:
                var systemStatus = IrrigationSystemStatusReport.Parse(message);
                nodeEvent = new NodeEvent(node, EventParameter.IrrigationSystemStatusReport, systemStatus, 0);
                break;

            case (byte)Command.IrrigationSystemConfigReport:
                var systemConfig = IrrigationSystemConfig.Parse(message);
                nodeEvent = new NodeEvent(node, EventParameter.IrrigationSystemConfigReport, systemConfig, 0);
                break;

            case (byte)Command.IrrigationValveInfoReport:
                var valveInfo = IrrigationValveInfo.Parse(message);
                nodeEvent = new NodeEvent(node, EventParameter.IrrigationValveInfoReport, valveInfo, 0);
                break;

            case (byte)Command.IrrigationValveConfigReport:
                var valveConfig = IrrigationValveConfig.Parse(message);
                nodeEvent = new NodeEvent(node, EventParameter.IrrigationValveConfigReport, valveConfig, 0);
                break;

            case (byte)Command.IrrigationValveTableReport:
                var valveTable = IrrigationValveTable.Parse(message);
                nodeEvent = new NodeEvent(node, EventParameter.IrrigationValveTableReport, valveTable, 0);
                break;
            }
            return(nodeEvent);
        }
        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);
        }