Merge remote-tracking branch 'origin/WJC' into NewFilePath
| | |
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\3-Intelligence\Automation\LogicView\BrightnessView.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)Common\ApiUtlis.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\3-Intelligence\Automation\InterfaceDsplaysLogic.cs" />
|
| | | <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\3-Intelligence\Automation\LogicView\TemperatureView.cs" />
|
| | | </ItemGroup>
|
| | | <ItemGroup>
|
| | | <Folder Include="$(MSBuildThisFileDirectory)UI\" />
|
| | |
| | | <Folder Include="$(MSBuildThisFileDirectory)UI\BindingResidence\" />
|
| | | <Folder Include="$(MSBuildThisFileDirectory)Common\Utlis\" />
|
| | | </ItemGroup>
|
| | | </Project> |
| | | </Project>
|
| | |
| | | ///或和与点击事件 |
| | | titleCondition.btnClick.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | FrameLayout fLayout = new FrameLayout |
| | | { |
| | | BackgroundColor = CSS.CSS_Color.viewTrans60lucence, |
| | | }; |
| | | this.AddChidren(fLayout); |
| | | AndOrMethod(fLayout, titleCondition.btnText); |
| | | AndOrMethod(titleCondition.btnText); |
| | | }; |
| | | ///条件添加点击事件 |
| | | addInputIcon.btnClick.MouseUpEventHandler += (sen, e) => |
| | |
| | | { |
| | | list.Add(logic.name); |
| | | } |
| | | new LogicView.TipPopView().InputBox(StringId.editName, InterfaceDsplaysLogic.GetLogicName(Logic.currlogic), StringId.nameNull, StringId.NameAlreadyExists, list, (logicName) => |
| | | new LogicView.TipPopView().InputBox(StringId.editName, InpOrOutLogicMethod.GetLogicName(Logic.currlogic), StringId.nameNull, StringId.NameAlreadyExists, list, (logicName) => |
| | | { |
| | | Logic.currlogic.name = logicName; |
| | | Logic.currlogic.sid = LogicMethod.NewSid(); |
| | |
| | | try |
| | | { |
| | | //发送修改逻辑命令; |
| | | responsePackNew = Send.updateLogic(Logic.currlogic); |
| | | responsePackNew = Send.UpdateLogic(Logic.currlogic); |
| | | |
| | | } |
| | | catch { } |
| | |
| | | /// <param name="button">显示文本</param> |
| | | public void WeekMethod(FrameLayout fLayout, Button button) |
| | | { |
| | | List<string> weekStr = new List<string> { |
| | | Language.StringByID(StringId.monday), |
| | | Language.StringByID(StringId.tuesday), |
| | | Language.StringByID(StringId.wednesday), |
| | | Language.StringByID(StringId.thursday), |
| | | Language.StringByID(StringId.friday), |
| | | Language.StringByID(StringId.saturday), |
| | | Language.StringByID(StringId.sunday), |
| | | }; |
| | | |
| | | //定义一个局部weekList列表用来记录选中数据; |
| | | List<string> weekStateList = new List<string>(); |
| | | weekStateList.Clear(); |
| | | |
| | | PublicInterface weekView = new PublicInterface(); |
| | | if (Logic.currlogic.cycle.type == "week") |
| | | { |
| | | var list = InterfaceDsplaysLogic.GetWeekString(Logic.currlogic.cycle.value, "int"); |
| | | //数据转换 |
| | | var list = weekView.GetWeekString(Logic.currlogic.cycle.value, "int"); |
| | | //加载之前保存的数据 |
| | | weekStateList.AddRange(list); |
| | | } |
| | | PublicInterface weekView = new PublicInterface(); |
| | | weekView.MultiSelectShow(fLayout, weekStr, Language.StringByID(StringId.cyclic), weekStateList |
| | | var weekListStr= weekView.GetViewList("week"); |
| | | weekView.MultiSelectShow(fLayout, weekListStr, Language.StringByID(StringId.cyclic), weekStateList |
| | | , (list) => |
| | | { |
| | | var statelist = InterfaceDsplaysLogic.GetWeekString(list, "str"); |
| | | |
| | | //选中数据处理 |
| | | var statelist = weekView.GetWeekString(list, "str"); |
| | | string textStr = MainView.GetWeekString(statelist); |
| | | //显示选中数据 |
| | | button.Text = textStr; |
| | | //封装数据 |
| | | Logic.currlogic.cycle.type = "week"; |
| | | Logic.currlogic.cycle.value = statelist; |
| | | button.Text = MainView.GetWeekString(statelist); |
| | | |
| | | }); |
| | | } |
| | |
| | | PublicInterface weekView = new PublicInterface(); |
| | | weekView.MonSelectShow(fLayout, Logic.currlogic, (monList) => |
| | | { |
| | | //选中数据处理 |
| | | string textStr= MainView.GetMonString(monList); |
| | | //显示选中数据 |
| | | button.Text = textStr; |
| | | //封装数据 |
| | | Logic.currlogic.cycle.type = "mon"; |
| | | Logic.currlogic.cycle.value = monList; |
| | | button.Text = MainView.GetMonString(monList); |
| | | }); |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 满足条件 |
| | | /// </summary> |
| | | /// <param name="fLayout">弹框主控件</param> |
| | | /// <param name="button">显示文本</param> |
| | | public void AndOrMethod(FrameLayout fLayout, Button button) |
| | | public void AndOrMethod(Button button) |
| | | { |
| | | List<string> strList = new List<string> { |
| | | Language.StringByID(StringId.andCondition), |
| | | Language.StringByID(StringId.orCondition), |
| | | }; |
| | | |
| | | ///之前的状态文本 |
| | | string currCondition = button.Text; |
| | | |
| | | PublicInterface conditionView = new PublicInterface(); |
| | | conditionView.SingleSelectionShow(fLayout, strList, Language.StringByID(StringId.meetTheCondition), currCondition |
| | | var strList = conditionView.GetViewList("andor"); |
| | | conditionView.SingleSelectionShow(this, strList, Language.StringByID(StringId.meetTheCondition), currCondition |
| | | , (stateValue) => |
| | | { |
| | | //界面显示选中值 |
| | | button.Text = stateValue; |
| | | //封装数据 |
| | | if (stateValue == Language.StringByID(StringId.orCondition)) |
| | | { |
| | | Logic.currlogic.relation = "or"; |
| | |
| | | { |
| | | Logic.currlogic.relation = "and"; |
| | | } |
| | | button.Text = stateValue; |
| | | |
| | | }); |
| | | |
| | |
| | | } |
| | | return valueStr; |
| | | } |
| | | |
| | | /// <summary> |
| | | ///获取自动化名称 |
| | | /// </summary> |
| | | /// <returns> 新建自动化命名规则</returns> |
| | | public static string GetLogicName(Logic logic) |
| | | { |
| | | |
| | | string name = ""; |
| | | try |
| | | { |
| | | //默认取第一个条件 |
| | | Input inputCondition = logic.input[0]; |
| | | //显示条件各种类型状态 |
| | | switch (inputCondition.condition_type) |
| | | { |
| | | case "1": |
| | | { |
| | | name = Language.StringByID(StringId.hour) + "-"; |
| | | } |
| | | break; |
| | | case "2": |
| | | { |
| | | name = Language.StringByID(StringId.timeHorizon) + "-"; |
| | | |
| | | } |
| | | break; |
| | | case "3": |
| | | { |
| | | //用sid找到设备; |
| | | var device = LogicMethod.GetDevice(inputCondition.sid); |
| | | name = device.name + "-"; |
| | | } |
| | | break; |
| | | |
| | | } |
| | | //默认取第一个目标 |
| | | Output outputTarget = logic.output[0]; |
| | | List<Dictionary<string, string>> dicList = outputTarget.status as List<Dictionary<string, string>>; |
| | | //显示输出条件各种类型状态 |
| | | switch (outputTarget.target_type) |
| | | { |
| | | case "1": |
| | | { |
| | | //用sid找到设备; |
| | | var device = LogicMethod.GetDevice(outputTarget.sid); |
| | | //显示设备名称 |
| | | name += device.name; |
| | | string stateStr = ""; |
| | | //区别不同设备,显示不同设备状态 |
| | | switch (device.functionType) |
| | | { |
| | | case FunctionType.Relay: |
| | | {//开关灯 |
| | | |
| | | foreach (var dic in dicList) |
| | | { |
| | | string value = dic["value"]; |
| | | if (value == "on") |
| | | { |
| | | stateStr = Language.StringByID(StringId.onLogic); |
| | | |
| | | } |
| | | else |
| | | { |
| | | stateStr = Language.StringByID(StringId.offLogic); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | case FunctionType.RGB: |
| | | case FunctionType.RGBW: |
| | | case FunctionType.ColorTemperature: |
| | | case FunctionType.Dimmer: |
| | | { |
| | | string on_off = InpOrOutLogicMethod.GetKeyValue("on_off", dicList); |
| | | string brightness = InpOrOutLogicMethod.GetKeyValue("brightness", dicList); |
| | | if (on_off == "on" && brightness != "") |
| | | { |
| | | stateStr = Language.StringByID(StringId.onLogic) + brightness + "%"; |
| | | } |
| | | else if (on_off == "on") |
| | | { |
| | | stateStr = Language.StringByID(StringId.onLogic); |
| | | } |
| | | else if (on_off == "off") |
| | | { |
| | | stateStr = Language.StringByID(StringId.offLogic); |
| | | } |
| | | else if (brightness != "") |
| | | { |
| | | stateStr = brightness + "%"; |
| | | } |
| | | } |
| | | break; |
| | | case FunctionType.Curtain: |
| | | case FunctionType.MotorCurtain: |
| | | case FunctionType.RollingShutter: |
| | | { |
| | | 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; |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | case FunctionType.AC: |
| | | case FunctionType.FloorHeating: |
| | | { |
| | | foreach (var dic in dicList) |
| | | { |
| | | string value = dic["value"]; |
| | | if (value == "on") |
| | | { |
| | | stateStr = Language.StringByID(StringId.onLogic); |
| | | |
| | | } |
| | | else if (value == "off") |
| | | { |
| | | stateStr = Language.StringByID(StringId.offLogic); |
| | | } |
| | | } |
| | | |
| | | } |
| | | break; |
| | | |
| | | } |
| | | name += stateStr; |
| | | } |
| | | break; |
| | | case "2": |
| | | { |
| | | //用sid找到场景; |
| | | var scene = LogicMethod.GetSecne(outputTarget.sid); |
| | | name += scene.name; |
| | | |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | catch { } |
| | | return name; |
| | | } |
| | | } |
| | | } |
| | |
| | | btnText.Gravity = Gravity.CenterVertical; |
| | | btnText.TextAlignment = TextAlignment.CenterLeft; |
| | | btnNextIcon.Gravity = Gravity.CenterVertical; |
| | | btnDeviceName.Gravity= Gravity.CenterVertical; |
| | | //btnDeviceName.Gravity= Gravity.CenterVertical; |
| | | frameLayout.AddChidren(btnIcon); |
| | | frameLayout.AddChidren(btnText); |
| | | frameLayout.AddChidren(btnDeviceName); |
| | |
| | | |
| | | }; |
| | | /// <summary> |
| | | /// 图标开关 |
| | | /// 点击事件 |
| | | /// </summary> |
| | | public Button btnclick= new Button |
| | | { |
New file |
| | |
| | | using System; |
| | | using Shared; |
| | | using System.Collections.Generic; |
| | | namespace HDL_ON.UI.UI2.Intelligence.Automation.LogicView |
| | | { |
| | | public class TemperatureView |
| | | { |
| | | /// <summary> |
| | | /// view |
| | | /// </summary> |
| | | /// <param name="frameLayout">弹窗父控件</param> |
| | | /// <param name="stateValue">之前状态值</param> |
| | | /// <param name="action">返回结果</param> |
| | | public void FLayoutView(FrameLayout frameLayout, string stateValue, Action<string> action) |
| | | { |
| | | FrameLayout frame = new FrameLayout |
| | | { |
| | | BackgroundColor = CSS.CSS_Color.viewTrans60lucence, |
| | | }; |
| | | frameLayout.AddChidren(frame); |
| | | LogicView.TimeView view = new LogicView.TimeView(); |
| | | view.FLayoutView(frame); |
| | | //取消点击事件 |
| | | view.btnCancel.MouseUpEventHandler += (sender1, e1) => |
| | | { |
| | | //移除fLayout界面 |
| | | frame.RemoveFromParent(); |
| | | }; |
| | | //初始化列表 |
| | | var temperatureList = new List<string>(); |
| | | for (int i = 16; i < 32; i++) |
| | | { |
| | | //添加数据 |
| | | temperatureList.Add(i.ToString() + "℃"); |
| | | temperatureList.Add((i + 0.5).ToString() + "℃"); |
| | | } |
| | | //加载数据界面的设置方法(列表互不联动) |
| | | view.mUIPickerView.setNPicker(temperatureList, null, null); |
| | | //默认初始选中状态 |
| | | view.mUIPickerView.setCurrentItems(9, 0, 0); |
| | | //定义一个局部变量记录选中时间 |
| | | string temperature = "25℃"; |
| | | for (int i = 0; i < temperatureList.Count; i++) |
| | | { |
| | | if (temperatureList[i] == stateValue) |
| | | { |
| | | //更新状态 |
| | | view.mUIPickerView.setCurrentItems(i, 0, 0); |
| | | //更新状态 |
| | | temperature = temperatureList[i]; |
| | | break; |
| | | } |
| | | } |
| | | //选中时间回调方法,时间变化一次回调一次 |
| | | view.mUIPickerView.OnSelectChangeEvent += (index1, index2, index3) => |
| | | { |
| | | temperature = temperatureList[index1]; |
| | | }; |
| | | //确定点击事件 |
| | | view.btnConfirm.MouseUpEventHandler += (sender2, e2) => |
| | | { |
| | | action(temperature); |
| | | frame.RemoveFromParent(); |
| | | }; |
| | | } |
| | | } |
| | | } |
| | |
| | | try |
| | | { |
| | | //逻辑使能的命令 |
| | | Send.switchLogic(currLogic); |
| | | Send.SwitchLogic(currLogic); |
| | | |
| | | } |
| | | catch { } |
| | |
| | | } |
| | | List<string> logicIdList = new List<string>(); |
| | | //获取逻辑ID列表 |
| | | var idStr = Send.getLogicIdList(); |
| | | var idStr = Send.GetLogicIdList(); |
| | | if (idStr.Code == "0" && idStr.Data != null && idStr.Data.ToString() != "") |
| | | { |
| | | var date = Newtonsoft.Json.JsonConvert.SerializeObject(idStr.Data); |
| | |
| | | } |
| | | } |
| | | //获取自动化列表 |
| | | var logicStr = Send.getLogic(logicIdList); |
| | | var logicStr = Send.GetLogic(logicIdList); |
| | | if (logicStr.Code == "0" && logicStr.Data != null && logicStr.Data.ToString() != "") |
| | | { |
| | | //获取逻辑详细返回是一个数组(object类型转换为数组); |
| | |
| | | /// <summary> |
| | | /// 单选择 |
| | | /// </summary> |
| | | /// <param name="frameLayout">父控件</param> |
| | | /// <param name="frame">显示在哪个界面的父控件</param> |
| | | /// <param name="list">显示数据源</param> |
| | | /// <param name="titleText"></param> |
| | | /// <param name="stateText">之前状态文本</param> |
| | | /// <param name="action">返回值</param> |
| | | /// <param name="textSize">显示文本字体大小</param> |
| | | public void SingleSelectionShow(FrameLayout frameLayout, List<string> list, string titleText, string stateText, Action<string> action, int textSize = LogicView.TextSize.text14) |
| | | public void SingleSelectionShow(FrameLayout frame, List<string> list, string titleText, string stateText, Action<string> action, int textSize = LogicView.TextSize.text14) |
| | | { |
| | | FrameLayout frameLayout = new FrameLayout |
| | | { |
| | | BackgroundColor = CSS.CSS_Color.viewTrans60lucence, |
| | | }; |
| | | frame.AddChidren(frameLayout); |
| | | |
| | | LogicView.DateView view = new LogicView.DateView(); |
| | | view.btnTitle.Text = titleText; |
| | | view.FLayoutView(frameLayout, list.Count); |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 获取界面列表 |
| | | /// </summary> |
| | | /// <param name="isStr">自己定义自己用</param> |
| | | /// <returns></returns> |
| | | public List<string> GetViewList(string isStr) |
| | | { |
| | | List<string> list = null; |
| | | switch (isStr) |
| | | { |
| | | case "mode": |
| | | { |
| | | list = new List<string> { |
| | | Language.StringByID(StringId.coolLogic), |
| | | Language.StringByID(StringId.heatingLogic), |
| | | Language.StringByID(StringId.autoLogic), |
| | | Language.StringByID(StringId.dehumidifyLogic), |
| | | }; |
| | | } |
| | | break; |
| | | case "fan": |
| | | { |
| | | list = new List<string> { |
| | | Language.StringByID(StringId.LowWindSpeed), |
| | | Language.StringByID(StringId.MiddleWindSpeed), |
| | | Language.StringByID(StringId.HighWindSpeed), |
| | | Language.StringByID(StringId.Auto), |
| | | }; |
| | | } |
| | | break; |
| | | case "floorheatingmode": |
| | | { |
| | | list = new List<string> { |
| | | Language.StringByID(StringId.dayMode), |
| | | Language.StringByID(StringId.nightMode), |
| | | Language.StringByID(StringId.leaveMode), |
| | | Language.StringByID(StringId.ordinaryMode), |
| | | Language.StringByID(StringId.timeMode), |
| | | }; |
| | | } |
| | | break; |
| | | case "week": |
| | | { |
| | | list = new List<string> { |
| | | Language.StringByID(StringId.monday), |
| | | Language.StringByID(StringId.tuesday), |
| | | Language.StringByID(StringId.wednesday), |
| | | Language.StringByID(StringId.thursday), |
| | | Language.StringByID(StringId.friday), |
| | | Language.StringByID(StringId.saturday), |
| | | Language.StringByID(StringId.sunday), |
| | | }; |
| | | } |
| | | break; |
| | | case "andor": |
| | | { |
| | | list = new List<string> { |
| | | Language.StringByID(StringId.andCondition), |
| | | Language.StringByID(StringId.orCondition), |
| | | }; |
| | | } |
| | | break; |
| | | |
| | | } |
| | | return list; |
| | | } |
| | | /// <summary> |
| | | /// 模式/风速互相转换值的方法 |
| | | /// </summary> |
| | | /// <param name="text"></param> |
| | | /// <param name="type">自己定义自己用</param> |
| | | /// <returns></returns> |
| | | public string GetModeValueString(string text, string type) |
| | | { |
| | | string str = ""; |
| | | switch (type) |
| | | { |
| | | case "mode": |
| | | { |
| | | if (text == Language.StringByID(StringId.coolLogic)) |
| | | { |
| | | str = "cool"; |
| | | } |
| | | else if (text == Language.StringByID(StringId.heatingLogic)) |
| | | { |
| | | str = "heat"; |
| | | } |
| | | else if (text == Language.StringByID(StringId.autoLogic)) |
| | | { |
| | | str = "auto"; |
| | | } |
| | | else if (text == Language.StringByID(StringId.dehumidifyLogic)) |
| | | { |
| | | str = "dry"; |
| | | } |
| | | } |
| | | break; |
| | | case "fan": |
| | | { |
| | | if (text == Language.StringByID(StringId.HighWindSpeed)) |
| | | { |
| | | str = "high"; |
| | | } |
| | | else if (text == Language.StringByID(StringId.MiddleWindSpeed)) |
| | | { |
| | | str = "medium"; |
| | | } |
| | | else if (text == Language.StringByID(StringId.LowWindSpeed)) |
| | | { |
| | | str = "low"; |
| | | } |
| | | else if (text == Language.StringByID(StringId.Auto)) |
| | | { |
| | | str = "auto"; |
| | | } |
| | | } |
| | | break; |
| | | case "floorheatingmode": |
| | | { |
| | | if (text == Language.StringByID(StringId.dayMode)) |
| | | { |
| | | str = "day"; |
| | | } |
| | | else if (text == Language.StringByID(StringId.nightMode)) |
| | | { |
| | | str = "night"; |
| | | } |
| | | else if (text == Language.StringByID(StringId.leaveMode)) |
| | | { |
| | | str = "away"; |
| | | } |
| | | else if (text == Language.StringByID(StringId.ordinaryMode)) |
| | | { |
| | | str = "normal"; |
| | | } |
| | | else if (text == Language.StringByID(StringId.timeMode)) |
| | | { |
| | | str = "timer"; |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | return str; |
| | | } |
| | | /// <summary> |
| | | /// 星期int和string互相转换值的方法 |
| | | /// </summary> |
| | | /// <param name="list"></param> |
| | | /// <param name="str_or_int"></param> |
| | | /// <returns></returns> |
| | | public List<string> GetWeekString(List<string> list, string str_or_int) |
| | | { |
| | | string weekTextName = ""; |
| | | List<string> stateList = new List<string>(); |
| | | for (int i = 0; i < list.Count; i++) |
| | | { |
| | | var s = list[i]; |
| | | if (str_or_int == "int") |
| | | { |
| | | switch (s) |
| | | { |
| | | case "1": |
| | | { |
| | | weekTextName = Language.StringByID(StringId.monday); |
| | | } |
| | | break; |
| | | case "2": |
| | | { |
| | | weekTextName = Language.StringByID(StringId.tuesday); |
| | | } |
| | | break; |
| | | case "3": |
| | | { |
| | | weekTextName = Language.StringByID(StringId.wednesday); |
| | | } |
| | | break; |
| | | case "4": |
| | | { |
| | | weekTextName = Language.StringByID(StringId.thursday); |
| | | } |
| | | break; |
| | | case "5": |
| | | { |
| | | weekTextName = Language.StringByID(StringId.friday); |
| | | } |
| | | break; |
| | | case "6": |
| | | { |
| | | weekTextName = Language.StringByID(StringId.saturday); |
| | | } |
| | | break; |
| | | case "0": |
| | | { |
| | | weekTextName = Language.StringByID(StringId.sunday); |
| | | } |
| | | break; |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | if (Language.StringByID(StringId.monday) == s) |
| | | { |
| | | weekTextName = "1"; |
| | | } |
| | | else if (Language.StringByID(StringId.tuesday) == s) |
| | | { |
| | | weekTextName = "2"; |
| | | } |
| | | else if (Language.StringByID(StringId.wednesday) == s) |
| | | { |
| | | weekTextName = "3"; |
| | | } |
| | | else if (Language.StringByID(StringId.thursday) == s) |
| | | { |
| | | weekTextName = "4"; |
| | | } |
| | | else if (Language.StringByID(StringId.friday) == s) |
| | | { |
| | | weekTextName = "5"; |
| | | } |
| | | else if (Language.StringByID(StringId.saturday) == s) |
| | | { |
| | | weekTextName = "6"; |
| | | } |
| | | else if (Language.StringByID(StringId.sunday) == s) |
| | | { |
| | | weekTextName = "0"; |
| | | } |
| | | } |
| | | stateList.Add(weekTextName); |
| | | |
| | | } |
| | | |
| | | return stateList; |
| | | } |
| | | } |
| | | } |
| | |
| | | /// <summary> |
| | | /// 网关ID(获取嘉乐网关ID) |
| | | /// </summary> |
| | | public static string gatewayId |
| | | public static string GatewayId |
| | | { |
| | | get |
| | | { |
| | |
| | | return Entity.DB_ResidenceData.Instance.HomeGateway.gatewayId; |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 住宅ID |
| | | /// </summary> |
| | | public static string homeId |
| | | public static string HomeId |
| | | { |
| | | get |
| | | { |
| | | return Entity.DB_ResidenceData.Instance.CurrentRegion.RegionID; |
| | | return Entity.DB_ResidenceData.Instance.CurrentRegion.RegionID; |
| | | } |
| | | } |
| | | |
| | |
| | | /// 获取逻辑ID列表 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static ResponsePackNew getLogicIdList() |
| | | public static ResponsePackNew GetLogicIdList() |
| | | { |
| | | var jObject = new JObject { { "homeId", homeId } }; |
| | | var jObject = new JObject { { "homeId", HomeId } }; |
| | | var responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_List); |
| | | //如果是token过期则刷新token |
| | | if (responsePackNew.Code == StateCode.TOKEN_EXPIRED) |
| | | { |
| | | RefreshToken(); |
| | | getLogicIdList(); |
| | | GetLogicIdList(); |
| | | } |
| | | return responsePackNew; |
| | | } |
| | |
| | | /// </summary> |
| | | /// <param name="listIdList">逻辑ID列表</param> |
| | | /// <returns></returns> |
| | | public static ResponsePackNew getLogic(List<string> listIdList) |
| | | public static ResponsePackNew GetLogic(List<string> listIdList) |
| | | { |
| | | var jArray = new JArray { }; |
| | | for (int i = 0; i < listIdList.Count; i++) |
| | |
| | | if (responsePackNew.Code == StateCode.TOKEN_EXPIRED) |
| | | { |
| | | RefreshToken(); |
| | | getLogic(listIdList); |
| | | GetLogic(listIdList); |
| | | } |
| | | return responsePackNew; |
| | | } |
| | | /// <summary> |
| | | /// 添加自动化命令 |
| | | /// 添加自动化命令 |
| | | /// </summary> |
| | | /// <param name="logic"></param> |
| | | /// <returns></returns> |
| | |
| | | var logicjArray = new JArray { }; |
| | | var logicIfon = new JObject { }; |
| | | logicIfon.Add("sid", logic.sid); |
| | | logicIfon.Add("gatewayId", gatewayId); |
| | | logicIfon.Add("gatewayId", GatewayId); |
| | | logicIfon.Add("name", logic.name); |
| | | logicIfon.Add("relation", logic.relation); |
| | | logicIfon.Add("enable", logic.enable); |
| | |
| | | logicIfon.Add("input", inputArray); |
| | | logicIfon.Add("output", outputArray); |
| | | logicjArray.Add(logicIfon); |
| | | var jObject = new JObject { { "homeId", homeId }, { "logics", logicjArray } }; |
| | | var jObject = new JObject { { "homeId", HomeId }, { "logics", logicjArray } }; |
| | | responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_Add); |
| | | //如果是token过期则刷新token |
| | | if (responsePackNew.Code == StateCode.TOKEN_EXPIRED) |
| | |
| | | /// </summary> |
| | | /// <param name="logic"></param> |
| | | /// <returns></returns> |
| | | public static ResponsePackNew updateLogic(Logic logic) |
| | | public static ResponsePackNew UpdateLogic(Logic logic) |
| | | { |
| | | ResponsePackNew responsePackNew = null; |
| | | try |
| | |
| | | var logicIfon = new JObject { }; |
| | | logicIfon.Add("userLogicId", logic.userLogicId); |
| | | logicIfon.Add("sid", logic.sid); |
| | | logicIfon.Add("gatewayId", gatewayId); |
| | | logicIfon.Add("gatewayId", GatewayId); |
| | | logicIfon.Add("name", logic.name); |
| | | logicIfon.Add("relation", logic.relation); |
| | | logicIfon.Add("enable", logic.enable); |
| | |
| | | logicIfon.Add("input", inputArray); |
| | | logicIfon.Add("output", outputArray); |
| | | logicjArray.Add(logicIfon); |
| | | var jObject = new JObject { { "homeId", homeId }, { "logics", logicjArray } }; |
| | | var jObject = new JObject { { "homeId", HomeId }, { "logics", logicjArray } }; |
| | | responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_Update); |
| | | //如果是token过期则刷新token |
| | | if (responsePackNew.Code == StateCode.TOKEN_EXPIRED) |
| | | { |
| | | RefreshToken(); |
| | | updateLogic(logic); |
| | | UpdateLogic(logic); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | |
| | | |
| | | |
| | | return responsePackNew; |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 删除逻辑 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static ResponsePackNew delLogic(Logic logic) |
| | | public static ResponsePackNew DelLogic(Logic logic) |
| | | { |
| | | var jArray = new JArray { }; |
| | | jArray.Add(logic.userLogicId); |
| | |
| | | if (responsePackNew.Code == StateCode.TOKEN_EXPIRED) |
| | | { |
| | | RefreshToken(); |
| | | delLogic(logic); |
| | | DelLogic(logic); |
| | | } |
| | | return responsePackNew; |
| | | } |
| | | /// <summary> |
| | | /// <summary> |
| | | /// 逻辑开关 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static ResponsePackNew switchLogic(Logic logic) |
| | | public static ResponsePackNew SwitchLogic(Logic logic) |
| | | { |
| | | var jArray = new JArray { }; |
| | | var job = new JObject { { "userLogicId", logic.userLogicId } , { "enable", logic.enable } }; |
| | |
| | | if (responsePackNew.Code == StateCode.TOKEN_EXPIRED) |
| | | { |
| | | RefreshToken(); |
| | | switchLogic(logic); |
| | | SwitchLogic(logic); |
| | | } |
| | | return responsePackNew; |
| | | } |
| | | /// <summary> |
| | | ///请求服务器(与住宅有关:例如;homeId) |
| | | ///请求服务器(与住宅有关:例如;homeId) |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static ResponsePackNew RequestServerhomeId(object o, string api_Url, int mTimeout = 3) |
| | |
| | | try |
| | | { |
| | | //发送删除逻辑命令; |
| | | responsePackNew = Send.delLogic(Logic.currlogic); |
| | | responsePackNew = Send.DelLogic(Logic.currlogic); |
| | | |
| | | } |
| | | catch { } |
| | |
| | | ///温度点击事件 |
| | | temperatureView.btnClick.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | FrameLayout frame = new FrameLayout |
| | | { |
| | | BackgroundColor = CSS.CSS_Color.viewTrans60lucence, |
| | | }; |
| | | this.AddChidren(frame); |
| | | LogicView.TimeView view = new LogicView.TimeView(); |
| | | view.FLayoutView(frame); |
| | | EventHandler<MouseEventArgs> removefLayout = (sender1, e1) => |
| | | { |
| | | //移除fLayout界面 |
| | | frame.RemoveFromParent(); |
| | | }; |
| | | //取消点击事件 |
| | | view.btnCancel.MouseUpEventHandler += removefLayout; |
| | | |
| | | //初始化列表 |
| | | var temperatureList = new List<string>(); |
| | | for (int i = 16; i < 32; i++) |
| | | { |
| | | //添加数据 |
| | | temperatureList.Add(i.ToString() + "℃"); |
| | | temperatureList.Add((i + 0.5).ToString() + "℃"); |
| | | |
| | | } |
| | | |
| | | //加载数据界面的设置方法(列表互不联动) |
| | | view.mUIPickerView.setNPicker(temperatureList, null, null); |
| | | //默认初始选中状态 |
| | | view.mUIPickerView.setCurrentItems(9, 0, 0); |
| | | //定义一个局部变量记录选中时间 |
| | | string temperature = "25℃"; |
| | | for (int i = 0; i < temperatureList.Count; i++) |
| | | { |
| | | if (temperatureList[i] == temperatureView.btnState.Text) |
| | | { |
| | | //更新状态 |
| | | view.mUIPickerView.setCurrentItems(i, 0, 0); |
| | | //更新状态 |
| | | temperature = temperatureList[i]; |
| | | break; |
| | | } |
| | | } |
| | | //选中时间回调方法,时间变化一次回调一次 |
| | | view.mUIPickerView.OnSelectChangeEvent += (index1, index2, index3) => |
| | | { |
| | | temperature = temperatureList[index1]; |
| | | }; |
| | | //确定点击事件 |
| | | view.btnConfirm.MouseUpEventHandler += (sender2, e2) => |
| | | { |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.dictionary(dic, "key", "set_temp"); |
| | | ///之前的状态文本 |
| | | string tempValue = temperatureView.btnState.Text; |
| | | LogicView.TemperatureView tempView= new LogicView.TemperatureView(); |
| | | tempView.FLayoutView(this, tempValue,(stateStr)=> { |
| | | //界面显示选中值 |
| | | temperatureView.btnState.Text = stateStr; |
| | | //设备属性值,云雀上定义好的; |
| | | string keyVlaue = "set_temp"; |
| | | string set_temp_value = temperature.Replace("℃", ""); |
| | | selectedState = device.functionType + "_"+ keyVlaue; |
| | | string set_temp_value = stateStr.Replace("℃", ""); |
| | | //数据封装 |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.dictionary(dic, "key", keyVlaue); |
| | | LogicMethod.dictionary(dic, "value", set_temp_value); |
| | | AddDictionaryData(dicSateteList, keyVlaue, dic); |
| | | selectedState = device.functionType + "_set_temp"; |
| | | RemView(frame); |
| | | temperatureView.btnState.Text = temperature; |
| | | }); |
| | | |
| | | |
| | | }; |
| | | }; |
| | | ///模式点击事件 |
| | | acModehView.btnClick.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | |
| | | List<string> modeStr = new List<string> { |
| | | Language.StringByID(StringId.coolLogic), |
| | | Language.StringByID(StringId.heatingLogic), |
| | | Language.StringByID(StringId.autoLogic), |
| | | Language.StringByID(StringId.dehumidifyLogic), |
| | | }; |
| | | FrameLayout frame = new FrameLayout |
| | | { |
| | | BackgroundColor = CSS.CSS_Color.viewTrans60lucence, |
| | | }; |
| | | this.AddChidren(frame); |
| | | |
| | | |
| | | ///之前的状态文本 |
| | | string currText = acModehView.btnState.Text; |
| | | //设备属性值,云雀上定义好的; |
| | | string keyVlaue = "mode"; |
| | | selectedState = device.functionType + "_"+keyVlaue; |
| | | PublicInterface modeView = new PublicInterface(); |
| | | modeView.SingleSelectionShow(frame, modeStr, Language.StringByID(StringId.modeLogic), currText |
| | | var modeListStr= modeView.GetViewList(keyVlaue); |
| | | modeView.SingleSelectionShow(this, modeListStr, Language.StringByID(StringId.modeLogic), currText |
| | | , (stateValue) => |
| | | { |
| | | string keyVlaue = "mode"; |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.dictionary(dic, "key", "mode"); |
| | | LogicMethod.dictionary(dic, "value", InterfaceDsplaysLogic.GetModeValueString(stateValue, "mode")); |
| | | AddDictionaryData(dicSateteList, keyVlaue, dic); |
| | | //界面显示选中值 |
| | | acModehView.btnState.Text = stateValue; |
| | | selectedState = device.functionType + "_mode"; |
| | | //数据封装 |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.dictionary(dic, "key", keyVlaue); |
| | | LogicMethod.dictionary(dic, "value", modeView.GetModeValueString(stateValue, keyVlaue)); |
| | | AddDictionaryData(dicSateteList, keyVlaue, dic); |
| | | |
| | | }); |
| | | |
| | |
| | | ///风速点击事件 |
| | | acSpeedView.btnClick.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | List<string> speedStr = new List<string> { |
| | | Language.StringByID(StringId.LowWindSpeed), |
| | | Language.StringByID(StringId.MiddleWindSpeed), |
| | | Language.StringByID(StringId.HighWindSpeed), |
| | | Language.StringByID(StringId.Auto), |
| | | }; |
| | | FrameLayout frame = new FrameLayout |
| | | { |
| | | BackgroundColor = CSS.CSS_Color.viewTrans60lucence, |
| | | }; |
| | | this.AddChidren(frame); |
| | | |
| | | ///之前的状态文本 |
| | | string currText = acSpeedView.btnState.Text; |
| | | PublicInterface modeView = new PublicInterface(); |
| | | modeView.SingleSelectionShow(frame, speedStr, Language.StringByID(StringId.speedLogic), currText |
| | | //设备属性值,云雀上定义好的; |
| | | string keyVlaue = "fan"; |
| | | selectedState = device.functionType + "_" + keyVlaue; |
| | | PublicInterface speedView = new PublicInterface(); |
| | | var speedListStr = speedView.GetViewList(keyVlaue); |
| | | speedView.SingleSelectionShow(this, speedListStr, Language.StringByID(StringId.speedLogic), currText |
| | | , (stateValue) => |
| | | { |
| | | string keyVlaue = "fan"; |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.dictionary(dic, "key", "fan"); |
| | | LogicMethod.dictionary(dic, "value", InterfaceDsplaysLogic.GetModeValueString(stateValue, "fan")); |
| | | AddDictionaryData(dicSateteList, keyVlaue, dic); |
| | | //界面显示选中值 |
| | | acSpeedView.btnState.Text = stateValue; |
| | | selectedState = device.functionType + "_fan"; |
| | | //数据封装 |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.dictionary(dic, "key", keyVlaue); |
| | | LogicMethod.dictionary(dic, "value", speedView.GetModeValueString(stateValue, keyVlaue)); |
| | | AddDictionaryData(dicSateteList, keyVlaue, dic); |
| | | |
| | | }); |
| | | }; |
| | | if (edit) |
| | | { |
| | | //显示编辑之前的设备状态 |
| | | GetEditState(device, index, acSwitchVie.btnState, temperatureView.btnState, acModehView.btnState, acSpeedView.btnState); |
| | | } |
| | | |
| | |
| | | ///温度点击事件 |
| | | temperatureView.btnClick.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | FrameLayout frame = new FrameLayout |
| | | { |
| | | BackgroundColor = CSS.CSS_Color.viewTrans60lucence, |
| | | }; |
| | | this.AddChidren(frame); |
| | | LogicView.TimeView view = new LogicView.TimeView(); |
| | | view.FLayoutView(frame); |
| | | EventHandler<MouseEventArgs> removefLayout = (sender1, e1) => |
| | | { |
| | | //移除fLayout界面 |
| | | frame.RemoveFromParent(); |
| | | }; |
| | | //取消点击事件 |
| | | view.btnCancel.MouseUpEventHandler += removefLayout; |
| | | |
| | | //初始化列表 |
| | | var temperatureList = new List<string>(); |
| | | for (int i = 16; i < 32; i++) |
| | | { |
| | | //添加数据 |
| | | temperatureList.Add(i.ToString() + "℃"); |
| | | temperatureList.Add((i + 0.5).ToString() + "℃"); |
| | | |
| | | } |
| | | |
| | | //加载数据界面的设置方法(列表互不联动) |
| | | view.mUIPickerView.setNPicker(temperatureList, null, null); |
| | | |
| | | //默认初始选中状态 |
| | | view.mUIPickerView.setCurrentItems(9, 0, 0); |
| | | //定义一个局部变量记录选中时间 |
| | | string temperature = "25℃"; |
| | | for (int i = 0; i < temperatureList.Count; i++) |
| | | { |
| | | if (temperatureList[i] == temperatureView.btnState.Text) |
| | | { |
| | | //更新状态 |
| | | view.mUIPickerView.setCurrentItems(i, 0, 0); |
| | | //更新状态 |
| | | temperature = temperatureList[i]; |
| | | break; |
| | | } |
| | | } |
| | | //选中时间回调方法,时间变化一次回调一次 |
| | | view.mUIPickerView.OnSelectChangeEvent += (index1, index2, index3) => |
| | | { |
| | | temperature = temperatureList[index1]; |
| | | }; |
| | | //确定点击事件 |
| | | view.btnConfirm.MouseUpEventHandler += (sender2, e2) => |
| | | { |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.dictionary(dic, "key", "set_temp"); |
| | | string tempValue = temperatureView.btnState.Text; |
| | | LogicView.TemperatureView tempView = new LogicView.TemperatureView(); |
| | | tempView.FLayoutView(this, tempValue, (stateStr) => { |
| | | //界面显示选中值 |
| | | temperatureView.btnState.Text = stateStr; |
| | | //设备属性值,云雀上定义好的; |
| | | string keyVlaue = "set_temp"; |
| | | string set_temp_value = temperature.Replace("℃", ""); |
| | | selectedState = device.functionType + "_"+ keyVlaue; |
| | | string set_temp_value = stateStr.Replace("℃", ""); |
| | | //数据封装 |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.dictionary(dic, "key", keyVlaue); |
| | | LogicMethod.dictionary(dic, "value", set_temp_value); |
| | | selectedState = device.functionType + "_set_temp"; |
| | | AddDictionaryData(dicSateteList, keyVlaue, dic); |
| | | RemView(frame); |
| | | temperatureView.btnState.Text = temperature; |
| | | |
| | | }; |
| | | }); |
| | | |
| | | }; |
| | | ///模式点击事件 |
| | | floorHeatingModehView.btnClick.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | FrameLayout frame = new FrameLayout |
| | | { |
| | | BackgroundColor = CSS.CSS_Color.viewTrans60lucence, |
| | | }; |
| | | this.AddChidren(frame); |
| | | List<string> modeStr = new List<string> { |
| | | Language.StringByID(StringId.dayMode), |
| | | Language.StringByID(StringId.nightMode), |
| | | Language.StringByID(StringId.leaveMode), |
| | | Language.StringByID(StringId.ordinaryMode), |
| | | Language.StringByID(StringId.timeMode), |
| | | }; |
| | | |
| | | |
| | | ///之前的状态文本 |
| | | string currText= floorHeatingModehView.btnState.Text; |
| | | //设备属性值,云雀上定义好的; |
| | | string keyVlaue = "mode"; |
| | | selectedState = device.functionType + "_"+ keyVlaue; |
| | | |
| | | PublicInterface modeView = new PublicInterface(); |
| | | modeView.SingleSelectionShow(frame, modeStr, Language.StringByID(StringId.modeLogic), currText |
| | | var modeListStr = modeView.GetViewList("floorheatingmode"); |
| | | modeView.SingleSelectionShow(this, modeListStr, Language.StringByID(StringId.modeLogic), currText |
| | | , (stateValue) => |
| | | { |
| | | string keyVlaue = "mode"; |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.dictionary(dic, "key", "mode"); |
| | | LogicMethod.dictionary(dic, "value", InterfaceDsplaysLogic.GetModeValueString(stateValue, "FloorHeating")); |
| | | AddDictionaryData(dicSateteList, keyVlaue, dic); |
| | | //界面显示选中值 |
| | | floorHeatingModehView.btnState.Text = stateValue; |
| | | selectedState = device.functionType + "_mode"; |
| | | //数据封装 |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.dictionary(dic, "key", keyVlaue); |
| | | LogicMethod.dictionary(dic, "value", modeView.GetModeValueString(stateValue, "floorheatingmode")); |
| | | AddDictionaryData(dicSateteList, keyVlaue, dic); |
| | | }); |
| | | |
| | | }; |
| | | if (edit) |
| | | { |
| | | //显示编辑之前的设备状态 |
| | | GetEditState(device, index, floorHeatingSwitchVie.btnState, temperatureView.btnState, floorHeatingModehView.btnState, null); |
| | | } |
| | | |
| | |
| | | }; |
| | | if (edit) |
| | | { |
| | | //显示编辑之前的设备状态 |
| | | GetEditState(device, index, curtainSwitchView.btnState, null, null, null); |
| | | } |
| | | #endregion |
| | |
| | | }; |
| | | if (edit) |
| | | { |
| | | //显示编辑之前的设备状态 |
| | | GetEditState(device, index, lightSwitchView.btnState, brightnessView.btnState, null, null); |
| | | } |
| | | #endregion |
| | |
| | | id = StringId.stop; |
| | | } break; |
| | | } |
| | | //界面显示选中值 |
| | | button.TextID = id; |
| | | selectedState = device.functionType + "_" + strValue; |
| | | string keyVlaue = "on_off"; |
| | | //数据封装 |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.dictionary(dic, "key", "on_off"); |
| | | string keyVlaue = "on_off"; |
| | | LogicMethod.dictionary(dic, "value", strValue); |
| | | AddDictionaryData(dicSateteList, keyVlaue, dic); |
| | | selectedState = device.functionType + "_" + strValue; |
| | | |
| | | }); |
| | | #endregion |
| | |
| | | BackgroundColor = CSS.CSS_Color.viewTrans60lucence, |
| | | }; |
| | | this.AddChidren(frame); |
| | | string stateVlaue = button.Text; |
| | | LogicView.BrightnessView brightness = new LogicView.BrightnessView(); |
| | | brightness.FLayoutView(frame, titleName, button.Text, (brightnesValue) => |
| | | brightness.FLayoutView(frame, titleName, stateVlaue, (brightnesValue) => |
| | | { |
| | | //界面显示选中值 |
| | | button.Text = brightnesValue+"%"; |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | string keyVlaue = ""; |
| | | selectedState = device.functionType + brightnesValue.ToString(); |
| | | //数据封装 |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | switch (device.functionType) |
| | | { |
| | | //开关灯光 light.Switch |
| | |
| | | } |
| | | LogicMethod.dictionary(dic, "value", brightnesValue.ToString()); |
| | | AddDictionaryData(dicSateteList, keyVlaue, dic); |
| | | selectedState = device.functionType + brightnesValue.ToString(); |
| | | }); |
| | | #endregion |
| | | |
| | |
| | | } |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 移除控件 |
| | | /// </summary> |
| | | /// <param name="frame"></param> |
| | | private void RemView(FrameLayout frame) |
| | | { |
| | | frame.RemoveFromParent(); |
| | | } |
| | | |
| | | |
| | | |
| | | } |