progress on component room classes and interfaces

This commit is contained in:
Neil Dorin
2021-01-28 13:36:59 -07:00
parent fb97cf4753
commit bee73edbe1
4 changed files with 61 additions and 29 deletions

View File

@@ -434,7 +434,7 @@ namespace PepperDash.Essentials
{ {
Device room = null; Device room = null;
if (roomConfig.Type != "componentRoom") if (roomConfig.Type.ToLower() != "componentroom")
{ {
room = EssentialsRoomConfigHelper.GetRoomObject(roomConfig) as EssentialsRoomBase; room = EssentialsRoomConfigHelper.GetRoomObject(roomConfig) as EssentialsRoomBase;
} }
@@ -451,11 +451,14 @@ namespace PepperDash.Essentials
// default to no join map key // default to no join map key
string fusionJoinMapKey = string.Empty; 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"); Debug.Console(2, "Custom Fusion config found. Using custom values");
var fusionConfig = room.Config.Properties["fusion"].ToObject<EssentialsRoomFusionConfig>(); var fusionConfig = essRoom.Config.Properties["fusion"].ToObject<EssentialsRoomFusionConfig>();
if (fusionConfig != null) 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"); 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..."); 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"); 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..."); 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, Debug.Console(0, Debug.ErrorLogLevel.Notice,
"Room is EssentialsTechRoom, Attempting to add to DeviceManager with Fusion"); "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"); Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to build Mobile Control Bridge");
CreateMobileControlBridge(room); CreateMobileControlBridge(essRoom);
} }
else else
{ {
@@ -601,7 +604,7 @@ namespace PepperDash.Essentials
return ((logoDark != null && logoDark == "system") || return ((logoDark != null && logoDark == "system") ||
(logoLight != null && logoLight == "system") || (logo != null && logo == "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); Debug.Console(1, Debug.ErrorLogLevel.Notice, "Unable to find logo information in any room config: {0}", e);
return false; return false;

View File

@@ -246,8 +246,11 @@ namespace PepperDash.Essentials.Core
public class DeviceActionWrapper public class DeviceActionWrapper
{ {
[JsonProperty("deviceKey")]
public string DeviceKey { get; set; } public string DeviceKey { get; set; }
[JsonProperty("methodName")]
public string MethodName { get; set; } public string MethodName { get; set; }
[JsonProperty("params")]
public object[] Params { get; set; } public object[] Params { get; set; }
} }

View File

@@ -13,10 +13,10 @@ namespace PepperDash.Essentials.Core.Interfaces.Components
/// </summary> /// </summary>
public interface IComponentRoom : IKeyed public interface IComponentRoom : IKeyed
{ {
List<IRoomComponent> Components { get; } List<IActivatableComponent> Components { get; }
List<IRoomActivityComponent> Activities { get; } List<IRoomActivityComponent> Activities { get; }
List<IRoomComponent> GetRoomComponentsOfType(Type type); List<T> GetRoomComponentsOfType<T>();
List<IRoomActivityComponent> GetOrderedActvities(); List<IRoomActivityComponent> GetOrderedActvities();
} }
@@ -41,11 +41,15 @@ namespace PepperDash.Essentials.Core.Interfaces.Components
/// </summary> /// </summary>
public interface IRoomActivityComponent : IRoomComponent public interface IRoomActivityComponent : IRoomComponent
{ {
BoolFeedback IsEnabledFeedback { get; }
bool Enable { set; }
string Label { get; } string Label { get; }
string Icon { get; } string Icon { get; }
IRoomComponent Component { get; } IRoomBehaviourGroupComponent Component { get; }
int Order { get; } int Order { get; }
void StartActivity(); void StartActivity();
void EndActivity(); void EndActivity();
} }
@@ -53,27 +57,37 @@ namespace PepperDash.Essentials.Core.Interfaces.Components
/// <summary> /// <summary>
/// Describes a room component that can be "used" by a user /// Describes a room component that can be "used" by a user
/// </summary> /// </summary>
public interface IUsableRoomComponent public interface IActivatableComponent : IRoomComponent
{ {
bool InUse { get; } BoolFeedback ActivatedFeedback { get; }
void StartUse(); void Activate();
void EndUse(); void Deactivate();
} }
/// <summary> /// <summary>
/// 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
/// </summary> /// </summary>
public interface IRoomBehaviourComponent : IUsableRoomComponent public interface IRoomBehaviourGroupComponent
{
List<IActivatableComponent> Components { get; }
void ActivateComponents();
void DeactivateComponents();
}
public interface IRoomBehaviourComponent : IActivatableComponent
{ {
} }
/// <summary> /// <summary>
/// Describes a room device component /// Describes a room device component
/// </summary> /// </summary>
public interface IRoomDeviceComponent : IUsableRoomComponent public interface IRoomDeviceComponent<T> : IActivatableComponent where T : EssentialsDevice
{ {
public T Device { get; }
} }
} }

View File

@@ -34,6 +34,8 @@ namespace PepperDash.Essentials.Core.Room
public string ComponentKey { get; set; } public string ComponentKey { get; set; }
[JsonProperty("order")] [JsonProperty("order")]
public int Order { get; set; } public int Order { get; set; }
[JsonProperty("selectAction")]
public DeviceActionWrapper SelectAction { get; set; }
} }
/// <summary> /// <summary>
@@ -49,7 +51,8 @@ namespace PepperDash.Essentials.Core.Room
/// </summary> /// </summary>
public class RoomDeviceBehaviourConfig : RoomComponentConfig public class RoomDeviceBehaviourConfig : RoomComponentConfig
{ {
[JsonProperty("deviceKey")]
public string DeviceKey { get; set; }
} }
/// <summary> /// <summary>
@@ -72,7 +75,7 @@ namespace PepperDash.Essentials.Core.Room
{ {
public ComponentRoomPropertiesConfig PropertiesConfig { get; private set; } public ComponentRoomPropertiesConfig PropertiesConfig { get; private set; }
public List<IRoomComponent> Components { get; private set; } public List<IActivatableComponent> Components { get; private set; }
public List<IRoomActivityComponent> Activities { get; private set; } public List<IRoomActivityComponent> Activities { get; private set; }
public ComponentRoom(DeviceConfig config) public ComponentRoom(DeviceConfig config)
@@ -80,23 +83,32 @@ namespace PepperDash.Essentials.Core.Room
{ {
try try
{ {
PropertiesConfig = JsonConvert.DeserializeObject<ComponentRoomPropertiesConfig> PropertiesConfig = config.Properties.ToObject<ComponentRoomPropertiesConfig>();
(config.Properties.ToString());
} }
catch (Exception e) catch (Exception e)
{ {
Debug.Console(1, this, "Error building ComponentRoom: \n{0}", e); Debug.Console(1, this, "Error building ComponentRoom: \n{0}", e);
} }
BuildComponents();
} }
public List<IRoomComponent> GetRoomComponentsOfType(Type componentType) private void BuildComponents()
{ {
// TODO: Figure this out later
return Components;
//var results = Components.OfType<componentType>(); }
//return results;
//return Components.Where(c => c != null && type.IsAssignableFrom(c.GetType()));
/// <summary>
/// Returns a set of IRoomComponent that matches the specified Type
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public List<T> GetRoomComponentsOfType<T>() where T : IActivatableComponent
{
return Components.OfType<T>().ToList();
} }
/// <summary> /// <summary>