From 2a23fbede38fadaf7060510a3cd72a93a8a95ec0 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期五, 18 十二月 2020 17:49:46 +0800
Subject: [PATCH] 2020-12-18-3
---
HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs | 401 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 379 insertions(+), 22 deletions(-)
diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs
index 086bd83..7eee6bc 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs
@@ -21,7 +21,7 @@
///璁板綍鏉′欢绫诲瀷
inputView.btnClick.Name = inputCondition.condition_type;
///璁板綍鏉′欢绱㈠紩
- inputView.btnClick.Tag = i;
+ inputView.btnClick.Tag = inputCondition.sid;
///鏉′欢鐘舵�佹暟缁�
List<Dictionary<string, string>> dicList = inputCondition.condition as List<Dictionary<string, string>>;
//鏄剧ず鏉′欢鍚勭绫诲瀷鐘舵��
@@ -29,7 +29,7 @@
{
case "1":
{
- inputView.btnIcon.UnSelectedImagePath = "LogicIcon/timecondition.png";
+ inputView.btnIcon.UnSelectedImagePath = "LogicIcon/time.png";
foreach (var dic in dicList)
{
string value = dic["value"];
@@ -40,7 +40,7 @@
break;
case "2":
{
- inputView.btnIcon.UnSelectedImagePath = "LogicIcon/timecondition.png";
+ inputView.btnIcon.UnSelectedImagePath = "LogicIcon/time.png";
foreach (var dic in dicList)
{
string value = dic["value"];
@@ -63,7 +63,20 @@
//鍖哄埆涓嶅悓璁惧锛屾樉绀轰笉鍚岃澶囩姸鎬�
switch (device.functionType)
{
+ //寮�鍏崇伅鍏� light.Switch
+ case FunctionType.Dimmer:
+ case FunctionType.RGB:
+ case FunctionType.RGBW:
+ case FunctionType.ColorTemperature:
case FunctionType.Relay:
+ //绐楀笜
+ case FunctionType.Curtain:
+ case FunctionType.RollingShutter:
+ case FunctionType.MotorCurtain:
+ //绌鸿皟
+ case FunctionType.AC:
+ //鍦扮儹
+ case FunctionType.FloorHeating:
{//寮�鍏崇伅
foreach (var dic in dicList)
{
@@ -91,11 +104,21 @@
{
Button button = (Button)sen;
//鎵惧埌褰撳墠缂栬緫鐨勭储寮�
- int indexVulae = int.Parse(inputView.btnClick.Tag.ToString());
+ int indexVulae = 0;
+ for (int index = 0; index < Logic.currlogic.input.Count; index++)
+ {
+ Input input = Logic.currlogic.input[index];
+ if (input.sid == inputView.btnClick.Tag.ToString())
+ {
+ //鐢ㄦ埛鍙兘鍒犻櫎鏁版嵁锛屼娇鍒楄〃绱㈠紩鍙戠敓鏀瑰彉锛�
+ //閫氳繃鍞竴sid閲嶆柊鏌ユ壘鍒扮储寮曚笖鏇存柊绱㈠紩鍊�
+ indexVulae = index;
+ break;
+ }
+ }
+
//鏍囪缂栬緫鐘舵��
bool edit = true;
- //琛ㄧず鏄潯浠�
- string if_type = LogicMethod.condition_if;
switch (button.Name)
{
case "1":
@@ -120,14 +143,13 @@
timeTpye.TimeHorizon(fLayout, edit, indexVulae);
}
break;
-
case "3":
{
//鐢╯id鎵惧埌璁惧锛�
var device = LogicMethod.GetDevice(inputCondition.sid);
- DeviceFunList deviceFunList = new DeviceFunList();
+ ConditionDeviceFunList deviceFunList = new ConditionDeviceFunList();
MainPage.BasePageView.AddChidren(deviceFunList);
- deviceFunList.Show(device, indexVulae, edit, if_type);
+ deviceFunList.Show(device, indexVulae, edit);
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
}
break;
@@ -152,7 +174,7 @@
public static void OutputTarget(FrameLayout thisView, VerticalScrolViewLayout viewLayout)
{
- for (int i = 0; i < Logic.currlogic.output.Count; i++)
+ for (int i = 0; i < Logic.currlogic.output.Count; i++)
{
Output outputTarget = Logic.currlogic.output[i];
///鍚勭鏉′欢鐨刅iew
@@ -161,10 +183,10 @@
///璁板綍鏉′欢绫诲瀷
targetView.btnClick.Name = outputTarget.target_type;
///璁板綍鏉′欢绱㈠紩
- targetView.btnClick.Tag = i;
+ targetView.btnClick.Tag = outputTarget.sid;
///鏉′欢鐘舵�佹暟缁�
List<Dictionary<string, string>> dicList = outputTarget.status as List<Dictionary<string, string>>;
- //鏄剧ず鏉′欢鍚勭绫诲瀷鐘舵��
+ //鏄剧ず杈撳嚭鏉′欢鍚勭绫诲瀷鐘舵��
switch (outputTarget.target_type)
{
case "1":
@@ -177,24 +199,329 @@
targetView.btnText.Text = device.name;
//鏀瑰彉璁惧鍚嶇О鏄剧ず鎺т欢瀹藉害
targetView.btnText.Width = Application.GetRealWidth(80);
+ //绗竴涓彉閲忔樉绀虹姸鎬佸��
+ string stateStr = "";
//鍖哄埆涓嶅悓璁惧锛屾樉绀轰笉鍚岃澶囩姸鎬�
switch (device.functionType)
{
case FunctionType.Relay:
{//寮�鍏崇伅
+
foreach (var dic in dicList)
{
-
string value = dic["value"];
if (value == "on")
{
- targetView.btnState.Text = Language.StringByID(StringId.onLogic);
+ stateStr = Language.StringByID(StringId.onLogic);
}
else
{
- targetView.btnState.Text = Language.StringByID(StringId.offLogic);
+ stateStr = Language.StringByID(StringId.offLogic);
}
+ }
+ targetView.btnState.Text = stateStr;
+ }
+ break;
+ case FunctionType.RGB:
+ case FunctionType.RGBW:
+ case FunctionType.ColorTemperature:
+ case FunctionType.Dimmer:
+ {
+ string on_off = GetKeyValue("on_off", dicList);
+ string brightness = GetKeyValue("brightness", dicList);
+ if (on_off != "")
+ {
+ if (on_off == "on")
+ {
+ stateStr = Language.StringByID(StringId.onLogic);
+
+ }
+ else
+ {
+ stateStr = Language.StringByID(StringId.offLogic);
+
+ }
+ }
+ if (brightness != "")
+ {
+ stateStr += brightness + "%";
+ }
+ if (on_off != "" && on_off == "off")
+ {
+ targetView.btnState.Text = Language.StringByID(StringId.offLogic);
+ }
+ else
+ {
+ targetView.btnState.Text = stateStr;
+
+ }
+
+ }
+ break;
+ case FunctionType.Curtain:
+ {//寮�鍏崇伅
+ foreach (var dic in dicList)
+ {
+ string value = dic["value"];
+ switch (value)
+ {
+ case "on":
+ {
+ stateStr = Language.StringByID(StringId.onLogic);
+ }
+ break;
+ case "off":
+ {
+ stateStr = Language.StringByID(StringId.offLogic);
+ }
+ break;
+ case "stop":
+ {
+ stateStr = Language.StringByID(StringId.stop);
+ }
+ break;
+ }
+ }
+ targetView.btnState.Text = stateStr;
+ }
+ break;
+ case FunctionType.MotorCurtain:
+ case FunctionType.RollingShutter:
+ {//寮�鍏崇伅
+ string on_off = GetKeyValue("on_off", dicList);
+ string brightness = GetKeyValue("brightness", dicList);
+ if (on_off != "")
+ {
+ switch (on_off)
+ {
+ case "on":
+ {
+ stateStr = Language.StringByID(StringId.onLogic);
+
+ }
+ break;
+ case "off":
+ {
+ stateStr = Language.StringByID(StringId.offLogic);
+
+ }
+ break;
+ case "stop":
+ {
+ stateStr = Language.StringByID(StringId.stop);
+ }
+ break;
+ }
+ }
+ if (brightness != "")
+ {
+ stateStr += brightness + "%";
+
+ }
+
+ if (on_off != "" && on_off == "stop"|| on_off != "" && on_off == "off")
+ {
+ targetView.btnState.Text = Language.StringByID(StringId.stop);
+ }
+ else
+ {
+ targetView.btnState.Text = stateStr;
+
+ }
+
+ }
+ break;
+ case FunctionType.AC: {
+ string on_off = GetKeyValue("on_off", dicList);
+ string set_temp = GetKeyValue("set_temp", dicList);
+ string mode = GetKeyValue("mode", dicList);
+ string fan = GetKeyValue("fan", dicList);
+ if (on_off != "") {
+ switch (on_off)
+ {
+ case "on":
+ {
+ stateStr = Language.StringByID(StringId.onLogic)+",";
+ }
+ break;
+ case "off":
+ {
+ stateStr = Language.StringByID(StringId.offLogic) + ",";
+ }
+ break;
+
+ }
+ }
+
+ if (set_temp != "")
+ {
+
+ stateStr += set_temp + "鈩�,";
+ }
+
+ if (mode != "")
+ {
+
+ switch (mode)
+ {
+ case "cool":
+ {
+ stateStr += Language.StringByID(StringId.coolLogic)+",";
+ }
+ break;
+ case "heat":
+ {
+ stateStr += Language.StringByID(StringId.heatingLogic) + ",";
+ }
+ break;
+ case "auto":
+ {
+ stateStr += Language.StringByID(StringId.autoLogic) + ",";
+ }
+ break;
+ case "dry":
+ {
+ stateStr += Language.StringByID(StringId.dehumidifyLogic) + ",";
+ }
+ break;
+ }
+
+ }
+
+ if (fan != "")
+ {
+
+ switch (fan)
+ {
+ case "high":
+ {
+ stateStr += Language.StringByID(StringId.HighWindSpeed)+",";
+ }
+ break;
+ case "medium":
+ {
+ stateStr += Language.StringByID(StringId.MiddleWindSpeed) + ",";
+ }
+ break;
+ case "low":
+ {
+ stateStr += Language.StringByID(StringId.LowWindSpeed) + ",";
+ }
+ break;
+ case "auto":
+ {
+ stateStr += Language.StringByID(StringId.Auto) + ",";
+ }
+ break;
+ }
+
+ }
+ if (on_off != "" && on_off == "off")
+ {
+ targetView.btnState.Text = Language.StringByID(StringId.offLogic);
+ }
+ else {
+ targetView.btnState.Text = stateStr.TrimEnd(',');
+
+ }
+
+ }
+ break;
+ case FunctionType.FloorHeating:
+ {
+ string on_off = GetKeyValue("on_off", dicList);
+ string set_temp = GetKeyValue("set_temp", dicList);
+ string mode = GetKeyValue("mode", dicList);
+ if (on_off != "")
+ {
+ switch (on_off)
+ {
+ case "on":
+ {
+ stateStr = Language.StringByID(StringId.onLogic) + ",";
+ }
+ break;
+ case "off":
+ {
+ stateStr = Language.StringByID(StringId.offLogic) + ",";
+ }
+ break;
+
+ }
+ }
+ if (set_temp != "")
+ {
+
+ stateStr += set_temp + "鈩�,";
+ }
+ if (mode != "")
+ {
+
+ switch (mode)
+ {
+ case "day":
+ {
+ stateStr += Language.StringByID(StringId.dayMode)+",";
+ }
+ break;
+ case "night":
+ {
+ stateStr += Language.StringByID(StringId.nightMode) + ",";
+ }
+ break;
+
+ case "away":
+ {
+ stateStr += Language.StringByID(StringId.leaveMode) + ",";
+ }
+ break;
+ case "normal":
+ {
+ stateStr += Language.StringByID(StringId.ordinaryMode) + ",";
+ }
+ break;
+ case "timer":
+ {
+ stateStr += Language.StringByID(StringId.timeMode) + ",";
+ }
+ break;
+ }
+
+
+ switch (mode)
+ {
+ case "cool":
+ {
+ stateStr += Language.StringByID(StringId.coolLogic) + ",";
+ }
+ break;
+ case "heat":
+ {
+ stateStr += Language.StringByID(StringId.heatingLogic) + ",";
+ }
+ break;
+ case "auto":
+ {
+ stateStr += Language.StringByID(StringId.autoLogic) + ",";
+ }
+ break;
+ case "dry":
+ {
+ stateStr += Language.StringByID(StringId.dehumidifyLogic) + ",";
+ }
+ break;
+ }
+
+ }
+ if (on_off != "" && on_off == "off")
+ {
+ targetView.btnState.Text =Language.StringByID(StringId.offLogic);
+ }
+ else
+ {
+ targetView.btnState.Text = stateStr.TrimEnd(',');
+
}
}
break;
@@ -217,7 +544,7 @@
foreach (var dic in dicList)
{
string value = dic["value"];
- targetView.btnText.Text =value;
+ targetView.btnText.Text = value;
}
}
break;
@@ -227,20 +554,29 @@
{
Button button = (Button)sen;
//鎵惧埌褰撳墠缂栬緫鐨勭储寮�
- int indexVulae = int.Parse(targetView.btnClick.Tag.ToString());
+ int indexVulae =0;
+ for (int index = 0; index < Logic.currlogic.output.Count; index++)
+ {
+ Output target = Logic.currlogic.output[index];
+ if (target.sid == targetView.btnClick.Tag.ToString())
+ {
+ //鐢ㄦ埛鍙兘鍒犻櫎鏁版嵁锛屼娇鍒楄〃绱㈠紩鍙戠敓鏀瑰彉锛�
+ //閫氳繃鍞竴sid閲嶆柊鏌ユ壘鍒扮储寮曚笖鏇存柊绱㈠紩鍊�
+ indexVulae = index;
+ break;
+ }
+ }
//鏍囪缂栬緫鐘舵��
bool edit = true;
- //琛ㄧず鏄洰鏍�
- string if_type = LogicMethod.target_if;
switch (button.Name)
{
case "1":
{
//鐢╯id鎵惧埌璁惧锛�
var device = LogicMethod.GetDevice(outputTarget.sid);
- DeviceFunList deviceFunList = new DeviceFunList();
+ TargetDeviceFunList deviceFunList = new TargetDeviceFunList();
MainPage.BasePageView.AddChidren(deviceFunList);
- deviceFunList.Show(device, indexVulae, edit, if_type);
+ deviceFunList.Show(device, indexVulae, edit);
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
}
break;
@@ -255,7 +591,7 @@
AddTarget addTarget = new AddTarget();
addTarget.Delayed(fLayout, edit, indexVulae);
-
+
}
break;
}
@@ -269,5 +605,26 @@
}
}
+ /// <summary>
+ /// 鑾峰彇value閿��
+ /// </summary>
+ /// <param name="keyValue"></param>
+ /// <param name="dicList"></param>
+ /// <returns></returns>
+ private static string GetKeyValue(string keyValue, List<Dictionary<string, string>> dicList)
+ {
+
+ string valueStr = "";
+ foreach (var dic in dicList)
+ {
+ if (dic["key"] == keyValue)
+ {
+ valueStr = dic["value"];
+ break;
+ }
+
+ }
+ return valueStr;
+ }
}
}
--
Gitblit v1.8.0