From 64b5d3b0eab77341795cc7d6634ffa7cf60848e2 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期一, 16 十一月 2020 14:39:00 +0800
Subject: [PATCH] 2020-11-16 1.界面问题优化。2.上传和下载增加失败重新操作处理。
---
Crabtree/SmartHome/UI/SimpleControl/Phone/Scene/SceneMethod.cs | 354 +++++++++++++++++++++++++++++++---------------------------
1 files changed, 191 insertions(+), 163 deletions(-)
diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Scene/SceneMethod.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Scene/SceneMethod.cs
index 690786c..1acb95e 100644
--- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Scene/SceneMethod.cs
+++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Scene/SceneMethod.cs
@@ -397,13 +397,13 @@
if (device == null) {
continue;
}
- replyBytes = Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, device.SubnetID, device.DeviceID, new byte [] { 1, (byte)device.Status });
+ replyBytes = Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, device.SubnetID, device.DeviceID, new byte [] { 17, (byte)device.CurtainProress });
} else if (common.Type == DeviceType.CurtainTrietex) {
var device = Newtonsoft.Json.JsonConvert.DeserializeObject<CurtainTrietex> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
if (device == null) {
continue;
}
- replyBytes = Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, device.SubnetID, device.DeviceID, new byte [] { 1, (byte)device.Status });
+ replyBytes = Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, device.SubnetID, device.DeviceID, new byte [] { 17, (byte)device.CurtainProress });
} else if (common.Type == DeviceType.HVAC || common.Type == DeviceType.ACInfrared) {
var device = Newtonsoft.Json.JsonConvert.DeserializeObject<HVAC> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
if (device == null) {
@@ -445,6 +445,12 @@
}
replyBytes = Control.ControlBytesSendHasReturn (Command.SetScene, device.SubnetID, device.DeviceID, new byte [] {
device.AreaID,device.AreaSceneID});
+ } else if (common.Type == DeviceType.UniversalDevice) {//2020-09-02 澧炲姞閫氱敤寮�鍏�
+ var device = Newtonsoft.Json.JsonConvert.DeserializeObject<UniversalDevice> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
+ if (device == null) {
+ continue;
+ }
+ replyBytes = Control.ControlBytesSendHasReturn (Command.SetCommonSwitch, device.SubnetID, device.DeviceID, new byte [] { device.SendBytes [0], device.SendBytes [1] });
}
try {
@@ -535,6 +541,10 @@
});
});
}
+ /// <summary>
+ /// 2020-06-05 鍔犻攣
+ /// </summary>
+ private readonly object SendLocker = new object ();
public void ControlScene (string sceneFilePath)
{
@@ -559,104 +569,108 @@
foreach (var deviceFilePath in tempScene.DeviceFilePathList) {
controlDeviceIndex++;
new System.Threading.Thread (() => {
- mSendCount++;
- var common = Newtonsoft.Json.JsonConvert.DeserializeObject<Common> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
- if (common.Type == DeviceType.LightDimming) {
- var device = Newtonsoft.Json.JsonConvert.DeserializeObject<LightDimming> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
- if (device == null) {
- replyBytes = new byte [] { 0x00 };
- } else {
- replyBytes = Control.ControlBytesSendHasReturn (Command.SetSingleLight, device.SubnetID, device.DeviceID, new byte [] { device.LoopID, device.CurrentBrightness, device.DelayTimeHeight, device.DelayTimeLow });
+ try {
+ lock (SendLocker) {
+ mSendCount++;
}
- } else if (common.Type == DeviceType.LightEnergySocket) {
- var device = Newtonsoft.Json.JsonConvert.DeserializeObject<LightEnergySocket> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
- //if (device == null) {
- // mSendCount--;
- // continue;
- //}
- if (device == null) {
- replyBytes = new byte [] { 0x00 };
- } else {
- replyBytes = Control.ControlBytesSendHasReturn (Command.SetSingleLight, device.SubnetID, device.DeviceID, new byte [] { device.LoopID, device.CurrentBrightness, device.DelayTimeHeight, device.DelayTimeLow });
- }
- } else if (common.Type == DeviceType.LightEnergySwitch) {
- var device = Newtonsoft.Json.JsonConvert.DeserializeObject<LightEnergySwitch> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
- //if (device == null) {
- // mSendCount--;
- // continue;
- //}
- if (device == null) {
- replyBytes = new byte [] { 0x00 };
- } else {
- replyBytes = Control.ControlBytesSendHasReturn (Command.SetSingleLight, device.SubnetID, device.DeviceID, new byte [] { device.LoopID, device.CurrentBrightness, device.DelayTimeHeight, device.DelayTimeLow });
- }
- } else if (common.Type == DeviceType.LightRGB) {
- var device = Newtonsoft.Json.JsonConvert.DeserializeObject<LightLogic> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
- //if (device == null) {
- // mSendCount--;
- // continue;
- //}
- if (device == null) {
- replyBytes = new byte [] { 0x00 };
- } else {
+ //mSendCount++;
+ var common = Newtonsoft.Json.JsonConvert.DeserializeObject<Common> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
+ if (common.Type == DeviceType.LightDimming) {
+ var device = Newtonsoft.Json.JsonConvert.DeserializeObject<LightDimming> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
+ if (device == null) {
+ replyBytes = new byte [] { 0x00 };
+ } else {
+ replyBytes = Control.ControlBytesSendHasReturn (Command.SetSingleLight, device.SubnetID, device.DeviceID, new byte [] { device.LoopID, device.CurrentBrightness, device.DelayTimeHeight, device.DelayTimeLow });
+ }
+ } else if (common.Type == DeviceType.LightEnergySocket) {
+ var device = Newtonsoft.Json.JsonConvert.DeserializeObject<LightEnergySocket> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
+ //if (device == null) {
+ // mSendCount--;
+ // continue;
+ //}
+ if (device == null) {
+ replyBytes = new byte [] { 0x00 };
+ } else {
+ replyBytes = Control.ControlBytesSendHasReturn (Command.SetSingleLight, device.SubnetID, device.DeviceID, new byte [] { device.LoopID, device.CurrentBrightness, device.DelayTimeHeight, device.DelayTimeLow });
+ }
+ } else if (common.Type == DeviceType.LightEnergySwitch) {
+ var device = Newtonsoft.Json.JsonConvert.DeserializeObject<LightEnergySwitch> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
+ //if (device == null) {
+ // mSendCount--;
+ // continue;
+ //}
+ if (device == null) {
+ replyBytes = new byte [] { 0x00 };
+ } else {
+ replyBytes = Control.ControlBytesSendHasReturn (Command.SetSingleLight, device.SubnetID, device.DeviceID, new byte [] { device.LoopID, device.CurrentBrightness, device.DelayTimeHeight, device.DelayTimeLow });
+ }
+ } else if (common.Type == DeviceType.LightRGB) {
+ var device = Newtonsoft.Json.JsonConvert.DeserializeObject<LightLogic> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
+ //if (device == null) {
+ // mSendCount--;
+ // continue;
+ //}
+ if (device == null) {
+ replyBytes = new byte [] { 0x00 };
+ } else {
- replyBytes = Control.ControlBytesSendHasReturn (Command.SetLogicLoopColor, device.SubnetID, device.DeviceID, new byte [] { device.LoopID, device.CurrentBrightness, 254, device.DelayTimeHeigh,device.DelayTimeLow,
+ replyBytes = Control.ControlBytesSendHasReturn (Command.SetLogicLoopColor, device.SubnetID, device.DeviceID, new byte [] { device.LoopID, device.CurrentBrightness, 254, device.DelayTimeHeigh,device.DelayTimeLow,
3,device.RStatus,device.GStatus,device.BStatus,0,0});
- }
- } else if (common.Type == DeviceType.LightSwitch) {
- var device = Newtonsoft.Json.JsonConvert.DeserializeObject<LightSwitch> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
- //if (device == null) {
- // mSendCount--;
- // continue;
- //}
- if (device == null) {
- replyBytes = new byte [] { 0x00 };
- } else {
- replyBytes = Control.ControlBytesSendHasReturn (Command.SetSingleLight, device.SubnetID, device.DeviceID, new byte [] { device.LoopID, device.CurrentBrightness, device.DelayTimeHeight, device.DelayTimeLow });
- }
- } else if (common.Type == DeviceType.CurtainModel) {
- var device = Newtonsoft.Json.JsonConvert.DeserializeObject<CurtainModel> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
- //if (device == null) {
- // mSendCount--;
- // continue;
- //}
- if (device == null) {
- replyBytes = new byte [] { 0x00 };
- } else {
- replyBytes = Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, device.SubnetID, device.DeviceID, new byte [] { device.LoopID, (byte)device.Status });
- }
- } else if (common.Type == DeviceType.CurtainRoller) {
- var device = Newtonsoft.Json.JsonConvert.DeserializeObject<CurtainRoller> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
- //if (device == null) {
- // mSendCount--;
- // continue;
- //}
- if (device == null) {
- replyBytes = new byte [] { 0x00 };
- } else {
- replyBytes = Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, device.SubnetID, device.DeviceID, new byte [] { 1, (byte)device.Status });
- }
- } else if (common.Type == DeviceType.CurtainTrietex) {
- var device = Newtonsoft.Json.JsonConvert.DeserializeObject<CurtainTrietex> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
- //if (device == null) {
- // mSendCount--;
- // continue;
- //}
- if (device == null) {
- replyBytes = new byte [] { 0x00 };
- } else {
- replyBytes = Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, device.SubnetID, device.DeviceID, new byte [] { 1, (byte)device.Status });
- }
- } else if (common.Type == DeviceType.HVAC || common.Type == DeviceType.ACInfrared) {
- var device = Newtonsoft.Json.JsonConvert.DeserializeObject<HVAC> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
- //if (device == null) {
- // mSendCount--;
- // continue;
- //}
- if (device == null) {
- replyBytes = new byte [] { 0x00 };
- } else {
- replyBytes = Control.ControlBytesSendHasReturn (Command.SetACMode, device.SubnetID, device.DeviceID, new byte [] {
+ }
+ } else if (common.Type == DeviceType.LightSwitch) {
+ var device = Newtonsoft.Json.JsonConvert.DeserializeObject<LightSwitch> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
+ //if (device == null) {
+ // mSendCount--;
+ // continue;
+ //}
+ if (device == null) {
+ replyBytes = new byte [] { 0x00 };
+ } else {
+ replyBytes = Control.ControlBytesSendHasReturn (Command.SetSingleLight, device.SubnetID, device.DeviceID, new byte [] { device.LoopID, device.CurrentBrightness, device.DelayTimeHeight, device.DelayTimeLow });
+ }
+ } else if (common.Type == DeviceType.CurtainModel) {
+ var device = Newtonsoft.Json.JsonConvert.DeserializeObject<CurtainModel> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
+ //if (device == null) {
+ // mSendCount--;
+ // continue;
+ //}
+ if (device == null) {
+ replyBytes = new byte [] { 0x00 };
+ } else {
+ replyBytes = Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, device.SubnetID, device.DeviceID, new byte [] { device.LoopID, (byte)device.Status });
+ }
+ } else if (common.Type == DeviceType.CurtainRoller) {
+ var device = Newtonsoft.Json.JsonConvert.DeserializeObject<CurtainRoller> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
+ //if (device == null) {
+ // mSendCount--;
+ // continue;
+ //}
+ if (device == null) {
+ replyBytes = new byte [] { 0x00 };
+ } else {
+ replyBytes = Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, device.SubnetID, device.DeviceID, new byte [] { 1, (byte)device.Status });
+ }
+ } else if (common.Type == DeviceType.CurtainTrietex) {
+ var device = Newtonsoft.Json.JsonConvert.DeserializeObject<CurtainTrietex> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
+ //if (device == null) {
+ // mSendCount--;
+ // continue;
+ //}
+ if (device == null) {
+ replyBytes = new byte [] { 0x00 };
+ } else {
+ replyBytes = Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, device.SubnetID, device.DeviceID, new byte [] { 1, (byte)device.Status });
+ }
+ } else if (common.Type == DeviceType.HVAC || common.Type == DeviceType.ACInfrared) {
+ var device = Newtonsoft.Json.JsonConvert.DeserializeObject<HVAC> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
+ //if (device == null) {
+ // mSendCount--;
+ // continue;
+ //}
+ if (device == null) {
+ replyBytes = new byte [] { 0x00 };
+ } else {
+ replyBytes = Control.ControlBytesSendHasReturn (Command.SetACMode, device.SubnetID, device.DeviceID, new byte [] {
device.LoopID,
device.TemperatureMode,
device.IndoorTemperature,
@@ -670,77 +684,91 @@
device.SetFanSpeed,
device.SetTemperature,
device.ShaoFanMode});
- }
- } else if (common.Type == DeviceType.FoolHeat) {
- var device = Newtonsoft.Json.JsonConvert.DeserializeObject<FoolHeat> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
- //if (device == null) {
- // mSendCount--;
- // continue;
- //}
- if (device == null) {
- replyBytes = new byte [] { 0x00 };
- } else {
- replyBytes = Control.ControlBytesSendHasReturn (Command.SetFoolHeat, device.SubnetID, device.DeviceID,
- new byte [] { device.LoopID, (byte)(device.Status + device.WorkingMode * 16), 0,device.WorkingMode,device.NormalTemperature, device.DayTemperature,
+ }
+ } else if (common.Type == DeviceType.FoolHeat) {
+ var device = Newtonsoft.Json.JsonConvert.DeserializeObject<FoolHeat> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
+ //if (device == null) {
+ // mSendCount--;
+ // continue;
+ //}
+ if (device == null) {
+ replyBytes = new byte [] { 0x00 };
+ } else {
+ replyBytes = Control.ControlBytesSendHasReturn (Command.SetFoolHeat, device.SubnetID, device.DeviceID,
+ new byte [] { device.LoopID, (byte)(device.Status + device.WorkingMode * 16), 0,device.WorkingMode,device.NormalTemperature, device.DayTemperature,
device.NightTemperature, device.AwayTemperature , 0, 0 });
- }
- } else if (common.Type == DeviceType.FanModule) {
- var device = Newtonsoft.Json.JsonConvert.DeserializeObject<FanModule> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
- //if (device == null) {
- // mSendCount--;
- // continue;
- //}
- if (device == null) {
- replyBytes = new byte [] { 0x00 };
- } else {
- replyBytes = Control.ControlBytesSendHasReturn (Command.SetSingleLight, device.SubnetID, device.DeviceID, new byte [] { device.LoopID, (byte)device.WindSpeed });
- }
- } else if (common.Type == DeviceType.LogicModule) {
- var device = Newtonsoft.Json.JsonConvert.DeserializeObject<LogicModule> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
- //if (device == null) {
- // mSendCount--;
- // continue;
- //}
- if (device == null) {
- replyBytes = new byte [] { 0x00 };
- } else {
- replyBytes = Control.ControlBytesSendHasReturn (Command.SetScene, device.SubnetID, device.DeviceID, new byte [] {
+ }
+ } else if (common.Type == DeviceType.FanModule) {
+ var device = Newtonsoft.Json.JsonConvert.DeserializeObject<FanModule> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
+ //if (device == null) {
+ // mSendCount--;
+ // continue;
+ //}
+ if (device == null) {
+ replyBytes = new byte [] { 0x00 };
+ } else {
+ replyBytes = Control.ControlBytesSendHasReturn (Command.SetSingleLight, device.SubnetID, device.DeviceID, new byte [] { device.LoopID, (byte)device.WindSpeed });
+ }
+ } else if (common.Type == DeviceType.LogicModule) {
+ var device = Newtonsoft.Json.JsonConvert.DeserializeObject<LogicModule> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
+ //if (device == null) {
+ // mSendCount--;
+ // continue;
+ //}
+ if (device == null) {
+ replyBytes = new byte [] { 0x00 };
+ } else {
+ replyBytes = Control.ControlBytesSendHasReturn (Command.SetScene, device.SubnetID, device.DeviceID, new byte [] {
device.AreaID,device.AreaSceneID});
- }
- }
-
- try {
- if (showTip) {
- if (replyBytes == null) {
- Application.RunOnMainThread (() => {
- string tipString = Language.StringByID (R.MyInternationalizationString.ControlFailure);
- var btnTip = new Button () {
- Height = Application.GetRealHeight (140),
- Text = common.Name + tipString + "..." + controlDeviceIndex.ToString () + @"/" + sceneDeviceCount.ToString (),
- BackgroundColor = SkinStyle.Current.TitileView,
- };
- MainPage.MainFrameLayout.AddChidren (btnTip);
- btnTip.MouseUpEventHandler += (sender, e) => {
- btnTip.RemoveFromParent ();
- showTip = false;
- //MainPage.MainFrameLayout.Remove (btnTip);
- };
- System.Threading.Tasks.Task.Run (() => {
- System.Threading.Thread.Sleep (3000);
- Application.RunOnMainThread (() => {
- btnTip.RemoveFromParent ();
- //MainPage.MainFrameLayout.Remove (btnTip);
- //showTip = false;
- });
- });
- });
+ }
+ } else if (common.Type == DeviceType.UniversalDevice) {//2020-09-02 澧炲姞閫氱敤寮�鍏�
+ var device = Newtonsoft.Json.JsonConvert.DeserializeObject<UniversalDevice> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
+ if (device == null) {
+ replyBytes = new byte [] { 0x00 };
+ } else {
+ replyBytes = Control.ControlBytesSendHasReturn (Command.SetCommonSwitch, device.SubnetID, device.DeviceID, new byte [] { device.SendBytes [0], device.SendBytes [1] });
}
}
- } catch {
- }
- mSendCount--;
- }){ IsBackground = true}.Start();
+
+
+ try {
+ if (showTip) {
+ if (replyBytes == null) {
+ Application.RunOnMainThread (() => {
+ string tipString = Language.StringByID (R.MyInternationalizationString.ControlFailure);
+ var btnTip = new Button () {
+ Height = Application.GetRealHeight (140),
+ Text = common.Name + tipString + "..." + controlDeviceIndex.ToString () + @"/" + sceneDeviceCount.ToString (),
+ BackgroundColor = SkinStyle.Current.TitileView,
+ };
+ MainPage.MainFrameLayout.AddChidren (btnTip);
+ btnTip.MouseUpEventHandler += (sender, e) => {
+ btnTip.RemoveFromParent ();
+ showTip = false;
+ //MainPage.MainFrameLayout.Remove (btnTip);
+ };
+ System.Threading.Tasks.Task.Run (() => {
+ System.Threading.Thread.Sleep (3000);
+ Application.RunOnMainThread (() => {
+ btnTip.RemoveFromParent ();
+ //MainPage.MainFrameLayout.Remove (btnTip);
+ //showTip = false;
+ });
+ });
+ });
+ }
+ }
+ } catch {
+ }
+
+ //mSendCount--;
+ } catch { } finally {
+ lock (SendLocker) {
+ mSendCount--;
+ }
+ }
+ }) { IsBackground = true }.Start ();
//绛夊緟100ms鍐嶅彂閫佺浜屼釜璁惧鏁版嵁
System.Threading.Thread.Sleep (100);
--
Gitblit v1.8.0