wei
2021-09-24 4820da229822687e472b9d5abb2a09093a877a3a
HDL_ON/DAL/DriverLayer/Control_Udp.cs
@@ -297,7 +297,7 @@
                            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)
@@ -366,6 +366,7 @@
                            }
                            break;
                        case SPK.ElectricSocket:
                        case SPK.PanelSocket:
                            foreach (var attr in f.status)
                            {
                                if (attr.key == FunctionAttributeKey.OnOff)
@@ -432,12 +433,10 @@
                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))
                                {
@@ -462,8 +461,10 @@
                                            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))
                                {
@@ -489,8 +490,10 @@
                                            (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))
                                {
@@ -511,30 +514,30 @@
                                            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:
@@ -548,16 +551,8 @@
                                }
                                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)
@@ -599,15 +594,9 @@
                                            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)
@@ -651,15 +640,15 @@
                                    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"))
                                        {
@@ -684,17 +673,14 @@
                                            }
                                        }
                                        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)) });
@@ -702,16 +688,14 @@
                                {
                                    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:金茂新风
@@ -783,8 +767,7 @@
                                    //function.GetAttrState(FunctionAttributeKey.FilterTimeout) =="true"?1:0,
                                    0,0
                                });
                                break;
                        }
                        #endregion
                        break;
                }
                #region 发送命令立即更新UI
@@ -811,9 +794,6 @@
                var deviceId = function.bus.DeviceID;
                var loopId = function.bus.LoopId;
                switch (function.Spk_Prefix)
                {
                    case FunctionCategory.Light:
                        switch (function.spk)
                        {
                            case SPK.LightSwitch:
@@ -826,74 +806,43 @@
                            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;
                }
            }