JLChen
2020-04-03 be95e839f40eb3ddf64706b60cba6dfcf4fad5e5
Crabtree/SmartHome/UI/SimpleControl/CommonPage.cs
@@ -103,7 +103,7 @@
                    foreach (var bin in usefullBytes) {
                        pushBytesString += bin + ",";
                    }
                    Console.WriteLine (pushBytesString);
                    Utlis.WriteLine (pushBytesString);
#endif
                    if (DeviceList.Find ((l) => { return l.SubnetID == subnetID && l.DeviceID == deviceID; }) != null) {
                        return;
@@ -122,7 +122,7 @@
                            continue;
                        }
                        DeviceType deviceType_wireless = (DeviceType)(usefullBytes [i] * 256 + usefullBytes [i + 1]);
                        Console.WriteLine (deviceType_wireless.ToString ());
                        Utlis.WriteLine (deviceType_wireless.ToString ());
                        if (noRemake || MyEncodingGB2312.GetString (usefullBytes, 2, 20).Trim ('\0') == "") {
                            byte [] ddd = CommonPage.MyEncodingGB2312.GetBytes (deviceType_wireless.ToString () + "-" + subnetID.ToString () + "-" + deviceID.ToString ());
                            byte [] newddd = new byte [20];
@@ -256,7 +256,8 @@
                    }
                    break;
                case Command.SetSingleLightACK:
                    Console.WriteLine ("Command.SetSingleLightACK");
                    //Utlis.WriteLine ($"Command.SetSingleLightACK: subnetID:{subnetID} deviceID:{deviceID} 回路:{usefullBytes [0]}");
                    //Utlis.WriteLine ("Command.SetSingleLightACK");
                    foreach (var room in Room.Lists) {
                        var common = room.DeviceList.Find ((obj) => obj.CommonLoopID == subnetID.ToString () + "_" + deviceID.ToString () + "_" + usefullBytes [0].ToString ());
                        if (common != null) {
@@ -279,7 +280,14 @@
                                    hadBeUpdate = false;
                                (common as LightDimming).CurrentBrightness = usefullBytes [2];
                            } else if (common.Type == DeviceType.FanModule) {
                                //if ((common as FanModule).Switch == usefullBytes [2]) {
                                //    hadBeUpdate = false;
                                //}
                                (common as FanModule).Switch = usefullBytes [2];
                                if (usefullBytes [2] != 0)
                                    (common as FanModule).WindSpeed = usefullBytes [2];
                                //(common as FanModule).Switch = usefullBytes [2];
                            } else if (common.Type == DeviceType.LightMixSwitch) {
                                if ((common as LightMixSwitch).CurrentBrightness == usefullBytes [2])
                                    hadBeUpdate = false;
@@ -312,6 +320,7 @@
                                if (!string.IsNullOrEmpty (room.Name))
                                    UserDeviceToLight.UpdateBrighingCount (updateFlag);
                                if (hadBeUpdate) {
                                    UserRoom.UpdataDeviceStatus (common);
                                    UserLightPage.UpdateStatus (updateFlag, usefullBytes [2]);
                                    UserDeviceToLight.UpdateStatus (updateFlag, usefullBytes [2]);
@@ -350,7 +359,7 @@
                                int dddd = usefullBytes [0] & 0x3F;
                            int dddd = usefullBytes [0] & 0x3F;
                            // 0xXX:公司内部协议对应的序号
                            // common.Type:对应的是编辑软件的序号(没有一一对应,是为了将相近的调整在一起,方便客户使用)
@@ -704,7 +713,7 @@
                            case "DISPMODE":
                                if (7 <= backResult [1].Length) {
                                    music.playMode = int.Parse (backResult [1].Substring (6, 1));
                                    System.Console.WriteLine ("DISPMODE=====" + music.playMode);
                                    Utlis.WriteLine ("DISPMODE=====" + music.playMode);
                                }
                                break;
                            }
@@ -1199,7 +1208,7 @@
                            continue;
                        }
                        deviceType = (DeviceType)(usefullBytes [iReadDeviceModulACK] * 256 + usefullBytes [iReadDeviceModulACK + 1]);
                        Console.WriteLine (deviceType.ToString ());
                        Utlis.WriteLine (deviceType.ToString ());
                        string devcieTempName = MyEncodingGB2312.GetString (usefullBytes, 2, 20).Trim ('\0');
                        if (notHasRemake || MyEncodingGB2312.GetString (usefullBytes, 2, 20).Trim ('\0') == "") {
                            devcieTempName = deviceType.ToString ().Replace (DeviceType.Sensor.ToString (), "") + "-" + deviceID.ToString ();
@@ -1583,7 +1592,7 @@
                        wirelessPanelButtonKey.Name = MyEncodingGB2312.GetString (usefullBytes, 3, 20).Trim ('\0');
                        wirelessPanelButtonKey.Mode = usefullBytes [23];
                        ButtonBkeyModelList.Add (wirelessPanelButtonKey.Mode);
                        System.Console.WriteLine ("读取面板按键:回路号:" + wirelessPanelButtonKey.LoopID + "  模式:" + wirelessPanelButtonKey.Mode);
                        Utlis.WriteLine ("读取面板按键:回路号:" + wirelessPanelButtonKey.LoopID + "  模式:" + wirelessPanelButtonKey.Mode);
                        IO.FileUtils.SaveEquipmentMessage (wirelessPanelButtonKey, wirelessPanelButtonKey.LoopID.ToString ());
                        #endregion
                        break;
@@ -2060,7 +2069,7 @@
                    //01 01 59(+30) 02 0D 03 64 00 01 
                    break;
                case Command.AssignedAddressACK:
                    Console.WriteLine (usefullBytes [0].ToString ());
                    Utlis.WriteLine (usefullBytes [0].ToString ());
                    if (usefullBytes [0] == 3) {
                        dt = DateTime.Now;
                    } else if (usefullBytes [0] == 4) {
@@ -2068,24 +2077,24 @@
                    }
                    break;
                case Command.Remote3thACK:
                    Console.WriteLine (usefullBytes [0]);
                    Utlis.WriteLine (usefullBytes [0]);
                    break;
                case Command.DownloadInfraredACK:
                    string loopID_IM = usefullBytes [0] < 10 ? "0" + usefullBytes [0].ToString () : usefullBytes [0].ToString ();
                    if ((InfraredType)usefullBytes [2] != InfraredType.AC) {
                        if ((InfraredType)usefullBytes [2] == InfraredType.NULL) {
                            Console.WriteLine ("NULL-------------");
                            Utlis.WriteLine ("NULL-------------");
                        }
                        string filePath = "Equipment_InfraredMode_" + subnetID + "_" + deviceID + "_" + loopID_IM;
                        InfraredMode im = Newtonsoft.Json.JsonConvert.DeserializeObject<InfraredMode> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (filePath)));
                        im.InfraredType = (InfraredType)usefullBytes [2];
                        Console.WriteLine (im.InfraredType.ToString () + "------------------------------------------------------");
                        Utlis.WriteLine (im.InfraredType.ToString () + "------------------------------------------------------");
                        IO.FileUtils.SaveEquipmentMessage (im, im.LoopID.ToString ());
                    }
                    break;
                }
            } catch (Exception ex) {
                Console.WriteLine ("Packet_ReceiveEvent:" + ex.ToString ());
                Utlis.WriteLine ("Packet_ReceiveEvent:" + ex.ToString ());
            }
        }
@@ -2176,7 +2185,7 @@
                    outputStream.Flush ();
                }
            } catch (Exception ex) {
                Console.WriteLine ("httpListener_EventHandler" + ex.ToString ());
                Utlis.WriteLine ("httpListener_EventHandler" + ex.ToString ());
            } 
        }