HDL-ON_Android/Properties/AndroidManifest.xml
@@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="202203111" android:versionName="1.5.5" package="com.hdl.onpro" xmlns:tools="http://schemas.android.com/tools"> <uses-sdk android:minSdkVersion="28" android:targetSdkVersion="30" /> <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.5.6" package="com.hdl.onpro" xmlns:tools="http://schemas.android.com/tools" android:versionCode="202205241"> <uses-sdk android:minSdkVersion="26" android:targetSdkVersion="29" /> <!--友盟--> <!--<uses-sdk android:minSdkVersion="8"></uses-sdk>--> <!--<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>--> HDL-ON_iOS/Info.plist
@@ -100,9 +100,9 @@ <key>UIStatusBarStyle</key> <string>UIStatusBarStyleLightContent</string> <key>CFBundleShortVersionString</key> <string>1.5.502203111</string> <string>1.5.502205201</string> <key>CFBundleVersion</key> <string>1.5.503111</string> <string>1.5.505201</string> <key>NSLocationWhenInUseUsageDescription</key> <string>Use geographic location to provide services such as weather</string> <key>NSAppleMusicUsageDescription</key> HDL_ON/Common/ApiUtlis.cs
@@ -159,7 +159,7 @@ endTime = DateTime.Now.AddSeconds(5); MainPage.Log($"读取设备信息成功"); var deviceList = Newtonsoft.Json.JsonConvert.DeserializeObject<DevcieApiPack>(deviceResult.Data.ToString()); var deviceList = JsonConvert.DeserializeObject<DevcieApiPack>(deviceResult.Data.ToString()); if (deviceList == null) { deviceList = new DevcieApiPack(); @@ -171,7 +171,7 @@ var deviceResult2 = Ins.HttpRequest.GetDeviceList("30", Convert.ToInt32(deviceList.pageNo) + 1 + ""); if (deviceResult2.Code == StateCode.SUCCESS) { var deviceList2 = Newtonsoft.Json.JsonConvert.DeserializeObject<DevcieApiPack>(deviceResult.Data.ToString()); var deviceList2 = JsonConvert.DeserializeObject<DevcieApiPack>(deviceResult.Data.ToString()); deviceList.pageNo = deviceList2.pageNo; deviceList.list.AddRange(deviceList2.list); } HDL_ON/DAL/DriverLayer/Control.cs
@@ -94,7 +94,7 @@ } set { if (_GatewayOnline_Local != value) //if (_GatewayOnline_Local != value) { _GatewayOnline_Local = value; if (value) @@ -129,7 +129,7 @@ } set { if (_GatewayOnline_Cloud != value) //if (_GatewayOnline_Cloud != value) { _GatewayOnline_Cloud = value; if(GatewayOnline_Local) @@ -655,6 +655,79 @@ } /// <summary> /// 发送读取命令 /// 自动判断是否为A协议设备 /// </summary> public void SendReadCommand(List<Function> functions, bool forceRemote = false) { List<string> sids = new List<string>(); foreach (Function function in functions) { sids.Add(function.sid); function.refreshTime = DateTime.Now; } if (forceRemote) { var pm = new DAL.Server.HttpServerRequest(); var pack = pm.RefreshDeviceStatus(sids); } else { if (Ins.GatewayOnline_Local) { if (DB_ResidenceData.Instance.GatewayType == 0) { try { var busClient = new Control_Udp(); foreach (Function function in functions) { busClient.ReadBusData(function); } } catch (Exception ex) { MainPage.Log($"发送数据异常: {ex.Message}"); } } else { var objects = new List<Dictionary<string, string>>(); foreach (Function function in functions) { 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(CommunicationTopic.ct.ReadStatus, functionControlDataJson); MainPage.Log($"本地通讯 发送HDL-Link数据:{functionControlDataJson}"); new Control_Udp().SendLocalHdlLinkData(sendBytes, readDataObj.id); } } else { var pm = new DAL.Server.HttpServerRequest(); var pack = pm.RefreshDeviceStatus(sids); } } } /// <summary> /// 安防控制 /// </summary> public void ControlSecurity(SecurityAlarm securityAlarm,string state) HDL_ON/DAL/Mqtt/MqttClient.cs
@@ -1094,8 +1094,17 @@ //创建AES解密器对象 var cTransform = rm.CreateDecryptor(); byte[] reData = null; //使用AES将密文流转成明文的字节数组 return cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length); try { reData = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length); } catch (Exception ex) { Console.WriteLine(ex.Message); } return reData; } #endregion HDL_ON/DAL/ThirdPartySdk/HDLLinphone.cs
@@ -120,6 +120,7 @@ if (mHDLSipInfo == null) return; #if __IOS__ //Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().Login("1003", "123456", "192.168.31.194:5060"); //Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().Login("6666", "85521566", "116.62.26.215:5060"); Shared.IOS.HDLLinphoneSDK.HDLLinPhoneSDK.Instance().Login(mHDLSipInfo.sipAccount, mHDLSipInfo.sipPasswd, mHDLSipInfo.realm); #else HDL_ON/Entity/DB_ResidenceData.cs
@@ -470,6 +470,10 @@ #endregion /// <summary> /// 场景筛选时,选择的房间 /// </summary> public string sceneChooseRoomId = ""; /// <summary> HDL_ON/Entity/Function/Sensor.cs
@@ -64,7 +64,7 @@ } } double value = 0.0; double.TryParse( attr.state,out value); double.TryParse(attr.state, out value); return Convert.ToDouble(value); } @@ -126,6 +126,48 @@ } return _intervalValue; } public string Unit(Function function) { string unit = ""; if (function.attrKeyConfigs.Count > 0) { foreach (var attrKey in function.attrKeyConfigs) { if (function.spk.Replace(".", "").Contains(attrKey.key.Replace(".", ""))) { if (!string.IsNullOrEmpty(attrKey.unit)) return attrKey.unit; } } } switch (function.spk) { case SPK.SensorPm25: unit = "ug/m²"; break; case SPK.SensorTemperature: unit = "°C"; break; case SPK.SensorTVOC: unit = "PPB"; break; case SPK.SensorCO2: unit = "PPM"; break; case SPK.SensorHumidity: unit = "%"; break; case SPK.SensorHcho: unit = "mg/m3"; break; } return unit; } /// <summary> @@ -237,6 +279,69 @@ } return _levelTextList; } /// <summary> /// 获取 /// </summary> /// <param name="function"></param> /// <returns></returns> public uint GetCurColor(Function function) { var spk = function.spk; var values = GetValues(function); uint level = 0x00000000; if (function.attrKeyConfigs.Count > 0) { foreach (var attrKey in function.attrKeyConfigs) { if (function.spk.Replace(".", "").Contains(attrKey.key.Replace(".", ""))) { foreach (var info in attrKey.configs) { if ((Convert.ToInt32(info.start) >= values) && (Convert.ToInt32(info.end) < values)) { return Convert.ToUInt32(info.color, 16); } } } } } return level; } /// <summary> /// 获取文本 /// </summary> /// <param name="function"></param> /// <returns></returns> public string GetCurText(Function function) { var spk = function.spk; var values = GetValues(function); var level = ""; if (function.attrKeyConfigs.Count > 0) { foreach (var attrKey in function.attrKeyConfigs) { if (function.spk.Replace(".", "").Contains(attrKey.key.Replace(".", ""))) { foreach (var info in attrKey.configs) { if ((Convert.ToInt32(info.start) >= values) && (Convert.ToInt32(info.end) < values)) { return info.desc; } } } } } return level; } /// <summary> /// 当前等级 /// </summary> @@ -245,6 +350,37 @@ var spk = function.spk; var values = GetValues(function); int level = 1; if (function.attrKeyConfigs.Count > 0) { foreach (var attrKey in function.attrKeyConfigs) { if (function.spk.Replace(".", "").Contains(attrKey.key.Replace(".", ""))) { level = 1; if(attrKey.configs.Count == 0) { break; } foreach (var info in attrKey.configs) { if ((Convert.ToDouble(info.start) < values) && (Convert.ToDouble(info.end) >= values)) { return level; } level++; } } } return 1; } switch (spk) { case SPK.SensorPm25: HDL_ON/Entity/FunctionList.cs
@@ -459,12 +459,25 @@ if(DriverLayer.Control.Ins.GatewayOnline_Local) { //List<Function> functions = GetDeviceFunctionList(SPK.BrandType.Hdl); //var sss = functions.OrderBy((obj) => obj.collect); List<Function> readList = new List<Function>(); foreach (var function in GetDeviceFunctionList(SPK.BrandType.Hdl)) { readList.Add(function); MainPage.Log($"读取功能状态:{function.name} : {function.sid} "); Control.Ins.SendReadCommand(function); if (readList.Count > 9) { Control.Ins.SendReadCommand(readList); } } if(DB_ResidenceData.Instance.GatewayType == 1) if (readList.Count > 0) { Control.Ins.SendReadCommand(readList); } if (DB_ResidenceData.Instance.GatewayType == 1) { Dictionary<string, string> pairs = new Dictionary<string, string>(); string sendId = Control.Ins.msg_id.ToString(); @@ -481,6 +494,8 @@ var page = new List<string>(); int count = 0; //List<Function> functions = GetDeviceFunctionList(SPK.BrandType.Hdl); //var sss = functions.OrderBy((obj) => obj.collect); foreach (var function in GetDeviceFunctionList(SPK.BrandType.Hdl)) { page.Add(function.deviceId); HDL_ON/UI/UI1-Login/LoginPage.cs
@@ -217,6 +217,7 @@ //etAccount.Text = "18316120654";//tujie //etAccount.Text = "13450425807";//黄竹溪 knx项目 etAccount.Text = "18244942707"; etAccount.Text = "3083375423@qq.com";//陈伟潮 自研可视对讲 } else { @@ -243,7 +244,8 @@ //etAccount.Text = "13375012441"; //etAccount.Text = "info@smartlife-ks.com"; //etAccount.Text = "551775569@qq.com";//wcf etAccount.Text = "15626203746"; //etAccount.Text = "15626203746"; etAccount.Text = "18244942707"; //etAccount.Text = "zhangquansongjava@163.com"; //etAccount.Text = "s.savinov@hdlautomation.ru"; } HDL_ON/UI/UI2/3-Intelligence/Scene/SceneEditPage.cs
@@ -98,6 +98,7 @@ public void LoadPage(Action backRefresh) { DB_ResidenceData.Instance.SupportFacePass new TopViewDiv(bodyView, Language.StringByID(StringId.EditScene)).LoadTopView(backRefresh); initPage(); } HDL_ON/UI/UI2/3-Intelligence/Scene/SceneFunctionListChoosePage.cs
@@ -156,9 +156,33 @@ { unallocatedList.Add(function); } } if (string.IsNullOrEmpty(DB_ResidenceData.Instance.sceneChooseRoomId)) { LoadFunctionListRow(null); } else { var selectedRoom = Room.CurrentSpatial.RoomList.Find((obj) => obj.uid == DB_ResidenceData.Instance.sceneChooseRoomId); var listAllFun = new List<Function>(); var listFun = new List<Function>(); listAllFun.AddRange(unallocatedList); listAllFun.AddRange(allocatedList); btnFloor.Text = selectedRoom.floorRoomName; foreach(var funtion in listAllFun) { if (funtion.roomIds.Contains(selectedRoom.roomId)) { listFun.Add(funtion); } } LoadFunctionListRow(listFun); } LoadFunctionListRow(null); LoadEventList(); } @@ -278,6 +302,7 @@ form.ShowDeviceFunctionView(btnFloor, listAllFun, (selectId, listFun) => { nowSelectId = selectId; DB_ResidenceData.Instance.sceneChooseRoomId = selectId; //重新刷新设备列表 this.LoadFunctionListRow(listFun); }, nowSelectId); HDL_ON/UI/UI2/FuntionControlView/Light/ColorTureLampPageBLL.cs
@@ -26,8 +26,8 @@ if (!bodyView.onDimmerBar) { bodyView.dimmerBar.Progress = Convert.ToInt32(updataTemp.GetAttrState(FunctionAttributeKey.Brightness)); } bodyView.btnBrightnessText.Text = updataTemp.GetAttrState(FunctionAttributeKey.Brightness) + "%"; } bodyView.btnBrightnessText.Text = updataTemp.GetAttrState(FunctionAttributeKey.Brightness) + "%"; bodyView.btnBrightnessText.Y = ((100 - Convert.ToInt32(updataTemp.GetAttrState(FunctionAttributeKey.Brightness))) * Application.GetRealHeight(222 - 16) / 100) + Application.GetRealWidth(80); } else @@ -38,8 +38,8 @@ bodyView.barColorTemplatrue.Enable = updataTemp.trait_on_off.curValue.ToString() == "on"; var cct = 27; int.TryParse(updataTemp.GetAttrState(FunctionAttributeKey.CCT), out cct); bodyView.barColorTemplatrue.Progress = cct / 100; //设置初始值 bodyView.barColorTemplatrue.Progress = cct / 100; //设置初始值 bodyView.barColorTemplatrue.SetCustomText(bodyView.barColorTemplatrue.Progress * 100 + "K"); } @@ -59,7 +59,7 @@ LoadEvet_ChangeFadeTime(); LoadEvet_ChangeColorTemplatrue(); //回退刷新信息事件 actionRefresh = () => actionRefresh = () => { btnFunctionName.Text = btnFunctionName_Out.Text = function.name; btnFromFloor_Out.Text = btnFromFoorAndRoom.Text = function.GetRoomListName(); @@ -71,54 +71,54 @@ /// </summary> void LoadEvet_ChangeFadeTime() { if (function.GetAttribute(FunctionAttributeKey.FadeTime) != null) { barFadeTime.OnStopTrackingTouchEvent = (sender, e) => { function.SetAttrState(FunctionAttributeKey.FadeTime, e.ToString()); function.SaveFunctionFile(); }; } if (function.GetAttribute(FunctionAttributeKey.FadeTime) != null) { barFadeTime.OnStopTrackingTouchEvent = (sender, e) => { function.SetAttrState(FunctionAttributeKey.FadeTime, e.ToString()); function.SaveFunctionFile(); }; } } /// <summary> /// 修改色温 /// </summary> void LoadEvet_ChangeColorTemplatrue() { if (!function.online) { new Tip() { CloseTime = 1, Text = Language.StringByID(StringId.DeviceOfflineCannotOption), Direction = AMPopTipDirection.None, }.Show(MainPage.BaseView); return; { if (!function.online) { new Tip() { CloseTime = 1, Text = Language.StringByID(StringId.DeviceOfflineCannotOption), Direction = AMPopTipDirection.None, }.Show(MainPage.BaseView); return; } barColorTemplatrue.OnProgressChangedEvent += (sender, value) => { new System.Threading.Thread(() => { Application.RunOnMainThread(() => { //设置自定义的文本 barColorTemplatrue.SetCustomText(value * 100 + "K"); function.SetAttrState(FunctionAttributeKey.CCT, value * 100); //System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>(); //d.Add(FunctionAttributeKey.CCT, function.Attr_CCT.curValue.ToString()); //Control.Ins.SendWriteCommand(function, d); new System.Threading.Thread(() => { Application.RunOnMainThread(() => { //设置自定义的文本 barColorTemplatrue.SetCustomText(value * 100 + "K"); function.SetAttrState(FunctionAttributeKey.CCT, value * 100); //System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>(); //d.Add(FunctionAttributeKey.CCT, function.Attr_CCT.curValue.ToString()); //Control.Ins.SendWriteCommand(function, d); }); //System.Threading.Thread.Sleep(200); }).Start(); }; }; barColorTemplatrue.OnStopTrackingTouchEvent = (sender, value) => { function.SetAttrState(FunctionAttributeKey.CCT, value * 100); System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>(); d.Add(FunctionAttributeKey.CCT, (value * 100 ).ToString()); Control.Ins.SendWriteCommand(function, d); { function.SetAttrState(FunctionAttributeKey.CCT, value * 100); System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>(); d.Add(FunctionAttributeKey.CCT, (value * 100 ).ToString()); Control.Ins.SendWriteCommand(function, d); }; } @@ -139,74 +139,79 @@ /// </summary> void LoadEvent_DimmerBar() { dimmerBar.OnStopTrackingTouchEvent = (sender, e) => { if (!function.online) { new Tip() { CloseTime = 1, Text = Language.StringByID(StringId.DeviceOfflineCannotOption), Direction = AMPopTipDirection.None, }.Show(MainPage.BaseView); return; dimmerBar.OnStopTrackingTouchEvent = (sender, e) => { if (!function.online) { new Tip() { CloseTime = 1, Text = Language.StringByID(StringId.DeviceOfflineCannotOption), Direction = AMPopTipDirection.None, }.Show(MainPage.BaseView); return; } onDimmerBar = false; function.SetAttrState(FunctionAttributeKey.Brightness, dimmerBar.Progress); System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>(); d.Add(FunctionAttributeKey.Brightness, dimmerBar.Progress.ToString()); d.Add(FunctionAttributeKey.FadeTime, function.GetAttrState(FunctionAttributeKey.FadeTime)); if (dimmerBar.Progress > 0) { d.Add(FunctionAttributeKey.OnOff, "on"); } Control.Ins.SendWriteCommand(function, d); //function.fadeTime = barFadeTime.Progress; btnBrightnessText.Text = dimmerBar.Progress + "%"; dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1); }; if (function.online) { dimmerBar.OnStartTrackingTouchEvent = (sender, e) => { onDimmerBar = true; }; dimmerBar.OnProgressChangedEvent = (sender, e) => { dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1); //function.fadeTime = 0; //if (!btnSwitch.IsSelected) //{ // dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1); //} //btnSwitch.IsSelected = e > 0 ? true : false; //function.brightness = e; //function.trait_on_off.curValue = e > 0 ? "on" : "off"; //if (e == 0 || e == 100) //{ // System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>(); // d.Add(FunctionAttributeKey.Brightness, function.brightness.ToString()); // Control.Ins.SendWriteCommand(function, d); //} //else //{ // if (200 < (DateTime.Now - function.refreshTime).TotalMilliseconds) // { // function.refreshTime = DateTime.Now; // new System.Threading.Thread(() => // { // System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>(); // d.Add(FunctionAttributeKey.Brightness, function.brightness.ToString()); // Control.Ins.SendWriteCommand(function, d); // }) // { IsBackground = true }.Start(); // } //} //btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(222 - 16 - 16) / 100) + Application.GetRealWidth(40); //btnBrightnessText.Text = function.brightness + "%"; btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(222 - 16) / 100) + Application.GetRealWidth(80); btnBrightnessText.Text = dimmerBar.Progress + "%"; }; btnBrightnessText.Text = dimmerBar.Progress + "%"; dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1); }; if (function.online) { dimmerBar.OnStartTrackingTouchEvent = (sender, e) => { onDimmerBar = true; }; dimmerBar.OnProgressChangedEvent = (sender, e) => { dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1); //function.fadeTime = 0; //if (!btnSwitch.IsSelected) //{ // dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1); //} //btnSwitch.IsSelected = e > 0 ? true : false; //function.brightness = e; //function.trait_on_off.curValue = e > 0 ? "on" : "off"; //if (e == 0 || e == 100) //{ // System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>(); // d.Add(FunctionAttributeKey.Brightness, function.brightness.ToString()); // Control.Ins.SendWriteCommand(function, d); //} //else //{ // if (200 < (DateTime.Now - function.refreshTime).TotalMilliseconds) // { // function.refreshTime = DateTime.Now; // new System.Threading.Thread(() => // { // System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>(); // d.Add(FunctionAttributeKey.Brightness, function.brightness.ToString()); // Control.Ins.SendWriteCommand(function, d); // }) // { IsBackground = true }.Start(); // } //} //btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(222 - 16 - 16) / 100) + Application.GetRealWidth(40); //btnBrightnessText.Text = function.brightness + "%"; btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(222 - 16) / 100) + Application.GetRealWidth(80); btnBrightnessText.Text = dimmerBar.Progress + "%"; }; } } @@ -216,16 +221,16 @@ void LoadSwitchEvent() { btnSwitch.MouseUpEventHandler += (sender, e) => { if (!function.online) { new Tip() { CloseTime = 1, Text = Language.StringByID(StringId.DeviceOfflineCannotOption), Direction = AMPopTipDirection.None, }.Show(MainPage.BaseView); return; { if (!function.online) { new Tip() { CloseTime = 1, Text = Language.StringByID(StringId.DeviceOfflineCannotOption), Direction = AMPopTipDirection.None, }.Show(MainPage.BaseView); return; } //function.fadeTime = barFadeTime.Progress; btnSwitch.IsSelected = !btnSwitch.IsSelected; HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPageBLL.cs
@@ -93,6 +93,7 @@ dimmerBar.OnStartTrackingTouchEvent = (sender, e) => { onDimmerBar = true; dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1); }; dimmerBar.OnStopTrackingTouchEvent = (sender, e) => { @@ -100,13 +101,17 @@ function.SetAttrState(FunctionAttributeKey.Brightness, dimmerBar.Progress); System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>(); d.Add(FunctionAttributeKey.Brightness, dimmerBar.Progress.ToString()); if(dimmerBar.Progress > 0) { d.Add(FunctionAttributeKey.OnOff, "on"); } Control.Ins.SendWriteCommand(function, d); btnBrightnessText.Text = dimmerBar.Progress + "%"; }; //20201223 删除滑动发送命令,防止控件跳动 dimmerBar.OnProgressChangedEvent = (sender, e) => { dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1); //function.fadeTime = 0; //if (!btnSwitch.IsSelected) //{ HDL_ON/UI/UI2/FuntionControlView/Video/WanderingAlarmPage.cs
New file @@ -0,0 +1,231 @@ using System; using System.Collections.Generic; using HDL_ON.DAL.Server; using HDL_ON.UI.CSS; using Shared; namespace HDL_ON.UI.UI2.FuntionControlView.Video { public class WanderingAlarmPage : FrameLayout { FrameLayout bodyView; string deviceId; public WanderingAlarmPage(string deviceId) { bodyView = this; this.deviceId = deviceId; } VerticalScrolViewLayout contentView; public void LoadPage() { bodyView.BackgroundColor = CSS_Color.MainBackgroundColor; new TopViewDiv(bodyView, Language.StringByID(StringId.WanderingAlarm)).LoadTopView(); var btnTipMsg = new Button() { Y = Application.GetRealHeight(64), X = Application.GetRealWidth(20), Height = Application.GetRealHeight(58), Width = Application.GetRealWidth(318), TextAlignment = TextAlignment.CenterLeft, TextColor = CSS_Color.PromptingColor1, TextSize = CSS_FontSize.PromptFontSize_FirstLevel, Text = "*可视对讲可以自动识别门口可疑人员,并发起徘徊报警记录" }; if(Language.CurrentLanguage != "Chinese") { btnTipMsg.Text = "*Visual intercom can automatically identify suspicious persons at the door and initiate wandering alarm records"; } bodyView.AddChidren(btnTipMsg); contentView = new VerticalScrolViewLayout() { Y = Application.GetRealHeight(64 + 62), Height = Application.GetRealHeight(550), }; bodyView.AddChidren(contentView); LoadCloudData(20, 1); } /// <summary> /// 读取云端数据 /// </summary> void LoadCloudData(int pageCount,int pageNo) { Loading loading = new Loading(); bodyView.AddChidren(loading); loading.Start(""); new System.Threading.Thread(() => { try { HttpServerRequest http = new HttpServerRequest(); var pack = http.GetAlarmRecords(deviceId, pageCount,pageNo); if (pack.Code == StateCode.SUCCESS) { var obj = Newtonsoft.Json.JsonConvert.DeserializeObject<AlarmRecordInfoPack>(pack.Data.ToString()); Application.RunOnMainThread(() => { LoadSceneGallery(obj); }); } } catch (Exception ex) { MainPage.Log($"读取徘徊报警数据异常:{ex.Message}"); } finally { Application.RunOnMainThread(() => { if (loading != null) { loading.Hide(); loading.RemoveFromParent(); } }); } }) { IsBackground = true }.Start(); } /// <summary> /// 加载场景图库 /// </summary> void LoadSceneGallery(AlarmRecordInfoPack pack) { FrameLayout sceneImageRow = new FrameLayout() { Height = Application.GetRealWidth(128), }; new System.Threading.Thread(() => { for (int i = 0; i < pack.list.Count; i++) { var item = pack.list[i]; var imageBytes = ImageUtlis.Current.DownImageByImageUrl(item.alarmImg); Application.RunOnMainThread(() => { var sceneImageView = new ImageView() { Width = Application.GetRealWidth(172), Height = Application.GetRealHeight(90), Radius = (uint)Application.GetRealWidth(12), ImageBytes = imageBytes }; var btnTime = new Button() { Width = Application.GetRealHeight(160), Height = Application.GetRealHeight(41), Y = Application.GetRealHeight(90), Text = Utlis.UnixToDateTimeMS(item.alarmTime).ToString(), TextColor = CSS_Color.FirstLevelTitleColor, TextAlignment = TextAlignment.Center }; if (i % 2 == 0) { sceneImageRow = new FrameLayout() { Height = Application.GetRealHeight(90 + 53), }; contentView.AddChidren(sceneImageRow); sceneImageView.X = Application.GetRealWidth(10); sceneImageRow.AddChidren(sceneImageView); btnTime.X = Application.GetRealWidth(10); sceneImageRow.AddChidren(btnTime); } else { sceneImageView.X = Application.GetRealWidth(194); sceneImageRow.AddChidren(sceneImageView); btnTime.X = Application.GetRealWidth(194); sceneImageRow.AddChidren(btnTime); } sceneImageView.MouseUpEventHandler = (sender, e) => { Dialog dialog = new Dialog(); FrameLayout dialogContentView = new FrameLayout(); dialog.AddChidren(dialogContentView); dialogContentView.MouseUpEventHandler = (sender2, e2) => { dialog.Close(); }; ImageView btnImage = new ImageView() { Gravity = Gravity.Center, Height = Application.GetRealHeight(211), ImageBytes = sceneImageView.ImageBytes, }; dialogContentView.AddChidren(btnImage); dialog.Show(); }; }); System.Threading.Thread.Sleep(20); } Application.RunOnMainThread(() => { if (pack.totalPage > pack.pageNo) { var btnLoadMore = new Button() { TextAlignment = TextAlignment.Center, TextID = StringId.GetMore, Height = Application.GetRealHeight(60), TextSize = CSS_FontSize.SubheadingFontSize, TextColor = CSS_Color.FirstLevelTitleColor, }; contentView.AddChidren(btnLoadMore); btnLoadMore.MouseUpEventHandler = (sender, e) => { LoadCloudData(20, pack.pageNo + 1); btnLoadMore.RemoveFromParent(); }; } }); }) { IsBackground = true }.Start(); } } public class AlarmRecordInfoPack { public int totalCount = 0; public int totalPage = 0; public int pageNo = 0; public int pageSize = 0; public List<AlarmRecordInfo> list = new List<AlarmRecordInfo>(); } /// <summary> /// 徘徊报警信息 /// </summary> public class AlarmRecordInfo { public string alarmImg = string.Empty; public long alarmTime; public string alarmType = string.Empty; public string alarmTypeDesc = string.Empty; } }