From a1b0ab7044100daaa7e0f1da2d2ca45e38098963 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期一, 29 三月 2021 09:13:25 +0800
Subject: [PATCH] 2021-3-29-2
---
HDL_ON/UI/UI2/FuntionControlView/Electrical/TuyaWaterValvePage.cs | 172 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 165 insertions(+), 7 deletions(-)
diff --git a/HDL_ON/UI/UI2/FuntionControlView/Electrical/TuyaWaterValvePage.cs b/HDL_ON/UI/UI2/FuntionControlView/Electrical/TuyaWaterValvePage.cs
index f2e04a4..73e6c7a 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/Electrical/TuyaWaterValvePage.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/Electrical/TuyaWaterValvePage.cs
@@ -16,6 +16,20 @@
/// </summary>
private PicViewControl btnPictrue = null;
/// <summary>
+ /// 鎺у埗鍣ㄦ帶鍒剁姸鎬佹彁绀烘枃鏈寜閽�
+ /// </summary>
+ NormalViewControl btnControlTip = null;
+ /// <summary>
+ /// 鎺у埗鍣ㄦ帶鍒舵椂闂存彁绀烘枃鏈寜閽�
+ /// </summary>
+ NormalViewControl btnControlTimeTip = null;
+
+ /// <summary>
+ ///
+ /// </summary>
+ private IconViewControl btnTimeSet = null;
+
+ /// <summary>
/// 寮�鍏虫帶浠�
/// </summary>
private IconViewControl btnSwitch = null;
@@ -28,14 +42,18 @@
/// </summary>
public override void InitFrameWhiteContent()
{
- base.SetTitleText(Language.StringByID(StringId.AirCleaner));
+ base.SetTitleText(Language.StringByID(StringId.WaterValve));
- //娣诲姞绗簩绱㈠紩椤�
- this.AddSecondPage();
//鍒濆鍖栫涓�涓储寮曢〉鐨勫唴瀹�
this.InitFrameWhiteContent1();
//鍒锋柊鐣岄潰鐘舵��
this.RefreshFormStatu();
+ //璇诲彇鐘舵��
+ new System.Threading.Thread(() =>
+ {
+ Control.Ins.ReadFunctionsInfo(new List<string>() { device.deviceId});
+ })
+ { IsBackground = true }.Start();
}
/// <summary>
@@ -56,6 +74,58 @@
this.SendSwitchComand();
};
+ btnControlTip = new NormalViewControl(300,30, true)
+ {
+ Y = Application.GetRealHeight(231),
+ TextAlignment = TextAlignment.Center,
+ Gravity = Gravity.CenterHorizontal,
+ TextSize = CSS_FontSize.TextFontSize,
+ SelectedTextColor = CSS_Color.MainColor,
+ TextColor = CSS_Color.TextualColor,
+ TextID = StringId.ControllerNotOn,
+ };
+ FrameWhiteCentet1.AddChidren(btnControlTip);
+
+ btnControlTimeTip = new NormalViewControl(300, 30, true)
+ {
+ Y = Application.GetRealHeight(252),
+ Gravity = Gravity.CenterHorizontal,
+ TextAlignment = TextAlignment.Center,
+ TextSize = CSS_FontSize.TextFontSize,
+ //TextColor = 0x00000000,
+ SelectedTextColor = CSS_Color.TextualColor,
+ TextColor = CSS_Color.TextualColor,
+ Text = "00:00:00"
+ };
+ FrameWhiteCentet1.AddChidren(btnControlTimeTip);
+
+ btnTimeSet = new IconViewControl(50)
+ {
+ Y = Application.GetRealHeight(365),
+ Gravity = Gravity.CenterHorizontal,
+ UnSelectedImagePath = "FunctionIcon/Electrical/WaterValve/SetTimeIcon.png",
+ SelectedImagePath = "FunctionIcon/Electrical/WaterValve/SetTimeIcon.png",
+ };
+ FrameWhiteCentet1.AddChidren(btnTimeSet);
+ btnTimeSet.ButtonClickEvent = (sender, e) => {
+ SetControlTime();
+ };
+
+
+ var btnTimeSetTip = new NormalViewControl(300, 30, true)
+ {
+ Y = btnTimeSet.Bottom ,
+ Gravity = Gravity.CenterHorizontal,
+ TextAlignment = TextAlignment.Center,
+ TextSize = CSS_FontSize.TextFontSize,
+ //TextColor = 0x00000000,
+ SelectedTextColor = CSS_Color.TextualColor,
+ TextColor = CSS_Color.TextualColor,
+ TextID = StringId.TimeSwitch,
+ };
+ FrameWhiteCentet1.AddChidren(btnTimeSetTip);
+
+
//寮�鍏冲浘鏍�
this.btnSwitch = new IconViewControl(40);
btnSwitch.Gravity = Gravity.CenterHorizontal;
@@ -68,6 +138,8 @@
//鍙戦�佸紑鍏冲懡浠�
this.SendSwitchComand();
};
+
+ var pack = new DAL.Server.HttpServerRequest().GetDeviceInfoList(new List<string>() { base.device.deviceId });
}
#endregion
@@ -99,7 +171,6 @@
this.btnSwitch.CanClick = false;
string statu = this.btnSwitch.IsSelected == true ? "off" : "on";
- //btnSwitch.IsSelected = !btnSwitch.IsSelected;
HdlThreadLogic.Current.RunThread(() =>
{
var dic = new Dictionary<string, string>();
@@ -124,16 +195,103 @@
{
Application.RunOnMainThread(() =>
{
- foreach (var data in this.device.attributes)
+ var onoffStatu = device.attributes.Find((obj) => obj.key == FunctionAttributeKey.OnOff);
+ var timeStatu = device.attributes.Find((obj) => obj.key == FunctionAttributeKey.TuyaWaterTime);
+
+ if (onoffStatu != null)
{
- if (data.key == FunctionAttributeKey.OnOff)
+ if (onoffStatu.state == "on")
{
- this.btnSwitch.IsSelected = this.btnPictrue.IsSelected = data.curValue.ToString() == "on";
+ btnControlTip.TextID = StringId.ControllerOn;
}
+ else
+ {
+ btnControlTip.TextID = StringId.ControllerNotOn;
+ }
+ this.btnSwitch.IsSelected = this.btnPictrue.IsSelected = onoffStatu.state.ToString() == "on";
}
+ if (timeStatu != null)
+ {
+ int.TryParse(timeStatu.state, out waterRunningTime);
+ }
+ RefreshTimeButton();
});
}
+
+ System.Threading.Thread refreshTimeThread;
+ int waterRunningTime = 0;
+ /// <summary>
+ /// 鍒锋柊姘撮榾鏃堕棿鏂囨湰
+ /// </summary>
+ private void RefreshTimeButton()
+ {
+ if (refreshTimeThread == null || refreshTimeThread.ThreadState == System.Threading.ThreadState.Stopped)
+ {
+ refreshTimeThread = new System.Threading.Thread(() =>
+ {
+ while (waterRunningTime >= 0)
+ {
+ if (waterRunningTime > 0)
+ {
+ waterRunningTime--;
+ }
+ var sce = waterRunningTime % 60;
+ var min = 0;
+ if(waterRunningTime > 60)
+ {
+ min = (waterRunningTime - sce) / 60 %60;
+ }
+ var hour = 0;
+ if(waterRunningTime > 360)
+ {
+ hour = (waterRunningTime - sce - (min * 60)) / 3600;
+ }
+ Application.RunOnMainThread(() =>
+ {
+ btnControlTimeTip.Text = $"{hour.ToString().PadLeft(2,'0')}:{min.ToString().PadLeft(2, '0')}:{sce.ToString().PadLeft(2, '0')}";
+ });
+ System.Threading.Thread.Sleep(1000);
+ }
+ })
+ { IsBackground = true };
+ }
+ refreshTimeThread.Start();
+ }
+
+ public override void RemoveFromParent()
+ {
+ if (refreshTimeThread != null)
+ {
+ refreshTimeThread.Abort();
+ }
+ base.RemoveFromParent();
+ }
+
#endregion
+
+ private void SetControlTime()
+ {
+ var timeControl = new BottomTimeSelectControl();
+ timeControl.RowCount = 5;
+ timeControl.InitControl(0,0);
+ timeControl.FinishEvent = (type,hours,min) => {
+ if (type == 1)//0:鍙栨秷锛�1:纭畾
+ {
+ HdlThreadLogic.Current.RunThread(() =>
+ {
+ var time = hours * 60 * 60 + min * 60;
+ var dic = new Dictionary<string, string>();
+ dic.Add(FunctionAttributeKey.TuyaWaterTime, time.ToString());
+ Control.Ins.SendWriteCommand(this.device, dic, true);
+ HdlThreadLogic.Current.RunMain(() =>
+ {
+ waterRunningTime = time;
+ this.btnControlTimeTip.Text = $"{hours.ToString().PadLeft(2, '0')}:{min.ToString().PadLeft(2, '0')}:00";
+ });
+ });
+ }
+ };
+ }
}
}
--
Gitblit v1.8.0