mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-04-14 21:16:48 +00:00
chore: move all files to file-scoped namespace
This commit is contained in:
parent
aaa5b0532b
commit
3ece4f0b7b
522 changed files with 39628 additions and 45678 deletions
|
|
@ -5,41 +5,40 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
namespace PepperDash.Essentials.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Base class for items that can be added to an AudioControlList. Contains properties that are common to all items, such as the parent device key and an optional item key. Also includes properties for display purposes, such as a name and order.
|
||||
/// </summary>
|
||||
public abstract class AudioControlListItemBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for audio control list items
|
||||
/// Key of the parent device in the DeviceManager
|
||||
/// </summary>
|
||||
public abstract class AudioControlListItemBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Key of the parent device in the DeviceManager
|
||||
/// </summary>
|
||||
[JsonProperty("parentDeviceKey")]
|
||||
public string ParentDeviceKey { get; set; }
|
||||
[JsonProperty("parentDeviceKey")]
|
||||
public string ParentDeviceKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Optional key of the item in the parent device
|
||||
/// </summary>
|
||||
[JsonProperty("itemKey")]
|
||||
public string ItemKey { get; set; }
|
||||
/// <summary>
|
||||
/// Optional key of the item in the parent device
|
||||
/// </summary>
|
||||
[JsonProperty("itemKey")]
|
||||
public string ItemKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A name that will override the items's name on the UI
|
||||
/// </summary>
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
/// <summary>
|
||||
/// A name that will override the items's name on the UI
|
||||
/// </summary>
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if the item should be included in the user accessible list
|
||||
/// </summary>
|
||||
[JsonProperty("includeInUserList")]
|
||||
public bool IncludeInUserList { get; set; }
|
||||
/// <summary>
|
||||
/// Indicates if the item should be included in the user accessible list
|
||||
/// </summary>
|
||||
[JsonProperty("includeInUserList")]
|
||||
public bool IncludeInUserList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Used to specify the order of the items in the source list when displayed
|
||||
/// </summary>
|
||||
[JsonProperty("order")]
|
||||
public int Order { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Used to specify the order of the items in the source list when displayed
|
||||
/// </summary>
|
||||
[JsonProperty("order")]
|
||||
public int Order { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ using Crestron.SimplSharp;
|
|||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
namespace PepperDash.Essentials.Core;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Enumeration of AudioChangeType values
|
||||
|
|
@ -50,5 +50,4 @@ namespace PepperDash.Essentials.Core
|
|||
ChangeType = changeType;
|
||||
AudioDevice = device;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,82 +1,82 @@
|
|||
using Newtonsoft.Json;
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
namespace PepperDash.Essentials.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an item in a camera list, which can be used to display camera sources in a user interface. Contains properties for the device key, preferred name, icon, and order of the item in the list. Also includes a property to get the associated camera device from the DeviceManager based on the device key.
|
||||
/// </summary>
|
||||
public class CameraListItem
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Represents a CameraListItem
|
||||
/// Key of the camera device in the DeviceManager
|
||||
/// </summary>
|
||||
public class CameraListItem
|
||||
[JsonProperty("deviceKey")]
|
||||
public string DeviceKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the source Device for this, if it exists in DeviceManager
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public Device CameraDevice
|
||||
{
|
||||
/// <summary>
|
||||
/// Key of the camera device
|
||||
/// </summary>
|
||||
[JsonProperty("deviceKey")]
|
||||
public string DeviceKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the source Device for this, if it exists in DeviceManager
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public Device CameraDevice
|
||||
get
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_cameraDevice == null)
|
||||
_cameraDevice = DeviceManager.GetDeviceForKey(DeviceKey) as Device;
|
||||
return _cameraDevice;
|
||||
}
|
||||
if (_cameraDevice == null)
|
||||
_cameraDevice = DeviceManager.GetDeviceForKey(DeviceKey) as Device;
|
||||
return _cameraDevice;
|
||||
}
|
||||
Device _cameraDevice;
|
||||
|
||||
/// <summary>
|
||||
/// Gets either the source's Name or this AlternateName property, if
|
||||
/// defined. If source doesn't exist, returns "Missing source"
|
||||
/// </summary>
|
||||
[JsonProperty("preferredName")]
|
||||
public string PreferredName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(Name))
|
||||
{
|
||||
if (CameraDevice == null)
|
||||
return "---";
|
||||
return CameraDevice.Name;
|
||||
}
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A name that will override the source's name on the UI
|
||||
/// </summary>
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Specifies and icon for the source list item
|
||||
/// </summary>
|
||||
[JsonProperty("icon")]
|
||||
public string Icon { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Alternate icon
|
||||
/// </summary>
|
||||
[JsonProperty("altIcon", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public string AltIcon { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if the item should be included in the user facing list
|
||||
/// </summary>
|
||||
[JsonProperty("includeInUserList")]
|
||||
public bool IncludeInUserList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Used to specify the order of the items in the source list when displayed
|
||||
/// </summary>
|
||||
[JsonProperty("order")]
|
||||
public int Order { get; set; }
|
||||
}
|
||||
Device _cameraDevice;
|
||||
|
||||
/// <summary>
|
||||
/// Gets either the source's Name or this AlternateName property, if
|
||||
/// defined. If source doesn't exist, returns "Missing source"
|
||||
/// </summary>
|
||||
[JsonProperty("preferredName")]
|
||||
public string PreferredName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(Name))
|
||||
{
|
||||
if (CameraDevice == null)
|
||||
return "---";
|
||||
return CameraDevice.Name;
|
||||
}
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A name that will override the source's name on the UI
|
||||
/// </summary>
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Specifies and icon for the source list item
|
||||
/// </summary>
|
||||
[JsonProperty("icon")]
|
||||
public string Icon { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Alternate icon
|
||||
/// </summary>
|
||||
[JsonProperty("altIcon", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public string AltIcon { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if the item should be included in the user facing list
|
||||
/// </summary>
|
||||
[JsonProperty("includeInUserList")]
|
||||
public bool IncludeInUserList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Used to specify the order of the items in the source list when displayed
|
||||
/// </summary>
|
||||
[JsonProperty("order")]
|
||||
public int Order { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,107 +4,106 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
namespace PepperDash.Essentials.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Adds control of codec receive volume
|
||||
/// </summary>
|
||||
public interface IReceiveVolume
|
||||
{
|
||||
// Break this out into 3 interfaces
|
||||
|
||||
/// <summary>
|
||||
/// Sets the receive volume level
|
||||
/// </summary>
|
||||
/// <param name="level">volume level to set</param>
|
||||
void SetReceiveVolume(ushort level);
|
||||
|
||||
/// <summary>
|
||||
/// Mutes the receive audio
|
||||
/// </summary>
|
||||
void ReceiveMuteOn();
|
||||
|
||||
/// <summary>
|
||||
/// Unmutes the receive audio
|
||||
/// </summary>
|
||||
void ReceiveMuteOff();
|
||||
|
||||
/// <summary>
|
||||
/// Toggles the receive mute state
|
||||
/// </summary>
|
||||
void ReceiveMuteToggle();
|
||||
|
||||
/// <summary>
|
||||
/// Feedback for the receive volume level
|
||||
/// </summary>
|
||||
IntFeedback ReceiveLevelFeedback { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Feedback for the receive mute state
|
||||
/// </summary>
|
||||
BoolFeedback ReceiveMuteIsOnFeedback { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the contract for ITransmitVolume
|
||||
/// </summary>
|
||||
public interface ITransmitVolume
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds control of codec receive volume
|
||||
/// Sets the transmit volume level
|
||||
/// </summary>
|
||||
public interface IReceiveVolume
|
||||
{
|
||||
// Break this out into 3 interfaces
|
||||
|
||||
/// <summary>
|
||||
/// Sets the receive volume level
|
||||
/// </summary>
|
||||
/// <param name="level">volume level to set</param>
|
||||
void SetReceiveVolume(ushort level);
|
||||
|
||||
/// <summary>
|
||||
/// Mutes the receive audio
|
||||
/// </summary>
|
||||
void ReceiveMuteOn();
|
||||
|
||||
/// <summary>
|
||||
/// Unmutes the receive audio
|
||||
/// </summary>
|
||||
void ReceiveMuteOff();
|
||||
|
||||
/// <summary>
|
||||
/// Toggles the receive mute state
|
||||
/// </summary>
|
||||
void ReceiveMuteToggle();
|
||||
|
||||
/// <summary>
|
||||
/// Feedback for the receive volume level
|
||||
/// </summary>
|
||||
IntFeedback ReceiveLevelFeedback { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Feedback for the receive mute state
|
||||
/// </summary>
|
||||
BoolFeedback ReceiveMuteIsOnFeedback { get; }
|
||||
}
|
||||
/// <param name="level">volume level to set</param>
|
||||
void SetTransmitVolume(ushort level);
|
||||
|
||||
/// <summary>
|
||||
/// Defines the contract for ITransmitVolume
|
||||
/// Mutes the transmit audio
|
||||
/// </summary>
|
||||
public interface ITransmitVolume
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets the transmit volume level
|
||||
/// </summary>
|
||||
/// <param name="level">volume level to set</param>
|
||||
void SetTransmitVolume(ushort level);
|
||||
|
||||
/// <summary>
|
||||
/// Mutes the transmit audio
|
||||
/// </summary>
|
||||
void TransmitMuteOn();
|
||||
|
||||
/// <summary>
|
||||
/// Unmutes the transmit audio
|
||||
/// </summary>
|
||||
void TransmitMuteOff();
|
||||
|
||||
/// <summary>
|
||||
/// Toggles the transmit mute state
|
||||
/// </summary>
|
||||
void TransmitMuteToggle();
|
||||
|
||||
/// <summary>
|
||||
/// Feedback for the transmit volume level
|
||||
/// </summary>
|
||||
IntFeedback TransmitLevelFeedback { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Feedback for the transmit mute state
|
||||
/// </summary>
|
||||
BoolFeedback TransmitMuteIsOnFeedback { get; }
|
||||
}
|
||||
void TransmitMuteOn();
|
||||
|
||||
/// <summary>
|
||||
/// Defines the contract for IPrivacy
|
||||
/// Unmutes the transmit audio
|
||||
/// </summary>
|
||||
public interface IPrivacy
|
||||
{
|
||||
/// <summary>
|
||||
/// Enables privacy mode
|
||||
/// </summary>
|
||||
void PrivacyModeOn();
|
||||
void TransmitMuteOff();
|
||||
|
||||
/// <summary>
|
||||
/// Disables privacy mode
|
||||
/// </summary>
|
||||
void PrivacyModeOff();
|
||||
/// <summary>
|
||||
/// Toggles the transmit mute state
|
||||
/// </summary>
|
||||
void TransmitMuteToggle();
|
||||
|
||||
/// <summary>
|
||||
/// Toggles privacy mode
|
||||
/// </summary>
|
||||
void PrivacyModeToggle();
|
||||
/// <summary>
|
||||
/// Feedback for the transmit volume level
|
||||
/// </summary>
|
||||
IntFeedback TransmitLevelFeedback { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Feedback for the privacy mode state
|
||||
/// </summary>
|
||||
BoolFeedback PrivacyModeIsOnFeedback { get; }
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Feedback for the transmit mute state
|
||||
/// </summary>
|
||||
BoolFeedback TransmitMuteIsOnFeedback { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the contract for IPrivacy
|
||||
/// </summary>
|
||||
public interface IPrivacy
|
||||
{
|
||||
/// <summary>
|
||||
/// Enables privacy mode
|
||||
/// </summary>
|
||||
void PrivacyModeOn();
|
||||
|
||||
/// <summary>
|
||||
/// Disables privacy mode
|
||||
/// </summary>
|
||||
void PrivacyModeOff();
|
||||
|
||||
/// <summary>
|
||||
/// Toggles privacy mode
|
||||
/// </summary>
|
||||
void PrivacyModeToggle();
|
||||
|
||||
/// <summary>
|
||||
/// Feedback for the privacy mode state
|
||||
/// </summary>
|
||||
BoolFeedback PrivacyModeIsOnFeedback { get; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,56 +8,45 @@ using PepperDash.Core;
|
|||
using PepperDash.Essentials.Core.CrestronIO;
|
||||
using Serilog.Events;
|
||||
|
||||
namespace PepperDash.Essentials.Core.Devices
|
||||
namespace PepperDash.Essentials.Core.Devices;
|
||||
|
||||
/// <summary>
|
||||
/// This wrapper class is meant to allow interfaces to be applied to any Crestron processor
|
||||
/// </summary>
|
||||
public class CrestronProcessor : Device, ISwitchedOutputCollection
|
||||
{
|
||||
/// <summary>
|
||||
/// This wrapper class is meant to allow interfaces to be applied to any Crestron processor
|
||||
/// </summary>
|
||||
public class CrestronProcessor : Device, ISwitchedOutputCollection
|
||||
public Dictionary<uint, ISwitchedOutput> SwitchedOutputs { get; private set; }
|
||||
|
||||
public Crestron.SimplSharpPro.CrestronControlSystem Processor { get; private set; }
|
||||
|
||||
public CrestronProcessor(string key)
|
||||
: base(key)
|
||||
{
|
||||
/// <summary>
|
||||
/// Collection of switched outputs (relays) on the processor
|
||||
/// </summary>
|
||||
public Dictionary<uint, ISwitchedOutput> SwitchedOutputs { get; private set; }
|
||||
SwitchedOutputs = new Dictionary<uint, ISwitchedOutput>();
|
||||
Processor = Global.ControlSystem;
|
||||
|
||||
/// <summary>
|
||||
/// The underlying CrestronControlSystem processor
|
||||
/// </summary>
|
||||
public Crestron.SimplSharpPro.CrestronControlSystem Processor { get; private set; }
|
||||
GetRelays();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="key">key for the processor</param>
|
||||
public CrestronProcessor(string key)
|
||||
: base(key)
|
||||
/// <summary>
|
||||
/// Creates a GenericRelayDevice for each relay on the processor and adds them to the SwitchedOutputs collection
|
||||
/// </summary>
|
||||
void GetRelays()
|
||||
{
|
||||
try
|
||||
{
|
||||
SwitchedOutputs = new Dictionary<uint, ISwitchedOutput>();
|
||||
Processor = Global.ControlSystem;
|
||||
|
||||
GetRelays();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a GenericRelayDevice for each relay on the processor and adds them to the SwitchedOutputs collection
|
||||
/// </summary>
|
||||
void GetRelays()
|
||||
{
|
||||
try
|
||||
if (Processor.SupportsRelay)
|
||||
{
|
||||
if (Processor.SupportsRelay)
|
||||
for (uint i = 1; i <= Processor.NumberOfRelayPorts; i++)
|
||||
{
|
||||
for (uint i = 1; i <= Processor.NumberOfRelayPorts; i++)
|
||||
{
|
||||
var relay = new GenericRelayDevice(string.Format("{0}-relay-{1}", this.Key, i), Processor.RelayPorts[i]);
|
||||
SwitchedOutputs.Add(i, relay);
|
||||
}
|
||||
var relay = new GenericRelayDevice(string.Format("{0}-relay-{1}", this.Key, i), Processor.RelayPorts[i]);
|
||||
SwitchedOutputs.Add(i, relay);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, "Error Getting Relays from processor:\n '{0}'", e);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, "Error Getting Relays from processor:\n '{0}'", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,122 +3,123 @@
|
|||
using Newtonsoft.Json;
|
||||
using PepperDash.Essentials.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
namespace PepperDash.Essentials.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a destination item in a routing system that can receive audio/video signals.
|
||||
/// Contains information about the destination device, its properties, and location settings.
|
||||
/// </summary>
|
||||
public class DestinationListItem
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Represents a destination item in a routing system that can receive audio/video signals.
|
||||
/// Contains information about the destination device, its properties, and location settings.
|
||||
/// Gets or sets the key identifier for the sink device that this destination represents.
|
||||
/// </summary>
|
||||
public class DestinationListItem
|
||||
[JsonProperty("sinkKey")]
|
||||
public string SinkKey { get; set; }
|
||||
|
||||
private EssentialsDevice _sinkDevice;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the actual device instance for this destination.
|
||||
/// Lazily loads the device from the DeviceManager using the SinkKey.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public EssentialsDevice SinkDevice
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the key identifier for the sink device that this destination represents.
|
||||
/// </summary>
|
||||
[JsonProperty("sinkKey")]
|
||||
public string SinkKey { get; set; }
|
||||
|
||||
private EssentialsDevice _sinkDevice;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the actual device instance for this destination.
|
||||
/// Lazily loads the device from the DeviceManager using the SinkKey.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public EssentialsDevice SinkDevice
|
||||
{
|
||||
get { return _sinkDevice ?? (_sinkDevice = DeviceManager.GetDeviceForKey(SinkKey) as EssentialsDevice); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the preferred display name for this destination.
|
||||
/// Returns the custom Name if set, otherwise returns the SinkDevice name, or "---" if no device is found.
|
||||
/// </summary>
|
||||
[JsonProperty("preferredName")]
|
||||
public string PreferredName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Name))
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
return SinkDevice == null ? "---" : SinkDevice.Name;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the custom name for this destination.
|
||||
/// If set, this name will be used as the PreferredName instead of the device name.
|
||||
/// </summary>
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this destination should be included in destination lists.
|
||||
/// </summary>
|
||||
[JsonProperty("includeInDestinationList")]
|
||||
public bool IncludeInDestinationList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the display order for this destination in lists.
|
||||
/// Lower values appear first in sorted lists.
|
||||
/// </summary>
|
||||
[JsonProperty("order")]
|
||||
public int Order { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the surface location identifier for this destination.
|
||||
/// Used to specify which surface or screen this destination is located on.
|
||||
/// </summary>
|
||||
[JsonProperty("surfaceLocation")]
|
||||
public int SurfaceLocation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the vertical location position for this destination.
|
||||
/// Used for spatial positioning in multi-display configurations.
|
||||
/// </summary>
|
||||
[JsonProperty("verticalLocation")]
|
||||
public int VerticalLocation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the horizontal location position for this destination.
|
||||
/// Used for spatial positioning in multi-display configurations.
|
||||
/// </summary>
|
||||
[JsonProperty("horizontalLocation")]
|
||||
public int HorizontalLocation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the signal type that this destination can receive (Audio, Video, AudioVideo, etc.).
|
||||
/// </summary>
|
||||
[JsonProperty("sinkType")]
|
||||
public eRoutingSignalType SinkType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this destination is used for codec content sharing.
|
||||
/// </summary>
|
||||
[JsonProperty("isCodecContentDestination")]
|
||||
public bool isCodecContentDestination { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this destination is used for program audio output.
|
||||
/// </summary>
|
||||
[JsonProperty("isProgramAudioDestination")]
|
||||
public bool isProgramAudioDestination { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this destination supports USB connections.
|
||||
/// Indicates if the destination can handle USB functionality, such as USB signal routing or device connections.
|
||||
/// This property is used to determine compatibility with USB-based devices or systems.
|
||||
/// </summary>
|
||||
[JsonProperty("supportsUsb")]
|
||||
public bool SupportsUsb { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The key of the destination port associated with this destination item
|
||||
/// This is used to identify the specific port on the destination device that this item refers to for advanced routing
|
||||
/// </summary>
|
||||
[JsonProperty("destinationPortKey")]
|
||||
public string DestinationPortKey { get; set; }
|
||||
get { return _sinkDevice ?? (_sinkDevice = DeviceManager.GetDeviceForKey(SinkKey) as EssentialsDevice); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the preferred display name for this destination.
|
||||
/// Returns the custom Name if set, otherwise returns the SinkDevice name, or "---" if no device is found.
|
||||
/// </summary>
|
||||
[JsonProperty("preferredName")]
|
||||
public string PreferredName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Name))
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
return SinkDevice == null ? "---" : SinkDevice.Name;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the custom name for this destination.
|
||||
/// If set, this name will be used as the PreferredName instead of the device name.
|
||||
/// </summary>
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this destination should be included in destination lists.
|
||||
/// </summary>
|
||||
[JsonProperty("includeInDestinationList")]
|
||||
public bool IncludeInDestinationList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the display order for this destination in lists.
|
||||
/// Lower values appear first in sorted lists.
|
||||
/// </summary>
|
||||
[JsonProperty("order")]
|
||||
public int Order { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the surface location identifier for this destination.
|
||||
/// Used to specify which surface or screen this destination is located on.
|
||||
/// </summary>
|
||||
[JsonProperty("surfaceLocation")]
|
||||
public int SurfaceLocation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the vertical location position for this destination.
|
||||
/// Used for spatial positioning in multi-display configurations.
|
||||
/// </summary>
|
||||
[JsonProperty("verticalLocation")]
|
||||
public int VerticalLocation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the horizontal location position for this destination.
|
||||
/// Used for spatial positioning in multi-display configurations.
|
||||
/// </summary>
|
||||
[JsonProperty("horizontalLocation")]
|
||||
public int HorizontalLocation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the signal type that this destination can receive (Audio, Video, AudioVideo, etc.).
|
||||
/// </summary>
|
||||
[JsonProperty("sinkType")]
|
||||
public eRoutingSignalType SinkType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this destination is used for codec content sharing.
|
||||
/// </summary>
|
||||
[JsonProperty("isCodecContentDestination")]
|
||||
public bool isCodecContentDestination { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this destination is used for program audio output.
|
||||
/// </summary>
|
||||
[JsonProperty("isProgramAudioDestination")]
|
||||
public bool isProgramAudioDestination { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this destination supports USB connections.
|
||||
/// Indicates if the destination can handle USB functionality, such as USB signal routing or device connections.
|
||||
/// This property is used to determine compatibility with USB-based devices or systems.
|
||||
/// </summary>
|
||||
[JsonProperty("supportsUsb")]
|
||||
public bool SupportsUsb { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The key of the destination port associated with this destination item
|
||||
/// This is used to identify the specific port on the destination device that this item refers to for advanced routing
|
||||
/// </summary>
|
||||
[JsonProperty("destinationPortKey")]
|
||||
public string DestinationPortKey { get; set; }
|
||||
|
||||
}
|
||||
|
|
@ -4,21 +4,20 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
namespace PepperDash.Essentials.Core.Devices
|
||||
namespace PepperDash.Essentials.Core.Devices;
|
||||
|
||||
/// <summary>
|
||||
/// Base class for all Device APIs
|
||||
/// </summary>
|
||||
public abstract class DeviceApiBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for all Device APIs
|
||||
/// Action API dictionary
|
||||
/// </summary>
|
||||
public abstract class DeviceApiBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Action API dictionary
|
||||
/// </summary>
|
||||
public Dictionary<string, Object> ActionApi { get; protected set; }
|
||||
public Dictionary<string, Object> ActionApi { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Feedback API dictionary
|
||||
/// </summary>
|
||||
public Dictionary<string, Feedback> FeedbackApi { get; protected set; }
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Feedback API dictionary
|
||||
/// </summary>
|
||||
public Dictionary<string, Feedback> FeedbackApi { get; protected set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,30 +6,29 @@ using Crestron.SimplSharp;
|
|||
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
namespace PepperDash.Essentials.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for working with device feedback properties.
|
||||
/// </summary>
|
||||
public static class DeviceFeedbackExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// DeviceFeedbackExtensions class
|
||||
/// Attempts to get and return a feedback property from a device by name.
|
||||
/// If unsuccessful, returns null.
|
||||
/// </summary>
|
||||
public static class DeviceFeedbackExtensions
|
||||
/// <param name="device"></param>
|
||||
/// <param name="propertyName"></param>
|
||||
/// <returns></returns>
|
||||
public static Feedback GetFeedbackProperty(this Device device, string propertyName)
|
||||
{
|
||||
/// <summary>
|
||||
/// Attempts to get and return a feedback property from a device by name.
|
||||
/// If unsuccessful, returns null.
|
||||
/// </summary>
|
||||
/// <param name="device">device to get feedback from</param>
|
||||
/// <param name="propertyName">name of the feedback property</param>
|
||||
/// <returns>Feedback property if found, otherwise null</returns>
|
||||
public static Feedback GetFeedbackProperty(this Device device, string propertyName)
|
||||
var feedback = DeviceJsonApi.GetPropertyByName(device.Key, propertyName) as Feedback;
|
||||
|
||||
if (feedback != null)
|
||||
{
|
||||
var feedback = DeviceJsonApi.GetPropertyByName(device.Key, propertyName) as Feedback;
|
||||
|
||||
if (feedback != null)
|
||||
{
|
||||
return feedback;
|
||||
}
|
||||
|
||||
return null;
|
||||
return feedback;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -4,8 +4,8 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
namespace PepperDash.Essentials.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Integers that represent the "source type number" for given sources.
|
||||
/// Primarily used by the UI to calculate subpage join offsets
|
||||
|
|
@ -62,5 +62,4 @@ namespace PepperDash.Essentials.Core
|
|||
/// TypeNoControls constant
|
||||
/// </summary>
|
||||
public const uint TypeNoControls = 49;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,31 +1,17 @@
|
|||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
using PepperDash.Essentials.Core.Bridges;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
namespace PepperDash.Essentials.Core;
|
||||
|
||||
public abstract class EssentialsBridgeableDevice:EssentialsDevice, IBridgeAdvanced
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for devices that can be bridged to an EISC API.
|
||||
/// </summary>
|
||||
public abstract class EssentialsBridgeableDevice : EssentialsDevice, IBridgeAdvanced
|
||||
protected EssentialsBridgeableDevice(string key) : base(key)
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="EssentialsBridgeableDevice"/> class with the specified key.
|
||||
/// </summary>
|
||||
/// <param name="key">The unique key for the device.</param>
|
||||
protected EssentialsBridgeableDevice(string key) : base(key)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="EssentialsBridgeableDevice"/> class with the specified key and name.
|
||||
/// </summary>
|
||||
/// <param name="key">The unique key for the device.</param>
|
||||
/// <param name="name">The display name for the device.</param>
|
||||
protected EssentialsBridgeableDevice(string key, string name) : base(key, name)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge);
|
||||
}
|
||||
|
||||
protected EssentialsBridgeableDevice(string key, string name) : base(key, name)
|
||||
{
|
||||
}
|
||||
|
||||
public abstract void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge);
|
||||
}
|
||||
|
|
@ -5,185 +5,225 @@ using PepperDash.Core;
|
|||
using PepperDash.Essentials.Core.Config;
|
||||
using Serilog.Events;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
namespace PepperDash.Essentials.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the basic needs for an EssentialsDevice to enable it to be build by an IDeviceFactory class
|
||||
/// </summary>
|
||||
[Description("The base Essentials Device Class")]
|
||||
public abstract class EssentialsDevice : Device
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the basic needs for an EssentialsDevice to enable it to be build by an IDeviceFactory class
|
||||
/// Event that fires when the device has completed initialization. This is useful for any setup that needs to occur after all devices have been activated.
|
||||
/// </summary>
|
||||
[Description("The base Essentials Device Class")]
|
||||
public abstract class EssentialsDevice : Device
|
||||
public event EventHandler Initialized;
|
||||
|
||||
private bool _isInitialized;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the device has completed initialization. Initialization occurs after all devices have been activated, and is triggered by the DeviceManager.AllDevicesActivated event. This property can be used to determine when it is safe to perform actions that require all devices to be active.
|
||||
/// </summary>
|
||||
public bool IsInitialized
|
||||
{
|
||||
/// <summary>
|
||||
/// Event raised when the device is initialized.
|
||||
/// </summary>
|
||||
public event EventHandler Initialized;
|
||||
|
||||
private bool _isInitialized;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the device is initialized.
|
||||
/// </summary>
|
||||
public bool IsInitialized
|
||||
get { return _isInitialized; }
|
||||
private set
|
||||
{
|
||||
get { return _isInitialized; }
|
||||
private set
|
||||
if (_isInitialized == value) return;
|
||||
|
||||
_isInitialized = value;
|
||||
|
||||
if (_isInitialized)
|
||||
{
|
||||
if (_isInitialized == value) return;
|
||||
|
||||
_isInitialized = value;
|
||||
|
||||
if (_isInitialized)
|
||||
{
|
||||
Initialized?.Invoke(this, new EventArgs());
|
||||
}
|
||||
Initialized?.Invoke(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the EssentialsDevice class.
|
||||
/// </summary>
|
||||
/// <param name="key">The unique identifier for the device.</param>
|
||||
protected EssentialsDevice(string key)
|
||||
: base(key)
|
||||
{
|
||||
SubscribeToActivateComplete();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the EssentialsDevice class.
|
||||
/// </summary>
|
||||
/// <param name="key">The unique identifier for the device.</param>
|
||||
/// <param name="name">The name of the device.</param>
|
||||
protected EssentialsDevice(string key, string name)
|
||||
: base(key, name)
|
||||
{
|
||||
SubscribeToActivateComplete();
|
||||
}
|
||||
|
||||
private void SubscribeToActivateComplete()
|
||||
{
|
||||
DeviceManager.AllDevicesActivated += DeviceManagerOnAllDevicesActivated;
|
||||
}
|
||||
|
||||
private void DeviceManagerOnAllDevicesActivated(object sender, EventArgs eventArgs)
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Initialize();
|
||||
|
||||
IsInitialized = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Error, this, "Exception initializing device: {0}", ex.Message);
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, "Stack Trace: {0}", ex.StackTrace);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// CustomActivate method
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
public override bool CustomActivate()
|
||||
{
|
||||
CreateMobileControlMessengers();
|
||||
|
||||
return base.CustomActivate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override this method to build and create custom Mobile Control Messengers during the Activation phase
|
||||
/// </summary>
|
||||
protected virtual void CreateMobileControlMessengers()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = true)]
|
||||
public class DescriptionAttribute : Attribute
|
||||
{
|
||||
private string _Description;
|
||||
|
||||
public DescriptionAttribute(string description)
|
||||
{
|
||||
//Debug.LogMessage(LogEventLevel.Verbose, "Setting Description: {0}", description);
|
||||
_Description = description;
|
||||
}
|
||||
|
||||
public string Description
|
||||
{
|
||||
get { return _Description; }
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = true)]
|
||||
public class ConfigSnippetAttribute : Attribute
|
||||
{
|
||||
private string _ConfigSnippet;
|
||||
|
||||
public ConfigSnippetAttribute(string configSnippet)
|
||||
{
|
||||
//Debug.LogMessage(LogEventLevel.Verbose, "Setting Config Snippet {0}", configSnippet);
|
||||
_ConfigSnippet = configSnippet;
|
||||
}
|
||||
|
||||
public string ConfigSnippet
|
||||
{
|
||||
get { return _ConfigSnippet; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a factory for creating processor extension devices.
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the processor extension device.</typeparam>
|
||||
public abstract class ProcessorExtensionDeviceFactory<T> : IProcessorExtensionDeviceFactory where T : EssentialsDevice
|
||||
/// <param name="key"></param>
|
||||
protected EssentialsDevice(string key)
|
||||
: base(key)
|
||||
{
|
||||
#region IProcessorExtensionDeviceFactory Members
|
||||
|
||||
/// <summary>
|
||||
/// A list of strings that can be used in the type property of a DeviceConfig object to build an instance of this device
|
||||
/// </summary>
|
||||
public List<string> TypeNames { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Loads an item to the ProcessorExtensionDeviceFactory.ProcessorExtensionFactoryMethods dictionary for each entry in the TypeNames list
|
||||
/// </summary>
|
||||
public void LoadFactories()
|
||||
{
|
||||
foreach (var typeName in TypeNames)
|
||||
{
|
||||
//Debug.LogMessage(LogEventLevel.Verbose, "Getting Description Attribute from class: '{0}'", typeof(T).FullName);
|
||||
var descriptionAttribute = typeof(T).GetCustomAttributes(typeof(DescriptionAttribute), true) as DescriptionAttribute[];
|
||||
string description = descriptionAttribute[0].Description;
|
||||
var snippetAttribute = typeof(T).GetCustomAttributes(typeof(ConfigSnippetAttribute), true) as ConfigSnippetAttribute[];
|
||||
ProcessorExtensionDeviceFactory.AddFactoryForType(typeName.ToLower(), description, typeof(T), BuildDevice);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The method that will build the device
|
||||
/// </summary>
|
||||
/// <param name="dc">The device config</param>
|
||||
/// <returns>An instance of the device</returns>
|
||||
public abstract EssentialsDevice BuildDevice(DeviceConfig dc);
|
||||
|
||||
#endregion
|
||||
|
||||
SubscribeToActivateComplete();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Devices the basic needs for a Device Factory
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public abstract class EssentialsPluginDeviceFactory<T> : EssentialsDeviceFactory<T>, IPluginDeviceFactory where T : EssentialsDevice
|
||||
/// <param name="key"></param>
|
||||
/// <param name="name"></param>
|
||||
protected EssentialsDevice(string key, string name)
|
||||
: base(key, name)
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the minimum version of Essentials required for a plugin to run. Must use the format Major.Minor.Build (ex. "1.4.33")
|
||||
/// </summary>
|
||||
public string MinimumEssentialsFrameworkVersion { get; protected set; }
|
||||
SubscribeToActivateComplete();
|
||||
}
|
||||
|
||||
private void SubscribeToActivateComplete()
|
||||
{
|
||||
DeviceManager.AllDevicesActivated += DeviceManagerOnAllDevicesActivated;
|
||||
}
|
||||
|
||||
private void DeviceManagerOnAllDevicesActivated(object sender, EventArgs eventArgs)
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Initialize();
|
||||
|
||||
IsInitialized = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Error, this, "Exception initializing device: {0}", ex.Message);
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, "Stack Trace: {0}", ex.StackTrace);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override this method to perform any initialization that requires all devices to be activated. This method is called automatically after the DeviceManager.AllDevicesActivated event is fired, and should not be called directly.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override bool CustomActivate()
|
||||
{
|
||||
CreateMobileControlMessengers();
|
||||
|
||||
return base.CustomActivate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override this method to build and create custom Mobile Control Messengers during the Activation phase
|
||||
/// </summary>
|
||||
protected virtual void CreateMobileControlMessengers()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides a description for a device that can be used in the UI and other areas where a human-readable description of the device is needed.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = true)]
|
||||
public class DescriptionAttribute : Attribute
|
||||
{
|
||||
private string _Description;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="description"></param>
|
||||
public DescriptionAttribute(string description)
|
||||
{
|
||||
//Debug.LogMessage(LogEventLevel.Verbose, "Setting Description: {0}", description);
|
||||
_Description = description;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the description of the device
|
||||
/// </summary>
|
||||
public string Description
|
||||
{
|
||||
get { return _Description; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides a configuration snippet for a device that can be used in the UI and other areas where a sample configuration of the device is needed. This is especially useful for plugin developers to provide users with an example of how to configure their device.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = true)]
|
||||
public class ConfigSnippetAttribute : Attribute
|
||||
{
|
||||
private string _ConfigSnippet;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="configSnippet"></param>
|
||||
public ConfigSnippetAttribute(string configSnippet)
|
||||
{
|
||||
//Debug.LogMessage(LogEventLevel.Verbose, "Setting Config Snippet {0}", configSnippet);
|
||||
_ConfigSnippet = configSnippet;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the configuration snippet for the device
|
||||
/// </summary>
|
||||
public string ConfigSnippet
|
||||
{
|
||||
get { return _ConfigSnippet; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides a base class for creating device factories specifically designed for processor extension development in the Essentials framework. This class implements the IProcessorExtensionDeviceFactory interface and provides a structure for defining type names and building devices based on a DeviceConfig object.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of device that this factory creates. Must derive from <see cref="EssentialsDevice"/>.</typeparam>
|
||||
public abstract class ProcessorExtensionDeviceFactory<T> : IProcessorExtensionDeviceFactory where T : EssentialsDevice
|
||||
{
|
||||
#region IProcessorExtensionDeviceFactory Members
|
||||
|
||||
/// <summary>
|
||||
/// A list of strings that can be used in the type property of a DeviceConfig object to build an instance of this device
|
||||
/// </summary>
|
||||
public List<string> TypeNames { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Loads an item to the ProcessorExtensionDeviceFactory.ProcessorExtensionFactoryMethods dictionary for each entry in the TypeNames list
|
||||
/// </summary>
|
||||
public void LoadFactories()
|
||||
{
|
||||
foreach (var typeName in TypeNames)
|
||||
{
|
||||
//Debug.LogMessage(LogEventLevel.Verbose, "Getting Description Attribute from class: '{0}'", typeof(T).FullName);
|
||||
var descriptionAttribute = typeof(T).GetCustomAttributes(typeof(DescriptionAttribute), true) as DescriptionAttribute[];
|
||||
string description = descriptionAttribute[0].Description;
|
||||
var snippetAttribute = typeof(T).GetCustomAttributes(typeof(ConfigSnippetAttribute), true) as ConfigSnippetAttribute[];
|
||||
ProcessorExtensionDeviceFactory.AddFactoryForType(typeName.ToLower(), description, typeof(T), BuildDevice);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The method that will build the device
|
||||
/// </summary>
|
||||
/// <param name="dc">The device config</param>
|
||||
/// <returns>An instance of the device</returns>
|
||||
public abstract EssentialsDevice BuildDevice(DeviceConfig dc);
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Devices the basic needs for a Device Factory
|
||||
/// </summary>
|
||||
public abstract class EssentialsPluginDeviceFactory<T> : EssentialsDeviceFactory<T>, IPluginDeviceFactory where T : EssentialsDevice
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the minimum version of Essentials required for a plugin to run. Must use the format Major.Minor.Build (ex. "1.4.33")
|
||||
/// </summary>
|
||||
public string MinimumEssentialsFrameworkVersion { get; protected set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides a base class for creating device factories specifically designed for plugin development in the Essentials
|
||||
/// framework.
|
||||
/// </summary>
|
||||
/// <remarks>This class is intended to be used by developers creating plugins for the Essentials framework. It
|
||||
/// includes properties to specify the minimum required Essentials framework version and to track framework versions
|
||||
/// used during development.</remarks>
|
||||
/// <typeparam name="T">The type of device that this factory creates. Must derive from <see cref="EssentialsDevice"/>.</typeparam>
|
||||
public abstract class EssentialsPluginDevelopmentDeviceFactory<T> : EssentialsDeviceFactory<T>, IPluginDevelopmentDeviceFactory where T : EssentialsDevice
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the minimum version of Essentials required for a plugin to run. Must use the format Major.Minor.Build (ex. "1.4.33")
|
||||
/// </summary>
|
||||
public string MinimumEssentialsFrameworkVersion { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// A list of Essentials framework versions that were used during the development of the plugin. This can be used to track which versions of the framework the plugin is compatible with, and can be helpful for users when determining whether a plugin will work with their current version of the Essentials framework.
|
||||
/// </summary>
|
||||
public List<string> DevelopmentEssentialsFrameworkVersions { get; protected set; }
|
||||
}
|
||||
|
|
@ -2,31 +2,29 @@
|
|||
using System.Collections.Generic;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
namespace PepperDash.Essentials.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Devices the basic needs for a Device Factory
|
||||
/// </summary>
|
||||
public abstract class EssentialsDeviceFactory<T> : IDeviceFactory where T:EssentialsDevice
|
||||
{
|
||||
#region IDeviceFactory Members
|
||||
|
||||
/// <inheritdoc />
|
||||
public Type FactoryType => typeof(T);
|
||||
|
||||
/// <summary>
|
||||
/// Devices the basic needs for a Device Factory
|
||||
/// A list of strings that can be used in the type property of a DeviceConfig object to build an instance of this device
|
||||
/// </summary>
|
||||
public abstract class EssentialsDeviceFactory<T> : IDeviceFactory where T:EssentialsDevice
|
||||
{
|
||||
#region IDeviceFactory Members
|
||||
public List<string> TypeNames { get; protected set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public Type FactoryType => typeof(T);
|
||||
|
||||
/// <summary>
|
||||
/// A list of strings that can be used in the type property of a DeviceConfig object to build an instance of this device
|
||||
/// </summary>
|
||||
public List<string> TypeNames { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// The method that will build the device
|
||||
/// </summary>
|
||||
/// <param name="dc">The device config</param>
|
||||
/// <returns>An instance of the device</returns>
|
||||
public abstract EssentialsDevice BuildDevice(DeviceConfig dc);
|
||||
|
||||
#endregion
|
||||
}
|
||||
/// <summary>
|
||||
/// The method that will build the device
|
||||
/// </summary>
|
||||
/// <param name="dc">The device config</param>
|
||||
/// <returns>An instance of the device</returns>
|
||||
public abstract EssentialsDevice BuildDevice(DeviceConfig dc);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
@ -11,84 +11,68 @@ using PepperDash.Essentials.Core.Config;
|
|||
using PepperDash.Essentials.Core.Bridges.JoinMaps;
|
||||
using Serilog.Events;
|
||||
|
||||
namespace PepperDash.Essentials.Core.Devices
|
||||
namespace PepperDash.Essentials.Core.Devices;
|
||||
|
||||
public class GenericIrController: EssentialsBridgeableDevice
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a GenericIrController
|
||||
/// </summary>
|
||||
public class GenericIrController: EssentialsBridgeableDevice
|
||||
//data storage for bridging
|
||||
private BasicTriList _trilist;
|
||||
private uint _joinStart;
|
||||
private string _joinMapKey;
|
||||
private EiscApiAdvanced _bridge;
|
||||
|
||||
private readonly IrOutputPortController _port;
|
||||
|
||||
public string[] IrCommands {get { return _port.IrFileCommands; }}
|
||||
|
||||
public GenericIrController(string key, string name, IrOutputPortController irPort) : base(key, name)
|
||||
{
|
||||
//data storage for bridging
|
||||
private BasicTriList _trilist;
|
||||
private uint _joinStart;
|
||||
private string _joinMapKey;
|
||||
private EiscApiAdvanced _bridge;
|
||||
|
||||
private readonly IrOutputPortController _port;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the IrCommands
|
||||
/// </summary>
|
||||
public string[] IrCommands {get { return _port.IrFileCommands; }}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="key">key for the device</param>
|
||||
/// <param name="name">name of the device</param>
|
||||
/// <param name="irPort">IR output port controller</param>
|
||||
public GenericIrController(string key, string name, IrOutputPortController irPort) : base(key, name)
|
||||
_port = irPort;
|
||||
if (_port == null)
|
||||
{
|
||||
_port = irPort;
|
||||
if (_port == null)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, this, "IR Port is null, device will not function");
|
||||
return;
|
||||
}
|
||||
DeviceManager.AddDevice(_port);
|
||||
Debug.LogMessage(LogEventLevel.Information, this, "IR Port is null, device will not function");
|
||||
return;
|
||||
}
|
||||
DeviceManager.AddDevice(_port);
|
||||
|
||||
_port.DriverLoaded.OutputChange += DriverLoadedOnOutputChange;
|
||||
_port.DriverLoaded.OutputChange += DriverLoadedOnOutputChange;
|
||||
}
|
||||
|
||||
private void DriverLoadedOnOutputChange(object sender, FeedbackEventArgs args)
|
||||
{
|
||||
if (!args.BoolValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
private void DriverLoadedOnOutputChange(object sender, FeedbackEventArgs args)
|
||||
if (_trilist == null || _bridge == null)
|
||||
{
|
||||
if (!args.BoolValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_trilist == null || _bridge == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LinkToApi(_trilist, _joinStart, _joinMapKey, _bridge);
|
||||
return;
|
||||
}
|
||||
|
||||
#region Overrides of EssentialsBridgeableDevice
|
||||
LinkToApi(_trilist, _joinStart, _joinMapKey, _bridge);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LinkToApi method
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
|
||||
#region Overrides of EssentialsBridgeableDevice
|
||||
|
||||
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
|
||||
{
|
||||
//if driver isn't loaded yet, store the variables until it is loaded, then call the LinkToApi method again
|
||||
if (!_port.DriverIsLoaded)
|
||||
{
|
||||
//if driver isn't loaded yet, store the variables until it is loaded, then call the LinkToApi method again
|
||||
if (!_port.DriverIsLoaded)
|
||||
{
|
||||
_trilist = trilist;
|
||||
_joinStart = joinStart;
|
||||
_joinMapKey = joinMapKey;
|
||||
_bridge = bridge;
|
||||
return;
|
||||
}
|
||||
_trilist = trilist;
|
||||
_joinStart = joinStart;
|
||||
_joinMapKey = joinMapKey;
|
||||
_bridge = bridge;
|
||||
return;
|
||||
}
|
||||
|
||||
var joinMap = new GenericIrControllerJoinMap(joinStart);
|
||||
var joinMap = new GenericIrControllerJoinMap(joinStart);
|
||||
|
||||
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
|
||||
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
|
||||
|
||||
if (!string.IsNullOrEmpty(joinMapSerialized))
|
||||
joinMap = JsonConvert.DeserializeObject<GenericIrControllerJoinMap>(joinMapSerialized);
|
||||
if (!string.IsNullOrEmpty(joinMapSerialized))
|
||||
joinMap = JsonConvert.DeserializeObject<GenericIrControllerJoinMap>(joinMapSerialized);
|
||||
|
||||
if (_port.UseBridgeJoinMap)
|
||||
{
|
||||
|
|
@ -150,56 +134,42 @@ namespace PepperDash.Essentials.Core.Devices
|
|||
}
|
||||
}
|
||||
|
||||
joinMap.PrintJoinMapInfo();
|
||||
joinMap.PrintJoinMapInfo();
|
||||
|
||||
if (bridge != null)
|
||||
{
|
||||
bridge.AddJoinMap(Key, joinMap);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Press method
|
||||
/// </summary>
|
||||
public void Press(string command, bool pressRelease)
|
||||
if (bridge != null)
|
||||
{
|
||||
_port.PressRelease(command, pressRelease);
|
||||
bridge.AddJoinMap(Key, joinMap);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a GenericIrControllerFactory
|
||||
/// </summary>
|
||||
public class GenericIrControllerFactory : EssentialsDeviceFactory<GenericIrController>
|
||||
#endregion
|
||||
|
||||
public void Press(string command, bool pressRelease)
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public GenericIrControllerFactory()
|
||||
{
|
||||
TypeNames = new List<string> {"genericIrController"};
|
||||
}
|
||||
#region Overrides of EssentialsDeviceFactory<GenericIRController>
|
||||
|
||||
/// <summary>
|
||||
/// BuildDevice method
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic IR Controller Device");
|
||||
|
||||
var irPort = IRPortHelper.GetIrOutputPortController(dc);
|
||||
|
||||
return new GenericIrController(dc.Key, dc.Name, irPort);
|
||||
}
|
||||
|
||||
#endregion
|
||||
_port.PressRelease(command, pressRelease);
|
||||
}
|
||||
}
|
||||
|
||||
public class GenericIrControllerFactory : EssentialsDeviceFactory<GenericIrController>
|
||||
{
|
||||
public GenericIrControllerFactory()
|
||||
{
|
||||
TypeNames = new List<string> {"genericIrController"};
|
||||
}
|
||||
#region Overrides of EssentialsDeviceFactory<GenericIRController>
|
||||
|
||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic IR Controller Device");
|
||||
|
||||
var irPort = IRPortHelper.GetIrOutputPortController(dc);
|
||||
|
||||
return new GenericIrController(dc.Key, dc.Name, irPort);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
@ -8,10 +8,10 @@ using PepperDash.Core;
|
|||
using Serilog.Events;
|
||||
|
||||
|
||||
namespace PepperDash.Essentials.Core.Devices
|
||||
{
|
||||
namespace PepperDash.Essentials.Core.Devices;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a GenericCommunicationMonitoredDevice
|
||||
/// A device that monitors the communication status of a communication client. Useful for monitoring TCP, serial, or telnet clients.
|
||||
/// </summary>
|
||||
public class GenericCommunicationMonitoredDevice : Device, ICommunicationMonitor
|
||||
{
|
||||
|
|
@ -77,5 +77,4 @@ namespace PepperDash.Essentials.Core.Devices
|
|||
CommunicationMonitor.Stop();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,42 +4,41 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
namespace PepperDash.Essentials.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for devices that can be attached to a port that provides video status information. Provides an extension method for getting that status information.
|
||||
/// </summary>
|
||||
public static class IAttachVideoStatusExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// IAttachVideoStatusExtensions class
|
||||
/// Gets the VideoStatusOutputs for the device
|
||||
/// </summary>
|
||||
public static class IAttachVideoStatusExtensions
|
||||
/// <param name="attachedDev"></param>
|
||||
/// <returns>Attached VideoStatusOutputs or the default if none attached</returns>
|
||||
public static VideoStatusOutputs GetVideoStatuses(this IAttachVideoStatus attachedDev)
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the VideoStatusOutputs for the device
|
||||
/// </summary>
|
||||
/// <param name="attachedDev"></param>
|
||||
/// <returns>Attached VideoStatusOutputs or the default if none attached</returns>
|
||||
public static VideoStatusOutputs GetVideoStatuses(this IAttachVideoStatus attachedDev)
|
||||
// See if this device is connected to a status-providing port
|
||||
var tl = TieLineCollection.Default.FirstOrDefault(t =>
|
||||
t.SourcePort.ParentDevice == attachedDev
|
||||
&& t.DestinationPort is RoutingInputPortWithVideoStatuses);
|
||||
if (tl != null)
|
||||
{
|
||||
// See if this device is connected to a status-providing port
|
||||
var tl = TieLineCollection.Default.FirstOrDefault(t =>
|
||||
t.SourcePort.ParentDevice == attachedDev
|
||||
&& t.DestinationPort is RoutingInputPortWithVideoStatuses);
|
||||
if (tl != null)
|
||||
{
|
||||
// if so, and it's got status, return it -- or null
|
||||
var port = tl.DestinationPort as RoutingInputPortWithVideoStatuses;
|
||||
if (port != null)
|
||||
return port.VideoStatus;
|
||||
}
|
||||
return VideoStatusOutputs.NoStatus;
|
||||
// if so, and it's got status, return it -- or null
|
||||
var port = tl.DestinationPort as RoutingInputPortWithVideoStatuses;
|
||||
if (port != null)
|
||||
return port.VideoStatus;
|
||||
}
|
||||
return VideoStatusOutputs.NoStatus;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// HasVideoStatuses method
|
||||
/// </summary>
|
||||
public static bool HasVideoStatuses(this IAttachVideoStatus attachedDev)
|
||||
{
|
||||
return TieLineCollection.Default.FirstOrDefault(t =>
|
||||
t.SourcePort.ParentDevice == attachedDev
|
||||
&& t.DestinationPort is RoutingInputPortWithVideoStatuses) != null;
|
||||
}
|
||||
/// <summary>
|
||||
/// HasVideoStatuses method
|
||||
/// </summary>
|
||||
public static bool HasVideoStatuses(this IAttachVideoStatus attachedDev)
|
||||
{
|
||||
return TieLineCollection.Default.FirstOrDefault(t =>
|
||||
t.SourcePort.ParentDevice == attachedDev
|
||||
&& t.DestinationPort is RoutingInputPortWithVideoStatuses) != null;
|
||||
}
|
||||
}
|
||||
|
|
@ -48,42 +48,40 @@ namespace PepperDash.Essentials.Core
|
|||
/// <param name="getCurrentStates"></param>
|
||||
public static void DumpFeedbacksToConsole(this IHasFeedback source, bool getCurrentStates)
|
||||
{
|
||||
Type t = source.GetType();
|
||||
// get the properties and set them into a new collection of NameType wrappers
|
||||
var props = t.GetProperties().Select(p => new PropertyNameType(p, t));
|
||||
|
||||
var feedbacks = source.Feedbacks;
|
||||
|
||||
if (feedbacks == null || feedbacks.Count == 0)
|
||||
{
|
||||
CrestronConsole.ConsoleCommandResponse("No available feedbacks\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
CrestronConsole.ConsoleCommandResponse("Available feedbacks:\r\n");
|
||||
|
||||
// Sort feedbacks by type first, then by key
|
||||
var sortedFeedbacks = feedbacks.OrderBy(f => GetFeedbackTypeName(f)).ThenBy(f => string.IsNullOrEmpty(f.Key) ? "" : f.Key);
|
||||
|
||||
foreach (var feedback in sortedFeedbacks)
|
||||
{
|
||||
string value = "";
|
||||
string type = "";
|
||||
if (getCurrentStates)
|
||||
Debug.LogMessage(LogEventLevel.Information, source, "\n\nAvailable feedbacks:");
|
||||
foreach (var f in feedbacks)
|
||||
{
|
||||
if (feedback is BoolFeedback)
|
||||
string val = "";
|
||||
string type = "";
|
||||
if (getCurrentStates)
|
||||
{
|
||||
value = feedback.BoolValue.ToString();
|
||||
type = "boolean";
|
||||
}
|
||||
else if (feedback is IntFeedback)
|
||||
{
|
||||
value = feedback.IntValue.ToString();
|
||||
type = "integer";
|
||||
}
|
||||
else if (feedback is StringFeedback)
|
||||
{
|
||||
value = feedback.StringValue;
|
||||
type = "string";
|
||||
if (f is BoolFeedback)
|
||||
{
|
||||
val = f.BoolValue.ToString();
|
||||
type = "boolean";
|
||||
}
|
||||
else if (f is IntFeedback)
|
||||
{
|
||||
val = f.IntValue.ToString();
|
||||
type = "integer";
|
||||
}
|
||||
else if (f is StringFeedback)
|
||||
{
|
||||
val = f.StringValue;
|
||||
type = "string";
|
||||
}
|
||||
}
|
||||
Debug.LogMessage(LogEventLevel.Information, "{0,-12} {1, -25} {2}", type,
|
||||
(string.IsNullOrEmpty(f.Key) ? "-no key-" : f.Key), val);
|
||||
}
|
||||
CrestronConsole.ConsoleCommandResponse($" {type,-12} {(string.IsNullOrEmpty(feedback.Key) ? "-no key-" : feedback.Key),-25} {value}\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,41 +1,34 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
namespace PepperDash.Essentials.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
/// <summary>
|
||||
/// Defines the contract for IBasicVideoMute
|
||||
/// </summary>
|
||||
public interface IBasicVideoMute
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the contract for IBasicVideoMute
|
||||
/// Toggles the video mute
|
||||
/// </summary>
|
||||
public interface IBasicVideoMute
|
||||
{
|
||||
/// <summary>
|
||||
/// Toggles the video mute
|
||||
/// </summary>
|
||||
void VideoMuteToggle();
|
||||
}
|
||||
void VideoMuteToggle();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the contract for IBasicVideoMuteWithFeedback
|
||||
/// </summary>
|
||||
public interface IBasicVideoMuteWithFeedback : IBasicVideoMute
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the VideoMuteIsOn feedback
|
||||
/// </summary>
|
||||
BoolFeedback VideoMuteIsOn { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Defines the contract for IBasicVideoMuteWithFeedback
|
||||
/// Sets the video mute on
|
||||
/// </summary>
|
||||
public interface IBasicVideoMuteWithFeedback : IBasicVideoMute
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the VideoMuteIsOn feedback
|
||||
/// </summary>
|
||||
BoolFeedback VideoMuteIsOn { get; }
|
||||
void VideoMuteOn();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the video mute on
|
||||
/// </summary>
|
||||
void VideoMuteOn();
|
||||
/// <summary>
|
||||
/// Sets the video mute off
|
||||
/// </summary>
|
||||
void VideoMuteOff();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the video mute off
|
||||
/// </summary>
|
||||
void VideoMuteOff();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,27 +6,27 @@ using Crestron.SimplSharp;
|
|||
using PepperDash.Essentials.Core.Config;
|
||||
|
||||
|
||||
namespace PepperDash.Essentials.Core.Devices
|
||||
namespace PepperDash.Essentials.Core.Devices;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Defines the contract for IReconfigurableDevice
|
||||
/// </summary>
|
||||
public interface IReconfigurableDevice
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the contract for IReconfigurableDevice
|
||||
/// Event fired when the configuration changes
|
||||
/// </summary>
|
||||
public interface IReconfigurableDevice
|
||||
{
|
||||
/// <summary>
|
||||
/// Event fired when the configuration changes
|
||||
/// </summary>
|
||||
event EventHandler<EventArgs> ConfigChanged;
|
||||
event EventHandler<EventArgs> ConfigChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current DeviceConfig
|
||||
/// </summary>
|
||||
DeviceConfig Config { get; }
|
||||
/// <summary>
|
||||
/// Gets the current DeviceConfig
|
||||
/// </summary>
|
||||
DeviceConfig Config { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Sets the DeviceConfig
|
||||
/// </summary>
|
||||
/// <param name="config">config to set</param>
|
||||
void SetConfig(DeviceConfig config);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Sets the DeviceConfig
|
||||
/// </summary>
|
||||
/// <param name="config">config to set</param>
|
||||
void SetConfig(DeviceConfig config);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,143 +6,99 @@ using Crestron.SimplSharp;
|
|||
using PepperDash.Core;
|
||||
using Serilog.Events;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
namespace PepperDash.Essentials.Core;
|
||||
|
||||
public interface IUsageTracking
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the contract for IUsageTracking
|
||||
/// </summary>
|
||||
public interface IUsageTracking
|
||||
UsageTracking UsageTracker { get; set; }
|
||||
}
|
||||
|
||||
//public static class IUsageTrackingExtensions
|
||||
//{
|
||||
// public static void EnableUsageTracker(this IUsageTracking device)
|
||||
// {
|
||||
// device.UsageTracker = new UsageTracking();
|
||||
// }
|
||||
//}
|
||||
|
||||
public class UsageTracking
|
||||
{
|
||||
public event EventHandler<DeviceUsageEventArgs> DeviceUsageEnded;
|
||||
|
||||
public InUseTracking InUseTracker { get; protected set; }
|
||||
|
||||
public bool UsageIsTracked { get; set; }
|
||||
|
||||
public bool UsageTrackingStarted { get; protected set; }
|
||||
public DateTime UsageStartTime { get; protected set; }
|
||||
public DateTime UsageEndTime { get; protected set; }
|
||||
|
||||
public Device Parent { get; private set; }
|
||||
|
||||
public UsageTracking(Device parent)
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the UsageTracker
|
||||
/// </summary>
|
||||
UsageTracking UsageTracker { get; set; }
|
||||
Parent = parent;
|
||||
|
||||
InUseTracker = new InUseTracking();
|
||||
|
||||
InUseTracker.InUseFeedback.OutputChange += InUseFeedback_OutputChange; //new EventHandler<EventArgs>();
|
||||
}
|
||||
|
||||
void InUseFeedback_OutputChange(object sender, EventArgs e)
|
||||
{
|
||||
if(InUseTracker.InUseFeedback.BoolValue)
|
||||
{
|
||||
StartDeviceUsage();
|
||||
}
|
||||
else
|
||||
{
|
||||
EndDeviceUsage();
|
||||
}
|
||||
}
|
||||
|
||||
//public static class IUsageTrackingExtensions
|
||||
//{
|
||||
// public static void EnableUsageTracker(this IUsageTracking device)
|
||||
// {
|
||||
// device.UsageTracker = new UsageTracking();
|
||||
// }
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a UsageTracking
|
||||
/// Stores the usage start time
|
||||
/// </summary>
|
||||
public class UsageTracking
|
||||
public void StartDeviceUsage()
|
||||
{
|
||||
/// <summary>
|
||||
/// Event fired when device usage ends
|
||||
/// </summary>
|
||||
public event EventHandler<DeviceUsageEventArgs> DeviceUsageEnded;
|
||||
UsageTrackingStarted = true;
|
||||
UsageStartTime = DateTime.Now;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the InUseTracker
|
||||
/// </summary>
|
||||
public InUseTracking InUseTracker { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the UsageIsTracked
|
||||
/// </summary>
|
||||
public bool UsageIsTracked { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the UsageTrackingStarted
|
||||
/// </summary>
|
||||
public bool UsageTrackingStarted { get; protected set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the UsageStartTime
|
||||
/// </summary>
|
||||
public DateTime UsageStartTime { get; protected set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the UsageEndTime
|
||||
/// </summary>
|
||||
public DateTime UsageEndTime { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Parent
|
||||
/// </summary>
|
||||
public Device Parent { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for UsageTracking class
|
||||
/// </summary>
|
||||
/// <param name="parent">The parent device</param>
|
||||
public UsageTracking(Device parent)
|
||||
/// <summary>
|
||||
/// Calculates the difference between the usage start and end times, gets the total minutes used and fires an event to pass that info to a consumer
|
||||
/// </summary>
|
||||
public void EndDeviceUsage()
|
||||
{
|
||||
try
|
||||
{
|
||||
Parent = parent;
|
||||
|
||||
InUseTracker = new InUseTracking();
|
||||
UsageTrackingStarted = false;
|
||||
|
||||
InUseTracker.InUseFeedback.OutputChange += InUseFeedback_OutputChange; //new EventHandler<EventArgs>();
|
||||
}
|
||||
UsageEndTime = DateTime.Now;
|
||||
|
||||
void InUseFeedback_OutputChange(object sender, EventArgs e)
|
||||
{
|
||||
if(InUseTracker.InUseFeedback.BoolValue)
|
||||
if (UsageStartTime != null)
|
||||
{
|
||||
StartDeviceUsage();
|
||||
}
|
||||
else
|
||||
{
|
||||
EndDeviceUsage();
|
||||
}
|
||||
}
|
||||
var timeUsed = UsageEndTime - UsageStartTime;
|
||||
|
||||
var handler = DeviceUsageEnded;
|
||||
|
||||
/// <summary>
|
||||
/// StartDeviceUsage method
|
||||
/// </summary>
|
||||
public void StartDeviceUsage()
|
||||
{
|
||||
UsageTrackingStarted = true;
|
||||
UsageStartTime = DateTime.Now;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the difference between the usage start and end times, gets the total minutes used and fires an event to pass that info to a consumer
|
||||
/// </summary>
|
||||
public void EndDeviceUsage()
|
||||
{
|
||||
try
|
||||
{
|
||||
UsageTrackingStarted = false;
|
||||
|
||||
UsageEndTime = DateTime.Now;
|
||||
|
||||
if (UsageStartTime != null)
|
||||
if (handler != null)
|
||||
{
|
||||
var timeUsed = UsageEndTime - UsageStartTime;
|
||||
|
||||
var handler = DeviceUsageEnded;
|
||||
|
||||
if (handler != null)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, "Device Usage Ended for: {0} at {1}. In use for {2} minutes.", Parent.Name, UsageEndTime, timeUsed.Minutes);
|
||||
handler(this, new DeviceUsageEventArgs() { UsageEndTime = UsageEndTime, MinutesUsed = timeUsed.Minutes });
|
||||
}
|
||||
Debug.LogMessage(LogEventLevel.Debug, "Device Usage Ended for: {0} at {1}. In use for {2} minutes.", Parent.Name, UsageEndTime, timeUsed.Minutes);
|
||||
handler(this, new DeviceUsageEventArgs() { UsageEndTime = UsageEndTime, MinutesUsed = timeUsed.Minutes });
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, "Error ending device usage: {0}", e);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, "Error ending device usage: {0}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a DeviceUsageEventArgs
|
||||
/// </summary>
|
||||
public class DeviceUsageEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the UsageEndTime
|
||||
/// </summary>
|
||||
public DateTime UsageEndTime { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the MinutesUsed
|
||||
/// </summary>
|
||||
public int MinutesUsed { get; set; }
|
||||
}
|
||||
public class DeviceUsageEventArgs : EventArgs
|
||||
{
|
||||
public DateTime UsageEndTime { get; set; }
|
||||
public int MinutesUsed { get; set; }
|
||||
}
|
||||
|
|
@ -1,232 +1,223 @@
|
|||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Crestron.SimplSharp;
|
||||
using System;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
|
||||
|
||||
using PepperDash.Core;
|
||||
using Serilog.Events;
|
||||
using System.IO;
|
||||
using PepperDash.Core.Logging;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
namespace PepperDash.Essentials.Core;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// IR port wrapper. May act standalone
|
||||
/// </summary>
|
||||
public class IrOutputPortController : Device
|
||||
{
|
||||
uint IrPortUid;
|
||||
IROutputPort IrPort;
|
||||
|
||||
/// <summary>
|
||||
/// IR port wrapper. May act standalone
|
||||
/// Gets the DriverLoaded feedback
|
||||
/// </summary>
|
||||
public class IrOutputPortController : Device
|
||||
{
|
||||
uint IrPortUid;
|
||||
IROutputPort IrPort;
|
||||
public BoolFeedback DriverLoaded { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the DriverLoaded feedback
|
||||
/// </summary>
|
||||
public BoolFeedback DriverLoaded { get; private set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the StandardIrPulseTime
|
||||
/// </summary>
|
||||
public ushort StandardIrPulseTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the StandardIrPulseTime
|
||||
/// </summary>
|
||||
public ushort StandardIrPulseTime { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the DriverFilepath
|
||||
/// </summary>
|
||||
public string DriverFilepath { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the DriverFilepath
|
||||
/// </summary>
|
||||
public string DriverFilepath { get; private set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the DriverIsLoaded
|
||||
/// </summary>
|
||||
public bool DriverIsLoaded { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the DriverIsLoaded
|
||||
/// </summary>
|
||||
public bool DriverIsLoaded { get; private set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the IrFileCommands
|
||||
/// </summary>
|
||||
public string[] IrFileCommands { get { return IrPort.AvailableStandardIRCmds(IrPortUid); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the IrFileCommands
|
||||
/// </summary>
|
||||
public string[] IrFileCommands { get { return IrPort.AvailableStandardIRCmds(IrPortUid); } }
|
||||
/// <summary>
|
||||
/// Gets or sets the UseBridgeJoinMap
|
||||
/// </summary>
|
||||
public bool UseBridgeJoinMap { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the UseBridgeJoinMap
|
||||
/// </summary>
|
||||
public bool UseBridgeJoinMap { get; private set; }
|
||||
/// <summary>
|
||||
/// Constructor for IrDevice base class. If a null port is provided, this class will
|
||||
/// still function without trying to talk to a port.
|
||||
/// </summary>
|
||||
public IrOutputPortController(string key, IROutputPort port, string irDriverFilepath)
|
||||
: base(key)
|
||||
{
|
||||
//if (port == null) throw new ArgumentNullException("port");
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for IrDevice base class. If a null port is provided, this class will
|
||||
/// still function without trying to talk to a port.
|
||||
/// </summary>
|
||||
public IrOutputPortController(string key, IROutputPort port, string irDriverFilepath)
|
||||
: base(key)
|
||||
DriverLoaded = new BoolFeedback(() => DriverIsLoaded);
|
||||
IrPort = port;
|
||||
if (port == null)
|
||||
{
|
||||
//if (port == null) throw new ArgumentNullException("port");
|
||||
Debug.LogMessage(LogEventLevel.Information, this, "WARNING No valid IR Port assigned to controller. IR will not function");
|
||||
return;
|
||||
}
|
||||
LoadDriver(irDriverFilepath);
|
||||
}
|
||||
|
||||
DriverLoaded = new BoolFeedback(() => DriverIsLoaded);
|
||||
IrPort = port;
|
||||
if (port == null)
|
||||
/// <summary>
|
||||
/// Constructor for IrDevice base class using post activation function to get port
|
||||
/// </summary>
|
||||
/// <param name="key">key of the device</param>
|
||||
/// <param name="postActivationFunc">function to call post activation</param>
|
||||
/// <param name="config">config of the device</param>
|
||||
public IrOutputPortController(string key, Func<DeviceConfig, IROutputPort> postActivationFunc,
|
||||
DeviceConfig config)
|
||||
: base(key)
|
||||
{
|
||||
DriverLoaded = new BoolFeedback(() => DriverIsLoaded);
|
||||
UseBridgeJoinMap = config.Properties["control"].Value<bool>("useBridgeJoinMap");
|
||||
AddPostActivationAction(() =>
|
||||
{
|
||||
IrPort = postActivationFunc(config);
|
||||
|
||||
if (IrPort == null)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, this, "WARNING No valid IR Port assigned to controller. IR will not function");
|
||||
return;
|
||||
}
|
||||
LoadDriver(irDriverFilepath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for IrDevice base class using post activation function to get port
|
||||
/// </summary>
|
||||
/// <param name="key">key of the device</param>
|
||||
/// <param name="postActivationFunc">function to call post activation</param>
|
||||
/// <param name="config">config of the device</param>
|
||||
public IrOutputPortController(string key, Func<DeviceConfig, IROutputPort> postActivationFunc,
|
||||
DeviceConfig config)
|
||||
: base(key)
|
||||
{
|
||||
DriverLoaded = new BoolFeedback(() => DriverIsLoaded);
|
||||
UseBridgeJoinMap = config.Properties["control"].Value<bool>("useBridgeJoinMap");
|
||||
AddPostActivationAction(() =>
|
||||
{
|
||||
IrPort = postActivationFunc(config);
|
||||
// var filePath = Global.FilePathPrefix + "ir" + Global.DirectorySeparator + config.Properties["control"]["irFile"].Value<string>();
|
||||
|
||||
if (IrPort == null)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, this, "WARNING No valid IR Port assigned to controller. IR will not function");
|
||||
return;
|
||||
}
|
||||
|
||||
// var filePath = Global.FilePathPrefix + "ir" + Global.DirectorySeparator + config.Properties["control"]["irFile"].Value<string>();
|
||||
var fileName = config.Properties["control"]["irFile"].Value<string>();
|
||||
|
||||
var fileName = config.Properties["control"]["irFile"].Value<string>();
|
||||
var files = Directory.GetFiles(Global.FilePathPrefix, fileName, SearchOption.AllDirectories);
|
||||
|
||||
var files = Directory.GetFiles(Global.FilePathPrefix, fileName, SearchOption.AllDirectories);
|
||||
if (files.Length == 0)
|
||||
{
|
||||
this.LogError("IR file {fileName} not found in {path}", fileName, Global.FilePathPrefix);
|
||||
return;
|
||||
}
|
||||
|
||||
if(files.Length == 0)
|
||||
{
|
||||
this.LogError("IR file {fileName} not found in {path}", fileName, Global.FilePathPrefix);
|
||||
return;
|
||||
}
|
||||
if (files.Length > 1)
|
||||
{
|
||||
this.LogError("IR file {fileName} found in multiple locations: {files}", fileName, files);
|
||||
return;
|
||||
}
|
||||
|
||||
if(files.Length > 1)
|
||||
{
|
||||
this.LogError("IR file {fileName} found in multiple locations: {files}", fileName, files);
|
||||
return;
|
||||
}
|
||||
var filePath = files[0];
|
||||
|
||||
var filePath = files[0];
|
||||
Debug.LogMessage(LogEventLevel.Debug, "*************Attempting to load IR file: {0}***************", filePath);
|
||||
|
||||
Debug.LogMessage(LogEventLevel.Debug, "*************Attempting to load IR file: {0}***************", filePath);
|
||||
LoadDriver(filePath);
|
||||
|
||||
LoadDriver(filePath);
|
||||
|
||||
PrintAvailableCommands();
|
||||
});
|
||||
}
|
||||
PrintAvailableCommands();
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PrintAvailableCommands method
|
||||
/// </summary>
|
||||
public void PrintAvailableCommands()
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Verbose, this, "Available IR Commands in IR File {0}", IrPortUid);
|
||||
foreach (var cmd in IrPort.AvailableIRCmds())
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Verbose, this, "{0}", cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Loads the IR driver at path
|
||||
/// </summary>
|
||||
/// <param name="path">path of the IR driver file</param>
|
||||
public void LoadDriver(string path)
|
||||
/// <summary>
|
||||
/// PrintAvailableCommands method
|
||||
/// </summary>
|
||||
public void PrintAvailableCommands()
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Verbose, this, "Available IR Commands in IR File {0}", IrPortUid);
|
||||
foreach (var cmd in IrPort.AvailableIRCmds())
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Verbose, this, "***Loading IR File***");
|
||||
if (string.IsNullOrEmpty(path)) path = DriverFilepath;
|
||||
try
|
||||
{
|
||||
IrPortUid = IrPort.LoadIRDriver(path);
|
||||
DriverFilepath = path;
|
||||
StandardIrPulseTime = 200;
|
||||
DriverIsLoaded = true;
|
||||
|
||||
DriverLoaded.FireUpdate();
|
||||
}
|
||||
catch
|
||||
{
|
||||
DriverIsLoaded = false;
|
||||
var message = string.Format("WARNING IR Driver '{0}' failed to load", path);
|
||||
Debug.LogMessage(LogEventLevel.Information, this, message);
|
||||
DriverLoaded.FireUpdate();
|
||||
}
|
||||
Debug.LogMessage(LogEventLevel.Verbose, this, "{0}", cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// PressRelease method
|
||||
/// </summary>
|
||||
/// <param name="command">IR command to send</param>
|
||||
/// <param name="state">true to press, false to release</param>
|
||||
/// <inheritdoc />
|
||||
public virtual void PressRelease(string command, bool state)
|
||||
/// <summary>
|
||||
/// Loads the IR driver at path
|
||||
/// </summary>
|
||||
/// <param name="path">path of the IR driver file</param>
|
||||
public void LoadDriver(string path)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Verbose, this, "***Loading IR File***");
|
||||
if (string.IsNullOrEmpty(path)) path = DriverFilepath;
|
||||
try
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Verbose, this, "IR:'{0}'={1}", command, state);
|
||||
if (IrPort == null)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Verbose, this, "WARNING No IR Port assigned to controller");
|
||||
return;
|
||||
}
|
||||
if (!DriverIsLoaded)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Verbose, this, "WARNING IR driver is not loaded");
|
||||
return;
|
||||
}
|
||||
if (state)
|
||||
{
|
||||
if (IrPort.IsIRCommandAvailable(IrPortUid, command))
|
||||
IrPort.Press(IrPortUid, command);
|
||||
else
|
||||
NoIrCommandError(command);
|
||||
}
|
||||
else
|
||||
IrPort.Release();
|
||||
IrPortUid = IrPort.LoadIRDriver(path);
|
||||
DriverFilepath = path;
|
||||
StandardIrPulseTime = 200;
|
||||
DriverIsLoaded = true;
|
||||
|
||||
DriverLoaded.FireUpdate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pulse method
|
||||
/// </summary>
|
||||
/// <param name="command">IR command to send</param>
|
||||
/// <param name="time">time to pulse the command</param>
|
||||
/// <inheritdoc />
|
||||
public virtual void Pulse(string command, ushort time)
|
||||
catch
|
||||
{
|
||||
DriverIsLoaded = false;
|
||||
var message = string.Format("WARNING IR Driver '{0}' failed to load", path);
|
||||
Debug.LogMessage(LogEventLevel.Information, this, message);
|
||||
DriverLoaded.FireUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// PressRelease method
|
||||
/// </summary>
|
||||
/// <param name="command">IR command to send</param>
|
||||
/// <param name="state">true to press, false to release</param>
|
||||
/// <inheritdoc />
|
||||
public virtual void PressRelease(string command, bool state)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Verbose, this, "IR:'{0}'={1}", command, state);
|
||||
if (IrPort == null)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Verbose, this, "WARNING No IR Port assigned to controller");
|
||||
return;
|
||||
}
|
||||
if (!DriverIsLoaded)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Verbose, this, "WARNING IR driver is not loaded");
|
||||
return;
|
||||
}
|
||||
if (state)
|
||||
{
|
||||
if (IrPort == null)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Verbose, this, "WARNING No IR Port assigned to controller");
|
||||
return;
|
||||
}
|
||||
if (!DriverIsLoaded)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Verbose, this, "WARNING IR driver is not loaded");
|
||||
return;
|
||||
}
|
||||
if (IrPort.IsIRCommandAvailable(IrPortUid, command))
|
||||
IrPort.PressAndRelease(IrPortUid, command, time);
|
||||
IrPort.Press(IrPortUid, command);
|
||||
else
|
||||
NoIrCommandError(command);
|
||||
}
|
||||
else
|
||||
IrPort.Release();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notifies the console when a bad command is used.
|
||||
/// </summary>
|
||||
/// <param name="command">command that was not found</param>
|
||||
protected void NoIrCommandError(string command)
|
||||
/// <summary>
|
||||
/// Pulse method
|
||||
/// </summary>
|
||||
/// <param name="command">IR command to send</param>
|
||||
/// <param name="time">time to pulse the command</param>
|
||||
/// <inheritdoc />
|
||||
public virtual void Pulse(string command, ushort time)
|
||||
{
|
||||
if (IrPort == null)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Verbose, this, "Device {0}: IR Driver {1} does not contain command {2}",
|
||||
Key, IrPort.IRDriverFileNameByIRDriverId(IrPortUid), command);
|
||||
Debug.LogMessage(LogEventLevel.Verbose, this, "WARNING No IR Port assigned to controller");
|
||||
return;
|
||||
}
|
||||
if (!DriverIsLoaded)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Verbose, this, "WARNING IR driver is not loaded");
|
||||
return;
|
||||
}
|
||||
if (IrPort.IsIRCommandAvailable(IrPortUid, command))
|
||||
IrPort.PressAndRelease(IrPortUid, command, time);
|
||||
else
|
||||
NoIrCommandError(command);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notifies the console when a bad command is used.
|
||||
/// </summary>
|
||||
/// <param name="command">command that was not found</param>
|
||||
protected void NoIrCommandError(string command)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Verbose, this, "Device {0}: IR Driver {1} does not contain command {2}",
|
||||
Key, IrPort.IRDriverFileNameByIRDriverId(IrPortUid), command);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,113 +1,115 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core.Devices;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
namespace PepperDash.Essentials.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a level control item in a list, which can be used to control volume or mute functionality.
|
||||
/// </summary>
|
||||
public class LevelControlListItem : AudioControlListItemBase
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// A reference to the IBasicVolumeWithFeedback device for control.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public IBasicVolumeWithFeedback LevelControl
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_levelControl == null)
|
||||
_levelControl = DeviceManager.GetDeviceForKey(ParentDeviceKey) as IBasicVolumeWithFeedback;
|
||||
return _levelControl;
|
||||
}
|
||||
}
|
||||
IBasicVolumeWithFeedback _levelControl;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name from the device if it implements IKeyName or else returns the Name property
|
||||
/// </summary>
|
||||
[JsonProperty("preferredName")]
|
||||
public string PreferredName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Name)) return Name;
|
||||
else
|
||||
{
|
||||
if (LevelControl is IKeyName namedLevelControl)
|
||||
{
|
||||
if (namedLevelControl == null)
|
||||
return "---";
|
||||
return namedLevelControl.Name;
|
||||
}
|
||||
else return "---";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The key of the device in the DeviceManager for control
|
||||
/// </summary>
|
||||
[JsonProperty("deviceKey")]
|
||||
public string DeviceKey
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(ItemKey)) return ParentDeviceKey;
|
||||
else
|
||||
{
|
||||
return DeviceManager.AllDevices.
|
||||
Where(d => d.Key.Contains(ParentDeviceKey) && d.Key.Contains(ItemKey)).FirstOrDefault()?.Key ?? $"{ParentDeviceKey}--{ItemKey}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if the item is a level, mute , or both
|
||||
/// </summary>
|
||||
[JsonProperty("type")]
|
||||
[JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
|
||||
public eLevelControlType Type { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if the item is a mic or not.
|
||||
/// </summary>
|
||||
[JsonProperty("isMic", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public bool? IsMic { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if the item should show the raw level in the UI.
|
||||
/// </summary>
|
||||
[JsonProperty("showRawLevel", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public bool? ShowRawLevel { get; set; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Indicates the type of level control item.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum eLevelControlType
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a level control item in a list, which can be used to control volume or mute functionality.
|
||||
/// Indicates that the item is a level control only
|
||||
/// </summary>
|
||||
public class LevelControlListItem : AudioControlListItemBase
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// A reference to the IBasicVolumeWithFeedback device for control.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public IBasicVolumeWithFeedback LevelControl
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_levelControl == null)
|
||||
_levelControl = DeviceManager.GetDeviceForKey(ParentDeviceKey) as IBasicVolumeWithFeedback;
|
||||
return _levelControl;
|
||||
}
|
||||
}
|
||||
IBasicVolumeWithFeedback _levelControl;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name from the device if it implements IKeyName or else returns the Name property
|
||||
/// </summary>
|
||||
[JsonProperty("preferredName")]
|
||||
public string PreferredName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Name)) return Name;
|
||||
else
|
||||
{
|
||||
if (LevelControl is IKeyName namedLevelControl)
|
||||
{
|
||||
if (namedLevelControl == null)
|
||||
return "---";
|
||||
return namedLevelControl.Name;
|
||||
}
|
||||
else return "---";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The key of the device in the DeviceManager for control
|
||||
/// </summary>
|
||||
[JsonProperty("deviceKey")]
|
||||
public string DeviceKey
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(ItemKey)) return ParentDeviceKey;
|
||||
else
|
||||
{
|
||||
return DeviceManager.AllDevices.
|
||||
Where(d => d.Key.Contains(ParentDeviceKey) && d.Key.Contains(ItemKey)).FirstOrDefault()?.Key ?? $"{ParentDeviceKey}--{ItemKey}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if the item is a level, mute , or both
|
||||
/// </summary>
|
||||
[JsonProperty("type")]
|
||||
[JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
|
||||
public eLevelControlType Type { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if the item is a mic or not.
|
||||
/// </summary>
|
||||
[JsonProperty("isMic", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public bool? IsMic { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if the item should show the raw level in the UI.
|
||||
/// </summary>
|
||||
[JsonProperty("showRawLevel", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public bool? ShowRawLevel { get; set; }
|
||||
}
|
||||
|
||||
Level = 1,
|
||||
/// <summary>
|
||||
/// Indicates the type of level control item.
|
||||
/// Indicates that the item is a mute control only
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum eLevelControlType
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates that the item is a level control only
|
||||
/// </summary>
|
||||
Level = 1,
|
||||
/// <summary>
|
||||
/// Indicates that the item is a mute control only
|
||||
/// </summary>
|
||||
Mute = 2,
|
||||
/// <summary>
|
||||
/// Indicates that the item is both a level and mute control
|
||||
/// </summary>
|
||||
LevelAndMute = Level | Mute,
|
||||
}
|
||||
|
||||
Mute = 2,
|
||||
/// <summary>
|
||||
/// Indicates that the item is both a level and mute control
|
||||
/// </summary>
|
||||
LevelAndMute = Level | Mute,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,33 +4,32 @@ using Crestron.SimplSharp;
|
|||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core.Devices
|
||||
namespace PepperDash.Essentials.Core.Devices;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for any device that is able to control its power and has a configurable reboot time
|
||||
/// </summary>
|
||||
public interface IHasPowerCycle : IKeyName, IHasPowerControlWithFeedback
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface for any device that is able to control it'spower and has a configurable reboot time
|
||||
/// </summary>
|
||||
public interface IHasPowerCycle : IKeyName, IHasPowerControlWithFeedback
|
||||
{
|
||||
/// <summary>
|
||||
/// Delay between power off and power on for reboot
|
||||
/// </summary>
|
||||
int PowerCycleTimeMs { get;}
|
||||
|
||||
/// <summary>
|
||||
/// Reboot outlet
|
||||
/// </summary>
|
||||
void PowerCycle();
|
||||
}
|
||||
/// Delay between power off and power on for reboot
|
||||
/// </summary>
|
||||
int PowerCycleTimeMs { get;}
|
||||
|
||||
/// <summary>
|
||||
/// Interface for any device that contains a collection of IHasPowerReboot Devices
|
||||
/// </summary>
|
||||
public interface IHasControlledPowerOutlets : IKeyName
|
||||
{
|
||||
/// <summary>
|
||||
/// Collection of IPduOutlets
|
||||
/// </summary>
|
||||
ReadOnlyDictionary<int, IHasPowerCycle> PduOutlets { get; }
|
||||
/// Reboot outlet
|
||||
/// </summary>
|
||||
void PowerCycle();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Interface for any device that contains a collection of IHasPowerReboot Devices
|
||||
/// </summary>
|
||||
public interface IHasControlledPowerOutlets : IKeyName
|
||||
{
|
||||
/// <summary>
|
||||
/// Collection of IPduOutlets
|
||||
/// </summary>
|
||||
ReadOnlyDictionary<int, IHasPowerCycle> PduOutlets { get; }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,153 +1,150 @@
|
|||
using Crestron.SimplSharp;
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
namespace PepperDash.Essentials.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the contract for IHasBatteryStats
|
||||
/// </summary>
|
||||
public interface IHasBatteryStats : IKeyName
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the contract for IHasBatteryStats
|
||||
/// Gets the BatteryPercentage
|
||||
/// </summary>
|
||||
public interface IHasBatteryStats : IKeyName
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the BatteryPercentage
|
||||
/// </summary>
|
||||
int BatteryPercentage { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the BatteryCautionThresholdPercentage
|
||||
/// </summary>
|
||||
int BatteryCautionThresholdPercentage { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the BatteryWarningThresholdPercentage
|
||||
/// </summary>
|
||||
int BatteryWarningThresholdPercentage { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the BatteryIsWarningFeedback
|
||||
/// </summary>
|
||||
BoolFeedback BatteryIsWarningFeedback { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the BatteryIsCautionFeedback
|
||||
/// </summary>
|
||||
BoolFeedback BatteryIsCautionFeedback { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the BatteryIsOkFeedback
|
||||
/// </summary>
|
||||
BoolFeedback BatteryIsOkFeedback { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the BatteryPercentageFeedback
|
||||
/// </summary>
|
||||
IntFeedback BatteryPercentageFeedback { get; }
|
||||
}
|
||||
int BatteryPercentage { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Defines the contract for IHasBatteryCharging
|
||||
/// Gets the BatteryCautionThresholdPercentage
|
||||
/// </summary>
|
||||
public interface IHasBatteryCharging : IHasBatteryStats
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the BatteryIsCharging
|
||||
/// </summary>
|
||||
BoolFeedback BatteryIsCharging { get; }
|
||||
}
|
||||
int BatteryCautionThresholdPercentage { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Interface for any device that has multiple batteries that can be monitored
|
||||
/// Gets the BatteryWarningThresholdPercentage
|
||||
/// </summary>
|
||||
public interface IHasBatteries : IKeyName
|
||||
{
|
||||
/// <summary>
|
||||
/// Collection of batteries
|
||||
/// </summary>
|
||||
ReadOnlyDictionary<string, IHasBatteryStats> Batteries { get; }
|
||||
}
|
||||
int BatteryWarningThresholdPercentage { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Defines the contract for IHasBatteryStatsExtended
|
||||
/// Gets the BatteryIsWarningFeedback
|
||||
/// </summary>
|
||||
public interface IHasBatteryStatsExtended : IHasBatteryStats
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the InputVoltage in millivolts
|
||||
/// </summary>
|
||||
int InputVoltage { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the OutputVoltage in millivolts
|
||||
/// </summary>
|
||||
int OutputVoltage { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the InputCurrent in milliamps
|
||||
/// </summary>
|
||||
int InptuCurrent { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the OutputCurrent in milliamps
|
||||
/// </summary>
|
||||
int OutputCurrent { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the InputVoltageFeedback
|
||||
/// </summary>
|
||||
IntFeedback InputVoltageFeedback { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the OutputVoltageFeedback
|
||||
/// </summary>
|
||||
IntFeedback OutputVoltageFeedback { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the InputCurrentFeedback
|
||||
/// </summary>
|
||||
IntFeedback InputCurrentFeedback { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the OutputCurrentFeedback
|
||||
/// </summary>
|
||||
IntFeedback OutputCurrentFeedback { get; }
|
||||
}
|
||||
BoolFeedback BatteryIsWarningFeedback { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Defines the contract for IHasPowerCycleWithBattery
|
||||
/// Gets the BatteryIsCautionFeedback
|
||||
/// </summary>
|
||||
public interface IHasPowerCycleWithBattery : IHasPowerCycle, IHasBatteryStats
|
||||
{
|
||||
|
||||
}
|
||||
BoolFeedback BatteryIsCautionFeedback { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Interface for any device that is able to control it's power and has a configurable reboot time
|
||||
/// Gets the BatteryIsOkFeedback
|
||||
/// </summary>
|
||||
public interface IHasPowerCycle : IKeyName, IHasPowerControlWithFeedback
|
||||
{
|
||||
/// <summary>
|
||||
/// Delay between power off and power on for reboot
|
||||
/// </summary>
|
||||
int PowerCycleTimeMs { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Reboot outlet
|
||||
/// </summary>
|
||||
void PowerCycle();
|
||||
}
|
||||
BoolFeedback BatteryIsOkFeedback { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Interface for any device that contains a collection of IHasPowerReboot Devices
|
||||
/// Gets the BatteryPercentageFeedback
|
||||
/// </summary>
|
||||
public interface IHasControlledPowerOutlets : IKeyName
|
||||
{
|
||||
/// <summary>
|
||||
/// Collection of IPduOutlets
|
||||
/// </summary>
|
||||
ReadOnlyDictionary<int, IHasPowerCycle> PduOutlets { get; }
|
||||
IntFeedback BatteryPercentageFeedback { get; }
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Defines the contract for IHasBatteryCharging
|
||||
/// </summary>
|
||||
public interface IHasBatteryCharging : IHasBatteryStats
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the BatteryIsCharging
|
||||
/// </summary>
|
||||
BoolFeedback BatteryIsCharging { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Interface for any device that has multiple batteries that can be monitored
|
||||
/// </summary>
|
||||
public interface IHasBatteries : IKeyName
|
||||
{
|
||||
/// <summary>
|
||||
/// Collection of batteries
|
||||
/// </summary>
|
||||
ReadOnlyDictionary<string, IHasBatteryStats> Batteries { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the contract for IHasBatteryStatsExtended
|
||||
/// </summary>
|
||||
public interface IHasBatteryStatsExtended : IHasBatteryStats
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the InputVoltage in millivolts
|
||||
/// </summary>
|
||||
int InputVoltage { get; }
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the OutputVoltage in millivolts
|
||||
/// </summary>
|
||||
int OutputVoltage { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the InputCurrent in milliamps
|
||||
/// </summary>
|
||||
int InptuCurrent { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the OutputCurrent in milliamps
|
||||
/// </summary>
|
||||
int OutputCurrent { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the InputVoltageFeedback
|
||||
/// </summary>
|
||||
IntFeedback InputVoltageFeedback { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the OutputVoltageFeedback
|
||||
/// </summary>
|
||||
IntFeedback OutputVoltageFeedback { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the InputCurrentFeedback
|
||||
/// </summary>
|
||||
IntFeedback InputCurrentFeedback { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the OutputCurrentFeedback
|
||||
/// </summary>
|
||||
IntFeedback OutputCurrentFeedback { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Interface for any device that is able to control its power, has a configurable reboot time, and has batteries that can be monitored
|
||||
/// </summary>
|
||||
public interface IHasPowerCycleWithBattery : IHasPowerCycle, IHasBatteryStats
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Interface for any device that is able to control it's power and has a configurable reboot time
|
||||
/// </summary>
|
||||
public interface IHasPowerCycle : IKeyName, IHasPowerControlWithFeedback
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Delay between power off and power on for reboot
|
||||
/// </summary>
|
||||
int PowerCycleTimeMs { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Reboot outlet
|
||||
/// </summary>
|
||||
void PowerCycle();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Interface for any device that contains a collection of IHasPowerReboot Devices
|
||||
/// </summary>
|
||||
public interface IHasControlledPowerOutlets : IKeyName
|
||||
{
|
||||
/// <summary>
|
||||
/// Collection of PDU outlets
|
||||
/// </summary>
|
||||
ReadOnlyDictionary<int, IHasPowerCycle> PduOutlets { get; }
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
using Crestron.SimplSharpPro.EthernetCommunication;
|
||||
using Crestron.SimplSharpPro.UI;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Enumeration of PresentationSourceType values
|
||||
|
|
@ -44,4 +35,4 @@ namespace PepperDash.Essentials.Core
|
|||
/// </summary>
|
||||
VCR
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,51 +1,46 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json;
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
/// <summary>
|
||||
/// Represents a PresetListItem
|
||||
/// </summary>
|
||||
|
||||
public class PresetListItem : AudioControlListItemBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a PresetListItem
|
||||
/// Gets the preset associated with this list item
|
||||
/// </summary>
|
||||
public class PresetListItem : AudioControlListItemBase
|
||||
[JsonIgnore]
|
||||
public IKeyName Preset
|
||||
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the preset associated with this list item
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public IKeyName Preset
|
||||
get
|
||||
{
|
||||
get
|
||||
if (_preset == null)
|
||||
{
|
||||
if (_preset == null)
|
||||
{
|
||||
var parent = DeviceManager.GetDeviceForKey(ParentDeviceKey) as IDspPresets;
|
||||
if (parent == null || !parent.Presets.ContainsKey(ItemKey))
|
||||
return null;
|
||||
_preset = parent.Presets[ItemKey];
|
||||
}
|
||||
return _preset;
|
||||
var parent = DeviceManager.GetDeviceForKey(ParentDeviceKey) as IDspPresets;
|
||||
if (parent == null || !parent.Presets.ContainsKey(ItemKey))
|
||||
return null;
|
||||
_preset = parent.Presets[ItemKey];
|
||||
}
|
||||
return _preset;
|
||||
}
|
||||
private IKeyName _preset;
|
||||
}
|
||||
private IKeyName _preset;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name from the device if it implements IKeyName or else returns the Name property
|
||||
/// </summary>
|
||||
[JsonProperty("preferredName")]
|
||||
public string PreferredName
|
||||
/// <summary>
|
||||
/// Gets the name from the device if it implements IKeyName or else returns the Name property
|
||||
/// </summary>
|
||||
[JsonProperty("preferredName")]
|
||||
public string PreferredName
|
||||
{
|
||||
get
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Name)) return Name;
|
||||
if (!string.IsNullOrEmpty(Name)) return Name;
|
||||
|
||||
else return Preset.Name;
|
||||
}
|
||||
else return Preset.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,95 +12,67 @@ using PepperDash.Essentials.Core.Config;
|
|||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace PepperDash.Essentials.Core.Devices
|
||||
namespace PepperDash.Essentials.Core.Devices;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public abstract class ReconfigurableDevice : EssentialsDevice, IReconfigurableDevice
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public abstract class ReconfigurableDevice : EssentialsDevice, IReconfigurableDevice
|
||||
public event EventHandler<EventArgs> ConfigChanged;
|
||||
|
||||
public DeviceConfig Config { get; private set; }
|
||||
|
||||
protected ReconfigurableDevice(DeviceConfig config)
|
||||
: base(config.Key)
|
||||
{
|
||||
/// <summary>
|
||||
/// Event fired when the configuration changes
|
||||
/// </summary>
|
||||
public event EventHandler<EventArgs> ConfigChanged;
|
||||
SetNameHelper(config);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current DeviceConfig
|
||||
/// </summary>
|
||||
public DeviceConfig Config { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="config">config of the device</param>
|
||||
protected ReconfigurableDevice(DeviceConfig config)
|
||||
: base(config.Key)
|
||||
{
|
||||
SetNameHelper(config);
|
||||
|
||||
Config = config;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the Config, calls CustomSetConfig and fires the ConfigChanged event
|
||||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
/// <summary>
|
||||
/// SetConfig method
|
||||
/// </summary>
|
||||
public void SetConfig(DeviceConfig config)
|
||||
{
|
||||
Config = config;
|
||||
|
||||
SetNameHelper(config);
|
||||
|
||||
CustomSetConfig(config);
|
||||
|
||||
var handler = ConfigChanged;
|
||||
if (handler != null)
|
||||
{
|
||||
handler(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
|
||||
void SetNameHelper(DeviceConfig config)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(config.Name))
|
||||
Name = config.Name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Used by the extending class to allow for any custom actions to be taken (tell the ConfigWriter to write config, etc)
|
||||
/// </summary>
|
||||
/// <param name="config">config of the device</param>
|
||||
protected virtual void CustomSetConfig(DeviceConfig config)
|
||||
{
|
||||
ConfigWriter.UpdateDeviceConfig(config);
|
||||
}
|
||||
Config = config;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A ReconfigurableDevice that is also bridgeable
|
||||
/// Sets the Config, calls CustomSetConfig and fires the ConfigChanged event
|
||||
/// </summary>
|
||||
public abstract class ReconfigurableBridgableDevice : ReconfigurableDevice, IBridgeAdvanced
|
||||
/// <param name="config"></param>
|
||||
public void SetConfig(DeviceConfig config)
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="config">config of the device</param>
|
||||
protected ReconfigurableBridgableDevice(DeviceConfig config) : base(config)
|
||||
{
|
||||
}
|
||||
Config = config;
|
||||
|
||||
/// <summary>
|
||||
/// LinkToApi method
|
||||
/// </summary>
|
||||
/// <param name="trilist">trilist to link</param>
|
||||
/// <param name="joinStart">the join to start at</param>
|
||||
/// <param name="joinMapKey">key to the join map</param>
|
||||
/// <param name="bridge">the bridge to use</param>
|
||||
public abstract void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge);
|
||||
SetNameHelper(config);
|
||||
|
||||
CustomSetConfig(config);
|
||||
|
||||
var handler = ConfigChanged;
|
||||
if (handler != null)
|
||||
{
|
||||
handler(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
|
||||
void SetNameHelper(DeviceConfig config)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(config.Name))
|
||||
Name = config.Name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Used by the extending class to allow for any custom actions to be taken (tell the ConfigWriter to write config, etc)
|
||||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
protected virtual void CustomSetConfig(DeviceConfig config)
|
||||
{
|
||||
ConfigWriter.UpdateDeviceConfig(config);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class ReconfigurableBridgableDevice : ReconfigurableDevice, IBridgeAdvanced
|
||||
{
|
||||
protected ReconfigurableBridgableDevice(DeviceConfig config) : base(config)
|
||||
{
|
||||
}
|
||||
|
||||
public abstract void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge);
|
||||
}
|
||||
|
|
@ -1,24 +1,23 @@
|
|||
|
||||
namespace PepperDash.Essentials.Core
|
||||
namespace PepperDash.Essentials.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a SmartObjectJoinOffsets
|
||||
/// </summary>
|
||||
public class SmartObjectJoinOffsets
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a SmartObjectJoinOffsets
|
||||
/// </summary>
|
||||
public class SmartObjectJoinOffsets
|
||||
{
|
||||
/// <summary>
|
||||
/// Dpad Join Offset
|
||||
/// </summary>
|
||||
public const ushort Dpad = 1;
|
||||
/// <summary>
|
||||
/// Dpad Join Offset
|
||||
/// </summary>
|
||||
public const ushort Dpad = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Numpad Join Offset
|
||||
/// </summary>
|
||||
public const ushort Numpad = 2;
|
||||
/// <summary>
|
||||
/// Numpad Join Offset
|
||||
/// </summary>
|
||||
public const ushort Numpad = 2;
|
||||
|
||||
/// <summary>
|
||||
/// PresetList Join Offset
|
||||
/// </summary>
|
||||
public const ushort PresetList = 6;
|
||||
}
|
||||
/// <summary>
|
||||
/// PresetList Join Offset
|
||||
/// </summary>
|
||||
public const ushort PresetList = 6;
|
||||
}
|
||||
|
|
@ -4,344 +4,252 @@ using Newtonsoft.Json;
|
|||
using Newtonsoft.Json.Converters;
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
namespace PepperDash.Essentials.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the type of source list item, which can be a route, off, or other.
|
||||
/// </summary>
|
||||
public enum eSourceListItemType
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a typical route.
|
||||
/// </summary>
|
||||
Route,
|
||||
/// <summary>
|
||||
/// Represents an off route.
|
||||
/// </summary>
|
||||
Off,
|
||||
/// <summary>
|
||||
/// Represents some other type of route
|
||||
/// </summary>
|
||||
Other,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents an item in a source list - can be deserialized into.
|
||||
/// </summary>
|
||||
public class SourceListItem
|
||||
{
|
||||
/// <summary>
|
||||
/// The key of the source item, which is used to identify it in the DeviceManager
|
||||
/// </summary>
|
||||
[JsonProperty("sourceKey")]
|
||||
public string SourceKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Defines the type of source list item, which can be a route, off, or other.
|
||||
/// This is used to categorize the source list items in a room.
|
||||
/// The type is serialized to JSON and can be used to determine how the item should be displayed or handled in the UI.
|
||||
/// Returns the source Device for this, if it exists in DeviceManager
|
||||
/// </summary>
|
||||
public enum eSourceListItemType
|
||||
[JsonIgnore]
|
||||
public Device SourceDevice
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a typical route.
|
||||
/// </summary>
|
||||
Route,
|
||||
/// <summary>
|
||||
/// Represents an off route.
|
||||
/// </summary>
|
||||
Off,
|
||||
/// <summary>
|
||||
/// Represents some other type of route
|
||||
/// </summary>
|
||||
Other,
|
||||
get
|
||||
{
|
||||
if (_SourceDevice == null)
|
||||
_SourceDevice = DeviceManager.GetDeviceForKey(SourceKey) as Device;
|
||||
return _SourceDevice;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a SourceListItem
|
||||
/// </summary>
|
||||
public class SourceListItem
|
||||
{
|
||||
/// <summary>
|
||||
/// The key of the source item, which is used to identify it in the DeviceManager
|
||||
/// </summary>
|
||||
[JsonProperty("sourceKey")]
|
||||
public string SourceKey { get; set; }
|
||||
private Device _SourceDevice;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the source Device for this, if it exists in DeviceManager
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public Device SourceDevice
|
||||
/// <summary>
|
||||
/// Gets either the source's Name or this AlternateName property, if
|
||||
/// defined. If source doesn't exist, returns "Missing source"
|
||||
/// </summary>
|
||||
[JsonProperty("preferredName")]
|
||||
public string PreferredName
|
||||
{
|
||||
get
|
||||
{
|
||||
get
|
||||
if (string.IsNullOrEmpty(Name))
|
||||
{
|
||||
if (_SourceDevice == null)
|
||||
_SourceDevice = DeviceManager.GetDeviceForKey(SourceKey) as Device;
|
||||
return _SourceDevice;
|
||||
if (SourceDevice == null)
|
||||
return "---";
|
||||
return SourceDevice.Name;
|
||||
}
|
||||
}
|
||||
|
||||
private Device _SourceDevice;
|
||||
|
||||
/// <summary>
|
||||
/// Gets either the source's Name or this AlternateName property, if
|
||||
/// defined. If source doesn't exist, returns "Missing source"
|
||||
/// </summary>
|
||||
[JsonProperty("preferredName")]
|
||||
public string PreferredName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(Name))
|
||||
{
|
||||
if (SourceDevice == null)
|
||||
return "---";
|
||||
return SourceDevice.Name;
|
||||
}
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A name that will override the source's name on the UI
|
||||
/// </summary>
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Specifies and icon for the source list item
|
||||
/// </summary>
|
||||
[JsonProperty("icon")]
|
||||
public string Icon { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Alternate icon
|
||||
/// </summary>
|
||||
[JsonProperty("altIcon")]
|
||||
public string AltIcon { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if the item should be included in the source list
|
||||
/// </summary>
|
||||
[JsonProperty("includeInSourceList")]
|
||||
public bool IncludeInSourceList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Used to specify the order of the items in the source list when displayed
|
||||
/// </summary>
|
||||
[JsonProperty("order")]
|
||||
public int Order { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The key of the device for volume control
|
||||
/// </summary>
|
||||
[JsonProperty("volumeControlKey")]
|
||||
public string VolumeControlKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The type of source list item
|
||||
/// </summary>
|
||||
[JsonProperty("type")]
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public eSourceListItemType Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The list of routes to execute for this source list item
|
||||
/// </summary>
|
||||
[JsonProperty("routeList")]
|
||||
public List<SourceRouteListItem> RouteList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if this source should be disabled for sharing to the far end call participants via codec content
|
||||
/// </summary>
|
||||
[JsonProperty("disableCodecSharing")]
|
||||
public bool DisableCodecSharing { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if this source should be disabled for routing to a shared output
|
||||
/// </summary>
|
||||
[JsonProperty("disableRoutedSharing")]
|
||||
public bool DisableRoutedSharing { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[JsonProperty("destinations")]
|
||||
public List<eSourceListItemDestinationTypes> Destinations { get; set; }
|
||||
/// <summary>
|
||||
/// A means to reference a source list for this source item, in the event that this source has an input that can have sources routed to it
|
||||
/// </summary>
|
||||
[JsonProperty("sourceListKey")]
|
||||
public string SourceListKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if the device associated with this source is controllable
|
||||
/// </summary>
|
||||
[JsonProperty("isControllable")]
|
||||
public bool IsControllable { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the device associated with this source has audio available
|
||||
/// </summary>
|
||||
[JsonProperty("isAudioSource")]
|
||||
public bool IsAudioSource { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Hide source on UI when Avanced Sharing is enabled
|
||||
/// </summary>
|
||||
[JsonProperty("disableAdvancedRouting")]
|
||||
public bool DisableAdvancedRouting { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Hide source on UI when Simpl Sharing is enabled
|
||||
/// </summary>
|
||||
[JsonProperty("disableSimpleRouting")]
|
||||
public bool DisableSimpleRouting { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The key of the device that provides video sync for this source item
|
||||
/// </summary>
|
||||
[JsonProperty("syncProviderDeviceKey")]
|
||||
public string SyncProviderDeviceKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if the source supports USB connections
|
||||
/// </summary>
|
||||
[JsonProperty("supportsUsb")]
|
||||
public bool SupportsUsb { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The key of the source port associated with this source item
|
||||
/// This is used to identify the specific port on the source device that this item refers to for advanced routing
|
||||
/// </summary>
|
||||
[JsonProperty("sourcePortKey")]
|
||||
public string SourcePortKey { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor for SourceListItem, initializes the Icon to "Blank"
|
||||
/// </summary>
|
||||
public SourceListItem()
|
||||
{
|
||||
Icon = "Blank";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string representation of the SourceListItem, including the SourceKey and Name
|
||||
/// </summary>
|
||||
/// <returns> A string representation of the SourceListItem</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{SourceKey}:{Name}";
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a route in a source list item, which defines the source and destination keys and the type of signal being routed
|
||||
/// A name that will override the source's name on the UI
|
||||
/// </summary>
|
||||
public class SourceRouteListItem
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Specifies and icon for the source list item
|
||||
/// </summary>
|
||||
[JsonProperty("icon")]
|
||||
public string Icon { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Alternate icon
|
||||
/// </summary>
|
||||
[JsonProperty("altIcon")]
|
||||
public string AltIcon { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if the item should be included in the source list
|
||||
/// </summary>
|
||||
[JsonProperty("includeInSourceList")]
|
||||
public bool IncludeInSourceList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Used to specify the order of the items in the source list when displayed
|
||||
/// </summary>
|
||||
[JsonProperty("order")]
|
||||
public int Order { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The key of the device for volume control
|
||||
/// </summary>
|
||||
[JsonProperty("volumeControlKey")]
|
||||
public string VolumeControlKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The type of source list item
|
||||
/// </summary>
|
||||
[JsonProperty("type")]
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public eSourceListItemType Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The list of routes to execute for this source list item
|
||||
/// </summary>
|
||||
[JsonProperty("routeList")]
|
||||
public List<SourceRouteListItem> RouteList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if this source should be disabled for sharing to the far end call participants via codec content
|
||||
/// </summary>
|
||||
[JsonProperty("disableCodecSharing")]
|
||||
public bool DisableCodecSharing { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if this source should be disabled for routing to a shared output
|
||||
/// </summary>
|
||||
[JsonProperty("disableRoutedSharing")]
|
||||
public bool DisableRoutedSharing { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A means to reference a source list for this source item, in the event that this source has an input that can have sources routed to it
|
||||
/// </summary>
|
||||
[JsonProperty("sourceListKey")]
|
||||
public string SourceListKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if the device associated with this source is controllable
|
||||
/// </summary>
|
||||
[JsonProperty("isControllable")]
|
||||
public bool IsControllable { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the device associated with this source has audio available
|
||||
/// </summary>
|
||||
[JsonProperty("isAudioSource")]
|
||||
public bool IsAudioSource { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Hide source on UI when Avanced Sharing is enabled
|
||||
/// </summary>
|
||||
[JsonProperty("disableAdvancedRouting")]
|
||||
public bool DisableAdvancedRouting { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Hide source on UI when Simpl Sharing is enabled
|
||||
/// </summary>
|
||||
[JsonProperty("disableSimpleRouting")]
|
||||
public bool DisableSimpleRouting { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The key of the device that provides video sync for this source item
|
||||
/// </summary>
|
||||
[JsonProperty("syncProviderDeviceKey")]
|
||||
public string SyncProviderDeviceKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if the source supports USB connections
|
||||
/// </summary>
|
||||
[JsonProperty("supportsUsb")]
|
||||
public bool SupportsUsb { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The key of the source port associated with this source item
|
||||
/// This is used to identify the specific port on the source device that this item refers to for advanced routing
|
||||
/// </summary>
|
||||
[JsonProperty("sourcePortKey")]
|
||||
public string SourcePortKey { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor for SourceListItem, initializes the Icon to "Blank"
|
||||
/// </summary>
|
||||
public SourceListItem()
|
||||
{
|
||||
/// <summary>
|
||||
/// The key of the source device to route from
|
||||
/// </summary>
|
||||
[JsonProperty("sourceKey")]
|
||||
public string SourceKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The key of the source port to route from
|
||||
/// </summary>
|
||||
[JsonProperty("sourcePortKey")]
|
||||
public string SourcePortKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The key of the destination device to route to
|
||||
/// </summary>
|
||||
[JsonProperty("destinationKey")]
|
||||
public string DestinationKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The key of the destination port to route to
|
||||
/// </summary>
|
||||
[JsonProperty("destinationPortKey")]
|
||||
public string DestinationPortKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The type of signal being routed, such as audio or video
|
||||
/// </summary>
|
||||
[JsonProperty("type")]
|
||||
public eRoutingSignalType Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Key for a destination list item. If BOTH SourceListItemKey AND DestinationListItemKey are defined,
|
||||
/// then the direct route method should be used.
|
||||
/// </summary>
|
||||
[JsonProperty("destinationListItemKey", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public string DestinationListItemKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Key for a source list item. If BOTH SourceListItemKey AND DestinationListItemKey are defined,
|
||||
/// then the direct route method should be used.
|
||||
/// </summary>
|
||||
[JsonProperty("sourceListItemKey", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public string SourceListItemKey { get; set; }
|
||||
Icon = "Blank";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the valid destination types for SourceListItems in a room
|
||||
/// Returns a string representation of the SourceListItem, including the SourceKey and Name
|
||||
/// </summary>
|
||||
[Obsolete]
|
||||
public enum eSourceListItemDestinationTypes
|
||||
/// <returns> A string representation of the SourceListItem</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
/// <summary>
|
||||
/// Default display, used for the main video output in a room
|
||||
/// </summary>
|
||||
defaultDisplay,
|
||||
/// <summary>
|
||||
/// Left display
|
||||
/// </summary>
|
||||
leftDisplay,
|
||||
/// <summary>
|
||||
/// Right display
|
||||
/// </summary>
|
||||
rightDisplay,
|
||||
/// <summary>
|
||||
/// Center display
|
||||
/// </summary>
|
||||
centerDisplay,
|
||||
/// <summary>
|
||||
/// Program audio, used for the main audio output in a room
|
||||
/// </summary>
|
||||
programAudio,
|
||||
/// <summary>
|
||||
/// Codec content, used for sharing content to the far end in a video call
|
||||
/// </summary>
|
||||
codecContent,
|
||||
/// <summary>
|
||||
/// Front left display, used for rooms with multiple displays
|
||||
/// </summary>
|
||||
frontLeftDisplay,
|
||||
/// <summary>
|
||||
/// Front right display, used for rooms with multiple displays
|
||||
/// </summary>
|
||||
frontRightDisplay,
|
||||
/// <summary>
|
||||
/// Rear left display, used for rooms with multiple displays
|
||||
/// </summary>
|
||||
rearLeftDisplay,
|
||||
/// <summary>
|
||||
/// Rear right display, used for rooms with multiple displays
|
||||
/// </summary>
|
||||
rearRightDisplay,
|
||||
/// <summary>
|
||||
/// Auxiliary display 1, used for additional displays in a room
|
||||
/// </summary>
|
||||
auxDisplay1,
|
||||
/// <summary>
|
||||
/// Auxiliary display 2, used for additional displays in a room
|
||||
/// </summary>
|
||||
auxDisplay2,
|
||||
/// <summary>
|
||||
/// Auxiliary display 3, used for additional displays in a room
|
||||
/// </summary>
|
||||
auxDisplay3,
|
||||
/// <summary>
|
||||
/// Auxiliary display 4, used for additional displays in a room
|
||||
/// </summary>
|
||||
auxDisplay4,
|
||||
/// <summary>
|
||||
/// Auxiliary display 5, used for additional displays in a room
|
||||
/// </summary>
|
||||
auxDisplay5,
|
||||
/// <summary>
|
||||
/// Auxiliary display 6, used for additional displays in a room
|
||||
/// </summary>
|
||||
auxDisplay6,
|
||||
/// <summary>
|
||||
/// Auxiliary display 7, used for additional displays in a room
|
||||
/// </summary>
|
||||
auxDisplay7,
|
||||
/// <summary>
|
||||
/// Auxiliary display 8, used for additional displays in a room
|
||||
/// </summary>
|
||||
auxDisplay8,
|
||||
/// <summary>
|
||||
/// Auxiliary display 9, used for additional displays in a room
|
||||
/// </summary>
|
||||
auxDisplay9,
|
||||
/// <summary>
|
||||
/// Auxiliary display 10, used for additional displays in a room
|
||||
/// </summary>
|
||||
auxDisplay10,
|
||||
return $"{SourceKey}:{Name}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a route in a source list item, which defines the source and destination keys and the type of signal being routed
|
||||
/// </summary>
|
||||
public class SourceRouteListItem
|
||||
{
|
||||
/// <summary>
|
||||
/// The key of the source device to route from
|
||||
/// </summary>
|
||||
[JsonProperty("sourceKey")]
|
||||
public string SourceKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The key of the source port to route from
|
||||
/// </summary>
|
||||
[JsonProperty("sourcePortKey")]
|
||||
public string SourcePortKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The key of the destination device to route to
|
||||
/// </summary>
|
||||
[JsonProperty("destinationKey")]
|
||||
public string DestinationKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The key of the destination port to route to
|
||||
/// </summary>
|
||||
[JsonProperty("destinationPortKey")]
|
||||
public string DestinationPortKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The type of signal being routed, such as audio or video
|
||||
/// </summary>
|
||||
[JsonProperty("type")]
|
||||
public eRoutingSignalType Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Key for a destination list item. If BOTH SourceListItemKey AND DestinationListItemKey are defined,
|
||||
/// then the direct route method should be used.
|
||||
/// </summary>
|
||||
[JsonProperty("destinationListItemKey", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public string DestinationListItemKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Key for a source list item. If BOTH SourceListItemKey AND DestinationListItemKey are defined,
|
||||
/// then the direct route method should be used.
|
||||
/// </summary>
|
||||
[JsonProperty("sourceListItemKey", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public string SourceListItemKey { get; set; }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
namespace PepperDash.Essentials.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
|
@ -58,4 +51,3 @@ namespace PepperDash.Essentials.Core
|
|||
/// </summary>
|
||||
DidChange
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
using System;
|
||||
|
||||
namespace PepperDash.Essentials.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the eSourceListItemDestinationTypes enumeration, which represents the various destination types for source list items in a room control system.
|
||||
/// This enumeration is marked as obsolete, indicating that it may be removed in future versions and should not be used in new development.
|
||||
/// Each member of the enumeration corresponds to a specific type of display or audio output commonly found in room control systems,
|
||||
/// such as default displays, program audio, codec content, and auxiliary displays.
|
||||
/// </summary>
|
||||
[Obsolete]
|
||||
public enum eSourceListItemDestinationTypes
|
||||
{
|
||||
/// <summary>
|
||||
/// Default display, used for the main video output in a room
|
||||
/// </summary>
|
||||
defaultDisplay,
|
||||
/// <summary>
|
||||
/// Left display
|
||||
/// </summary>
|
||||
leftDisplay,
|
||||
/// <summary>
|
||||
/// Right display
|
||||
/// </summary>
|
||||
rightDisplay,
|
||||
/// <summary>
|
||||
/// Center display
|
||||
/// </summary>
|
||||
centerDisplay,
|
||||
/// <summary>
|
||||
/// Program audio, used for the main audio output in a room
|
||||
/// </summary>
|
||||
programAudio,
|
||||
/// <summary>
|
||||
/// Codec content, used for sharing content to the far end in a video call
|
||||
/// </summary>
|
||||
codecContent,
|
||||
/// <summary>
|
||||
/// Front left display, used for rooms with multiple displays
|
||||
/// </summary>
|
||||
frontLeftDisplay,
|
||||
/// <summary>
|
||||
/// Front right display, used for rooms with multiple displays
|
||||
/// </summary>
|
||||
frontRightDisplay,
|
||||
/// <summary>
|
||||
/// Rear left display, used for rooms with multiple displays
|
||||
/// </summary>
|
||||
rearLeftDisplay,
|
||||
/// <summary>
|
||||
/// Rear right display, used for rooms with multiple displays
|
||||
/// </summary>
|
||||
rearRightDisplay,
|
||||
/// <summary>
|
||||
/// Auxiliary display 1, used for additional displays in a room
|
||||
/// </summary>
|
||||
auxDisplay1,
|
||||
/// <summary>
|
||||
/// Auxiliary display 2, used for additional displays in a room
|
||||
/// </summary>
|
||||
auxDisplay2,
|
||||
/// <summary>
|
||||
/// Auxiliary display 3, used for additional displays in a room
|
||||
/// </summary>
|
||||
auxDisplay3,
|
||||
/// <summary>
|
||||
/// Auxiliary display 4, used for additional displays in a room
|
||||
/// </summary>
|
||||
auxDisplay4,
|
||||
/// <summary>
|
||||
/// Auxiliary display 5, used for additional displays in a room
|
||||
/// </summary>
|
||||
auxDisplay5,
|
||||
/// <summary>
|
||||
/// Auxiliary display 6, used for additional displays in a room
|
||||
/// </summary>
|
||||
auxDisplay6,
|
||||
/// <summary>
|
||||
/// Auxiliary display 7, used for additional displays in a room
|
||||
/// </summary>
|
||||
auxDisplay7,
|
||||
/// <summary>
|
||||
/// Auxiliary display 8, used for additional displays in a room
|
||||
/// </summary>
|
||||
auxDisplay8,
|
||||
/// <summary>
|
||||
/// Auxiliary display 9, used for additional displays in a room
|
||||
/// </summary>
|
||||
auxDisplay9,
|
||||
/// <summary>
|
||||
/// Auxiliary display 10, used for additional displays in a room
|
||||
/// </summary>
|
||||
auxDisplay10,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue