| | |
| | | break; |
| | | case SPK.LightRGB: |
| | | break; |
| | | case SPK.FloorHeatStandard: |
| | | case SPK.HvacFloorHeat:case SPK.FloorHeatStandard: |
| | | if (f.status.Find((obj)=>obj.key ==FunctionAttributeKey.Mode) == null) |
| | | { |
| | | foreach (var dic in f.status) |
| | |
| | | } |
| | | break; |
| | | case SPK.ElectricSocket: |
| | | case SPK.PanelSocket: |
| | | foreach (var attr in f.status) |
| | | { |
| | | if (attr.key == FunctionAttributeKey.OnOff) |
| | |
| | | var deviceId = function.bus.DeviceID; |
| | | var loopId = function.bus.LoopId; |
| | | |
| | | switch (function.Spk_Prefix) |
| | | { |
| | | case FunctionCategory.Light: |
| | | switch (function.spk) |
| | | { |
| | | case SPK.LightCCT: |
| | | #region cct light |
| | | byte b0 = 100; |
| | | if (commandDictionary.ContainsKey(FunctionAttributeKey.OnOff)) |
| | | { |
| | |
| | | 0, |
| | | 0,0}; |
| | | ControlBytesSend(Command.SetLogicLoopColor, subnetId, deviceId, bytes0, 1); |
| | | #endregion |
| | | break; |
| | | case SPK.LightRGB: |
| | | #region rgb light |
| | | byte b = 100; |
| | | if (commandDictionary.ContainsKey(FunctionAttributeKey.OnOff)) |
| | | { |
| | |
| | | (byte)tempLight.GetColor(2,function), |
| | | 0,0}; |
| | | ControlBytesSend(Command.SetLogicLoopColor, subnetId, deviceId, bytes, 1); |
| | | #endregion |
| | | break; |
| | | case SPK.LightDimming: |
| | | #region dimming light |
| | | byte b1 = 100; |
| | | if (commandDictionary.ContainsKey(FunctionAttributeKey.OnOff)) |
| | | { |
| | |
| | | function.bus.LoopId, |
| | | b1, |
| | | 0, Convert.ToByte(function.GetAttrState(FunctionAttributeKey.FadeTime)) }); |
| | | #endregion |
| | | break; |
| | | case SPK.LightSwitch: |
| | | #region LightSwitch |
| | | ControlBytesSend(Command.SetSingleLight, subnetId, deviceId, new byte[] { function.bus.LoopId, function.trait_on_off.curValue.ToString() == "on" ? (byte)100 : (byte)0, 0, 0 }); |
| | | #endregion |
| | | break; |
| | | } |
| | | break; |
| | | case FunctionCategory.Curtain: |
| | | switch (function.spk) |
| | | { |
| | | case SPK.CurtainSwitch: |
| | | byte b1 = 0; |
| | | #region switch curtain |
| | | byte switchCurtain = 0; |
| | | if (function.trait_on_off.curValue.ToString() == "stop") |
| | | { |
| | | b1 = 0; |
| | | switchCurtain = 0; |
| | | } |
| | | else if (function.trait_on_off.curValue.ToString() == "on") |
| | | { |
| | | b1 = 1; |
| | | switchCurtain = 1; |
| | | } |
| | | else |
| | | { |
| | | b1 = 2; |
| | | switchCurtain = 2; |
| | | } |
| | | ControlBytesSend(Command.SetCurtainModelStutas, subnetId, deviceId, new byte[] { function.bus.LoopId, b1 }); |
| | | ControlBytesSend(Command.SetCurtainModelStutas, subnetId, deviceId, new byte[] { function.bus.LoopId, switchCurtain }); |
| | | #endregion |
| | | break; |
| | | case SPK.CurtainTrietex: |
| | | case SPK.CurtainRoller: |
| | |
| | | |
| | | } |
| | | break; |
| | | } |
| | | break; |
| | | case FunctionCategory.AC: |
| | | switch (function.spk) |
| | | { |
| | | case SPK.AcStandard: |
| | | var ac = new AC(); |
| | | //ControlBytesSend(Command.SetACMode, subnetId, deviceId, new byte[] { function.bus.LoopId, 0, 32, 32, 32, 32, 32, 0, function.trait_on_off.curValue.ToString() == "on" ? (byte)1 : (byte)0, |
| | | // ac.GetModeIndex(function), |
| | | // ac.GetFanIndex(function), Convert.ToByte(function.GetAttrState(FunctionAttributeKey.SetTemp)), 0 }); |
| | | foreach (var dic in commandDictionary) |
| | | { |
| | | switch (dic.Key) |
| | |
| | | break; |
| | | } |
| | | } |
| | | |
| | | break; |
| | | } |
| | | break; |
| | | case FunctionCategory.FloorHeat: |
| | | case SPK.HvacFloorHeat:case SPK.FloorHeatStandard: |
| | | var fhTemp = new FloorHeating(); |
| | | switch (function.spk) |
| | | { |
| | | case SPK.FloorHeatStandard: |
| | | if (function.Fh_Mode_Temp.Count == 4) |
| | | { |
| | | if (function.GetAttribute(FunctionAttributeKey.Mode) == null) |
| | |
| | | else |
| | | { |
| | | var onoffString = function.trait_on_off.curValue.ToString(); |
| | | byte b1 = 1; |
| | | byte b12 = 1; |
| | | if (onoffString == "off") |
| | | { |
| | | b1 = 0; |
| | | b12 = 0; |
| | | } |
| | | var wm = fhTemp.GetWorkModeIndex(function); |
| | | if (wm > 0) |
| | | { |
| | | b1 += (byte)(16 + wm); |
| | | b12 += (byte)(16 + wm); |
| | | } |
| | | if (commandDictionary.ContainsKey("set_temp")) |
| | | { |
| | |
| | | } |
| | | } |
| | | var tt = fhTemp.GetTempUintIndex(function); |
| | | ControlBytesSend(Command.SetFloorHeat, subnetId, deviceId, new byte[] { function.bus.LoopId, b1, |
| | | ControlBytesSend(Command.SetFloorHeat, subnetId, deviceId, new byte[] { function.bus.LoopId, b12, |
| | | (byte)tt,fhTemp.GetModeIndex(function), function.Fh_Mode_Temp["normal"], function.Fh_Mode_Temp["day"], function.Fh_Mode_Temp["night"], function.Fh_Mode_Temp["away"], 0, 0 }); |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | break; |
| | | case FunctionCategory.Electric: |
| | | switch (function.spk) |
| | | { |
| | | case SPK.HvacFan: |
| | | case SPK.ElectricFan: |
| | | #region ElectricFan |
| | | if (function.trait_on_off.curValue.ToString() == "on") |
| | | { |
| | | ControlBytesSend(Command.SetSingleLight, subnetId, deviceId, new byte[] { function.bus.LoopId, Convert.ToByte(function.GetAttrState(FunctionAttributeKey.OpenLevel)) }); |
| | |
| | | { |
| | | ControlBytesSend(Command.SetSingleLight, subnetId, deviceId, new byte[] { function.bus.LoopId, 0 }); |
| | | } |
| | | #endregion |
| | | break; |
| | | case SPK.ElectricSocket: |
| | | case SPK.PanelSocket: |
| | | ControlBytesSend(Command.SetSingleLight, subnetId, deviceId, new byte[] { function.bus.LoopId, function.trait_on_off.curValue.ToString() == "on" ? (byte)100 : (byte)0 }); |
| | | break; |
| | | } |
| | | break; |
| | | case FunctionCategory.AirFresh: |
| | | switch(function.spk) |
| | | { |
| | | case SPK.AirFreshJinmao: |
| | | case SPK.AirFreshJinmao:case SPK.HvacAirFreshJinmao: |
| | | #region AirFresh |
| | | //1 新风编号 1~200 |
| | | //2 类型 第三方类型 0:金茂新风 |
| | | |
| | |
| | | //function.GetAttrState(FunctionAttributeKey.FilterTimeout) =="true"?1:0, |
| | | 0,0 |
| | | }); |
| | | break; |
| | | } |
| | | #endregion |
| | | break; |
| | | } |
| | | #region 发送命令立即更新UI |
| | |
| | | var deviceId = function.bus.DeviceID; |
| | | var loopId = function.bus.LoopId; |
| | | |
| | | switch (function.Spk_Prefix) |
| | | { |
| | | case FunctionCategory.Light: |
| | | switch (function.spk) |
| | | { |
| | | case SPK.LightSwitch: |
| | |
| | | case SPK.LightCCT: |
| | | ControlBytesSend(Command.ReadLogicLoopColor, subnetId, deviceId, new byte[] { function.bus.LoopId }); |
| | | break; |
| | | } |
| | | break; |
| | | case FunctionCategory.Curtain: |
| | | switch (function.spk) |
| | | { |
| | | case SPK.CurtainSwitch: |
| | | case SPK.CurtainTrietex: |
| | | case SPK.CurtainRoller: |
| | | ControlBytesSend(Command.ReadCurtainStatus, subnetId, deviceId, new byte[] { function.bus.LoopId }); |
| | | break; |
| | | } |
| | | break; |
| | | case FunctionCategory.AC: |
| | | switch (function.spk) |
| | | { |
| | | case SPK.AcStandard: |
| | | ControlBytesSend(Command.ReadACMode, subnetId, deviceId, new byte[] { function.bus.LoopId }); |
| | | break; |
| | | } |
| | | break; |
| | | case FunctionCategory.FloorHeat: |
| | | switch (function.spk) |
| | | { |
| | | case SPK.FloorHeatStandard: |
| | | case SPK.HvacFloorHeat:case SPK.FloorHeatStandard: |
| | | ControlBytesSend(Command.ReadFloorHeat, subnetId, deviceId, new byte[] { function.bus.LoopId }); |
| | | break; |
| | | } |
| | | break; |
| | | case FunctionCategory.Electric: |
| | | switch (function.spk) |
| | | { |
| | | case SPK.HvacFan: |
| | | case SPK.ElectricFan: |
| | | ControlBytesSend(Command.SetSingleLight, subnetId, deviceId, new byte[] { function.bus.LoopId }); |
| | | break; |
| | | case SPK.ElectricSocket: |
| | | case SPK.PanelSocket: |
| | | ControlBytesSend(Command.SetSingleLight, subnetId, deviceId, new byte[] { function.bus.LoopId }); |
| | | break; |
| | | } |
| | | break; |
| | | case FunctionCategory.Sensor: |
| | | byte sensorType = 0; |
| | | switch (function.spk) |
| | | { |
| | | case SPK.SensorTemperature: |
| | | sensorType = 2; |
| | | ControlBytesSend(Command.ReadDeviceLoopInfo, subnetId, deviceId, new byte[] { 5, 2, function.bus.LoopId }); |
| | | break; |
| | | case SPK.SensorHumidity: |
| | | sensorType = 3; |
| | | ControlBytesSend(Command.ReadDeviceLoopInfo, subnetId, deviceId, new byte[] { 5, 3, function.bus.LoopId }); |
| | | break; |
| | | case SPK.SensorTVOC: |
| | | sensorType = 5; |
| | | ControlBytesSend(Command.ReadDeviceLoopInfo, subnetId, deviceId, new byte[] { 5, 5, function.bus.LoopId }); |
| | | break; |
| | | case SPK.SensorPm25: |
| | | sensorType = 6; |
| | | ControlBytesSend(Command.ReadDeviceLoopInfo, subnetId, deviceId, new byte[] { 5, 6, function.bus.LoopId }); |
| | | break; |
| | | case SPK.SensorCO2: |
| | | sensorType = 7; |
| | | ControlBytesSend(Command.ReadDeviceLoopInfo, subnetId, deviceId, new byte[] { 5, 7, function.bus.LoopId }); |
| | | break; |
| | | } |
| | | ControlBytesSend(Command.ReadDeviceLoopInfo, subnetId, deviceId, new byte[] { 5, sensorType, function.bus.LoopId }); |
| | | break; |
| | | case FunctionCategory.AirFresh: |
| | | switch(function.spk) |
| | | { |
| | | case SPK.AirFreshJinmao: |
| | | case SPK.HvacAirFreshJinmao: |
| | | ControlBytesSend(Command.FreshAirRead_JinMao, subnetId, deviceId, new byte[] { function.bus.LoopId }); |
| | | break; |
| | | } |
| | | break; |
| | | } |
| | | } |