From 83df0ebfbd306d0fb5a51a21a7ef2271c0c507ec Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期二, 09 三月 2021 19:39:26 +0800 Subject: [PATCH] 2021-3-9-1 --- HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/View/SaveView.cs | 3 HDL_ON/UI/UI0-Public/PublicAssmeblyBLL.cs | 2 HDL-ON_Android/Assets/Language.ini | 2 HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/View/TipView.cs | 171 +++++++++++++++++ HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Pir.cs | 19 - HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs | 11 HDL_ON/DAL/Mqtt/MqttClient.cs | 18 + HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs | 121 ++++++++++-- HDL-ON_iOS/Resources/Language.ini | 1 HDL_ON/DAL/Server/NewAPI.cs | 5 HDL_ON/Entity/Function/Function.cs | 4 HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddButton.cs | 61 +++-- HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControl.cs | 24 +- HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControlComplete.cs | 19 + HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirMain.cs | 24 + HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/TipPopView.cs | 4 HDL_ON/Common/R.cs | 2 .vs/HDL_APP_Project/xs/UserPrefs.xml | 48 +++- HDL_ON/DAL/DriverLayer/Control.cs | 2 HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirSend.cs | 13 + HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/View/FailView.cs | 1 HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/DeviceSet.cs | 22 + 22 files changed, 464 insertions(+), 113 deletions(-) diff --git a/.vs/HDL_APP_Project/xs/UserPrefs.xml b/.vs/HDL_APP_Project/xs/UserPrefs.xml index 7afbeeb..ead20b4 100644 --- a/.vs/HDL_APP_Project/xs/UserPrefs.xml +++ b/.vs/HDL_APP_Project/xs/UserPrefs.xml @@ -1,33 +1,47 @@ 锘�<Properties StartupConfiguration="{09712674-2A38-407B-B1E2-560B2C352F9A}|Default"> <MonoDevelop.Ide.ItemProperties.HDL-ON__iOS automaticSigning="False" PreferredExecutionTarget="MonoDevelop.IPhone.IPhoneDeviceTarget.00008020-001674E61438002E" /> - <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs"> + <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/DAL/Server/NewAPI.cs"> <Files> - <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs" Line="45" Column="48" /> - <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirSend.cs" Line="65" Column="23" /> - <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Pir.cs" Line="43" Column="21" /> - <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirMain.cs" Line="21" Column="25" /> - <File FileName="HDL_ON/Entity/Function/Function.cs" /> - <File FileName="HDL_ON/Entity/FunctionList.cs" /> - <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddButton.cs" /> - <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PersonalCenterPageBLL.cs" /> - <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs" Line="199" Column="1" /> - <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControl.cs" /> - <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/DeviceSet.cs" /> + <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs" Line="66" Column="58" /> + <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirSend.cs" Line="68" Column="88" /> + <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Pir.cs" /> + <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirMain.cs" /> + <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs" Line="191" Column="28" /> + <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControl.cs" Line="135" Column="46" /> + <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/DeviceSet.cs" Line="1" Column="1" /> + <File FileName="HDL_ON/DAL/Mqtt/MqttClient.cs" Line="310" Column="1" /> + <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControlComplete.cs" Line="116" Column="21" /> <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/BrandList.cs" /> + <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddButton.cs" Line="136" Column="54" /> + <File FileName="HDL_ON/DAL/Server/NewAPI.cs" Line="327" Column="6" /> </Files> <Pads> <Pad Id="ProjectPad"> <State name="__root__"> <Node name="HDL_APP_Project" expanded="True"> <Node name="HDL_ON" expanded="True"> + <Node name="Common" expanded="True" /> <Node name="DAL" expanded="True"> + <Node name="DriverLayer" expanded="True" /> <Node name="Mqtt" expanded="True" /> + <Node name="Server" expanded="True"> + <Node name="NewAPI.cs" selected="True" /> + </Node> + </Node> + <Node name="Entity" expanded="True"> + <Node name="Function" expanded="True" /> </Node> <Node name="UI" expanded="True"> + <Node name="UI0-Public" expanded="True" /> <Node name="UI2" expanded="True"> + <Node name="3-Intelligence" expanded="True"> + <Node name="Automation" expanded="True"> + <Node name="LogicView" expanded="True" /> + </Node> + </Node> <Node name="4-PersonalCenter" expanded="True"> <Node name="PirDevice" expanded="True"> - <Node name="Matching.cs" selected="True" /> + <Node name="View" expanded="True" /> </Node> </Node> </Node> @@ -35,7 +49,9 @@ </Node> <Node name="HDL-ON_Android" expanded="True"> <Node name="Assets" expanded="True"> - <Node name="Phone" expanded="True" /> + <Node name="Phone" expanded="True"> + <Node name="PirIcon" expanded="True" /> + </Node> </Node> </Node> <Node name="HDL-ON_iOS" expanded="True"> @@ -56,9 +72,7 @@ <MonoDevelop.Ide.ItemProperties.HDL-ON__Android PreferredExecutionTarget="Android.4b65c4650918" /> <MonoDevelop.Ide.DebuggingService.Breakpoints> <BreakpointStore> - <Breakpoint file="/Users/hdl/Desktop/wjc/HDL_APP_Project/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs" relfile="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs" line="199" column="1" /> - <Breakpoint file="/Users/hdl/Desktop/wjc/HDL_APP_Project/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs" relfile="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs" line="195" column="1" /> - <Breakpoint file="/Users/hdl/Desktop/wjc/HDL_APP_Project/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs" relfile="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs" line="188" column="1" /> + <Breakpoint file="/Users/hdl/Desktop/wjc/HDL_APP_Project/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs" relfile="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs" line="323" column="1" /> </BreakpointStore> </MonoDevelop.Ide.DebuggingService.Breakpoints> <MultiItemStartupConfigurations /> diff --git a/HDL-ON_Android/Assets/Language.ini b/HDL-ON_Android/Assets/Language.ini index 9b278ff..0fe8100 100644 --- a/HDL-ON_Android/Assets/Language.ini +++ b/HDL-ON_Android/Assets/Language.ini @@ -1264,6 +1264,8 @@ 6071=淇敼鍚嶅瓧 6072=纭鍒犻櫎 6073=鍙栨秷 +6074=閬ユ帶鍣ㄤ笉鑳借秴杩�10涓紵 + 7000=鏂板缓鑷姩鍖� 7001=缂栬緫鑷姩鍖� diff --git a/HDL-ON_iOS/Resources/Language.ini b/HDL-ON_iOS/Resources/Language.ini index d231c84..d55156e 100644 --- a/HDL-ON_iOS/Resources/Language.ini +++ b/HDL-ON_iOS/Resources/Language.ini @@ -1268,6 +1268,7 @@ 6071=淇敼鍚嶅瓧 6072=纭鍒犻櫎 6073=鍙栨秷 +6074=閬ユ帶鍣ㄤ笉鑳借秴杩�10涓紵 diff --git a/HDL_ON/Common/R.cs b/HDL_ON/Common/R.cs index b31ccc6..49d4bfa 100644 --- a/HDL_ON/Common/R.cs +++ b/HDL_ON/Common/R.cs @@ -748,7 +748,7 @@ public const int xiugaimingzi = 6071; public const int querenshanchu = 6072; public const int quxiao = 6073; - + public const int bunengchaoguo10 = 6074; diff --git a/HDL_ON/DAL/DriverLayer/Control.cs b/HDL_ON/DAL/DriverLayer/Control.cs index 7982419..106ed8e 100644 --- a/HDL_ON/DAL/DriverLayer/Control.cs +++ b/HDL_ON/DAL/DriverLayer/Control.cs @@ -844,7 +844,7 @@ case SPK.SensorSmoke: case SPK.SensorWater: case SPK.ClothesHanger: - case SPK.IrAC: + case SPK.AcIr: //璁惧鐘舵�佹帹閫� Stan.HdlDeviceStatuPushLogic.Current.UpdateDeviceStatu(updateTemp.sid, updateTemp.status); break; diff --git a/HDL_ON/DAL/Mqtt/MqttClient.cs b/HDL_ON/DAL/Mqtt/MqttClient.cs index 62d34ba..b0ba2a9 100644 --- a/HDL_ON/DAL/Mqtt/MqttClient.cs +++ b/HDL_ON/DAL/Mqtt/MqttClient.cs @@ -197,10 +197,17 @@ Topic = $"/user/{DB_ResidenceData.Instance.CurrentRegion.RegionID}/app/thing/topo/found", QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtMostOnce }; + //App璁㈤槄閬ユ帶鍣ㄨ嚜瀛︽寜閿涔犳垚鍔熼�氱煡 + var study = new MqttTopicFilter() + { + Topic = $"/user/{DB_ResidenceData.Instance.CurrentRegion.RegionID}/app/thing/event/irCodeStudyDone/up", + QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtMostOnce + }; Utlis.WriteLine("寮�濮嬭闃咃紒"); var result = await RemoteMqttClient.SubscribeAsync(new MqttTopicFilter[] { pirStatus, + study, topicFilterPush2, topicAlinkStatus }); if (result.Items[0].ResultCode == MQTTnet.Client.Subscribing.MqttClientSubscribeResultCode.GrantedQoS0) { @@ -291,7 +298,16 @@ { var bytes = Securitys.EncryptionService.AesDecryptPayload(e.ApplicationMessage.Payload, tuyaEncryptKey); var revString = Encoding.UTF8.GetString(bytes); - HDL_ON.UI.UI2.PersonalCenter.PirDevice.Method.addcontronsid = revString; + HDL_ON.UI.UI2.PersonalCenter.PirDevice.Method.addcontrondata = revString; + //ReceiveCheckGateway(ss); + //return; + } + //App璁㈤槄閬ユ帶鍣ㄨ嚜瀛︽寜閿涔犳垚鍔熼�氱煡 + else if (topic == $"/user/{DB_ResidenceData.Instance.CurrentRegion.RegionID}/app/thing/event/irCodeStudyDone/up") + { + var bytes = Securitys.EncryptionService.AesDecryptPayload(e.ApplicationMessage.Payload, tuyaEncryptKey); + var revString = Encoding.UTF8.GetString(bytes); + HDL_ON.UI.UI2.PersonalCenter.PirDevice.Method.studybtndata = revString; //ReceiveCheckGateway(ss); //return; } diff --git a/HDL_ON/DAL/Server/NewAPI.cs b/HDL_ON/DAL/Server/NewAPI.cs index 6b2034c..2991a2a 100644 --- a/HDL_ON/DAL/Server/NewAPI.cs +++ b/HDL_ON/DAL/Server/NewAPI.cs @@ -325,6 +325,7 @@ /// 鑾峰彇璁惧璇︽儏 /// </summary> public const string Api_Post_GetDevcieInfoList = "/home-wisdom/app/device/info"; + /// <summary> /// 鍒锋柊璁惧鐘� /// </summary> @@ -502,6 +503,10 @@ /// 閬ユ帶鍣ㄨ嚜瀛︽寜閿垹闄� /// </summary> public const string API_POST_Ir_CodeRemove = "/home-wisdom/app/device/ir/codeRemove"; + /// <summary> + /// 鑾峰彇璁惧璇︽儏閫氳繃(spk,sid) + /// </summary> + public const string Api_Post_GetinfoBySid = "/home-wisdom/app/device/infoBySid"; #endregion diff --git a/HDL_ON/Entity/Function/Function.cs b/HDL_ON/Entity/Function/Function.cs index 3567c12..0216ac5 100644 --- a/HDL_ON/Entity/Function/Function.cs +++ b/HDL_ON/Entity/Function/Function.cs @@ -1016,9 +1016,9 @@ /// </summary> public const string IrModule = "ir.module"; /// <summary> - /// 绾㈠绌鸿皟 + /// 绾㈠鐢佃 /// </summary> - public const string IrAC = "ir.ac"; + public const string TvIr = "ir.tv"; /// <summary> diff --git a/HDL_ON/UI/UI0-Public/PublicAssmeblyBLL.cs b/HDL_ON/UI/UI0-Public/PublicAssmeblyBLL.cs index 265dc13..564ed4d 100644 --- a/HDL_ON/UI/UI0-Public/PublicAssmeblyBLL.cs +++ b/HDL_ON/UI/UI0-Public/PublicAssmeblyBLL.cs @@ -133,7 +133,7 @@ var clothesHangerpage = new ClothesHangerPage(); clothesHangerpage.AddForm(function, btnCollectionIcon, btnName, btnFromFloor); break; - case SPK.IrAC: + case SPK.AcIr: case SPK.AcStandard: var acPage = new AcControlPage(); acPage.AddForm(function, btnCollectionIcon, btnName, btnFromFloor); diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/TipPopView.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/TipPopView.cs index acb78cb..9786316 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/TipPopView.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/TipPopView.cs @@ -892,9 +892,9 @@ /// 淇℃伅鎻愮ず绐楀彛锛岃嚜鍔ㄥ叧闂� /// </summary> /// <param name="msg">鎻愮ず閿欒鏂囨湰</param> - public void FlashingBox(string msg) + public void FlashingBox(string msg,int time=2000) { - new PublicAssmebly().TipMsgAutoClose(msg, false, 2000); + new PublicAssmebly().TipMsgAutoClose(msg, false, time); } /// <summary> diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddButton.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddButton.cs index 28d0f31..aecbe5b 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddButton.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddButton.cs @@ -114,7 +114,7 @@ //鍚嶇О涓嶈兘涓虹┖ return; } - var butName = Pir.BuottonList.Find((c) => c.value == texts); + var butName = control.status.Find((c) => c.value == texts); if (butName != null) { //鍚嶇О宸茬粡瀛樺湪 @@ -126,41 +126,54 @@ //娣诲姞鏁版嵁瀵硅薄 Entity.AttributesStatus buttonObj = new Entity.AttributesStatus(); - buttonObj.key = "key" + Pir.BuottonList.Count.ToString(); + buttonObj.key = "key" + control.status.Count.ToString(); buttonObj.value = texts; PirSend.CodeStudy(control, buttonObj, (responsePackNew) => { - //浼戠湢鏄负鏄剧ず寮曞鐣岄潰 - System.Threading.Thread.Sleep(5000); - //绉婚櫎娣诲姞鎸夐挳寮曞鐣岄潰 - replication.RemView(); if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") { - var buttonName = Pir.BuottonList.Find((c) => c.value == buttonObj.value); - if (buttonName == null) + Method method = new Method(); + var mqttdate = method.MqttDate(control.sid, 20); + if (mqttdate !=null) { - //娣诲姞鏁版嵁 - Pir.BuottonList.Add(buttonObj); - } - //绉婚櫎娣诲姞鎸夐挳鐣岄潰 - this.RemoveFromParent(); - - for (int i = MainPage.BasePageView.ChildrenCount - 1; 0 <= i; i--) - { - var view = MainPage.BasePageView.GetChildren(i); - if (view.GetType() == typeof(AddControl)) + //浼戠湢鏄负鏄剧ず寮曞鐣岄潰 + // System.Threading.Thread.Sleep(3000); + //绉婚櫎娣诲姞鎸夐挳寮曞鐣岄潰 + replication.RemView(); + var buttonName = control.status.Find((c) => c.value == buttonObj.value); + if (buttonName == null) { - view.RemoveFromParent(); + //娣诲姞鏁版嵁 + control.status.Add(buttonObj); + } + //绉婚櫎娣诲姞鎸夐挳鐣岄潰 + this.RemoveFromParent(); + + for (int i = MainPage.BasePageView.ChildrenCount - 1; 0 <= i; i--) + { + var view = MainPage.BasePageView.GetChildren(i); + if (view.GetType() == typeof(AddControl)) + { + new Intelligence.Automation.LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.tianjiashibai)); + view.RemoveFromParent(); + } + } + //鍔犺浇鏁版嵁鐣岄潰 + AddControl addControl = new AddControl(); + MainPage.BasePageView.AddChidren(addControl); + addControl.Show(control); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; } + else + { + replication.RemView(); + new Intelligence.Automation.LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.tianjiashibai)); - //鍔犺浇鏁版嵁鐣岄潰 - AddControl addControl = new AddControl(); - MainPage.BasePageView.AddChidren(addControl); - addControl.Show(control); - MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + } + } else { diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControl.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControl.cs index 06fcb00..f598e88 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControl.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControl.cs @@ -103,7 +103,7 @@ VerticalScrolViewLayout vv = new VerticalScrolViewLayout(); frameLayout.AddChidren(vv); - RefreshView(vv, false); + RefreshView(vv, false, control); #endregion #region 鐣岄潰鐐瑰嚮浜嬩欢 @@ -117,13 +117,13 @@ topView.topIconBtn.Text = Language.StringByID(StringId.wancheng); topView.topIconBtn.TextSize = TextSize.text14; topView.topIconBtn.TextColor = CSS.CSS_Color.textColor; - RefreshView(vv, true); + RefreshView(vv, true, control); } else { topView.topIconBtn.UnSelectedImagePath = "PirIcon/del.png"; topView.topIconBtn.Text = ""; - RefreshView(vv, false); + RefreshView(vv, false, control); } @@ -164,18 +164,18 @@ /// </summary> /// <param name="vv">涓婁笅婊戝姩鎺т欢</param> /// <param name="if_bool">琛ㄧず鏄惁鏄剧ず鍒犻櫎鍥炬爣</param> - void RefreshView(VerticalScrolViewLayout vv, bool if_bool) + void RefreshView(VerticalScrolViewLayout vv, bool if_bool, Control control) { vv.RemoveAll(); //瀹氫箟涓�涓彉閲忚褰曡鏁� int sum = 0; - if (Pir.BuottonList.Count % 3 == 0) + if (control.status.Count % 3 == 0) { - sum = Pir.BuottonList.Count / 3; + sum = control.status.Count / 3; } else { - sum = Pir.BuottonList.Count / 3 + 1; + sum = control.status.Count / 3 + 1; } //璁$畻鍔犺浇鍑烘潵鐨勬暟鎹渶瑕佺殑楂樺害 int h = 16 + sum * (16 + 44) + 104 + 76; @@ -186,9 +186,9 @@ Height = Application.GetRealWidth(h), }; vv.AddChidren(FLayout); - for (int i = 1, j = 0; i <= Pir.BuottonList.Count; i++, j++) + for (int i = 1, j = 0; i <= control.status.Count; i++, j++) { - var nameObj = Pir.BuottonList[i - 1]; + var nameObj = control.status[i - 1]; //鎸夐挳 var buttonNameBtn = new Button { @@ -245,12 +245,12 @@ if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") { ///杩欓噷锛氱洃鍚琈TTP鎺ㄩ�佷笅鏉ヤ富棰橈紝鎵嶇煡閬撴槸鍚︽坊鍔犳垚鍔� - var buttonObj = Pir.BuottonList.Find((c) => c.value == obj.value); + var buttonObj = control.status.Find((c) => c.value == obj.value); if (buttonObj != null) { - Pir.BuottonList.Remove(buttonObj); + control.status.Remove(buttonObj); } - RefreshView(vv, true); + RefreshView(vv, true, control); } else { Method method = new Method(); diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControlComplete.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControlComplete.cs index ac1b20d..61d0ee9 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControlComplete.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControlComplete.cs @@ -116,10 +116,10 @@ else { Method method = new Method(); - method.AddControl(this, (control1) => { + method.AddControl(this, (controlDevice) => { AddButton addButton = new AddButton(); MainPage.BasePageView.AddChidren(addButton); - addButton.Show(control1); + addButton.Show(controlDevice); MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; }); } @@ -129,6 +129,21 @@ { MainPage.BasePageView.RemoveViewByTag("AddControl"); MainPage.BasePageView.RemoveViewByTag("Pir"); + + Entity.Function function = new Entity.Function(); + function.sid = control.sid; + function.deviceId = control.deviceId; + function.name = control.name; + function.spk = control.spk; + function.attributes.AddRange(function.attributes); + if (null == Pir.currPir.FunctioList.Find((c) => c.sid == function.sid)) + { + Pir.currPir.FunctioList.Add(function); + } + //Entity.FunctionAttributes functionAttributes = new Entity.FunctionAttributes(); + //functionAttributes.key + + }; #endregion } diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/DeviceSet.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/DeviceSet.cs index 591e56c..1b58afe 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/DeviceSet.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/DeviceSet.cs @@ -11,7 +11,7 @@ { Tag = "PirView"; } - public void Show() + public void Show(Action action) { #region 鐣岄潰甯冨眬 this.BackgroundColor = CSS.CSS_Color.viewMiddle; @@ -19,7 +19,10 @@ topView.topNameBtn.TextID = StringId.shebeigaunli; topView.topIconBtn.Visible = true; this.AddChidren(topView.FLayoutView()); - topView.clickBackBtn.MouseUpEventHandler += (sender, e) => { this.RemoveFromParent(); }; + topView.clickBackBtn.MouseUpEventHandler += (sender, e) => { + action(); + this.RemoveFromParent(); + }; VerticalRefreshLayout vv = new VerticalRefreshLayout(); vv.Height = Application.GetRealHeight(667 - 64); vv.Y = Application.GetRealHeight(64); @@ -147,6 +150,7 @@ Width = Application.GetRealWidth(8), Height = Application.GetRealWidth(8), UnSelectedImagePath = "PirIcon/online.png", + SelectedImagePath = "PirIcon/offline.png", }; devfLayout.AddChidren(stateIconBtn); //绾㈠瀹濈姸鎬侊紙鍦ㄧ嚎-绂荤嚎锛� @@ -160,9 +164,17 @@ TextAlignment = TextAlignment.CenterLeft, TextSize = TextSize.text12, TextColor = 0xFF67D569,// CSS.CSS_Color.textColor, + SelectedTextColor =CSS.CSS_Color.textRedColor, IsBold = true, }; devfLayout.AddChidren(stateTextBtn); + if (pirDevice.online) { + stateIconBtn.IsSelected = true; + stateTextBtn.IsSelected = true; + } else { + stateIconBtn.IsSelected = false; + stateTextBtn.IsSelected = false; + } //绾� Button lineBtn = new Button { @@ -302,7 +314,11 @@ { if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") { - pirDevice.FunctioList.Remove(Function); + var function = pirDevice.FunctioList.Find((c)=>c.sid== Function.sid); + if (function != null) + { + pirDevice.FunctioList.Remove(Function); + } UIView(vv); } diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs index caf97eb..e640385 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs @@ -247,11 +247,11 @@ } } break; - case SPK.ElectricTV: + case SPK.TvIr: { switch (textInt) { - case StringId.dianshi: + case StringId.dianyuan: { key = "on_off"; value = "on"; @@ -259,8 +259,8 @@ break; case StringId.yinliangjia: { - key = "on_off"; - value = "on"; + key = "volume+"; + value = "50"; } break; case StringId.jingyin: @@ -284,6 +284,7 @@ control.type = "library"; control.status.Add(buttonObj); control.deviceId = Pir.currPir.deviceId; + control.sid = ""; string[] strings = library.irCode.Split(','); for (int arrayStr = 0; arrayStr < strings.Length; arrayStr++) { @@ -368,7 +369,7 @@ } } break; - case SPK.ElectricTV: + case SPK.TvIr: { switch (code) { diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs index 3b9cb15..a4a0393 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs @@ -16,14 +16,20 @@ View.TipView tipView = new View.TipView(); tipView.InputBox(frameLayout, "", (name, frame) => { - ///娓呴櫎涔嬪墠鍒楄〃鏁版嵁 - Pir.BuottonList.Clear(); - Control control = new Control(); - control.name = name; - control.type = "learn"; - control.spk = "ir.learn"; - control.deviceId = Pir.currPir.deviceId; - ThreadAddControl(control, frame, action); + if (Pir.currPir != null && Pir.currPir.FunctioList.Count < 10) + { + Control control = new Control(); + control.name = name; + control.type = "learn"; + control.spk = "ir.learn"; + control.deviceId = Pir.currPir.deviceId; + ThreadAddControl(control, frame, action); + } + else + { + View.TipView tt = new View.TipView(); + tt.TipBox(StringId.tip, StringId.bunengchaoguo10); + } }, false); } @@ -54,13 +60,20 @@ { string sid = responsePackNew.Data.ToString(); var mqttdate = MqttDate(sid); - if (mqttdate.id!="") + if (mqttdate != null) { ///杩欓噷锛氱洃鍚琈TTP鎺ㄩ�佷笅鏉ヤ富棰橈紝鎵嶇煡閬撴槸鍚︽坊鍔犳垚鍔� - frame.RemoveFromParent();//娣诲姞鎴愬姛鍏抽棴寮圭獥 - control.deviceId = mqttdate.id; control.sid = sid; - action(control); + //浼戠湢500姣锛屼负绛夊緟浜戠鍒涘缓deviceid锛� + System.Threading.Thread.Sleep(500); + GetControl(frame, control,(device)=> { + if (device != null) + { + control.deviceId = device.deviceId; + frame.RemoveFromParent();//娣诲姞鎴愬姛鍏抽棴寮圭獥 + action(control); + } + }); } else { @@ -232,27 +245,85 @@ } /// <summary> + /// 鑾峰彇閬ユ帶鍣ㄨ缁� + /// </summary> + public void GetControl(FrameLayout frame, Control control, Action<Entity.Function> action) + { + Entity.Function function = null; + //鍔犺浇log + Loading loading = new Loading(); + frame.AddChidren(loading); + HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null; + loading.Start(); + new System.Threading.Thread(() => + { + try + { + responsePackNew = PirSend.GetinfoBySid(control); + } + catch { } + finally + { + Application.RunOnMainThread(() => + { + try + { + if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") + { + var str = Newtonsoft.Json.JsonConvert.SerializeObject(responsePackNew.Data.ToString()); + function = Newtonsoft.Json.JsonConvert.DeserializeObject<Entity.Function>(str); + } + else + { + Method method = new Method(); + method.ErrorShow(responsePackNew); + } + } + catch { } + finally + { + Application.RunOnMainThread(() => + { + loading.Hide(); + action(function); + }); + } + + }); + } + + }) + { IsBackground = true }.Start(); + } + + /// <summary> /// MQTT涓婚鎺ㄩ�佷笅鏉ョ殑鏁版嵁(閬ユ帶鍣ㄦ坊鍔�) /// </summary> - public static string addcontronsid = ""; + public static string addcontrondata = ""; + /// <summary> + /// MQTT涓婚鎺ㄩ�佷笅鏉ョ殑鏁版嵁(瀛︿範鎸夐敭) + /// </summary> + public static string studybtndata = ""; + /// <summary> /// 鍒ゆ柇杩欎釜涓婚鏄惁鏄坊鍔犻仴鎺у櫒涓婚 /// </summary> /// <returns></returns> - public Cloud MqttDate(string sid) + public Cloud MqttDate(string sid,int timeValue=10) { - Cloud cloud = new Cloud(); + Cloud cloud=null; var dateTime = DateTime.Now; - while ((DateTime.Now - dateTime).TotalMilliseconds < 10 * 1000) + while ((DateTime.Now - dateTime).TotalMilliseconds < timeValue * 1000) { - if (!string.IsNullOrEmpty(addcontronsid)) + if (!string.IsNullOrEmpty(addcontrondata)) { - cloud = Newtonsoft.Json.JsonConvert.DeserializeObject<Cloud>(addcontronsid); - for (int i = 0; i < cloud.objects.Count; i++) + var cloudjson = Newtonsoft.Json.JsonConvert.DeserializeObject<Cloud>(addcontrondata); + for (int i = 0; i < cloudjson.objects.Count; i++) { - var objects = cloud.objects[i]; + var objects = cloudjson.objects[i]; if (sid == objects.sid) { + cloud = cloudjson; break; } } @@ -289,7 +360,7 @@ /// <summary> /// 璁惧id /// </summary> - public string id =""; + public string id = ""; public List<Objects> objects = new List<Objects>(); public string time_stamp = string.Empty; @@ -301,6 +372,14 @@ public string sid = string.Empty; public string spk = string.Empty; + public List<Attributes> attributes = new List<Attributes>(); } + [Serializable] + public class Attributes + { + public string key = ""; + public string data_type = ""; + public List<string> value = new List<string>(); + } } diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Pir.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Pir.cs index 0c160ff..9ec777a 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Pir.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Pir.cs @@ -5,12 +5,11 @@ namespace HDL_ON.UI.UI2.PersonalCenter.PirDevice { [System.Serializable] - public class Pir: Entity.Function + public class Pir : Entity.Function { /// <summary> - /// 娣诲姞鎸夐敭鍒楄〃 + /// 绾㈠瀹濆垪琛� /// </summary> - public static List<AttributesStatus> BuottonList = new List<AttributesStatus>(); public static List<Pir> pirDeviceList = new List<Pir>(); /// <summary> /// 褰撳墠閫昏緫 @@ -22,7 +21,6 @@ public List<Entity.Function> FunctioList = new List<Entity.Function>(); } - [System.Serializable] public class Control @@ -30,15 +28,15 @@ /// <summary> /// 绾㈠瀹濊澶嘔d /// </summary> - public string deviceId = "0"; + public string deviceId = ""; /// <summary> /// sid /// </summary> - public string sid = "0"; + public string sid = ""; /// <summary> /// 绾㈠閬ユ帶鍣ㄥ悕绉� /// </summary> - public string name = "0"; + public string name = ""; /// <summary> /// 绾㈠閬ユ帶鍣╯pk /// </summary> @@ -50,13 +48,13 @@ /// <summary> /// 鐮佺粍鍙� /// </summary> - public string groupId = "12"; + public string groupId = ""; /// <summary> - /// 绾㈠鐮� + /// 绾㈠鐮佸簱 /// </summary> public List<string> library = new List<string>(); /// <summary> - /// 绾㈠鐮� + /// /// </summary> public List<AttributesStatus> status = new List<AttributesStatus>(); } @@ -90,7 +88,6 @@ public string brandName = string.Empty; } - public class Library { /// <summary> diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirMain.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirMain.cs index 902b7ee..b1e7b74 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirMain.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirMain.cs @@ -135,14 +135,7 @@ ///绾㈠瀹濈偣鍑讳簨浠� FrameLayout clickFLayout = new FrameLayout(); pirDeviceFLayout.AddChidren(clickFLayout); - clickFLayout.MouseUpEventHandler += (sender, e) => - { - - DeviceSet deviceSet = new DeviceSet(); - MainPage.BasePageView.AddChidren(deviceSet); - deviceSet.Show(); - MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; - }; + FrameLayout deviceListFLayout = new FrameLayout(); deviceListFLayout.Y = pirDeviceFLayout.Bottom + Application.GetRealHeight(12); @@ -282,6 +275,19 @@ }; + clickFLayout.MouseUpEventHandler += (sender, e) => + { + + DeviceSet deviceSet = new DeviceSet(); + MainPage.BasePageView.AddChidren(deviceSet); + deviceSet.Show(() => { + if (Pir.currPir != null) + { + deviceNameBtn.Text = Pir.currPir.name; + } + }); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + }; #endregion int line = 0; for (int i = 1, j = 0; i <= 7; i++, j++) @@ -451,7 +457,7 @@ case 2: { //鐢佃 - type = "tv-" + SPK.ElectricTV; + type = "tv-" + SPK.TvIr; } break; case 3: diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirSend.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirSend.cs index 43c4136..96c3425 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirSend.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirSend.cs @@ -52,6 +52,19 @@ return responsePackNew; } /// <summary> + /// 鑾峰彇璁惧璇︽儏閫氳繃(spk,sid) + /// </summary> + /// <returns></returns> + public static ResponsePackNew GetinfoBySid(Control control) + { + var jObject = new JObject { }; + jObject.Add("homeId", HomeId); + jObject.Add("spk", control.spk); + jObject.Add("sid", control.sid); + var responsePackNew = RequestServerhomeId(jObject, NewAPI.Api_Post_GetinfoBySid); + return responsePackNew; + } + /// <summary> /// 鑾峰彇閬ユ帶鍣ㄥ垪琛� /// </summary> public static ResponsePackNew ControlList(Pir pir) diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/View/FailView.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/View/FailView.cs index f224e9d..abe1886 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/View/FailView.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/View/FailView.cs @@ -52,7 +52,6 @@ View.SaveView saveView = new View.SaveView(); dialog.AddChidren(saveView.FLayoutView()); saveView.btnSave.TextID = StringId.chongshii; - saveView.frameLayout.BackgroundColor = CSS.CSS_Color.viewLine; saveView.frameLayout.SetCornerWithSameRadius(Application.GetRealHeight(24), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight); dialog.Show(); saveView.btnClick.MouseUpEventHandler += (sender,e) => { diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/View/SaveView.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/View/SaveView.cs index 37e24d9..2b8b5d4 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/View/SaveView.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/View/SaveView.cs @@ -15,6 +15,8 @@ Width = Application.GetRealWidth(TextSize.view375), Gravity = Gravity.BottomCenter,//缃簳鐨勫睘鎬� BackgroundColor = CSS.CSS_Color.view, + BorderWidth = 1, + BorderColor = CSS.CSS_Color.viewLine, }; /// <summary> @@ -33,6 +35,7 @@ BackgroundColor = CSS.CSS_Color.btnSaveBackgroundColor, Radius = (uint)Application.GetRealHeight(22), + }; public Button btnClick = new Button { diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/View/TipView.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/View/TipView.cs index b86395d..6fec343 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/View/TipView.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/View/TipView.cs @@ -326,7 +326,178 @@ } + /// <summary> + /// 纭畾鎻愮ず妗� + /// </summary> + /// <param name="titleId">鏍囬鏂囨湰</param> + /// <param name="tipTxet">鑷畾涔夋彁绀烘枃鏈�</param> + /// <param name="confirmAction">鍥炶皟鍑芥暟</param> + public void TipBox(int titleId, int tipTxet, Action confirmAction) + { + Dialog dialog = new Dialog() + { + BackgroundColor = CSS.CSS_Color.viewTrans60lucence, + }; + + FrameLayout whiteView = new FrameLayout() + { + //Gravity = Gravity.Center, + X = Application.GetRealWidth(53), + Y = Application.GetRealHeight(264), + Width = Application.GetRealWidth(270), + Height = Application.GetRealHeight(140), + BackgroundColor = CSS_Color.view, + BorderColor = CSS_Color.viewTranslucence, + BorderWidth = 0, + Radius = (uint)Application.GetRealHeight(RradiusFrameLayout), + }; + dialog.AddChidren(whiteView); + + Button titleBtn = new Button() + { + Y = Application.GetRealHeight(20), + X = Application.GetRealWidth(35), + Height = Application.GetRealHeight(22), + Width = Application.GetRealWidth(270 - 35 * 2), + TextColor = CSS_Color.textConfirmColor, + TextSize = TextSize.Text16, + TextAlignment = TextAlignment.Center, + TextID = titleId, + }; + whiteView.AddChidren(titleBtn); + + Button tipBtn = new Button() + { + Y = titleBtn.Bottom + Application.GetRealHeight(8), + X = Application.GetRealWidth(20), + Height = Application.GetRealHeight(22), + Width = Application.GetRealWidth(270 - 20 * 2), + TextColor = CSS_Color.textTipColor, + TextSize = TextSize.Text12, + TextAlignment = TextAlignment.Center, + TextID = tipTxet, + }; + whiteView.AddChidren(tipBtn); + Button btnLine = new Button() + { + Y = whiteView.Height - Application.GetRealHeight(44 + 1), + Height = Application.GetRealHeight(1), + BackgroundColor = CSS_Color.viewLine, + }; + whiteView.AddChidren(btnLine); + + Button btnCancel = new Button() + { + Y = btnLine.Bottom, + Width = Application.GetRealWidth(135), + Height = Application.GetRealHeight(44), + TextAlignment = TextAlignment.Center, + TextColor = CSS_Color.textTipColor, + TextSize = TextSize.Text16, + TextID = StringId.cancelMusic, + Gravity = Gravity.BottomLeft, + }; + whiteView.AddChidren(btnCancel); + btnCancel.SetCornerWithSameRadius(Application.GetRealHeight(RradiusFrameLayout), HDLUtils.RectCornerBottomLeft); + Button btnConfirm = new Button() + { + X = btnCancel.Right, + Y = btnLine.Bottom, + Width = Application.GetRealWidth(135), + Height = Application.GetRealHeight(44), + TextAlignment = TextAlignment.Center, + TextColor = CSS_Color.view, + IsBold = true, + TextSize = TextSize.Text16, + TextID = StringId.confirmMusic, + BackgroundColor = CSS_Color.textConfirmColor, + Gravity = Gravity.BottomRight, + }; + whiteView.AddChidren(btnConfirm); + btnConfirm.SetCornerWithSameRadius(Application.GetRealHeight(RradiusFrameLayout), HDLUtils.RectCornerBottomRight); + dialog.Show(); + btnCancel.MouseUpEventHandler += (sender, e) => + { + dialog.Close(); + }; + + btnConfirm.MouseUpEventHandler += (sender, e) => + { + confirmAction(); + dialog.Close(); + }; + + } + /// <summary> + /// 閿欒淇℃伅鎻愮ず绐楀彛锛屾墜鍔ㄧ‘瀹氬叧闂� + /// </summary> + /// <param name="titleId">鏍囬鏂囨湰</param> + /// <param name="msgId">鎻愮ず閿欒鏂囨湰</param> + public void TipBox(int titleId, int msgId) + { + Dialog dialog = new Dialog() + { + BackgroundColor = CSS_Color.viewTrans60lucence, + }; + + FrameLayout contentView = new FrameLayout() + { + Gravity = Gravity.Center, + Width = Application.GetRealWidth(270), + Height = Application.GetRealHeight(140), + BackgroundColor = CSS.CSS_Color.MainBackgroundColor, + Radius = (uint)Application.GetRealHeight(RradiusFrameLayout), + }; + dialog.AddChidren(contentView); + + Button btnTitle = new Button() + { + Y = Application.GetRealHeight(20), + Height = Application.GetRealHeight(22), + TextColor = CSS_Color.MainColor, + TextSize =TextSize.Text16, + TextAlignment = TextAlignment.Center, + TextID = titleId, + }; + contentView.AddChidren(btnTitle); + + Button btnMsg = new Button() + { + Height = Application.GetRealHeight(17), + Y = Application.GetRealHeight(50), + TextAlignment = TextAlignment.Center, + TextColor = CSS_Color.TextualColor, + TextSize = TextSize.Text12, + TextID = msgId, + }; + contentView.AddChidren(btnMsg); + + Button btnLine = new Button() + { + Y = Application.GetRealHeight(96), + Height = Application.GetRealHeight(1), + BackgroundColor = CSS_Color.viewLine, + }; + contentView.AddChidren(btnLine); + + Button btnConfirm = new Button() + { + Y = btnLine.Bottom, + Height = Application.GetRealHeight(43), + TextAlignment = TextAlignment.Center, + TextColor = CSS_Color.MainColor, + TextSize = TextSize.Text16, + TextID = StringId.Close, + }; + contentView.AddChidren(btnConfirm); + dialog.Show(); + btnConfirm.MouseUpEventHandler += (sender, e) => + { + dialog.Close(); + }; + + } } } -- Gitblit v1.8.0