From 38a11bcfaf3cf703e38201c9c6cd6631354ea243 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期二, 30 十一月 2021 09:55:09 +0800
Subject: [PATCH] Siri功能完成
---
SiriIntents/HDLRunSceneIntentHandlder.cs | 41 ++++++
SiriIntents/Server/HttpServerRequest.cs | 4
SiriKit/Base.lproj/Intents.intentdefinition | 106 +++++++++++++++-
SiriIntentsUI/IntentViewController.cs | 4
DLL/IOS/Shared.IOS.HDLSceneSiri.dll | 0
.vs/HDL_APP_Project/xs/UserPrefs.xml | 50 +-------
HDL-ON_iOS/Other/SkipControl.cs | 101 +++++++++++++++-
7 files changed, 240 insertions(+), 66 deletions(-)
diff --git a/.vs/HDL_APP_Project/xs/UserPrefs.xml b/.vs/HDL_APP_Project/xs/UserPrefs.xml
index 1c65ebd..78e92ec 100644
--- a/.vs/HDL_APP_Project/xs/UserPrefs.xml
+++ b/.vs/HDL_APP_Project/xs/UserPrefs.xml
@@ -3,61 +3,25 @@
<MonoDevelop.MacDev.AppleDevelopmentTeam />
</MonoDevelop.Ide.ItemProperties.SiriIntentUI>
<MonoDevelop.Ide.ItemProperties.HDL-ON__iOS PreferredExecutionTarget="MonoDevelop.IPhone.IPhoneDeviceTarget.6242be7109c740c6cb8999a8904b6e0ea8d45192" />
- <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/UI/UI2/FuntionControlView/ArmCenter/PushConfigPage.cs">
+ <MonoDevelop.Ide.Workbench ActiveDocument="SiriIntentsUI/IntentViewController.cs">
<Files>
- <File FileName="HDL_ON/UI/UI2/FuntionControlView/ArmCenter/AddAlarmDeploymentPage.cs" Line="9" Column="40" />
- <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/Logic.cs" Line="51" Column="35" />
- <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/AddTarget.cs" Line="112" Column="75" />
- <File FileName="HDL_ON/UI/UI2/3-Intelligence/Scene/SceneEditPage.cs" Line="282" Column="55" />
- <File FileName="HDL_ON/UI/UI0-Public/PublicAssmebly.cs" Line="593" Column="55" />
- <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/AddLogic.cs" Line="192" Column="15" />
- <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/InputPushText.cs" Line="83" Column="24" />
- <File FileName="HDL_ON/UI/UI2/FuntionControlView/ArmCenter/PushConfigPage.cs" Line="85" Column="66" />
- <File FileName="HDL_ON/UI/UI2/FuntionControlView/ArmCenter/ArmCenterPage.cs" Line="458" Column="45" />
- <File FileName="HDL_ON/UI/UI2/3-Intelligence/IntelligencePage.cs" Line="213" Column="55" />
- <File FileName="HDL_ON/UI/UI2/FuntionControlView/ArmCenter/ArmDeploymentSettingPage.cs" Line="1" Column="1" />
- <File FileName="HDL_ON/UI/UI2/FuntionControlView/ArmCenter/AddInputPage.cs" Line="465" Column="12" />
- <File FileName="HDL_ON/UI/UI2/FuntionControlView/ArmCenter/AddOutputPage.cs" Line="433" Column="17" />
- <File FileName="HDL_ON/Entity/Function/SecurityAlarm.cs" Line="138" Column="29" />
+ <File FileName="HDL-ON_iOS/Other/SkipControl.cs" Line="68" Column="45" />
+ <File FileName="HDL-ON_iOS/Info.plist" />
+ <File FileName="SiriIntentsUI/IntentViewController.cs" Line="1" Column="1" />
</Files>
<Pads>
<Pad Id="ProjectPad">
<State name="__root__">
<Node name="HDL_APP_Project" expanded="True">
- <Node name="HDL_ON" expanded="True">
- <Node name="Common" expanded="True">
- <Node name="Utlis" expanded="True" />
- </Node>
- <Node name="Entity" expanded="True">
- <Node name="Function" expanded="True" />
- </Node>
- <Node name="UI" expanded="True">
- <Node name="UI0-Public" expanded="True" />
- <Node name="UI2" expanded="True">
- <Node name="2-Classification" expanded="True" />
- <Node name="3-Intelligence" expanded="True">
- <Node name="Automation" expanded="True" />
- <Node name="Scene" expanded="True" />
- </Node>
- <Node name="FuntionControlView" expanded="True">
- <Node name="ArmCenter" expanded="True">
- <Node name="PushConfigPage.cs" selected="True" />
- </Node>
- </Node>
- </Node>
- </Node>
- </Node>
- <Node name="HDL-ON_Android" expanded="True">
- <Node name="Assets" expanded="True" />
- </Node>
<Node name="HDL-ON_iOS" expanded="True">
- <Node name="Resources" expanded="True" />
+ <Node name="Other" expanded="True" />
</Node>
<Node name="SiriIntents" expanded="True" />
<Node name="SiriIntentsUI" expanded="True">
- <Node name="IntentViewController.cs" expanded="True" />
+ <Node name="IntentViewController.cs" selected="True" />
</Node>
<Node name="SiriKit" expanded="True">
+ <Node name="References" expanded="True" />
<Node name="Base.lproj" expanded="True" />
</Node>
</Node>
diff --git a/DLL/IOS/Shared.IOS.HDLSceneSiri.dll b/DLL/IOS/Shared.IOS.HDLSceneSiri.dll
index 971f7e0..17986a1 100644
--- a/DLL/IOS/Shared.IOS.HDLSceneSiri.dll
+++ b/DLL/IOS/Shared.IOS.HDLSceneSiri.dll
Binary files differ
diff --git a/HDL-ON_iOS/Other/SkipControl.cs b/HDL-ON_iOS/Other/SkipControl.cs
index f320b4d..9a8439d 100644
--- a/HDL-ON_iOS/Other/SkipControl.cs
+++ b/HDL-ON_iOS/Other/SkipControl.cs
@@ -1,8 +1,11 @@
锘縰sing System;
using CoreGraphics;
using Foundation;
+using HDL_ON.Entity;
+using HDLSceneSiri;
using Intents;
using IntentsUI;
+using Shared;
using UIKit;
namespace Other
@@ -24,20 +27,104 @@
var sDM = new SiriKit.SceneDateManager();
Console.WriteLine($"IsLogin:{sDM.IsLgoin};accessToken:{sDM.AccessToken};refreshToken:{sDM.RefreshToken};RegionUrl:{sDM.RegionUrl};HomeId:{sDM.HomeId}");
+ //NSMutableArray list = new NSMutableArray();
+ //foreach (var localScene in HDL_ON.Entity.FunctionList.List.scenes)
+ //{
+ // list.Add(new HDLSceneSiri.HDLSiriControlModel()
+ // {
+ // UserSceneId = localScene.userSceneId,
+ // Name = localScene.name,
+ // });
+ //}
+ //var vc = new HDLSceneSiri.HDLSiriSceneListViewController();
+ //vc.DataSource = list;
+ ////vc.TitleName
+ ////PresentViewController(vc, true, null);
+ //HDL_ON_iOS.AppDelegate.rootViewController.PushViewController(vc, true);
+
+
+ //1.鍒濆鍖杁ataList
+ NSMutableArray dataSourceList = new NSMutableArray();
+ //2.鍒濆鍖栧満鏅垪琛ㄦ暟鎹�
+ HDLSiriShortcutModel sceneModel = new HDLSiriShortcutModel();
+ if (Language.CurrentLanguage == "Chinese")
+ {
+ sceneModel.Title = "鍦烘櫙";
+ sceneModel.Content = "灏嗗満鏅坊鍔犲埌蹇嵎鎸囦护锛屽嵆鍙�氳繃Siri鎵ц";
+ }
+ else
+ {
+ sceneModel.Title = "Scenes";
+ sceneModel.Content = "Add the scene to the shortcut, which can be executed through Siri";
+ }
+
NSMutableArray list = new NSMutableArray();
foreach (var localScene in HDL_ON.Entity.FunctionList.List.scenes)
{
- list.Add(new HDLSceneSiri.HDLSiriSceneModel()
+ list.Add(new HDLSiriControlModel()
{
- UserSceneId = localScene.userSceneId,
- Name = localScene.name,
+ ControlId = localScene.userSceneId,//涓嶈兘涓虹┖
+ ControlName = localScene.name,//涓嶈兘涓虹┖
+ ControlType = "1",//涓嶈兘涓虹┖
+ ControlJSONStr = "1",//涓嶈兘涓虹┖
+ ActionName = Language.CurrentLanguage == "Chinese"? "鍦烘櫙": "Scene"//涓嶈兘涓虹┖
});
}
- var vc = new HDLSceneSiri.HDLSiriSceneListViewController();
- vc.DataSource = list;
- //vc.TitleName
- //PresentViewController(vc, true, null);
+ sceneModel.List = NSArray.FromArray<HDLSiriControlModel>(list);
+ dataSourceList.Add(sceneModel);
+
+ //3.鍒濆鍖栧畨闃插垪琛ㄦ暟鎹�
+ HDLSiriShortcutModel securityModel = new HDLSiriShortcutModel();
+ if (Language.CurrentLanguage == "Chinese")
+ {
+ securityModel.Title = "瀹夐槻";
+ securityModel.Content = "灏嗗畨闃叉坊鍔犲埌蹇嵎鎸囦护锛屽嵆鍙�氳繃Siri鎵ц";
+ }else
+ {
+ securityModel.Title = "Security";
+ securityModel.Content = "Add security to the shortcut, which can be executed through Siri";
+ }
+ NSMutableArray list2 = new NSMutableArray();
+ foreach (var temp in HDL_ON.Entity.FunctionList.List.securities)
+ {
+ SecurityState securityState = new SecurityState()
+ {
+ gatewayId = DB_ResidenceData.Instance.HomeGateway.gatewayId,
+ sid = temp.sid,
+ status = "enable",
+ userSecurityId = temp.userSecurityId
+ };
+
+ var ControlJSONStr = Newtonsoft.Json.JsonConvert.SerializeObject(securityState);
+
+ list2.Add(new HDLSiriControlModel()
+ {
+ ControlId = temp.userSecurityId,//涓嶈兘涓虹┖
+ ControlName = temp.name,//涓嶈兘涓虹┖
+ ControlType = "2",//涓嶈兘涓虹┖
+ ControlJSONStr = ControlJSONStr,//涓嶈兘涓虹┖
+ ActionName = Language.CurrentLanguage == "Chinese" ? "瀹夐槻" : "Security"//涓嶈兘涓虹┖
+
+ });
+ }
+ securityModel.List = NSArray.FromArray<HDLSiriControlModel>(list2);
+ dataSourceList.Add(securityModel);
+ //4.璺宠浆Siri娣诲姞鎴栬�呯紪杈戠鐞嗛〉闈�
+ HDLSceneSiri.HDLSiriSceneListViewController vc = new HDLSceneSiri.HDLSiriSceneListViewController();
+ vc.DataSource = dataSourceList;
+ vc.HomeId = DB_ResidenceData.Instance.CurrentRegion.id;//涓嶈兘涓虹┖
+ if (Language.CurrentLanguage == "Chinese")
+ {
+ vc.TitleName = "蹇嵎鎸囦护";
+ }
+ else
+ {
+ vc.TitleName = "Shortcut instruction";
+ }
+
HDL_ON_iOS.AppDelegate.rootViewController.PushViewController(vc, true);
+
+
}
public void SetData(bool isLogin, string accessToken, string refreshToken, string regionUrl, string homeId)
diff --git a/SiriIntents/HDLRunSceneIntentHandlder.cs b/SiriIntents/HDLRunSceneIntentHandlder.cs
index 99f94ee..b053f56 100644
--- a/SiriIntents/HDLRunSceneIntentHandlder.cs
+++ b/SiriIntents/HDLRunSceneIntentHandlder.cs
@@ -1,4 +1,5 @@
锘縰sing System;
+using System.Collections.Generic;
using Foundation;
using HDLSceneSiri;
using ObjCRuntime;
@@ -54,7 +55,20 @@
{
if (Server.HttpServerRequest.Ins.DataManager.IsLgoin)
{
- var result = Server.HttpServerRequest.Ins.ExecuteScene(intent.SceneId);
+ var result = "-1";
+ if (intent.ControlType == "1")
+ {
+ result = Server.HttpServerRequest.Ins.ExecuteScene(intent.ControlId);
+ }
+ else
+ {
+
+ var security = Newtonsoft.Json.JsonConvert.DeserializeObject<SecurityState>(intent.ControlJSONStr);
+ var sendObj = new List<SecurityState>() { new SecurityState() {
+ gatewayId =security.gatewayId,sid = security.sid, status = security.status, userSecurityId = security.userSecurityId
+ } };
+ result = Server.HttpServerRequest.Ins.SetSecurityStatus(sendObj);
+ }
if (result == "0")
{
var rsp = new HDLRunSceneIntentResponse(HDLRunSceneIntentResponseCode.Success, null);
@@ -104,4 +118,29 @@
}
}
}
+
+
+ /// <summary>
+ /// 瀹夐槻鐘舵�侀厤缃�
+ /// </summary>
+ public class SecurityState
+ {
+ /// <summary>
+ /// 瀹夐槻浜戠id
+ /// </summary>
+ public string userSecurityId;
+ /// <summary>
+ /// 缃戝叧id 缃戝叧id 濡傛灉浼犵殑鏄痵id璇ュ瓧娈甸渶瑕佷紶
+ /// </summary>
+ public string gatewayId;
+ /// <summary>
+ /// 瀹夐槻sid
+ /// </summary>
+ public string sid;
+ /// <summary>
+ /// 鐘舵�� enable甯冮槻銆乨isable鎾掗槻
+ /// </summary>
+ public string status;
+ }
+
}
diff --git a/SiriIntents/Server/HttpServerRequest.cs b/SiriIntents/Server/HttpServerRequest.cs
index fcb96b2..6fe2f52 100644
--- a/SiriIntents/Server/HttpServerRequest.cs
+++ b/SiriIntents/Server/HttpServerRequest.cs
@@ -85,7 +85,7 @@
/// <summary>
/// 璁剧疆瀹夐槻闃插尯鐘舵��
/// </summary>
- public ResponsePackNew SetSecurityStatus(List<object> securityStates)
+ public string SetSecurityStatus(object securityStates)
{
Dictionary<string, object> d = new Dictionary<string, object>();
d.Add("homeId", DataManager.HomeId);
@@ -93,7 +93,7 @@
var requestJson = HttpUtil.GetSignRequestJson(d);
var pack = HttpUtil.RequestHttpsPostFroHome(
NewAPI.Api_Post_Security_StatusSet, requestJson);
- return pack;
+ return pack.Code;
}
diff --git a/SiriIntentsUI/IntentViewController.cs b/SiriIntentsUI/IntentViewController.cs
index 8cf1560..18864b6 100644
--- a/SiriIntentsUI/IntentViewController.cs
+++ b/SiriIntentsUI/IntentViewController.cs
@@ -59,8 +59,8 @@
HDLRunSceneIntentResponse rsp = interaction.IntentResponse as HDLRunSceneIntentResponse;
this.lblMsg.Text = rsp.SuccessMessage;
this.lblMsg.TextColor = UIColor.Black;
- this.lblMsg.Frame = new CGRect(0, 0, DesiredSize().Width, 180);
- CGSize size = new CGSize(DesiredSize().Width, 180);
+ this.lblMsg.Frame = new CGRect(0, 0, DesiredSize().Width, 100);
+ CGSize size = new CGSize(DesiredSize().Width, 100);
if (completion != null)
diff --git a/SiriKit/Base.lproj/Intents.intentdefinition b/SiriKit/Base.lproj/Intents.intentdefinition
index f49bdce..fbbcd16 100644
--- a/SiriKit/Base.lproj/Intents.intentdefinition
+++ b/SiriKit/Base.lproj/Intents.intentdefinition
@@ -24,28 +24,28 @@
<key>INIntentDescriptionID</key>
<string>Pe02nj</string>
<key>INIntentLastParameterTag</key>
- <integer>2</integer>
+ <integer>22</integer>
<key>INIntentName</key>
<string>HDLRunScene</string>
<key>INIntentParameterCombinations</key>
<dict>
- <key>sceneName,sceneId</key>
+ <key>controlName,controlId,controlType,controlJSONStr,actionName,homeId</key>
<dict>
<key>INIntentParameterCombinationIsPrimary</key>
<true/>
<key>INIntentParameterCombinationSupportsBackgroundExecution</key>
<true/>
<key>INIntentParameterCombinationTitle</key>
- <string>鎵ц鍦烘櫙鈥�${sceneName}鈥�</string>
+ <string>${actionName}鈥�${controlName}鈥�</string>
<key>INIntentParameterCombinationTitleID</key>
- <string>oCGdw4</string>
+ <string>3GPMaH</string>
</dict>
</dict>
<key>INIntentParameters</key>
<array>
<dict>
<key>INIntentParameterDisplayName</key>
- <string>Scene Name</string>
+ <string>Control Name</string>
<key>INIntentParameterDisplayNameID</key>
<string>wC0SgK</string>
<key>INIntentParameterDisplayPriority</key>
@@ -58,7 +58,7 @@
<string>xz2KkJ</string>
</dict>
<key>INIntentParameterName</key>
- <string>sceneName</string>
+ <string>controlName</string>
<key>INIntentParameterTag</key>
<integer>1</integer>
<key>INIntentParameterType</key>
@@ -66,7 +66,7 @@
</dict>
<dict>
<key>INIntentParameterDisplayName</key>
- <string>Scene Id</string>
+ <string>Control Id</string>
<key>INIntentParameterDisplayNameID</key>
<string>MtgGtd</string>
<key>INIntentParameterDisplayPriority</key>
@@ -79,9 +79,93 @@
<string>hQHCm1</string>
</dict>
<key>INIntentParameterName</key>
- <string>sceneId</string>
+ <string>controlId</string>
<key>INIntentParameterTag</key>
<integer>2</integer>
+ <key>INIntentParameterType</key>
+ <string>String</string>
+ </dict>
+ <dict>
+ <key>INIntentParameterDisplayName</key>
+ <string>Home Id</string>
+ <key>INIntentParameterDisplayNameID</key>
+ <string>Re9KKp</string>
+ <key>INIntentParameterDisplayPriority</key>
+ <integer>3</integer>
+ <key>INIntentParameterMetadata</key>
+ <dict>
+ <key>INIntentParameterMetadataCapitalization</key>
+ <string>Sentences</string>
+ <key>INIntentParameterMetadataDefaultValueID</key>
+ <string>mQMSns</string>
+ </dict>
+ <key>INIntentParameterName</key>
+ <string>homeId</string>
+ <key>INIntentParameterTag</key>
+ <integer>12</integer>
+ <key>INIntentParameterType</key>
+ <string>String</string>
+ </dict>
+ <dict>
+ <key>INIntentParameterDisplayName</key>
+ <string>Control Type</string>
+ <key>INIntentParameterDisplayNameID</key>
+ <string>TBoK4E</string>
+ <key>INIntentParameterDisplayPriority</key>
+ <integer>4</integer>
+ <key>INIntentParameterMetadata</key>
+ <dict>
+ <key>INIntentParameterMetadataCapitalization</key>
+ <string>Sentences</string>
+ <key>INIntentParameterMetadataDefaultValueID</key>
+ <string>Yg2EJK</string>
+ </dict>
+ <key>INIntentParameterName</key>
+ <string>controlType</string>
+ <key>INIntentParameterTag</key>
+ <integer>14</integer>
+ <key>INIntentParameterType</key>
+ <string>String</string>
+ </dict>
+ <dict>
+ <key>INIntentParameterDisplayName</key>
+ <string>Control JSON Str</string>
+ <key>INIntentParameterDisplayNameID</key>
+ <string>WYEDs9</string>
+ <key>INIntentParameterDisplayPriority</key>
+ <integer>5</integer>
+ <key>INIntentParameterMetadata</key>
+ <dict>
+ <key>INIntentParameterMetadataCapitalization</key>
+ <string>Sentences</string>
+ <key>INIntentParameterMetadataDefaultValueID</key>
+ <string>WXdhpn</string>
+ </dict>
+ <key>INIntentParameterName</key>
+ <string>controlJSONStr</string>
+ <key>INIntentParameterTag</key>
+ <integer>21</integer>
+ <key>INIntentParameterType</key>
+ <string>String</string>
+ </dict>
+ <dict>
+ <key>INIntentParameterDisplayName</key>
+ <string>Action Name</string>
+ <key>INIntentParameterDisplayNameID</key>
+ <string>sB0JdL</string>
+ <key>INIntentParameterDisplayPriority</key>
+ <integer>6</integer>
+ <key>INIntentParameterMetadata</key>
+ <dict>
+ <key>INIntentParameterMetadataCapitalization</key>
+ <string>Sentences</string>
+ <key>INIntentParameterMetadataDefaultValueID</key>
+ <string>nGpmbm</string>
+ </dict>
+ <key>INIntentParameterName</key>
+ <string>actionName</string>
+ <key>INIntentParameterTag</key>
+ <integer>22</integer>
<key>INIntentParameterType</key>
<string>String</string>
</dict>
@@ -92,7 +176,7 @@
<array>
<dict>
<key>INIntentResponseCodeFormatString</key>
- <string>${sceneName}</string>
+ <string>${controlName}</string>
<key>INIntentResponseCodeFormatStringID</key>
<string>Pq8YBC</string>
<key>INIntentResponseCodeName</key>
@@ -149,13 +233,13 @@
</dict>
<dict>
<key>INIntentResponseParameterDisplayName</key>
- <string>Scene Name</string>
+ <string>Control Name</string>
<key>INIntentResponseParameterDisplayNameID</key>
<string>pqg7cb</string>
<key>INIntentResponseParameterDisplayPriority</key>
<integer>3</integer>
<key>INIntentResponseParameterName</key>
- <string>sceneName</string>
+ <string>controlName</string>
<key>INIntentResponseParameterTag</key>
<integer>3</integer>
<key>INIntentResponseParameterType</key>
--
Gitblit v1.8.0