From f14dcfd967404e197e7ec995ca8d6f2b090d3b7d Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期五, 11 九月 2020 09:16:59 +0800 Subject: [PATCH] 优化多功能面板:绑定温湿度传感器目标,和设备列表回路显示。优化数据矫正功能温湿度度不设置的情况。优化门锁时间设置最后一天和最后最后一个月的时间显示等 细节 --- ZigbeeApp/Shared/Phone/ZigBee/Common/OwnCodes.cs | 243 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 243 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Common/OwnCodes.cs b/ZigbeeApp/Shared/Phone/ZigBee/Common/OwnCodes.cs new file mode 100755 index 0000000..4ebcf61 --- /dev/null +++ b/ZigbeeApp/Shared/Phone/ZigBee/Common/OwnCodes.cs @@ -0,0 +1,243 @@ +锘縰sing System; +using System.Linq; + +namespace ZigBee.Droid.Common +{ + public class OwnCodes + { + + /// <summary> + /// 灏哛GB杞崲涓洪鑹层�傘�傘�� + /// </summary> + /// <param name="R"></param> + /// <param name="G"></param> + /// <param name="B"></param> + /// <returns></returns> + private uint GetColorByRGB(byte R, byte G, byte B) + { + return (uint)(0xFF000000 + R * 256 * 256 + G * 256 + B); + } + + #region set/get + [Newtonsoft.Json.JsonIgnore] + /// <summary> + /// 寮�鍏夌姸鎬�:0=鍏�,1=寮�, + /// <para>0:</para> + /// </summary> + public int OnOffStatus + { + get + { + //if (DeviceStatusReport != null && DeviceStatusReport.CluterID == 6) + //{ + // var attriButeList = DeviceStatusReport.AttriBute; + // foreach (var attriBute1 in attriButeList) + // { + // return attriBute1.AttriButeData; + // } + //} + return 0; + } + set + { + //if (DeviceStatusReport != null && DeviceStatusReport.CluterID == 6) + //{ + // var attriButeList = DeviceStatusReport.AttriBute; + // foreach (var attriBute1 in attriButeList) + // { + // attriBute1.AttriButeData = value; + // } + //} + } + } + #endregion + + #region json鏍煎紡锛屽彂鏁版嵁涓垪琛ㄦ湁鏁扮粍鐨勬儏鍐� + //public static void hdlButtonSetBind(ZigBee.Device.ZbGateway gateway, ZigBee.Device.HDLbutton.BindListDeviceInfo bindListObj, string buttonMacAddr, int epoint, int buttonMode, int buttonType) + //{ + // var jobject = new JObject { { "DeviceAddr", buttonMacAddr }, { "Epoint", epoint }, { "Cluster_ID", 64528 }, { "Command", 6 } }; + + // var bindList = new JArray{ + // new JObject {{ "BindType", bindListObj.BindType},{ "BindMacAddr", bindListObj.BindMacAddr},{ "BindEpoint", bindListObj.BindEpoint }} + // }; + // var data = new JObject { { "ButtonEpoint", epoint }, + // { "ButtonMode", buttonMode },{ "ButtonType", buttonType }, + // { "BindList", bindList } + // }; + + // jobject.Add("Data", data); + // gateway.Send(("hdlButton/SetBind"), Common.SecuritySet.Encryption((jobject.ToString()))); + //} + #endregion + + #region Int 涓巄yte鐨勮繍绠� + // 锛�1锛� + //int count = 5; + //int homeId = 112; + // byte[] byteHomeId = new byte[4]; + //for (int i = 0; i < byteHomeId.Length; i++) + //{ + // byteHomeId[i] = (byte)((homeId >> (i * 8)) & 0xFF); + //} + //byteHomeId[0] = (byte)((homeId >> 24) & 0xff);//H + //byteHomeId[1] = (byte)((homeId >> 16) & 0xff); + //byteHomeId[2] = (byte)((homeId >> 8) & 0xff); + //byteHomeId[3] = (byte)(homeId & 0xff);//L + + //锛�2锛夈�� + // int homeID = (bytes[7] & 0xff) << 24 | (bytes[8] & 0xff) << 16 | (bytes[9] & 0xff) << 8 | (bytes[10] & 0xff); + #endregion + + #region 杩涘害鏄剧ず + //Application.RunOnMainThread(() => + //{ + // int pro = (int)(index * 1.0 / backuplist.Count * 100); + // MainPage.Loading.Text = pro.ToString() + "%"; + //}; + #endregion + + /// <summary> + /// 鏂瑰紡涓�锛氫娇鐢╨ambda琛ㄨ揪寮忕瓫閫夎繃婊ゆ帀鏁扮粍涓┖瀛楃涓� + /// </summary> + /// <param name="args"></param> + static void FilterOutEmptyStrings1() + { + string[] strArray = { "", "111", "", "222", "", "333" }; + Console.WriteLine("杈撳嚭甯︽湁绌哄瓧绗︿覆鐨勬暟缁勶細"); + foreach (string str in strArray) + { + Console.WriteLine(str); + } + Console.WriteLine("-------------------------------------------"); + //浣跨敤lambda琛ㄨ揪寮忚繃婊ゆ帀绌哄瓧绗︿覆 + strArray = strArray.Where(s => !string.IsNullOrEmpty(s)).ToArray(); + Console.WriteLine("杈撳嚭杩囨护鎺夌┖瀛楃涓茬殑鏁扮粍锛�"); + foreach (string str in strArray) + { + Console.WriteLine(str); + } + Console.Read(); + } + + /// <summary> + /// 鏂瑰紡浜岋細浣跨敤娉涘瀷闆嗗悎List<string>鐨凢orEach寰幆,杩囨护鑾峰彇姝g‘鐨勫瓧绗︿覆锛岄噸鏂版坊鍔犲埌鏂板瓧绗︿覆鏁扮粍涓� + /// </summary> + /// <param name="args"></param> + public void FilterOutEmptyStrings2() + { + string[] strArray = { "", "111", "", "222", "", "333" }; + + /* + *浣跨敤List娉涘瀷闆嗗悎鐨凢orEach鏂规硶寰幆鑾峰彇闈炵┖绌哄瓧绗︿覆 + *杩欓噷浣跨敤浜嗗尶鍚嶆柟娉� + */ + var list = new System.Collections.Generic.List<string>(); + + strArray.ToList().ForEach( + (s) => + { + if (string.IsNullOrEmpty(s)) + { + list.Add(s); + } + }); + + foreach (string str in strArray) + { + Console.WriteLine(str); + } + Console.Read(); + } + + /// <summary> + /// 浣跨敤浼犵粺寰幆鏂瑰紡鏉ユ帓闄ゅ拰鍒犻櫎瀛楃涓叉暟缁勪腑鐨勭┖瀛楃涓� + /// </summary> + public void FilterOutEmptyStrings3() + { + string[] strArray = { "", "111", "", "222", "", "333" }; + Console.WriteLine("杈撳嚭甯︽湁绌哄瓧绗︿覆鐨勬暟缁勶細"); + foreach (string str in strArray) + { + Console.WriteLine(str); + } + Console.WriteLine("-------------------------------------------"); + + //浣跨敤寰幆鎺掗櫎鍜岃繃婊ゆ帀绌哄瓧绗︿覆 + var list = new System.Collections.Generic.List<string>(); + foreach (string s in strArray) + { + if (!string.IsNullOrEmpty(s)) + { + list.Add(s); + } + } + strArray = list.ToArray(); + + Console.WriteLine("杈撳嚭杩囨护鎺夌┖瀛楃涓茬殑鏁扮粍锛�"); + foreach (string str in strArray) + { + Console.WriteLine(str); + } + Console.Read(); + } + + #region &GPS浣嶇疆鍙樺寲浜嬩欢 + /// <summary>鈥� /// GPS浣嶇疆鍙樺寲浜嬩欢鈥� /// </summary> + //public static Action<double, double> LocationAction; + //LocationAction = (arg1, arg2) => { + // LocationAction = null; + // System.Threading.Tasks.Task.Run(() => { + // while (true) { + // try { + // Shared.SimpleControl.CommonPage.AirQuality = new service.hdlcontrol.com_WebServiceAirQuality.WebServiceAirQuality().GetAirQuality(arg2.ToString (), arg1.ToString ()); + // if (Shared.SimpleControl.CommonPage.AirQuality != null) + // break; + // } catch { } + // } + // Shared.Application.RunOnMainThread(() => { + // if (CommonPage.RefreshAir != null) + // CommonPage.RefreshAir(); + // } ); + // } ); + //} ; + #endregion + + #region 鐢佃瘽鍙风爜鍐欐硶 + // EditText etPhoneNumber = new EditText() + // { + // X = btnPhoneZone.Right + Application.GetRealWidth(10), + // Width = Application.GetRealWidth(410), + // TextAlignment = TextAlignment.Center, + // }; + // phoneNumView.AddChidren(etPhoneNumber); + + //etPhoneNumber.TextChangeEventHandler += (sender, e) => { + // if (e.Length > 11) + // { + // etPhoneNumber.Text = e.Remove(11); + // } + // else if (e.Length == 11) + // { + // var reg = new Regex("^[1]+[3,5,7,8]+\\d{9}"); + // var mFalg = reg.Match(etPhoneNumber.Text.Trim()); + // if (mFalg.Success) + // { + // btnNext.IsSelected = btnNext.Enable = true; + // } + // else + // { + // new Tip() { CloseTime = 3, Text = "鍙风爜閿欒", Direction = AMPopTipDirection.Down } .Show(etPhoneNumber); + + // } + // } + // else if (e.Length< 11) + // { + // btnNext.IsSelected = btnNext.Enable = false; + // } + //} ; + #endregion + + #region 杩涘害鏄剧ず + #endregion + } +} -- Gitblit v1.8.0