JLChen
2020-02-28 9137222ece9b978eb97b5598f2eee6e070bcf9d6
Crabtree/SmartHome/UI/SimpleControl/Phone/Light/UserDeviceToLight.cs
@@ -249,6 +249,7 @@
            System.Threading.Tasks.Task.Run (() => {
                try {
                    int mSendCount = 0;
                    foreach (var room in Room.Lists) {
                        if (room == null)
                            continue;
@@ -256,9 +257,14 @@
                            continue;
                        }
                        foreach (var common in room.DeviceList) {
                            byte [] returnBytes = null;
                            if (common.Type == DeviceType.LightDimming || common.Type == DeviceType.LightSwitch || common.Type == DeviceType.LightRGB || common.Type == DeviceType.LightEnergySwitch
                                || common.Type == DeviceType.LightMixDimming || common.Type == DeviceType.LightMixSwitch || common.Type == DeviceType.LightDALI) {
                               new System.Threading.Thread (() => {
                                   mSendCount++;
                                if (common.Type == DeviceType.LightDimming || common.Type == DeviceType.LightDALI) {
                                    var light = (LightDimming)common;
                                    if (b == 100) {
@@ -294,7 +300,7 @@
                                    var light = (LightMixSwitch)common;
                                    returnBytes = Control.ControlBytesSendHasReturn (Command.SetSingleLight, common.SubnetID, common.DeviceID, new byte [] { light.PhysicsLoopID, b, light.DelayTimeHeight, light.DelayTimeLow });
                                } else {
                                    continue;
                                       returnBytes = new byte [] { 0x00 };
                                }
                                if (showTip) {
                                    if (returnBytes == null) {
@@ -325,9 +331,26 @@
                                        });
                                    }
                                }
                                   mSendCount--;
                               }) { IsBackground = true }.Start();
                                //等待100ms再发送第二个设备数据
                                System.Threading.Thread.Sleep (100);
                            }
                            }
                        }
                    while (mSendCount > 0) {
                        System.Threading.Thread.Sleep (100);
                    }
                } catch {
                    Console.WriteLine ("controlAllLight catch");
                } finally {
@@ -338,6 +361,7 @@
                }
            });
        }
        /// <summary>
        /// 通过设备类型方式选择设备
        /// </summary>