2022年08月25日15:04:41
自动化输入条件:支持可视对讲(人脸,视频通话呼叫);
| | |
| | | 7158=is |
| | | 7159=Fall in the alarm |
| | | 7160=Someone called the police |
| | | 7161=Warning tone |
| | | 7162=Face to open the door |
| | | 7163=Video call |
| | | |
| | | |
| | | |
| | | |
| | |
| | | 7158=是 |
| | | 7159=跌倒报警 |
| | | 7160=有人报警 |
| | | 7161=提示音 |
| | | 7162=人脸开门 |
| | | 7163=视频通话呼叫 |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | isfirst = false; |
| | | ///监听经纬度 |
| | | HDL_ON.UI.UI2.Intelligence.Automation.LogicMethod.CurrLogicMethod.AppLatAndLonEvent(lon, lat); |
| | | HDL_ON.UI.UI2.Intelligence.Automation.LogicMethod.Current.AppLatAndLonEvent(lon, lat); |
| | | //关闭定位服务 |
| | | //Shared.Application.StopGPSLocationService(); |
| | | } |
| | |
| | | 7158=is |
| | | 7159=Fall in the alarm |
| | | 7160=Someone called the police |
| | | 7161=Warning tone |
| | | 7162=Face to open the door |
| | | 7163=Video call |
| | | |
| | | |
| | | |
| | |
| | | 7158=是 |
| | | 7159=跌倒报警 |
| | | 7160=有人报警 |
| | | 7161=提示音 |
| | | 7162=人脸开门 |
| | | 7163=视频通话呼叫 |
| | | |
| | | |
| | | |
| | |
| | | /// 有人报警 |
| | | /// </summary> |
| | | public const int yourenbaojing = 7160; |
| | | /// <summary> |
| | | /// 提示音 |
| | | /// </summary> |
| | | public const int tishiyin = 7161; |
| | | /// <summary> |
| | | /// 人脸开门 |
| | | /// </summary> |
| | | public const int renliankaimen = 7162; |
| | | /// <summary> |
| | | /// 视频通话呼叫 |
| | | /// </summary> |
| | | public const int shipintonghuahujiao = 7163; |
| | | |
| | | |
| | | |
| | |
| | | new Control_Udp().SendLocalHdlLinkData(sendBytes, aLinkData.id,0); |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 获取音乐目录 |
| | | /// </summary> |
| | | public void GetMusicDirectory(Function function) |
| | | { |
| | | if (Ins.GatewayOnline_Local) |
| | | { |
| | | var objects = new List<Dictionary<string, string>>(); |
| | | var readKey = new Dictionary<string, string>(); |
| | | readKey.Add("sid", function.sid); |
| | | objects.Add(readKey); |
| | | var readDataObj = new AlinkReadFunctionStatusObj() |
| | | { |
| | | id = Ins.msg_id.ToString(), |
| | | objects = objects, |
| | | time_stamp = Utlis.GetTimestamp() |
| | | }; |
| | | var functionControlDataJson = Newtonsoft.Json.JsonConvert.SerializeObject(readDataObj); |
| | | var sendBytes = Ins.ConvertSendBodyData($"/base/{DB_ResidenceData.Instance.HomeGateway.gatewayId}/thing/service/MusicPlayGroupListGet/down", functionControlDataJson); |
| | | MainPage.Log($"本地通讯 发送HDL-Link数据:{functionControlDataJson}"); |
| | | new Control_Udp().SendLocalHdlLinkData(sendBytes, readDataObj.id); |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 网关进入配网模式 |
| | | /// </summary> |
| | |
| | | //} |
| | | receiveObj.BodyDataString = res[1]; |
| | | |
| | | |
| | | |
| | | //2021-09-23 过滤不需要解密的主题 目前搜索网关主题不加密 |
| | | if (receiveObj.Topic != CommunicationTopic.SearchLoaclGatewayReply) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | if (receiveObj.Topic.Contains("/thing/service/MusicPlayGroupListGet/down_reply")) { |
| | | |
| | | |
| | | } |
| | | |
| | | if (receiveObj.Topic == CommunicationTopic.SearchLoaclGatewayReply || receiveObj.Topic == CommunicationTopic.GatewayBroadcast) |
| | | { |
| | |
| | | /// 公共域名就近解析 |
| | | /// </summary> |
| | | |
| | | public const string GlobalRequestHttpsHost = "https://nearest.hdlcontrol.com"; |
| | | //public const string GlobalRequestHttpsHost = "https://test-gz.hdlcontrol.com";//mmmm |
| | | //public const string GlobalRequestHttpsHost = "https://nearest.hdlcontrol.com"; |
| | | public const string GlobalRequestHttpsHost = "https://test-gz.hdlcontrol.com";//mmmm |
| | | /// <summary> |
| | | /// RegionMark |
| | | /// </summary> |
| | |
| | | /// 住宅sip账号获取 |
| | | /// </summary> |
| | | public const string API_POST_VideoDevice_GetSipAccount = "/home-wisdom/app/home/getSipAccount"; |
| | | /// <summary> |
| | | /// 获取住宅已录入人脸信息(可视对讲人脸开门触发自动化配置用) |
| | | /// </summary> |
| | | public const string Api_Post_GetListHomeFace = "/home-wisdom/app/logic/listHomeFace"; |
| | | |
| | | |
| | | #endregion |
| | | |
| | | |
| | |
| | | /// 获取音乐列表 |
| | | /// </summary> |
| | | public const string Api_Post_PlayerList = "/home-wisdom/app/wise/music/playerList"; |
| | | /// <summary> |
| | | /// 获取音乐分组列表 |
| | | /// </summary> |
| | | public const string Api_Post_GroupList = "/home-wisdom/app/wise/music/groupList"; |
| | | /// <summary> |
| | | /// 获取分组的音乐列表 |
| | | /// </summary> |
| | | public const string Api_Post_GroupPlayerList = "/home-wisdom/app/wise/music/groupPlayerList"; |
| | | |
| | | |
| | | #endregion |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | #region 灯光 |
| | | /// <summary> |
| | | /// (开关灯) |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region 可视对讲 |
| | | /// <summary> |
| | | /// HDL可视对讲 |
| | | /// </summary> |
| | | public const string doorgate="door.gate"; |
| | | #endregion |
| | | |
| | | #region 第三方spk列表 |
| | | /// <summary> |
| | | /// 获取所有第三方品牌功能的spk |
| | |
| | | /// </summary> |
| | | public void SceneMethod() |
| | | { |
| | | var sceneList = LogicMethod.CurrLogicMethod.GetSceneList(); |
| | | var sceneList = LogicMethod.Current.GetSceneList(); |
| | | List<string> nameList = new List<string>(); |
| | | for (int i = 0; i < sceneList.Count; i++) |
| | | { |
| | |
| | | nameList.Add(scene.name); |
| | | } |
| | | PublicInterface publicInterface = new PublicInterface(); |
| | | publicInterface.FrameOrVv(this, nameList, new List<string> { }, StringId.addSceneLogic, (index) => |
| | | publicInterface.FrameOrVv(this, nameList, new List<string> { }, Language.StringByID(StringId.addSceneLogic), (index) => |
| | | { |
| | | var sceneSelecetd = sceneList[index]; |
| | | Input input = new Input(); |
| | | input.sid = sceneSelecetd.sid; |
| | | input.condition_type = "10"; |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "key", "scene"); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "comparator", "="); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "data_type", "string"); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "value", "on"); |
| | | LogicMethod.Current.dictionary(dic, "key", "scene"); |
| | | LogicMethod.Current.dictionary(dic, "comparator", "="); |
| | | LogicMethod.Current.dictionary(dic, "data_type", "string"); |
| | | LogicMethod.Current.dictionary(dic, "value", "on"); |
| | | input.condition.Add(dic); |
| | | AddCondition(input); |
| | | LogicMethod.CurrLogicMethod.RemoveAllView(); |
| | | LogicMethod.Current.RemoveAllView(); |
| | | AddLogic addLogic = new AddLogic(); |
| | | MainPage.BasePageView.AddChidren(addLogic); |
| | | addLogic.Show(); |
| | |
| | | ///通过调试宝给的经纬度<标准GPS> |
| | | double latitude = Entity.DB_ResidenceData.Instance.CurrentRegion.latitude;//纬度 |
| | | double longitude = Entity.DB_ResidenceData.Instance.CurrentRegion.longitude;//经度 |
| | | LogicMethod.CurrLogicMethod.WGS84_to_GCJ02(Entity.DB_ResidenceData.Instance.CurrentRegion.longitude, Entity.DB_ResidenceData.Instance.CurrentRegion.latitude, out longitude, out latitude); |
| | | LogicMethod.Current.WGS84_to_GCJ02(Entity.DB_ResidenceData.Instance.CurrentRegion.longitude, Entity.DB_ResidenceData.Instance.CurrentRegion.latitude, out longitude, out latitude); |
| | | int r = 500;//默认半径 |
| | | if (edit) |
| | | { |
| | |
| | | { |
| | | //高德坐标转WGS84坐标(高德地图设置GPS) |
| | | double out_lng, out_lat; |
| | | LogicMethod.CurrLogicMethod.GCJ02_to_WGS84(mLongitude, mLatitude, out out_lng, out out_lat); |
| | | LogicMethod.Current.GCJ02_to_WGS84(mLongitude, mLatitude, out out_lng, out out_lat); |
| | | Input input = new Input(); |
| | | input.sid = LogicMethod.CurrLogicMethod.NewSid(); |
| | | input.sid = LogicMethod.Current.NewSid(); |
| | | input.condition_type = "8"; |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "key", "direction"); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "comparator", "="); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "data_type", "string"); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "value", valueStr); |
| | | LogicMethod.Current.dictionary(dic, "key", "direction"); |
| | | LogicMethod.Current.dictionary(dic, "comparator", "="); |
| | | LogicMethod.Current.dictionary(dic, "data_type", "string"); |
| | | LogicMethod.Current.dictionary(dic, "value", valueStr); |
| | | input.condition.Add(dic); |
| | | //纬度 |
| | | input.geo_fence.latitude = out_lat.ToString(); |
| | |
| | | //半径<单位米> |
| | | input.geo_fence.radius = mRadius.ToString(); |
| | | AddCondition(input); |
| | | LogicMethod.CurrLogicMethod.RemoveAllView(); |
| | | LogicMethod.Current.RemoveAllView(); |
| | | AddLogic addLogic = new AddLogic(); |
| | | MainPage.BasePageView.AddChidren(addLogic); |
| | | addLogic.Show(); |
| | |
| | | } |
| | | |
| | | // 条件处理方法 |
| | | InpOrOutLogicMethod.InputCondition(this, viewLayout); |
| | | InpOrOutLogicMethod.Current.InputCondition(this, viewLayout); |
| | | ///添加图标的View |
| | | LogicView.LogicAddView addInputIcon = new LogicView.LogicAddView(); |
| | | addInputIcon.frameLayout.SetCornerWithSameRadius(Application.GetRealHeight(12), HDLUtils.RectCornerBottomLeft | HDLUtils.RectCornerBottomRight); |
| | |
| | | titleOutpu.btnNextIcon.Visible = false; |
| | | viewLayout.AddChidren(titleOutpu.FLayoutView()); |
| | | //目标处理方法 |
| | | InpOrOutLogicMethod.OutputTarget(this, viewLayout); |
| | | InpOrOutLogicMethod.Current.OutputTarget(this, viewLayout); |
| | | ///添加图标的View |
| | | LogicView.LogicAddView addOutputIcon = new LogicView.LogicAddView(); |
| | | addOutputIcon.frameLayout.SetCornerWithSameRadius(Application.GetRealHeight(12), HDLUtils.RectCornerBottomLeft | HDLUtils.RectCornerBottomRight); |
| | |
| | | new LogicView.TipPopView().TipBox(StringId.tip, StringId.targetNull); |
| | | return; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | Loading loading = new Loading(); |
| | | this.AddChidren(loading); |
| | | HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null; |
| | | HDL_ON.DAL.Server.ResponsePackNew r = null; |
| | | if (string.IsNullOrEmpty(Logic.currlogic.userLogicId)) |
| | | { |
| | | List<string> list = new List<string>(); |
| | |
| | | { |
| | | list.Add(logic.name); |
| | | } |
| | | new LogicView.TipPopView().InputBox(StringId.editName, InpOrOutLogicMethod.GetLogicName(Logic.currlogic), StringId.nameNull, StringId.NameAlreadyExists, list, (logicName, view |
| | | new LogicView.TipPopView().InputBox(StringId.editName, InpOrOutLogicMethod.Current.GetLogicName(Logic.currlogic), StringId.nameNull, StringId.NameAlreadyExists, list, (logicName, view |
| | | ) => |
| | | { |
| | | Logic.currlogic.name = logicName; |
| | | Logic.currlogic.sid = LogicMethod.CurrLogicMethod.NewSid(); |
| | | Logic.currlogic.sid = LogicMethod.Current.NewSid(); |
| | | loading.Start(); |
| | | new System.Threading.Thread(() => |
| | | { |
| | |
| | | if (!MainPage.NoLoginMode) |
| | | { |
| | | //发送新加逻辑命令; |
| | | responsePackNew = Send.AddLogic(Logic.currlogic); |
| | | r = Send.Current.AddLogic(Logic.currlogic,true); |
| | | } |
| | | |
| | | } |
| | |
| | | if(MainPage.NoLoginMode) |
| | | { |
| | | Logic.LogicList.Add(Logic.currlogic); |
| | | LogicMethod.CurrLogicMethod.RemoveAllView(); |
| | | LogicMethod.Current.RemoveAllView(); |
| | | MainView.MainShow(); |
| | | return; |
| | | } |
| | | |
| | | if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") |
| | | if (r != null) |
| | | { |
| | | //获取逻辑详细返回是一个数组(object类型转换为数组); |
| | | var jArray = Newtonsoft.Json.Linq.JArray.Parse(responsePackNew.Data.ToString()); |
| | | for (int a = 0; a < jArray.Count; a++) |
| | | var userLogicIdList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Logic>>(r.Data.ToString()); |
| | | for (int i = 0; i < userLogicIdList.Count; i++) |
| | | { |
| | | var jay = jArray[a]; |
| | | //数据返序列化为Logic对象 |
| | | var str = Newtonsoft.Json.JsonConvert.SerializeObject(jay); |
| | | var logic = Newtonsoft.Json.JsonConvert.DeserializeObject<Logic>(str); |
| | | if (logic.userLogicId != "") |
| | | { |
| | | //更新云端唯一自动化id; |
| | | Logic.currlogic.userLogicId = logic.userLogicId; |
| | | } |
| | | else |
| | | var logic = userLogicIdList[i]; |
| | | if (string.IsNullOrEmpty(logic.userLogicId)) |
| | | { |
| | | //自己看的所以不需要支持中英文 |
| | | new LogicView.TipPopView().FlashingBox("没有返回云端唯一自动化id"); |
| | | } |
| | | |
| | | //更新云端唯一自动化id; |
| | | Logic.currlogic.userLogicId = logic.userLogicId; |
| | | } |
| | | |
| | | Logic.LogicList.Add(Logic.currlogic); |
| | | LogicMethod.CurrLogicMethod.RemoveAllView(); |
| | | LogicMethod.Current.RemoveAllView(); |
| | | MainView.MainShow(); |
| | | } |
| | | else |
| | | { |
| | | if (responsePackNew != null) |
| | | { |
| | | new LogicView.TipPopView().FlashingBox(responsePackNew.message); |
| | | } |
| | | |
| | | } |
| | | |
| | | }); |
| | | } |
| | | |
| | |
| | | try |
| | | { |
| | | //发送修改逻辑命令; |
| | | responsePackNew = Send.UpdateLogic(Logic.currlogic); |
| | | r = Send.Current.UpdateLogic(Logic.currlogic,true); |
| | | |
| | | } |
| | | catch { } |
| | |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | loading.Hide(); |
| | | if (responsePackNew != null && responsePackNew.Code == "0") |
| | | if (r != null ) |
| | | { |
| | | LogicMethod.CurrLogicMethod.RemoveAllView(); |
| | | LogicMethod.Current.RemoveAllView(); |
| | | MainView.MainShow(); |
| | | } |
| | | else |
| | | { |
| | | if (responsePackNew != null) |
| | | { |
| | | new LogicView.TipPopView().FlashingBox(responsePackNew.message); |
| | | } |
| | | |
| | | } |
| | | |
| | | }); |
| | | } |
| | | |
| | | |
| | | |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | |
| | | /// </summary> |
| | | public void SceneMethod() |
| | | { |
| | | var sceneList = LogicMethod.CurrLogicMethod.GetSceneList(); |
| | | var sceneList = LogicMethod.Current.GetSceneList(); |
| | | List<string> nameList = new List<string>(); |
| | | for (int i = 0; i < sceneList.Count; i++) { |
| | | var scene = sceneList[i]; |
| | | nameList.Add(scene.name); |
| | | } |
| | | PublicInterface publicInterface = new PublicInterface(); |
| | | publicInterface.FrameOrVv(this, nameList,new List<string> { }, StringId.addSceneLogic, (index) => |
| | | publicInterface.FrameOrVv(this, nameList,new List<string> { },Language.StringByID(StringId.addSceneLogic), (index) => |
| | | { |
| | | var sceneSelecetd = sceneList[index]; |
| | | Output outputDevice = new Output(); |
| | |
| | | //没啥作用,为了发送数据格式统一; |
| | | outputDevice.status = new List<Dictionary<string, string>> { new Dictionary<string, string> { { "key", "scene" }, { "value", "0" } } }; |
| | | AddOutput(outputDevice); |
| | | LogicMethod.CurrLogicMethod.RemoveAllView(); |
| | | LogicMethod.Current.RemoveAllView(); |
| | | AddLogic addLogic = new AddLogic(); |
| | | MainPage.BasePageView.AddChidren(addLogic); |
| | | addLogic.Show(); |
| | |
| | | List<string> stateList = new List<string>(); |
| | | if (edit&& index1 != -1) { |
| | | Output output = Logic.currlogic.output[index1]; |
| | | var security = LogicMethod.CurrLogicMethod.GetSecurity(output.sid); |
| | | var security = LogicMethod.Current.GetSecurity(output.sid); |
| | | stateList.Add(security.name); |
| | | } |
| | | var securityList = LogicMethod.CurrLogicMethod.GetSecurityList(); |
| | | var securityList = LogicMethod.Current.GetSecurityList(); |
| | | List<string> nameList = new List<string>(); |
| | | for (int i = 0; i < securityList.Count; i++) |
| | | { |
| | |
| | | nameList.Add(security.name); |
| | | } |
| | | PublicInterface publicInterface = new PublicInterface(); |
| | | publicInterface.FrameOrVv(frameLayout, nameList, stateList, StringId.addSecurityLogic,(index) => |
| | | publicInterface.FrameOrVv(frameLayout, nameList, stateList,Language.StringByID(StringId.addSecurityLogic),(index) => |
| | | { |
| | | var securitySelecetd = securityList[index]; |
| | | Output outputDevice = new Output(); |
| | |
| | | //没啥作用,为了发送数据格式统一; |
| | | outputDevice.status = new List<Dictionary<string, string>> { new Dictionary<string, string> { { "key", "security" }, { "value", "0" } } }; |
| | | AddOutput(outputDevice,true); |
| | | LogicMethod.CurrLogicMethod.RemoveAllView(); |
| | | LogicMethod.Current.RemoveAllView(); |
| | | AddLogic addLogic = new AddLogic(); |
| | | MainPage.BasePageView.AddChidren(addLogic); |
| | | addLogic.Show(); |
| | |
| | | return; |
| | | } |
| | | Output outputTime= new Output(); |
| | | outputTime.sid = LogicMethod.CurrLogicMethod.NewSid(); |
| | | outputTime.sid = LogicMethod.Current.NewSid(); |
| | | outputTime.target_type = "4"; |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "key", "delay"); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "value", timepoint); |
| | | LogicMethod.Current.dictionary(dic, "key", "delay"); |
| | | LogicMethod.Current.dictionary(dic, "value", timepoint); |
| | | outputTime.status.Add(dic); |
| | | if (edit) |
| | | { |
| | |
| | | AddOutput(outputTime); |
| | | } |
| | | fLayout.RemoveFromParent(); |
| | | LogicMethod.CurrLogicMethod.RemoveAllView(); |
| | | LogicMethod.Current.RemoveAllView(); |
| | | AddLogic addLogic = new AddLogic(); |
| | | MainPage.BasePageView.AddChidren(addLogic); |
| | | addLogic.Show(); |
| | |
| | | private void AddDic(string value) |
| | | { |
| | | Input input = new Input(); |
| | | input.sid = LogicMethod.CurrLogicMethod.NewSid(); |
| | | input.sid = LogicMethod.Current.NewSid(); |
| | | input.condition_type = "6"; |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "key", "airquality"); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "comparator", "="); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "data_type", "string"); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "value", value); |
| | | LogicMethod.Current.dictionary(dic, "key", "airquality"); |
| | | LogicMethod.Current.dictionary(dic, "comparator", "="); |
| | | LogicMethod.Current.dictionary(dic, "data_type", "string"); |
| | | LogicMethod.Current.dictionary(dic, "value", value); |
| | | input.condition.Add(dic); |
| | | AddCondition(input, "airquality" ,"="); |
| | | } |
| | |
| | | Logic.currlogic.input.Add(input); |
| | | } |
| | | |
| | | LogicMethod.CurrLogicMethod.RemoveAllView(); |
| | | LogicMethod.Current.RemoveAllView(); |
| | | AddLogic addLogic = new AddLogic(); |
| | | MainPage.BasePageView.AddChidren(addLogic); |
| | | addLogic.Show(); |
| | |
| | | /// 输入条件列表索引值 |
| | | /// </summary> |
| | | private int mIndex; |
| | | /// <summary> |
| | | /// 可视对讲专用 |
| | | /// </summary> |
| | | private string identifier; |
| | | |
| | | private static ConditionDeviceFunList m_Current = null; |
| | | |
| | | public static ConditionDeviceFunList Current |
| | | { |
| | | get |
| | | { |
| | | if (m_Current == null) |
| | | { |
| | | m_Current = new ConditionDeviceFunList(); |
| | | } |
| | | return m_Current; |
| | | } |
| | | } |
| | | |
| | | public void Show(Entity.Function device, int index, bool edit) |
| | | { |
| | |
| | | //毫米波传感器(自研北邮) |
| | | case SPK.SenesorMegahealth: |
| | | { |
| | | |
| | | LogicView.FunTypeView view1= new LogicView.FunTypeView(); |
| | | |
| | | LogicView.FunTypeView view1 = new LogicView.FunTypeView(); |
| | | view1.btnText.TextID = StringId.diedaobaojing; |
| | | view1.btnState.Name = Language.StringByID(StringId.diedaobaojing); |
| | | fLayout.AddChidren(view1.FLayoutView()); |
| | |
| | | { |
| | | DeviceView(device, view1.btnState, StringId.shi, StringId.offLogic, 1); |
| | | }; |
| | | |
| | | |
| | | LogicView.FunTypeView view2 = new LogicView.FunTypeView(); |
| | | view2.frameLayout.Y = view1.frameLayout.Bottom; |
| | | view2.btnText.TextID = StringId.yourenbaojing; |
| | |
| | | { |
| | | fLayout.AddChidren(tvocView.FLayoutView()); |
| | | } |
| | | |
| | | |
| | | #endregion |
| | | #region 点击事件 |
| | | ///温度点击事件 |
| | |
| | | { |
| | | new PublicInterface { }.ViewZuHe(this, StringId.wendugaoyu, StringId.wendudiyu, (intText, view) => |
| | | { |
| | | InputBoxAction(device,intText, index, edit); |
| | | InputBoxAction(device, intText, index, edit); |
| | | }); |
| | | }; |
| | | ///湿度点击事件 |
| | |
| | | { |
| | | new PublicInterface { }.ViewZuHe(this, StringId.shidugaoyu, StringId.shidudiyu, (intText, view) => |
| | | { |
| | | InputBoxAction(device,intText, index, edit); |
| | | InputBoxAction(device, intText, index, edit); |
| | | }); |
| | | |
| | | }; |
| | | ///pm2.5点击事件 |
| | | pm25View.btnClick.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | PmCo2TvocAction(this,device, "pm25",StringId.pm25, index,edit); |
| | | PmCo2TvocAction(this, device, "pm25", StringId.pm25, index, edit); |
| | | }; |
| | | ///co2点击事件 |
| | | co2View.btnClick.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | PmCo2TvocAction(this,device, "co2", StringId.co2, index, edit); |
| | | PmCo2TvocAction(this, device, "co2", StringId.co2, index, edit); |
| | | }; |
| | | ///tvoc点击事件 |
| | | tvocView.btnClick.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | PmCo2TvocAction(this,device, "tvoc", StringId.tvoc, index, edit); |
| | | PmCo2TvocAction(this, device, "tvoc", StringId.tvoc, index, edit); |
| | | |
| | | }; |
| | | #endregion |
| | | } |
| | | break; |
| | | //温度传感器 |
| | | //温度传感器 |
| | | case SPK.SensorTemperature: |
| | | { |
| | | ///温度 |
| | |
| | | //tvoc |
| | | case SPK.SensorTVOC: |
| | | { |
| | | |
| | | |
| | | ///tvoc |
| | | LogicView.FunTypeView tvocView = new LogicView.FunTypeView(); |
| | | tvocView.btnText.TextID = StringId.tvoc; |
| | |
| | | fLayout.AddChidren(view.FLayoutView()); |
| | | view.btnClick.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | DeviceView(device, view.btnState, StringId.shi, StringId.offLogic,1); |
| | | DeviceView(device, view.btnState, StringId.shi, StringId.offLogic, 1); |
| | | }; |
| | | if (edit) |
| | | { |
| | | GetEditState(device, index, view.btnState, null, null, null); |
| | | } |
| | | } |
| | | break; |
| | | //可视对讲 |
| | | case SPK.doorgate: |
| | | { |
| | | |
| | | LogicView.FunTypeView view1 = new LogicView.FunTypeView(); |
| | | view1.btnText.TextID = StringId.shipintonghuahujiao; |
| | | view1.btnText.Name = Language.StringByID(StringId.shipintonghuahujiao); |
| | | fLayout.AddChidren(view1.FLayoutView()); |
| | | view1.btnClick.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | identifier = "door_call_cloud_event"; |
| | | DeviceView(device, view1.btnState, StringId.shi, StringId.offLogic, 1); |
| | | }; |
| | | |
| | | LogicView.FunTypeView view2 = new LogicView.FunTypeView(); |
| | | view2.frameLayout.Y = view1.frameLayout.Bottom; |
| | | view2.btnText.TextID = StringId.renliankaimen; |
| | | fLayout.AddChidren(view2.FLayoutView()); |
| | | view2.btnClick.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | identifier = "door_pedestrian_records"; |
| | | this.FaceAction(this, device, view2.btnState); |
| | | }; |
| | | |
| | | int intValue = 0; |
| | | if (edit) |
| | | { |
| | | Input inputs = Logic.currlogic.input[index]; |
| | | if (inputs.identifier == "door_call_cloud_event") |
| | | { |
| | | intValue = 1; |
| | | } |
| | | else |
| | | { |
| | | intValue = 2; |
| | | } |
| | | } |
| | | if (intValue == 1) |
| | | { |
| | | //跌倒报警 |
| | | view2.frameLayout.Visible = false; |
| | | |
| | | } |
| | | else if (intValue == 2) |
| | | { |
| | | //有人报警 |
| | | view2.frameLayout.Y = Application.GetRealHeight(0); |
| | | } |
| | | if (edit) |
| | | { |
| | | GetEditState(device, index, view1.btnState, view2.btnState, null, null); |
| | | } |
| | | } |
| | | break; |
| | |
| | | inputDevice.condition_type = "3"; |
| | | inputDevice.sid = device.sid; |
| | | inputDevice.condition = dicSateteList; |
| | | if (device.spk == SPK.doorgate) |
| | | { |
| | | //可视对讲 |
| | | inputDevice.condition_type = "9"; |
| | | inputDevice.identifier = this.identifier; |
| | | if (this.identifier == "door_call_cloud_event") |
| | | { |
| | | inputDevice.condition = new List<Dictionary<string, string>>(); |
| | | } |
| | | } |
| | | |
| | | |
| | | if (edit) |
| | | { |
| | | //移除旧数据 |
| | |
| | | this.RemoveFromParent(); |
| | | return; |
| | | } |
| | | LogicMethod.CurrLogicMethod.RemoveAllView(); |
| | | LogicMethod.Current.RemoveAllView(); |
| | | if (MainView.IsGatewayType) |
| | | { //A网关 |
| | | var addLogic = new AddLogic(); |
| | |
| | | if (button != null) |
| | | { |
| | | |
| | | |
| | | if (button.Name == Language.StringByID(StringId.yourenbaojing) |
| | | || (button.Name == Language.StringByID(StringId.diedaobaojing))) |
| | | { |
| | | //只有毫米波传感器(自研) |
| | | Save(device, mIndex, mEdit); |
| | | } |
| | | else if (button.Name == Language.StringByID(StringId.shipintonghuahujiao)) { |
| | | //只有毫米波传感器(自研) |
| | | Save(device, mIndex, mEdit); |
| | | } |
| | |
| | | }); |
| | | } |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="frame">当前界面</param> |
| | | /// <param name="device">当前设备</param> |
| | | /// <param name="btnState">旧状态</param> |
| | | public void FaceAction(FrameLayout frame, Entity.Function device,Button btnState) { |
| | | selectedState = device.spk + "_"; |
| | | Loading loading = new Loading(); |
| | | frame.AddChidren(loading); |
| | | loading.Start(); |
| | | System.Threading.Tasks.Task.Run(() => |
| | | { |
| | | try |
| | | { |
| | | var faceIDList = Send.Current.GetListHomeFace(device.deviceId,true); |
| | | List<string> faceNameList = new List<string>(); |
| | | for (int i = 0; i < faceIDList.Count; i++) |
| | | { |
| | | var face = faceIDList[i]; |
| | | faceNameList.Add(face.userName); |
| | | } |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | loading.Hide(); |
| | | PublicInterface publicInterface = new PublicInterface(); |
| | | publicInterface.FrameOrVv(this, faceNameList, new List<string> { btnState.Text }, device.name, (index) => |
| | | { |
| | | var face = faceIDList[index]; |
| | | //界面显示选中值 |
| | | btnState.Text = face.userName; |
| | | //数据封装 |
| | | AddDictionary("open_type", "1", "string"); |
| | | AddDictionary("user_id", face.userId, "string"); |
| | | |
| | | }, false); |
| | | |
| | | }); |
| | | } |
| | | catch { } |
| | | |
| | | }); |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 显示编辑之前的设备状态 |
| | | /// </summary> |
| | | /// <param name="device">编辑设备</param> |
| | |
| | | //有数据重新赋值 |
| | | dicSateteList = dicList; |
| | | } |
| | | InpOrOutLogicMethod.EditState(device, dicList, button1, button2, button3, button4); |
| | | InpOrOutLogicMethod.Current.EditDeviceState(device, dicList, button1, button2, button3, button4); |
| | | } |
| | | /// <summary> |
| | | /// 添加选中数据 |
| | |
| | | { |
| | | //数据封装 |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "key", KeyValue); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "comparator", comparator); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "data_type", data_type); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "value", selectedValue); |
| | | LogicMethod.Current.dictionary(dic, "key", KeyValue); |
| | | LogicMethod.Current.dictionary(dic, "comparator", comparator); |
| | | LogicMethod.Current.dictionary(dic, "data_type", data_type); |
| | | LogicMethod.Current.dictionary(dic, "value", selectedValue); |
| | | AddDictionaryList(dic); |
| | | } |
| | | /// <summary> |
| | |
| | | Width = Application.GetRealWidth(144), |
| | | Height = Application.GetRealHeight(44 * 5), |
| | | }; |
| | | var roomList = LogicMethod.CurrLogicMethod.GetGatewayRoomList(Language.StringByID(StringId.allAreas)); |
| | | var roomList = LogicMethod.Current.GetGatewayRoomList(Language.StringByID(StringId.allAreas)); |
| | | |
| | | if (roomList.Count > 5) |
| | | { |
| | |
| | | ///切换房间默认:全部功能 |
| | | UserInfo.Current.logicselectedFunction = Language.StringByID(StringId.allFun); |
| | | ///获取显示设备列表 |
| | | var list = LogicMethod.CurrLogicMethod.GetFunctionDeviceList(areaView.btnClick.Tag as Entity.Room, if_Type); |
| | | var list = LogicMethod.Current.GetFunctionDeviceList(areaView.btnClick.Tag as Entity.Room, if_Type); |
| | | |
| | | this.LoadingDeviceListView(vv, list); |
| | | }; |
| | |
| | | { |
| | | |
| | | //获取最终显示列表 |
| | | var functionList = LogicMethod.CurrLogicMethod.GetFunctionDeviceList(UserInfo.Current.logicselectedRoom, if_Type); |
| | | var functionList = LogicMethod.Current.GetFunctionDeviceList(UserInfo.Current.logicselectedRoom, if_Type); |
| | | //获取设备列表的类型(例如:灯光类,窗帘类。。。) |
| | | var deviceTypeList = LogicMethod.CurrLogicMethod.GetDeviceTypeList(functionList); |
| | | var deviceTypeList = LogicMethod.Current.GetDeviceTypeList(functionList); |
| | | if (deviceTypeList.Count == 0) |
| | | { |
| | | //没有类型直接返回去; |
| | |
| | | funAllAreaView.btnText2.Text = clickText; |
| | | UserInfo.Current.logicselectedFunction = clickText; |
| | | ///获取设备单个大类spk列表(例如:灯光类,空调类...) |
| | | var typeFunctionList2 = LogicMethod.CurrLogicMethod.GetDeviceTypeFunctionList(clickText); |
| | | var typeFunctionList2 = LogicMethod.Current.GetDeviceTypeFunctionList(clickText); |
| | | ///获取设备单个小类列表(例如:灯光1,灯光2...) |
| | | var lists2 = LogicMethod.CurrLogicMethod.GetShowDeviceList(typeFunctionList2, functionList); |
| | | var lists2 = LogicMethod.Current.GetShowDeviceList(typeFunctionList2, functionList); |
| | | this.LoadingDeviceListView(vv, lists2); |
| | | |
| | | }; |
| | |
| | | funAllAreaView.btnText2.MouseUpEventHandler += funClick; |
| | | funAllAreaView.btnIcon2.MouseUpEventHandler += funClick; |
| | | ///获取房间支持的设备列表 |
| | | var deviceList = LogicMethod.CurrLogicMethod.GetFunctionDeviceList(UserInfo.Current.logicselectedRoom, if_Type); |
| | | var deviceList = LogicMethod.Current.GetFunctionDeviceList(UserInfo.Current.logicselectedRoom, if_Type); |
| | | ///获取设备单个大类spk列表(例如:灯光类,空调类...) |
| | | var typeFunctionList = LogicMethod.CurrLogicMethod.GetDeviceTypeFunctionList(UserInfo.Current.logicselectedFunction); |
| | | var typeFunctionList = LogicMethod.Current.GetDeviceTypeFunctionList(UserInfo.Current.logicselectedFunction); |
| | | ///获取设备单个小类列表(例如:灯光1,灯光2...) |
| | | var lists = LogicMethod.CurrLogicMethod.GetShowDeviceList(typeFunctionList, deviceList); |
| | | var lists = LogicMethod.Current.GetShowDeviceList(typeFunctionList, deviceList); |
| | | ///房间名称 |
| | | funAllAreaView.btnText1.Text = UserInfo.Current.logicselectedRoom.roomName; |
| | | ///设备大类名称<灯光类。。。。。> |
| | |
| | | funView.btnLine.X = Application.GetRealWidth(16); |
| | | funView.btnLine.Width = Application.GetRealWidth(343); |
| | | verticalScrolView.AddChidren(funView.FLayoutView()); |
| | | funView.btnIcon.UnSelectedImagePath = LogicMethod.CurrLogicMethod.GetIconPath(dev.spk); |
| | | funView.btnIcon.UnSelectedImagePath = LogicMethod.Current.GetIconPath(dev.spk); |
| | | funView.btnDeviceName.Text = dev.name; |
| | | funView.btnRoomName.Text = dev.GetRoomListName(); |
| | | funView.btnClick.MouseUpEventHandler += (sen, e) => |
| | |
| | | { |
| | | public class InpOrOutLogicMethod |
| | | { |
| | | |
| | | private static InpOrOutLogicMethod s_Current = null; |
| | | |
| | | public static InpOrOutLogicMethod Current |
| | | { |
| | | get |
| | | { |
| | | if (s_Current == null) |
| | | { |
| | | s_Current = new InpOrOutLogicMethod(); |
| | | |
| | | } |
| | | return s_Current; |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 输入条件处理方法 |
| | | /// </summary> |
| | | /// <param name="thisView">当前界面</param> |
| | | /// <param name="viewLayout">上下滑动控件</param> |
| | | public static void InputCondition(FrameLayout thisView, VerticalScrolViewLayout viewLayout) |
| | | public void InputCondition(FrameLayout thisView, VerticalScrolViewLayout viewLayout) |
| | | { |
| | | for (int i = 0; i < Logic.currlogic.input.Count; i++) |
| | | { |
| | |
| | | } |
| | | break; |
| | | case "3": |
| | | case "9"://可视对讲:9 |
| | | { |
| | | //用sid找到设备; |
| | | var device = LogicMethod.CurrLogicMethod.GetDevice(inputCondition.sid); |
| | | var device = LogicMethod.Current.GetDevice(inputCondition.sid); |
| | | //用设备的functionType类型找到对应图标; |
| | | inputView.btnIcon.UnSelectedImagePath = LogicMethod.CurrLogicMethod.GetIconPath(device.spk); |
| | | inputView.btnIcon.UnSelectedImagePath = LogicMethod.Current.GetIconPath(device.spk); |
| | | //显示设备名称 |
| | | inputView.btnText.Text = device.name; |
| | | //改变设备名称显示控件宽度 |
| | |
| | | } |
| | | |
| | | } |
| | | }break; |
| | | } |
| | | break; |
| | | case SPK.SenesorMegahealth2: |
| | | { |
| | | foreach (var dic in dicList) |
| | |
| | | break; |
| | | case SPK.SensorHumidity: |
| | | { |
| | | string str = new InpOrOutLogicMethod { }.GetText(dicList, "humidity"); |
| | | string str = this.GetText(dicList, "humidity"); |
| | | inputView.btnState.Text = str; |
| | | |
| | | } |
| | |
| | | case SPK.SensorTVOC: |
| | | case SPK.SensorHcho: |
| | | { |
| | | string strvalue = ""; |
| | | string strvalue = ""; |
| | | foreach (var dic in dicList) |
| | | { |
| | | strvalue = dic["value"]; |
| | |
| | | inputView.btnState.Text = Language.StringByID(StringId.kaiqi); |
| | | } |
| | | |
| | | } |
| | | } |
| | | break; |
| | | case SPK.doorgate: |
| | | { |
| | | if (inputCondition.identifier == "door_call_cloud_event") |
| | | { |
| | | inputView.btnState.Text = Language.StringByID(StringId.shipintonghuahujiao); |
| | | } |
| | | else |
| | | { |
| | | |
| | | foreach (var dic in dicList) |
| | | { |
| | | string key = dic["key"]; |
| | | if (key == "user_id") |
| | | { |
| | | string userId = dic["value"]; |
| | | var FaceItem = this.FaceItem(userId, device.deviceId); |
| | | inputView.btnState.Text = FaceItem.userName; |
| | | // Language.StringByID(StringId.kaiqi); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | break; |
| | |
| | | case "10": |
| | | { |
| | | //用sid找到场景; |
| | | var scene = LogicMethod.CurrLogicMethod.GetSecne(inputCondition.sid); |
| | | var scene = LogicMethod.Current.GetSecne(inputCondition.sid); |
| | | inputView.btnIcon.UnSelectedImagePath = "LogicIcon/scene.png"; |
| | | inputView.btnNextIcon.Visible = false; |
| | | inputView.btnClick.Visible = false; |
| | |
| | | { |
| | | Button button = (Button)sen; |
| | | //当前编辑的条件 |
| | | Input ckcliInput = inputView.btnClick.Tag as Input; |
| | | Input clickInput = inputView.btnClick.Tag as Input; |
| | | //找到当前编辑的索引 |
| | | int indexVulae = 0; |
| | | for (int index = 0; index < Logic.currlogic.input.Count; index++) |
| | | { |
| | | Input input = Logic.currlogic.input[index]; |
| | | if (input.sid == ckcliInput.sid) |
| | | if (input.sid == clickInput.sid) |
| | | { |
| | | if (button.Name == "3") |
| | | if (button.Name == "3" || button.Name == "9") |
| | | { |
| | | //有些设备比较特殊(例如:海林传感器还是要判断属性值,温湿度属性还要判断比较关系,才能确认是否已经存在该条件,其他设备条件直接用sid判断即可) |
| | | //加一级判断是为兼容特殊设备 |
| | | if (new ConditionDeviceFunList { }.IsContainsAll(ckcliInput.condition, input.condition)) |
| | | if (new ConditionDeviceFunList { }.IsContainsAll(clickInput.condition, input.condition)) |
| | | { |
| | | //用户可能删除数据,使列表索引发生改变; |
| | | //通过唯一sid重新查找到索引且更新索引值 |
| | |
| | | timeTpye.TimeHorizon(fLayout, edit, indexVulae); |
| | | } |
| | | break; |
| | | case "9": |
| | | case "3": |
| | | { |
| | | //用sid找到设备; |
| | | var device = LogicMethod.CurrLogicMethod.GetDevice(inputCondition.sid); |
| | | var device = LogicMethod.Current.GetDevice(inputCondition.sid); |
| | | if (device.spk == SPK.SensorEnvironment |
| | | || device.spk == SPK.SensorEnvironment2 |
| | | || device.spk == SPK.SensorEnvironment3 |
| | |
| | | /// </summary> |
| | | /// <param name="thisView">当前界面</param> |
| | | /// <param name="viewLayout">上下滑动控件</param> |
| | | public static void OutputTarget(FrameLayout thisView, VerticalScrolViewLayout viewLayout) |
| | | public void OutputTarget(FrameLayout thisView, VerticalScrolViewLayout viewLayout) |
| | | { |
| | | |
| | | for (int i = 0; i < Logic.currlogic.output.Count; i++) |
| | |
| | | case "1": |
| | | { |
| | | //用sid找到设备; |
| | | var device = LogicMethod.CurrLogicMethod.GetDevice(outputTarget.sid); |
| | | var device = LogicMethod.Current.GetDevice(outputTarget.sid); |
| | | //用设备的functionType类型找到对应图标; |
| | | targetView.btnIcon.UnSelectedImagePath = LogicMethod.CurrLogicMethod.GetIconPath(device.spk); |
| | | targetView.btnIcon.UnSelectedImagePath = LogicMethod.Current.GetIconPath(device.spk); |
| | | //显示设备名称 |
| | | targetView.btnText.Text = device.name; |
| | | //改变设备名称显示控件宽度 |
| | |
| | | case SPK.CurtainRoller: |
| | | { |
| | | string on_off = GetKeyValue("on_off", dicList); |
| | | string percent = GetKeyValue("percent", dicList); |
| | | string percent = GetKeyValue("percent", dicList); |
| | | if (on_off == "on" && percent != "") |
| | | { |
| | | stateStr = Language.StringByID(StringId.onLogic) + percent + "%"; |
| | |
| | | if (percent != "" && angle != "") |
| | | { |
| | | stateStr += Language.StringByID(StringId.onLogic) + percent + "%;"; |
| | | stateStr +=Language.StringByID(StringId.Angle)+angle + "°"; |
| | | stateStr += Language.StringByID(StringId.Angle) + angle + "°"; |
| | | } |
| | | else if (percent != "") |
| | | { |
| | |
| | | |
| | | } |
| | | break; |
| | | case SPK.FloorHeatStandard:case SPK.HvacFloorHeat: |
| | | case SPK.FloorHeatStandard: |
| | | case SPK.HvacFloorHeat: |
| | | { |
| | | string on_off = GetKeyValue("on_off", dicList); |
| | | string set_temp = GetKeyValue("set_temp", dicList); |
| | |
| | | } |
| | | } |
| | | break; |
| | | case SPK.MusicStandard: |
| | | case SPK.AvMusic: |
| | | { |
| | | foreach (var dic in dicList) |
| | | { |
| | | if (dic["key"] == "song_name") |
| | | { |
| | | stateStr = dic["value"]?.ToString(); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | break; |
| | | case "2": |
| | | { |
| | | //用sid找到场景; |
| | | var scene = LogicMethod.CurrLogicMethod.GetSecne(outputTarget.sid); |
| | | var scene = LogicMethod.Current.GetSecne(outputTarget.sid); |
| | | targetView.btnIcon.UnSelectedImagePath = "LogicIcon/scene.png"; |
| | | targetView.btnNextIcon.Visible = false; |
| | | //显示场景名称 |
| | |
| | | case "3": |
| | | { |
| | | //用sid找到安防; |
| | | var security = LogicMethod.CurrLogicMethod.GetSecurity(outputTarget.sid); |
| | | var security = LogicMethod.Current.GetSecurity(outputTarget.sid); |
| | | targetView.btnIcon.UnSelectedImagePath = "LogicIcon/security.png"; |
| | | targetView.btnDelay.Visible = false; |
| | | //显示安防名称 |
| | |
| | | case "1": |
| | | { |
| | | //用sid找到设备; |
| | | var device = LogicMethod.CurrLogicMethod.GetDevice(outputTarget.sid); |
| | | var device = LogicMethod.Current.GetDevice(outputTarget.sid); |
| | | TargetDeviceFunList deviceFunList = new TargetDeviceFunList(); |
| | | MainPage.BasePageView.AddChidren(deviceFunList); |
| | | deviceFunList.Show(device, indexVulae, edit); |
| | |
| | | /// <param name="button1">显示Btn</param> |
| | | /// <param name="button2">显示Btn</param> |
| | | /// <param name="button3">显示Btn</param> |
| | | /// <param name="button4">显示Btn</param> |
| | | public static void EditState(Entity.Function device, List<Dictionary<string, string>> dicList, Button button1, Button button2, Button button3, Button button4) |
| | | /// <param name="button4">显示Btn</param> |
| | | public void EditDeviceState(Entity.Function device, List<Dictionary<string, string>> dicList, Button button1, Button button2, Button button3, Button button4) |
| | | { |
| | | switch (device.spk) |
| | | { |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | break; |
| | | case SPK.CurtainDream: |
| | |
| | | |
| | | } |
| | | break; |
| | | case SPK.FloorHeatStandard:case SPK.HvacFloorHeat: |
| | | case SPK.FloorHeatStandard: |
| | | case SPK.HvacFloorHeat: |
| | | { |
| | | |
| | | foreach (var dic in dicList) |
| | |
| | | string value = dic["value"]; |
| | | switch (dic["key"]) |
| | | { |
| | | |
| | | |
| | | case "target_status": |
| | | { |
| | | if (value == "4") |
| | |
| | | { |
| | | button1.Text = Language.StringByID(StringId.shi); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | break; |
| | | case SPK.MusicStandard: |
| | | case SPK.AvMusic: |
| | | { |
| | | foreach (var dic in dicList) |
| | | { |
| | | if (dic["key"] == "song_name") |
| | | { |
| | | button1.Text = dic["value"]?.ToString(); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | case SPK.doorgate: |
| | | { |
| | | foreach (var dic in dicList) |
| | | { |
| | | if (dic["key"] == "user_id") |
| | | { |
| | | button2.Text = dic["value"]?.ToString(); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | |
| | | /// <param name="keyValue"></param> |
| | | /// <param name="dicList"></param> |
| | | /// <returns></returns> |
| | | public static string GetKeyValue(string keyValue, List<Dictionary<string, string>> dicList) |
| | | public string GetKeyValue(string keyValue, List<Dictionary<string, string>> dicList) |
| | | { |
| | | |
| | | string valueStr = ""; |
| | |
| | | ///获取自动化名称 |
| | | /// </summary> |
| | | /// <returns> 新建自动化命名规则</returns> |
| | | public static string GetLogicName(Logic logic) |
| | | public string GetLogicName(Logic logic) |
| | | { |
| | | |
| | | string name = ""; |
| | |
| | | } |
| | | break; |
| | | case "3": |
| | | case "9": |
| | | { |
| | | //用sid找到设备; |
| | | var device = LogicMethod.CurrLogicMethod.GetDevice(inputCondition.sid); |
| | | var device = LogicMethod.Current.GetDevice(inputCondition.sid); |
| | | name = device.name + "-"; |
| | | } |
| | | break; |
| | | case "10": |
| | | { |
| | | //用sid找到场景; |
| | | var scene = LogicMethod.CurrLogicMethod.GetSecne(inputCondition.sid); |
| | | var scene = LogicMethod.Current.GetSecne(inputCondition.sid); |
| | | name = scene.name + "-"; |
| | | } |
| | | break; |
| | |
| | | case "1": |
| | | { |
| | | //用sid找到设备; |
| | | var device = LogicMethod.CurrLogicMethod.GetDevice(outputTarget.sid); |
| | | var device = LogicMethod.Current.GetDevice(outputTarget.sid); |
| | | //显示设备名称 |
| | | name += device.name; |
| | | string stateStr = ""; |
| | |
| | | case SPK.LightCCT: |
| | | case SPK.LightDimming: |
| | | { |
| | | string on_off = InpOrOutLogicMethod.GetKeyValue("on_off", dicList); |
| | | string brightness = InpOrOutLogicMethod.GetKeyValue("brightness", dicList); |
| | | string on_off = this.GetKeyValue("on_off", dicList); |
| | | string brightness = this.GetKeyValue("brightness", dicList); |
| | | if (on_off == "on" && brightness != "") |
| | | { |
| | | stateStr = Language.StringByID(StringId.onLogic) + brightness + "%"; |
| | |
| | | break; |
| | | case SPK.AcStandard: |
| | | case SPK.HvacAC: |
| | | case SPK.FloorHeatStandard:case SPK.HvacFloorHeat: |
| | | case SPK.FloorHeatStandard: |
| | | case SPK.HvacFloorHeat: |
| | | { |
| | | foreach (var dic in dicList) |
| | | { |
| | |
| | | case "2": |
| | | { |
| | | //用sid找到场景; |
| | | var scene = LogicMethod.CurrLogicMethod.GetSecne(outputTarget.sid); |
| | | var scene = LogicMethod.Current.GetSecne(outputTarget.sid); |
| | | name += scene.name; |
| | | |
| | | } |
| | |
| | | case "3": |
| | | { |
| | | //用sid找到安防; |
| | | var security = LogicMethod.CurrLogicMethod.GetSecurity(outputTarget.sid); |
| | | var security = LogicMethod.Current.GetSecurity(outputTarget.sid); |
| | | name += security.name; |
| | | |
| | | } |
| | |
| | | /// </summary> |
| | | /// <param name="dicList">状态数据列表</param> |
| | | /// <returns></returns> |
| | | private string GetText(List<Dictionary<string, string>> dicList,string key) |
| | | private string GetText(List<Dictionary<string, string>> dicList, string key) |
| | | { |
| | | string strtext = ""; |
| | | foreach (var dic in dicList) |
| | |
| | | } |
| | | return strtext; |
| | | } |
| | | private void SensorView(FrameLayout thisView, Function device,string key, int indexVulae) { |
| | | private void SensorView(FrameLayout thisView, Function device, string key, int indexVulae) |
| | | { |
| | | //这个设备比较特殊 |
| | | ConditionDeviceFunList conditionDeviceFunList = new ConditionDeviceFunList(); |
| | | ///当前的索引值数据对象 |
| | |
| | | } |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 查找指定userId |
| | | /// </summary> |
| | | /// <param name="userId"></param> |
| | | /// <returns></returns> |
| | | public Face FaceItem(string userId, string deviceId) |
| | | { |
| | | if (Send.Current.faceList.Count == 0) |
| | | { |
| | | Send.Current.GetListHomeFace(deviceId, false); |
| | | } |
| | | var face = Send.Current.faceList.Find((o) => { return o.userId == userId; }); |
| | | if (face == null) |
| | | { |
| | | face = new Face(); |
| | | } |
| | | return face; |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | try |
| | | { |
| | | userList = Send.GetResidenceMemberAccount(); |
| | | userList = Send.Current.GetResidenceMemberAccount(); |
| | | |
| | | } |
| | | catch { } |
| | |
| | | /// 某个逻辑/场景的输出条件=7; |
| | | /// 地理围栏=8; |
| | | /// 空气质量=9(废弃); |
| | | /// 可视对讲=9; |
| | | /// 场景=10; |
| | | /// </summary> |
| | | public string condition_type = ""; |
| | | /// <summary> |
| | | /// condition_type=9时使用 |
| | | /// </summary> |
| | | public string identifier = ""; |
| | | public List<Dictionary<string, string>> condition = new List<Dictionary<string, string>>(); |
| | | /// <summary> |
| | | /// 地理围栏配置 |
| | |
| | | { |
| | | /// <summary> |
| | | /// 定义一个静态对象 |
| | | /// </summary> |
| | | private static LogicMethod logicMethod = null; |
| | | /// </summary> |
| | | private static LogicMethod s_Current = null; |
| | | /// <summary> |
| | | /// 获取静态对象 |
| | | /// </summary> |
| | | public static LogicMethod CurrLogicMethod |
| | | public static LogicMethod Current |
| | | { |
| | | get |
| | | { |
| | | if (logicMethod == null) |
| | | if (s_Current == null) |
| | | { |
| | | return new LogicMethod(); |
| | | } |
| | | return logicMethod; |
| | | return s_Current; |
| | | } |
| | | |
| | | } |
| | |
| | | /// <returns></returns> |
| | | public List<HDL_ON.Entity.Function> GetGatewayDeviceList() |
| | | { |
| | | var list = Entity.FunctionList.List.GetDeviceFunctionList(); |
| | | var list = new List<HDL_ON.Entity.Function>(); |
| | | var list1 = Entity.FunctionList.List.GetDeviceFunctionList(); |
| | | var list2 = this.GetVideoDeviceList(); |
| | | list.AddRange(list1); |
| | | list.AddRange(list2); |
| | | //GetTestDevice(ref list, true); |
| | | return list; |
| | | } |
| | | /// <summary> |
| | | /// 获取可视对讲设备列表 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public List<HDL_ON.Entity.Function> GetVideoDeviceList() |
| | | { |
| | | var functionList = new List<Function>(); |
| | | foreach (var videoDevice in FunctionList.List.videoIntercom) { |
| | | Function function = new Function(); |
| | | function.spk = videoDevice.spk; |
| | | function.name = videoDevice.deviceName; |
| | | function.deviceId = videoDevice.deviceId; |
| | | function.online = videoDevice.status== "online"; |
| | | function.sid = videoDevice.sid; |
| | | var video = functionList.Find((o) => o.deviceId == function.deviceId); |
| | | if (video == null) { |
| | | functionList.Add(function); |
| | | } |
| | | |
| | | } |
| | | return functionList; |
| | | } |
| | | /// <summary> |
| | | /// 获取场景列表 |
| | |
| | | string strPath = ""; |
| | | switch (functionType) |
| | | { |
| | | |
| | | case SPK.doorgate: |
| | | { |
| | | strPath = "VideoIcon/keshiduijiang.png"; |
| | | } |
| | | break; |
| | | case SPK.AirSwitch: |
| | | { |
| | | strPath = "FunctionIcon/Icon/electricalbreaker.png"; |
| | |
| | | case SPK.DoorLock: |
| | | { |
| | | strPath = "FunctionIcon/DoorLock/DoorLock.png"; |
| | | } |
| | | break; |
| | | case SPK.MusicStandard: |
| | | case SPK.AvMusic: |
| | | { |
| | | strPath = "MusicIcon/localMusic.png"; |
| | | } |
| | | break; |
| | | |
| | |
| | | { |
| | | deviceStrTypeList.Add(Language.StringByID(StringId.DoorLock)); |
| | | } |
| | | ///音乐类 |
| | | var music = deviceList.Find((device) => device.spk == SPK.MusicStandard || device.spk == SPK.AvMusic); |
| | | if (music != null) |
| | | { |
| | | deviceStrTypeList.Add(Language.StringByID(StringId.Music)); |
| | | } |
| | | ///可视对讲 |
| | | var doorgate = deviceList.Find((device) => device.spk == SPK.doorgate); |
| | | if (doorgate != null) |
| | | { |
| | | deviceStrTypeList.Add(Language.StringByID(StringId.VideoIntercom)); |
| | | } |
| | | return deviceStrTypeList; |
| | | |
| | | } |
| | |
| | | { |
| | | functionTypeList.Add(SPK.DoorLock); |
| | | } |
| | | ///音乐类 |
| | | else if (deviceType == Language.StringByID(StringId.Music)) |
| | | { |
| | | functionTypeList.Add(SPK.MusicStandard); |
| | | functionTypeList.Add(SPK.AvMusic); |
| | | } |
| | | ///HDL可视对讲 |
| | | else if (deviceType == Language.StringByID(StringId.VideoIntercom)) |
| | | { |
| | | functionTypeList.Add(SPK.doorgate); |
| | | } |
| | | else |
| | | { |
| | | //全部区域 |
| | |
| | | functionTypeList.Add(SPK.SensorHelp); |
| | | functionTypeList.Add(SPK.DoorLock); |
| | | functionTypeList.Add(SPK.CurtainDream); |
| | | functionTypeList.Add(SPK.MusicStandard); |
| | | functionTypeList.Add(SPK.AvMusic); |
| | | functionTypeList.Add(SPK.doorgate); |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | deviceTypeList.Add(SPK.HvacCac); |
| | | deviceTypeList.Add(SPK.SensorHelp); |
| | | deviceTypeList.Add(SPK.DoorLock); |
| | | deviceTypeList.Add(SPK.doorgate); |
| | | |
| | | } |
| | | break; |
| | |
| | | deviceTypeList.Add(SPK.PanelSocket); |
| | | deviceTypeList.Add(SPK.ElectricSocket); |
| | | deviceTypeList.Add(SPK.CurtainDream); |
| | | deviceTypeList.Add(SPK.MusicStandard); |
| | | deviceTypeList.Add(SPK.AvMusic); |
| | | } |
| | | break; |
| | | } |
| | |
| | | try |
| | | { |
| | | //获取逻辑ID列表,目前针对所有<备注:如果只针对当前手机的话,可以直接拿缓存数据自动化列表遍历> |
| | | var idStr = Send.GetLogicIdList(); |
| | | if (idStr.Code == "0" && idStr.Data != null && idStr.Data.ToString() != "") |
| | | var idStr = Send.Current.GetLogicIdList(); |
| | | if (idStr != null) |
| | | { |
| | | var date = Newtonsoft.Json.JsonConvert.SerializeObject(idStr.Data); |
| | | logicDataList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<LogicData>>(date); |
| | |
| | | if (isPush == null) |
| | | { |
| | | //推送给云端是否成功 |
| | | bool push = Send.GeoFenceStateReport(logicDate.userLogicId, logicDate.sid, direction); |
| | | bool push = Send.Current.GetFenceStateReport(logicDate.userLogicId, logicDate.sid, direction); |
| | | if (push) |
| | | { |
| | | ///添加到推送列表 |
| | |
| | | { |
| | | //模拟设备 |
| | | var functions = new List<Function> { |
| | | new Entity.Function { sid = "0123456789", name = "超声波传感器", spk = Entity.SPK.SensorUtrasonic }, |
| | | }; |
| | | new Entity.Function { sid = "1234567890", name = "超声波传感器", spk = Entity.SPK.SensorUtrasonic }, |
| | | new Entity.Function { sid = "1234567891", name = "温度传感器", spk = Entity.SPK.SensorTemperature }, |
| | | new Entity.Function { sid = "1234567892", name = "湿度传感器", spk = Entity.SPK.SensorHumidity }, |
| | | }; |
| | | foreach (var function in functions) |
| | | { |
| | | var device = list.Find((o) => { return o.sid == function.sid; }); |
| | |
| | | /// 信息提示窗口,自动关闭 |
| | | /// </summary> |
| | | /// <param name="msg">提示错误文本</param> |
| | | public void FlashingBox(string msg,int time=2) |
| | | public void FlashingBox(string msg, int time = 2) |
| | | { |
| | | new PublicAssmebly().TipMsgAutoClose(msg, false, time*1000); |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | new PublicAssmebly().TipMsgAutoClose(msg, false, time * 1000); |
| | | }); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | try |
| | | { |
| | | //逻辑使能的命令 |
| | | Send.SwitchLogic(currLogic); |
| | | Send.Current.SwitchLogic(currLogic); |
| | | |
| | | } |
| | | catch { } |
| | |
| | | } |
| | | List<string> logicIdList = new List<string>(); |
| | | //获取逻辑ID列表 |
| | | var idStr = Send.GetLogicIdList(); |
| | | if (idStr.Code == "0" && idStr.Data != null && idStr.Data.ToString() != "") |
| | | var idStr = Send.Current.GetLogicIdList(); |
| | | if (idStr != null) |
| | | { |
| | | var date = Newtonsoft.Json.JsonConvert.SerializeObject(idStr.Data); |
| | | var dateList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<LogicData>>(date); |
| | |
| | | } |
| | | } |
| | | //获取自动化列表 |
| | | var logicStr = Send.GetLogic(logicIdList); |
| | | if (logicStr.Code == "0" && logicStr.Data != null && logicStr.Data.ToString() != "") |
| | | var logicListStr = Send.Current.GetLogic(logicIdList); |
| | | if (logicListStr != null) |
| | | { |
| | | //获取逻辑详细返回是一个数组(object类型转换为数组); |
| | | var jArray = JArray.Parse(logicStr.Data.ToString()); |
| | | for (int a = 0; a < jArray.Count; a++) |
| | | var logicList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Logic>>(logicListStr.Data.ToString()); |
| | | for (int j = 0; j < logicList.Count; j++) |
| | | { |
| | | var jay = jArray[a]; |
| | | //数据返序列化为Logic对象 |
| | | var str = Newtonsoft.Json.JsonConvert.SerializeObject(jay); |
| | | var logic = Newtonsoft.Json.JsonConvert.DeserializeObject<Logic>(str); |
| | | var logic = logicList[j]; |
| | | if (logic != null) |
| | | { |
| | | //查找是否已经存在该逻辑 |
| | |
| | | } |
| | | |
| | | // 条件处理方法 |
| | | InpOrOutLogicMethod.InputCondition(this, viewLayout); |
| | | InpOrOutLogicMethod.Current.InputCondition(this, viewLayout); |
| | | ///添加图标的View |
| | | LogicView.LogicAddView addInputIcon = new LogicView.LogicAddView(); |
| | | addInputIcon.frameLayout.SetCornerWithSameRadius(Application.GetRealHeight(12), HDLUtils.RectCornerBottomLeft | HDLUtils.RectCornerBottomRight); |
| | |
| | | LogicView.AddOutputInputTextView addOutpuTextView = new LogicView.AddOutputInputTextView(); |
| | | addOutpuTextView.btnIf.TextID = StringId.isExecuted; |
| | | viewLayout.AddChidren(addOutpuTextView.FLayoutView(54, 20)); |
| | | |
| | | |
| | | |
| | | #region 执行推送 发送通知 |
| | | ///上下间隔12像素 |
| | |
| | | } |
| | | Loading loading = new Loading(); |
| | | this.AddChidren(loading); |
| | | HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null; |
| | | HDL_ON.DAL.Server.ResponsePackNew r = null; |
| | | if (string.IsNullOrEmpty(Logic.currlogic.userLogicId)) |
| | | { |
| | | List<string> list = new List<string>(); |
| | |
| | | { |
| | | list.Add(logic.name); |
| | | } |
| | | new LogicView.TipPopView().InputBox(StringId.editName, InpOrOutLogicMethod.GetLogicName(Logic.currlogic), StringId.nameNull, StringId.NameAlreadyExists, list, (logicName, view) => |
| | | new LogicView.TipPopView().InputBox(StringId.editName, InpOrOutLogicMethod.Current.GetLogicName(Logic.currlogic), StringId.nameNull, StringId.NameAlreadyExists, list, (logicName, view) => |
| | | { |
| | | Logic.currlogic.name = logicName; |
| | | Logic.currlogic.sid = LogicMethod.CurrLogicMethod.NewSid(); |
| | | Logic.currlogic.sid = LogicMethod.Current.NewSid(); |
| | | if (MainPage.NoLoginMode) |
| | | { |
| | | Logic.currlogic.userLogicId = Guid.NewGuid().ToString(); |
| | | Logic.LogicList.Add(Logic.currlogic); |
| | | LogicMethod.CurrLogicMethod.RemoveAllView(); |
| | | LogicMethod.Current.RemoveAllView(); |
| | | MainView.MainShow(); |
| | | return; |
| | | } |
| | |
| | | try |
| | | { |
| | | //发送新加逻辑命令; |
| | | responsePackNew = Send.AddLogic(Logic.currlogic); |
| | | |
| | | r = Send.Current.AddLogic(Logic.currlogic, true); |
| | | } |
| | | catch { } |
| | | finally |
| | |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | loading.Hide(); |
| | | if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") |
| | | if (r != null) |
| | | { |
| | | |
| | | |
| | | //获取逻辑详细返回是一个数组(object类型转换为数组); |
| | | var jArray = Newtonsoft.Json.Linq.JArray.Parse(responsePackNew.Data.ToString()); |
| | | for (int a = 0; a < jArray.Count; a++) |
| | | var userLogicIdList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Logic>>(r.Data.ToString()); |
| | | for (int i = 0; i < userLogicIdList.Count; i++) |
| | | { |
| | | var jay = jArray[a]; |
| | | //数据返序列化为Logic对象 |
| | | var str = Newtonsoft.Json.JsonConvert.SerializeObject(jay); |
| | | var logic = Newtonsoft.Json.JsonConvert.DeserializeObject<Logic>(str); |
| | | if (logic.userLogicId != "") |
| | | { |
| | | //更新云端唯一自动化id; |
| | | Logic.currlogic.userLogicId = logic.userLogicId; |
| | | } |
| | | else |
| | | var logic = userLogicIdList[i]; |
| | | if (string.IsNullOrEmpty(logic.userLogicId)) |
| | | { |
| | | //自己看的所以不需要支持中英文 |
| | | new LogicView.TipPopView().FlashingBox("没有返回云端唯一自动化id"); |
| | | } |
| | | |
| | | //更新云端唯一自动化id; |
| | | Logic.currlogic.userLogicId = logic.userLogicId; |
| | | } |
| | | |
| | | Logic.LogicList.Add(Logic.currlogic); |
| | | LogicMethod.CurrLogicMethod.RemoveAllView(); |
| | | LogicMethod.Current.RemoveAllView(); |
| | | MainView.MainShow(); |
| | | } |
| | | else if (responsePackNew != null && responsePackNew.Code == "14005") |
| | | { |
| | | new LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.gatewayNotOnline)); |
| | | } |
| | | else |
| | | { |
| | | new LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.saveFail)); |
| | | } |
| | | }); |
| | | } |
| | |
| | | try |
| | | { |
| | | //发送修改逻辑命令; |
| | | responsePackNew = Send.UpdateLogic(Logic.currlogic); |
| | | r = Send.Current.UpdateLogic(Logic.currlogic, true); |
| | | |
| | | } |
| | | catch { } |
| | |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | loading.Hide(); |
| | | if (responsePackNew != null && responsePackNew.Code == "0") |
| | | if (r != null) |
| | | { |
| | | LogicMethod.CurrLogicMethod.RemoveAllView(); |
| | | LogicMethod.Current.RemoveAllView(); |
| | | MainView.MainShow(); |
| | | } |
| | | else if (responsePackNew != null && responsePackNew.Code == "14005") |
| | | { |
| | | new LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.gatewayNotOnline)); |
| | | } |
| | | else |
| | | { |
| | | new LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.saveFail)); |
| | | } |
| | | |
| | | }); |
| | | } |
| | | |
| | | |
| | | |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | |
| | | public void AddDic(string keyValue, string comparator,string value,string data_type) |
| | | { |
| | | Input input = new Input(); |
| | | input.sid = LogicMethod.CurrLogicMethod.NewSid(); |
| | | input.sid = LogicMethod.Current.NewSid(); |
| | | input.condition_type = "6"; |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "key", keyValue); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "comparator", comparator); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "data_type", data_type); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "value", value); |
| | | LogicMethod.Current.dictionary(dic, "key", keyValue); |
| | | LogicMethod.Current.dictionary(dic, "comparator", comparator); |
| | | LogicMethod.Current.dictionary(dic, "data_type", data_type); |
| | | LogicMethod.Current.dictionary(dic, "value", value); |
| | | input.condition.Add(dic); |
| | | AddCondition(input, keyValue, comparator); |
| | | } |
| | |
| | | Logic.currlogic.input.Add(input); |
| | | } |
| | | |
| | | LogicMethod.CurrLogicMethod.RemoveAllView(); |
| | | LogicMethod.Current.RemoveAllView(); |
| | | AddLogic addLogic = new AddLogic(); |
| | | MainPage.BasePageView.AddChidren(addLogic); |
| | | addLogic.Show(); |
| | |
| | | /// </summary> |
| | | /// <param name="frame">显示在哪个界面的父控件</param> |
| | | /// <param name="list">显示数据源</param> |
| | | /// <param name="stateList">之前状态数据源</param> |
| | | /// <param name="titleText">标题</param> |
| | | /// <param name="action">返回值索引值</param> |
| | | public void FrameOrVv(FrameLayout frame, List<string> list, List<string> stateList, int titleText, Action<int> action) |
| | | public void FrameOrVv(FrameLayout frame, List<string> list, List<string> stateList, string titleText, Action<int> action,bool isIcon=true) |
| | | { |
| | | |
| | | int line = 0; |
| | |
| | | frame.AddChidren(frameLayout); |
| | | |
| | | LogicView.DateView view = new LogicView.DateView(); |
| | | view.btnTitle.TextID = titleText; |
| | | view.btnTitle.Text = titleText; |
| | | view.FLayoutView(frameLayout, line); |
| | | view.btnCancel.MouseUpEventHandler += (sender, e) => |
| | | { |
| | |
| | | verticalRefresh.EndHeaderRefreshing(); |
| | | }; |
| | | |
| | | if (list.Count == 0) |
| | | if (list.Count == 0&&isIcon) |
| | | { |
| | | Button btnTipNot = new Button |
| | | { |
| | |
| | | verticalRefresh.AddChidren(checkView.FLayoutView()); |
| | | } |
| | | |
| | | if (stateList.Contains(strName)) |
| | | { |
| | | checkView.btnCheckIcon.IsSelected = true; |
| | | } |
| | | checkView.btnText.Text = strName; |
| | | checkView.btnClick.Tag = i;//标记 |
| | | |
| | | if (stateList.Contains(strName)) |
| | | { |
| | | //checkView.btnCheckIcon.IsSelected = true; |
| | | |
| | | checkBtn.IsSelected = false; |
| | | checkView.btnCheckIcon.IsSelected = true; |
| | | checkBtn = checkView.btnCheckIcon; |
| | | checkBtn.Tag = checkView.btnClick.Tag.ToString(); |
| | | } |
| | | //点击事件 |
| | | checkView.btnClick.MouseUpEventHandler += (sender1, e1) => |
| | | { |
| | |
| | | BackgroundColor = CSS.CSS_Color.viewMiddle, |
| | | }; |
| | | this.AddChidren(viewLayout); |
| | | var securityList = LogicMethod.CurrLogicMethod.GetSecurityList(); |
| | | var securityList = LogicMethod.Current.GetSecurityList(); |
| | | for (int i = 0; i < securityList.Count; i++) |
| | | { |
| | | var security = securityList[i]; |
| | |
| | | outputDevice.sid = sid; |
| | | outputDevice.status = new List<Dictionary<string, string>> { new Dictionary<string, string> { { "key", "security" }, { "value", selecttionMode } } }; |
| | | AddOutput(outputDevice, true); |
| | | LogicMethod.CurrLogicMethod.RemoveAllView(); |
| | | LogicMethod.Current.RemoveAllView(); |
| | | AddLogic addLogic = new AddLogic(); |
| | | MainPage.BasePageView.AddChidren(addLogic); |
| | | addLogic.Show(); |
| | |
| | | |
| | | namespace HDL_ON.UI.UI2.Intelligence.Automation |
| | | { |
| | | public class Send |
| | | { |
| | | |
| | | /// <summary> |
| | | /// 调用获取住宅子账号列表 |
| | | /// </summary> |
| | | public static List<ResidenceMemberInfo> GetResidenceMemberAccount() |
| | | public class Send |
| | | { |
| | | |
| | | var responePack = new HttpServerRequest().GetResidenceMemberAccount(); |
| | | if (responePack.Code == StateCode.SUCCESS) |
| | | { |
| | | return Newtonsoft.Json.JsonConvert.DeserializeObject<List<ResidenceMemberInfo>>(responePack.Data.ToString()); |
| | | } |
| | | //失败 |
| | | else |
| | | { |
| | | //提示 |
| | | IMessageCommon.Current.ShowErrorInfoAlter(responePack.Code); |
| | | } |
| | | return new List<ResidenceMemberInfo>(); |
| | | } |
| | | /// <summary> |
| | | /// 获取逻辑ID列表 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static ResponsePackNew GetLogicIdList() |
| | | { |
| | | var jObject = new JObject { { "homeId", LogicMethod.CurrLogicMethod.HomeId } }; |
| | | var responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_List); |
| | | //如果是token过期则刷新token |
| | | if (responsePackNew.Code == StateCode.TOKEN_EXPIRED) |
| | | { |
| | | RefreshToken(); |
| | | GetLogicIdList(); |
| | | } |
| | | return responsePackNew; |
| | | } |
| | | /// <summary> |
| | | /// 获取逻辑 |
| | | /// </summary> |
| | | /// <param name="listIdList">逻辑ID列表</param> |
| | | /// <returns></returns> |
| | | public static ResponsePackNew GetLogic(List<string> listIdList) |
| | | { |
| | | var jArray = new JArray { }; |
| | | for (int i = 0; i < listIdList.Count; i++) |
| | | { |
| | | jArray.Add(listIdList[i]); |
| | | } |
| | | var jObject = new JObject { { "userLogicIds", jArray } }; |
| | | var responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_Info); |
| | | //如果是token过期则刷新token |
| | | if (responsePackNew.Code == StateCode.TOKEN_EXPIRED) |
| | | { |
| | | RefreshToken(); |
| | | GetLogic(listIdList); |
| | | } |
| | | return responsePackNew; |
| | | } |
| | | /// <summary> |
| | | /// 添加自动化命令 |
| | | /// </summary> |
| | | /// <param name="logic"></param> |
| | | /// <returns></returns> |
| | | public static ResponsePackNew AddLogic(Logic logic) |
| | | { |
| | | ResponsePackNew responsePackNew = null; |
| | | try |
| | | { |
| | | |
| | | var cycleJObject = new JObject { }; |
| | | var cyclevaluejArray = new JArray { }; |
| | | cycleJObject.Add("type", logic.cycle.type); |
| | | foreach (var dictionary in logic.cycle.value) |
| | | private static Send s_Current = null; |
| | | public static Send Current |
| | | { |
| | | cyclevaluejArray.Add(dictionary); |
| | | } |
| | | cycleJObject.Add("value", cyclevaluejArray); |
| | | |
| | | var inputArray = new JArray { }; |
| | | foreach (var dictionary in logic.input) |
| | | { |
| | | var inputTypeJOb = new JObject { }; |
| | | inputTypeJOb.Add("sid", dictionary.sid); |
| | | inputTypeJOb.Add("condition_type", dictionary.condition_type); |
| | | |
| | | var conditionArray = new JArray { }; |
| | | foreach (var dic in dictionary.condition) |
| | | { |
| | | var conditionJOb = new JObject { }; |
| | | conditionJOb.Add("key", dic["key"]); |
| | | conditionJOb.Add("comparator", dic["comparator"]); |
| | | conditionJOb.Add("data_type", dic["data_type"]); |
| | | conditionJOb.Add("value", dic["value"]); |
| | | conditionArray.Add(conditionJOb); |
| | | } |
| | | inputTypeJOb.Add("condition", conditionArray); |
| | | if (dictionary.condition_type == "8") |
| | | { |
| | | ///地理围栏 |
| | | var geo_fencejob = new JObject(); |
| | | geo_fencejob.Add("longitude", dictionary.geo_fence.longitude); |
| | | geo_fencejob.Add("latitude", dictionary.geo_fence.latitude); |
| | | geo_fencejob.Add("radius", dictionary.geo_fence.radius); |
| | | inputTypeJOb.Add("geo_fence", geo_fencejob); |
| | | } |
| | | inputArray.Add(inputTypeJOb); |
| | | } |
| | | |
| | | var outputArray = new JArray { }; |
| | | foreach (var dictionary in logic.output) |
| | | { |
| | | var outputTypeJOb = new JObject { }; |
| | | outputTypeJOb.Add("sid", dictionary.sid); |
| | | outputTypeJOb.Add("delay", dictionary.delay); |
| | | outputTypeJOb.Add("target_type", dictionary.target_type); |
| | | var statusArray = new JArray { }; |
| | | foreach (var dic in dictionary.status) |
| | | { |
| | | var statusJOb = new JObject { }; |
| | | statusJOb.Add("key", dic["key"]); |
| | | statusJOb.Add("value", dic["value"]); |
| | | statusArray.Add(statusJOb); |
| | | } |
| | | outputTypeJOb.Add("status", statusArray); |
| | | outputArray.Add(outputTypeJOb); |
| | | } |
| | | |
| | | |
| | | var noticeConfigJObject = new JObject(); |
| | | noticeConfigJObject.Add("enable", logic.noticeConfig.enable); |
| | | noticeConfigJObject.Add("noticeContent", logic.noticeConfig.noticeContent); |
| | | |
| | | var pushConfigsArray = new JArray { }; |
| | | if (logic.pushConfigs.Count > 0) |
| | | { // 推送文本 |
| | | foreach (var pushConfig in logic.pushConfigs) |
| | | { |
| | | |
| | | var pushConfigJob = new JObject { }; |
| | | pushConfigJob.Add("pushMethod", pushConfig.pushMethod); |
| | | var accountArray = new JArray { }; |
| | | foreach (var account in pushConfig.pushTarget) |
| | | get |
| | | { |
| | | accountArray.Add(account); |
| | | if (s_Current == null) |
| | | { |
| | | s_Current = new Send(); |
| | | } |
| | | return s_Current; |
| | | } |
| | | pushConfigJob.Add("pushTarget", accountArray); |
| | | pushConfigsArray.Add(pushConfigJob); |
| | | } |
| | | } |
| | | |
| | | var logicjArray = new JArray { }; |
| | | var logicIfon = new JObject { }; |
| | | logicIfon.Add("sid", logic.sid); |
| | | logicIfon.Add("gatewayId", LogicMethod.CurrLogicMethod.GatewayId); |
| | | logicIfon.Add("tag", logic.tag); |
| | | logicIfon.Add("name", logic.name); |
| | | logicIfon.Add("relation", logic.relation); |
| | | logicIfon.Add("enable", logic.enable); |
| | | logicIfon.Add("cycle", cycleJObject); |
| | | logicIfon.Add("input", inputArray); |
| | | logicIfon.Add("output", outputArray); |
| | | logicIfon.Add("noticeConfig", noticeConfigJObject); |
| | | logicIfon.Add("pushConfigs", pushConfigsArray); |
| | | logicjArray.Add(logicIfon); |
| | | //string str = logicIfon.ToString(); |
| | | var jObject = new JObject { { "homeId", LogicMethod.CurrLogicMethod.HomeId }, { "logics", logicjArray } }; |
| | | responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_Add, 5); |
| | | //如果是token过期则刷新token |
| | | if (responsePackNew.Code == StateCode.TOKEN_EXPIRED) |
| | | public List<Face> faceList = new List<Face>(); |
| | | /// <summary> |
| | | /// 调用获取住宅子账号列表 |
| | | /// </summary> |
| | | public List<ResidenceMemberInfo> GetResidenceMemberAccount() |
| | | { |
| | | RefreshToken(); |
| | | AddLogic(logic); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | var dd = e.Message; |
| | | } |
| | | return responsePackNew; |
| | | } |
| | | /// <summary> |
| | | /// 编辑更新逻辑 |
| | | /// </summary> |
| | | /// <param name="logic"></param> |
| | | /// <returns></returns> |
| | | public static ResponsePackNew UpdateLogic(Logic logic) |
| | | { |
| | | ResponsePackNew responsePackNew = null; |
| | | try |
| | | { |
| | | var cycleJObject = new JObject { }; |
| | | var cyclevaluejArray = new JArray { }; |
| | | cycleJObject.Add("type", logic.cycle.type); |
| | | foreach (var dictionary in logic.cycle.value) |
| | | { |
| | | cyclevaluejArray.Add(dictionary); |
| | | } |
| | | cycleJObject.Add("value", cyclevaluejArray); |
| | | |
| | | var inputArray = new JArray { }; |
| | | foreach (var dictionary in logic.input) |
| | | { |
| | | var inputTypeJOb = new JObject { }; |
| | | inputTypeJOb.Add("sid", dictionary.sid); |
| | | inputTypeJOb.Add("condition_type", dictionary.condition_type); |
| | | |
| | | var conditionArray = new JArray { }; |
| | | foreach (var dic in dictionary.condition) |
| | | { |
| | | |
| | | var conditionJOb = new JObject { }; |
| | | conditionJOb.Add("key", dic["key"]); |
| | | var c1 = ""; |
| | | dic.TryGetValue("comparator", out c1); |
| | | c1 = string.IsNullOrEmpty(c1) ? "" : c1; |
| | | conditionJOb.TryAdd("comparator", c1); |
| | | conditionJOb.Add("data_type", dic["data_type"]); |
| | | conditionJOb.Add("value", dic["value"]); |
| | | conditionArray.Add(conditionJOb); |
| | | if (dictionary.condition_type == "8") |
| | | var responePack = new HttpServerRequest().GetResidenceMemberAccount(); |
| | | if (responePack.Code == StateCode.SUCCESS) |
| | | { |
| | | ///地理围栏 |
| | | var geo_fencejob = new JObject(); |
| | | geo_fencejob.Add("longitude", dictionary.geo_fence.longitude); |
| | | geo_fencejob.Add("latitude", dictionary.geo_fence.latitude); |
| | | geo_fencejob.Add("radius", dictionary.geo_fence.radius); |
| | | inputTypeJOb.Add("geo_fence", geo_fencejob); |
| | | return Newtonsoft.Json.JsonConvert.DeserializeObject<List<ResidenceMemberInfo>>(responePack.Data.ToString()); |
| | | } |
| | | } |
| | | inputTypeJOb.Add("condition", conditionArray); |
| | | inputArray.Add(inputTypeJOb); |
| | | } |
| | | |
| | | var outputArray = new JArray { }; |
| | | foreach (var dictionary in logic.output) |
| | | { |
| | | var outputTypeJOb = new JObject { }; |
| | | outputTypeJOb.Add("sid", dictionary.sid); |
| | | outputTypeJOb.Add("delay", dictionary.delay); |
| | | outputTypeJOb.Add("target_type", dictionary.target_type); |
| | | var statusArray = new JArray { }; |
| | | foreach (var dic in dictionary.status) |
| | | { |
| | | var statusJOb = new JObject { }; |
| | | statusJOb.Add("key", dic["key"]); |
| | | statusJOb.Add("value", dic["value"]); |
| | | statusArray.Add(statusJOb); |
| | | } |
| | | outputTypeJOb.Add("status", statusArray); |
| | | outputArray.Add(outputTypeJOb); |
| | | } |
| | | |
| | | var noticeConfigJObject = new JObject(); |
| | | noticeConfigJObject.Add("enable", logic.noticeConfig.enable); |
| | | noticeConfigJObject.Add("noticeContent", logic.noticeConfig.noticeContent); |
| | | |
| | | var pushConfigsArray = new JArray { }; |
| | | if (logic.pushConfigs.Count > 0) |
| | | { |
| | | // 推送文本 |
| | | foreach (var pushConfig in logic.pushConfigs) |
| | | { |
| | | |
| | | var pushConfigJob = new JObject { }; |
| | | pushConfigJob.Add("pushMethod", pushConfig.pushMethod); |
| | | var accountArray = new JArray { }; |
| | | foreach (var account in pushConfig.pushTarget) |
| | | //失败 |
| | | else |
| | | { |
| | | accountArray.Add(account); |
| | | //提示 |
| | | IMessageCommon.Current.ShowErrorInfoAlter(responePack.Code); |
| | | } |
| | | pushConfigJob.Add("pushTarget", accountArray); |
| | | pushConfigsArray.Add(pushConfigJob); |
| | | } |
| | | return new List<ResidenceMemberInfo>(); |
| | | } |
| | | |
| | | var logicjArray = new JArray { }; |
| | | var logicIfon = new JObject { }; |
| | | logicIfon.Add("userLogicId", logic.userLogicId); |
| | | logicIfon.Add("sid", logic.sid); |
| | | logicIfon.Add("gatewayId", LogicMethod.CurrLogicMethod.GatewayId); |
| | | logicIfon.Add("tag", logic.tag); |
| | | logicIfon.Add("name", logic.name); |
| | | logicIfon.Add("relation", logic.relation); |
| | | logicIfon.Add("enable", logic.enable); |
| | | logicIfon.Add("cycle", cycleJObject); |
| | | logicIfon.Add("input", inputArray); |
| | | logicIfon.Add("output", outputArray); |
| | | logicIfon.Add("noticeConfig", noticeConfigJObject); |
| | | logicIfon.Add("pushConfigs", pushConfigsArray); |
| | | |
| | | logicjArray.Add(logicIfon); |
| | | var jObject = new JObject { { "homeId", LogicMethod.CurrLogicMethod.HomeId }, { "logics", logicjArray } }; |
| | | |
| | | string str = jObject.ToString(); |
| | | responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_Update, 5); |
| | | //如果是token过期则刷新token |
| | | if (responsePackNew.Code == StateCode.TOKEN_EXPIRED) |
| | | /// <summary> |
| | | /// 获取逻辑ID列表 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public ResponsePackNew GetLogicIdList(bool isTip = false) |
| | | { |
| | | RefreshToken(); |
| | | UpdateLogic(logic); |
| | | var jObject = new JObject { { "homeId", LogicMethod.Current.HomeId } }; |
| | | var responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_List, "获取逻辑ID列表"); |
| | | //如果是token过期则刷新token |
| | | if (responsePackNew.Code == StateCode.TOKEN_EXPIRED) |
| | | { |
| | | RefreshToken(); |
| | | GetLogicIdList(isTip); |
| | | } |
| | | if (Check(responsePackNew, isTip) == false) |
| | | { |
| | | return null; |
| | | } |
| | | return responsePackNew; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | var dd = e.Message; |
| | | } |
| | | return responsePackNew; |
| | | } |
| | | /// <summary> |
| | | /// 删除逻辑 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static ResponsePackNew DelLogic(Logic logic) |
| | | { |
| | | var jArray = new JArray { }; |
| | | jArray.Add(logic.userLogicId); |
| | | var jObject = new JObject { { "userLogicIds", jArray } }; |
| | | var responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_Delete); |
| | | //如果是token过期则刷新token |
| | | if (responsePackNew.Code == StateCode.TOKEN_EXPIRED) |
| | | { |
| | | RefreshToken(); |
| | | DelLogic(logic); |
| | | } |
| | | return responsePackNew; |
| | | } |
| | | /// <summary> |
| | | /// 逻辑开关 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static ResponsePackNew SwitchLogic(Logic logic) |
| | | { |
| | | var jArray = new JArray { }; |
| | | var job = new JObject { { "userLogicId", logic.userLogicId }, { "enable", logic.enable } }; |
| | | jArray.Add(job); |
| | | var jObject = new JObject { { "logics", jArray } }; |
| | | var responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_Enable); |
| | | //如果是token过期则刷新token |
| | | if (responsePackNew.Code == StateCode.TOKEN_EXPIRED) |
| | | { |
| | | RefreshToken(); |
| | | SwitchLogic(logic); |
| | | } |
| | | return responsePackNew; |
| | | } |
| | | /// <summary> |
| | | /// 自动化地理围栏状态上报 |
| | | /// </summary> |
| | | /// <param name="userLogicId">自动化云端id<备注:logicSid与userLogicId 不能同时为空></param> |
| | | /// <param name="logicSid">自动化sid<备注:logicSid与userLogicId 不能同时为空></param> |
| | | /// <param name="direction">arrive:到达(进入) leave:离开</param> |
| | | /// <returns></returns> |
| | | public static bool GeoFenceStateReport(string userLogicId, string logicSid, string direction) |
| | | { |
| | | var jObject = new JObject(); |
| | | jObject.Add("homeId", LogicMethod.CurrLogicMethod.HomeId); |
| | | jObject.Add("userLogicId", userLogicId); |
| | | jObject.Add("sid", logicSid); |
| | | jObject.Add("direction", direction); |
| | | var responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_GeoFenceStateReport); |
| | | //如果是token过期则刷新token |
| | | if (responsePackNew.Code == StateCode.TOKEN_EXPIRED) |
| | | { |
| | | RefreshToken(); |
| | | GeoFenceStateReport(userLogicId, logicSid, direction); |
| | | } |
| | | if (responsePackNew.Code == "0") |
| | | { |
| | | //成功 |
| | | return true; |
| | | } |
| | | //失败 |
| | | return false; |
| | | } |
| | | /// <summary> |
| | | /// 获取自动化详情 |
| | | /// </summary> |
| | | /// <param name="listIdList">自动化ID列表</param> |
| | | /// <returns></returns> |
| | | public ResponsePackNew GetLogic(List<string> listIdList, bool isTip = false) |
| | | { |
| | | var jArray = new JArray { }; |
| | | for (int i = 0; i < listIdList.Count; i++) |
| | | { |
| | | jArray.Add(listIdList[i]); |
| | | } |
| | | var jObject = new JObject { { "userLogicIds", jArray } }; |
| | | var responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_Info, "获取自动化详情"); |
| | | //如果是token过期则刷新token |
| | | if (responsePackNew.Code == StateCode.TOKEN_EXPIRED) |
| | | { |
| | | RefreshToken(); |
| | | GetLogic(listIdList,isTip); |
| | | } |
| | | if (Check(responsePackNew, isTip) == false) |
| | | { |
| | | return null; |
| | | } |
| | | return responsePackNew; |
| | | } |
| | | /// <summary> |
| | | /// 添加自动化命令 |
| | | /// </summary> |
| | | /// <param name="logic"></param> |
| | | /// <returns></returns> |
| | | public ResponsePackNew AddLogic(Logic logic,bool isTip) |
| | | { |
| | | ResponsePackNew responsePackNew = null; |
| | | try |
| | | { |
| | | |
| | | /// <summary> |
| | | ///请求服务器(与住宅有关:例如;homeId) |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static ResponsePackNew RequestServerhomeId(object o, string api_Url, int mTimeout = 3) |
| | | { |
| | | var requestJson = HttpUtil.GetSignRequestJson(o); |
| | | return HttpUtil.RequestHttpsPostFroHome(api_Url, requestJson, mTimeout); |
| | | var cycleJObject = new JObject { }; |
| | | var cyclevaluejArray = new JArray { }; |
| | | cycleJObject.Add("type", logic.cycle.type); |
| | | foreach (var dictionary in logic.cycle.value) |
| | | { |
| | | cyclevaluejArray.Add(dictionary); |
| | | } |
| | | cycleJObject.Add("value", cyclevaluejArray); |
| | | |
| | | var inputArray = new JArray { }; |
| | | foreach (var dictionary in logic.input) |
| | | { |
| | | var inputTypeJOb = new JObject { }; |
| | | inputTypeJOb.Add("sid", dictionary.sid); |
| | | inputTypeJOb.Add("condition_type", dictionary.condition_type); |
| | | if (dictionary.condition_type=="9") { |
| | | inputTypeJOb.Add("identifier", dictionary.identifier); |
| | | } |
| | | var conditionArray = new JArray { }; |
| | | foreach (var dic in dictionary.condition) |
| | | { |
| | | var conditionJOb = new JObject { }; |
| | | conditionJOb.Add("key", dic["key"]); |
| | | conditionJOb.Add("comparator", dic["comparator"]); |
| | | conditionJOb.Add("data_type", dic["data_type"]); |
| | | conditionJOb.Add("value", dic["value"]); |
| | | conditionArray.Add(conditionJOb); |
| | | } |
| | | inputTypeJOb.Add("condition", conditionArray); |
| | | if (dictionary.condition_type == "8") |
| | | { |
| | | ///地理围栏 |
| | | var geo_fencejob = new JObject(); |
| | | geo_fencejob.Add("longitude", dictionary.geo_fence.longitude); |
| | | geo_fencejob.Add("latitude", dictionary.geo_fence.latitude); |
| | | geo_fencejob.Add("radius", dictionary.geo_fence.radius); |
| | | inputTypeJOb.Add("geo_fence", geo_fencejob); |
| | | } |
| | | inputArray.Add(inputTypeJOb); |
| | | } |
| | | |
| | | var outputArray = new JArray { }; |
| | | foreach (var dictionary in logic.output) |
| | | { |
| | | var outputTypeJOb = new JObject { }; |
| | | outputTypeJOb.Add("sid", dictionary.sid); |
| | | outputTypeJOb.Add("delay", dictionary.delay); |
| | | outputTypeJOb.Add("target_type", dictionary.target_type); |
| | | var statusArray = new JArray { }; |
| | | foreach (var dic in dictionary.status) |
| | | { |
| | | var statusJOb = new JObject { }; |
| | | statusJOb.Add("key", dic["key"]); |
| | | statusJOb.Add("value", dic["value"]); |
| | | statusArray.Add(statusJOb); |
| | | } |
| | | outputTypeJOb.Add("status", statusArray); |
| | | outputArray.Add(outputTypeJOb); |
| | | } |
| | | |
| | | |
| | | var noticeConfigJObject = new JObject(); |
| | | noticeConfigJObject.Add("enable", logic.noticeConfig.enable); |
| | | noticeConfigJObject.Add("noticeContent", logic.noticeConfig.noticeContent); |
| | | |
| | | var pushConfigsArray = new JArray { }; |
| | | if (logic.pushConfigs.Count > 0) |
| | | { // 推送文本 |
| | | foreach (var pushConfig in logic.pushConfigs) |
| | | { |
| | | |
| | | var pushConfigJob = new JObject { }; |
| | | pushConfigJob.Add("pushMethod", pushConfig.pushMethod); |
| | | var accountArray = new JArray { }; |
| | | foreach (var account in pushConfig.pushTarget) |
| | | { |
| | | accountArray.Add(account); |
| | | } |
| | | pushConfigJob.Add("pushTarget", accountArray); |
| | | pushConfigsArray.Add(pushConfigJob); |
| | | } |
| | | } |
| | | |
| | | var logicjArray = new JArray { }; |
| | | var logicIfon = new JObject { }; |
| | | logicIfon.Add("sid", logic.sid); |
| | | logicIfon.Add("gatewayId", LogicMethod.Current.GatewayId); |
| | | logicIfon.Add("tag", logic.tag); |
| | | logicIfon.Add("name", logic.name); |
| | | logicIfon.Add("relation", logic.relation); |
| | | logicIfon.Add("enable", logic.enable); |
| | | logicIfon.Add("cycle", cycleJObject); |
| | | logicIfon.Add("input", inputArray); |
| | | logicIfon.Add("output", outputArray); |
| | | logicIfon.Add("noticeConfig", noticeConfigJObject); |
| | | logicIfon.Add("pushConfigs", pushConfigsArray); |
| | | logicjArray.Add(logicIfon); |
| | | var jObject = new JObject { { "homeId", LogicMethod.Current.HomeId }, { "logics", logicjArray } }; |
| | | responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_Add, "添加自动化", 5); |
| | | //如果是token过期则刷新token |
| | | if (responsePackNew.Code == StateCode.TOKEN_EXPIRED) |
| | | { |
| | | RefreshToken(); |
| | | AddLogic(logic,isTip); |
| | | } |
| | | if (Check(responsePackNew, isTip) == false) |
| | | { |
| | | return null; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | var dd = e.Message; |
| | | } |
| | | return responsePackNew; |
| | | } |
| | | /// <summary> |
| | | /// 编辑更新自动化 |
| | | /// </summary> |
| | | /// <param name="logic"></param> |
| | | /// <returns></returns> |
| | | public ResponsePackNew UpdateLogic(Logic logic,bool isTip) |
| | | { |
| | | ResponsePackNew responsePackNew = null; |
| | | try |
| | | { |
| | | var cycleJObject = new JObject { }; |
| | | var cyclevaluejArray = new JArray { }; |
| | | cycleJObject.Add("type", logic.cycle.type); |
| | | foreach (var dictionary in logic.cycle.value) |
| | | { |
| | | cyclevaluejArray.Add(dictionary); |
| | | } |
| | | cycleJObject.Add("value", cyclevaluejArray); |
| | | |
| | | var inputArray = new JArray { }; |
| | | foreach (var dictionary in logic.input) |
| | | { |
| | | var inputTypeJOb = new JObject { }; |
| | | inputTypeJOb.Add("sid", dictionary.sid); |
| | | inputTypeJOb.Add("condition_type", dictionary.condition_type); |
| | | |
| | | var conditionArray = new JArray { }; |
| | | foreach (var dic in dictionary.condition) |
| | | { |
| | | |
| | | var conditionJOb = new JObject { }; |
| | | conditionJOb.Add("key", dic["key"]); |
| | | var c1 = ""; |
| | | dic.TryGetValue("comparator", out c1); |
| | | c1 = string.IsNullOrEmpty(c1) ? "" : c1; |
| | | conditionJOb.TryAdd("comparator", c1); |
| | | conditionJOb.Add("data_type", dic["data_type"]); |
| | | conditionJOb.Add("value", dic["value"]); |
| | | conditionArray.Add(conditionJOb); |
| | | if (dictionary.condition_type == "8") |
| | | { |
| | | ///地理围栏 |
| | | var geo_fencejob = new JObject(); |
| | | geo_fencejob.Add("longitude", dictionary.geo_fence.longitude); |
| | | geo_fencejob.Add("latitude", dictionary.geo_fence.latitude); |
| | | geo_fencejob.Add("radius", dictionary.geo_fence.radius); |
| | | inputTypeJOb.Add("geo_fence", geo_fencejob); |
| | | } |
| | | } |
| | | inputTypeJOb.Add("condition", conditionArray); |
| | | inputArray.Add(inputTypeJOb); |
| | | } |
| | | |
| | | var outputArray = new JArray { }; |
| | | foreach (var dictionary in logic.output) |
| | | { |
| | | var outputTypeJOb = new JObject { }; |
| | | outputTypeJOb.Add("sid", dictionary.sid); |
| | | outputTypeJOb.Add("delay", dictionary.delay); |
| | | outputTypeJOb.Add("target_type", dictionary.target_type); |
| | | var statusArray = new JArray { }; |
| | | foreach (var dic in dictionary.status) |
| | | { |
| | | var statusJOb = new JObject { }; |
| | | statusJOb.Add("key", dic["key"]); |
| | | statusJOb.Add("value", dic["value"]); |
| | | statusArray.Add(statusJOb); |
| | | } |
| | | outputTypeJOb.Add("status", statusArray); |
| | | outputArray.Add(outputTypeJOb); |
| | | } |
| | | |
| | | var noticeConfigJObject = new JObject(); |
| | | noticeConfigJObject.Add("enable", logic.noticeConfig.enable); |
| | | noticeConfigJObject.Add("noticeContent", logic.noticeConfig.noticeContent); |
| | | |
| | | var pushConfigsArray = new JArray { }; |
| | | if (logic.pushConfigs.Count > 0) |
| | | { |
| | | // 推送文本 |
| | | foreach (var pushConfig in logic.pushConfigs) |
| | | { |
| | | |
| | | var pushConfigJob = new JObject { }; |
| | | pushConfigJob.Add("pushMethod", pushConfig.pushMethod); |
| | | var accountArray = new JArray { }; |
| | | foreach (var account in pushConfig.pushTarget) |
| | | { |
| | | accountArray.Add(account); |
| | | } |
| | | pushConfigJob.Add("pushTarget", accountArray); |
| | | pushConfigsArray.Add(pushConfigJob); |
| | | } |
| | | } |
| | | |
| | | var logicjArray = new JArray { }; |
| | | var logicIfon = new JObject { }; |
| | | logicIfon.Add("userLogicId", logic.userLogicId); |
| | | logicIfon.Add("sid", logic.sid); |
| | | logicIfon.Add("gatewayId", LogicMethod.Current.GatewayId); |
| | | logicIfon.Add("tag", logic.tag); |
| | | logicIfon.Add("name", logic.name); |
| | | logicIfon.Add("relation", logic.relation); |
| | | logicIfon.Add("enable", logic.enable); |
| | | logicIfon.Add("cycle", cycleJObject); |
| | | logicIfon.Add("input", inputArray); |
| | | logicIfon.Add("output", outputArray); |
| | | logicIfon.Add("noticeConfig", noticeConfigJObject); |
| | | logicIfon.Add("pushConfigs", pushConfigsArray); |
| | | |
| | | logicjArray.Add(logicIfon); |
| | | var jObject = new JObject { { "homeId", LogicMethod.Current.HomeId }, { "logics", logicjArray } }; |
| | | |
| | | string str = jObject.ToString(); |
| | | responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_Update, "编辑更新自动化", 5); |
| | | //如果是token过期则刷新token |
| | | if (responsePackNew.Code == StateCode.TOKEN_EXPIRED) |
| | | { |
| | | RefreshToken(); |
| | | UpdateLogic(logic, isTip); |
| | | } |
| | | if (Check(responsePackNew, isTip) == false) |
| | | { |
| | | return null; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return null; |
| | | } |
| | | return responsePackNew; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 删除自动化 |
| | | /// </summary> |
| | | /// <param name="logic">当前对象</param> |
| | | /// <param name="isTip">是否要提示</param> |
| | | /// <returns></returns> |
| | | public ResponsePackNew DelLogic(Logic logic,bool isTip) |
| | | { |
| | | var jArray = new JArray { }; |
| | | jArray.Add(logic.userLogicId); |
| | | var jObject = new JObject { { "userLogicIds", jArray } }; |
| | | var responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_Delete, "删除自动化"); |
| | | //如果是token过期则刷新token |
| | | if (responsePackNew.Code == StateCode.TOKEN_EXPIRED) |
| | | { |
| | | RefreshToken(); |
| | | DelLogic(logic, isTip); |
| | | } |
| | | if (Check(responsePackNew, isTip) == false) |
| | | { |
| | | return null; |
| | | } |
| | | return responsePackNew; |
| | | } |
| | | /// <summary> |
| | | /// 自动化使能 |
| | | /// </summary> |
| | | /// <param name="logic">当前对象</param> |
| | | /// <param name="isTip">是否要提示</param> |
| | | /// <returns></returns> |
| | | public ResponsePackNew SwitchLogic(Logic logic,bool isTip=false) |
| | | { |
| | | var jArray = new JArray { }; |
| | | var job = new JObject { { "userLogicId", logic.userLogicId }, { "enable", logic.enable } }; |
| | | jArray.Add(job); |
| | | var jObject = new JObject { { "logics", jArray } }; |
| | | var responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_Enable, "自动化开关"); |
| | | //如果是token过期则刷新token |
| | | if (responsePackNew.Code == StateCode.TOKEN_EXPIRED) |
| | | { |
| | | RefreshToken(); |
| | | SwitchLogic(logic, isTip); |
| | | } |
| | | if (Check(responsePackNew, isTip) == false) |
| | | { |
| | | return null; |
| | | } |
| | | return responsePackNew; |
| | | } |
| | | /// <summary> |
| | | /// 自动化地理围栏状态上报 |
| | | /// </summary> |
| | | /// <param name="userLogicId">自动化云端id<备注:logicSid与userLogicId 不能同时为空></param> |
| | | /// <param name="logicSid">自动化sid<备注:logicSid与userLogicId 不能同时为空></param> |
| | | /// <param name="direction">arrive:到达(进入) leave:离开</param> |
| | | /// <returns></returns> |
| | | public bool GetFenceStateReport(string userLogicId, string logicSid, string direction) |
| | | { |
| | | var jObject = new JObject(); |
| | | jObject.Add("homeId", LogicMethod.Current.HomeId); |
| | | jObject.Add("userLogicId", userLogicId); |
| | | jObject.Add("sid", logicSid); |
| | | jObject.Add("direction", direction); |
| | | var responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_GeoFenceStateReport, "自动化地理围栏状态上报"); |
| | | //如果是token过期则刷新token |
| | | if (responsePackNew.Code == StateCode.TOKEN_EXPIRED) |
| | | { |
| | | RefreshToken(); |
| | | GetFenceStateReport(userLogicId, logicSid, direction); |
| | | } |
| | | if (responsePackNew.Code == "0") |
| | | { |
| | | //成功 |
| | | return true; |
| | | } |
| | | //失败 |
| | | return false; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取住宅已录入人脸信息(可视对讲人脸开门触发自动化配置用) |
| | | /// </summary> |
| | | /// <param name="deviceId">可视对讲设备id</param> |
| | | /// <returns></returns> |
| | | public List<Face> GetListHomeFace(string deviceId, bool isTip) |
| | | { |
| | | var jObject = new JObject(); |
| | | jObject.Add("homeId", LogicMethod.Current.HomeId); |
| | | jObject.Add("deviceId", deviceId); |
| | | var responsePackNew = RequestServerhomeId(jObject, NewAPI.Api_Post_GetListHomeFace, "获取住宅已录入人脸信息"); |
| | | //如果是token过期则刷新token |
| | | if (responsePackNew.Code == StateCode.TOKEN_EXPIRED) |
| | | { |
| | | RefreshToken(); |
| | | GetListHomeFace(deviceId, isTip); |
| | | } |
| | | if (Check(responsePackNew, isTip) == false) |
| | | { |
| | | return new List<Face>(); |
| | | } |
| | | var list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Face>>(responsePackNew.Data.ToString()); |
| | | if (list == null) |
| | | { |
| | | list = new List<Face>(); |
| | | } |
| | | faceList.Clear(); |
| | | faceList.AddRange(list); |
| | | return list; |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | ///请求服务器(与住宅有关:例如;homeId) |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public ResponsePackNew RequestServerhomeId(object o, string api_Url, string tag,int mTimeout = 3) |
| | | { |
| | | Log($"{DateTime.Now}->发送->{tag}", o.ToString()); |
| | | var requestJson = HttpUtil.GetSignRequestJson(o); |
| | | var r= HttpUtil.RequestHttpsPostFroHome(api_Url, requestJson, mTimeout); |
| | | Log($"{DateTime.Now}->回复->{tag}", Newtonsoft.Json.JsonConvert.SerializeObject(r)); |
| | | return r; |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 请求服务器 |
| | | /// </summary> |
| | | /// <param name="o">发送数据</param> |
| | | /// <param name="api_Url">请求地址(不是绝对地址)</param> |
| | | /// <param name="tag">标记</param> |
| | | /// <returns></returns> |
| | | public ResponsePackNew RequestServer(object o, string api_Url,string tag) |
| | | { |
| | | Log($"发送->{tag}", o.ToString()); |
| | | var requestJson = HttpUtil.GetSignRequestJson(o); |
| | | var r = HttpUtil.RequestHttpsPost(api_Url, requestJson); |
| | | Log($"回复->{tag}", Newtonsoft.Json.JsonConvert.SerializeObject(r)); |
| | | return r; |
| | | } |
| | | /// <summary> |
| | | /// 刷新Token |
| | | /// </summary> |
| | | public void RefreshToken() |
| | | { |
| | | IMessageCommon.Current.StartRefreshToken(); |
| | | } |
| | | /// <summary> |
| | | /// 检验数据是否合法的 |
| | | /// </summary> |
| | | /// <param name="r"></param> |
| | | /// <param name="isTip">是否要弹窗(默认是false不需要)</param> |
| | | /// <returns></returns> |
| | | public bool Check(ResponsePackNew r, bool isTip) |
| | | { |
| | | if (r.Code == "0" && r.Data != null && r.Data.ToString() != "") |
| | | { |
| | | return true; |
| | | } |
| | | if (r.Code != "0") |
| | | { |
| | | //失败时是否要提示 |
| | | if (isTip) |
| | | { |
| | | new LogicView.TipPopView().FlashingBox(r.message + $"({r.Code})"); |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | /// <summary> |
| | | /// 打印日志 |
| | | /// </summary> |
| | | /// <param name="tag">打印标记</param> |
| | | /// <param name="content">打印内容</param> |
| | | public void Log(string tag, string content) |
| | | { |
| | | #if DEBUG |
| | | Console.WriteLine(tag + $"\r\n数据内容->->{content}"); |
| | | #endif |
| | | } |
| | | |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 请求服务器 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static ResponsePackNew RequestServer(object o, string api_Url) |
| | | public class Face |
| | | { |
| | | var requestJson = HttpUtil.GetSignRequestJson(o); |
| | | return HttpUtil.RequestHttpsPost(api_Url, requestJson); |
| | | |
| | | /// <summary> |
| | | /// 用户名称 |
| | | /// </summary> |
| | | public string userName = string.Empty; |
| | | /// <summary> |
| | | /// 用户人脸id |
| | | /// </summary> |
| | | public string userId = string.Empty; |
| | | } |
| | | /// <summary> |
| | | /// 刷新Token |
| | | /// </summary> |
| | | public static void RefreshToken() |
| | | { |
| | | IMessageCommon.Current.StartRefreshToken(); |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | X = Application.GetRealWidth(40), |
| | | Gravity = Gravity.CenterVertical, |
| | | TextAlignment = TextAlignment.CenterRight, |
| | | Text =Logic.currlogic.name, |
| | | Text = Logic.currlogic.name, |
| | | }; |
| | | nameView.frameLayout.AddChidren(btnAutomationName); |
| | | |
| | |
| | | EventHandler<MouseEventArgs> editClick = (sender, e) => |
| | | { |
| | | List<string> list = new List<string>(); |
| | | foreach (var logic in Logic.LogicList) { |
| | | foreach (var logic in Logic.LogicList) |
| | | { |
| | | list.Add(logic.name); |
| | | } |
| | | |
| | | new LogicView.TipPopView().InputBox(StringId.editName, Logic.currlogic.name, StringId.nameNull, StringId.NameAlreadyExists, list, (logicName,view |
| | | new LogicView.TipPopView().InputBox(StringId.editName, Logic.currlogic.name, StringId.nameNull, StringId.NameAlreadyExists, list, (logicName, view |
| | | ) => |
| | | { |
| | | btnAutomationName.Text = logicName; |
| | | Logic.currlogic.name = logicName; |
| | | |
| | | },()=> { }); |
| | | }, () => { }); |
| | | }; |
| | | nameView.btnClick.MouseUpEventHandler += editClick; |
| | | btnAutomationName.MouseUpEventHandler += editClick; |
| | |
| | | try |
| | | { |
| | | //发送删除逻辑命令; |
| | | responsePackNew = Send.DelLogic(Logic.currlogic); |
| | | |
| | | responsePackNew = Send.Current.DelLogic(Logic.currlogic, true); |
| | | } |
| | | catch { } |
| | | finally |
| | |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | loading.Hide(); |
| | | if (responsePackNew != null && responsePackNew.Code == "0") |
| | | if (responsePackNew != null) |
| | | { |
| | | LogicMethod.CurrLogicMethod.RemoveAllView(); |
| | | LogicMethod.Current.RemoveAllView(); |
| | | Logic.LogicList.Remove(Logic.currlogic); |
| | | MainView.MainShow(); |
| | | //发送删除逻辑命令; |
| | | } |
| | | else if (responsePackNew != null && responsePackNew.Code == "14005") |
| | | { |
| | | new LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.gatewayNotOnline)); |
| | | } |
| | | else |
| | | { |
| | | new LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.delFail)); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | |
| | | |
| | | }); |
| | | |
| | | }; |
| | |
| | | if (edit) |
| | | { |
| | | //显示编辑之前的设备状态 |
| | | GetEditState(device, index, lightSwitchView.btnState, null, null, null); |
| | | GetEditDeviceState(device, index, lightSwitchView.btnState, null, null, null); |
| | | } |
| | | #endregion |
| | | } |
| | |
| | | if (edit) |
| | | { |
| | | //显示编辑之前的设备状态 |
| | | GetEditState(device, index, lightSwitchView.btnState, brightnessView.btnState, null, null); |
| | | GetEditDeviceState(device, index, lightSwitchView.btnState, brightnessView.btnState, null, null); |
| | | } |
| | | #endregion |
| | | } |
| | |
| | | if (edit) |
| | | { |
| | | //显示编辑之前的设备状态 |
| | | GetEditState(device, index, curtainSwitchView.btnState, null, null, null); |
| | | GetEditDeviceState(device, index, curtainSwitchView.btnState, null, null, null); |
| | | } |
| | | #endregion |
| | | } |
| | |
| | | if (edit) |
| | | { |
| | | //显示编辑之前的设备状态 |
| | | GetEditState(device, index, curtainSwitchView.btnState, crtainPercentumView.btnState, null, null); |
| | | GetEditDeviceState(device, index, curtainSwitchView.btnState, crtainPercentumView.btnState, null, null); |
| | | } |
| | | #endregion |
| | | } |
| | |
| | | if (edit) |
| | | { |
| | | //显示编辑之前的设备状态 |
| | | GetEditState(device, index, crtainPercentumView.btnState, AngleView.btnState, null, null); |
| | | GetEditDeviceState(device, index, crtainPercentumView.btnState, AngleView.btnState, null, null); |
| | | } |
| | | #endregion |
| | | } |
| | |
| | | if (edit) |
| | | { |
| | | //显示编辑之前的设备状态 |
| | | GetEditState(device, index, acSwitchVie.btnState, temperatureView.btnState, acModehView.btnState, acSpeedView.btnState); |
| | | GetEditDeviceState(device, index, acSwitchVie.btnState, temperatureView.btnState, acModehView.btnState, acSpeedView.btnState); |
| | | } |
| | | |
| | | #endregion |
| | | } |
| | | break; |
| | | case SPK.FloorHeatStandard:case SPK.HvacFloorHeat: |
| | | case SPK.FloorHeatStandard: |
| | | case SPK.HvacFloorHeat: |
| | | { |
| | | #region 界面 |
| | | ///开关 |
| | |
| | | if (edit) |
| | | { |
| | | //显示编辑之前的设备状态 |
| | | GetEditState(device, index, floorHeatingSwitchVie.btnState, temperatureView.btnState, floorHeatingModehView.btnState, null); |
| | | GetEditDeviceState(device, index, floorHeatingSwitchVie.btnState, temperatureView.btnState, floorHeatingModehView.btnState, null); |
| | | } |
| | | |
| | | #endregion |
| | |
| | | if (edit) |
| | | { |
| | | //显示编辑之前的设备状态 |
| | | GetEditState(device, index, AirFreshSwitchVie.btnState, AirFreshSpeedView.btnState, null, null); |
| | | GetEditDeviceState(device, index, AirFreshSwitchVie.btnState, AirFreshSpeedView.btnState, null, null); |
| | | } |
| | | |
| | | #endregion |
| | | } |
| | | break; |
| | | //音乐 |
| | | case SPK.MusicStandard: |
| | | case SPK.AvMusic: |
| | | { |
| | | #region 界面 |
| | | //提示语音 |
| | | LogicView.FunTypeView funTypeView = new LogicView.FunTypeView(); |
| | | funTypeView.btnText.TextID = StringId.tishiyin; |
| | | fLayout.AddChidren(funTypeView.FLayoutView()); |
| | | |
| | | ///设备延时iewv |
| | | DelayView(fLayout, funTypeView.frameLayout.Bottom); |
| | | #endregion |
| | | #region 点击事件 |
| | | ///提示语音点击事件 |
| | | funTypeView.btnClick.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | selectedState = device.spk + "_"; |
| | | Loading loading = new Loading(); |
| | | this.AddChidren(loading); |
| | | loading.Start(); |
| | | System.Threading.Tasks.Task.Run(() => |
| | | { |
| | | try |
| | | { |
| | | //HDL_ON.DriverLayer.Control.Ins.GetMusicDirectory(device); |
| | | //var palyListName = Music.SendMethod.mMethod.GetListName(device); |
| | | var palyList= Music.SendMethod.mMethod.GetListMusic(device, "hdl_special"); |
| | | List<string> musicNameList = new List<string>(); |
| | | for (int i = 0; i < palyList.songs.Count; i++) |
| | | { |
| | | var music = palyList.songs[i]; |
| | | musicNameList.Add(music.name); |
| | | } |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | loading.Hide(); |
| | | PublicInterface publicInterface = new PublicInterface(); |
| | | publicInterface.FrameOrVv(this, musicNameList, new List<string> { funTypeView.btnState.Text }, palyList.group, (index) => |
| | | { |
| | | var musicSelecetd = palyList.songs[index]; |
| | | //界面显示选中值 |
| | | funTypeView.btnState.Text = musicSelecetd.name; |
| | | //数据封装 |
| | | AddDictionary("playlist_name", palyList.group);//列表名 |
| | | AddDictionary("song_name", musicSelecetd.name);//歌曲名 |
| | | |
| | | },false); |
| | | |
| | | }); |
| | | } |
| | | catch { } |
| | | |
| | | }); |
| | | }; |
| | | |
| | | if (edit) |
| | | { |
| | | //显示编辑之前的设备状态 |
| | | GetEditDeviceState(device, index, funTypeView.btnState, null, null, null); |
| | | } |
| | | |
| | | #endregion |
| | |
| | | Output outputDevice = new Output(); |
| | | outputDevice.target_type = "1"; |
| | | outputDevice.sid = device.sid; |
| | | outputDevice.delay= strdelay; |
| | | outputDevice.delay = strdelay; |
| | | switch (device.spk) |
| | | { |
| | | case SPK.LightDimming: |
| | |
| | | } |
| | | case SPK.HvacAC: |
| | | case SPK.AcStandard: |
| | | case SPK.FloorHeatStandard:case SPK.HvacFloorHeat: |
| | | case SPK.FloorHeatStandard: |
| | | case SPK.HvacFloorHeat: |
| | | { |
| | | //做了一个特殊处理; |
| | | bool _bool = false; |
| | |
| | | } |
| | | } |
| | | break; |
| | | |
| | | |
| | | } |
| | | outputDevice.status = dicSateteList; |
| | | |
| | |
| | | this.RemoveFromParent(); |
| | | return; |
| | | } |
| | | LogicMethod.CurrLogicMethod.RemoveAllView(); |
| | | LogicMethod.Current.RemoveAllView(); |
| | | AddLogic addLogic = new AddLogic(); |
| | | MainPage.BasePageView.AddChidren(addLogic); |
| | | addLogic.Show(); |
| | |
| | | break; |
| | | } |
| | | //数据封装 |
| | | AddDictionary(keyVlaue, brightnesValue); |
| | | AddDictionary(keyVlaue, brightnesValue); |
| | | }); |
| | | #endregion |
| | | |
| | |
| | | /// <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 GetEditDeviceState(Entity.Function device, int index, Button button1, Button button2, Button button3, Button button4) |
| | | { |
| | | Output outputs = Logic.currlogic.output[index]; |
| | | var dicList = outputs.status; |
| | |
| | | this.btnDelay.Text = outputs.delay + "s"; |
| | | this.strdelay = outputs.delay; |
| | | } |
| | | InpOrOutLogicMethod.EditState(device, dicList, button1, button2, button3, button4); |
| | | InpOrOutLogicMethod.Current.EditDeviceState(device, dicList, button1, button2, button3, button4); |
| | | } |
| | | /// <summary> |
| | | /// 添加选中数据 |
| | |
| | | { |
| | | //数据封装 |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "key", KeyValue); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "value", selectedValue); |
| | | LogicMethod.Current.dictionary(dic, "key", KeyValue); |
| | | LogicMethod.Current.dictionary(dic, "value", selectedValue); |
| | | AddDictionaryList(KeyValue, dic); |
| | | } |
| | | /// <summary> |
| | |
| | | private void AddDic(string keyValue, string value, bool edit, int index) |
| | | { |
| | | Input inputTime = new Input(); |
| | | inputTime.sid = LogicMethod.CurrLogicMethod.NewSid(); |
| | | inputTime.sid = LogicMethod.Current.NewSid(); |
| | | inputTime.condition_type = "1"; |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "key", keyValue); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "comparator", "="); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "data_type", "string"); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "value", value); |
| | | LogicMethod.Current.dictionary(dic, "key", keyValue); |
| | | LogicMethod.Current.dictionary(dic, "comparator", "="); |
| | | LogicMethod.Current.dictionary(dic, "data_type", "string"); |
| | | LogicMethod.Current.dictionary(dic, "value", value); |
| | | inputTime.condition.Add(dic); |
| | | AddCondition(inputTime, edit, index); |
| | | } |
| | |
| | | //添加一个新的时间条件 |
| | | Logic.currlogic.input.Add(input); |
| | | } |
| | | LogicMethod.CurrLogicMethod.RemoveAllView(); |
| | | LogicMethod.Current.RemoveAllView(); |
| | | AddLogic addLogic = new AddLogic(); |
| | | MainPage.BasePageView.AddChidren(addLogic); |
| | | addLogic.Show(); |
| | |
| | | timePointView.FLayoutView(fLayout); |
| | | timePointView.TimePoint(fLayout, editTime, (timeValue)=>{ |
| | | Input inputTime = new Input(); |
| | | inputTime.sid = LogicMethod.CurrLogicMethod.NewSid(); |
| | | inputTime.sid = LogicMethod.Current.NewSid(); |
| | | inputTime.condition_type = "1"; |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "key", "timepoint"); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "comparator", "="); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "data_type", "string"); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "value", timeValue); |
| | | LogicMethod.Current.dictionary(dic, "key", "timepoint"); |
| | | LogicMethod.Current.dictionary(dic, "comparator", "="); |
| | | LogicMethod.Current.dictionary(dic, "data_type", "string"); |
| | | LogicMethod.Current.dictionary(dic, "value", timeValue); |
| | | inputTime.condition.Add(dic); |
| | | AddCondition(inputTime, edit, index); |
| | | }); |
| | |
| | | } |
| | | |
| | | Input inputTime = new Input(); |
| | | inputTime.sid = LogicMethod.CurrLogicMethod.NewSid(); |
| | | inputTime.sid = LogicMethod.Current.NewSid(); |
| | | inputTime.condition_type = "2"; |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "key", "timesection"); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "comparator", "="); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "data_type", "string"); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "value", btnStartTimeText.Text + "-" + btnEndTimeText.Text); |
| | | LogicMethod.Current.dictionary(dic, "key", "timesection"); |
| | | LogicMethod.Current.dictionary(dic, "comparator", "="); |
| | | LogicMethod.Current.dictionary(dic, "data_type", "string"); |
| | | LogicMethod.Current.dictionary(dic, "value", btnStartTimeText.Text + "-" + btnEndTimeText.Text); |
| | | inputTime.condition.Add(dic); |
| | | AddCondition(inputTime, edit, index); |
| | | |
| | |
| | | //添加一个新的时间条件 |
| | | Logic.currlogic.input.Add(input); |
| | | } |
| | | LogicMethod.CurrLogicMethod.RemoveAllView(); |
| | | LogicMethod.Current.RemoveAllView(); |
| | | AddLogic addLogic = new AddLogic(); |
| | | MainPage.BasePageView.AddChidren(addLogic); |
| | | addLogic.Show(); |
| | |
| | | private void AddDic(string value) |
| | | { |
| | | Input input = new Input(); |
| | | input.sid = LogicMethod.CurrLogicMethod.NewSid(); |
| | | input.sid = LogicMethod.Current.NewSid(); |
| | | input.condition_type = "6"; |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "key", "weather"); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "comparator", "="); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "data_type", "string"); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "value", value); |
| | | LogicMethod.Current.dictionary(dic, "key", "weather"); |
| | | LogicMethod.Current.dictionary(dic, "comparator", "="); |
| | | LogicMethod.Current.dictionary(dic, "data_type", "string"); |
| | | LogicMethod.Current.dictionary(dic, "value", value); |
| | | input.condition.Add(dic); |
| | | AddCondition(input, "weather", "="); |
| | | } |
| | |
| | | Logic.currlogic.input.Add(input); |
| | | } |
| | | |
| | | LogicMethod.CurrLogicMethod.RemoveAllView(); |
| | | LogicMethod.Current.RemoveAllView(); |
| | | AddLogic addLogic = new AddLogic(); |
| | | MainPage.BasePageView.AddChidren(addLogic); |
| | | addLogic.Show(); |
| | |
| | | quyuPatchView.frameLayout.Y = namePatchView.frameLayout.Bottom; |
| | | this.AddChidren(quyuPatchView.FLayoutView()); |
| | | quyuPatchView.btnText1.TextID = StringId.suoshuquyu; |
| | | quyuPatchView.btnText2.Text = Intelligence.Automation.LogicMethod.CurrLogicMethod.GetGetRoomName(GetFunction(control.deviceId)); |
| | | quyuPatchView.btnText2.Text = Intelligence.Automation.LogicMethod.Current.GetGetRoomName(GetFunction(control.deviceId)); |
| | | |
| | | //继续添加 |
| | | Button addBtn = new Button |
| | |
| | | method.ManagementPosition(GetFunction(control.deviceId), () => |
| | | { |
| | | //更新区域 |
| | | quyuPatchView.btnText2.Text = Intelligence.Automation.LogicMethod.CurrLogicMethod.GetGetRoomName(GetFunction(control.deviceId)); |
| | | quyuPatchView.btnText2.Text = Intelligence.Automation.LogicMethod.Current.GetGetRoomName(GetFunction(control.deviceId)); |
| | | }); |
| | | }; |
| | | //继续添加点击事件 |
| | |
| | | //遥控器所属区域: |
| | | FrameLayout50 areaFLayout = new FrameLayout50(); |
| | | areaFLayout.btnText.Text = Language.StringByID(StringId.yaokongqiquyu); |
| | | areaFLayout.btnEditText.Text = Intelligence.Automation.LogicMethod.CurrLogicMethod.GetGetRoomName(control); |
| | | areaFLayout.btnEditText.Text = Intelligence.Automation.LogicMethod.Current.GetGetRoomName(control); |
| | | areaFLayout.frameLayout.Y = editNameFLayout.frameLayout.Bottom; |
| | | viewLayout.AddChidren(areaFLayout.FLayoutView()); |
| | | #endregion |
| | |
| | | method.ManagementPosition(control, () => |
| | | { |
| | | //更新区域 |
| | | areaFLayout.btnEditText.Text = Intelligence.Automation.LogicMethod.CurrLogicMethod.GetGetRoomName(control); |
| | | areaFLayout.btnEditText.Text = Intelligence.Automation.LogicMethod.Current.GetGetRoomName(control); |
| | | }); |
| | | }; |
| | | #endregion |
| | |
| | | //遥控器名称 |
| | | controlView.nameBtn.Text = control.name; |
| | | //遥控器存放区域 |
| | | controlView.areaBtn.Text = Intelligence.Automation.LogicMethod.CurrLogicMethod.GetGetRoomName(control); |
| | | controlView.areaBtn.Text = Intelligence.Automation.LogicMethod.Current.GetGetRoomName(control); |
| | | //标记遥控器 |
| | | controlView.delBtn.Tag = control; |
| | | //删除点击事件 |
| | |
| | | { |
| | | //回调更新名字/区域 |
| | | controlView.nameBtn.Text = device.name; |
| | | controlView.areaBtn.Text = Intelligence.Automation.LogicMethod.CurrLogicMethod.GetGetRoomName(device); |
| | | controlView.areaBtn.Text = Intelligence.Automation.LogicMethod.Current.GetGetRoomName(device); |
| | | |
| | | }); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | |
| | | { |
| | | try |
| | | { |
| | | userList = Send.GetResidenceMemberAccount(); |
| | | userList = Send.Current.GetResidenceMemberAccount(); |
| | | |
| | | } |
| | | catch { } |
| | |
| | | //Refresh(); |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 音乐功能 |
| | | /// </summary> |
| | | public Function functionMusic = new Function(); |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | ///保存当前音乐列表 |
| | | /// </summary> |
| | |
| | | A31MusicModelList.RemoveAll((obj) => obj == null); |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 上一次更新的时间 |
| | | /// 记录数据反馈的时间(因为有时候网络差数据不回复,导致刷新当前播放音乐时间不正确) |
| | |
| | | /// <summary> |
| | | /// 列表 |
| | | /// </summary> |
| | | public List<PalyList> palyLists = new List<PalyList>(); |
| | | public List<PalyList> palyLists = new List<PalyList>(); |
| | | |
| | | /// <summary> |
| | | /// 喜爱音乐列表 |
| | |
| | | /// </summary> |
| | | public static A31MusicModel Current; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 指定列表名获取音乐列表 |
| | |
| | | /// <returns></returns> |
| | | public List<Songs> GetSongList(string listName) |
| | | { |
| | | var list = palyLists.Find((o)=>o.group==listName); |
| | | if (list==null) { |
| | | var list = palyLists.Find((o) => o.group == listName); |
| | | if (list == null) |
| | | { |
| | | return new List<Songs>(); |
| | | } |
| | | return list.songs; |
| | | } |
| | | |
| | | |
| | | |
| | | public Slaves Slave = new Slaves(); |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 判断是否是json数据 |
| | |
| | | public List<Songs> songs = new List<Songs>(); |
| | | } |
| | | [System.Serializable] |
| | | public class Songs:MusicInfo |
| | | public class Songs : MusicInfo |
| | | { |
| | | /// <summary> |
| | | /// 歌曲名称 |
| | |
| | | /// 类型<自己用> |
| | | /// </summary> |
| | | public string type = string.Empty; |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 列表名和group组名是一样的 |
| | | /// </summary> |
| | | public string listName = string.Empty; |
| | | } |
| | | |
| | | |
| | | [System.Serializable] |
| | | /// <summary> |
| | | /// 列表名列表 |
| | | /// </summary> |
| | | public class GroupList |
| | | { |
| | | /// <summary> |
| | | ///设备sid |
| | | /// </summary> |
| | | public string sid = string.Empty; |
| | | /// <summary> |
| | | /// 列表名集合 |
| | | /// </summary> |
| | | public List<ListName> groupList = new List<ListName>(); |
| | | |
| | | } |
| | | [System.Serializable] |
| | | /// <summary> |
| | | /// 列表名 |
| | | /// </summary> |
| | | public class ListName |
| | | { |
| | | /// <summary> |
| | | /// 组名=列表名 |
| | | /// </summary> |
| | | public string group = string.Empty; |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | ///我的列表事件 |
| | | myListView.clickBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | A31MyList a31MyList = new A31MyList(); |
| | | MainPage.BasePageView.AddChidren(a31MyList); |
| | | a31MyList.Show(); |
| | | a31MyList.UpdateSelectedFile(); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | //A31MyList a31MyList = new A31MyList(); |
| | | //MainPage.BasePageView.AddChidren(a31MyList); |
| | | //a31MyList.Show(); |
| | | //a31MyList.UpdateSelectedFile(); |
| | | //MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | |
| | | System.Threading.Tasks.Task.Run(() => |
| | | { |
| | | try |
| | | { |
| | | |
| | | //HDL_ON.DriverLayer.Control.Ins.GetMusicDirectory(device); |
| | | var palyListName = Music.SendMethod.mMethod.GetListName(A31MusicModel.Current.functionMusic); |
| | | var palyList = Music.SendMethod.mMethod.GetListMusic(A31MusicModel.Current.functionMusic, "hdl_special"); |
| | | List<string> musicNameList = new List<string>(); |
| | | for (int i = 0; i < palyList.songs.Count; i++) |
| | | { |
| | | var music = palyList.songs[i]; |
| | | musicNameList.Add(music.name); |
| | | } |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | UI2.Intelligence.Automation.PublicInterface publicInterface = new UI2.Intelligence.Automation.PublicInterface(); |
| | | publicInterface.FrameOrVv(this, musicNameList, new List<string> { "123" }, palyList.group, (index) => |
| | | { |
| | | |
| | | |
| | | }, false); |
| | | |
| | | }); |
| | | } |
| | | catch { } |
| | | |
| | | }); |
| | | }; |
| | | |
| | | |
| | |
| | | { |
| | | //RefreshDeviceStatus(functionIds); |
| | | //a31Music.LastDateTime = DateTime.Now; |
| | | ///从缓存里面查找音乐播放器对象<缓存数据收到推送过来的状态会更新缓存数据> |
| | | ///从缓存里面查找音乐播放器对象<收到推送过来的状态会更新缓存数据> |
| | | var allLocalFuntion = FunctionList.List.GetDeviceFunctionList(); |
| | | var localFunction = allLocalFuntion.Find((obj) => obj.sid == sid); |
| | | if (localFunction == null) |
| | |
| | | } |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 获取列表名列表 |
| | | /// </summary> |
| | | /// <param name="music"></param> |
| | | /// <returns></returns> |
| | | public List<GroupList> GetListName(Function music) |
| | | { |
| | | try |
| | | { |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id); |
| | | d.Add("gatewayId", DB_ResidenceData.Instance.HomeGateway.gatewayId); |
| | | d.Add("deviceIds", new List<string> { music.deviceId }); |
| | | var responsePackNew = RequestServerhomeId(d, NewAPI.Api_Post_GroupList); |
| | | if (responsePackNew.Code != "0" || responsePackNew.Data == null || responsePackNew.Data.ToString() == "") |
| | | { |
| | | return new List<GroupList>(); |
| | | } |
| | | //数据返序列化为Function对象 |
| | | var str = Newtonsoft.Json.JsonConvert.SerializeObject(responsePackNew.Data); |
| | | var groupLists = Newtonsoft.Json.JsonConvert.DeserializeObject<List<GroupList>>(str); |
| | | if (groupLists == null) |
| | | { |
| | | groupLists = new List<GroupList>(); |
| | | } |
| | | return groupLists; |
| | | } |
| | | catch |
| | | { |
| | | return new List<GroupList>(); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 获取列表音乐 |
| | | /// </summary> |
| | | /// <param name="music"></param> |
| | | /// <param name="listName">列表名</param> |
| | | /// <returns></returns> |
| | | public PalyList GetListMusic(Function music, string listName) |
| | | { |
| | | try |
| | | { |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | Dictionary<string, object> d1 = new Dictionary<string, object>(); |
| | | Dictionary<string, object> d2 = new Dictionary<string, object>(); |
| | | d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id); |
| | | d.Add("gatewayId", DB_ResidenceData.Instance.HomeGateway.gatewayId); |
| | | d2.Add("group", listName); |
| | | d1.Add("sid", music.sid); |
| | | d1.Add("groupList", new List<Dictionary<string, object>> { d2 }); |
| | | d.Add("sidGroups", new List<Dictionary<string, object>> { d1 }); |
| | | |
| | | var responsePackNew = RequestServerhomeId(d, NewAPI.Api_Post_GroupPlayerList); |
| | | if (responsePackNew.Code != "0" || responsePackNew.Data == null || responsePackNew.Data.ToString() == "") |
| | | { |
| | | return new PalyList(); |
| | | } |
| | | //数据返序列化为Function对象 |
| | | var str = Newtonsoft.Json.JsonConvert.SerializeObject(responsePackNew.Data); |
| | | var palyLists = Newtonsoft.Json.JsonConvert.DeserializeObject<PalyList>(str); |
| | | if (palyLists == null) |
| | | { |
| | | palyLists = new PalyList(); |
| | | } |
| | | return palyLists; |
| | | } |
| | | catch |
| | | { |
| | | return new PalyList(); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | ///请求服务器(与住宅有关:例如;homeId) |
| | |
| | | /// homeId |
| | | /// </summary> |
| | | public string homeId; |
| | | /// <summary> |
| | | /// sid |
| | | /// </summary> |
| | | public string sid=string.Empty; |
| | | } |
| | | |
| | | /// <summary> |