From 6eb21769c74cfcd10084f73ff3f212355849a3c7 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期一, 17 五月 2021 15:00:13 +0800
Subject: [PATCH] 2021-5-17-2
---
HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs | 360 +++++++++++++++++++++++++++++++++++++++++------------------
1 files changed, 248 insertions(+), 112 deletions(-)
diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs
index bb24069..47f2d15 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs
@@ -1,6 +1,8 @@
-锘縰sing System;
+using System;
using Shared;
using System.Collections.Generic;
+using HDL_ON.Entity;
+
namespace HDL_ON.UI.UI2.Intelligence.Automation
{
public class ConditionDeviceFunList : FrameLayout
@@ -17,10 +19,6 @@
/// 瀹氫箟涓�涓彉閲忥紝璁板綍閫変腑鐘舵��
/// </summary>
private string selectedState = "unknown";
- /// <summary>
- /// 瀹氫箟涓�涓彉閲忥紝璁板綍閫変腑鐘舵�佽褰曞睘鎬�
- /// </summary>
- private string keyVlaue = "";
public void Show(Entity.Function device, int index, bool edit)
{
#region 鐣岄潰甯冨眬
@@ -40,41 +38,141 @@
};
this.AddChidren(fLayout);
#endregion
- switch (device.functionType)
+ switch (device.spk)
{
//寮�鍏崇伅鍏� light.Switch
- case FunctionType.Dimmer:
- case FunctionType.RGB:
- case FunctionType.RGBW:
- case FunctionType.ColorTemperature:
- case FunctionType.Relay:
+ case SPK.LightDimming:
+ case SPK.LightRGB:
+ case SPK.LightRGBW:
+ case SPK.LightCCT:
+ case SPK.LightSwitch:
//绐楀笜
- case FunctionType.Curtain:
- case FunctionType.RollingShutter:
- case FunctionType.MotorCurtain:
+ case SPK.CurtainSwitch:
+ case SPK.CurtainRoller:
+ case SPK.CurtainTrietex:
//绌鸿皟
- case FunctionType.AC:
+ case SPK.AcStandard:
//鍦扮儹
- case FunctionType.FloorHeating:
+ case SPK.FloorHeatStandard:
{
- LogicView.FunTypeView lightSwitchView = new LogicView.FunTypeView();
- lightSwitchView.btnText.TextID = StringId.switchLogic;
- lightSwitchView.btnState.Text = "";
- fLayout.AddChidren(lightSwitchView.FLayoutView());
- lightSwitchView.btnClick.MouseUpEventHandler += (sender, e) =>
+
+ LogicView.FunTypeView view = new LogicView.FunTypeView();
+ view.btnText.TextID = StringId.switchLogic;
+ fLayout.AddChidren(view.FLayoutView());
+ view.btnClick.MouseUpEventHandler += (sender, e) =>
{
- FrameLayout frame = new FrameLayout
- {
- BackgroundColor = CSS.CSS_Color.viewTrans60lucence,
- };
- this.AddChidren(frame);
- SwitchViewMethod(frame, device, lightSwitchView.btnState, 2);
+ DeviceView(device, view.btnState, StringId.onLogic, StringId.offLogic);
};
if (edit)
{
- GetEditState(device, index, lightSwitchView.btnState, null, null, null);
+ GetEditState(device, index, view.btnState, null, null, null);
+ }
+ }
+ break;
+ case SPK.SensorWater:
+ {
+ LogicView.FunTypeView view = new LogicView.FunTypeView();
+ view.btnText.TextID = StringId.luoshuiandwuluoshui;
+ fLayout.AddChidren(view.FLayoutView());
+ view.btnClick.MouseUpEventHandler += (sender, e) =>
+ {
+ DeviceView(device, view.btnState, StringId.luoshui, StringId.wuluoshui);
+ };
+ if (edit)
+ {
+ GetEditState(device, index, view.btnState, null, null, null);
}
+ }
+ break;
+ case SPK.SensorSmoke:
+ case SPK.SensorGas:
+ {
+ LogicView.FunTypeView view = new LogicView.FunTypeView();
+ view.btnText.TextID = StringId.xieluoandwuxieluo;
+ fLayout.AddChidren(view.FLayoutView());
+ view.btnClick.MouseUpEventHandler += (sender, e) =>
+ {
+ DeviceView(device, view.btnState, StringId.xieluo, StringId.wuxieluo);
+ };
+ if (edit)
+ {
+ GetEditState(device, index, view.btnState, null, null, null);
+ }
+
+ }
+ break;
+ case SPK.SensorDryContact:
+ {
+ LogicView.FunTypeView view = new LogicView.FunTypeView();
+ view.btnText.TextID = StringId.switchLogic;
+ fLayout.AddChidren(view.FLayoutView());
+ view.btnClick.MouseUpEventHandler += (sender, e) =>
+ {
+ DeviceView(device, view.btnState, StringId.onLogic, StringId.offLogic);
+ };
+ if (edit)
+ {
+ GetEditState(device, index, view.btnState, null, null, null);
+ }
+
+ }
+ break;
+ case SPK.SensorShanLan:
+ case SPK.SensorDuiShe:
+ case SPK.SensorPir:
+ {
+ LogicView.FunTypeView view = new LogicView.FunTypeView();
+ view.btnText.TextID = StringId.yourenandwuren;
+ fLayout.AddChidren(view.FLayoutView());
+ view.btnClick.MouseUpEventHandler += (sender, e) =>
+ {
+ DeviceView(device, view.btnState, StringId.youren, StringId.wuren);
+ };
+ if (edit)
+ {
+ GetEditState(device, index, view.btnState, null, null, null);
+ }
+ }
+ break;
+ case SPK.SensorDoorWindow:
+ {
+ LogicView.FunTypeView view = new LogicView.FunTypeView();
+ view.btnText.TextID = StringId.kaiqiandbihe;
+ fLayout.AddChidren(view.FLayoutView());
+ view.btnClick.MouseUpEventHandler += (sender, e) =>
+ {
+ DeviceView(device, view.btnState, StringId.kaiqi, StringId.bihe);
+ };
+ if (edit)
+ {
+ GetEditState(device, index, view.btnState, null, null, null);
+ }
+ }
+ break;
+ case SPK.SensoruUtrasonic:
+ {
+
+ LogicView.FunTypeView view = new LogicView.FunTypeView();
+ view.btnText.TextID = StringId.yourenandwuren;
+ fLayout.AddChidren(view.FLayoutView());
+ view.btnClick.MouseUpEventHandler += (sender, e) =>
+ {
+ DeviceView(device, view.btnState, StringId.youren, StringId.wuren);
+ };
+ LogicView.FunTypeView view1 = new LogicView.FunTypeView();
+ view1.frameLayout.Y = view.frameLayout.Bottom;
+ view1.btnText.TextID = StringId.fangchaigongneng;
+ fLayout.AddChidren(view1.FLayoutView());
+ view1.btnClick.MouseUpEventHandler += (sender, e) =>
+ {
+ DeviceView(device, view1.btnState, StringId.zaixian, StringId.buzaixian);
+ };
+
+ if (edit)
+ {
+ GetEditState(device, index, view.btnState, view1.btnState, null, null);
+ }
}
break;
@@ -87,8 +185,6 @@
this.AddChidren(saveView.FLayoutView());
saveView.btnClick.MouseUpEventHandler += (sen, e) =>
{
-
-
if (selectedState != "unknown")
{
Input inputDevice = new Input();
@@ -119,51 +215,117 @@
return;
}
LogicMethod.RemoveAllView();
- AddLogic addLogic = new AddLogic();
- MainPage.BasePageView.AddChidren(addLogic);
- addLogic.Show();
- MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+
+ if (MainView.IsGatewayType)
+ { //A缃戝叧
+ var addLogic = new AddLogic();
+ MainPage.BasePageView.AddChidren(addLogic);
+ addLogic.Show();
+ MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+ }
+ else
+ {
+ //涓�绔彛缃戝叧
+ var onePortAutomation = new OnePortAutomation();
+ MainPage.BasePageView.AddChidren(onePortAutomation);
+ onePortAutomation.Show();
+ MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+ }
};
#endregion
}
/// <summary>
- /// 寮�鍏冲姛鑳藉睍寮�鐣岄潰
+ /// 璁惧閫夋嫨鏉′欢鐣岄潰
/// </summary>
- /// <param name="frame"></param>
- /// <param name="device"></param>
- /// <param name="button"></param>
- /// <param name="len"></param>
- public void SwitchViewMethod(FrameLayout frame, Entity.Function device, Button button, int len)
- {
-
+ /// <param name="device">璁惧</param>
+ /// <param name="button">閫変腑鐘舵�佹樉绀烘枃鏈珺tn鎺т欢</param>
+ /// <param name="btnText1">灞炴�х姸鎬佸�兼枃鏈�1</param>
+ /// <param name="btnText2">灞炴�х姸鎬佸�兼枃鏈�2</param>
+ private void DeviceView(Entity.Function device,Button button,int btnText1,int btnText2) {
+ FrameLayout frame = new FrameLayout { BackgroundColor = CSS.CSS_Color.viewTrans60lucence };
+ this.AddChidren(frame);
LogicView.SwitchView switchView = new LogicView.SwitchView();
- switchView.FLayoutView(frame, len, button.Text, (strValue) =>
+ switchView.FLayoutView(frame, btnText1, btnText2, button.Text, (intValue) =>
{
- int id = 0;
- switch (strValue)
+ //璁惧灞炴�у�硷紝浜戦泙涓婂畾涔夊ソ鐨�;
+ string keyVlaue = "on_off";
+ string value = "";
+ switch (device.spk)
{
- case "on":
+ //浼犳劅鍣�
+ case SPK.SensorWater:
+ case SPK.SensorSmoke:
+ case SPK.SensorGas:
+ case SPK.SensorDryContact:
+ case SPK.SensorShanLan:
+ case SPK.SensorDuiShe:
+ case SPK.SensorPir:
+ case SPK.SensorDoorWindow:
+ case SPK.SensoruUtrasonic:
{
- id = StringId.onLogic;
+ keyVlaue = "status";
}
break;
- case "off":
- {
- id = StringId.offLogic;
- }
- break;
+
}
- button.TextID = id;
- keyVlaue = "on_off";
- Dictionary<string, string> dic = new Dictionary<string, string>();
- LogicMethod.dictionary(dic, "key", "on_off");
- LogicMethod.dictionary(dic, "comparator", "=");
- LogicMethod.dictionary(dic, "data_type", "string");
- LogicMethod.dictionary(dic, "value", strValue);
- AddDictionaryData(dicSateteList, keyVlaue, dic);
- selectedState = device.functionType + "_" + strValue;
+ switch (intValue)
+ {
+ case StringId.xieluo:
+ case StringId.luoshui:
+ {
+ value = "alarm";
+ }
+ break;
+ case StringId.wuxieluo:
+ case StringId.wuluoshui:
+ {
+ value = "normal";
+ }
+ break;
+ case StringId.onLogic:
+ {
+ value = "on";
+ }
+ break;
+ case StringId.offLogic:
+ {
+ value = "off";
+ }
+ break;
+ case StringId.youren: {
+ value = "true";
+ }
+ break;
+ case StringId.wuren: {
+ value = "false";
+ }
+ break;
+ case StringId.kaiqi:
+ {
+ value = "open";
+ }
+ break;
+ case StringId.bihe:
+ {
+ value = "close";
+ }
+ break;
+ case StringId.zaixian: {
+ keyVlaue = "dismantle";
+ value = "true";
+ };break;
+ case StringId.buzaixian:
+ {
+ keyVlaue = "dismantle";
+ value = "false";
+ }; break;
+ }
+ //鏄剧ず鏂囨湰
+ button.TextID = intValue;
+ selectedState = device.spk + "_" + value;
+ AddDictionary(keyVlaue, value);
});
@@ -177,7 +339,7 @@
/// <param name="button2">鏄剧ずBtn</param>
/// <param name="button3">鏄剧ずBtn</param>
/// <param name="button4">鏄剧ずBtn</param>
- private void GetEditState(Entity.Function device , int index, Button button1, Button button2, Button button3, Button button4)
+ private void GetEditState(Entity.Function device, int index, Button button1, Button button2, Button button3, Button button4)
{
Input inputs = Logic.currlogic.input[index];
var dicList = inputs.condition as List<Dictionary<string, string>>;
@@ -188,53 +350,35 @@
//鏈夋暟鎹噸鏂拌祴鍊�
dicSateteList = dicList;
}
- 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)
- {
- string value = dic["value"];
- if (value == "on")
- {
- button1.Text = Language.StringByID(StringId.onLogic);
- }
- else
- {
- button1.Text = Language.StringByID(StringId.offLogic);
- }
- }
- }
- break;
-
- }
+ InpOrOutLogicMethod.EditState(device, dicList, button1, button2, button3, button4);
}
/// <summary>
/// 娣诲姞閫変腑鏁版嵁
/// </summary>
- /// <param name="dicList">瀛樺偍鏁版嵁鍒楄〃</param>
- /// <param name="keyValue">璇嗗埆璁惧</param>
- /// <param name="dictionary">閫変腑鏁版嵁</param>
+ /// <param name="KeyValue">璁惧灞炴�у�硷紝浜戦泙涓婂畾涔夊ソ鐨�</param>
+ /// <param name="selectedValue">鐘舵�佸��</param>
+ private void AddDictionary(string KeyValue, string selectedValue)
+ {
+ //鏁版嵁灏佽
+ Dictionary<string, string> dic = new Dictionary<string, string>();
+ LogicMethod.dictionary(dic, "key", KeyValue);
+ LogicMethod.dictionary(dic, "comparator", "=");
+ LogicMethod.dictionary(dic, "data_type", "string");
+ LogicMethod.dictionary(dic, "value", selectedValue);
+ AddDictionaryList(KeyValue, dic);
+ }
+ /// <summary>
+ /// 鏇存柊鏁版嵁鍒楄〃
+ /// </summary>
+ /// <param name="keyValue">璁惧灞炴�у�硷紝浜戦泙涓婂畾涔夊ソ鐨�</param>
+ /// <param name="dictionary">娣诲姞閫変腑鏁版嵁</param>
/// <returns></returns>
- private void AddDictionaryData(List<Dictionary<string, string>> dicList, string keyValue, Dictionary<string, string> dictionary)
+ private void AddDictionaryList(string keyValue, Dictionary<string, string> dictionary)
{
int indexValue = -1;
- for (int i = 0; i < dicList.Count; i++)
+ for (int i = 0; i < dicSateteList.Count; i++)
{
- var dic = dicList[i];
+ var dic = dicSateteList[i];
if (dic.ContainsValue(keyValue))
{
//鍒ゆ柇鏄惁瀛樺湪
@@ -246,14 +390,14 @@
if (indexValue != -1)
{
//瀛樺湪绉婚櫎
- dicList.RemoveAt(indexValue);
+ dicSateteList.RemoveAt(indexValue);
//閲嶆柊娣诲姞
- dicList.Insert(indexValue, dictionary);
+ dicSateteList.Insert(indexValue, dictionary);
}
else
{
//鏂版坊鍔�
- dicList.Add(dictionary);
+ dicSateteList.Add(dictionary);
}
}
@@ -283,14 +427,6 @@
Logic.currlogic.input.Add(input);
}
- }
- /// <summary>
- /// 绉婚櫎鎺т欢
- /// </summary>
- /// <param name="frame"></param>
- private void RemView(FrameLayout frame)
- {
- frame.RemoveFromParent();
}
}
}
--
Gitblit v1.8.0