mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-15 20:54:55 +00:00
@@ -11,35 +11,35 @@ namespace PepperDash.Core
|
|||||||
public class Device : IKeyName
|
public class Device : IKeyName
|
||||||
{
|
{
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Unique Key
|
/// Unique Key
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Key { get; protected set; }
|
public string Key { get; protected set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Name of the devie
|
/// Name of the devie
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Name { get; protected set; }
|
public string Name { get; protected set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Enabled { get; protected set; }
|
public bool Enabled { get; protected set; }
|
||||||
|
|
||||||
///// <summary>
|
///// <summary>
|
||||||
///// A place to store reference to the original config object, if any. These values should
|
///// A place to store reference to the original config object, if any. These values should
|
||||||
///// NOT be used as properties on the device as they are all publicly-settable values.
|
///// NOT be used as properties on the device as they are all publicly-settable values.
|
||||||
///// </summary>
|
///// </summary>
|
||||||
//public DeviceConfig Config { get; private set; }
|
//public DeviceConfig Config { get; private set; }
|
||||||
///// <summary>
|
///// <summary>
|
||||||
///// Helper method to check if Config exists
|
///// Helper method to check if Config exists
|
||||||
///// </summary>
|
///// </summary>
|
||||||
//public bool HasConfig { get { return Config != null; } }
|
//public bool HasConfig { get { return Config != null; } }
|
||||||
|
|
||||||
List<Action> _PreActivationActions;
|
List<Action> _PreActivationActions;
|
||||||
List<Action> _PostActivationActions;
|
List<Action> _PostActivationActions;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static Device DefaultDevice { get { return _DefaultDevice; } }
|
public static Device DefaultDevice { get { return _DefaultDevice; } }
|
||||||
static Device _DefaultDevice = new Device("Default", "Default");
|
static Device _DefaultDevice = new Device("Default", "Default");
|
||||||
|
|
||||||
@@ -54,27 +54,27 @@ namespace PepperDash.Core
|
|||||||
Name = "";
|
Name = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor with key and name
|
/// Constructor with key and name
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="key"></param>
|
/// <param name="key"></param>
|
||||||
/// <param name="name"></param>
|
/// <param name="name"></param>
|
||||||
public Device(string key, string name) : this(key)
|
public Device(string key, string name) : this(key)
|
||||||
{
|
{
|
||||||
Name = name;
|
Name = name;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//public Device(DeviceConfig config)
|
//public Device(DeviceConfig config)
|
||||||
// : this(config.Key, config.Name)
|
// : this(config.Key, config.Name)
|
||||||
//{
|
//{
|
||||||
// Config = config;
|
// Config = config;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds a pre activation action
|
/// Adds a pre activation action
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="act"></param>
|
/// <param name="act"></param>
|
||||||
public void AddPreActivationAction(Action act)
|
public void AddPreActivationAction(Action act)
|
||||||
{
|
{
|
||||||
if (_PreActivationActions == null)
|
if (_PreActivationActions == null)
|
||||||
@@ -82,10 +82,10 @@ namespace PepperDash.Core
|
|||||||
_PreActivationActions.Add(act);
|
_PreActivationActions.Add(act);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds a post activation action
|
/// Adds a post activation action
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="act"></param>
|
/// <param name="act"></param>
|
||||||
public void AddPostActivationAction(Action act)
|
public void AddPostActivationAction(Action act)
|
||||||
{
|
{
|
||||||
if (_PostActivationActions == null)
|
if (_PostActivationActions == null)
|
||||||
@@ -93,55 +93,58 @@ namespace PepperDash.Core
|
|||||||
_PostActivationActions.Add(act);
|
_PostActivationActions.Add(act);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Executes the preactivation actions
|
/// Executes the preactivation actions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void PreActivate()
|
public void PreActivate()
|
||||||
{
|
{
|
||||||
if (_PreActivationActions != null)
|
if (_PreActivationActions != null)
|
||||||
_PreActivationActions.ForEach(a => {
|
_PreActivationActions.ForEach(a =>
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
a.Invoke();
|
a.Invoke();
|
||||||
} catch (Exception e)
|
}
|
||||||
{
|
catch (Exception e)
|
||||||
|
{
|
||||||
Debug.LogMessage(e, "Error in PreActivationAction: " + e.Message, this);
|
Debug.LogMessage(e, "Error in PreActivationAction: " + e.Message, this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets this device ready to be used in the system. Runs any added pre-activation items, and
|
/// Gets this device ready to be used in the system. Runs any added pre-activation items, and
|
||||||
/// all post-activation at end. Classes needing additional logic to
|
/// all post-activation at end. Classes needing additional logic to
|
||||||
/// run should override CustomActivate()
|
/// run should override CustomActivate()
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Activate()
|
public bool Activate()
|
||||||
{
|
{
|
||||||
//if (_PreActivationActions != null)
|
//if (_PreActivationActions != null)
|
||||||
// _PreActivationActions.ForEach(a => a.Invoke());
|
// _PreActivationActions.ForEach(a => a.Invoke());
|
||||||
var result = CustomActivate();
|
var result = CustomActivate();
|
||||||
//if(result && _PostActivationActions != null)
|
//if(result && _PostActivationActions != null)
|
||||||
// _PostActivationActions.ForEach(a => a.Invoke());
|
// _PostActivationActions.ForEach(a => a.Invoke());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Executes the postactivation actions
|
/// Executes the postactivation actions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void PostActivate()
|
public void PostActivate()
|
||||||
{
|
{
|
||||||
if (_PostActivationActions != null)
|
if (_PostActivationActions != null)
|
||||||
_PostActivationActions.ForEach(a => {
|
_PostActivationActions.ForEach(a =>
|
||||||
try
|
{
|
||||||
{
|
try
|
||||||
a.Invoke();
|
{
|
||||||
}
|
a.Invoke();
|
||||||
catch (Exception e)
|
}
|
||||||
{
|
catch (Exception e)
|
||||||
Debug.LogMessage(e, "Error in PostActivationAction: " + e.Message, this);
|
{
|
||||||
}
|
Debug.LogMessage(e, "Error in PostActivationAction: " + e.Message, this);
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called in between Pre and PostActivationActions when Activate() is called.
|
/// Called in between Pre and PostActivationActions when Activate() is called.
|
||||||
@@ -158,14 +161,14 @@ namespace PepperDash.Core
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual bool Deactivate() { return true; }
|
public virtual bool Deactivate() { return true; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Call this method to start communications with a device. Overriding classes do not need to call base.Initialize()
|
/// Call this method to start communications with a device. Overriding classes do not need to call base.Initialize()
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void Initialize()
|
public virtual void Initialize()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Helper method to check object for bool value false and fire an Action method
|
/// Helper method to check object for bool value false and fire an Action method
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="o">Should be of type bool, others will be ignored</param>
|
/// <param name="o">Should be of type bool, others will be ignored</param>
|
||||||
@@ -175,5 +178,15 @@ namespace PepperDash.Core
|
|||||||
if (o is bool && !(bool)o) a();
|
if (o is bool && !(bool)o) a();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a string representation of the object, including its key and name.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>The returned string is formatted as "{Key} - {Name}". If the <c>Name</c> property is
|
||||||
|
/// null or empty, "---" is used in place of the name.</remarks>
|
||||||
|
/// <returns>A string that represents the object, containing the key and name in the format "{Key} - {Name}".</returns>
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return string.Format("{0} - {1}", Key, string.IsNullOrEmpty(Name) ? "---" : Name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This defines a device that has screens with layouts
|
||||||
|
/// Simply decorative
|
||||||
|
/// </summary>
|
||||||
|
public interface IHasScreensWithLayouts
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A dictionary of screens, keyed by screen ID, that contains information about each screen and its layouts.
|
||||||
|
/// </summary>
|
||||||
|
Dictionary<uint, ScreenInfo> Screens { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Applies a specific layout to a screen based on the provided screen ID and layout index.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="screenId"></param>
|
||||||
|
/// <param name="layoutIndex"></param>
|
||||||
|
void ApplyLayout(uint screenId, uint layoutIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents information about a screen and its layouts.
|
||||||
|
/// </summary>
|
||||||
|
public class ScreenInfo
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates whether the screen is enabled or not.
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("enabled")]
|
||||||
|
public bool Enabled { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The name of the screen.
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("name")]
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The index of the screen.
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("screenIndex")]
|
||||||
|
public int ScreenIndex { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A dictionary of layout information for the screen, keyed by layout ID.
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("layouts")]
|
||||||
|
public Dictionary<uint, LayoutInfo> Layouts { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents information about a layout on a screen.
|
||||||
|
/// </summary>
|
||||||
|
public class LayoutInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The name of the layout.
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("layoutName")]
|
||||||
|
public string LayoutName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The index of the layout.
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("layoutIndex")]
|
||||||
|
public int LayoutIndex { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The type of the layout, which can be "single", "double", "triple", or "quad".
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("layoutType")]
|
||||||
|
public string LayoutType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A dictionary of window configurations for the layout, keyed by window ID.
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("windows")]
|
||||||
|
public Dictionary<uint, WindowConfig> Windows { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the configuration of a window within a layout on a screen.
|
||||||
|
/// </summary>
|
||||||
|
public class WindowConfig
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The display label for the window
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("label")]
|
||||||
|
public string Label { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The input for the window
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("input")]
|
||||||
|
public string Input { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -248,7 +248,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
foreach (var dev in Devices.Values.OfType<ICommunicationMonitor>())
|
foreach (var dev in Devices.Values.OfType<ICommunicationMonitor>())
|
||||||
{
|
{
|
||||||
CrestronConsole.ConsoleCommandResponse($"{dev}: {dev.CommunicationMonitor.Status}{Environment.NewLine}");
|
CrestronConsole.ConsoleCommandResponse($"{dev}: {dev.CommunicationMonitor.Status}\r\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,19 +20,20 @@ namespace PepperDash.Essentials.Core
|
|||||||
public event EventHandler Initialized;
|
public event EventHandler Initialized;
|
||||||
|
|
||||||
private bool _isInitialized;
|
private bool _isInitialized;
|
||||||
public bool IsInitialized {
|
public bool IsInitialized
|
||||||
|
{
|
||||||
get { return _isInitialized; }
|
get { return _isInitialized; }
|
||||||
private set
|
private set
|
||||||
{
|
{
|
||||||
if (_isInitialized == value) return;
|
if (_isInitialized == value) return;
|
||||||
|
|
||||||
_isInitialized = value;
|
_isInitialized = value;
|
||||||
|
|
||||||
if (_isInitialized)
|
if (_isInitialized)
|
||||||
{
|
{
|
||||||
Initialized?.Invoke(this, new EventArgs());
|
Initialized?.Invoke(this, new EventArgs());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected EssentialsDevice(string key)
|
protected EssentialsDevice(string key)
|
||||||
@@ -80,8 +81,9 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Override this method to build and create custom Mobile Control Messengers during the Activation phase
|
/// Override this method to build and create custom Mobile Control Messengers during the Activation phase
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual void CreateMobileControlMessengers() {
|
protected virtual void CreateMobileControlMessengers()
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,13 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a device that manages room combinations by controlling partitions and scenarios.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>The <see cref="EssentialsRoomCombiner"/> allows for dynamic configuration of room
|
||||||
|
/// combinations based on partition states and predefined scenarios. It supports both automatic and manual modes
|
||||||
|
/// for managing room combinations. In automatic mode, the device determines the current room combination scenario
|
||||||
|
/// based on partition sensor states. In manual mode, scenarios can be set explicitly by the user.</remarks>
|
||||||
public class EssentialsRoomCombiner : EssentialsDevice, IEssentialsRoomCombiner
|
public class EssentialsRoomCombiner : EssentialsDevice, IEssentialsRoomCombiner
|
||||||
{
|
{
|
||||||
private EssentialsRoomCombinerPropertiesConfig _propertiesConfig;
|
private EssentialsRoomCombinerPropertiesConfig _propertiesConfig;
|
||||||
@@ -18,6 +25,9 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
private List<IEssentialsRoom> _rooms;
|
private List<IEssentialsRoom> _rooms;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a list of rooms represented as key-name pairs.
|
||||||
|
/// </summary>
|
||||||
public List<IKeyName> Rooms
|
public List<IKeyName> Rooms
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -28,6 +38,12 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
private bool _isInAutoMode;
|
private bool _isInAutoMode;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether the system is operating in automatic mode.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>Changing this property triggers an update event via
|
||||||
|
/// <c>IsInAutoModeFeedback.FireUpdate()</c>. Ensure that any event listeners are properly configured to handle
|
||||||
|
/// this update.</remarks>
|
||||||
public bool IsInAutoMode
|
public bool IsInAutoMode
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -46,12 +62,36 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether automatic mode is disabled.
|
||||||
|
/// </summary>
|
||||||
|
public bool DisableAutoMode
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _propertiesConfig.DisableAutoMode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private CTimer _scenarioChangeDebounceTimer;
|
private CTimer _scenarioChangeDebounceTimer;
|
||||||
|
|
||||||
private int _scenarioChangeDebounceTimeSeconds = 10; // default to 10s
|
private int _scenarioChangeDebounceTimeSeconds = 10; // default to 10s
|
||||||
|
|
||||||
private Mutex _scenarioChange = new Mutex();
|
private Mutex _scenarioChange = new Mutex();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="EssentialsRoomCombiner"/> class, which manages room combination
|
||||||
|
/// scenarios and partition states.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>The <see cref="EssentialsRoomCombiner"/> class is designed to handle dynamic room
|
||||||
|
/// combination scenarios based on partition states. It supports both automatic and manual modes for managing
|
||||||
|
/// room combinations. By default, the instance starts in automatic mode unless the <paramref name="props"/>
|
||||||
|
/// specifies otherwise. After activation, the room combiner initializes partition state providers and sets up
|
||||||
|
/// the initial room configuration. Additionally, it subscribes to the <see
|
||||||
|
/// cref="DeviceManager.AllDevicesInitialized"/> event to ensure proper initialization of dependent devices
|
||||||
|
/// before determining or setting the room combination scenario.</remarks>
|
||||||
|
/// <param name="key">The unique identifier for the room combiner instance.</param>
|
||||||
|
/// <param name="props">The configuration properties for the room combiner, including default settings and debounce times.</param>
|
||||||
public EssentialsRoomCombiner(string key, EssentialsRoomCombinerPropertiesConfig props)
|
public EssentialsRoomCombiner(string key, EssentialsRoomCombinerPropertiesConfig props)
|
||||||
: base(key)
|
: base(key)
|
||||||
{
|
{
|
||||||
@@ -246,8 +286,16 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
#region IEssentialsRoomCombiner Members
|
#region IEssentialsRoomCombiner Members
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Occurs when the room combination scenario changes.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>This event is triggered whenever the configuration or state of the room combination
|
||||||
|
/// changes. Subscribers can use this event to update their logic or UI based on the new scenario.</remarks>
|
||||||
public event EventHandler<EventArgs> RoomCombinationScenarioChanged;
|
public event EventHandler<EventArgs> RoomCombinationScenarioChanged;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the current room combination scenario.
|
||||||
|
/// </summary>
|
||||||
public IRoomCombinationScenario CurrentScenario
|
public IRoomCombinationScenario CurrentScenario
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -256,10 +304,25 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the feedback indicating whether the system is currently in auto mode.
|
||||||
|
/// </summary>
|
||||||
public BoolFeedback IsInAutoModeFeedback { get; private set; }
|
public BoolFeedback IsInAutoModeFeedback { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enables auto mode for the room combiner and its partitions, allowing automatic room combination scenarios to
|
||||||
|
/// be determined.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>Auto mode allows the room combiner to automatically adjust its configuration based on
|
||||||
|
/// the state of its partitions. If auto mode is disabled in the configuration, this method logs a warning and
|
||||||
|
/// does not enable auto mode.</remarks>
|
||||||
public void SetAutoMode()
|
public void SetAutoMode()
|
||||||
{
|
{
|
||||||
|
if(_propertiesConfig.DisableAutoMode)
|
||||||
|
{
|
||||||
|
this.LogWarning("Auto mode is disabled for this room combiner. Cannot set to auto mode.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
IsInAutoMode = true;
|
IsInAutoMode = true;
|
||||||
|
|
||||||
foreach (var partition in Partitions)
|
foreach (var partition in Partitions)
|
||||||
@@ -270,6 +333,12 @@ namespace PepperDash.Essentials.Core
|
|||||||
DetermineRoomCombinationScenario();
|
DetermineRoomCombinationScenario();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Switches the system to manual mode, disabling automatic operations.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>This method sets the system to manual mode by updating the mode state and propagates
|
||||||
|
/// the change to all partitions. Once in manual mode, automatic operations are disabled for the system and its
|
||||||
|
/// partitions.</remarks>
|
||||||
public void SetManualMode()
|
public void SetManualMode()
|
||||||
{
|
{
|
||||||
IsInAutoMode = false;
|
IsInAutoMode = false;
|
||||||
@@ -280,6 +349,11 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Toggles the current mode between automatic and manual.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>If the current mode is automatic, this method switches to manual mode. If the
|
||||||
|
/// current mode is manual, it switches to automatic mode.</remarks>
|
||||||
public void ToggleMode()
|
public void ToggleMode()
|
||||||
{
|
{
|
||||||
if (IsInAutoMode)
|
if (IsInAutoMode)
|
||||||
@@ -292,10 +366,22 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the collection of room combination scenarios.
|
||||||
|
/// </summary>
|
||||||
public List<IRoomCombinationScenario> RoomCombinationScenarios { get; private set; }
|
public List<IRoomCombinationScenario> RoomCombinationScenarios { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the collection of partition controllers managed by this instance.
|
||||||
|
/// </summary>
|
||||||
public List<IPartitionController> Partitions { get; private set; }
|
public List<IPartitionController> Partitions { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Toggles the state of the partition identified by the specified partition key.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>If no partition with the specified key exists, the method performs no
|
||||||
|
/// action.</remarks>
|
||||||
|
/// <param name="partitionKey">The key of the partition whose state is to be toggled. This value cannot be null or empty.</param>
|
||||||
public void TogglePartitionState(string partitionKey)
|
public void TogglePartitionState(string partitionKey)
|
||||||
{
|
{
|
||||||
var partition = Partitions.FirstOrDefault((p) => p.Key.Equals(partitionKey));
|
var partition = Partitions.FirstOrDefault((p) => p.Key.Equals(partitionKey));
|
||||||
@@ -306,6 +392,17 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the room combination scenario based on the specified scenario key.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>This method manually adjusts the partition states according to the specified
|
||||||
|
/// scenario. If the application is in auto mode, the operation will not proceed, and a log message will be
|
||||||
|
/// generated indicating that the mode must be set to manual first. If the specified scenario key does not
|
||||||
|
/// match any existing scenario, a debug log message will be generated. For each partition state in the
|
||||||
|
/// scenario, the corresponding partition will be updated to either "Present" or "Not Present" based on the
|
||||||
|
/// scenario's configuration. If a partition key in the scenario cannot be found, a debug log message will be
|
||||||
|
/// generated.</remarks>
|
||||||
|
/// <param name="scenarioKey">The key identifying the room combination scenario to apply. This must match the key of an existing scenario.</param>
|
||||||
public void SetRoomCombinationScenario(string scenarioKey)
|
public void SetRoomCombinationScenario(string scenarioKey)
|
||||||
{
|
{
|
||||||
if (IsInAutoMode)
|
if (IsInAutoMode)
|
||||||
@@ -354,13 +451,32 @@ namespace PepperDash.Essentials.Core
|
|||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Provides a factory for creating instances of <see cref="EssentialsRoomCombiner"/> devices.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>This factory is responsible for constructing <see cref="EssentialsRoomCombiner"/> devices
|
||||||
|
/// based on the provided configuration. It supports the type name "essentialsroomcombiner" for device
|
||||||
|
/// creation.</remarks>
|
||||||
public class EssentialsRoomCombinerFactory : EssentialsDeviceFactory<EssentialsRoomCombiner>
|
public class EssentialsRoomCombinerFactory : EssentialsDeviceFactory<EssentialsRoomCombiner>
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="EssentialsRoomCombinerFactory"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>This factory is used to create instances of room combiners with the specified type
|
||||||
|
/// names. By default, the factory includes the type name "essentialsroomcombiner".</remarks>
|
||||||
public EssentialsRoomCombinerFactory()
|
public EssentialsRoomCombinerFactory()
|
||||||
{
|
{
|
||||||
TypeNames = new List<string> { "essentialsroomcombiner" };
|
TypeNames = new List<string> { "essentialsroomcombiner" };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates and initializes a new instance of the <see cref="EssentialsRoomCombiner"/> device.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>This method uses the provided device configuration to extract the properties and
|
||||||
|
/// create an <see cref="EssentialsRoomCombiner"/> device. Ensure that the configuration contains valid
|
||||||
|
/// properties for the device to be created successfully.</remarks>
|
||||||
|
/// <param name="dc">The device configuration containing the key and properties required to build the device.</param>
|
||||||
|
/// <returns>A new instance of <see cref="EssentialsRoomCombiner"/> initialized with the specified configuration.</returns>
|
||||||
public override EssentialsDevice BuildDevice(PepperDash.Essentials.Core.Config.DeviceConfig dc)
|
public override EssentialsDevice BuildDevice(PepperDash.Essentials.Core.Config.DeviceConfig dc)
|
||||||
{
|
{
|
||||||
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new EssentialsRoomCombiner Device");
|
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new EssentialsRoomCombiner Device");
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
|
|
||||||
@@ -17,6 +11,14 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class EssentialsRoomCombinerPropertiesConfig
|
public class EssentialsRoomCombinerPropertiesConfig
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether the system operates in automatic mode.
|
||||||
|
/// <remarks>Some systems don't have partitions sensors, and show shouldn't allow auto mode to be turned on. When this is true in the configuration,
|
||||||
|
/// auto mode won't be allowed to be turned on.</remarks>
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("disableAutoMode")]
|
||||||
|
public bool DisableAutoMode { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The list of partitions that device the rooms
|
/// The list of partitions that device the rooms
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -47,6 +49,9 @@ namespace PepperDash.Essentials.Core
|
|||||||
[JsonProperty("defaultScenarioKey")]
|
[JsonProperty("defaultScenarioKey")]
|
||||||
public string defaultScenarioKey { get; set; }
|
public string defaultScenarioKey { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the debounce time, in seconds, for scenario changes.
|
||||||
|
/// </summary>
|
||||||
[JsonProperty("scenarioChangeDebounceTimeSeconds")]
|
[JsonProperty("scenarioChangeDebounceTimeSeconds")]
|
||||||
public int ScenarioChangeDebounceTimeSeconds { get; set; }
|
public int ScenarioChangeDebounceTimeSeconds { get; set; }
|
||||||
}
|
}
|
||||||
@@ -56,9 +61,15 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class PartitionConfig : IKeyName
|
public class PartitionConfig : IKeyName
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the unique key associated with the object.
|
||||||
|
/// </summary>
|
||||||
[JsonProperty("key")]
|
[JsonProperty("key")]
|
||||||
public string Key { get; set; }
|
public string Key { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the name associated with the object.
|
||||||
|
/// </summary>
|
||||||
[JsonProperty("name")]
|
[JsonProperty("name")]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
@@ -80,12 +91,21 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class RoomCombinationScenarioConfig : IKeyName
|
public class RoomCombinationScenarioConfig : IKeyName
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the key associated with the object.
|
||||||
|
/// </summary>
|
||||||
[JsonProperty("key")]
|
[JsonProperty("key")]
|
||||||
public string Key { get; set; }
|
public string Key { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the name associated with the object.
|
||||||
|
/// </summary>
|
||||||
[JsonProperty("name")]
|
[JsonProperty("name")]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the collection of partition states.
|
||||||
|
/// </summary>
|
||||||
[JsonProperty("partitionStates")]
|
[JsonProperty("partitionStates")]
|
||||||
public List<PartitionState> PartitionStates { get; set; }
|
public List<PartitionState> PartitionStates { get; set; }
|
||||||
|
|
||||||
@@ -95,9 +115,15 @@ namespace PepperDash.Essentials.Core
|
|||||||
[JsonProperty("uiMap")]
|
[JsonProperty("uiMap")]
|
||||||
public Dictionary<string, string> UiMap { get; set; }
|
public Dictionary<string, string> UiMap { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the list of actions to be performed during device activation.
|
||||||
|
/// </summary>
|
||||||
[JsonProperty("activationActions")]
|
[JsonProperty("activationActions")]
|
||||||
public List<DeviceActionWrapper> ActivationActions { get; set; }
|
public List<DeviceActionWrapper> ActivationActions { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the list of actions to be performed when a device is deactivated.
|
||||||
|
/// </summary>
|
||||||
[JsonProperty("deactivationActions")]
|
[JsonProperty("deactivationActions")]
|
||||||
public List<DeviceActionWrapper> DeactivationActions { get; set; }
|
public List<DeviceActionWrapper> DeactivationActions { get; set; }
|
||||||
}
|
}
|
||||||
@@ -107,9 +133,15 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class PartitionState
|
public class PartitionState
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the partition key used to group and organize data within a storage system.
|
||||||
|
/// </summary>
|
||||||
[JsonProperty("partitionKey")]
|
[JsonProperty("partitionKey")]
|
||||||
public string PartitionKey { get; set; }
|
public string PartitionKey { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether a partition is currently present.
|
||||||
|
/// </summary>
|
||||||
[JsonProperty("partitionSensedState")]
|
[JsonProperty("partitionSensedState")]
|
||||||
public bool PartitionPresent { get; set; }
|
public bool PartitionPresent { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,9 +28,20 @@ namespace PepperDash.Essentials.Core
|
|||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
BoolFeedback IsInAutoModeFeedback {get;}
|
BoolFeedback IsInAutoModeFeedback {get;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether the automatic mode is disabled.
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("disableAutoMode")]
|
||||||
|
bool DisableAutoMode { get; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether the system is operating in automatic mode.
|
||||||
|
/// </summary>
|
||||||
[JsonProperty("isInAutoMode")]
|
[JsonProperty("isInAutoMode")]
|
||||||
bool IsInAutoMode { get; }
|
bool IsInAutoMode { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the collection of rooms associated with the current object.
|
||||||
|
/// </summary>
|
||||||
[JsonProperty("rooms")]
|
[JsonProperty("rooms")]
|
||||||
List<IKeyName> Rooms { get; }
|
List<IKeyName> Rooms { get; }
|
||||||
|
|
||||||
@@ -74,6 +85,13 @@ namespace PepperDash.Essentials.Core
|
|||||||
void SetRoomCombinationScenario(string scenarioKey);
|
void SetRoomCombinationScenario(string scenarioKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a scenario for combining rooms, including activation, deactivation, and associated state.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>This interface defines the behavior for managing room combination scenarios, including
|
||||||
|
/// activation and deactivation, tracking the active state, and managing related partition states and UI mappings.
|
||||||
|
/// Implementations of this interface are expected to handle the logic for room combinations based on the provided
|
||||||
|
/// partition states and UI mappings.</remarks>
|
||||||
public interface IRoomCombinationScenario : IKeyName
|
public interface IRoomCombinationScenario : IKeyName
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -82,6 +100,9 @@ namespace PepperDash.Essentials.Core
|
|||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
BoolFeedback IsActiveFeedback { get; }
|
BoolFeedback IsActiveFeedback { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether the entity is active.
|
||||||
|
/// </summary>
|
||||||
[JsonProperty("isActive")]
|
[JsonProperty("isActive")]
|
||||||
bool IsActive { get; }
|
bool IsActive { get; }
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
using PepperDash.Core;
|
||||||
|
using PepperDash.Essentials.Core;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Devices.Common.Codec.Cisco
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Describes the available tracking modes for a Cisco codec's Presenter Track feature.
|
||||||
|
/// </summary>
|
||||||
|
public enum ePresenterTrackMode
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Presenter Track is turned off.
|
||||||
|
/// </summary>
|
||||||
|
Off,
|
||||||
|
/// <summary>
|
||||||
|
/// Presenter Track follows the speaker's movements.
|
||||||
|
/// </summary>
|
||||||
|
Follow,
|
||||||
|
/// <summary>
|
||||||
|
/// Presenter Track is set to background mode, where it tracks the speaker but does not actively follow.
|
||||||
|
/// </summary>
|
||||||
|
Background,
|
||||||
|
/// <summary>
|
||||||
|
/// Presenter Track is set to persistent mode, where it maintains a fixed position or focus on the speaker.
|
||||||
|
/// </summary>
|
||||||
|
Persistent
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Describes the Presenter Track controls for a Cisco codec.
|
||||||
|
/// </summary>
|
||||||
|
public interface IPresenterTrack : IKeyed
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
bool PresenterTrackAvailability { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Feedback indicating whether Presenter Track is available.
|
||||||
|
/// </summary>
|
||||||
|
BoolFeedback PresenterTrackAvailableFeedback { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Feedback indicating the current status of Presenter Track is off
|
||||||
|
/// </summary>
|
||||||
|
BoolFeedback PresenterTrackStatusOffFeedback { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Feedback indicating the current status of Presenter Track is follow
|
||||||
|
/// </summary>
|
||||||
|
BoolFeedback PresenterTrackStatusFollowFeedback { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Feedback indicating the current status of Presenter Track is background
|
||||||
|
/// </summary>
|
||||||
|
BoolFeedback PresenterTrackStatusBackgroundFeedback { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Feedback indicating the current status of Presenter Track is persistent
|
||||||
|
/// </summary>
|
||||||
|
BoolFeedback PresenterTrackStatusPersistentFeedback { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates the current status of Presenter Track.
|
||||||
|
/// </summary>
|
||||||
|
bool PresenterTrackStatus { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Turns off Presenter Track.
|
||||||
|
/// </summary>
|
||||||
|
void PresenterTrackOff();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Turns on Presenter Track in follow mode.
|
||||||
|
/// </summary>
|
||||||
|
void PresenterTrackFollow();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Turns on Presenter Track in background mode.
|
||||||
|
/// </summary>
|
||||||
|
void PresenterTrackBackground();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Turns on Presenter Track in persistent mode.
|
||||||
|
/// </summary>
|
||||||
|
void PresenterTrackPersistent();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
using PepperDash.Core;
|
||||||
|
using PepperDash.Essentials.Core;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Devices.Common.Codec.Cisco
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Describes the available tracking modes for a Cisco codec
|
||||||
|
/// </summary>
|
||||||
|
public interface ISpeakerTrack : IKeyed
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates whether Speaker Track is available on the codec.
|
||||||
|
/// </summary>
|
||||||
|
bool SpeakerTrackAvailability { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
BoolFeedback SpeakerTrackAvailableFeedback { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Feedback indicating the current status of Speaker Track is off
|
||||||
|
/// </summary>
|
||||||
|
bool SpeakerTrackStatus { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Turns Speaker Track off
|
||||||
|
/// </summary>
|
||||||
|
void SpeakerTrackOff();
|
||||||
|
/// <summary>
|
||||||
|
/// Turns Speaker Track on
|
||||||
|
/// </summary>
|
||||||
|
void SpeakerTrackOn();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,20 +12,45 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IHasCodecRoomPresets
|
public interface IHasCodecRoomPresets
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Event that is raised when the list of room presets has changed.
|
||||||
|
/// </summary>
|
||||||
event EventHandler<EventArgs> CodecRoomPresetsListHasChanged;
|
event EventHandler<EventArgs> CodecRoomPresetsListHasChanged;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List of near end presets that can be recalled.
|
||||||
|
/// </summary>
|
||||||
List<CodecRoomPreset> NearEndPresets { get; }
|
List<CodecRoomPreset> NearEndPresets { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List of far end presets that can be recalled.
|
||||||
|
/// </summary>
|
||||||
List<CodecRoomPreset> FarEndRoomPresets { get; }
|
List<CodecRoomPreset> FarEndRoomPresets { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Selects a near end preset by its ID.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="preset"></param>
|
||||||
void CodecRoomPresetSelect(int preset);
|
void CodecRoomPresetSelect(int preset);
|
||||||
|
|
||||||
void CodecRoomPresetStore(int preset, string description);
|
/// <summary>
|
||||||
|
/// Stores a near end preset with the given ID and description.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="preset"></param>
|
||||||
|
/// <param name="description"></param>
|
||||||
|
void CodecRoomPresetStore(int preset, string description);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Selects a far end preset by its ID. This is typically used to recall a preset that has been defined on the far end codec.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="preset"></param>
|
||||||
void SelectFarEndPreset(int preset);
|
void SelectFarEndPreset(int preset);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class RoomPresets
|
/// <summary>
|
||||||
|
/// Static class for converting non-generic RoomPresets to generic CameraPresets.
|
||||||
|
/// </summary>
|
||||||
|
public static class RoomPresets
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Converts non-generic RoomPresets to generic CameraPresets
|
/// Converts non-generic RoomPresets to generic CameraPresets
|
||||||
@@ -47,6 +72,13 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class CodecRoomPreset : PresetBase
|
public class CodecRoomPreset : PresetBase
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <param name="description"></param>
|
||||||
|
/// <param name="def"></param>
|
||||||
|
/// <param name="isDef"></param>
|
||||||
public CodecRoomPreset(int id, string description, bool def, bool isDef)
|
public CodecRoomPreset(int id, string description, bool def, bool isDef)
|
||||||
: base(id, description, def, isDef)
|
: base(id, description, def, isDef)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,27 +2,69 @@
|
|||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core.DeviceInfo;
|
using PepperDash.Essentials.Core.DeviceInfo;
|
||||||
|
using System.Timers;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.AppServer.Messengers
|
namespace PepperDash.Essentials.AppServer.Messengers
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Facilitates communication of device information by providing mechanisms for status updates and device
|
||||||
|
/// information reporting.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>The <see cref="DeviceInfoMessenger"/> class integrates with an <see
|
||||||
|
/// cref="IDeviceInfoProvider"/> to manage device-specific information. It uses a debounce timer to limit the
|
||||||
|
/// frequency of updates, ensuring efficient communication. The timer is initialized with a 1-second interval and
|
||||||
|
/// is disabled by default. This class also subscribes to device information change events and provides actions for
|
||||||
|
/// reporting full device status and triggering updates.</remarks>
|
||||||
public class DeviceInfoMessenger : MessengerBase
|
public class DeviceInfoMessenger : MessengerBase
|
||||||
{
|
{
|
||||||
private readonly IDeviceInfoProvider _deviceInfoProvider;
|
private readonly IDeviceInfoProvider _deviceInfoProvider;
|
||||||
|
|
||||||
|
private readonly Timer debounceTimer;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="DeviceInfoMessenger"/> class, which facilitates communication
|
||||||
|
/// of device information.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>The messenger uses a debounce timer to limit the frequency of certain operations. The
|
||||||
|
/// timer is initialized with a 1-second interval and is disabled by default.</remarks>
|
||||||
|
/// <param name="key">A unique identifier for the messenger instance.</param>
|
||||||
|
/// <param name="messagePath">The path used for sending and receiving messages.</param>
|
||||||
|
/// <param name="device">An implementation of <see cref="IDeviceInfoProvider"/> that provides device-specific information.</param>
|
||||||
public DeviceInfoMessenger(string key, string messagePath, IDeviceInfoProvider device) : base(key, messagePath, device as Device)
|
public DeviceInfoMessenger(string key, string messagePath, IDeviceInfoProvider device) : base(key, messagePath, device as Device)
|
||||||
{
|
{
|
||||||
_deviceInfoProvider = device;
|
_deviceInfoProvider = device;
|
||||||
}
|
|
||||||
|
|
||||||
|
debounceTimer = new Timer(1000)
|
||||||
|
{
|
||||||
|
Enabled = false,
|
||||||
|
AutoReset = false
|
||||||
|
};
|
||||||
|
|
||||||
|
debounceTimer.Elapsed += DebounceTimer_Elapsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DebounceTimer_Elapsed(object sender, ElapsedEventArgs e)
|
||||||
|
{
|
||||||
|
PostStatusMessage(JToken.FromObject(new
|
||||||
|
{
|
||||||
|
deviceInfo = _deviceInfoProvider.DeviceInfo
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Registers actions and event handlers for device information updates and status reporting.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>This method sets up actions for handling device status updates and reporting full
|
||||||
|
/// device status. It also subscribes to the <see cref="IDeviceInfoProvider.DeviceInfoChanged"/> event to
|
||||||
|
/// trigger debounced updates when the device information changes.</remarks>
|
||||||
protected override void RegisterActions()
|
protected override void RegisterActions()
|
||||||
{
|
{
|
||||||
base.RegisterActions();
|
base.RegisterActions();
|
||||||
|
|
||||||
_deviceInfoProvider.DeviceInfoChanged += (o, a) =>
|
_deviceInfoProvider.DeviceInfoChanged += (o, a) =>
|
||||||
{
|
{
|
||||||
PostStatusMessage(JToken.FromObject(new
|
debounceTimer.Stop();
|
||||||
{
|
debounceTimer.Start();
|
||||||
deviceInfo = a.DeviceInfo
|
|
||||||
}));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
AddAction("/fullStatus", (id, context) => PostStatusMessage(new DeviceInfoStateMessage
|
AddAction("/fullStatus", (id, context) => PostStatusMessage(new DeviceInfoStateMessage
|
||||||
@@ -34,6 +76,12 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a message containing the state information of a device, including detailed device information.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>This class is used to encapsulate the state of a device along with its associated
|
||||||
|
/// information. It extends <see cref="DeviceStateMessageBase"/> to provide additional details about the
|
||||||
|
/// device.</remarks>
|
||||||
public class DeviceInfoStateMessage : DeviceStateMessageBase
|
public class DeviceInfoStateMessage : DeviceStateMessageBase
|
||||||
{
|
{
|
||||||
[JsonProperty("deviceInfo")]
|
[JsonProperty("deviceInfo")]
|
||||||
|
|||||||
@@ -8,16 +8,42 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace PepperDash.Essentials.AppServer.Messengers
|
namespace PepperDash.Essentials.AppServer.Messengers
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides messaging functionality for managing room combination scenarios and partition states in an <see
|
||||||
|
/// cref="IEssentialsRoomCombiner"/> instance. Enables external systems to interact with the room combiner via
|
||||||
|
/// predefined actions and status updates.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>This class facilitates communication with an <see cref="IEssentialsRoomCombiner"/> by
|
||||||
|
/// exposing actions for toggling modes, managing partitions, and setting room combination scenarios. It also
|
||||||
|
/// listens for feedback changes and broadcasts status updates to connected systems. Typical usage involves
|
||||||
|
/// registering actions for external commands and handling feedback events to synchronize state changes.</remarks>
|
||||||
public class IEssentialsRoomCombinerMessenger : MessengerBase
|
public class IEssentialsRoomCombinerMessenger : MessengerBase
|
||||||
{
|
{
|
||||||
private readonly IEssentialsRoomCombiner _roomCombiner;
|
private readonly IEssentialsRoomCombiner _roomCombiner;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="IEssentialsRoomCombinerMessenger"/> class, which facilitates
|
||||||
|
/// messaging for an <see cref="IEssentialsRoomCombiner"/> instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>This class is designed to enable communication and interaction with an <see
|
||||||
|
/// cref="IEssentialsRoomCombiner"/> through the specified messaging path. Ensure that the <paramref
|
||||||
|
/// name="roomCombiner"/> parameter is not null when creating an instance.</remarks>
|
||||||
|
/// <param name="key">The unique key identifying this messenger instance.</param>
|
||||||
|
/// <param name="messagePath">The path used for messaging operations.</param>
|
||||||
|
/// <param name="roomCombiner">The <see cref="IEssentialsRoomCombiner"/> instance associated with this messenger.</param>
|
||||||
public IEssentialsRoomCombinerMessenger(string key, string messagePath, IEssentialsRoomCombiner roomCombiner)
|
public IEssentialsRoomCombinerMessenger(string key, string messagePath, IEssentialsRoomCombiner roomCombiner)
|
||||||
: base(key, messagePath, roomCombiner as IKeyName)
|
: base(key, messagePath, roomCombiner as IKeyName)
|
||||||
{
|
{
|
||||||
_roomCombiner = roomCombiner;
|
_roomCombiner = roomCombiner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Registers actions and event handlers for managing room combination scenarios and partition states.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>This method sets up various actions that can be triggered via specific endpoints,
|
||||||
|
/// such as toggling modes, setting room combination scenarios, and managing partition states. It also
|
||||||
|
/// subscribes to feedback events to update the status when changes occur in room combination scenarios or
|
||||||
|
/// partition states.</remarks>
|
||||||
protected override void RegisterActions()
|
protected override void RegisterActions()
|
||||||
{
|
{
|
||||||
AddAction("/fullStatus", (id, content) => SendFullStatus());
|
AddAction("/fullStatus", (id, content) => SendFullStatus());
|
||||||
@@ -107,6 +133,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
|||||||
|
|
||||||
var message = new IEssentialsRoomCombinerStateMessage
|
var message = new IEssentialsRoomCombinerStateMessage
|
||||||
{
|
{
|
||||||
|
DisableAutoMode = _roomCombiner.DisableAutoMode,
|
||||||
IsInAutoMode = _roomCombiner.IsInAutoMode,
|
IsInAutoMode = _roomCombiner.IsInAutoMode,
|
||||||
CurrentScenario = _roomCombiner.CurrentScenario,
|
CurrentScenario = _roomCombiner.CurrentScenario,
|
||||||
Rooms = rooms,
|
Rooms = rooms,
|
||||||
@@ -132,20 +159,48 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the state message for a room combiner system, providing information about the current configuration,
|
||||||
|
/// operational mode, and associated rooms, partitions, and scenarios.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>This class is used to encapsulate the state of a room combiner system, including its current
|
||||||
|
/// mode of operation, active room combination scenario, and the list of rooms and partitions involved. It is
|
||||||
|
/// typically serialized and transmitted to communicate the state of the system.</remarks>
|
||||||
public class IEssentialsRoomCombinerStateMessage : DeviceStateMessageBase
|
public class IEssentialsRoomCombinerStateMessage : DeviceStateMessageBase
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether automatic mode is disabled.
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("disableAutoMode", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
|
public bool DisableAutoMode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether the system is operating in automatic mode.
|
||||||
|
/// </summary>
|
||||||
[JsonProperty("isInAutoMode", NullValueHandling = NullValueHandling.Ignore)]
|
[JsonProperty("isInAutoMode", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
public bool IsInAutoMode { get; set; }
|
public bool IsInAutoMode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the current room combination scenario.
|
||||||
|
/// </summary>
|
||||||
[JsonProperty("currentScenario", NullValueHandling = NullValueHandling.Ignore)]
|
[JsonProperty("currentScenario", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
public IRoomCombinationScenario CurrentScenario { get; set; }
|
public IRoomCombinationScenario CurrentScenario { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the collection of rooms associated with the entity.
|
||||||
|
/// </summary>
|
||||||
[JsonProperty("rooms", NullValueHandling = NullValueHandling.Ignore)]
|
[JsonProperty("rooms", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
public List<IKeyName> Rooms { get; set; }
|
public List<IKeyName> Rooms { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the collection of room combination scenarios.
|
||||||
|
/// </summary>
|
||||||
[JsonProperty("roomCombinationScenarios", NullValueHandling = NullValueHandling.Ignore)]
|
[JsonProperty("roomCombinationScenarios", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
public List<IRoomCombinationScenario> RoomCombinationScenarios { get; set; }
|
public List<IRoomCombinationScenario> RoomCombinationScenarios { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the collection of partition controllers.
|
||||||
|
/// </summary>
|
||||||
[JsonProperty("partitions", NullValueHandling = NullValueHandling.Ignore)]
|
[JsonProperty("partitions", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
public List<IPartitionController> Partitions { get; set; }
|
public List<IPartitionController> Partitions { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user