From bee73edbe1ecbb1221976df25c01c8cb7e96eb6a Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Thu, 28 Jan 2021 13:36:59 -0700 Subject: [PATCH] progress on component room classes and interfaces --- PepperDashEssentials/ControlSystem.cs | 19 +++++----- .../Devices/DeviceJsonApi.cs | 3 ++ .../Interfaces/Components/RoomComponents.cs | 36 +++++++++++++------ .../Room/Components/ComponentRoom.cs | 32 +++++++++++------ 4 files changed, 61 insertions(+), 29 deletions(-) diff --git a/PepperDashEssentials/ControlSystem.cs b/PepperDashEssentials/ControlSystem.cs index f2a25927..d600c0da 100644 --- a/PepperDashEssentials/ControlSystem.cs +++ b/PepperDashEssentials/ControlSystem.cs @@ -434,7 +434,7 @@ namespace PepperDash.Essentials { Device room = null; - if (roomConfig.Type != "componentRoom") + if (roomConfig.Type.ToLower() != "componentroom") { room = EssentialsRoomConfigHelper.GetRoomObject(roomConfig) as EssentialsRoomBase; } @@ -451,11 +451,14 @@ namespace PepperDash.Essentials // default to no join map key string fusionJoinMapKey = string.Empty; - if (room.Config.Properties["fusion"] != null) + + var essRoom = room as EssentialsRoomBase; + + if (essRoom.Config.Properties["fusion"] != null) { Debug.Console(2, "Custom Fusion config found. Using custom values"); - var fusionConfig = room.Config.Properties["fusion"].ToObject(); + var fusionConfig = essRoom.Config.Properties["fusion"].ToObject(); if (fusionConfig != null) { @@ -468,7 +471,7 @@ namespace PepperDash.Essentials { Debug.Console(0, Debug.ErrorLogLevel.Notice, "Room is EssentialsHuddleSpaceRoom, attempting to add to DeviceManager with Fusion"); - DeviceManager.AddDevice(new Core.Fusion.EssentialsHuddleSpaceFusionSystemControllerBase(room, fusionIpId, fusionJoinMapKey)); + DeviceManager.AddDevice(new Core.Fusion.EssentialsHuddleSpaceFusionSystemControllerBase(essRoom, fusionIpId, fusionJoinMapKey)); Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to build Mobile Control Bridge..."); @@ -479,7 +482,7 @@ namespace PepperDash.Essentials { Debug.Console(0, Debug.ErrorLogLevel.Notice, "Room is EssentialsHuddleVtc1Room, attempting to add to DeviceManager with Fusion"); - DeviceManager.AddDevice(new EssentialsHuddleVtc1FusionController((EssentialsHuddleVtc1Room)room, fusionIpId, fusionJoinMapKey)); + DeviceManager.AddDevice(new EssentialsHuddleVtc1FusionController((EssentialsHuddleVtc1Room)essRoom, fusionIpId, fusionJoinMapKey)); Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to build Mobile Control Bridge..."); @@ -491,11 +494,11 @@ namespace PepperDash.Essentials Debug.Console(0, Debug.ErrorLogLevel.Notice, "Room is EssentialsTechRoom, Attempting to add to DeviceManager with Fusion"); - DeviceManager.AddDevice(new EssentialsTechRoomFusionSystemController((EssentialsTechRoom)room, fusionIpId, fusionJoinMapKey)); + DeviceManager.AddDevice(new EssentialsTechRoomFusionSystemController((EssentialsTechRoom)essRoom, fusionIpId, fusionJoinMapKey)); Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to build Mobile Control Bridge"); - CreateMobileControlBridge(room); + CreateMobileControlBridge(essRoom); } else { @@ -601,7 +604,7 @@ namespace PepperDash.Essentials return ((logoDark != null && logoDark == "system") || (logoLight != null && logoLight == "system") || (logo != null && logo == "system")); } - catch + catch (Exception e) { Debug.Console(1, Debug.ErrorLogLevel.Notice, "Unable to find logo information in any room config: {0}", e); return false; diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceJsonApi.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceJsonApi.cs index 51d5882f..b04c93e5 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceJsonApi.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceJsonApi.cs @@ -246,8 +246,11 @@ namespace PepperDash.Essentials.Core public class DeviceActionWrapper { + [JsonProperty("deviceKey")] public string DeviceKey { get; set; } + [JsonProperty("methodName")] public string MethodName { get; set; } + [JsonProperty("params")] public object[] Params { get; set; } } diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Interfaces/Components/RoomComponents.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Interfaces/Components/RoomComponents.cs index c11f3319..62c64a7b 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Interfaces/Components/RoomComponents.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Interfaces/Components/RoomComponents.cs @@ -13,10 +13,10 @@ namespace PepperDash.Essentials.Core.Interfaces.Components /// public interface IComponentRoom : IKeyed { - List Components { get; } + List Components { get; } List Activities { get; } - List GetRoomComponentsOfType(Type type); + List GetRoomComponentsOfType(); List GetOrderedActvities(); } @@ -41,11 +41,15 @@ namespace PepperDash.Essentials.Core.Interfaces.Components /// public interface IRoomActivityComponent : IRoomComponent { + BoolFeedback IsEnabledFeedback { get; } + + bool Enable { set; } string Label { get; } string Icon { get; } - IRoomComponent Component { get; } + IRoomBehaviourGroupComponent Component { get; } int Order { get; } + void StartActivity(); void EndActivity(); } @@ -53,27 +57,37 @@ namespace PepperDash.Essentials.Core.Interfaces.Components /// /// Describes a room component that can be "used" by a user /// - public interface IUsableRoomComponent + public interface IActivatableComponent : IRoomComponent { - bool InUse { get; } + BoolFeedback ActivatedFeedback { get; } - void StartUse(); - void EndUse(); + void Activate(); + void Deactivate(); } /// - /// Describes a room behaviour component + /// Describes a room behaviour component. Is able to contain a collection of components that aggregate + /// together to behave as one /// - public interface IRoomBehaviourComponent : IUsableRoomComponent + public interface IRoomBehaviourGroupComponent + { + List Components { get; } + + void ActivateComponents(); + void DeactivateComponents(); + } + + public interface IRoomBehaviourComponent : IActivatableComponent { } + /// /// Describes a room device component /// - public interface IRoomDeviceComponent : IUsableRoomComponent + public interface IRoomDeviceComponent : IActivatableComponent where T : EssentialsDevice { - + public T Device { get; } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Components/ComponentRoom.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Components/ComponentRoom.cs index 975c97d7..d8535ee8 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Components/ComponentRoom.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Components/ComponentRoom.cs @@ -34,6 +34,8 @@ namespace PepperDash.Essentials.Core.Room public string ComponentKey { get; set; } [JsonProperty("order")] public int Order { get; set; } + [JsonProperty("selectAction")] + public DeviceActionWrapper SelectAction { get; set; } } /// @@ -49,7 +51,8 @@ namespace PepperDash.Essentials.Core.Room /// public class RoomDeviceBehaviourConfig : RoomComponentConfig { - + [JsonProperty("deviceKey")] + public string DeviceKey { get; set; } } /// @@ -72,7 +75,7 @@ namespace PepperDash.Essentials.Core.Room { public ComponentRoomPropertiesConfig PropertiesConfig { get; private set; } - public List Components { get; private set; } + public List Components { get; private set; } public List Activities { get; private set; } public ComponentRoom(DeviceConfig config) @@ -80,23 +83,32 @@ namespace PepperDash.Essentials.Core.Room { try { - PropertiesConfig = JsonConvert.DeserializeObject - (config.Properties.ToString()); + PropertiesConfig = config.Properties.ToObject(); } catch (Exception e) { Debug.Console(1, this, "Error building ComponentRoom: \n{0}", e); } + BuildComponents(); } - public List GetRoomComponentsOfType(Type componentType) + private void BuildComponents() { - // TODO: Figure this out later - return Components; - //var results = Components.OfType(); - //return results; - //return Components.Where(c => c != null && type.IsAssignableFrom(c.GetType())); + + + } + + + + /// + /// Returns a set of IRoomComponent that matches the specified Type + /// + /// + /// + public List GetRoomComponentsOfType() where T : IActivatableComponent + { + return Components.OfType().ToList(); } ///