diff --git a/PepperDashEssentials/ControlSystem.cs b/PepperDashEssentials/ControlSystem.cs index 460086e0..2049ef34 100644 --- a/PepperDashEssentials/ControlSystem.cs +++ b/PepperDashEssentials/ControlSystem.cs @@ -16,6 +16,7 @@ using PepperDash.Essentials.Devices.Common; using PepperDash.Essentials.DM; using PepperDash.Essentials.Fusion; using PepperDash.Essentials.Room.Config; +using PepperDash.Essentials.Core.Room; using Newtonsoft.Json; using PepperDash.Essentials.Core.DeviceTypeInterfaces; @@ -428,8 +429,18 @@ namespace PepperDash.Essentials foreach (var roomConfig in ConfigReader.ConfigObject.Rooms) { - var room = EssentialsRoomConfigHelper.GetRoomObject(roomConfig) as EssentialsRoomBase; - if (room != null) + Device room = null; + + if (roomConfig.Type != "componentRoom") + { + room = EssentialsRoomConfigHelper.GetRoomObject(roomConfig) as EssentialsRoomBase; + } + else + { + + } + + if (room != null && room is EssentialsRoomBase) { if (room is EssentialsHuddleSpaceRoom) { @@ -441,7 +452,7 @@ namespace PepperDash.Essentials Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to build Mobile Control Bridge..."); - CreateMobileControlBridge(room); + CreateMobileControlBridge(room as EssentialsRoomBase); } else if (room is EssentialsHuddleVtc1Room) { @@ -452,7 +463,7 @@ namespace PepperDash.Essentials Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to build Mobile Control Bridge..."); - CreateMobileControlBridge(room); + CreateMobileControlBridge(room as EssentialsRoomBase); } else { @@ -460,6 +471,10 @@ namespace PepperDash.Essentials DeviceManager.AddDevice(room); } + } + else if (room is ComponentRoom) + { + } else Debug.Console(0, Debug.ErrorLogLevel.Notice, "Notice: Cannot create room from config, key '{0}' - Is this intentional? This may be a valid configuration.", roomConfig.Key); @@ -558,7 +573,7 @@ namespace PepperDash.Essentials } catch (Exception e) { - Debug.Console(1, Debug.ErrorLogLevel.Notice, "Unable to find logo information in any room config"); + 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/PepperDash_Essentials_Core.csproj b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj index b5aa4543..a9ef203f 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -277,9 +277,13 @@ + + + + diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Components/ComponentFactory.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Components/ComponentFactory.cs new file mode 100644 index 00000000..e48c0a86 --- /dev/null +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Components/ComponentFactory.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +using PepperDash.Essentials.Interfaces.Components; + +namespace PepperDash.Essentials.Core.Room.Components +{ + public class ComponentFactory + { + + } +} \ 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 new file mode 100644 index 00000000..fd12901c --- /dev/null +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Components/ComponentRoom.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +using PepperDash.Core; +using PepperDash.Essentials.Interfaces.Components; +using PepperDash.Essentials.Core.Config; + +using Newtonsoft.Json; + +namespace PepperDash.Essentials.Core.Room +{ + /// + /// The base config class for various component types + /// + public abstract class RoomComponentConfig : DeviceConfig + { + + } + + /// + /// The config class for an activiry + /// + public class RoomActivityConfig : RoomComponentConfig + { + [JsonProperty("label")] + public string Label { get; set; } + [JsonProperty("icon")] + public string Icon { get; set; } + [JsonProperty("componentKey")] + public string ComponentKey { get; set; } + [JsonProperty("order")] + public int Order { get; set; } + } + + /// + /// The config class for a room behaviour + /// + public class RoomBehaviourConfig : RoomComponentConfig + { + + } + + /// + /// The config class for a device behavior + /// + public class RoomDeviceBehaviourConfig : RoomComponentConfig + { + + } + + public class ComponentRoomPropertiesConfig + { + [JsonProperty("activities")] + public List Activities { get; set; } + [JsonProperty("components")] + public List Components { get; set; } + + } + + public class ComponentRoom : Device, IComponentRoom + { + public List Components { get; private set; } + public List Activities { get; private set; } + + public ComponentRoom(string key, string name) + : base(key, name) + { + + } + + public List GetRoomComponentsOfType(Type componentType) + { + // 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 list of the activies sorted by order + /// + /// + public List GetOrderedActvities() + { + return Activities.OrderBy(a => a.Order).ToList(); + } + + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Components/RoomComponentBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Components/RoomComponentBase.cs new file mode 100644 index 00000000..1e640f5b --- /dev/null +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Components/RoomComponentBase.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +using PepperDash.Essentials.Interfaces.Components; + +namespace PepperDash.Essentials.Core.Room.Components +{ + /// + /// The base class from which Room Components should be derived + /// + public abstract class RoomComponentBase : IRoomComponent + { + private string _componentKey; + + /// + /// The key of the component, which is composed of the parent room key, plus the specific component key + /// + public string Key { + get + { + return Parent.Key + "-" + _componentKey; + } + } + + public IComponentRoom Parent { get; private set; } + + public RoomComponentBase(string key, IComponentRoom parent) + { + _componentKey = key; + Parent = parent; + } + + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Room.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Room.cs index 5e190bc9..68a1f4b1 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Room.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Room.cs @@ -12,45 +12,45 @@ namespace PepperDash.Essentials.Core { //*************************************************************************************************** - public abstract class Room : Device, IHasFeedback - { - public abstract BoolFeedback RoomIsOnFeedback { get; protected set; } - public abstract BoolFeedback IsCoolingDownFeedback { get; protected set; } - public abstract BoolFeedback IsWarmingUpFeedback { get; protected set; } +// public abstract class Room : Device, IHasFeedback +// { +// public abstract BoolFeedback RoomIsOnFeedback { get; protected set; } +// public abstract BoolFeedback IsCoolingDownFeedback { get; protected set; } +// public abstract BoolFeedback IsWarmingUpFeedback { get; protected set; } - // In concrete classes, these should be computed from the relevant devices - public virtual uint CooldownTime { get { return 10000; } } - public virtual uint WarmupTime { get { return 5000; } } +// // In concrete classes, these should be computed from the relevant devices +// public virtual uint CooldownTime { get { return 10000; } } +// public virtual uint WarmupTime { get { return 5000; } } - public string Description { get; set; } - public string HelpMessage { get; set; } +// public string Description { get; set; } +// public string HelpMessage { get; set; } - public Room(string key, string name) - : base(key, name) - { - Description = ""; - HelpMessage = ""; - } +// public Room(string key, string name) +// : base(key, name) +// { +// Description = ""; +// HelpMessage = ""; +// } - public virtual void RoomOn() { } +// public virtual void RoomOn() { } - public virtual void RoomOff() { } +// public virtual void RoomOff() { } - #region IDeviceWithOutputs Members +// #region IDeviceWithOutputs Members - public virtual FeedbackCollection Feedbacks - { - get - { - return new FeedbackCollection - { - RoomIsOnFeedback, - IsCoolingDownFeedback, - IsWarmingUpFeedback - }; - } - } +// public virtual FeedbackCollection Feedbacks +// { +// get +// { +// return new FeedbackCollection +// { +// RoomIsOnFeedback, +// IsCoolingDownFeedback, +// IsWarmingUpFeedback +// }; +// } +// } - #endregion - } +// #endregion +// } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/RoomFactory.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/RoomFactory.cs new file mode 100644 index 00000000..59ce9de4 --- /dev/null +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/RoomFactory.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +using PepperDash.Essentials.Interfaces.Components; + +namespace PepperDash.Essentials.Core.Room +{ + /// + /// The class that constructs rooms + /// + public static class RoomFactory + { + + + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials Interfaces/PepperDash_Essentials_Interfaces/Components/RoomComponents.cs b/essentials-framework/Essentials Interfaces/PepperDash_Essentials_Interfaces/Components/RoomComponents.cs new file mode 100644 index 00000000..a67c49d5 --- /dev/null +++ b/essentials-framework/Essentials Interfaces/PepperDash_Essentials_Interfaces/Components/RoomComponents.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +using PepperDash.Core; + +namespace PepperDash.Essentials.Interfaces.Components +{ + /// + /// Describes a room comprised of components + /// + public interface IComponentRoom : IKeyed + { + List Components { get; } + List Activities { get; } + + List GetRoomComponentsOfType(Type type); + List GetOrderedActvities(); + } + + /// + /// Describes a component + /// + public interface IComponent : IKeyed + { + + } + + /// + /// Describes a room component + /// + public interface IRoomComponent : IComponent + { + IComponentRoom Parent { get; } + } + + /// + /// Describes a room activity component + /// + public interface IRoomActivityComponent : IRoomComponent + { + string Label { get; } + string Icon { get; } + IRoomComponent Component { get; } + int Order { get; } + + void StartActivity(); + void EndActivity(); + } + + /// + /// Describes a room component that can be "used" by a user + /// + public interface IUsableRoomComponent + { + bool InUse { get; } + + void StartUse(); + void EndUse(); + } + + /// + /// Describes a room behaviour component + /// + public interface IRoomBehaviourComponent : IUsableRoomComponent + { + + } + + /// + /// Describes a room device component + /// + public interface IRoomDeviceComponent : IUsableRoomComponent + { + + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials Interfaces/PepperDash_Essentials_Interfaces/PepperDash_Essentials_Interfaces.csproj b/essentials-framework/Essentials Interfaces/PepperDash_Essentials_Interfaces/PepperDash_Essentials_Interfaces.csproj index 1ccb318d..a791044d 100644 --- a/essentials-framework/Essentials Interfaces/PepperDash_Essentials_Interfaces/PepperDash_Essentials_Interfaces.csproj +++ b/essentials-framework/Essentials Interfaces/PepperDash_Essentials_Interfaces/PepperDash_Essentials_Interfaces.csproj @@ -47,6 +47,10 @@ + + False + ..\..\..\packages\PepperDashCore\lib\net35\PepperDash_Core.dll + False ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll @@ -60,6 +64,7 @@ +