Compare commits

...

1 Commits

Author SHA1 Message Date
Neil Dorin
cb49b1f8c8 Interfaces added and some base classes built 2020-11-27 18:05:14 -07:00
9 changed files with 305 additions and 38 deletions

View File

@@ -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;
}
}

View File

@@ -277,9 +277,13 @@
<Compile Include="Remotes\CrestronRemotePropertiesConfig.cs" />
<Compile Include="Remotes\Hrxx0WirelessRemoteController.cs" />
<Compile Include="Room\Behaviours\RoomOnToDefaultSourceWhenOccupied.cs" />
<Compile Include="Room\Components\ComponentFactory.cs" />
<Compile Include="Room\Components\ComponentRoom.cs" />
<Compile Include="Room\Components\RoomComponentBase.cs" />
<Compile Include="Room\EssentialsRoomBase.cs" />
<Compile Include="Room\Interfaces.cs" />
<Compile Include="Room\iOccupancyStatusProvider.cs" />
<Compile Include="Room\RoomFactory.cs" />
<Compile Include="Routing\DummyRoutingInputsDevice.cs" />
<Compile Include="Routing\ICardPortsDevice.cs" />
<Compile Include="InUseTracking\IInUseTracking.cs" />

View File

@@ -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
{
}
}

View File

@@ -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
{
/// <summary>
/// The base config class for various component types
/// </summary>
public abstract class RoomComponentConfig : DeviceConfig
{
}
/// <summary>
/// The config class for an activiry
/// </summary>
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; }
}
/// <summary>
/// The config class for a room behaviour
/// </summary>
public class RoomBehaviourConfig : RoomComponentConfig
{
}
/// <summary>
/// The config class for a device behavior
/// </summary>
public class RoomDeviceBehaviourConfig : RoomComponentConfig
{
}
public class ComponentRoomPropertiesConfig
{
[JsonProperty("activities")]
public List<RoomActivityConfig> Activities { get; set; }
[JsonProperty("components")]
public List<RoomComponentConfig> Components { get; set; }
}
public class ComponentRoom : Device, IComponentRoom
{
public List<IRoomComponent> Components { get; private set; }
public List<IRoomActivityComponent> Activities { get; private set; }
public ComponentRoom(string key, string name)
: base(key, name)
{
}
public List<IRoomComponent> GetRoomComponentsOfType(Type componentType)
{
// 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 list of the activies sorted by order
/// </summary>
/// <returns></returns>
public List<IRoomActivityComponent> GetOrderedActvities()
{
return Activities.OrderBy(a => a.Order).ToList<IRoomActivityComponent>();
}
}
}

View File

@@ -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
{
/// <summary>
/// The base class from which Room Components should be derived
/// </summary>
public abstract class RoomComponentBase : IRoomComponent
{
private string _componentKey;
/// <summary>
/// The key of the component, which is composed of the parent room key, plus the specific component key
/// </summary>
public string Key {
get
{
return Parent.Key + "-" + _componentKey;
}
}
public IComponentRoom Parent { get; private set; }
public RoomComponentBase(string key, IComponentRoom parent)
{
_componentKey = key;
Parent = parent;
}
}
}

View File

@@ -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<Feedback> Feedbacks
{
get
{
return new FeedbackCollection<Feedback>
{
RoomIsOnFeedback,
IsCoolingDownFeedback,
IsWarmingUpFeedback
};
}
}
// public virtual FeedbackCollection<Feedback> Feedbacks
// {
// get
// {
// return new FeedbackCollection<Feedback>
// {
// RoomIsOnFeedback,
// IsCoolingDownFeedback,
// IsWarmingUpFeedback
// };
// }
// }
#endregion
}
// #endregion
// }
}

View File

@@ -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
{
/// <summary>
/// The class that constructs rooms
/// </summary>
public static class RoomFactory
{
}
}

View File

@@ -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
{
/// <summary>
/// Describes a room comprised of components
/// </summary>
public interface IComponentRoom : IKeyed
{
List<IRoomComponent> Components { get; }
List<IRoomActivityComponent> Activities { get; }
List<IRoomComponent> GetRoomComponentsOfType(Type type);
List<IRoomActivityComponent> GetOrderedActvities();
}
/// <summary>
/// Describes a component
/// </summary>
public interface IComponent : IKeyed
{
}
/// <summary>
/// Describes a room component
/// </summary>
public interface IRoomComponent : IComponent
{
IComponentRoom Parent { get; }
}
/// <summary>
/// Describes a room activity component
/// </summary>
public interface IRoomActivityComponent : IRoomComponent
{
string Label { get; }
string Icon { get; }
IRoomComponent Component { get; }
int Order { get; }
void StartActivity();
void EndActivity();
}
/// <summary>
/// Describes a room component that can be "used" by a user
/// </summary>
public interface IUsableRoomComponent
{
bool InUse { get; }
void StartUse();
void EndUse();
}
/// <summary>
/// Describes a room behaviour component
/// </summary>
public interface IRoomBehaviourComponent : IUsableRoomComponent
{
}
/// <summary>
/// Describes a room device component
/// </summary>
public interface IRoomDeviceComponent : IUsableRoomComponent
{
}
}

View File

@@ -47,6 +47,10 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="PepperDash_Core, Version=1.0.43.36276, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\PepperDashCore\lib\net35\PepperDash_Core.dll</HintPath>
</Reference>
<Reference Include="SimplSharpCustomAttributesInterface, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll</HintPath>
@@ -60,6 +64,7 @@
<Reference Include="System.Data" />
</ItemGroup>
<ItemGroup>
<Compile Include="Components\RoomComponents.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<None Include="Properties\ControlSystem.cfg" />
</ItemGroup>