From 358044c907e0e492b26377b21ca5091d19b503c8 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期二, 30 十一月 2021 09:58:59 +0800
Subject: [PATCH] 合并wjc
---
HDL-ON_Android/HDL-ON_Android.csproj | 3
HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs | 605 +++---
/dev/null | 0
HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs | 1838 ++++++++++----------
HDL_ON/UI/UI2/3-Intelligence/Automation/Send.cs | 759 ++++----
HDL_ON/UI/UI2/FuntionControlView/ArmCenter/AddOutputPage.cs | 463 ++++
HDL_ON/UI/MainPage.cs | 825 ++++----
HDL-ON_Android/Application.cs | 716 ++++----
HDL_ON/UI/UI2/3-Intelligence/Automation/WeatherCondition.cs | 3
9 files changed, 2,818 insertions(+), 2,394 deletions(-)
diff --git a/HDL-ON_Android/Application.cs b/HDL-ON_Android/Application.cs
index 52059fc..b2261ff 100644
--- a/HDL-ON_Android/Application.cs
+++ b/HDL-ON_Android/Application.cs
@@ -18,392 +18,400 @@
namespace HDL_ON_Android
{
- /// <summary>
- /// 璁惧畾涓洪粯璁ゅ惎鍔ㄧ殑Application
- /// </summary>
- [Android.App.Application]
- public class Application : Android.App.Application, Android.App.Application.IActivityLifecycleCallbacks
+ /// <summary>
+ /// 璁惧畾涓洪粯璁ゅ惎鍔ㄧ殑Application
+ /// </summary>
+ [Android.App.Application]
+ public class Application : Android.App.Application, Android.App.Application.IActivityLifecycleCallbacks
+ {
+ static void reStartApp(Android.App.Application application)
{
- static void reStartApp(Android.App.Application application)
- {
- var intent = new Intent(application, typeof(BaseActivity));
- intent.AddFlags(ActivityFlags.NewTask);
- application.StartActivity(intent);
- Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
- }
+ var intent = new Intent(application, typeof(BaseActivity));
+ intent.AddFlags(ActivityFlags.NewTask);
+ application.StartActivity(intent);
+ Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
+ }
- public Application(IntPtr handle, Android.Runtime.JniHandleOwnership ownerShip) : base(handle, ownerShip) { }
- public override void OnCreate()
- {
- //娉ㄥ唽鏈鐞嗗紓甯镐簨浠�
- AppCenter.Start("64ac5859-2cd7-4ef8-a5da-5455e29679ec", typeof(Analytics), typeof(Crashes));
- if (Shared.Application.Activity != null)
- {
- reStartApp(this);
- return;
- }
+ public Application(IntPtr handle, Android.Runtime.JniHandleOwnership ownerShip) : base(handle, ownerShip) { }
+ public override void OnCreate()
+ {
+ //娉ㄥ唽鏈鐞嗗紓甯镐簨浠�
+ AppCenter.Start("64ac5859-2cd7-4ef8-a5da-5455e29679ec", typeof(Analytics), typeof(Crashes));
+ if (Shared.Application.Activity != null)
+ {
+ reStartApp(this);
+ return;
+ }
- base.OnCreate();
- RegisterActivityLifecycleCallbacks(this);
+ base.OnCreate();
+ RegisterActivityLifecycleCallbacks(this);
- initAll();
+ initAll();
- }
+ }
- /// <summary>
- /// 鎵�鏈夊垵濮嬪寲鍏ㄩ儴鍦ㄨ繖涓柟娉曞疄鐜�
- /// </summary>
- void initAll()
- {
+ /// <summary>
+ /// 鎵�鏈夊垵濮嬪寲鍏ㄩ儴鍦ㄨ繖涓柟娉曞疄鐜�
+ /// </summary>
+ void initAll()
+ {
- string[] permissions = new string[] { Manifest.Permission.WriteExternalStorage, Manifest.Permission.RecordAudio,
+ string[] permissions = new string[] { Manifest.Permission.WriteExternalStorage, Manifest.Permission.RecordAudio,
Manifest.Permission.Camera, Manifest.Permission.ProcessOutgoingCalls, Manifest.Permission.GetAccounts};
- //绂佹灞忓箷闀夸寒
- BaseActivity.KeepScreenON = false;
- //闅愯棌铏氭嫙鎸夐敭
- BaseActivity.IsHideVirualButtons = true;
- //瀹炵幇瀹夊崜杩斿洖鎸夐敭
- BaseActivity.BackKeyAction = () =>
- {
- try
- {
- var result = MainPage.LoadEvent_BackAction();
- switch (result)
- {
- case 0:
- break;
- case 1:
- case 2:
- BaseActivity.VerifyDateTime = DateTime.MaxValue;
- break;
- default:
- BaseActivity.VerifyDateTime = DateTime.MaxValue;
- break;
- }
- }
- catch (Exception ex)
- {
- MainPage.Log(ex.Message);
- BaseActivity.VerifyDateTime = DateTime.MaxValue;
- }
- };
-
- init();
- BaseActivity.OnCreateActoin += (activity, application) =>
- {
- Language.CurrentLanguage = "Chinese";
- Locale locale1 = Locale.Default;
- var localeList = Resources.Configuration.Locale;
- if (localeList.Language == "zh")
- {
- Language.CurrentLanguage = "Chinese";
- }
- else
- {
- Language.CurrentLanguage = "English";
- }
- //鑾峰彇鏋佸厜鎺ㄩ�両D
- GetJPushRegistrationID(activity);
-
- BaseActivity.NetworkStateChanged += (int internetStatus) =>
- {
- //if (!IsEnterBackground)
- //{
- // ////BusSocket.Stop();
- // //new System.Threading.Thread(() =>
- // //{
- // // System.Threading.Thread.Sleep(1000);
- // // //BusSocket.Start();
- // //})
- // //{ IsBackground = true }.Start();
-
- //}
- //else
- //{
- // Console.WriteLine("HHH 缃戠粶鍙樺寲浣嗗浜庡悗鍙�");
- //}
-
- //缃戠粶鍙樺寲澶勭悊
- HDLCommon.Current.UpdateInternetStatus((int)internetStatus, MainPage.IsEnterBackground);
- };
- };
- BaseActivity.RefreshUIAction += (activity) =>
- {
- MainPage.Show();
- checkSomeInfo();
- };
- BaseActivity.OnResumeAction += (activity) =>
- {
- checkSomeInfo();
- };
- BaseActivity.OnDestroyAction += (activity) =>
- {
- Console.WriteLine("OnDestroyAction");
- //BusSocket.Stop();
- //UserInfo.Current.unlockTime = DateTime.Now;
- };
-
-
- HDLUtils.SetAuthoritiesName("com.hdl.onpro.fileProvider");
-
- //Shared.Application.IsGpsEnable = true;
- //鑾峰彇缁忕含搴�
- Shared.Application.LocationAction = (lon, lat) =>
- {
- try
- {
- Shared.Application.LocationAction = null;
- new HDL_ON.DAL.Server.HttpServerRequest().GetCityWeatherInfo(lon.ToString(), lat.ToString());
- //鍏抽棴瀹氫綅鏈嶅姟
- Shared.Application.StopGPSLocationService();
- }
- catch (Exception ex)
- {
- Utlis.WriteLine("GetCityInfo catch" + ex.Message);
- }
- MainPage.Log($"缁忕含搴�:::{lon}:{lat}");
- };
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="activity"></param>
- void GetJPushRegistrationID(BaseActivity activity)
+ //绂佹灞忓箷闀夸寒
+ BaseActivity.KeepScreenON = false;
+ //闅愯棌铏氭嫙鎸夐敭
+ BaseActivity.IsHideVirualButtons = true;
+ //瀹炵幇瀹夊崜杩斿洖鎸夐敭
+ BaseActivity.BackKeyAction = () =>
+ {
+ try
{
- try
- {
- //淇濆瓨鑾峰彇鐨勬瀬鍏夋湇鍔″櫒涓婄殑娉ㄥ唽ID鍒版湰鍦版枃浠�
- var tokenID = JPushInterface.GetRegistrationID(activity);
- Console.WriteLine("RegistrationID: " + tokenID);
- if (!string.IsNullOrEmpty(tokenID) && OnAppConfig.Instance.PushDeviceToken != tokenID)
- {
- OnAppConfig.Instance.PushDeviceToken = tokenID;
- OnAppConfig.Instance.PhoneName = Android.OS.Build.Manufacturer;
- OnAppConfig.Instance.SaveConfig();
- }
- int loadTokenCount = 0;
- System.Threading.Tasks.Task.Run(() =>
- {
- while (string.IsNullOrEmpty(tokenID))
- {
- System.Threading.Thread.Sleep(1000);
- tokenID = JPushInterface.GetRegistrationID(activity);
- Console.WriteLine("Sleep.tokenID + " + JPushInterface.GetRegistrationID(activity));
- loadTokenCount++;
- if (loadTokenCount > 30)
- {
- break;
- }
- }
- Console.WriteLine("RegistrationID: " + tokenID);
- if (!string.IsNullOrEmpty(tokenID) && OnAppConfig.Instance.PushDeviceToken != tokenID)
- {
- OnAppConfig.Instance.PushDeviceToken = tokenID;
- OnAppConfig.Instance.PhoneName = Android.OS.Build.Manufacturer;
- OnAppConfig.Instance.SaveConfig();
- }
- });
+ var result = MainPage.LoadEvent_BackAction();
+ switch (result)
+ {
+ case 0:
+ break;
+ case 1:
+ case 2:
+ BaseActivity.VerifyDateTime = DateTime.MaxValue;
+ break;
+ default:
+ BaseActivity.VerifyDateTime = DateTime.MaxValue;
+ break;
+ }
+ }
+ catch (Exception ex)
+ {
+ MainPage.Log(ex.Message);
+ BaseActivity.VerifyDateTime = DateTime.MaxValue;
+ }
+ };
+ init();
+ BaseActivity.OnCreateActoin += (activity, application) =>
+ {
+ Language.CurrentLanguage = "Chinese";
+ Locale locale1 = Locale.Default;
+ var localeList = Resources.Configuration.Locale;
+ if (localeList.Language == "zh")
+ {
+ Language.CurrentLanguage = "Chinese";
+ }
+ else
+ {
+ Language.CurrentLanguage = "English";
+ }
+ //鑾峰彇鏋佸厜鎺ㄩ�両D
+ GetJPushRegistrationID(activity);
+
+ BaseActivity.NetworkStateChanged += (int internetStatus) =>
+ {
+ //if (!IsEnterBackground)
+ //{
+ // ////BusSocket.Stop();
+ // //new System.Threading.Thread(() =>
+ // //{
+ // // System.Threading.Thread.Sleep(1000);
+ // // //BusSocket.Start();
+ // //})
+ // //{ IsBackground = true }.Start();
+
+ //}
+ //else
+ //{
+ // Console.WriteLine("HHH 缃戠粶鍙樺寲浣嗗浜庡悗鍙�");
+ //}
+
+ //缃戠粶鍙樺寲澶勭悊
+ HDLCommon.Current.UpdateInternetStatus((int)internetStatus, MainPage.IsEnterBackground);
+ };
+ };
+ BaseActivity.RefreshUIAction += (activity) =>
+ {
+ MainPage.Show();
+ checkSomeInfo();
+ };
+ BaseActivity.OnResumeAction += (activity) =>
+ {
+ checkSomeInfo();
+ };
+ BaseActivity.OnDestroyAction += (activity) =>
+ {
+ Console.WriteLine("OnDestroyAction");
+ //BusSocket.Stop();
+ //UserInfo.Current.unlockTime = DateTime.Now;
+ };
+
+
+ HDLUtils.SetAuthoritiesName("com.hdl.onpro.fileProvider");
+
+ //Shared.Application.IsGpsEnable = true;
+ bool isfirst = true;
+ //鑾峰彇缁忕含搴�
+ Shared.Application.LocationAction = (lon, lat) =>
+ {
+ try
+ {
+ if (isfirst)
+ {
+ //鍙Е鍙戜竴娆�
+ //Shared.Application.LocationAction = null;
+ new HDL_ON.DAL.Server.HttpServerRequest().GetCityWeatherInfo(lon.ToString(), lat.ToString());
+ }
+ isfirst = false;
+ ///鐩戝惉缁忕含搴�
+ HDL_ON.UI.UI2.Intelligence.Automation.LogicMethod.CurrLogicMethod.AppLatAndLonEvent(lon, lat);
+ //鍏抽棴瀹氫綅鏈嶅姟
+ //Shared.Application.StopGPSLocationService();
+ }
+ catch (Exception ex)
+ {
+ Utlis.WriteLine("GetCityInfo catch" + ex.Message);
+ }
+ MainPage.Log($"缁忕含搴�:::{lon}:{lat}");
+ };
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="activity"></param>
+ void GetJPushRegistrationID(BaseActivity activity)
+ {
+ try
+ {
+ //淇濆瓨鑾峰彇鐨勬瀬鍏夋湇鍔″櫒涓婄殑娉ㄥ唽ID鍒版湰鍦版枃浠�
+ var tokenID = JPushInterface.GetRegistrationID(activity);
+ Console.WriteLine("RegistrationID: " + tokenID);
+ if (!string.IsNullOrEmpty(tokenID) && OnAppConfig.Instance.PushDeviceToken != tokenID)
+ {
+ OnAppConfig.Instance.PushDeviceToken = tokenID;
+ OnAppConfig.Instance.PhoneName = Android.OS.Build.Manufacturer;
+ OnAppConfig.Instance.SaveConfig();
+ }
+ int loadTokenCount = 0;
+ System.Threading.Tasks.Task.Run(() =>
+ {
+ while (string.IsNullOrEmpty(tokenID))
+ {
+ System.Threading.Thread.Sleep(1000);
+ tokenID = JPushInterface.GetRegistrationID(activity);
+ Console.WriteLine("Sleep.tokenID + " + JPushInterface.GetRegistrationID(activity));
+ loadTokenCount++;
+ if (loadTokenCount > 30)
+ {
+ break;
}
- catch
- {
+ }
+ Console.WriteLine("RegistrationID: " + tokenID);
+ if (!string.IsNullOrEmpty(tokenID) && OnAppConfig.Instance.PushDeviceToken != tokenID)
+ {
+ OnAppConfig.Instance.PushDeviceToken = tokenID;
+ OnAppConfig.Instance.PhoneName = Android.OS.Build.Manufacturer;
+ OnAppConfig.Instance.SaveConfig();
+ }
+ });
- }
- }
+ }
+ catch
+ {
- public static bool IsShowTip = true;
- void init()
+ }
+ }
+
+ public static bool IsShowTip = true;
+ void init()
+ {
+ //鎵嬫満鍚嶇О Android.OS.Build.Manufacturer;
+ //OnAppConfig.Instance.PhoneName = Android.OS.Build.Manufacturer;
+ //#if DEBUG
+ //CN.Jpush.Android.Api.JPushInterface.SetDebugMode(true);
+ //#endif
+ CN.Jpush.Android.Api.JPushInterface.Init(this);
+
+ }
+ void checkSomeInfo()
+ {
+ try
+ {
+ IsShowTip = true;
+ var status = isNetworkAvailable(this);
+ int internetStatus = 0;
+ if (!status)
{
- //鎵嬫満鍚嶇О Android.OS.Build.Manufacturer;
- //OnAppConfig.Instance.PhoneName = Android.OS.Build.Manufacturer;
- //#if DEBUG
- //CN.Jpush.Android.Api.JPushInterface.SetDebugMode(true);
- //#endif
- CN.Jpush.Android.Api.JPushInterface.Init(this);
-
+ internetStatus = 0;
}
- void checkSomeInfo()
+
+ var isWifi = isWifiConnected(this);
+ if (isWifi)
{
- try
- {
- IsShowTip = true;
- var status = isNetworkAvailable(this);
- int internetStatus = 0;
- if (!status)
- {
- internetStatus = 0;
- }
-
- var isWifi = isWifiConnected(this);
- if (isWifi)
- {
- internetStatus = 2;
- }
- else
- {
- internetStatus = 1;
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine($"android check some info erorr : {ex.Message}");
- }
+ internetStatus = 2;
}
-
- bool isNetworkAvailable(Context context)
+ else
{
- var cm = (ConnectivityManager)context.GetSystemService(ConnectivityService);
- if (cm == null || cm.ActiveNetworkInfo == null)
- {
- return false;
- }
- else
- {
- return cm.ActiveNetworkInfo.IsAvailable;
- }
+ internetStatus = 1;
}
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"android check some info erorr : {ex.Message}");
+ }
+ }
- bool isWifiConnected(Context context)
+ bool isNetworkAvailable(Context context)
+ {
+ var cm = (ConnectivityManager)context.GetSystemService(ConnectivityService);
+ if (cm == null || cm.ActiveNetworkInfo == null)
+ {
+ return false;
+ }
+ else
+ {
+ return cm.ActiveNetworkInfo.IsAvailable;
+ }
+ }
+
+ bool isWifiConnected(Context context)
+ {
+ if (context != null)
+ {
+ var mConnectivityManager = (ConnectivityManager)context.GetSystemService
+ (ConnectivityService);
+ var mWiFiNetworkInfo = mConnectivityManager.GetNetworkInfo(ConnectivityType.Wifi);
+ if (mWiFiNetworkInfo != null)
{
- if (context != null)
- {
- var mConnectivityManager = (ConnectivityManager)context.GetSystemService
- (ConnectivityService);
- var mWiFiNetworkInfo = mConnectivityManager.GetNetworkInfo(ConnectivityType.Wifi);
- if (mWiFiNetworkInfo != null)
- {
- return mWiFiNetworkInfo.IsAvailable;
- }
- }
- return false;
+ return mWiFiNetworkInfo.IsAvailable;
}
+ }
+ return false;
+ }
- public void OnActivityCreated(Activity activity, Bundle savedInstanceState)
+ public void OnActivityCreated(Activity activity, Bundle savedInstanceState)
+ {
+
+ }
+
+ public void OnActivityDestroyed(Activity activity)
+ {
+ //throw new NotImplementedException ();
+ }
+
+ public void OnActivityPaused(Activity activity)
+ {
+ //throw new NotImplementedException ();
+ }
+
+ public void OnActivityResumed(Activity activity)
+ {
+ //throw new NotImplementedException ();
+ }
+
+ public void OnActivitySaveInstanceState(Activity activity, Bundle outState)
+ {
+ //throw new NotImplementedException ();
+ }
+
+ public void OnActivityStarted(Activity activity)
+ {
+ //throw new NotImplementedException ();
+
+ mCount++;
+ if (mCount == 1)
+ {
+ Console.WriteLine("HHH OnActivityStarted锛歠oreground");
+ BusSocketStart();
+ //鍚庡彴鍥炲埌鍓嶅彴
+ new HDL_ON.UI.AppUnlockPage().LoadPage();
+ }
+ }
+
+ public void OnActivityStopped(Activity activity)
+ {
+
+ mCount--;
+ if (mCount == 0)
+ {
+ Console.WriteLine("HHH OnActivityStopped锛� background");
+ BusSocketStop();
+ //杩涘叆鍚庡彴
+ UserInfo.Current.unlockTime = DateTime.Now;
+
+ }
+ }
+
+
+ public override void OnTerminate()
+ {
+ base.OnTerminate();
+ UnregisterActivityLifecycleCallbacks(this);
+ }
+
+ int mCount;
+
+ ///// <summary>
+ ///// 鏄惁杩涘叆鍚庡彴
+ ///// </summary>
+ //public bool IsEnterBackground = false;
+
+ /// <summary>
+ /// 杩涘叆鍚庡彴鐨勬椂闂�
+ /// </summary>
+ DateTime CloseTime = DateTime.Now;
+
+ /// <summary>
+ /// BusSocketStop
+ /// </summary>
+ void BusSocketStop()
+ {
+ //IsEnterBackground = true;
+ CloseTime = DateTime.Now;
+ MainPage.IsEnterBackground = true;
+ //杩涘叆鍚庡彴mqtt姝e湪杩炴帴閲嶇疆鐘舵��
+ HDL_ON.DAL.Mqtt.MqttClient.RemoteMqttIsConnecting = false;
+ HDL_ON.DriverLayer.UdpSocket._BusSocket.Stop();
+
+ }
+
+ /// <summary>
+ /// BusSocketStart
+ /// </summary>
+ void BusSocketStart()
+ {
+ //IsEnterBackground = false;
+
+ if (CloseTime.AddSeconds(10) < DateTime.Now)
+ {
+ //鍚庡彴瓒呰繃10s灏辨柇寮�MQTT閲嶈繛
+ //if (HDL_ON.DriverLayer.Control.Ins.IsRemote)
{
-
+ HDL_ON.DAL.Mqtt.MqttClient.DisConnectRemote("closeTime", false);
}
+ }
- public void OnActivityDestroyed(Activity activity)
- {
- //throw new NotImplementedException ();
- }
+ MainPage.IsEnterBackground = false;
+ HDL_ON.DriverLayer.UdpSocket._BusSocket.Start();
+ HDL_ON.DriverLayer.Control.Ins.SearchLoaclGateway();
+ }
- public void OnActivityPaused(Activity activity)
- {
- //throw new NotImplementedException ();
- }
+ protected override void Dispose(bool disposing)
+ {
+ base.Dispose(disposing);
+ }
- public void OnActivityResumed(Activity activity)
- {
- //throw new NotImplementedException ();
- }
-
- public void OnActivitySaveInstanceState(Activity activity, Bundle outState)
- {
- //throw new NotImplementedException ();
- }
-
- public void OnActivityStarted(Activity activity)
- {
- //throw new NotImplementedException ();
-
- mCount++;
- if (mCount == 1)
- {
- Console.WriteLine("HHH OnActivityStarted锛歠oreground");
- BusSocketStart();
- //鍚庡彴鍥炲埌鍓嶅彴
- new HDL_ON.UI.AppUnlockPage().LoadPage();
- }
- }
-
- public void OnActivityStopped(Activity activity)
- {
-
- mCount--;
- if (mCount == 0)
- {
- Console.WriteLine("HHH OnActivityStopped锛� background");
- BusSocketStop();
- //杩涘叆鍚庡彴
- UserInfo.Current.unlockTime = DateTime.Now;
-
- }
- }
-
-
- public override void OnTerminate()
- {
- base.OnTerminate();
- UnregisterActivityLifecycleCallbacks(this);
- }
-
- int mCount;
-
- ///// <summary>
- ///// 鏄惁杩涘叆鍚庡彴
- ///// </summary>
- //public bool IsEnterBackground = false;
-
- /// <summary>
- /// 杩涘叆鍚庡彴鐨勬椂闂�
- /// </summary>
- DateTime CloseTime = DateTime.Now;
-
- /// <summary>
- /// BusSocketStop
- /// </summary>
- void BusSocketStop()
- {
- //IsEnterBackground = true;
- CloseTime = DateTime.Now;
- MainPage.IsEnterBackground = true;
- //杩涘叆鍚庡彴mqtt姝e湪杩炴帴閲嶇疆鐘舵��
- HDL_ON.DAL.Mqtt.MqttClient.RemoteMqttIsConnecting = false;
- HDL_ON.DriverLayer.UdpSocket._BusSocket.Stop();
-
- }
-
- /// <summary>
- /// BusSocketStart
- /// </summary>
- void BusSocketStart()
- {
- //IsEnterBackground = false;
-
- if (CloseTime.AddSeconds(10) < DateTime.Now)
- {
- //鍚庡彴瓒呰繃10s灏辨柇寮�MQTT閲嶈繛
- //if (HDL_ON.DriverLayer.Control.Ins.IsRemote)
- {
- HDL_ON.DAL.Mqtt.MqttClient.DisConnectRemote("closeTime", false);
- }
- }
-
- MainPage.IsEnterBackground = false;
- HDL_ON.DriverLayer.UdpSocket._BusSocket.Start();
- HDL_ON.DriverLayer.Control.Ins.SearchLoaclGateway();
- }
-
- protected override void Dispose(bool disposing)
- {
- base.Dispose(disposing);
- }
-
- /// <summary>
- /// 鏌ヨ閫氱煡鏉冮檺锛屽苟鎻愮ず
- /// </summary>
- public void QueryNotificationPermission()
- {
-
-
- }
-
+ /// <summary>
+ /// 鏌ヨ閫氱煡鏉冮檺锛屽苟鎻愮ず
+ /// </summary>
+ public void QueryNotificationPermission()
+ {
}
+
+
+ }
+
}
diff --git a/HDL-ON_Android/HDL-ON_Android.csproj b/HDL-ON_Android/HDL-ON_Android.csproj
index 57f2aa5..8a796a6 100644
--- a/HDL-ON_Android/HDL-ON_Android.csproj
+++ b/HDL-ON_Android/HDL-ON_Android.csproj
@@ -33,7 +33,6 @@
<DefineConstants>DEBUG;TRACE;__Android__</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
- <EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
<MandroidI18n>cjk</MandroidI18n>
<AndroidDexTool>d8</AndroidDexTool>
<AndroidEnableSGenConcurrent>false</AndroidEnableSGenConcurrent>
@@ -62,7 +61,7 @@
<AndroidEnableSGenConcurrent>false</AndroidEnableSGenConcurrent>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
<AndroidKeyStore>True</AndroidKeyStore>
- <AndroidSigningKeyStore>/Users/kaede/Desktop/HDL_APP_Project/on_plus.keystore</AndroidSigningKeyStore>
+ <AndroidSigningKeyStore>/Users/hdl/Desktop/on_plus/on_plus.keystore</AndroidSigningKeyStore>
<AndroidSigningStorePass>85521566</AndroidSigningStorePass>
<AndroidSigningKeyPass>85521566</AndroidSigningKeyPass>
<AndroidSigningKeyAlias>on_plus</AndroidSigningKeyAlias>
diff --git a/HDL_ON/UI/MainPage.cs b/HDL_ON/UI/MainPage.cs
index ca75597..043eafc 100644
--- a/HDL_ON/UI/MainPage.cs
+++ b/HDL_ON/UI/MainPage.cs
@@ -8,86 +8,86 @@
namespace HDL_ON
{
- public static class MainPage
+ public static class MainPage
+ {
+
+ /// <summary>
+ /// BaseView
+ /// </summary>
+ public static FrameLayout BaseView { get; internal set; }
+ /// <summary>
+ /// BasePageView
+ /// </summary>
+ public static PageLayout BasePageView { get; set; }
+ /// <summary>
+ /// 鐢ㄦ埛鎺у埗鐖跺鍣�
+ /// </summary>
+ public static UserPage UserBasePage;
+ /// <summary>
+ /// 鐗堟湰鍙�
+ /// </summary>
+ public static string VersionString = "1.3.1123";
+ ///// <summary>
+ ///// 瀹㈡埛绔被鍨�
+ ///// </summary>
+ //public static string ClientType = APIClientType.HDL_ON_PRO.ToString();
+
+ /// <summary>
+ ///
+ /// </summary>
+ public static Entity.CityInfo cityInfo = new Entity.CityInfo();
+ /// <summary>
+ /// 澶╂皵鍒锋柊action
+ /// </summary>
+ public static Action RefreshAir;
+ /// <summary>
+ /// 鍥為��椤甸潰action 娌℃湁闇�瑕佸彲浠ヤ笉鐢�
+ /// </summary>
+ public static Action ReturnRefreshAction;
+ /// <summary>
+ /// 鏃犵櫥褰曟ā寮�
+ /// </summary>
+ public static bool NoLoginMode = false;
+ /// <summary>
+ /// 缃戠粶杩炴帴鐘舵��
+ /// 0:鏃犵綉缁�
+ /// </summary>
+ public static int InternetStatus = 2;
+ /// <summary>
+ /// 鏄惁杩涘叆鍚庡彴
+ /// </summary>
+ public static bool IsEnterBackground = false;
+ /// <summary>
+ /// 褰撳墠鍒嗛〉绱㈠紩
+ /// 0:鏀惰棌
+ /// 1:鍒嗙被
+ /// 2:鏅鸿兘
+ /// 3:涓汉
+ /// </summary>
+ public static int CurPageIndex = 9999;
+
+ ///// <summary>
+ ///// 鍏徃浠g爜
+ ///// 棰勭暀绗笁鏂瑰畾鍒舵爣璁�
+ ///// 0:HDL
+ ///// </summary>
+ //public static int Company = 0;
+
+ /// <summary>
+ /// 鍙虫粦鍚庨��鎻愮ず鎸夐挳
+ /// </summary>
+ public static Button BtnBackIcon;
+ /// <summary>
+ /// 鍚庨��鍙虫粦浜嗗灏戣窛绂伙紝瓒呰繃涓�瀹氳窛绂绘墠瑙﹀彂鍚庨��浜嬩欢
+ /// </summary>
+ public static int StartX = 0;
+ /// <summary>
+ /// 鏄惁鍏ㄩ潰灞忔墜鏈�
+ /// </summary>
+ public static bool Increase
{
-
- /// <summary>
- /// BaseView
- /// </summary>
- public static FrameLayout BaseView { get; internal set; }
- /// <summary>
- /// BasePageView
- /// </summary>
- public static PageLayout BasePageView { get; set; }
- /// <summary>
- /// 鐢ㄦ埛鎺у埗鐖跺鍣�
- /// </summary>
- public static UserPage UserBasePage;
- /// <summary>
- /// 鐗堟湰鍙�
- /// </summary>
- public static string VersionString = "1.3.1123";
- ///// <summary>
- ///// 瀹㈡埛绔被鍨�
- ///// </summary>
- //public static string ClientType = APIClientType.HDL_ON_PRO.ToString();
-
- /// <summary>
- ///
- /// </summary>
- public static Entity.CityInfo cityInfo = new Entity.CityInfo();
- /// <summary>
- /// 澶╂皵鍒锋柊action
- /// </summary>
- public static Action RefreshAir;
- /// <summary>
- /// 鍥為��椤甸潰action 娌℃湁闇�瑕佸彲浠ヤ笉鐢�
- /// </summary>
- public static Action ReturnRefreshAction;
- /// <summary>
- /// 鏃犵櫥褰曟ā寮�
- /// </summary>
- public static bool NoLoginMode = false;
- /// <summary>
- /// 缃戠粶杩炴帴鐘舵��
- /// 0:鏃犵綉缁�
- /// </summary>
- public static int InternetStatus = 2;
- /// <summary>
- /// 鏄惁杩涘叆鍚庡彴
- /// </summary>
- public static bool IsEnterBackground = false;
- /// <summary>
- /// 褰撳墠鍒嗛〉绱㈠紩
- /// 0:鏀惰棌
- /// 1:鍒嗙被
- /// 2:鏅鸿兘
- /// 3:涓汉
- /// </summary>
- public static int CurPageIndex = 9999;
-
- ///// <summary>
- ///// 鍏徃浠g爜
- ///// 棰勭暀绗笁鏂瑰畾鍒舵爣璁�
- ///// 0:HDL
- ///// </summary>
- //public static int Company = 0;
-
- /// <summary>
- /// 鍙虫粦鍚庨��鎻愮ず鎸夐挳
- /// </summary>
- public static Button BtnBackIcon;
- /// <summary>
- /// 鍚庨��鍙虫粦浜嗗灏戣窛绂伙紝瓒呰繃涓�瀹氳窛绂绘墠瑙﹀彂鍚庨��浜嬩欢
- /// </summary>
- public static int StartX = 0;
- /// <summary>
- /// 鏄惁鍏ㄩ潰灞忔墜鏈�
- /// </summary>
- public static bool Increase
- {
- get
- {
+ get
+ {
#if __IOS__
if (Application.PhoneType>10)
{
@@ -95,15 +95,15 @@
}
return false;
#else
- return false;
+ return false;
#endif
- }
- }
+ }
+ }
- /// <summary>
- /// 鍦烘櫙鏀寔鐨勫姛鑳藉垪琛�
- /// </summary>
- public static List<string> SceneSupportFunctionList = new List<string> {
+ /// <summary>
+ /// 鍦烘櫙鏀寔鐨勫姛鑳藉垪琛�
+ /// </summary>
+ public static List<string> SceneSupportFunctionList = new List<string> {
SPK.LightCCT,SPK.LightDimming,SPK.LightSwitch,SPK.LightRGB,
SPK.CurtainRoller,SPK.CurtainSwitch,SPK.CurtainTrietex,
SPK.AcIr,SPK.AcStandard,SPK.HvacAC,
@@ -114,350 +114,353 @@
};
- static List<string> _RoomNotSupportFunctionList = null;
- /// <summary>
- /// 鎴块棿鍔熻兘鍒楄〃涓嶅姞杞界殑鍔熻兘鍒楄〃
- /// </summary>
- public static List<string> RoomNotSupportFunctionList
+ static List<string> _RoomNotSupportFunctionList = null;
+ /// <summary>
+ /// 鎴块棿鍔熻兘鍒楄〃涓嶅姞杞界殑鍔熻兘鍒楄〃
+ /// </summary>
+ public static List<string> RoomNotSupportFunctionList
+ {
+ get
+ {
+ if (_RoomNotSupportFunctionList == null)
{
- get {
- if(_RoomNotSupportFunctionList == null)
- {
- _RoomNotSupportFunctionList = new List<string>();
- _RoomNotSupportFunctionList.Add(SPK.EnergyStandard);
- _RoomNotSupportFunctionList.Add(SPK.MusicStandard);
- _RoomNotSupportFunctionList.Add(SPK.AvMusic);
- _RoomNotSupportFunctionList.Add(SPK.AirSwitch);
- _RoomNotSupportFunctionList.Add(SPK.ElectricEnergy);
- _RoomNotSupportFunctionList.AddRange(SPK.EnvironDeviceSpkList());
- _RoomNotSupportFunctionList.AddRange(SPK.ArmSensorSpkList());
- }
- return _RoomNotSupportFunctionList;
- }
+ _RoomNotSupportFunctionList = new List<string>();
+ _RoomNotSupportFunctionList.Add(SPK.EnergyStandard);
+ _RoomNotSupportFunctionList.Add(SPK.MusicStandard);
+ _RoomNotSupportFunctionList.Add(SPK.AvMusic);
+ _RoomNotSupportFunctionList.Add(SPK.AirSwitch);
+ _RoomNotSupportFunctionList.Add(SPK.ElectricEnergy);
+ _RoomNotSupportFunctionList.AddRange(SPK.EnvironDeviceSpkList());
+ _RoomNotSupportFunctionList.AddRange(SPK.ArmSensorSpkList());
}
+ return _RoomNotSupportFunctionList;
+ }
+ }
- public static void Show()
+ public static void Show()
+ {
+ try
+ {
+ Application.DesignWidth = 375;
+ Application.DesignHeight = 667;
+
+ BaseView = Application.MainPage;
+ Application.MainPage.BackgroundColor = CSS_Color.MainBackgroundColor;
+ //#region 娴嬭瘯
+ //var ddd = new UI.test.TestDialog();
+ //ddd.InitView();
+ //return;
+ //#endregion
+
+ if (string.IsNullOrEmpty(OnAppConfig.Instance.LastLoginUserId))
{
- try
- {
- Application.DesignWidth = 375;
- Application.DesignHeight = 667;
-
- BaseView = Application.MainPage;
- Application.MainPage.BackgroundColor = CSS_Color.MainBackgroundColor;
- ///鐩戝惉缁忕含搴�
- HDL_ON.UI.UI2.Intelligence.Automation.LogicMethod.CurrLogicMethod.AppLatAndLonEvent();
-
- //#region 娴嬭瘯
- //var ddd = new UI.test.TestDialog();
- //ddd.InitView();
- //return;
- //#endregion
-
- if (string.IsNullOrEmpty(OnAppConfig.Instance.LastLoginUserId))
- {
- GoLoginPage();
- }
- else
- {
- //鍒ゆ柇闇�涓嶉渶瑕佺櫥褰曪紝鏈夋病鏈夌櫥褰曪紝鎴栬�呯櫥褰曟槸鍚﹁繃鏈燂紝
- if (UserInfo.Current == null || !UserInfo.Current.IsLogin)
- {
- GoLoginPage(UserInfo.Current);
- }
- else
- {
- //new System.Threading.Thread(() =>
- //{
- // var pm = new DAL.Server.HttpServerRequest();
- // pm.RefreshToken();//鍒锋柊Token
- // pm.GetHomePager();//鍒锋柊浣忓畢淇℃伅
- // pm.GetUserInfo();//鍒锋柊涓汉淇℃伅
- //})
- //{ IsBackground = true }.Start();
- Common.ApiUtlis.Ins.DownloadData();
-
- GoUserPage(false,true);
- }
- }
- }
- catch (Exception ex)
- {
- Log("root erorr : " + ex.Message);
- }
- finally
- {
- //Application.RunOnMainThread(() => {
- // Application.HideSoftInput();
- //});
- }
+ GoLoginPage();
}
-
- /// <summary>
- /// 杩涘叆鐧诲綍鐣岄潰
- /// </summary>
- public static void GoLoginPage(UserInfo userInfo = null)
+ else
{
- BaseView.RemoveAll();
- BaseView.BackgroundColor = CSS_Color.BackgroundColor;
- var fisrtView = new UI.UI1Login.LoginPage();
- fisrtView.BackgroundColor = CSS_Color.MainBackgroundColor;
- BaseView.AddChidren(fisrtView);
- fisrtView.LoadView(userInfo);
+ //鍒ゆ柇闇�涓嶉渶瑕佺櫥褰曪紝鏈夋病鏈夌櫥褰曪紝鎴栬�呯櫥褰曟槸鍚﹁繃鏈燂紝
+ if (UserInfo.Current == null || !UserInfo.Current.IsLogin)
+ {
+ GoLoginPage(UserInfo.Current);
+ }
+ else
+ {
+ //new System.Threading.Thread(() =>
+ //{
+ // var pm = new DAL.Server.HttpServerRequest();
+ // pm.RefreshToken();//鍒锋柊Token
+ // pm.GetHomePager();//鍒锋柊浣忓畢淇℃伅
+ // pm.GetUserInfo();//鍒锋柊涓汉淇℃伅
+ //})
+ //{ IsBackground = true }.Start();
+ Common.ApiUtlis.Ins.DownloadData();
+
+ GoUserPage(false, true);
+ }
}
+ }
+ catch (Exception ex)
+ {
+ Log("root erorr : " + ex.Message);
+ }
+ finally
+ {
+ //Application.RunOnMainThread(() => {
+ // Application.HideSoftInput();
+ //});
+ }
+ }
- /// <summary>
- /// 杩涘叆涓婚〉
- /// </summary>
- /// <param name="isFirstOpen">濡傛灉鏄涓�娆″惎鍔� 妫�娴嬫牎楠屽瘑鐮�</param>
- /// <param name="pageShowEvent">涓婚〉鏄剧ず涔嬪悗瑙﹀彂鐨勪簨浠�(娌℃湁浣忓畢鐨勮瘽,鍒欎笉浼氳Е鍙�)</param>
- public static void GoUserPage(bool downloadData , bool isFirstOpen = false, Action pageShowEvent = null)
- {
- BaseView.RemoveAll();
- #region 鍚庨��浜嬩欢
- BasePageView = new PageLayout();
- BasePageView.ScrollEnabled = false;
- BasePageView.IsShowPoint = false;
- BasePageView.PageChange = (sender, e) =>
+ /// <summary>
+ /// 杩涘叆鐧诲綍鐣岄潰
+ /// </summary>
+ public static void GoLoginPage(UserInfo userInfo = null)
+ {
+ BaseView.RemoveAll();
+ BaseView.BackgroundColor = CSS_Color.BackgroundColor;
+ var fisrtView = new UI.UI1Login.LoginPage();
+ fisrtView.BackgroundColor = CSS_Color.MainBackgroundColor;
+ BaseView.AddChidren(fisrtView);
+ fisrtView.LoadView(userInfo);
+ }
+
+ /// <summary>
+ /// 杩涘叆涓婚〉
+ /// </summary>
+ /// <param name="isFirstOpen">濡傛灉鏄涓�娆″惎鍔� 妫�娴嬫牎楠屽瘑鐮�</param>
+ /// <param name="pageShowEvent">涓婚〉鏄剧ず涔嬪悗瑙﹀彂鐨勪簨浠�(娌℃湁浣忓畢鐨勮瘽,鍒欎笉浼氳Е鍙�)</param>
+ public static void GoUserPage(bool downloadData, bool isFirstOpen = false, Action pageShowEvent = null)
+ {
+ BaseView.RemoveAll();
+ #region 鍚庨��浜嬩欢
+ BasePageView = new PageLayout();
+ BasePageView.ScrollEnabled = false;
+ BasePageView.IsShowPoint = false;
+ BasePageView.PageChange = (sender, e) =>
+ {
+ if (e < BasePageView.ChildrenCount - 1)
+ {
+ BasePageView.GetChildren(BasePageView.ChildrenCount - 1).RemoveFromParent();
+ }
+ try
+ {
+ ReturnRefreshAction?.Invoke();
+ ReturnRefreshAction = null;
+ }
+ catch (Exception ex)
+ {
+ Log($"鍚庨��浜嬩欢寮傚父:{ex.Message}");
+ }
+ };
+ BaseView.AddChidren(BasePageView);
+ var backView = new FrameLayout()
+ {
+ Y = Application.GetRealHeight(100),
+ Width = Application.GetRealWidth(10),
+ Height = Application.GetRealHeight(440),
+ };
+ BaseView.AddChidren(backView);
+
+ BtnBackIcon = new Button()
+ {
+ X = -Application.GetRealWidth(100),
+ Gravity = Gravity.CenterVertical,
+ Width = Application.GetRealWidth(88 / 2),
+ Height = Application.GetRealHeight(56 / 2),
+ UnSelectedImagePath = "Public/RightSlideBackIcon.png"
+ };
+ BaseView.AddChidren(BtnBackIcon);
+ backView.MouseMoveEventHandler = (sender, e) =>
+ {
+ if (BasePageView.ChildrenCount <= 1)
+ {
+ return;
+ }
+ MainPage.Log($"move:{e.X}");
+ if (StartX == 0 && e.X < 30)
+ {
+ StartX = (int)e.X;
+ }
+ if (StartX < 30)
+ {
+ if (e.X < Application.GetRealWidth(100))
+ {
+ BtnBackIcon.X = (int)e.X - Application.GetRealWidth(100);
+ }
+ }
+ };
+ backView.MouseDownEventHandler = (sender, e) =>
+ {
+ if (BasePageView.ChildrenCount <= 1)
+ {
+ return;
+ }
+ MainPage.Log($"down:{e.X}");
+ StartX = (int)e.X;
+ BtnBackIcon.Y = (int)e.Y + Application.GetRealHeight(50);
+ };
+ backView.MouseUpEventHandler = (sender, e) =>
+ {
+ MainPage.Log($"up{e.X}");
+ StartX = 0;
+ BtnBackIcon.X = -Application.GetRealWidth(100);
+
+ if (e.X > 70)
+ {
+ if (BasePageView.ChildrenCount > 1)
+ {
+ BasePageView.PageIndex = BasePageView.ChildrenCount - 2;
+ }
+ }
+ };
+ backView.MouseUpOutsideEventHandler = (sender, e) =>
+ {
+ MainPage.Log($"up{e.X}");
+ StartX = 0;
+ BtnBackIcon.X = -Application.GetRealWidth(100);
+
+ if (e.X > 70)
+ {
+ if (BasePageView.ChildrenCount > 1)
+ {
+ BasePageView.PageIndex = BasePageView.ChildrenCount - 2;
+ }
+ }
+ };
+ #endregion
+
+
+ //浣撻獙妯″紡
+ if (NoLoginMode)
+ {
+ //璺宠浆椤甸潰----
+ UserBasePage = new UserPage();
+ BasePageView.AddChidren(UserBasePage);
+ UserBasePage.LoadPage();
+ BasePageView.PageIndex = 0;
+
+ return;
+ }
+
+ //鍔犺浇Loading鏁堟灉
+ var waitPage = new Loading();
+ BaseView.AddChidren(waitPage);
+ waitPage.Start(Language.StringByID(StringId.PleaseWait));
+
+ //褰撴病鏈変綇瀹呮椂,涓嶈兘璁╁畠寰�涓嬭蛋
+ if (UserInfo.Current.regionList.Count == 0)
+ {
+ waitPage.Hide();
+ var addResidencePage = new BindingResidencePage();
+ BaseView.AddChidren(addResidencePage);
+ addResidencePage.LoadView();
+ return;
+ }
+ new System.Threading.Thread(async () =>
+ {
+ try
+ {
+ Entity.FunctionList.List.Clear();
+ Entity.SpatialInfo.CurrentSpatial.Clear();
+ ///绛夊緟鑾峰彇浣忓畢淇℃伅
+ Application.RunOnMainThread(() =>
+ {
+ if (waitPage != null)
{
- if (e < BasePageView.ChildrenCount - 1)
- {
- BasePageView.GetChildren(BasePageView.ChildrenCount - 1).RemoveFromParent();
- }
- try
- {
- ReturnRefreshAction?.Invoke();
- ReturnRefreshAction = null;
- }
- catch (Exception ex)
- {
- Log($"鍚庨��浜嬩欢寮傚父:{ex.Message}");
- }
- };
- BaseView.AddChidren(BasePageView);
- var backView = new FrameLayout()
- {
- Y = Application.GetRealHeight(100),
- Width = Application.GetRealWidth(10),
- Height = Application.GetRealHeight(440),
- };
- BaseView.AddChidren(backView);
-
- BtnBackIcon = new Button()
- {
- X = -Application.GetRealWidth(100),
- Gravity = Gravity.CenterVertical,
- Width = Application.GetRealWidth(88 / 2),
- Height = Application.GetRealHeight(56 / 2),
- UnSelectedImagePath = "Public/RightSlideBackIcon.png"
- };
- BaseView.AddChidren(BtnBackIcon);
- backView.MouseMoveEventHandler = (sender, e) =>
- {
- if (BasePageView.ChildrenCount <= 1)
- {
- return;
- }
- MainPage.Log($"move:{e.X}");
- if (StartX == 0 && e.X < 30)
- {
- StartX = (int)e.X;
- }
- if (StartX < 30)
- {
- if (e.X < Application.GetRealWidth(100))
- {
- BtnBackIcon.X = (int)e.X - Application.GetRealWidth(100);
- }
- }
- };
- backView.MouseDownEventHandler = (sender, e) =>
- {
- if (BasePageView.ChildrenCount <= 1)
- {
- return;
- }
- MainPage.Log($"down:{e.X}");
- StartX = (int)e.X;
- BtnBackIcon.Y = (int)e.Y + Application.GetRealHeight(50);
- };
- backView.MouseUpEventHandler = (sender, e) => {
- MainPage.Log($"up{e.X}");
- StartX = 0;
- BtnBackIcon.X = -Application.GetRealWidth(100);
-
- if (e.X > 70)
- {
- if (BasePageView.ChildrenCount > 1)
- {
- BasePageView.PageIndex = BasePageView.ChildrenCount - 2;
- }
- }
- };
- backView.MouseUpOutsideEventHandler = (sender, e) => {
- MainPage.Log($"up{e.X}");
- StartX = 0;
- BtnBackIcon.X = -Application.GetRealWidth(100);
-
- if (e.X > 70)
- {
- if (BasePageView.ChildrenCount > 1)
- {
- BasePageView.PageIndex = BasePageView.ChildrenCount - 2;
- }
- }
- };
- #endregion
-
-
- //浣撻獙妯″紡
- if (NoLoginMode)
- {
- //璺宠浆椤甸潰----
- UserBasePage = new UserPage();
- BasePageView.AddChidren(UserBasePage);
- UserBasePage.LoadPage();
- BasePageView.PageIndex = 0;
-
- return;
+ waitPage.RemoveFromParent();
+ waitPage = null;
}
- //鍔犺浇Loading鏁堟灉
- var waitPage = new Loading();
- BaseView.AddChidren(waitPage);
- waitPage.Start(Language.StringByID(StringId.PleaseWait));
+ //璺宠浆椤甸潰----
+ UserBasePage = new UserPage();
+ BasePageView.AddChidren(UserBasePage);
+ UserBasePage.LoadPage();
+ BasePageView.PageIndex = 0;
- //褰撴病鏈変綇瀹呮椂,涓嶈兘璁╁畠寰�涓嬭蛋
- if (UserInfo.Current.regionList.Count == 0)
+ if (isFirstOpen)
{
- waitPage.Hide();
- var addResidencePage = new BindingResidencePage();
- BaseView.AddChidren(addResidencePage);
- addResidencePage.LoadView();
- return;
+ //鍚姩瀵嗙爜楠岃瘉
+ new AppUnlockPage().LoadPage(isFirstOpen);
}
- new System.Threading.Thread(async () =>
- {
- try
- {
- Entity.FunctionList.List.Clear();
- Entity.SpatialInfo.CurrentSpatial.Clear();
- ///绛夊緟鑾峰彇浣忓畢淇℃伅
- Application.RunOnMainThread( () =>
- {
- if (waitPage != null)
- {
- waitPage.RemoveFromParent();
- waitPage = null;
- }
-
- //璺宠浆椤甸潰----
- UserBasePage = new UserPage();
- BasePageView.AddChidren(UserBasePage);
- UserBasePage.LoadPage();
- BasePageView.PageIndex = 0;
-
- if (isFirstOpen)
- {
- //鍚姩瀵嗙爜楠岃瘉
- new AppUnlockPage().LoadPage(isFirstOpen);
- }
- //涓婚〉鍔犺浇瀹屾垚,鍥炶皟浜嬩欢
- pageShowEvent?.Invoke();
- pageShowEvent = null;
- });
- }
- catch (Exception ex)
- {
- MainPage.Log($"GoUserPage : {ex.Message}");
- }finally
- {
- Application.RunOnMainThread(() =>
- {
- if (downloadData)
- {
- DB_ResidenceData.Instance.EixtAccount();
- ///鍒濆鍖朼pp鏁版嵁
- Common.ApiUtlis.Ins.DownloadData();
- };
- });
- }
- }).Start();
-
+ //涓婚〉鍔犺浇瀹屾垚,鍥炶皟浜嬩欢
+ pageShowEvent?.Invoke();
+ pageShowEvent = null;
+ });
}
-
- /// <summary>
- /// 鍚庨��浜嬩欢
- /// 0:鍚庨��
- /// 1:鏈夌瓑寰呯晫闈�
- /// 2:鏃犳硶鍐嶅悗閫�锛屽彲浠ユ墽琛岄��鍒版闈�
- /// </summary>
- public static int LoadEvent_BackAction()
+ catch (Exception ex)
{
- int result = 0;
- Application.RunOnMainThread(() =>
- {
- if (BasePageView == null || BasePageView.ChildrenCount<=1 )
- {
- result = 2;//鏃犳硶鍐嶅悗閫�锛屽彲浠ユ墽琛岄��鍒版闈�
- }
- if (BasePageView.ChildrenCount > 1)
- {
- int index = BasePageView.ChildrenCount - 1;
- var view = BasePageView.GetChildren(index);
- if (view.GetType() == typeof(Loading))
- {
- var loading = view as Loading;
- if (loading.CurStatus == false)//鏈変竴浜涚瓑寰呯晫闈㈤殣钘忎簡锛屼絾鏄病鏈夌Щ闄ゅ埌锛岄渶瑕佸厛绉婚櫎
- {
- loading.RemoveFromParent();
- result = LoadEvent_BackAction();
- }
- else
- {
- result = 1;//姝e湪绛夊緟鏌愪簺鎿嶄綔
- }
- }
- else
- {
- if (view != null)
- {
- if(view.Tag!=null )
- {
- if (view.Tag.ToString() != "unlockpage")
- {
- view.RemoveFromParent();
- }else
- {
- result = 2;
- }
- }else
- {
- view.RemoveFromParent();
- }
- }
- }
- }
- else
- {
- result = 2;//鏃犳硶鍐嶅悗閫�锛屽彲浠ユ墽琛岄��鍒版闈�
- }
- });
- return result;
+ MainPage.Log($"GoUserPage : {ex.Message}");
}
-
-
- /// <summary>
- /// 鑷畾涔夋棩蹇楄緭鍑�
- /// </summary>
- public static void Log(string msg)
+ finally
{
-#if DEBUG
- Console.WriteLine(msg);
-#endif
+ Application.RunOnMainThread(() =>
+ {
+ if (downloadData)
+ {
+ DB_ResidenceData.Instance.EixtAccount();
+ ///鍒濆鍖朼pp鏁版嵁
+ Common.ApiUtlis.Ins.DownloadData();
+ };
+ });
}
-
+ }).Start();
}
-}
+ /// <summary>
+ /// 鍚庨��浜嬩欢
+ /// 0:鍚庨��
+ /// 1:鏈夌瓑寰呯晫闈�
+ /// 2:鏃犳硶鍐嶅悗閫�锛屽彲浠ユ墽琛岄��鍒版闈�
+ /// </summary>
+ public static int LoadEvent_BackAction()
+ {
+ int result = 0;
+ Application.RunOnMainThread(() =>
+ {
+ if (BasePageView == null || BasePageView.ChildrenCount <= 1)
+ {
+ result = 2;//鏃犳硶鍐嶅悗閫�锛屽彲浠ユ墽琛岄��鍒版闈�
+ }
+ if (BasePageView.ChildrenCount > 1)
+ {
+ int index = BasePageView.ChildrenCount - 1;
+ var view = BasePageView.GetChildren(index);
+ if (view.GetType() == typeof(Loading))
+ {
+ var loading = view as Loading;
+ if (loading.CurStatus == false)//鏈変竴浜涚瓑寰呯晫闈㈤殣钘忎簡锛屼絾鏄病鏈夌Щ闄ゅ埌锛岄渶瑕佸厛绉婚櫎
+ {
+ loading.RemoveFromParent();
+ result = LoadEvent_BackAction();
+ }
+ else
+ {
+ result = 1;//姝e湪绛夊緟鏌愪簺鎿嶄綔
+ }
+ }
+ else
+ {
+ if (view != null)
+ {
+ if (view.Tag != null)
+ {
+ if (view.Tag.ToString() != "unlockpage")
+ {
+ view.RemoveFromParent();
+ }
+ else
+ {
+ result = 2;
+ }
+ }
+ else
+ {
+ view.RemoveFromParent();
+ }
+ }
+ }
+ }
+ else
+ {
+ result = 2;//鏃犳硶鍐嶅悗閫�锛屽彲浠ユ墽琛岄��鍒版闈�
+ }
+ });
+ return result;
+ }
+
+
+ /// <summary>
+ /// 鑷畾涔夋棩蹇楄緭鍑�
+ /// </summary>
+ public static void Log(string msg)
+ {
+#if DEBUG
+ Console.WriteLine(msg);
+#endif
+ }
+
+
+ }
+
+}
\ No newline at end of file
diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation 2.zip b/HDL_ON/UI/UI2/3-Intelligence/Automation 2.zip
deleted file mode 100644
index 29f5c62..0000000
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation 2.zip
+++ /dev/null
Binary files differ
diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation.zip b/HDL_ON/UI/UI2/3-Intelligence/Automation.zip
deleted file mode 100644
index 252e880..0000000
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation.zip
+++ /dev/null
Binary files differ
diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs
index d6d5c43..ea0ee18 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs
@@ -3,337 +3,328 @@
using Shared;
namespace HDL_ON.UI.UI2.Intelligence.Automation
{
- public class AddInputType : FrameLayout
+ public class AddInputType : FrameLayout
+ {
+ public AddInputType()
{
- public AddInputType()
+ Tag = "Logic";
+ }
+ public void Show()
+ {
+ LogicView.TopView topView = new LogicView.TopView();
+ this.AddChidren(topView.FLayoutView());
+ topView.clickBackBtn.MouseUpEventHandler += (e, sen) =>
+ {
+ RemoveFromParent();
+ };
+ topView.topNameBtn.TextID = StringId.selectionCondition;
+
+ FrameLayout viewLayout = new FrameLayout
+ {
+ Y = Application.GetRealHeight(64),
+ Width = Application.GetRealWidth(LogicView.TextSize.view375),
+ Height = Application.GetRealHeight(LogicView.TextSize.view667 - 64),
+ BackgroundColor = CSS.CSS_Color.viewMiddle,
+ };
+ this.AddChidren(viewLayout);
+ #region 鏃堕棿 鍔熻兘 瀹ゅ鍙樺寲
+ //鏃堕棿
+ LogicView.SelectTypeView timeView = new LogicView.SelectTypeView();
+ timeView.btnText.TextID = StringId.time;
+ timeView.btnIcon.UnSelectedImagePath = "LogicIcon/time.png";
+ if (MainView.IsGatewayType)
+ {
+ viewLayout.AddChidren(timeView.FLayoutView());
+ }
+
+ //鍔熻兘
+ LogicView.SelectTypeView functionView = new LogicView.SelectTypeView();
+ functionView.frameLayout.Y = timeView.frameLayout.Bottom;
+ functionView.btnText.TextID = StringId.funLogic;
+ functionView.btnIcon.UnSelectedImagePath = "LogicIcon/functionicon.png";
+ viewLayout.AddChidren(functionView.FLayoutView());
+ if (!MainView.IsGatewayType)
+ {
+ functionView.frameLayout.Y = Application.GetRealHeight(0);
+ }
+
+ //鍦烘櫙
+ LogicView.SelectTypeView sceneView = new LogicView.SelectTypeView();
+ sceneView.frameLayout.Y = functionView.frameLayout.Bottom;
+ sceneView.btnText.TextID = StringId.Scenes;
+ sceneView.btnIcon.UnSelectedImagePath = "LogicIcon/scene.png";
+ viewLayout.AddChidren(sceneView.FLayoutView());
+
+ //瀹ゅ鍙樺寲
+ LogicView.SelectTypeView shiwaiView = new LogicView.SelectTypeView();
+ shiwaiView.frameLayout.Y = sceneView.frameLayout.Bottom;
+ shiwaiView.btnText.TextID = StringId.shiwaibainhua;
+ shiwaiView.btnIcon.UnSelectedImagePath = "LogicIcon/changesinoutdoor.png";
+
+ if (MainView.IsGatewayType)
+ {
+ viewLayout.AddChidren(shiwaiView.FLayoutView());
+ }
+
+ //鍦扮悊鍥存爮
+ LogicView.SelectTypeView likiadaodaView = new LogicView.SelectTypeView();
+ likiadaodaView.frameLayout.Y = shiwaiView.frameLayout.Bottom;
+ likiadaodaView.btnText.TextID = StringId.likiadaoda;
+ likiadaodaView.btnIcon.UnSelectedImagePath = "LogicIcon/location.png";
+
+ if (MainView.IsGatewayType)
+ {
+ viewLayout.AddChidren(likiadaodaView.FLayoutView());
+ }
+
+ #endregion
+
+ #region 鎵�鏈夌偣鍑讳簨浠�
+ //鏃堕棿
+ timeView.btnClick.MouseUpEventHandler += (sen, e) =>
+ {
+ TimeTpye timeTpye = new TimeTpye();
+ MainPage.BasePageView.AddChidren(timeTpye);
+ timeTpye.Show();
+ MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+
+ };
+ //鍔熻兘
+ functionView.btnClick.MouseUpEventHandler += (sen, e) =>
+ {
+ FunTpye funTpye = new FunTpye();
+ MainPage.BasePageView.AddChidren(funTpye);
+ funTpye.Show(LogicMethod.condition_if);
+ MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+ };
+ //鍦烘櫙鐐瑰嚮浜嬩欢
+ sceneView.btnClick.MouseUpEventHandler += (sen, e) =>
+ {
+ SceneMethod();
+ };
+ //瀹ゅ鍙樺寲
+ shiwaiView.btnClick.MouseUpEventHandler += (sen, e) =>
+ {
+ //if (string.IsNullOrEmpty(Entity.DB_ResidenceData.Instance.CurrentRegion.homeAddress))//.longitude == 0 && Entity.DB_ResidenceData.Instance.CurrentRegion.latitude == 0)
+ //{
+ // new PublicAssmebly().TipMsg(StringId.tip, StringId.GatewayLocationInformationIsNotConfigured);
+ // return;
+ //}
+ Weather weather = new Weather();
+ MainPage.BasePageView.AddChidren(weather);
+ weather.Show();
+ MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+ };
+
+ //鍦扮悊鍥存爮
+ likiadaodaView.btnClick.MouseUpEventHandler += (sen, e) =>
+ {
+ LocationView(this, false);
+ };
+ #endregion
+
+ }
+
+ /// <summary>
+ /// 娣诲姞鍦烘櫙
+ /// </summary>
+ public void SceneMethod()
+ {
+ var sceneList = LogicMethod.CurrLogicMethod.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) =>
+ {
+ 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");
+ input.condition.Add(dic);
+ AddCondition(input);
+ LogicMethod.CurrLogicMethod.RemoveAllView();
+ AddLogic addLogic = new AddLogic();
+ MainPage.BasePageView.AddChidren(addLogic);
+ addLogic.Show();
+ MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+ });
+ }
+ /// <summary>
+ /// 娣诲姞鍦扮悊鍥存爮
+ /// </summary>
+ /// <param name="flMain">Fl main.</param>
+ /// <param name="edit">If set to <c>true</c> edit.</param>
+ public void LocationView(FrameLayout flMain, bool edit)
+ {
+ string strname = "";
+ ///閫氳繃璋冭瘯瀹濈粰鐨勭粡绾害<鏍囧噯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);
+ int r = 500;//榛樿鍗婂緞
+ if (edit)
+ {
+ for (var i = 0; i < Logic.currlogic.input.Count; i++)
{
- Tag = "Logic";
- }
- public void Show()
- {
-
- LogicView.TopView topView = new LogicView.TopView();
- this.AddChidren(topView.FLayoutView());
- topView.clickBackBtn.MouseUpEventHandler += (e, sen) =>
- {
- RemoveFromParent();
- };
- topView.topNameBtn.TextID = StringId.selectionCondition;
-
- FrameLayout viewLayout = new FrameLayout
- {
- Y = Application.GetRealHeight(64),
- Width = Application.GetRealWidth(LogicView.TextSize.view375),
- Height = Application.GetRealHeight(LogicView.TextSize.view667 - 64),
- BackgroundColor = CSS.CSS_Color.viewMiddle,
- };
- this.AddChidren(viewLayout);
- #region 鏃堕棿 鍔熻兘 瀹ゅ鍙樺寲
- //鏃堕棿
- LogicView.SelectTypeView timeView = new LogicView.SelectTypeView();
- timeView.btnText.TextID = StringId.time;
- timeView.btnIcon.UnSelectedImagePath = "LogicIcon/time.png";
- if (MainView.IsGatewayType)
- {
- viewLayout.AddChidren(timeView.FLayoutView());
- }
-
- //鍔熻兘
- LogicView.SelectTypeView functionView = new LogicView.SelectTypeView();
- functionView.frameLayout.Y = timeView.frameLayout.Bottom;
- functionView.btnText.TextID = StringId.funLogic;
- functionView.btnIcon.UnSelectedImagePath = "LogicIcon/functionicon.png";
- viewLayout.AddChidren(functionView.FLayoutView());
- if (!MainView.IsGatewayType)
- {
- functionView.frameLayout.Y = Application.GetRealHeight(0);
- }
-
- //鍦烘櫙
- LogicView.SelectTypeView sceneView = new LogicView.SelectTypeView();
- sceneView.frameLayout.Y = functionView.frameLayout.Bottom;
- sceneView.btnText.TextID = StringId.Scenes;
- sceneView.btnIcon.UnSelectedImagePath = "LogicIcon/scene.png";
- viewLayout.AddChidren(sceneView.FLayoutView());
-
- //瀹ゅ鍙樺寲
- LogicView.SelectTypeView shiwaiView = new LogicView.SelectTypeView();
- shiwaiView.frameLayout.Y = sceneView.frameLayout.Bottom;
- shiwaiView.btnText.TextID = StringId.shiwaibainhua;
- shiwaiView.btnIcon.UnSelectedImagePath = "LogicIcon/changesinoutdoor.png";
-
- if (MainView.IsGatewayType)
- {
- viewLayout.AddChidren(shiwaiView.FLayoutView());
- }
-
- //鍦扮悊鍥存爮
- LogicView.SelectTypeView likiadaodaView = new LogicView.SelectTypeView();
- likiadaodaView.frameLayout.Y = shiwaiView.frameLayout.Bottom;
- likiadaodaView.btnText.TextID = StringId.likiadaoda;
- likiadaodaView.btnIcon.UnSelectedImagePath = "LogicIcon/location.png";
-
- if (MainView.IsGatewayType)
- {
- viewLayout.AddChidren(likiadaodaView.FLayoutView());
- }
-
- #endregion
-
- #region 鎵�鏈夌偣鍑讳簨浠�
- //鏃堕棿
- timeView.btnClick.MouseUpEventHandler += (sen, e) =>
- {
- TimeTpye timeTpye = new TimeTpye();
- MainPage.BasePageView.AddChidren(timeTpye);
- timeTpye.Show();
- MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
-
- };
- //鍔熻兘
- functionView.btnClick.MouseUpEventHandler += (sen, e) =>
- {
- FunTpye funTpye = new FunTpye();
- MainPage.BasePageView.AddChidren(funTpye);
- funTpye.Show(LogicMethod.condition_if);
- MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
- };
- //鍦烘櫙鐐瑰嚮浜嬩欢
- sceneView.btnClick.MouseUpEventHandler += (sen, e) =>
- {
- SceneMethod();
- };
- //瀹ゅ鍙樺寲
- shiwaiView.btnClick.MouseUpEventHandler += (sen, e) =>
- {
- //if (string.IsNullOrEmpty(Entity.DB_ResidenceData.Instance.CurrentRegion.homeAddress))//.longitude == 0 && Entity.DB_ResidenceData.Instance.CurrentRegion.latitude == 0)
- //{
- // new PublicAssmebly().TipMsg(StringId.tip, StringId.GatewayLocationInformationIsNotConfigured);
- // return;
- //}
- Weather weather = new Weather();
- MainPage.BasePageView.AddChidren(weather);
- weather.Show();
- MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
- };
-
- //鍦扮悊鍥存爮
- likiadaodaView.btnClick.MouseUpEventHandler += (sen, e) =>
- {
- LocationView(this, false);
- };
- #endregion
-
- }
-
- /// <summary>
- /// 娣诲姞鍦烘櫙
- /// </summary>
- public void SceneMethod()
- {
- var sceneList = LogicMethod.CurrLogicMethod.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) =>
- {
- 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");
- input.condition.Add(dic);
- AddCondition(input);
- LogicMethod.CurrLogicMethod.RemoveAllView();
- AddLogic addLogic = new AddLogic();
- MainPage.BasePageView.AddChidren(addLogic);
- addLogic.Show();
- MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
- });
- }
-
- /// <summary>
- /// 鍦扮悊鍥存爮View
- /// </summary>
- /// <param name="flMain">Fl main.</param>
- /// <param name="edit">If set to <c>true</c> edit.</param>
- public void LocationView(FrameLayout flMain, bool edit)
- {
- string strname = "";
- ///閫氳繃璋冭瘯瀹濈粰鐨勭粡绾害<鏍囧噯GPS>
- double latitude = Entity.DB_ResidenceData.Instance.CurrentRegion.latitude;//绾害
- double longitude = Entity.DB_ResidenceData.Instance.CurrentRegion.longitude;//缁忓害
+ var input = Logic.currlogic.input[i];
+ if (input.condition_type != "8")
+ {
+ continue;
+ }
+ if (input.condition[0]["value"] == "arrive")
+ {
+ //鍒拌揪鏌愬湴
+ strname = Language.StringByID(StringId.daoda);
+ }
+ else
+ {
+ //绂诲紑鍦扮偣
+ strname = Language.StringByID(StringId.likai);
+ }
+ //鍐嶄竴娆$紪杈戝湴鐞嗗洿鏍� <鎺т欢鏆傛椂涓嶆敮鎸佹樉绀鸿褰曚笂涓�娆$殑鐘舵��>
+ if (!string.IsNullOrEmpty(input.geo_fence.latitude) && !string.IsNullOrEmpty(input.geo_fence.longitude))
+ {
+ ////绾害
+ //var latitude1 = Convert.ToDouble(input.geo_fence.latitude);
+ ////缁忓害
+ //var longitude1 = Convert.ToDouble(input.geo_fence.longitude);
+ //鍗婂緞
+ r = int.Parse(input.geo_fence.radius);
//WGS84鍧愭爣杞珮寰峰潗鏍�
- LogicMethod.CurrLogicMethod.WGS84_to_GCJ02(Entity.DB_ResidenceData.Instance.CurrentRegion.longitude, Entity.DB_ResidenceData.Instance.CurrentRegion.latitude, out longitude, out latitude);
- int r = 500;//鍗婂緞
- if (edit)
- {
- for (var i = 0; i < Logic.currlogic.input.Count; i++)
- {
- var input = Logic.currlogic.input[i];
- if (input.condition_type != "8")
- {
- continue;
- }
- if (input.condition[0]["value"] == "arrive")
- {
- //鍒拌揪鏌愬湴
- strname = Language.StringByID(StringId.daoda);
- }
- else
- {
- //绂诲紑鍦扮偣
- strname = Language.StringByID(StringId.likai);
- }
- //绾害
- latitude = Convert.ToDouble(input.geo_fence.latitude);
- //缁忓害
- longitude = Convert.ToDouble(input.geo_fence.longitude);
- //鍗婂緞
- r = int.Parse(input.geo_fence.radius);
- }
- }
- PublicInterface publicInterface = new PublicInterface();
- var list = publicInterface.GetViewList("鍦扮悊鍥存爮");
- publicInterface.SingleSelectionShow(flMain, list, Language.StringByID(StringId.likiadaoda), strname, (str) =>
- {
+ //LogicMethod.CurrLogicMethod.WGS84_to_GCJ02(longitude1, latitude1, out longitude, out latitude);
+ }
+ }
+ }
+ PublicInterface publicInterface = new PublicInterface();
+ var list = publicInterface.GetViewList("鍦扮悊鍥存爮");
+ publicInterface.SingleSelectionShow(flMain, list, Language.StringByID(StringId.likiadaoda), strname, (str) =>
+ {
- string valueStr = "arrive";
- if (str == Language.StringByID(StringId.daoda))
- {
- //鍒拌揪鏌愬湴
- valueStr = "arrive";
- }
- else
- {
- //绂诲紑
- valueStr = "leave";
- }
+ string valueStr = "arrive";
+ if (str == Language.StringByID(StringId.daoda))
+ {
+ //鍒拌揪鏌愬湴
+ valueStr = "arrive";
+ }
+ else
+ {
+ //绂诲紑
+ valueStr = "leave";
+ }
#if __Android__
//鐢宠瀹氫綅鏉冮檺
((BaseActivity)Application.Activity).SetGPSLocationPermission((result1) =>
{
- if (result1 == false) { return; }
+ if (result1 == false) { return; }
//鐢宠鍏佽绋嬪簭鍐欏叆澶栭儴瀛樺偍锛屽SD鍗′笂鍐欐枃浠�
((BaseActivity)Application.Activity).SetPermission((result2) =>
{
- if (result2 == false) { return; }
+ if (result2 == false) { return; }
//璇诲彇鐢佃瘽鐘舵�佹潈闄�
((BaseActivity)Application.Activity).SetPermission((result3) =>
{
- if (result3 == false) { return; }
-
- //璋冪敤鏂规硶锛岃烦杞〉闈�
- GDMapKit.Show((mLatitude, mLongitude, mRadius, name) =>
- {
- //楂樺痉鍧愭爣杞琖GS84鍧愭爣(楂樺痉鍦板浘璁剧疆GPS)
- double out_lng, out_lat;
- LogicMethod.CurrLogicMethod.GCJ02_to_WGS84(mLongitude, mLatitude, out out_lng, out out_lat);
- Input input = new Input();
- input.sid = LogicMethod.CurrLogicMethod.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);
- input.condition.Add(dic);
- //绾害
- input.geo_fence.latitude = out_lat.ToString();
- //缁忓害
- input.geo_fence.longitude = out_lng.ToString();
- //鍗婂緞<鍗曚綅绫�>
- input.geo_fence.radius = mRadius.ToString();
- AddCondition(input);
- LogicMethod.CurrLogicMethod.RemoveAllView();
- AddLogic addLogic = new AddLogic();
- MainPage.BasePageView.AddChidren(addLogic);
- addLogic.Show();
- MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
-
- }, strname, Language.StringByID(StringId.save), true, latitude, longitude, r);
-
+ if (result3 == false) { return; }
+ //璋冪敤鏂规硶锛岃烦杞〉闈�
+ Location(valueStr, strname, latitude, longitude, r);
}, "android.permission.READ_PHONE_STATE");
}, "android.permission.WRITE_EXTERNAL_STORAGE");
});
#endif
#if __IOS__
- //璋冪敤鏂规硶锛岃烦杞〉闈�
- GDMapKit.Show((mLatitude, mLongitude, mRadius, name) =>
- {
- //楂樺痉鍧愭爣杞琖GS84鍧愭爣(楂樺痉鍦板浘璁剧疆GPS)
- double out_lng, out_lat;
- LogicMethod.CurrLogicMethod.GCJ02_to_WGS84(mLongitude, mLatitude, out out_lng, out out_lat);
-
- Input input = new Input();
- input.sid = LogicMethod.CurrLogicMethod.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", "arrive");
- input.condition.Add(dic);
- //绾害
- input.geo_fence.latitude = out_lat.ToString();
- //缁忓害
- input.geo_fence.longitude = out_lng.ToString();
- //鍗婂緞<鍗曚綅绫�>
- input.geo_fence.radius = mRadius.ToString();
- AddCondition(input);
- LogicMethod.CurrLogicMethod.RemoveAllView();
- AddLogic addLogic = new AddLogic();
- MainPage.BasePageView.AddChidren(addLogic);
- addLogic.Show();
- MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
- }, strname, Language.StringByID(StringId.save), true, latitude, longitude, r);
+ //璋冪敤鏂规硶锛岃烦杞〉闈�
+ Location(valueStr, strname, latitude, longitude, r);
#endif
- });
+ });
- }
-
- /// <summary>
- /// 娣诲姞鏉′欢
- /// </summary>
- /// <param name="input"></param>
- private void AddCondition(Input input)
- {
- ///璁板綍绱㈠紩鍊�
- int index = -1;
- for (var i = 0; i < Logic.currlogic.input.Count; i++)
- {
- var condition_type = Logic.currlogic.input[i].condition_type;
- if (condition_type == "10" || condition_type == "8")
- {
- //鏀寔鍦烘櫙=10锛屽湴鐞嗗洿鏍�=8
- ///鎵惧埌鏍囪绱㈠紩锛岄��鍑哄惊鐜綋
- index = i;
- break;
- }
- }
- if (index != -1)
- {
- //绉婚櫎鏃ф暟鎹�
- Logic.currlogic.input.RemoveAt(index);
- //鏂版暟鎹彃鍏ユ棫鏁版嵁鐨勪綅缃�
- Logic.currlogic.input.Insert(index, input);
- }
- else
- {
- Logic.currlogic.input.Add(input);
- }
- }
}
+ /// <summary>
+ /// 鍦扮悊鍥存爮View
+ /// </summary>
+ /// <param name="valueStr">杩涘叆(arrive)鎴栬�呯寮�(leave)</param>
+ /// <param name="strname"></param>
+ /// <param name="latitude">绾害</param>
+ /// <param name="longitude">缁忓害</param>
+ /// <param name="r">鍗婂緞(榛樿500绫�)</param>
+ private void Location(string valueStr, string strname, double latitude, double longitude, int r)
+ {
+ if (r == 0)
+ {
+ //鎸夐亾鐞嗚涓嶄細鍑虹幇
+ r = 500;
+ }
+ //璋冪敤鏂规硶锛岃烦杞〉闈�
+ GDMapKit.Show((mLatitude, mLongitude, mRadius, name) =>
+ {
+ //楂樺痉鍧愭爣杞琖GS84鍧愭爣(楂樺痉鍦板浘璁剧疆GPS)
+ double out_lng, out_lat;
+ LogicMethod.CurrLogicMethod.GCJ02_to_WGS84(mLongitude, mLatitude, out out_lng, out out_lat);
+ Input input = new Input();
+ input.sid = LogicMethod.CurrLogicMethod.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);
+ input.condition.Add(dic);
+ //绾害
+ input.geo_fence.latitude = out_lat.ToString();
+ //缁忓害
+ input.geo_fence.longitude = out_lng.ToString();
+ //鍗婂緞<鍗曚綅绫�>
+ input.geo_fence.radius = mRadius.ToString();
+ AddCondition(input);
+ LogicMethod.CurrLogicMethod.RemoveAllView();
+ AddLogic addLogic = new AddLogic();
+ MainPage.BasePageView.AddChidren(addLogic);
+ addLogic.Show();
+ MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+
+ }, strname, Language.StringByID(StringId.save), true, latitude, longitude, r);
+ }
+ /// <summary>
+ /// 娣诲姞鏉′欢
+ /// </summary>
+ /// <param name="input"></param>
+ private void AddCondition(Input input)
+ {
+ ///璁板綍绱㈠紩鍊�
+ int index = -1;
+ for (var i = 0; i < Logic.currlogic.input.Count; i++)
+ {
+ var condition_type = Logic.currlogic.input[i].condition_type;
+ if (condition_type == "10" || condition_type == "8")
+ {
+ //鏀寔鍦烘櫙=10锛屽湴鐞嗗洿鏍�=8
+ ///鎵惧埌鏍囪绱㈠紩锛岄��鍑哄惊鐜綋
+ index = i;
+ break;
+ }
+ }
+ if (index != -1)
+ {
+ //绉婚櫎鏃ф暟鎹�
+ Logic.currlogic.input.RemoveAt(index);
+ //鏂版暟鎹彃鍏ユ棫鏁版嵁鐨勪綅缃�
+ Logic.currlogic.input.Insert(index, input);
+ }
+ else
+ {
+ Logic.currlogic.input.Add(input);
+ }
+ }
+ }
}
diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs
index 7b289d7..9b788f2 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs
@@ -6,893 +6,963 @@
namespace HDL_ON.UI.UI2.Intelligence.Automation
{
- public class LogicMethod
+ public class LogicMethod
+ {
+ /// <summary>
+ /// 瀹氫箟涓�涓潤鎬佸璞�
+ /// </summary>
+ private static LogicMethod logicMethod = null;
+ /// <summary>
+ /// 鑾峰彇闈欐�佸璞�
+ /// </summary>
+ public static LogicMethod CurrLogicMethod
{
- /// <summary>
- /// 瀹氫箟涓�涓潤鎬佸璞�
- /// </summary>
- private static LogicMethod logicMethod = null;
- /// <summary>
- /// 鑾峰彇闈欐�佸璞�
- /// </summary>
- public static LogicMethod CurrLogicMethod
+ get
+ {
+ if (logicMethod == null)
{
- get
- {
- if (logicMethod == null)
- {
- return new LogicMethod();
- }
- return logicMethod;
- }
-
+ return new LogicMethod();
}
-
- /// <summary>
- /// 琛ㄧず鏄潯浠�
- /// </summary>
- public const string condition_if = "鏉′欢";
- /// <summary>
- /// 琛ㄧず鏄洰鏍�
- /// </summary>
- public const string target_if = "鐩爣";
- /// <summary>
- /// 绉婚櫎鎵�鏈�"Logic"鐣岄潰
- /// </summary>
- public void RemoveAllView()
- {
- MainPage.BasePageView.RemoveViewByTag("Logic");
- }
-
- /// <summary> Converts an array of bytes into a formatted string of hex digits (ex: E4 CA B2)</summary>
- /// <param name="data"> The array of bytes to be translated into a string of hex digits. </param>
- /// <returns> Returns a well formatted string of hex digits with spacing. </returns>
- public string byteArrayToHexString(byte[] data)
- {
- System.Text.StringBuilder sb = new System.Text.StringBuilder();
- foreach (byte b in data)
- {
- sb.Append(Convert.ToString(b, 16).PadLeft(2, '0'));
- }
-
- return sb.ToString().ToUpper();
- }
-
- /**
- * int杞琤yte[]
- * 璇ユ柟娉曞皢涓�涓猧nt绫诲瀷鐨勬暟鎹浆鎹负byte[]褰㈠紡锛屽洜涓篿nt涓�32bit锛岃�宐yte涓�8bit鎵�浠ュ湪杩涜绫诲瀷杞崲鏃讹紝鐭ヤ細鑾峰彇浣�8浣嶏紝
- * 涓㈠純楂�24浣嶃�傞�氳繃浣嶇Щ鐨勬柟寮忥紝灏�32bit鐨勬暟鎹浆鎹㈡垚4涓�8bit鐨勬暟鎹�傛敞鎰� &0xff锛屽湪杩欏綋涓紝&0xff绠�鍗曠悊瑙d负涓�鎶婂壀鍒�锛�
- * 灏嗘兂瑕佽幏鍙栫殑8浣嶆暟鎹埅鍙栧嚭鏉ャ��
- * @param i 涓�涓猧nt鏁板瓧
- * @return byte[]
- */
- public byte[] int2ByteArray(int i)
- {
- byte[] result = new byte[4];
- result[0] = (byte)((i >> 24) & 0xFF);
- result[1] = (byte)((i >> 16) & 0xFF);
- result[2] = (byte)((i >> 8) & 0xFF);
- result[3] = (byte)(i & 0xFF);
- return result;
- }
- /// <summary>
- /// 鑾峰彇鏃堕棿鎴�
- /// </summary>
- /// <returns></returns>
- public int getTimeStamp()
- {
- TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
- return (int)ts.TotalSeconds;
- }
- /// <summary>
- /// 鐢熸垚閫昏緫sid鏂规硶
- /// </summary>
- public string NewSid()
- {
- string logicId = "";
- try
- {
- string sOidBeginsWith = "000101";//鍘傚晢 + 閫氳鏂瑰紡
- DateTime dt = DateTime.Now;
- DateTime startTime = TimeZoneInfo.ConvertTimeToUtc(new DateTime(2020, 1, 1));
- long m = (long)((dt - startTime).TotalMilliseconds / 10);
- string sTimeSpan = byteArrayToHexString(int2ByteArray(getTimeStamp()));
-
-
-
- logicId = sOidBeginsWith + sTimeSpan;
-
- logicId += "15";
- logicId += "1501";
- //1501 鐗╂ā鍨嬩负閫昏緫锛� 0001 琛ㄧず 1 鍙烽�昏緫鍔熻兘
- int maxId = 1;
-
-
- for (int i = 0; i < Logic.LogicList.Count; i++)
- {
- string s = Logic.LogicList[i].sid.Substring(20, 4);
- int iThisSceneId = Convert.ToInt16(s, 16);
- if (iThisSceneId > maxId)
- maxId = iThisSceneId;
- }
-
- logicId += (maxId + 1).ToString("X4");//閫昏緫鍙� 涓や釜byte
- logicId += "0000";
- }
- catch
- {
- return logicId;
- }
- return logicId;
- }
- /// <summary>
- /// 灏佽Dictionary瀵硅薄
- /// </summary>
- /// <param name="dic">Dictionary绫�</param>
- /// <param name="key">鍋�</param>
- /// <param name="value">鍊�</param>
- public void dictionary(Dictionary<string, string> dic, string key, string value)
- {
- if (dic.ContainsKey(key)) //鍒ゆ柇鏄惁瀛樺湪閿��
- {
- //閿瓨鍦ㄧЩ闄�
- dic.Remove(key);
- }
- //娣诲姞閿��
- dic.Add(key, value);
- }
- /// <summary>
- /// 鑾峰彇缃戝叧鎴块棿鍒楄〃
- /// </summary>
- /// <returns></returns>
- public List<HDL_ON.Entity.Room> GetGatewayRoomList()
- {
- return HDL_ON.Entity.SpatialInfo.CurrentSpatial.RoomList;
- }
- /// <summary>
- /// 鑾峰彇缃戝叧鎴块棿鍒楄〃
- /// </summary>
- /// <returns></returns>
- public List<HDL_ON.Entity.Room> GetGatewayRoomList(string name)
- {
- List<Entity.Room> roomList = new List<Entity.Room>();
- Entity.Room room1 = new Entity.Room();
- room1.roomName = name;//鑷畾涔夐粯璁や竴涓埧闂村悕涓�:6688
- room1.roomId = "6688";//鑷畾涔夐粯璁d鐢ㄨ瘑鍒鎴块棿
- roomList.Add(room1);//榛樿娣诲姞鍒版埧闂村垪琛ㄩ噷
- var roomLists = GetGatewayRoomList();
- for (int i = 0; i < roomLists.Count; i++)
- {
- var room = roomLists[i];
- var devlist = GetRoomDevice(room);
- if (devlist.Count == 0)
- {
- //杩囨护鎺夋病鏈夎澶囩殑鎴块棿;
- continue;
- }
- roomList.Add(room);
- }
- return roomList;
- }
- /// <summary>
- /// 鑾峰彇缃戝叧璁惧鍒楄〃
- /// </summary>
- /// <returns></returns>
- public List<HDL_ON.Entity.Function> GetGatewayDeviceList()
- {
- return Entity.FunctionList.List.GetDeviceFunctionList();
- }
- /// <summary>
- /// 鑾峰彇鍦烘櫙鍒楄〃
- /// </summary>
- /// <returns></returns>
- public List<HDL_ON.Entity.Scene> GetSceneList()
- {
- return HDL_ON.Entity.FunctionList.List.scenes;
- }
-
- /// <summary>
- /// 鑾峰彇瀹夐槻鍒楄〃
- /// </summary>
- /// <returns></returns>
- public List<HDL_ON.Entity.SecurityAlarm> GetSecurityList()
- {
- return FunctionList.List.securities;
- }
- /// <summary>
- /// 鑾峰彇鎴块棿鐨勮澶囧垪琛�
- /// </summary>
- /// <param name="room">褰撳墠鎴块棿</param>
- /// <returns></returns>
- public List<HDL_ON.Entity.Function> GetRoomDevice(HDL_ON.Entity.Room room)
- {
- List<HDL_ON.Entity.Function> deviceLists = new List<Entity.Function>();
- List<HDL_ON.Entity.Function> lists = GetGatewayDeviceList();
- if (room.roomId == "6688")
- {
- //榛樿涓�涓埧闂村悕锛�6688
- //鏄剧ず缃戝叧鍏ㄩ儴璁惧
- deviceLists = lists;
- }
- else
- {
- for (int i = 0; i < lists.Count; i++)
- {
- var dev = lists[i];
- if (dev.roomIds.Find((id) => id == room.roomId) != null)
- {
- //娣诲姞灞炰簬杩欎釜鎴块棿鐨勮澶�;
- deviceLists.Add(dev);
- }
-
- }
- }
- return deviceLists;
- }
- /// <summary>
- /// 鑾峰彇璁惧锛堝姛鑳斤級瀵硅薄
- /// </summary>
- /// <param name="sid">璁惧鍞竴鏍囪瘑</param>
- /// <returns></returns>
- public HDL_ON.Entity.Function GetDevice(string sid)
- {
- HDL_ON.Entity.Function device = new Entity.Function() { name = "Unknown" };
- List<HDL_ON.Entity.Function> deviceLists = GetGatewayDeviceList();
- for (int i = 0; i < deviceLists.Count; i++)
- {
- var dev = deviceLists[i];
- if (dev.sid == sid)
- {
- device = dev;
- break;
- }
- }
- return device;
- }
-
- /// <summary>
- /// 鑾峰彇鍦烘櫙瀵硅薄
- /// </summary>
- /// <param name="sid">鍦烘櫙鍞竴鏍囪瘑</param>
- /// <returns></returns>
- public HDL_ON.Entity.Scene GetSecne(string sid)
- {
- HDL_ON.Entity.Scene scene = new Entity.Scene() { name = "Unknown" };
- List<HDL_ON.Entity.Scene> sceneLists = GetSceneList();
- for (int i = 0; i < sceneLists.Count; i++)
- {
- var sce = sceneLists[i];
- if (sce.sid == sid)
- {
- scene = sce;
- break;
- }
- }
- return scene;
- }
- /// <summary>
- /// 鑾峰彇瀹夐槻瀵硅薄
- /// </summary>
- /// <param name="sid">瀹夐槻鍞竴鏍囪瘑</param>
- /// <returns></returns>
- public HDL_ON.Entity.SecurityAlarm GetSecurity(string sid)
- {
- HDL_ON.Entity.SecurityAlarm security = new Entity.SecurityAlarm() { name = "Unknown" };
- List<HDL_ON.Entity.SecurityAlarm> SecurityLists = GetSecurityList();
- for (int i = 0; i < SecurityLists.Count; i++)
- {
- var sce = SecurityLists[i];
- if (sce.sid == sid)
- {
- security = sce;
- break;
- }
- }
- return security;
- }
- /// <summary>
- /// 鑾峰彇鎴块棿鍚�(鍗虫槸=鍖哄煙鍚嶇О)
- /// </summary>
- /// <param name="device">璁惧</param>
- /// <returns></returns>
- public string GetGetRoomName(HDL_ON.Entity.Function device)
- {
- string roomName = "";
- List<HDL_ON.Entity.Room> roomLists = GetGatewayRoomList();
- for (int i = 0; i < device.roomIds.Count; i++)
- {
- var dev = device.roomIds[i];
- var room = roomLists.Find((c) => c.roomId == dev);
- if (room != null)
- {
- roomName += room.floorName + "." + room.roomName + ",";
- }
- }
-
- return roomName.TrimEnd(',');
- }
- #region 鍔ㄤ竴鏀瑰洓
- /// <summary>
- /// 鑾峰彇璁惧绫诲瀷鍥炬爣
- /// </summary>
- /// <param name="functionType">璁惧绫诲瀷</param>
- /// <returns></returns>
- public string GetIconPath(string functionType)
- {
- string strPath = "";
- switch (functionType)
- {
-
- case SPK.AirSwitch:
- {
- strPath = "FunctionIcon/Icon/electricalbreaker.png";
- }
- break;
- case SPK.PanelSocket:
- case SPK.ElectricSocket:
- {
- strPath = "FunctionIcon/Icon/electricalsocket.png";
- }
- break;
- case SPK.LightSwitch:
- case SPK.LightRGB:
- case SPK.LightRGBW:
- case SPK.LightCCT:
- case SPK.LightDimming:
- {
- strPath = "LogicIcon/lightloguc.png";
- }
- break;
- case SPK.CurtainSwitch:
- case SPK.CurtainRoller:
- case SPK.CurtainTrietex:
- {
- strPath = "LogicIcon/curtainlogic.png";
- }
- break;
- case SPK.AcStandard:
- case SPK.HvacAC:
- {
- strPath = "LogicIcon/airconditionerlogic.png";
- }
- break;
- case SPK.FloorHeatStandard:
- case SPK.HvacFloorHeat:
- {
- strPath = "LogicIcon/heatlogic.png";
- }
- break;
- case SPK.AirFreshStandard:
- case SPK.HvacAirFresh:
- {
- strPath = "LogicIcon/heatlogic.png";
- }
- break;
- case SPK.SensorSmoke:
- case SPK.SensorWater:
- case SPK.SensorGas:
- case SPK.SensorDryContact:
- case SPK.SensorDryContact2:
- case SPK.SensorShanLan:
- case SPK.SensorDuiShe:
- case SPK.SensorPir:
- case SPK.SensorDoorWindow:
- case SPK.SensorUtrasonic:
- case SPK.SenesorMegahealth:
- case SPK.SenesorMegahealth2:
- case SPK.SensorEnvironment:
- case SPK.SensorEnvironment2:
- case SPK.SensorEnvironment3:
- case SPK.SensorTemperature:
- case SPK.SensorHumidity:
- case SPK.SensorCO2:
- case SPK.SensorPm25:
- case SPK.SensorTVOC:
- case SPK.SensorHcho:
- {
- strPath = "LogicIcon/sensor.png";
- }
- break;
-
- }
- return strPath;
- }
- /// <summary>
- /// 璁惧绫诲瀷鐨勫垪琛�(鐏厜绫伙紝绐楀笜绫汇�傘�傘��)
- /// </summary>
- /// <param name="deviceList">璁惧鍒楄〃</param>
- /// <returns></returns>
- public List<string> GetDeviceTypeList(List<HDL_ON.Entity.Function> deviceList)
- {
- List<string> deviceStrTypeList = new List<string>();
- deviceStrTypeList.Clear();
- ///鐏厜绫�
- var lightjosn = deviceList.Find((device) =>
- device.spk == SPK.LightSwitch
- || device.spk == SPK.LightDimming
- || device.spk == SPK.LightCCT
- || device.spk == SPK.LightRGB
- || device.spk == SPK.LightRGBW
- );
- if (lightjosn != null)
- {
- deviceStrTypeList.Add(Language.StringByID(StringId.Lights));
- }
-
- ///绐楀笜绫�
- var curtainjosn = deviceList.Find((device) =>
- device.spk == SPK.CurtainSwitch
- || device.spk == SPK.CurtainTrietex
- || device.spk == SPK.CurtainRoller);
- if (curtainjosn != null)
- {
- deviceStrTypeList.Add(Language.StringByID(StringId.Curtain));
- }
- ///绌鸿皟绫�
- var ac = deviceList.Find((device) => device.spk == SPK.AcStandard || device.spk == SPK.HvacAC);
- if (ac != null)
- {
- deviceStrTypeList.Add(Language.StringByID(StringId.AC));
- }
- ///鍦版殩绫�
- var floorHeating = deviceList.Find((device) => device.spk == SPK.FloorHeatStandard || device.spk == SPK.HvacFloorHeat);
- if (floorHeating != null)
- {
- deviceStrTypeList.Add(Language.StringByID(StringId.FloorHeating));
- }
- ///鏂伴绫�
- var airFresh = deviceList.Find((device) => device.spk == SPK.AirFreshStandard || device.spk == SPK.HvacAirFresh);
- if (airFresh != null)
- {
- deviceStrTypeList.Add(Language.StringByID(StringId.AirFresh));
- }
- ///浼犳劅鍣ㄧ被
- var sensor = deviceList.Find((device) =>
- device.spk == SPK.SensorWater
- || device.spk == SPK.SensorGas
- || device.spk == SPK.SensorSmoke
- || device.spk == SPK.SensorDryContact || device.spk == SPK.SensorDryContact2
- || device.spk == SPK.SensorShanLan
- || device.spk == SPK.SensorDuiShe
- || device.spk == SPK.SensorPir
- || device.spk == SPK.SensorDoorWindow
- || device.spk == SPK.SensorUtrasonic
- || device.spk == SPK.SenesorMegahealth
- || device.spk == SPK.SenesorMegahealth2
- || device.spk == SPK.SensorEnvironment
- || device.spk == SPK.SensorEnvironment2
- || device.spk == SPK.SensorEnvironment3
- || device.spk == SPK.SensorTemperature
- || device.spk == SPK.SensorHumidity
- || device.spk == SPK.SensorCO2
- || device.spk == SPK.SensorPm25
- || device.spk == SPK.SensorTVOC
- || device.spk == SPK.SensorHcho
- );
- if (sensor != null)
- {
- deviceStrTypeList.Add(Language.StringByID(StringId.Sensor));
- }
- ///瀹剁數绫�
- var electric = deviceList.Find((device) =>
- device.spk == SPK.AirSwitch
- || device.spk == SPK.PanelSocket
- || device.spk == SPK.ElectricSocket
- );
- if (electric != null)
- {
- deviceStrTypeList.Add(Language.StringByID(StringId.Electric));
- }
- return deviceStrTypeList;
-
- }
- /// <summary>
- /// 璁惧绫诲瀷FunctionType鍒楄〃
- /// </summary>
- /// <param name="deviceType">璁惧绫诲瀷(鐏厜绫伙紝绐楀笜绫汇��)</param>
- /// <returns></returns>
- public List<string> GetDeviceTypeFunctionList(string deviceType)
- {
- List<string> functionTypeList = new List<string>();
- ///鐏厜绫�
- if (deviceType == Language.StringByID(StringId.Lights))
- {
- functionTypeList.Add(SPK.LightSwitch);
- functionTypeList.Add(SPK.LightDimming);
- functionTypeList.Add(SPK.LightRGB);
- functionTypeList.Add(SPK.LightRGBW);
- functionTypeList.Add(SPK.LightCCT);
- functionTypeList.Add(SPK.AirSwitch);
- functionTypeList.Add(SPK.PanelSocket);
- functionTypeList.Add(SPK.ElectricSocket);
- }
- ///绐楀笜绫�
- else if (deviceType == Language.StringByID(StringId.Curtain))
- {
- functionTypeList.Add(SPK.CurtainSwitch);
- functionTypeList.Add(SPK.CurtainRoller);
- functionTypeList.Add(SPK.CurtainTrietex);
- }
- ///绌鸿皟绫�
- else if (deviceType == Language.StringByID(StringId.AC))
- {
- functionTypeList.Add(SPK.AcStandard);
- functionTypeList.Add(SPK.HvacAC);
- }
- ///鍦版殩绫�
- else if (deviceType == Language.StringByID(StringId.FloorHeating))
- {
- functionTypeList.Add(SPK.FloorHeatStandard); functionTypeList.Add(SPK.HvacFloorHeat);
- }
- ///鏂伴绫�
- else if (deviceType == Language.StringByID(StringId.AirFresh))
- {
- functionTypeList.Add(SPK.AirFreshStandard); functionTypeList.Add(SPK.HvacAirFresh);
- }
- ///浼犳劅鍣ㄧ被
- else if (deviceType == Language.StringByID(StringId.Sensor))
- {
- functionTypeList.Add(SPK.SensorSmoke);
- functionTypeList.Add(SPK.SensorWater);
- functionTypeList.Add(SPK.SensorGas);
- functionTypeList.Add(SPK.SensorDryContact); functionTypeList.Add(SPK.SensorDryContact2);
- functionTypeList.Add(SPK.SensorShanLan);
- functionTypeList.Add(SPK.SensorDuiShe);
- functionTypeList.Add(SPK.SensorPir);
- functionTypeList.Add(SPK.SensorDoorWindow);
- functionTypeList.Add(SPK.SensorUtrasonic);
- functionTypeList.Add(SPK.SenesorMegahealth);
- functionTypeList.Add(SPK.SenesorMegahealth2);
- functionTypeList.Add(SPK.SensorEnvironment);
- functionTypeList.Add(SPK.SensorEnvironment2);
- functionTypeList.Add(SPK.SensorEnvironment3);
- functionTypeList.Add(SPK.SensorTemperature);
- functionTypeList.Add(SPK.SensorHumidity);
- functionTypeList.Add(SPK.SensorCO2);
- functionTypeList.Add(SPK.SensorPm25);
- functionTypeList.Add(SPK.SensorTVOC);
- functionTypeList.Add(SPK.SensorHcho);
-
-
- }
- ///瀹剁數绫�
- else if (deviceType == Language.StringByID(StringId.Electric))
- {
- functionTypeList.Add(SPK.AirSwitch);
- functionTypeList.Add(SPK.PanelSocket);
- functionTypeList.Add(SPK.ElectricSocket);
- }
-
-
- return functionTypeList;
-
- }
- /// <summary>
- /// 鏉′欢/鐩爣鏀寔璁惧
- /// </summary>
- /// <returns></returns>
- public List<string> GetSupportEquipment(string if_type)
- {
- List<string> deviceTypeList = new List<string>();
- switch (if_type)
- {
- case condition_if:
- {
- deviceTypeList.Add(SPK.LightSwitch);
- deviceTypeList.Add(SPK.LightRGB);
- deviceTypeList.Add(SPK.LightRGBW);
- deviceTypeList.Add(SPK.LightDimming);
- deviceTypeList.Add(SPK.LightCCT);
- deviceTypeList.Add(SPK.CurtainSwitch);
- deviceTypeList.Add(SPK.CurtainRoller);
- deviceTypeList.Add(SPK.CurtainTrietex);
- deviceTypeList.Add(SPK.AcStandard); deviceTypeList.Add(SPK.HvacAC);
- deviceTypeList.Add(SPK.AirFreshStandard); deviceTypeList.Add(SPK.HvacAirFresh);
- deviceTypeList.Add(SPK.FloorHeatStandard); deviceTypeList.Add(SPK.HvacFloorHeat);
- deviceTypeList.Add(SPK.SensorSmoke);
- deviceTypeList.Add(SPK.SensorWater);
- deviceTypeList.Add(SPK.SensorGas);
- deviceTypeList.Add(SPK.SensorDryContact); deviceTypeList.Add(SPK.SensorDryContact2);
- deviceTypeList.Add(SPK.SensorShanLan);
- deviceTypeList.Add(SPK.SensorDuiShe);
- deviceTypeList.Add(SPK.SensorPir);
- deviceTypeList.Add(SPK.SensorDoorWindow);
- deviceTypeList.Add(SPK.SensorUtrasonic);
- deviceTypeList.Add(SPK.SenesorMegahealth);
- deviceTypeList.Add(SPK.SenesorMegahealth2);
- deviceTypeList.Add(SPK.SensorEnvironment);
- deviceTypeList.Add(SPK.SensorEnvironment2);
- deviceTypeList.Add(SPK.SensorEnvironment3);
- deviceTypeList.Add(SPK.SensorTemperature);
- deviceTypeList.Add(SPK.SensorHumidity);
- deviceTypeList.Add(SPK.SensorCO2);
- deviceTypeList.Add(SPK.SensorPm25);
- deviceTypeList.Add(SPK.SensorTVOC);
- deviceTypeList.Add(SPK.SensorHcho);
- deviceTypeList.Add(SPK.AirSwitch);
- deviceTypeList.Add(SPK.PanelSocket);
- deviceTypeList.Add(SPK.ElectricSocket);
-
- }
- break;
- case target_if:
- {
- deviceTypeList.Add(SPK.LightSwitch);
- deviceTypeList.Add(SPK.LightRGB);
- deviceTypeList.Add(SPK.LightRGBW);
- deviceTypeList.Add(SPK.LightDimming);
- deviceTypeList.Add(SPK.LightCCT);
- deviceTypeList.Add(SPK.CurtainSwitch);
- deviceTypeList.Add(SPK.CurtainRoller);
- deviceTypeList.Add(SPK.CurtainTrietex);
- deviceTypeList.Add(SPK.AcStandard); deviceTypeList.Add(SPK.HvacAC);
- deviceTypeList.Add(SPK.FloorHeatStandard); deviceTypeList.Add(SPK.HvacFloorHeat);
- deviceTypeList.Add(SPK.AirFreshStandard); deviceTypeList.Add(SPK.HvacAirFresh);
- deviceTypeList.Add(SPK.AirSwitch);
- deviceTypeList.Add(SPK.PanelSocket);
- deviceTypeList.Add(SPK.ElectricSocket);
- }
- break;
- }
- return deviceTypeList;
- }
- #endregion
- /// <summary>
- /// 鏄剧ず鐨勮澶囧垪琛�
- /// </summary>
- /// <param name="functionType">婧愭暟鎹垪琛�1</param>
- /// <param name="deviceList">婧愭暟鎹垪琛�2</param>
- /// <returns></returns>
- public List<Entity.Function> GetShowDeviceList(List<string> functionType, List<HDL_ON.Entity.Function> deviceList)
- {
- List<HDL_ON.Entity.Function> devList = new List<Entity.Function>();
- for (int i = 0; i < deviceList.Count; i++)
- {
- var dev = deviceList[i];
- //杩囨护鎺変笉闇�瑕佹樉绀虹殑璁惧
- if (functionType.Contains(dev.spk))
- {
- devList.Add(dev);
- }
-
- }
-
- return devList;
- }
- /// <summary>
- /// 杩斿洖鏈�缁堟敮鎸佹樉绀哄嚭鏉ョ殑璁惧鍒楄〃
- /// </summary>
- /// <param name="room">褰撳墠鎴块棿</param>
- /// <param name="str">鍒ゆ柇绗︼紙琛ㄧず=杈撳叆璁惧鍜岃緭鍑鸿澶囷級</param>
- /// <returns></returns>
- public List<Entity.Function> GetFunctionDeviceList(Entity.Room room, string str)
- {
- List<string> functionTypeList = GetSupportEquipment(str);
- //杩斿洖鎴块棿璁惧鍒楄〃
- var roomDeviceList = GetRoomDevice(room);
- //杩斿洖鏈�缁堟敮鎸佹樉绀哄嚭鏉ョ殑璁惧鍒楄〃
- var list = GetShowDeviceList(functionTypeList, roomDeviceList);
- return list;
- }
- /// <summary>
- /// 缃戝叧ID(鑾峰彇鍢変箰缃戝叧ID)
- /// </summary>
- public string GatewayId
- {
- get
- {
- if (Entity.DB_ResidenceData.Instance.HomeGateway == null)
- {
- return DriverLayer.Control.Ins.GatewayId;
- }
- return Entity.DB_ResidenceData.Instance.HomeGateway.gatewayId;
- }
- }
- /// <summary>
- /// 浣忓畢ID
- /// </summary>
- public string HomeId
- {
- get
- {
- return Entity.DB_ResidenceData.Instance.CurrentRegion.id;
- }
- }
- /// <summary>
- /// 鏄惁涓哄叾浠栦富鐢ㄦ埛鍒嗕韩杩囨潵鐨勪綇瀹�
- /// </summary>
- public bool IsOthreShare
- {
- get
- {
- return Entity.DB_ResidenceData.Instance.CurrentRegion.isOtherShare;
- }
- }
-
- #region 楂樺痉鍧愭爣杞琖GS84鍧愭爣
- /// <summary>
- /// 楂樺痉鍧愭爣杞琖GS84鍧愭爣
- /// </summary>
- /// <param name="in_lng"></param>
- /// <param name="in_lat"></param>
- /// <param name="out_lng"></param>
- /// <param name="out_lat"></param>
- public void GCJ02_to_WGS84(double in_lng, double in_lat, out double out_lng, out double out_lat)
- {
- if (OutOfChina(in_lat, in_lng))
- {
- out_lng = in_lng;
- out_lat = in_lat;
- return;
- }
-
- CalculateDev(in_lng, in_lat, out out_lng, out out_lat);
- out_lng = in_lng - out_lng;
- out_lat = in_lat - out_lat;
- }
- #endregion
-
- #region WGS84鍧愭爣杞珮寰峰潗鏍�
- /// <summary>
- /// WGS84鍧愭爣杞珮寰峰潗鏍�
- /// </summary>
- /// <param name="in_lng">缁忓害</param>
- /// <param name="in_lat">绾害</param>
- /// <param name="out_lng"></param>
- /// <param name="out_lat"></param>
- public void WGS84_to_GCJ02(double in_lng, double in_lat, out double out_lng, out double out_lat)
- {
- if (OutOfChina(in_lat, in_lng))
- {
- out_lng = in_lng;
- out_lat = in_lat;
- return;
- }
-
- CalculateDev(in_lng, in_lat, out out_lng, out out_lat);
- out_lng = in_lng + out_lng;
- out_lat = in_lat + out_lat;
- }
- #endregion
-
- /// <summary>
- /// 鍧愭爣鏄惁鍦ㄤ腑鍥藉鍐�
- /// </summary>
- /// <param name="lat"></param>
- /// <param name="lng"></param>
- /// <returns></returns>
- public bool OutOfChina(double lat, double lng)
- {
- if (lng < 72.004 || lng > 137.8347)
- return true;
- if (lat < 0.8293 || lat > 55.8271)
- return true;
- return false;
- }
- /// <summary>
- /// 璁$畻鍋忓樊
- /// </summary>
- /// <param name="in_lng"></param>
- /// <param name="in_lat"></param>
- /// <param name="dLng"></param>
- /// <param name="dLat"></param>
- private void CalculateDev(double in_lng, double in_lat, out double dLng, out double dLat)
- {
- dLat = TransformLat(in_lng - 105.0, in_lat - 35.0);
- dLng = TransformLng(in_lng - 105.0, in_lat - 35.0);
-
- double radLat = in_lat / 180.0 * pi;
- double magic = Math.Sin(radLat);
- magic = 1 - ee * magic * magic;
- double sqrtMagic = Math.Sqrt(magic);
- dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi);
- dLng = (dLng * 180.0) / (a / sqrtMagic * Math.Cos(radLat) * pi);
- }
-
- private double TransformLat(double x, double y)
- {
- double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.Sqrt(Math.Abs(x));
- ret += (20.0 * Math.Sin(6.0 * x * pi) + 20.0 * Math.Sin(2.0 * x * pi)) * 2.0 / 3.0;
- ret += (20.0 * Math.Sin(y * pi) + 40.0 * Math.Sin(y / 3.0 * pi)) * 2.0 / 3.0;
- ret += (160.0 * Math.Sin(y / 12.0 * pi) + 320 * Math.Sin(y * pi / 30.0)) * 2.0 / 3.0;
- return ret;
- }
- private double TransformLng(double x, double y)
- {
- double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.Sqrt(Math.Abs(x));
- ret += (20.0 * Math.Sin(6.0 * x * pi) + 20.0 * Math.Sin(2.0 * x * pi)) * 2.0 / 3.0;
- ret += (20.0 * Math.Sin(x * pi) + 40.0 * Math.Sin(x / 3.0 * pi)) * 2.0 / 3.0;
- ret += (150.0 * Math.Sin(x / 12.0 * pi) + 300.0 * Math.Sin(x / 30.0 * pi)) * 2.0 / 3.0;
- return ret;
- }
- // 妞悆鍙傛暟-鍦嗗懆鐜�
- private const double pi = 3.14159265358979324;
-
- // (鍖椾含54)妞悆闀垮崐杞达紝鍗槦妞悆鍧愭爣鎶曞奖鍒板钩闈㈠湴鍥惧潗鏍囩郴鐨勬姇褰卞洜瀛�
- private const double a = 6378245.0;
- /*
- * Krasovsky 1940 (鍖椾含54)妞悆闀垮崐杞寸涓�鍋忓績鐜囧钩鏂�
- * 璁$畻鏂瑰紡锛�
- * 闀垮崐杞达細
- * a = 6378245.0
- * 鎵佺巼锛�
- * 1/f = 298.3锛堝彉閲忕浉鍏宠绠椾负锛�(a-b)/a锛�
- * 鐭崐杞达細
- * b = 6356863.0188 (鍙橀噺鐩稿叧璁$畻鏂规硶涓猴細b = a * (1 - f))
- * 绗竴鍋忓績鐜囧钩鏂�:
- * e2 = (a^2 - b^2) / a^2;
- */
- private const double ee = 0.00669342162296594323;
-
- /// <summary>
- /// APP涓婃姤GPS缁忕含搴�
- /// </summary>
- public void AppLatAndLonEvent()
- {
- Application.LocationAction += (lon, lat) =>
- {
- ////GPS鍧愭爣杞垚楂樺痉鍧愭爣
- //double out_lng, out_lat;
- //this.WGS84_to_GCJ02(lon, lat, out out_lng, out out_lat);
- //涓婃姤缁忕含搴�
- this.AutomatedGeofenceStatusReporting(lon, lat);
- };
- }
-
- /// <summary>
- /// 鑷姩鍖栧湴鐞嗗洿鏍忕姸鎬佷笂鎶ヤ簯绔�
- /// </summary>
- /// <param name="out_lng">APP GPS缁忓害</param>
- /// <param name="out_lat">APP GPS绾害</param>
- private void AutomatedGeofenceStatusReporting(double out_lng, double out_lat)
- {
- List<LogicData> logicDataList = new List<LogicData>();
- logicDataList.Clear();
- //鑾峰彇閫昏緫ID鍒楄〃
- var idStr = Send.GetLogicIdList();
- if (idStr.Code == "0" && idStr.Data != null && idStr.Data.ToString() != "")
- {
- var date = Newtonsoft.Json.JsonConvert.SerializeObject(idStr.Data);
- logicDataList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<LogicData>>(date);
- }
- ///鏈夎嚜鍔ㄥ垪琛ㄦ墠澶勭悊
- if (logicDataList.Count>0) {
- ///閬嶅巻鎵�鏈夊垪琛�
- for (int i = 0; i < logicDataList.Count; i++)
- {
- var logicDate = logicDataList[i];
- ///鑷姩鍖栨病鏈夐厤缃湴鐞嗗洿鏍忎笉澶勭悊
- if (string.IsNullOrEmpty(logicDate.geo_fence.latitude) || string.IsNullOrEmpty(logicDate.geo_fence.longitude))
- {
- //缁忕含搴︿负绌�,璁や负鑷姩鍖栨病鏈夐厤缃湴鐞嗗洿鏍忥紝涓嶅鐞�;
- continue;
- }
- //鑷姩鍖栫含搴�
- double lat = Convert.ToDouble(logicDate.geo_fence.latitude);
- //鑷姩鍖栫粡搴�
- double lon = Convert.ToDouble(logicDate.geo_fence.longitude);
- //鑷姩鍖栭厤缃緭鍏ユ潯浠�<鍦扮悊鍥存爮鍗婂緞><鍗曚綅锛屽叕閲屻�佸崈绫�.绫�>
- int radius = int.Parse(logicDate.geo_fence.radius);
- //璁$畻2涓粡绾害涔嬮棿鐨勮窛绂�
- int r =Infrastructure.Service.Helper.CalculatedDistance.Distance(out_lat, out_lng, lat, lon);
- //瀹氫箟涓�涓眬閮ㄥ彉閲�
- string direction = string.Empty;
- //涓ょ偣璺濈灏忎簬閰嶇疆璺濈<鏃㈣嚜鍔ㄥ寲閰嶇疆杈撳叆鏉′欢鍦扮悊鍥存爮鍗婂緞>,璇存槑杩涘叆鍖哄煙
- if (r<radius) {
- //鍒拌揪鏌愬湴
- direction = "arrive";
- } else {
- //绂诲紑
- direction = "leave";
- }
- bool f= Send.GeoFenceStateReport(logicDate.userLogicId,logicDate.sid, direction);
- //if () { }
- //Common.FileUtlis.Files.WriteFileByBytes(savePath, ssd);
- }
-
- }
-
- }
+ return logicMethod;
+ }
}
+
+ /// <summary>
+ /// 琛ㄧず鏄潯浠�
+ /// </summary>
+ public const string condition_if = "鏉′欢";
+ /// <summary>
+ /// 琛ㄧず鏄洰鏍�
+ /// </summary>
+ public const string target_if = "鐩爣";
+ /// <summary>
+ /// 绉婚櫎鎵�鏈�"Logic"鐣岄潰
+ /// </summary>
+ public void RemoveAllView()
+ {
+ MainPage.BasePageView.RemoveViewByTag("Logic");
+ }
+
+ /// <summary> Converts an array of bytes into a formatted string of hex digits (ex: E4 CA B2)</summary>
+ /// <param name="data"> The array of bytes to be translated into a string of hex digits. </param>
+ /// <returns> Returns a well formatted string of hex digits with spacing. </returns>
+ public string byteArrayToHexString(byte[] data)
+ {
+ System.Text.StringBuilder sb = new System.Text.StringBuilder();
+ foreach (byte b in data)
+ {
+ sb.Append(Convert.ToString(b, 16).PadLeft(2, '0'));
+ }
+
+ return sb.ToString().ToUpper();
+ }
+
+ /**
+* int杞琤yte[]
+* 璇ユ柟娉曞皢涓�涓猧nt绫诲瀷鐨勬暟鎹浆鎹负byte[]褰㈠紡锛屽洜涓篿nt涓�32bit锛岃�宐yte涓�8bit鎵�浠ュ湪杩涜绫诲瀷杞崲鏃讹紝鐭ヤ細鑾峰彇浣�8浣嶏紝
+* 涓㈠純楂�24浣嶃�傞�氳繃浣嶇Щ鐨勬柟寮忥紝灏�32bit鐨勬暟鎹浆鎹㈡垚4涓�8bit鐨勬暟鎹�傛敞鎰� &0xff锛屽湪杩欏綋涓紝&0xff绠�鍗曠悊瑙d负涓�鎶婂壀鍒�锛�
+* 灏嗘兂瑕佽幏鍙栫殑8浣嶆暟鎹埅鍙栧嚭鏉ャ��
+* @param i 涓�涓猧nt鏁板瓧
+* @return byte[]
+*/
+ public byte[] int2ByteArray(int i)
+ {
+ byte[] result = new byte[4];
+ result[0] = (byte)((i >> 24) & 0xFF);
+ result[1] = (byte)((i >> 16) & 0xFF);
+ result[2] = (byte)((i >> 8) & 0xFF);
+ result[3] = (byte)(i & 0xFF);
+ return result;
+ }
+ /// <summary>
+ /// 鑾峰彇鏃堕棿鎴�
+ /// </summary>
+ /// <returns></returns>
+ public int getTimeStamp()
+ {
+ TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
+ return (int)ts.TotalSeconds;
+ }
+ /// <summary>
+ /// 鐢熸垚閫昏緫sid鏂规硶
+ /// </summary>
+ public string NewSid()
+ {
+ string logicId = "";
+ try
+ {
+ string sOidBeginsWith = "000101";//鍘傚晢 + 閫氳鏂瑰紡
+ DateTime dt = DateTime.Now;
+ DateTime startTime = TimeZoneInfo.ConvertTimeToUtc(new DateTime(2020, 1, 1));
+ long m = (long)((dt - startTime).TotalMilliseconds / 10);
+ string sTimeSpan = byteArrayToHexString(int2ByteArray(getTimeStamp()));
+
+
+
+ logicId = sOidBeginsWith + sTimeSpan;
+
+ logicId += "15";
+ logicId += "1501";
+ //1501 鐗╂ā鍨嬩负閫昏緫锛� 0001 琛ㄧず 1 鍙烽�昏緫鍔熻兘
+ int maxId = 1;
+
+
+ for (int i = 0; i < Logic.LogicList.Count; i++)
+ {
+ string s = Logic.LogicList[i].sid.Substring(20, 4);
+ int iThisSceneId = Convert.ToInt16(s, 16);
+ if (iThisSceneId > maxId)
+ maxId = iThisSceneId;
+ }
+
+ logicId += (maxId + 1).ToString("X4");//閫昏緫鍙� 涓や釜byte
+ logicId += "0000";
+ }
+ catch
+ {
+ return logicId;
+ }
+ return logicId;
+ }
+ /// <summary>
+ /// 灏佽Dictionary瀵硅薄
+ /// </summary>
+ /// <param name="dic">Dictionary绫�</param>
+ /// <param name="key">鍋�</param>
+ /// <param name="value">鍊�</param>
+ public void dictionary(Dictionary<string, string> dic, string key, string value)
+ {
+ if (dic.ContainsKey(key)) //鍒ゆ柇鏄惁瀛樺湪閿��
+ {
+ //閿瓨鍦ㄧЩ闄�
+ dic.Remove(key);
+ }
+ //娣诲姞閿��
+ dic.Add(key, value);
+ }
+ /// <summary>
+ /// 鑾峰彇缃戝叧鎴块棿鍒楄〃
+ /// </summary>
+ /// <returns></returns>
+ public List<HDL_ON.Entity.Room> GetGatewayRoomList()
+ {
+ return HDL_ON.Entity.SpatialInfo.CurrentSpatial.RoomList;
+ }
+ /// <summary>
+ /// 鑾峰彇缃戝叧鎴块棿鍒楄〃
+ /// </summary>
+ /// <returns></returns>
+ public List<HDL_ON.Entity.Room> GetGatewayRoomList(string name)
+ {
+ List<Entity.Room> roomList = new List<Entity.Room>();
+ Entity.Room room1 = new Entity.Room();
+ room1.roomName = name;//鑷畾涔夐粯璁や竴涓埧闂村悕涓�:6688
+ room1.roomId = "6688";//鑷畾涔夐粯璁d鐢ㄨ瘑鍒鎴块棿
+ roomList.Add(room1);//榛樿娣诲姞鍒版埧闂村垪琛ㄩ噷
+ var roomLists = GetGatewayRoomList();
+ for (int i = 0; i < roomLists.Count; i++)
+ {
+ var room = roomLists[i];
+ var devlist = GetRoomDevice(room);
+ if (devlist.Count == 0)
+ {
+ //杩囨护鎺夋病鏈夎澶囩殑鎴块棿;
+ continue;
+ }
+ roomList.Add(room);
+ }
+ return roomList;
+ }
+ /// <summary>
+ /// 鑾峰彇缃戝叧璁惧鍒楄〃
+ /// </summary>
+ /// <returns></returns>
+ public List<HDL_ON.Entity.Function> GetGatewayDeviceList()
+ {
+ return Entity.FunctionList.List.GetDeviceFunctionList();
+ }
+ /// <summary>
+ /// 鑾峰彇鍦烘櫙鍒楄〃
+ /// </summary>
+ /// <returns></returns>
+ public List<HDL_ON.Entity.Scene> GetSceneList()
+ {
+ return HDL_ON.Entity.FunctionList.List.scenes;
+ }
+
+ /// <summary>
+ /// 鑾峰彇瀹夐槻鍒楄〃
+ /// </summary>
+ /// <returns></returns>
+ public List<HDL_ON.Entity.SecurityAlarm> GetSecurityList()
+ {
+ return FunctionList.List.securities;
+ }
+ /// <summary>
+ /// 鑾峰彇鎴块棿鐨勮澶囧垪琛�
+ /// </summary>
+ /// <param name="room">褰撳墠鎴块棿</param>
+ /// <returns></returns>
+ public List<HDL_ON.Entity.Function> GetRoomDevice(HDL_ON.Entity.Room room)
+ {
+ List<HDL_ON.Entity.Function> deviceLists = new List<Entity.Function>();
+ List<HDL_ON.Entity.Function> lists = GetGatewayDeviceList();
+ if (room.roomId == "6688")
+ {
+ //榛樿涓�涓埧闂村悕锛�6688
+ //鏄剧ず缃戝叧鍏ㄩ儴璁惧
+ deviceLists = lists;
+ }
+ else
+ {
+ for (int i = 0; i < lists.Count; i++)
+ {
+ var dev = lists[i];
+ if (dev.roomIds.Find((id) => id == room.roomId) != null)
+ {
+ //娣诲姞灞炰簬杩欎釜鎴块棿鐨勮澶�;
+ deviceLists.Add(dev);
+ }
+
+ }
+ }
+ return deviceLists;
+ }
+ /// <summary>
+ /// 鑾峰彇璁惧锛堝姛鑳斤級瀵硅薄
+ /// </summary>
+ /// <param name="sid">璁惧鍞竴鏍囪瘑</param>
+ /// <returns></returns>
+ public HDL_ON.Entity.Function GetDevice(string sid)
+ {
+ HDL_ON.Entity.Function device = new Entity.Function() { name = "Unknown" };
+ List<HDL_ON.Entity.Function> deviceLists = GetGatewayDeviceList();
+ for (int i = 0; i < deviceLists.Count; i++)
+ {
+ var dev = deviceLists[i];
+ if (dev.sid == sid)
+ {
+ device = dev;
+ break;
+ }
+ }
+ return device;
+ }
+
+ /// <summary>
+ /// 鑾峰彇鍦烘櫙瀵硅薄
+ /// </summary>
+ /// <param name="sid">鍦烘櫙鍞竴鏍囪瘑</param>
+ /// <returns></returns>
+ public HDL_ON.Entity.Scene GetSecne(string sid)
+ {
+ HDL_ON.Entity.Scene scene = new Entity.Scene() { name = "Unknown" };
+ List<HDL_ON.Entity.Scene> sceneLists = GetSceneList();
+ for (int i = 0; i < sceneLists.Count; i++)
+ {
+ var sce = sceneLists[i];
+ if (sce.sid == sid)
+ {
+ scene = sce;
+ break;
+ }
+ }
+ return scene;
+ }
+ /// <summary>
+ /// 鑾峰彇瀹夐槻瀵硅薄
+ /// </summary>
+ /// <param name="sid">瀹夐槻鍞竴鏍囪瘑</param>
+ /// <returns></returns>
+ public HDL_ON.Entity.SecurityAlarm GetSecurity(string sid)
+ {
+ HDL_ON.Entity.SecurityAlarm security = new Entity.SecurityAlarm() { name = "Unknown" };
+ List<HDL_ON.Entity.SecurityAlarm> SecurityLists = GetSecurityList();
+ for (int i = 0; i < SecurityLists.Count; i++)
+ {
+ var sce = SecurityLists[i];
+ if (sce.sid == sid)
+ {
+ security = sce;
+ break;
+ }
+ }
+ return security;
+ }
+ /// <summary>
+ /// 鑾峰彇鎴块棿鍚�(鍗虫槸=鍖哄煙鍚嶇О)
+ /// </summary>
+ /// <param name="device">璁惧</param>
+ /// <returns></returns>
+ public string GetGetRoomName(HDL_ON.Entity.Function device)
+ {
+ string roomName = "";
+ List<HDL_ON.Entity.Room> roomLists = GetGatewayRoomList();
+ for (int i = 0; i < device.roomIds.Count; i++)
+ {
+ var dev = device.roomIds[i];
+ var room = roomLists.Find((c) => c.roomId == dev);
+ if (room != null)
+ {
+ roomName += room.floorName + "." + room.roomName + ",";
+ }
+ }
+
+ return roomName.TrimEnd(',');
+ }
+ #region 鍔ㄤ竴鏀瑰洓
+ /// <summary>
+ /// 鑾峰彇璁惧绫诲瀷鍥炬爣
+ /// </summary>
+ /// <param name="functionType">璁惧绫诲瀷</param>
+ /// <returns></returns>
+ public string GetIconPath(string functionType)
+ {
+ string strPath = "";
+ switch (functionType)
+ {
+
+ case SPK.AirSwitch:
+ {
+ strPath = "FunctionIcon/Icon/electricalbreaker.png";
+ }
+ break;
+ case SPK.PanelSocket:
+ case SPK.ElectricSocket:
+ {
+ strPath = "FunctionIcon/Icon/electricalsocket.png";
+ }
+ break;
+ case SPK.LightSwitch:
+ case SPK.LightRGB:
+ case SPK.LightRGBW:
+ case SPK.LightCCT:
+ case SPK.LightDimming:
+ {
+ strPath = "LogicIcon/lightloguc.png";
+ }
+ break;
+ case SPK.CurtainSwitch:
+ case SPK.CurtainRoller:
+ case SPK.CurtainTrietex:
+ {
+ strPath = "LogicIcon/curtainlogic.png";
+ }
+ break;
+ case SPK.AcStandard:
+ case SPK.HvacAC:
+ {
+ strPath = "LogicIcon/airconditionerlogic.png";
+ }
+ break;
+ case SPK.FloorHeatStandard:
+ case SPK.HvacFloorHeat:
+ {
+ strPath = "LogicIcon/heatlogic.png";
+ }
+ break;
+ case SPK.AirFreshStandard:
+ case SPK.HvacAirFresh:
+ {
+ strPath = "LogicIcon/heatlogic.png";
+ }
+ break;
+ case SPK.SensorSmoke:
+ case SPK.SensorWater:
+ case SPK.SensorGas:
+ case SPK.SensorDryContact:
+ case SPK.SensorDryContact2:
+ case SPK.SensorShanLan:
+ case SPK.SensorDuiShe:
+ case SPK.SensorPir:
+ case SPK.SensorDoorWindow:
+ case SPK.SensorUtrasonic:
+ case SPK.SenesorMegahealth:
+ case SPK.SenesorMegahealth2:
+ case SPK.SensorEnvironment:
+ case SPK.SensorEnvironment2:
+ case SPK.SensorEnvironment3:
+ case SPK.SensorTemperature:
+ case SPK.SensorHumidity:
+ case SPK.SensorCO2:
+ case SPK.SensorPm25:
+ case SPK.SensorTVOC:
+ case SPK.SensorHcho:
+ {
+ strPath = "LogicIcon/sensor.png";
+ }
+ break;
+
+ }
+ return strPath;
+ }
+ /// <summary>
+ /// 璁惧绫诲瀷鐨勫垪琛�(鐏厜绫伙紝绐楀笜绫汇�傘�傘��)
+ /// </summary>
+ /// <param name="deviceList">璁惧鍒楄〃</param>
+ /// <returns></returns>
+ public List<string> GetDeviceTypeList(List<HDL_ON.Entity.Function> deviceList)
+ {
+ List<string> deviceStrTypeList = new List<string>();
+ deviceStrTypeList.Clear();
+ ///鐏厜绫�
+ var lightjosn = deviceList.Find((device) =>
+ device.spk == SPK.LightSwitch
+ || device.spk == SPK.LightDimming
+ || device.spk == SPK.LightCCT
+ || device.spk == SPK.LightRGB
+ || device.spk == SPK.LightRGBW
+ );
+ if (lightjosn != null)
+ {
+ deviceStrTypeList.Add(Language.StringByID(StringId.Lights));
+ }
+
+ ///绐楀笜绫�
+ var curtainjosn = deviceList.Find((device) =>
+ device.spk == SPK.CurtainSwitch
+ || device.spk == SPK.CurtainTrietex
+ || device.spk == SPK.CurtainRoller);
+ if (curtainjosn != null)
+ {
+ deviceStrTypeList.Add(Language.StringByID(StringId.Curtain));
+ }
+ ///绌鸿皟绫�
+ var ac = deviceList.Find((device) => device.spk == SPK.AcStandard || device.spk == SPK.HvacAC);
+ if (ac != null)
+ {
+ deviceStrTypeList.Add(Language.StringByID(StringId.AC));
+ }
+ ///鍦版殩绫�
+ var floorHeating = deviceList.Find((device) => device.spk == SPK.FloorHeatStandard || device.spk == SPK.HvacFloorHeat);
+ if (floorHeating != null)
+ {
+ deviceStrTypeList.Add(Language.StringByID(StringId.FloorHeating));
+ }
+ ///鏂伴绫�
+ var airFresh = deviceList.Find((device) => device.spk == SPK.AirFreshStandard || device.spk == SPK.HvacAirFresh);
+ if (airFresh != null)
+ {
+ deviceStrTypeList.Add(Language.StringByID(StringId.AirFresh));
+ }
+ ///浼犳劅鍣ㄧ被
+ var sensor = deviceList.Find((device) =>
+ device.spk == SPK.SensorWater
+ || device.spk == SPK.SensorGas
+ || device.spk == SPK.SensorSmoke
+ || device.spk == SPK.SensorDryContact || device.spk == SPK.SensorDryContact2
+ || device.spk == SPK.SensorShanLan
+ || device.spk == SPK.SensorDuiShe
+ || device.spk == SPK.SensorPir
+ || device.spk == SPK.SensorDoorWindow
+ || device.spk == SPK.SensorUtrasonic
+ || device.spk == SPK.SenesorMegahealth
+ || device.spk == SPK.SenesorMegahealth2
+ || device.spk == SPK.SensorEnvironment
+ || device.spk == SPK.SensorEnvironment2
+ || device.spk == SPK.SensorEnvironment3
+ || device.spk == SPK.SensorTemperature
+ || device.spk == SPK.SensorHumidity
+ || device.spk == SPK.SensorCO2
+ || device.spk == SPK.SensorPm25
+ || device.spk == SPK.SensorTVOC
+ || device.spk == SPK.SensorHcho
+ );
+ if (sensor != null)
+ {
+ deviceStrTypeList.Add(Language.StringByID(StringId.Sensor));
+ }
+ ///瀹剁數绫�
+ var electric = deviceList.Find((device) =>
+ device.spk == SPK.AirSwitch
+ || device.spk == SPK.PanelSocket
+ || device.spk == SPK.ElectricSocket
+ );
+ if (electric != null)
+ {
+ deviceStrTypeList.Add(Language.StringByID(StringId.Electric));
+ }
+ return deviceStrTypeList;
+
+ }
+ /// <summary>
+ /// 璁惧绫诲瀷FunctionType鍒楄〃
+ /// </summary>
+ /// <param name="deviceType">璁惧绫诲瀷(鐏厜绫伙紝绐楀笜绫汇��)</param>
+ /// <returns></returns>
+ public List<string> GetDeviceTypeFunctionList(string deviceType)
+ {
+ List<string> functionTypeList = new List<string>();
+ ///鐏厜绫�
+ if (deviceType == Language.StringByID(StringId.Lights))
+ {
+ functionTypeList.Add(SPK.LightSwitch);
+ functionTypeList.Add(SPK.LightDimming);
+ functionTypeList.Add(SPK.LightRGB);
+ functionTypeList.Add(SPK.LightRGBW);
+ functionTypeList.Add(SPK.LightCCT);
+ functionTypeList.Add(SPK.AirSwitch);
+ functionTypeList.Add(SPK.PanelSocket);
+ functionTypeList.Add(SPK.ElectricSocket);
+ }
+ ///绐楀笜绫�
+ else if (deviceType == Language.StringByID(StringId.Curtain))
+ {
+ functionTypeList.Add(SPK.CurtainSwitch);
+ functionTypeList.Add(SPK.CurtainRoller);
+ functionTypeList.Add(SPK.CurtainTrietex);
+ }
+ ///绌鸿皟绫�
+ else if (deviceType == Language.StringByID(StringId.AC))
+ {
+ functionTypeList.Add(SPK.AcStandard);
+ functionTypeList.Add(SPK.HvacAC);
+ }
+ ///鍦版殩绫�
+ else if (deviceType == Language.StringByID(StringId.FloorHeating))
+ {
+ functionTypeList.Add(SPK.FloorHeatStandard); functionTypeList.Add(SPK.HvacFloorHeat);
+ }
+ ///鏂伴绫�
+ else if (deviceType == Language.StringByID(StringId.AirFresh))
+ {
+ functionTypeList.Add(SPK.AirFreshStandard); functionTypeList.Add(SPK.HvacAirFresh);
+ }
+ ///浼犳劅鍣ㄧ被
+ else if (deviceType == Language.StringByID(StringId.Sensor))
+ {
+ functionTypeList.Add(SPK.SensorSmoke);
+ functionTypeList.Add(SPK.SensorWater);
+ functionTypeList.Add(SPK.SensorGas);
+ functionTypeList.Add(SPK.SensorDryContact); functionTypeList.Add(SPK.SensorDryContact2);
+ functionTypeList.Add(SPK.SensorShanLan);
+ functionTypeList.Add(SPK.SensorDuiShe);
+ functionTypeList.Add(SPK.SensorPir);
+ functionTypeList.Add(SPK.SensorDoorWindow);
+ functionTypeList.Add(SPK.SensorUtrasonic);
+ functionTypeList.Add(SPK.SenesorMegahealth);
+ functionTypeList.Add(SPK.SenesorMegahealth2);
+ functionTypeList.Add(SPK.SensorEnvironment);
+ functionTypeList.Add(SPK.SensorEnvironment2);
+ functionTypeList.Add(SPK.SensorEnvironment3);
+ functionTypeList.Add(SPK.SensorTemperature);
+ functionTypeList.Add(SPK.SensorHumidity);
+ functionTypeList.Add(SPK.SensorCO2);
+ functionTypeList.Add(SPK.SensorPm25);
+ functionTypeList.Add(SPK.SensorTVOC);
+ functionTypeList.Add(SPK.SensorHcho);
+
+
+ }
+ ///瀹剁數绫�
+ else if (deviceType == Language.StringByID(StringId.Electric))
+ {
+ functionTypeList.Add(SPK.AirSwitch);
+ functionTypeList.Add(SPK.PanelSocket);
+ functionTypeList.Add(SPK.ElectricSocket);
+ }
+
+
+ return functionTypeList;
+
+ }
+ /// <summary>
+ /// 鏉′欢/鐩爣鏀寔璁惧
+ /// </summary>
+ /// <returns></returns>
+ public List<string> GetSupportEquipment(string if_type)
+ {
+ List<string> deviceTypeList = new List<string>();
+ switch (if_type)
+ {
+ case condition_if:
+ {
+ deviceTypeList.Add(SPK.LightSwitch);
+ deviceTypeList.Add(SPK.LightRGB);
+ deviceTypeList.Add(SPK.LightRGBW);
+ deviceTypeList.Add(SPK.LightDimming);
+ deviceTypeList.Add(SPK.LightCCT);
+ deviceTypeList.Add(SPK.CurtainSwitch);
+ deviceTypeList.Add(SPK.CurtainRoller);
+ deviceTypeList.Add(SPK.CurtainTrietex);
+ deviceTypeList.Add(SPK.AcStandard); deviceTypeList.Add(SPK.HvacAC);
+ deviceTypeList.Add(SPK.AirFreshStandard); deviceTypeList.Add(SPK.HvacAirFresh);
+ deviceTypeList.Add(SPK.FloorHeatStandard); deviceTypeList.Add(SPK.HvacFloorHeat);
+ deviceTypeList.Add(SPK.SensorSmoke);
+ deviceTypeList.Add(SPK.SensorWater);
+ deviceTypeList.Add(SPK.SensorGas);
+ deviceTypeList.Add(SPK.SensorDryContact); deviceTypeList.Add(SPK.SensorDryContact2);
+ deviceTypeList.Add(SPK.SensorShanLan);
+ deviceTypeList.Add(SPK.SensorDuiShe);
+ deviceTypeList.Add(SPK.SensorPir);
+ deviceTypeList.Add(SPK.SensorDoorWindow);
+ deviceTypeList.Add(SPK.SensorUtrasonic);
+ deviceTypeList.Add(SPK.SenesorMegahealth);
+ deviceTypeList.Add(SPK.SenesorMegahealth2);
+ deviceTypeList.Add(SPK.SensorEnvironment);
+ deviceTypeList.Add(SPK.SensorEnvironment2);
+ deviceTypeList.Add(SPK.SensorEnvironment3);
+ deviceTypeList.Add(SPK.SensorTemperature);
+ deviceTypeList.Add(SPK.SensorHumidity);
+ deviceTypeList.Add(SPK.SensorCO2);
+ deviceTypeList.Add(SPK.SensorPm25);
+ deviceTypeList.Add(SPK.SensorTVOC);
+ deviceTypeList.Add(SPK.SensorHcho);
+ deviceTypeList.Add(SPK.AirSwitch);
+ deviceTypeList.Add(SPK.PanelSocket);
+ deviceTypeList.Add(SPK.ElectricSocket);
+
+ }
+ break;
+ case target_if:
+ {
+ deviceTypeList.Add(SPK.LightSwitch);
+ deviceTypeList.Add(SPK.LightRGB);
+ deviceTypeList.Add(SPK.LightRGBW);
+ deviceTypeList.Add(SPK.LightDimming);
+ deviceTypeList.Add(SPK.LightCCT);
+ deviceTypeList.Add(SPK.CurtainSwitch);
+ deviceTypeList.Add(SPK.CurtainRoller);
+ deviceTypeList.Add(SPK.CurtainTrietex);
+ deviceTypeList.Add(SPK.AcStandard); deviceTypeList.Add(SPK.HvacAC);
+ deviceTypeList.Add(SPK.FloorHeatStandard); deviceTypeList.Add(SPK.HvacFloorHeat);
+ deviceTypeList.Add(SPK.AirFreshStandard); deviceTypeList.Add(SPK.HvacAirFresh);
+ deviceTypeList.Add(SPK.AirSwitch);
+ deviceTypeList.Add(SPK.PanelSocket);
+ deviceTypeList.Add(SPK.ElectricSocket);
+ }
+ break;
+ }
+ return deviceTypeList;
+ }
+ #endregion
+ /// <summary>
+ /// 鏄剧ず鐨勮澶囧垪琛�
+ /// </summary>
+ /// <param name="functionType">婧愭暟鎹垪琛�1</param>
+ /// <param name="deviceList">婧愭暟鎹垪琛�2</param>
+ /// <returns></returns>
+ public List<Entity.Function> GetShowDeviceList(List<string> functionType, List<HDL_ON.Entity.Function> deviceList)
+ {
+ List<HDL_ON.Entity.Function> devList = new List<Entity.Function>();
+ for (int i = 0; i < deviceList.Count; i++)
+ {
+ var dev = deviceList[i];
+ //杩囨护鎺変笉闇�瑕佹樉绀虹殑璁惧
+ if (functionType.Contains(dev.spk))
+ {
+ devList.Add(dev);
+ }
+
+ }
+
+ return devList;
+ }
+ /// <summary>
+ /// 杩斿洖鏈�缁堟敮鎸佹樉绀哄嚭鏉ョ殑璁惧鍒楄〃
+ /// </summary>
+ /// <param name="room">褰撳墠鎴块棿</param>
+ /// <param name="str">鍒ゆ柇绗︼紙琛ㄧず=杈撳叆璁惧鍜岃緭鍑鸿澶囷級</param>
+ /// <returns></returns>
+ public List<Entity.Function> GetFunctionDeviceList(Entity.Room room, string str)
+ {
+ List<string> functionTypeList = GetSupportEquipment(str);
+ //杩斿洖鎴块棿璁惧鍒楄〃
+ var roomDeviceList = GetRoomDevice(room);
+ //杩斿洖鏈�缁堟敮鎸佹樉绀哄嚭鏉ョ殑璁惧鍒楄〃
+ var list = GetShowDeviceList(functionTypeList, roomDeviceList);
+ return list;
+ }
+ /// <summary>
+ /// 缃戝叧ID(鑾峰彇鍢変箰缃戝叧ID)
+ /// </summary>
+ public string GatewayId
+ {
+ get
+ {
+ if (Entity.DB_ResidenceData.Instance.HomeGateway == null)
+ {
+ return DriverLayer.Control.Ins.GatewayId;
+ }
+ return Entity.DB_ResidenceData.Instance.HomeGateway.gatewayId;
+ }
+ }
+ /// <summary>
+ /// 浣忓畢ID
+ /// </summary>
+ public string HomeId
+ {
+ get
+ {
+ return Entity.DB_ResidenceData.Instance.CurrentRegion.id;
+ }
+ }
+ /// <summary>
+ /// 鏄惁涓哄叾浠栦富鐢ㄦ埛鍒嗕韩杩囨潵鐨勪綇瀹�
+ /// </summary>
+ public bool IsOthreShare
+ {
+ get
+ {
+ return Entity.DB_ResidenceData.Instance.CurrentRegion.isOtherShare;
+ }
+ }
+
+ #region 楂樺痉鍧愭爣杞琖GS84鍧愭爣
+ /// <summary>
+ /// 楂樺痉鍧愭爣杞琖GS84鍧愭爣
+ /// </summary>
+ /// <param name="in_lng"></param>
+ /// <param name="in_lat"></param>
+ /// <param name="out_lng"></param>
+ /// <param name="out_lat"></param>
+ public void GCJ02_to_WGS84(double in_lng, double in_lat, out double out_lng, out double out_lat)
+ {
+ if (OutOfChina(in_lat, in_lng))
+ {
+ out_lng = in_lng;
+ out_lat = in_lat;
+ return;
+ }
+
+ CalculateDev(in_lng, in_lat, out out_lng, out out_lat);
+ out_lng = in_lng - out_lng;
+ out_lat = in_lat - out_lat;
+ }
+ #endregion
+
+ #region WGS84鍧愭爣杞珮寰峰潗鏍�
+ /// <summary>
+ /// WGS84鍧愭爣杞珮寰峰潗鏍�
+ /// </summary>
+ /// <param name="in_lng">缁忓害</param>
+ /// <param name="in_lat">绾害</param>
+ /// <param name="out_lng"></param>
+ /// <param name="out_lat"></param>
+ public void WGS84_to_GCJ02(double in_lng, double in_lat, out double out_lng, out double out_lat)
+ {
+ if (OutOfChina(in_lat, in_lng))
+ {
+ out_lng = in_lng;
+ out_lat = in_lat;
+ return;
+ }
+
+ CalculateDev(in_lng, in_lat, out out_lng, out out_lat);
+ out_lng = in_lng + out_lng;
+ out_lat = in_lat + out_lat;
+ }
+ #endregion
+
+ /// <summary>
+ /// 鍧愭爣鏄惁鍦ㄤ腑鍥藉鍐�
+ /// </summary>
+ /// <param name="lat"></param>
+ /// <param name="lng"></param>
+ /// <returns></returns>
+ public bool OutOfChina(double lat, double lng)
+ {
+ if (lng < 72.004 || lng > 137.8347)
+ return true;
+ if (lat < 0.8293 || lat > 55.8271)
+ return true;
+ return false;
+ }
+ /// <summary>
+ /// 璁$畻鍋忓樊
+ /// </summary>
+ /// <param name="in_lng"></param>
+ /// <param name="in_lat"></param>
+ /// <param name="dLng"></param>
+ /// <param name="dLat"></param>
+ private void CalculateDev(double in_lng, double in_lat, out double dLng, out double dLat)
+ {
+ dLat = TransformLat(in_lng - 105.0, in_lat - 35.0);
+ dLng = TransformLng(in_lng - 105.0, in_lat - 35.0);
+
+ double radLat = in_lat / 180.0 * pi;
+ double magic = Math.Sin(radLat);
+ magic = 1 - ee * magic * magic;
+ double sqrtMagic = Math.Sqrt(magic);
+ dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi);
+ dLng = (dLng * 180.0) / (a / sqrtMagic * Math.Cos(radLat) * pi);
+ }
+
+ private double TransformLat(double x, double y)
+ {
+ double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.Sqrt(Math.Abs(x));
+ ret += (20.0 * Math.Sin(6.0 * x * pi) + 20.0 * Math.Sin(2.0 * x * pi)) * 2.0 / 3.0;
+ ret += (20.0 * Math.Sin(y * pi) + 40.0 * Math.Sin(y / 3.0 * pi)) * 2.0 / 3.0;
+ ret += (160.0 * Math.Sin(y / 12.0 * pi) + 320 * Math.Sin(y * pi / 30.0)) * 2.0 / 3.0;
+ return ret;
+ }
+ private double TransformLng(double x, double y)
+ {
+ double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.Sqrt(Math.Abs(x));
+ ret += (20.0 * Math.Sin(6.0 * x * pi) + 20.0 * Math.Sin(2.0 * x * pi)) * 2.0 / 3.0;
+ ret += (20.0 * Math.Sin(x * pi) + 40.0 * Math.Sin(x / 3.0 * pi)) * 2.0 / 3.0;
+ ret += (150.0 * Math.Sin(x / 12.0 * pi) + 300.0 * Math.Sin(x / 30.0 * pi)) * 2.0 / 3.0;
+ return ret;
+ }
+ // 妞悆鍙傛暟-鍦嗗懆鐜�
+ private const double pi = 3.14159265358979324;
+
+ // (鍖椾含54)妞悆闀垮崐杞达紝鍗槦妞悆鍧愭爣鎶曞奖鍒板钩闈㈠湴鍥惧潗鏍囩郴鐨勬姇褰卞洜瀛�
+ private const double a = 6378245.0;
+ /*
+ * Krasovsky 1940 (鍖椾含54)妞悆闀垮崐杞寸涓�鍋忓績鐜囧钩鏂�
+ * 璁$畻鏂瑰紡锛�
+ * 闀垮崐杞达細
+ * a = 6378245.0
+ * 鎵佺巼锛�
+ * 1/f = 298.3锛堝彉閲忕浉鍏宠绠椾负锛�(a-b)/a锛�
+ * 鐭崐杞达細
+ * b = 6356863.0188 (鍙橀噺鐩稿叧璁$畻鏂规硶涓猴細b = a * (1 - f))
+ * 绗竴鍋忓績鐜囧钩鏂�:
+ * e2 = (a^2 - b^2) / a^2;
+ */
+ private const double ee = 0.00669342162296594323;
+
+ /// <summary>
+ /// APP涓婃姤GPS缁忕含搴�
+ /// </summary>
+ /// <param name="lon">APP GPS缁忓害</param>
+ /// <param name="lat">APP GPS绾害</param>
+ public void AppLatAndLonEvent(double lon, double lat)
+ {
+ Console.WriteLine($"GPS缁忓害===={lon} \nGPS绾害===={lat}");
+ //Application.LocationAction += (lon, lat) =>
+ //{
+ // Console.WriteLine($"GPS缁忓害===={lon}");
+ // Console.WriteLine($"GPS绾害===={lat}");
+ // ////GPS鍧愭爣杞垚楂樺痉鍧愭爣
+ // //double out_lng, out_lat;
+ // //this.WGS84_to_GCJ02(lon, lat, out out_lng, out out_lat);
+ // //涓婃姤缁忕含搴�
+ // this.AutomatedGeofenceStatusReporting(lon, lat);
+ //};
+ //涓婃姤缁忕含搴�<gps 涓婃姤鏉′欢澶т簬30绉掍笖绉诲姩璺濈澶т簬100绫筹紝涓婃姤缁忕含搴�>
+ this.AutomatedGeofenceStatusReporting(lon, lat);
+ }
+
+ /// <summary>
+ /// 鑷姩鍖栧湴鐞嗗洿鏍忕姸鎬佷笂鎶ヤ簯绔�
+ /// </summary>
+ /// <param name="out_lng">APP GPS缁忓害</param>
+ /// <param name="out_lat">APP GPS绾害</param>
+ private void AutomatedGeofenceStatusReporting(double out_lng, double out_lat)
+ {
+ if (IsOthreShare)
+ {
+ //涓嶆槸涓昏处鍙风洿鎺ヨ繑鍥�
+ return;
+ }
+ List<LogicData> logicDataList = new List<LogicData>();
+ logicDataList.Clear();
+ System.Threading.Tasks.Task.Run(() =>
+ {
+ try
+ {
+ //鑾峰彇閫昏緫ID鍒楄〃锛岀洰鍓嶉拡瀵规墍鏈�<澶囨敞:濡傛灉鍙拡瀵瑰綋鍓嶆墜鏈虹殑璇濓紝鍙互鐩存帴鎷跨紦瀛樻暟鎹嚜鍔ㄥ寲鍒楄〃閬嶅巻>
+ var idStr = Send.GetLogicIdList();
+ if (idStr.Code == "0" && idStr.Data != null && idStr.Data.ToString() != "")
+ {
+ var date = Newtonsoft.Json.JsonConvert.SerializeObject(idStr.Data);
+ logicDataList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<LogicData>>(date);
+ }
+ ///鏈夎嚜鍔ㄥ垪琛ㄦ墠澶勭悊
+ if (logicDataList.Count > 0)
+ {
+ ///閬嶅巻鎵�鏈夊垪琛�
+ for (int i = 0; i < logicDataList.Count; i++)
+ {
+ var logicDate = logicDataList[i];
+ ///鑷姩鍖栨病鏈夐厤缃湴鐞嗗洿鏍忎笉澶勭悊
+ if (string.IsNullOrEmpty(logicDate.geo_fence.latitude) || string.IsNullOrEmpty(logicDate.geo_fence.longitude))
+ {
+ //缁忕含搴︿负绌�,璁や负鑷姩鍖栨病鏈夐厤缃湴鐞嗗洿鏍忥紝涓嶅鐞�;
+ continue;
+ }
+ //鑷姩鍖栭厤缃緭鍏ユ潯浠剁含搴�
+ double lat = Convert.ToDouble(logicDate.geo_fence.latitude);
+ //鑷姩鍖栭厤缃緭鍏ユ潯浠剁粡搴�
+ double lon = Convert.ToDouble(logicDate.geo_fence.longitude);
+ //鑷姩鍖栭厤缃緭鍏ユ潯浠�<鍦扮悊鍥存爮鍗婂緞><鍗曚綅锛屽叕閲屻�佸崈绫�.绫�>
+ int radius = int.Parse(logicDate.geo_fence.radius);
+ //璁$畻2涓粡绾害涔嬮棿鐨勮窛绂�
+ int r = Infrastructure.Service.Helper.CalculatedDistance.Distance(out_lat, out_lng, lat, lon);
+ //瀹氫箟涓�涓眬閮ㄥ彉閲�
+ string direction = string.Empty;
+ //涓ょ偣璺濈灏忎簬閰嶇疆璺濈<鏃㈣嚜鍔ㄥ寲閰嶇疆杈撳叆鏉′欢鍦扮悊鍥存爮鍗婂緞>,璇存槑杩涘叆鍖哄煙
+ if (r < radius)
+ {
+ //鍒拌揪鏌愬湴
+ direction = "arrive";
+ }
+ else
+ {
+ //绂诲紑
+ direction = "leave";
+ }
+ ///閬嶅巻缂撳瓨鍒楄〃<涓嶄负绌鸿鏄庢暟鎹凡缁忔帹閫佽繃锛屼笉鍐嶆帹閫�>
+ var isPush = pushList.Find((o) => o.homeId == HomeId && o.userId == UserInfo.Current.ID && o.userLogicId == logicDate.userLogicId && o.arriveOnLeave == direction);
+ if (isPush == null)
+ {
+ //鎺ㄩ�佺粰浜戠鏄惁鎴愬姛
+ bool push = Send.GeoFenceStateReport(logicDate.userLogicId, logicDate.sid, direction);
+ if (push)
+ {
+ ///娣诲姞鍒版帹閫佸垪琛�
+ pushList.Add(new Push
+ {
+ homeId = HomeId,
+ userId = UserInfo.Current.ID,
+ userLogicId = logicDate.userLogicId,
+ sid = logicDate.sid,
+ arriveOnLeave = direction,
+ });
+ }
+ }
+ }
+
+ }
+ }
+ catch { }
+ });
+ }
+ /// <summary>
+ /// 鎺ㄩ�佸垪琛�<杩欓噷鏁版嵁宸茬粡鎺ㄩ�佽繃>
+ /// </summary>
+ private static List<Push> pushList = new List<Push>();
+
+ }
+ public class Push
+ {
+ /// <summary>
+ /// 浜戠鍞竴id
+ /// </summary>
+ public string userLogicId = "";
+ /// <summary>
+ /// 缃戝叧id
+ /// </summary>
+ public string gatewayId = "";
+ /// <summary>
+ /// 閫昏緫鍞竴鏍囪瘑
+ /// </summary>
+ public string sid = "";
+ /// <summary>
+ /// 浣忓畢id
+ /// </summary>
+ public string homeId = "";
+ /// <summary>
+ /// 鍒拌揪鏌愬湴 绂诲紑
+ /// </summary>
+ public string arriveOnLeave = "";
+ /// <summary>
+ /// 聽鐢ㄦ埛id
+ /// </summary>
+ public string userId = "";
+
+ }
}
diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/Send.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/Send.cs
index 3097608..e52e8e3 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/Send.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/Send.cs
@@ -8,407 +8,406 @@
namespace HDL_ON.UI.UI2.Intelligence.Automation
{
- public class Send
+ public class Send
+ {
+
+ /// <summary>
+ /// 璋冪敤鑾峰彇浣忓畢瀛愯处鍙峰垪琛�
+ /// </summary>
+ public static List<ResidenceMemberInfo> GetResidenceMemberAccount()
{
- /// <summary>
- /// 璋冪敤鑾峰彇浣忓畢瀛愯处鍙峰垪琛�
- /// </summary>
- public static List<ResidenceMemberInfo> GetResidenceMemberAccount()
+ 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);
+ //濡傛灉鏄痶oken杩囨湡鍒欏埛鏂皌oken
+ 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);
+ //濡傛灉鏄痶oken杩囨湡鍒欏埛鏂皌oken
+ 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)
{
+ cyclevaluejArray.Add(dictionary);
+ }
+ cycleJObject.Add("value", cyclevaluejArray);
- 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>();
+ 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);
}
- /// <summary>
- /// 鑾峰彇閫昏緫ID鍒楄〃
- /// </summary>
- /// <returns></returns>
- public static ResponsePackNew GetLogicIdList()
+ var outputArray = new JArray { };
+ foreach (var dictionary in logic.output)
{
- var jObject = new JObject { { "homeId", LogicMethod.CurrLogicMethod.HomeId } };
- var responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_List);
- //濡傛灉鏄痶oken杩囨湡鍒欏埛鏂皌oken
- 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);
- //濡傛灉鏄痶oken杩囨湡鍒欏埛鏂皌oken
- 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)
- {
- 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)
- {
- 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.CurrLogicMethod.GatewayId);
- 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 } };
- responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_Add,5);
- //濡傛灉鏄痶oken杩囨湡鍒欏埛鏂皌oken
- if (responsePackNew.Code == StateCode.TOKEN_EXPIRED)
- {
- 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 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.CurrLogicMethod.GatewayId);
- 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);
- //濡傛灉鏄痶oken杩囨湡鍒欏埛鏂皌oken
- if (responsePackNew.Code == StateCode.TOKEN_EXPIRED)
- {
- RefreshToken();
- UpdateLogic(logic);
- }
- }
- 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);
- //濡傛灉鏄痶oken杩囨湡鍒欏埛鏂皌oken
- 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);
- //濡傛灉鏄痶oken杩囨湡鍒欏埛鏂皌oken
- if (responsePackNew.Code == StateCode.TOKEN_EXPIRED)
- {
- RefreshToken();
- SwitchLogic(logic);
- }
- return responsePackNew;
+ 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);
}
- /// <summary>
- /// 鑷姩鍖栧湴鐞嗗洿鏍忕姸鎬佷笂鎶�
- /// </summary>
- /// <param name="userLogicId">鑷姩鍖栦簯绔痠d<澶囨敞锛歭ogicSid涓巙serLogicId 涓嶈兘鍚屾椂涓虹┖></param>
- /// <param name="logicSid">鑷姩鍖杝id<澶囨敞锛歭ogicSid涓巙serLogicId 涓嶈兘鍚屾椂涓虹┖></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);
- //濡傛灉鏄痶oken杩囨湡鍒欏埛鏂皌oken
- if (responsePackNew.Code == StateCode.TOKEN_EXPIRED)
+ 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)
{
- RefreshToken();
- GeoFenceStateReport(userLogicId, logicSid, direction);
+ accountArray.Add(account);
}
- if (responsePackNew.Code == "0")
+ 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("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 } };
+ responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_Add, 5);
+ //濡傛灉鏄痶oken杩囨湡鍒欏埛鏂皌oken
+ if (responsePackNew.Code == StateCode.TOKEN_EXPIRED)
+ {
+ 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")
{
- //鎴愬姛
- return true;
+ ///鍦扮悊鍥存爮
+ 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 false;
+ }
+ inputTypeJOb.Add("condition", conditionArray);
+ inputArray.Add(inputTypeJOb);
}
- /// <summary>
- ///璇锋眰鏈嶅姟鍣紙涓庝綇瀹呮湁鍏�:渚嬪锛沨omeId锛�
- /// </summary>
- /// <returns></returns>
- public static ResponsePackNew RequestServerhomeId(object o, string api_Url, int mTimeout = 3)
+ var outputArray = new JArray { };
+ foreach (var dictionary in logic.output)
{
- var requestJson = HttpUtil.GetSignRequestJson(o);
- return HttpUtil.RequestHttpsPostFroHome(api_Url, requestJson, mTimeout);
+ 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);
+ }
- }
- /// <summary>
- /// 璇锋眰鏈嶅姟鍣�
- /// </summary>
- /// <returns></returns>
- public static ResponsePackNew RequestServer(object o, string api_Url)
- {
- var requestJson = HttpUtil.GetSignRequestJson(o);
- return HttpUtil.RequestHttpsPost(api_Url, requestJson);
+ var noticeConfigJObject = new JObject();
+ noticeConfigJObject.Add("enable", logic.noticeConfig.enable);
+ noticeConfigJObject.Add("noticeContent", logic.noticeConfig.noticeContent);
- }
- /// <summary>
- /// 鍒锋柊Token
- /// </summary>
- public static void RefreshToken()
+ var pushConfigsArray = new JArray { };
+ if (logic.pushConfigs.Count > 0)
{
- IMessageCommon.Current.StartRefreshToken();
+ //聽鎺ㄩ�佹枃鏈�
+ 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.CurrLogicMethod.GatewayId);
+ 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);
+ //濡傛灉鏄痶oken杩囨湡鍒欏埛鏂皌oken
+ if (responsePackNew.Code == StateCode.TOKEN_EXPIRED)
+ {
+ RefreshToken();
+ UpdateLogic(logic);
+ }
+ }
+ 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);
+ //濡傛灉鏄痶oken杩囨湡鍒欏埛鏂皌oken
+ 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);
+ //濡傛灉鏄痶oken杩囨湡鍒欏埛鏂皌oken
+ if (responsePackNew.Code == StateCode.TOKEN_EXPIRED)
+ {
+ RefreshToken();
+ SwitchLogic(logic);
+ }
+ return responsePackNew;
+ }
+ /// <summary>
+ /// 鑷姩鍖栧湴鐞嗗洿鏍忕姸鎬佷笂鎶�
+ /// </summary>
+ /// <param name="userLogicId">鑷姩鍖栦簯绔痠d<澶囨敞锛歭ogicSid涓巙serLogicId 涓嶈兘鍚屾椂涓虹┖></param>
+ /// <param name="logicSid">鑷姩鍖杝id<澶囨敞锛歭ogicSid涓巙serLogicId 涓嶈兘鍚屾椂涓虹┖></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);
+ //濡傛灉鏄痶oken杩囨湡鍒欏埛鏂皌oken
+ if (responsePackNew.Code == StateCode.TOKEN_EXPIRED)
+ {
+ RefreshToken();
+ GeoFenceStateReport(userLogicId, logicSid, direction);
+ }
+ if (responsePackNew.Code == "0")
+ {
+ //鎴愬姛
+ return true;
+ }
+ //澶辫触
+ return false;
+ }
+
+ /// <summary>
+ ///璇锋眰鏈嶅姟鍣紙涓庝綇瀹呮湁鍏�:渚嬪锛沨omeId锛�
+ /// </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);
}
+ /// <summary>
+ /// 璇锋眰鏈嶅姟鍣�
+ /// </summary>
+ /// <returns></returns>
+ public static ResponsePackNew RequestServer(object o, string api_Url)
+ {
+ var requestJson = HttpUtil.GetSignRequestJson(o);
+ return HttpUtil.RequestHttpsPost(api_Url, requestJson);
+
+ }
+ /// <summary>
+ /// 鍒锋柊Token
+ /// </summary>
+ public static void RefreshToken()
+ {
+ IMessageCommon.Current.StartRefreshToken();
+ }
+
+ }
}
diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/WeatherCondition.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/WeatherCondition.cs
index 1c683eb..f4e8760 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/WeatherCondition.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/WeatherCondition.cs
@@ -108,9 +108,6 @@
index = i;
break;
}
- ///鎵惧埌鏍囪绱㈠紩锛岄��鍑哄惊鐜綋
- index = i;
- break;
}
}
if (index != -1)
diff --git a/HDL_ON/UI/UI2/FuntionControlView/ArmCenter/AddOutputPage.cs b/HDL_ON/UI/UI2/FuntionControlView/ArmCenter/AddOutputPage.cs
index 5647415..583048b 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/ArmCenter/AddOutputPage.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/ArmCenter/AddOutputPage.cs
@@ -7,28 +7,29 @@
namespace HDL_ON.UI
{
- public class AddOutputPage : FrameLayout
- {
- FrameLayout bodyView;
+ public class AddOutputPage : FrameLayout
+ {
+ FrameLayout bodyView;
- FrameLayout showdFunctionTypeRow;
+ FrameLayout showdFunctionTypeRow;
- /// <summary>
- /// 妤煎眰閫夋嫨涓嬫媺鍥炬爣
- /// </summary>
- Button btnFloorDownIcon;
- /// <summary>
- /// 妤煎眰鏄剧ず
- /// </summary>
- Button btnFloor;
+ /// <summary>
+ /// 妤煎眰閫夋嫨涓嬫媺鍥炬爣
+ /// </summary>
+ Button btnFloorDownIcon;
+ /// <summary>
+ /// 妤煎眰鏄剧ず
+ /// </summary>
+ Button btnFloor;
- /// <summary>
- /// 绛涢�夋枃鏈樉绀�
- /// </summary>
- Button btnScreenText;
+ /// <summary>
+ /// 绛涢�夋枃鏈樉绀�
+ /// </summary>
+ Button btnScreenText;
- VerticalScrolViewLayout functionListView;
+ VerticalScrolViewLayout functionListView;
+<<<<<<< HEAD
Action<SecurityAlarm> refreshAction;
/// <summary>
/// 鏈湴鍔熻兘杞崲鐨勮緭鍑哄垪琛紙鐏厜銆佸満鏅級
@@ -43,13 +44,83 @@
refreshAction = action;
alarm = inOutput;
}
+=======
+ SecurityAlarm securityAlarm;
+ Action<SecurityAlarm> refreshAction;
+ List<SecurityOutput> outputList = new List<SecurityOutput>();
+
+ List<Function> allocatedList = new List<Function>();
+
+ public AddOutputPage(SecurityAlarm function, Action<SecurityAlarm> action)
+ {
+ bodyView = this;
+ securityAlarm = function;
+ refreshAction = action;
+ }
+>>>>>>> WJC
- /// <summary>
- /// 鍔犺浇鐣岄潰
- /// </summary>
- public void LoadPage()
+ /// <summary>
+ /// 鍔犺浇鐣岄潰
+ /// </summary>
+ public void LoadPage()
+ {
+ bodyView.BackgroundColor = CSS_Color.BackgroundColor;
+ new TopViewDiv(bodyView, Language.StringByID(StringId.AddFunction)).LoadTopView();
+
+ #region 鏄剧ず鐨勫姛鑳界被鍨嬪垏鎹㈠尯鍩�
+ showdFunctionTypeRow = new FrameLayout()
+ {
+ Y = Application.GetRealHeight(64),
+ Height = Application.GetRealHeight(62),
+ BackgroundColor = CSS_Color.MainBackgroundColor,
+ };
+ bodyView.AddChidren(showdFunctionTypeRow);
+
+
+ btnFloorDownIcon = new Button()
+ {
+ Width = Application.GetMinRealAverage(16),
+ Height = Application.GetMinRealAverage(16),
+ X = Application.GetRealWidth(16),
+ Y = Application.GetRealHeight(18),
+ UnSelectedImagePath = "Public/DownIcon.png",
+ };
+ showdFunctionTypeRow.AddChidren(btnFloorDownIcon);
+
+ btnFloor = new Button()
+ {
+ X = btnFloorDownIcon.Right,
+ Y = Application.GetRealHeight(18),
+ Width = Application.GetRealWidth(200),
+ Height = Application.GetMinRealAverage(16),
+ TextColor = CSS_Color.FirstLevelTitleColor,
+ TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
+ TextAlignment = TextAlignment.CenterLeft,
+ Text = DB_ResidenceData.Instance.CurFloor.roomName,
+ };
+ showdFunctionTypeRow.AddChidren(btnFloor);
+
+ #endregion
+
+ functionListView = new VerticalScrolViewLayout()
+ {
+ Y = showdFunctionTypeRow.Bottom,
+ Height = Application.GetRealHeight(530 - 100),
+ BackgroundColor = CSS_Color.BackgroundColor,
+ };
+ bodyView.AddChidren(functionListView);
+
+
+
+
+
+
+ foreach (var function in FunctionList.List.Functions)
+ {
+ if (!MainPage.SceneSupportFunctionList.Contains(function.spk))
{
+<<<<<<< HEAD
bodyView.BackgroundColor = CSS_Color.BackgroundColor;
new TopViewDiv(bodyView, Language.StringByID(StringId.AddFunction)).LoadTopView();
@@ -130,9 +201,70 @@
this.RemoveFromParent();
refreshAction?.Invoke(alarm);
};
+=======
+ continue;
+ }
+ if (function == null)
+ {
+ continue;
+ }
+ function.roomIds.Remove(null);
+ allocatedList.Add(function);
+ }
+
+ LoadFunctionListRow(null);
+
+
+
+
+
+
+
+ var bottomView = new FrameLayout()
+ {
+ Y = Application.GetRealHeight(591),
+ Height = Application.GetRealHeight(100),
+ BackgroundColor = CSS_Color.MainBackgroundColor,
+ Radius = (uint)Application.GetRealWidth(22),
+ };
+ this.AddChidren(bottomView);
+
+ var btnConfrim = new Button()
+ {
+ X = Application.GetRealWidth(78),
+ Y = Application.GetRealHeight(12),
+ Width = Application.GetRealWidth(220),
+ Height = Application.GetRealWidth(44),
+ Radius = (uint)Application.GetRealWidth(22),
+ BackgroundColor = CSS_Color.MainColor,
+ TextID = StringId.Confirm,
+ TextSize = CSS_FontSize.SubheadingFontSize,
+ TextColor = CSS_Color.MainBackgroundColor,
+ TextAlignment = TextAlignment.Center,
+ };
+ bottomView.AddChidren(btnConfrim);
+ btnConfrim.MouseUpEventHandler = (sender, e) =>
+ {
+ securityAlarm.output = new List<SecurityOutput>();
+ foreach (var output in outputList)
+ {
+ if (output.addCondition)
+ {
+ securityAlarm.output.Add(output);
+ }
+ }
+ this.RemoveFromParent();
+ refreshAction?.Invoke(securityAlarm);
+ };
+
+
+
+
+>>>>>>> WJC
}
+<<<<<<< HEAD
/// <summary>
/// 閰嶇疆鏁版嵁
/// </summary>
@@ -164,6 +296,9 @@
RoomName = function.GetRoomListName(),
});
}
+=======
+ }
+>>>>>>> WJC
foreach (var scene in FunctionList.List.scenes)
@@ -192,10 +327,72 @@
});
}
+ // <summary>
+ /// 鏄剧ず鍔熻兘Row
+ /// </summary>
+ void LoadFunctionListRow(List<Function> functions)
+ {
+ functionListView.RemoveAll();
+ if (functions == null)
+ {
+ functions = allocatedList;
+ }
+ foreach (var function in functions)
+ {
+ var output = securityAlarm.output.Find((obj) => obj.sid == function.sid);
+ if (output == null)
+ {
+ output = new SecurityOutput();
+ output.sid = function.sid;
}
+ else
+ {
+ output.addCondition = true;
+ }
+ outputList.Add(output);
+ FrameLayout functionRow = new FrameLayout()
+ {
+ Height = Application.GetRealHeight(65),
+ BackgroundColor = CSS_Color.MainBackgroundColor,
+ };
+ functionListView.AddChidren(functionRow);
+ var btnFunctionName = new Button()
+ {
+ X = Application.GetRealWidth(16),
+ Width = Application.GetRealWidth(200),
+ Height = Application.GetRealHeight(44),
+ Text = function.name,
+ TextAlignment = TextAlignment.CenterLeft,
+ TextColor = CSS_Color.FirstLevelTitleColor,
+ TextSize = CSS_FontSize.TextFontSize,
+ };
+ functionRow.AddChidren(btnFunctionName);
+ var btnFunctionFloorName = new Button()
+ {
+ X = Application.GetRealWidth(16),
+ Y = Application.GetRealHeight(24),
+ Width = Application.GetRealWidth(200),
+ Height = Application.GetRealHeight(41),
+ Text = function.GetRoomListName(),
+ TextAlignment = TextAlignment.CenterLeft,
+ TextColor = CSS_Color.PromptingColor1,
+ TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
+ };
+ functionRow.AddChidren(btnFunctionFloorName);
+
+ Button btnState = new Button()
+ {
+ Width = Application.GetRealWidth(317),
+ TextAlignment = TextAlignment.CenterRight,
+ TextSize = CSS_FontSize.TextFontSize,
+ TextColor = CSS_Color.PromptingColor1,
+ };
+ functionRow.AddChidren(btnState);
+
+<<<<<<< HEAD
// <summary>
/// 鏄剧ず鍔熻兘Row
/// </summary>
@@ -313,30 +510,63 @@
Height = Application.GetRealWidth(1),
BackgroundColor = CSS_Color.DividingLineColor,
});
+=======
+ Button btnChooseIcon = new Button()
+ {
+ X = Application.GetRealWidth(333),
+ Gravity = Gravity.CenterVertical,
+ Width = Application.GetMinRealAverage(32),
+ Height = Application.GetMinRealAverage(32),
+ UnSelectedImagePath = "Public/ChooseIcon.png",
+ SelectedImagePath = "Public/ChooseOnIcon.png",
+ };
+ functionRow.AddChidren(btnChooseIcon);
+ btnChooseIcon.MouseUpEventHandler = (sender, e) =>
+ {
+ btnChooseIcon.IsSelected = !btnChooseIcon.IsSelected;
+ if (btnChooseIcon.IsSelected)
+ {
+ output.addCondition = true;
+ if (output.status.Count == 0)
+ {
+ ShowStateDialog(output, btnState, btnChooseIcon);
}
+ }
+ else
+ {
+ output.addCondition = false;
+ }
+ };
+ btnState.MouseUpEventHandler = (sender, e) =>
+ {
+ ShowStateDialog(output, btnState, btnChooseIcon);
+ };
+>>>>>>> WJC
+
+
+ if (output.addCondition)
+ {
+ btnChooseIcon.IsSelected = true;
+ btnState.Text = output.StateText();
}
+<<<<<<< HEAD
private void ShowStateDialog(SecurityOutput output, Button btnState, Button btnChoose = null)
+=======
+ functionListView.AddChidren(new Button()
+>>>>>>> WJC
{
- Dialog dialog = new Dialog();
+ Gravity = Gravity.CenterHorizontal,
+ Width = Application.GetRealWidth(343),
+ Height = Application.GetRealWidth(1),
+ BackgroundColor = CSS_Color.DividingLineColor,
+ });
- FrameLayout contentView = new FrameLayout();
- dialog.AddChidren(contentView);
- contentView.MouseUpEventHandler = (sender, e) =>
- {
- dialog.Close();
- if (output.status.Count == 0)
- {
- if (btnChoose != null)
- {
- btnChoose.IsSelected = false;
- }
- }
- };
+<<<<<<< HEAD
VerticalScrolViewLayout optinView = new VerticalScrolViewLayout()
{
Gravity = Gravity.CenterHorizontal,
@@ -379,27 +609,89 @@
btnOpen.IsSelected = output.status[0].value.ToLower() == "on";
btnClose.IsSelected = !btnOpen.IsSelected;
}
+=======
+ }
+ }
+
+>>>>>>> WJC
- Button btnCancel = new Button()
- {
- Gravity = Gravity.CenterHorizontal,
- Y = optinView.Bottom + Application.GetRealHeight(8),
- Width = Application.GetRealWidth(343),
- Height = Application.GetRealHeight(44),
- Radius = (uint)Application.GetRealHeight(13),
- BackgroundColor = CSS_Color.MainBackgroundColor,
- TextID = StringId.Cancel,
- TextColor = CSS_Color.WarningColor,
- IsBold = true,
- };
- contentView.AddChidren(btnCancel);
+ private void ShowStateDialog(SecurityOutput output, Button btnState, Button btnChoose = null)
+ {
+ Dialog dialog = new Dialog();
- dialog.Show();
+ FrameLayout contentView = new FrameLayout();
+ dialog.AddChidren(contentView);
+ contentView.MouseUpEventHandler = (sender, e) =>
+ {
+ dialog.Close();
+ if (output.status.Count == 0)
+ {
+ if (btnChoose != null)
+ {
+ btnChoose.IsSelected = false;
+ }
+ }
+ };
- btnOpen.MouseUpEventHandler = (sender, e) => {
- btnState.Text = btnOpen.Text;
- output.status = new List<SecurityOutputStatus>()
+ VerticalScrolViewLayout optinView = new VerticalScrolViewLayout()
+ {
+ Gravity = Gravity.CenterHorizontal,
+ Y = Application.GetRealHeight(515),
+ Width = Application.GetRealWidth(343),
+ Height = Application.GetRealHeight(88),
+ Radius = (uint)Application.GetRealHeight(13),
+ BackgroundColor = CSS_Color.MainBackgroundColor,
+ };
+ contentView.AddChidren(optinView);
+
+ Button btnOpen = new Button()
+ {
+ Height = Application.GetRealHeight(44),
+ TextAlignment = TextAlignment.Center,
+ TextColor = CSS_Color.MainColor,
+ TextSize = CSS_FontSize.SubheadingFontSize,
+ TextID = StringId.On
+ };
+ optinView.AddChidren(btnOpen);
+
+ optinView.AddChidren(new Button()
+ {
+ Height = 1,
+ BackgroundColor = CSS_Color.DividingLineColor
+ });
+
+ Button btnClose = new Button()
+ {
+ Height = Application.GetRealHeight(44),
+ TextAlignment = TextAlignment.Center,
+ TextColor = CSS_Color.PromptingColor1,
+ TextID = StringId.OFF,
+ TextSize = CSS_FontSize.SubheadingFontSize,
+ };
+ optinView.AddChidren(btnClose);
+
+
+ Button btnCancel = new Button()
+ {
+ Gravity = Gravity.CenterHorizontal,
+ Y = optinView.Bottom + Application.GetRealHeight(8),
+ Width = Application.GetRealWidth(343),
+ Height = Application.GetRealHeight(44),
+ Radius = (uint)Application.GetRealHeight(13),
+ BackgroundColor = CSS_Color.MainBackgroundColor,
+ TextID = StringId.Cancel,
+ TextColor = CSS_Color.WarningColor,
+ IsBold = true,
+ };
+ contentView.AddChidren(btnCancel);
+
+ dialog.Show();
+
+ btnOpen.MouseUpEventHandler = (sender, e) =>
+ {
+ btnState.Text = btnOpen.Text;
+ output.status = new List<SecurityOutputStatus>()
{
new SecurityOutputStatus()
{
@@ -407,6 +699,7 @@
value = "on",
}
};
+<<<<<<< HEAD
var localInput = alarm.output.Find((obj) =>
obj.sid == output.sid
);
@@ -422,11 +715,27 @@
btnState.Text = btnClose.Text;
output.status = new List<SecurityOutputStatus>()
{
+=======
+ output.addCondition = true;
+ if (btnChoose != null)
+ {
+ btnChoose.IsSelected = true;
+ }
+ dialog.Close();
+ };
+
+ btnClose.MouseUpEventHandler = (sender, e) =>
+ {
+ btnState.Text = btnClose.Text;
+ output.status = new List<SecurityOutputStatus>()
+ {
+>>>>>>> WJC
new SecurityOutputStatus()
{
key = FunctionAttributeKey.OnOff,
value = "off",
}
+<<<<<<< HEAD
};
var localInput = alarm.output.Find((obj) =>
obj.sid == output.sid
@@ -451,11 +760,33 @@
};
+=======
+ };
+ output.addCondition = true;
+ if (btnChoose != null)
+ {
+ btnChoose.IsSelected = true;
+>>>>>>> WJC
+ }
+ dialog.Close();
+ };
+
+ btnCancel.MouseUpEventHandler = (sender, e) =>
+ {
+ dialog.Close();
+ if (output.status.Count == 0)
+ {
+ if (btnChoose != null)
+ {
+ btnChoose.IsSelected = false;
+ }
}
+ };
+ }
-
+<<<<<<< HEAD
/// <summary>
/// 浣忓畢鍒楄〃鐐瑰嚮浜嬩欢
/// </summary>
@@ -477,7 +808,33 @@
}, nowSelectId);
};
}
+=======
+
+>>>>>>> WJC
+ /// <summary>
+ /// 浣忓畢鍒楄〃鐐瑰嚮浜嬩欢
+ /// </summary>
+ void LoadDialog_ChangeFloor()
+ {
+ string nowSelectId = null;
+ btnFloor.MouseUpEventHandler += (sender, e) =>
+ {
+ var listAllFun = new List<Function>();
+ listAllFun.AddRange(allocatedList);
+
+ //鏄剧ず涓嬫媺鐣岄潰
+ var form = new FloorRoomSelectPopupView();
+ form.ShowDeviceFunctionView(btnFloor, listAllFun, (selectId, listFun) =>
+ {
+ nowSelectId = selectId;
+ //閲嶆柊鍒锋柊璁惧鍒楄〃
+ this.LoadFunctionListRow(listFun);
+ }, nowSelectId);
+ };
}
+
+
+ }
}
--
Gitblit v1.8.0