From c54351f8eec4fd4d53233be43c8257d6335ac765 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 10 Dec 2019 14:28:20 -0700 Subject: [PATCH] Adds CustomUnregisterWithAppServer method to allow unregistration at runtime --- .../Messengers/SIMPLCameraMessenger.cs | 24 ++++++++++++++++--- .../Messengers/SIMPLRouteMessenger.cs | 11 +++++++-- .../MobileControlDdvc01RoomBridge.cs | 4 ++-- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/PepperDashEssentials/AppServer/Messengers/SIMPLCameraMessenger.cs b/PepperDashEssentials/AppServer/Messengers/SIMPLCameraMessenger.cs index d9868c69..bbf16cea 100644 --- a/PepperDashEssentials/AppServer/Messengers/SIMPLCameraMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/SIMPLCameraMessenger.cs @@ -109,10 +109,11 @@ namespace PepperDash.Essentials.AppServer.Messengers { var asc = appServerController; + asc.AddAction(MessagePath + "/fullStatus", new Action(SendCameraFullMessageObject)); // Add press and holds using helper action Action addPHAction = (s, u) => - AppServerController.AddAction(MessagePath + s, new PressAndHoldAction(b => EISC.SetBool(u, b))); + asc.AddAction(MessagePath + s, new PressAndHoldAction(b => EISC.SetBool(u, b))); addPHAction("/cameraUp", BoolJoin.CameraControlUp + JoinStart); addPHAction("/cameraDown", BoolJoin.CameraControlDown + JoinStart); addPHAction("/cameraLeft", BoolJoin.CameraControlLeft + JoinStart); @@ -121,7 +122,7 @@ namespace PepperDash.Essentials.AppServer.Messengers addPHAction("/cameraZoomOut", BoolJoin.CameraControlZoomOut + JoinStart); Action addAction = (s, u) => - AppServerController.AddAction(MessagePath + s, new Action(() => EISC.PulseBool(u, 100))); + asc.AddAction(MessagePath + s, new Action(() => EISC.PulseBool(u, 100))); addAction("/cameraModeAuto", BoolJoin.CameraModeAuto); addAction("/cameraModeManual", BoolJoin.CameraModeManual); @@ -132,10 +133,27 @@ namespace PepperDash.Essentials.AppServer.Messengers { addAction("/cameraPreset" + (i), BoolJoin.CameraPresetStart + i + JoinStart); } + } - asc.AddAction(MessagePath + "/fullStatus", new Action(SendCameraFullMessageObject)); + public void CustomUnregsiterWithAppServer(MobileControlSystemController appServerController) + { + appServerController.RemoveAction(MessagePath + "/fullStatus"); + appServerController.RemoveAction(MessagePath + "/cameraUp"); + appServerController.RemoveAction(MessagePath + "/cameraDown"); + appServerController.RemoveAction(MessagePath + "/cameraLeft"); + appServerController.RemoveAction(MessagePath + "/cameraRight"); + appServerController.RemoveAction(MessagePath + "/cameraZoomIn"); + appServerController.RemoveAction(MessagePath + "/cameraZoomOut"); + appServerController.RemoveAction(MessagePath + "/cameraModeAuto"); + appServerController.RemoveAction(MessagePath + "/cameraModeManual"); + appServerController.RemoveAction(MessagePath + "/cameraModeOff"); + EISC.SetUShortSigAction(UshortJoin.CameraPresetCount + JoinStart, null); + + EISC.SetBoolSigAction(BoolJoin.CameraModeAuto, null); + EISC.SetBoolSigAction(BoolJoin.CameraModeManual, null); + EISC.SetBoolSigAction(BoolJoin.CameraModeOff, null); } /// diff --git a/PepperDashEssentials/AppServer/Messengers/SIMPLRouteMessenger.cs b/PepperDashEssentials/AppServer/Messengers/SIMPLRouteMessenger.cs index 21eabaff..7b8c26d4 100644 --- a/PepperDashEssentials/AppServer/Messengers/SIMPLRouteMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/SIMPLRouteMessenger.cs @@ -34,7 +34,6 @@ namespace PepperDash.Essentials.AppServer.Messengers EISC.SetStringSigAction(JoinStart + StringJoin.CurrentSource, (s) => SendRoutingFullMessageObject(s)); } - protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController) { appServerController.AddAction(MessagePath + "/fullStatus", new Action(() => @@ -42,13 +41,21 @@ namespace PepperDash.Essentials.AppServer.Messengers SendRoutingFullMessageObject(EISC.GetString(JoinStart + StringJoin.CurrentSource)); })); - appServerController.AddAction(string.Format(@"/device/inRoomPc-1/source"), new Action(c => + appServerController.AddAction(MessagePath +"/source", new Action(c => { EISC.SetString(JoinStart + StringJoin.CurrentSource, c.SourceListItem); })); } + public void CustomUnregsiterWithAppServer(MobileControlSystemController appServerController) + { + appServerController.RemoveAction(MessagePath + "/fullStatus"); + appServerController.RemoveAction(MessagePath + "/source"); + + EISC.SetStringSigAction(JoinStart + StringJoin.CurrentSource, null); + } + /// /// Helper method to update full status of the routing device /// diff --git a/PepperDashEssentials/AppServer/RoomBridges/MobileControlDdvc01RoomBridge.cs b/PepperDashEssentials/AppServer/RoomBridges/MobileControlDdvc01RoomBridge.cs index 9d8ec22b..863f1681 100644 --- a/PepperDashEssentials/AppServer/RoomBridges/MobileControlDdvc01RoomBridge.cs +++ b/PepperDashEssentials/AppServer/RoomBridges/MobileControlDdvc01RoomBridge.cs @@ -776,13 +776,12 @@ namespace PepperDash.Essentials.Room.MobileControl { foreach (var device in ConfigReader.ConfigObject.Devices) { - if (device.Group.Equals("appServerMessenger")) + if (device.Group.Equals("simplmessenger")) { var props = JsonConvert.DeserializeObject(device.Properties.ToString()); var messengerKey = string.Format("device-{0}-{1}", this.Key, Parent.Key); - MessengerBase messenger = null; var dev = ConfigReader.ConfigObject.GetDeviceForKey(props.DeviceKey); @@ -793,6 +792,7 @@ namespace PepperDash.Essentials.Room.MobileControl } var type = device.Type.ToLower(); + MessengerBase messenger = null; if (type.Equals("simplcameramessenger")) {