diff --git a/PepperDashEssentials/Bridges/JoinMaps/DmRmcControllerJoinMap.cs b/PepperDashEssentials/Bridges/JoinMaps/DmRmcControllerJoinMap.cs index 7e1534bf..3d7cec8d 100644 --- a/PepperDashEssentials/Bridges/JoinMaps/DmRmcControllerJoinMap.cs +++ b/PepperDashEssentials/Bridges/JoinMaps/DmRmcControllerJoinMap.cs @@ -38,8 +38,12 @@ namespace PepperDash.Essentials.Bridges /// Reports the EDID serial number value /// public uint EdidSerialNumber { get; set; } - #endregion - + #endregion + + #region Analogs + public uint AudioVideoSource { get; set; } + #endregion + public DmRmcControllerJoinMap() { // Digital @@ -51,6 +55,9 @@ namespace PepperDash.Essentials.Bridges EdidName = 3; EdidPrefferedTiming = 4; EdidSerialNumber = 5; + + //Analog + AudioVideoSource = 1; } public override void OffsetJoinNumbers(uint joinStart) @@ -62,7 +69,8 @@ namespace PepperDash.Essentials.Bridges EdidManufacturer = EdidManufacturer + joinOffset; EdidName = EdidName + joinOffset; EdidPrefferedTiming = EdidPrefferedTiming + joinOffset; - EdidSerialNumber = EdidSerialNumber + joinOffset; + EdidSerialNumber = EdidSerialNumber + joinOffset; + AudioVideoSource = AudioVideoSource + joinOffset; } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DisplayControllerJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DisplayControllerJoinMap.cs index c2fe8573..a57c35e8 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DisplayControllerJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DisplayControllerJoinMap.cs @@ -1,117 +1,77 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using PepperDash.Essentials.Core; - -namespace PepperDash.Essentials.Core.Bridges -{ - public class DisplayControllerJoinMap : JoinMapBase - { - #region Digitals - /// - /// Turns the display off and reports power off feedback - /// - public uint PowerOff { get; set; } - /// - /// Turns the display on and repots power on feedback - /// - public uint PowerOn { get; set; } - /// - /// Indicates that the display device supports two way communication when high - /// - public uint IsTwoWayDisplay { get; set; } - /// - /// Increments the volume while high - /// - public uint VolumeUp { get; set; } - /// - /// Decrements teh volume while high - /// - public uint VolumeDown { get; set; } - /// - /// Toggles the mute state. Feedback is high when volume is muted - /// - public uint VolumeMute { get; set; } - /// - /// Range of digital joins to select inputs and report current input as feedback - /// - public uint InputSelectOffset { get; set; } - /// - /// Range of digital joins to report visibility for input buttons - /// - public uint ButtonVisibilityOffset { get; set; } - /// - /// High if the device is online - /// - public uint IsOnline { get; set; } - #endregion - - #region Analogs - /// - /// Analog join to set the input and report current input as feedback - /// - public uint InputSelect { get; set; } - /// - /// Sets the volume level and reports the current level as feedback - /// - public uint VolumeLevel { get; set; } - #endregion - - #region Serials - /// - /// Reports the name of the display as defined in config as feedback - /// - public uint Name { get; set; } - /// - /// Range of serial joins that reports the names of the inputs as feedback - /// - public uint InputNamesOffset { get; set; } - #endregion - - public DisplayControllerJoinMap() - { - // Digital - IsOnline = 50; - PowerOff = 1; - PowerOn = 2; - IsTwoWayDisplay = 3; - VolumeUp = 5; - VolumeDown = 6; - VolumeMute = 7; - - ButtonVisibilityOffset = 40; - InputSelectOffset = 10; - - // Analog - InputSelect = 11; - VolumeLevel = 5; - - // Serial - Name = 1; - InputNamesOffset = 10; - } - - public override void OffsetJoinNumbers(uint joinStart) - { - var joinOffset = joinStart - 1; - - IsOnline = IsOnline + joinOffset; - PowerOff = PowerOff + joinOffset; - PowerOn = PowerOn + joinOffset; - IsTwoWayDisplay = IsTwoWayDisplay + joinOffset; - ButtonVisibilityOffset = ButtonVisibilityOffset + joinOffset; - Name = Name + joinOffset; - InputNamesOffset = InputNamesOffset + joinOffset; - InputSelectOffset = InputSelectOffset + joinOffset; - - InputSelect = InputSelect + joinOffset; - - VolumeUp = VolumeUp + joinOffset; - VolumeDown = VolumeDown + joinOffset; - VolumeMute = VolumeMute + joinOffset; - VolumeLevel = VolumeLevel + joinOffset; - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.Core.Bridges +{ + public class DisplayControllerJoinMap : JoinMapBaseAdvanced + { + [JoinName("Name")] + public JoinDataComplete Name = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata() { Label = "Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("PowerOff")] + public JoinDataComplete PowerOff = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata() { Label = "Power Off", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("PowerOn")] + public JoinDataComplete PowerOn = new JoinDataComplete(new JoinData() { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata() { Label = "Power On", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("IsTwoWayDisplay")] + public JoinDataComplete IsTwoWayDisplay = new JoinDataComplete(new JoinData() { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata() { Label = "Is Two Way Display", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("VolumeUp")] + public JoinDataComplete VolumeUp = new JoinDataComplete(new JoinData() { JoinNumber = 5, JoinSpan = 1 }, + new JoinMetadata() { Label = "Volume Up", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("VolumeLevel")] + public JoinDataComplete VolumeLevel = new JoinDataComplete(new JoinData() { JoinNumber = 5, JoinSpan = 1 }, + new JoinMetadata() { Label = "Volume Level", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("VolumeDown")] + public JoinDataComplete VolumeDown = new JoinDataComplete(new JoinData() { JoinNumber = 6, JoinSpan = 1 }, + new JoinMetadata() { Label = "Volume Down", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("VolumeMute")] + public JoinDataComplete VolumeMute = new JoinDataComplete(new JoinData() { JoinNumber = 7, JoinSpan = 1 }, + new JoinMetadata() { Label = "Volume Mute", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("VolumeMuteOn")] + public JoinDataComplete VolumeMuteOn = new JoinDataComplete(new JoinData() { JoinNumber = 8, JoinSpan = 1 }, + new JoinMetadata() { Label = "Volume Mute On", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("VolumeMuteOff")] + public JoinDataComplete VolumeMuteOff = new JoinDataComplete(new JoinData() { JoinNumber = 9, JoinSpan = 1 }, + new JoinMetadata() { Label = "Volume Mute Off", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("InputSelectOffset")] + public JoinDataComplete InputSelectOffset = new JoinDataComplete(new JoinData() { JoinNumber = 11, JoinSpan = 10 }, + new JoinMetadata() { Label = "Input Select", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("InputNamesOffset")] + public JoinDataComplete InputNamesOffset = new JoinDataComplete(new JoinData() { JoinNumber = 11, JoinSpan = 10 }, + new JoinMetadata() { Label = "Input Names Offset", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("InputSelect")] + public JoinDataComplete InputSelect = new JoinDataComplete(new JoinData() { JoinNumber = 11, JoinSpan = 1 }, + new JoinMetadata() { Label = "Input Select", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("ButtonVisibilityOffset")] + public JoinDataComplete ButtonVisibilityOffset = new JoinDataComplete(new JoinData() { JoinNumber = 41, JoinSpan = 10 }, + new JoinMetadata() { Label = "Button Visibility Offset", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.DigitalSerial }); + + [JoinName("IsOnline")] + public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData() { JoinNumber = 50, JoinSpan = 1 }, + new JoinMetadata() { Label = "Is Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + public DisplayControllerJoinMap(uint joinStart) + : base(joinStart, typeof(CameraControllerJoinMap)) + { + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmRmcControllerJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmRmcControllerJoinMap.cs index 0bdedbbf..94b9396b 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmRmcControllerJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmRmcControllerJoinMap.cs @@ -37,31 +37,39 @@ namespace PepperDash.Essentials.Core.Bridges /// Reports the EDID serial number value /// public uint EdidSerialNumber { get; set; } - #endregion - - public DmRmcControllerJoinMap() - { - // Digital - IsOnline = 1; - - // Serial - CurrentOutputResolution = 1; - EdidManufacturer = 2; - EdidName = 3; - EdidPrefferedTiming = 4; - EdidSerialNumber = 5; - } - - public override void OffsetJoinNumbers(uint joinStart) - { - var joinOffset = joinStart - 1; - - IsOnline = IsOnline + joinOffset; - CurrentOutputResolution = CurrentOutputResolution + joinOffset; - EdidManufacturer = EdidManufacturer + joinOffset; - EdidName = EdidName + joinOffset; - EdidPrefferedTiming = EdidPrefferedTiming + joinOffset; - EdidSerialNumber = EdidSerialNumber + joinOffset; - } + #endregion + + #region Analogs + public uint AudioVideoSource { get; set; } + #endregion + + public DmRmcControllerJoinMap() + { + // Digital + IsOnline = 1; + + // Serial + CurrentOutputResolution = 1; + EdidManufacturer = 2; + EdidName = 3; + EdidPrefferedTiming = 4; + EdidSerialNumber = 5; + + //Analog + AudioVideoSource = 1; + } + + public override void OffsetJoinNumbers(uint joinStart) + { + var joinOffset = joinStart - 1; + + IsOnline = IsOnline + joinOffset; + CurrentOutputResolution = CurrentOutputResolution + joinOffset; + EdidManufacturer = EdidManufacturer + joinOffset; + EdidName = EdidName + joinOffset; + EdidPrefferedTiming = EdidPrefferedTiming + joinOffset; + EdidSerialNumber = EdidSerialNumber + joinOffset; + AudioVideoSource = AudioVideoSource + joinOffset; + } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs index 3669738e..612ace4f 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs @@ -1,67 +1,42 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using PepperDash.Essentials.Core; - -namespace PepperDash.Essentials.Core.Bridges -{ - public class IBasicCommunicationJoinMap : JoinMapBase - { - #region Digitals - /// - /// Set High to connect, Low to disconnect - /// - public uint Connect { get; set; } - /// - /// Reports Connected State (High = Connected) - /// - public uint Connected { get; set; } - #endregion - - #region Analogs - /// - /// Reports the connections status value - /// - public uint Status { get; set; } - #endregion - - #region Serials - /// - /// Data back from port - /// - public uint TextReceived { get; set; } - /// - /// Sends data to the port - /// - public uint SendText { get; set; } - /// - /// Takes a JSON serialized string that sets a COM port's parameters - /// - public uint SetPortConfig { get; set; } - #endregion - - public IBasicCommunicationJoinMap() - { - TextReceived = 1; - SendText = 1; - SetPortConfig = 2; - Connect = 1; - Connected = 1; - Status = 1; - } - - public override void OffsetJoinNumbers(uint joinStart) - { - var joinOffset = joinStart - 1; - - TextReceived = TextReceived + joinOffset; - SendText = SendText + joinOffset; - SetPortConfig = SetPortConfig + joinOffset; - Connect = Connect + joinOffset; - Connected = Connected + joinOffset; - Status = Status + joinOffset; - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.Core.Bridges +{ + public class IBasicCommunicationJoinMap : JoinMapBaseAdvanced + { + [JoinName("TextReceived")] + public JoinDataComplete TextReceived = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata() { Label = "Text Received From Remote Device", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("SendText")] + public JoinDataComplete SendText = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata() { Label = "Text Sent To Remote Device", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("SetPortConfig")] + public JoinDataComplete SetPortConfig = new JoinDataComplete(new JoinData() { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata() { Label = "Set Port Config", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("Connect")] + public JoinDataComplete Connect = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata() { Label = "Connect", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Connected")] + public JoinDataComplete Connected = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata() { Label = "Connected", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Status")] + public JoinDataComplete Status = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata() { Label = "Status", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + + public IBasicCommunicationJoinMap(uint joinStart) + : base(joinStart, typeof(IBasicCommunicationJoinMap)) + { + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Comm and IR/GenericComm.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Comm and IR/GenericComm.cs index 41438832..523ffb78 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Comm and IR/GenericComm.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Comm and IR/GenericComm.cs @@ -1,125 +1,124 @@ -using System; -using System.Collections.Generic; -using Crestron.SimplSharp.CrestronSockets; -using Crestron.SimplSharpPro.DeviceSupport; -using Newtonsoft.Json; - -using PepperDash.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Devices; -using PepperDash.Essentials.Core.Config; - - -namespace PepperDash.Essentials.Core -{ - /// - /// Serves as a generic wrapper class for all styles of IBasicCommuncation ports - /// - [Description("Generic communication wrapper class for any IBasicCommunication type")] - public class GenericComm : ReconfigurableBridgableDevice - { - EssentialsControlPropertiesConfig PropertiesConfig; - - public IBasicCommunication CommPort { get; private set; } - - public GenericComm(DeviceConfig config) - : base(config) - { - PropertiesConfig = CommFactory.GetControlPropertiesConfig(config); - - CommPort = CommFactory.CreateCommForDevice(config); - - } - - public static IKeyed BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); - return new GenericComm(dc); - } - - public void SetPortConfig(string portConfig) - { - // TODO: Deserialize new EssentialsControlPropertiesConfig and handle as necessary - try - { - PropertiesConfig = JsonConvert.DeserializeObject - (portConfig); - } - catch (Exception e) - { - Debug.Console(2, this, "Error deserializing port config: {0}", e); - } - } - - protected override void CustomSetConfig(DeviceConfig config) - { - PropertiesConfig = CommFactory.GetControlPropertiesConfig(config); - - ConfigWriter.UpdateDeviceConfig(config); - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new IBasicCommunicationJoinMap(); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - joinMap.OffsetJoinNumbers(joinStart); - - if (CommPort == null) - { - Debug.Console(1, this, "Unable to link device '{0}'. CommPort is null", Key); - return; - } - - Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - - // this is a permanent event handler. This cannot be -= from event - CommPort.TextReceived += (s, a) => - { - Debug.Console(2, this, "RX: {0}", a.Text); - trilist.SetString(joinMap.TextReceived, a.Text); - }; - trilist.SetStringSigAction(joinMap.SendText, s => CommPort.SendText(s)); - trilist.SetStringSigAction(joinMap.SetPortConfig, SetPortConfig); - - - var sComm = this as ISocketStatus; - if (sComm == null) return; - sComm.ConnectionChange += (s, a) => - { - trilist.SetUshort(joinMap.Status, (ushort)(a.Client.ClientStatus)); - trilist.SetBool(joinMap.Connected, a.Client.ClientStatus == - SocketStatus.SOCKET_STATUS_CONNECTED); - }; - - trilist.SetBoolSigAction(joinMap.Connect, b => - { - if (b) - { - sComm.Connect(); - } - else - { - sComm.Disconnect(); - } - }); - } - } - - public class GenericCommFactory : EssentialsDeviceFactory - { - public GenericCommFactory() - { - TypeNames = new List() { "genericComm" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); - return new GenericComm(dc); - } - } +using System; +using System.Collections.Generic; +using Crestron.SimplSharp.CrestronSockets; +using Crestron.SimplSharpPro.DeviceSupport; +using Newtonsoft.Json; + +using PepperDash.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.Core.Devices; +using PepperDash.Essentials.Core.Config; + + +namespace PepperDash.Essentials.Core +{ + /// + /// Serves as a generic wrapper class for all styles of IBasicCommuncation ports + /// + [Description("Generic communication wrapper class for any IBasicCommunication type")] + public class GenericComm : ReconfigurableBridgableDevice + { + EssentialsControlPropertiesConfig PropertiesConfig; + + public IBasicCommunication CommPort { get; private set; } + + public GenericComm(DeviceConfig config) + : base(config) + { + PropertiesConfig = CommFactory.GetControlPropertiesConfig(config); + + CommPort = CommFactory.CreateCommForDevice(config); + + } + + public static IKeyed BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); + return new GenericComm(dc); + } + + public void SetPortConfig(string portConfig) + { + // TODO: Deserialize new EssentialsControlPropertiesConfig and handle as necessary + try + { + PropertiesConfig = JsonConvert.DeserializeObject + (portConfig); + } + catch (Exception e) + { + Debug.Console(2, this, "Error deserializing port config: {0}", e); + } + } + + protected override void CustomSetConfig(DeviceConfig config) + { + PropertiesConfig = CommFactory.GetControlPropertiesConfig(config); + + ConfigWriter.UpdateDeviceConfig(config); + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = new IBasicCommunicationJoinMap(joinStart); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + if (CommPort == null) + { + Debug.Console(1, this, "Unable to link device '{0}'. CommPort is null", Key); + return; + } + + Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + // this is a permanent event handler. This cannot be -= from event + CommPort.TextReceived += (s, a) => + { + Debug.Console(2, this, "RX: {0}", a.Text); + trilist.SetString(joinMap.TextReceived.JoinNumber, a.Text); + }; + trilist.SetStringSigAction(joinMap.SendText.JoinNumber, s => CommPort.SendText(s)); + trilist.SetStringSigAction(joinMap.SetPortConfig.JoinNumber, SetPortConfig); + + + var sComm = this as ISocketStatus; + if (sComm == null) return; + sComm.ConnectionChange += (s, a) => + { + trilist.SetUshort(joinMap.Status.JoinNumber, (ushort)(a.Client.ClientStatus)); + trilist.SetBool(joinMap.Connected.JoinNumber, a.Client.ClientStatus == + SocketStatus.SOCKET_STATUS_CONNECTED); + }; + + trilist.SetBoolSigAction(joinMap.Connect.JoinNumber, b => + { + if (b) + { + sComm.Connect(); + } + else + { + sComm.Disconnect(); + } + }); + } + } + + public class GenericCommFactory : EssentialsDeviceFactory + { + public GenericCommFactory() + { + TypeNames = new List() { "genericComm" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); + return new GenericComm(dc); + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/DisplayBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/DisplayBase.cs index cf317f40..2dd72340 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/DisplayBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/DisplayBase.cs @@ -18,7 +18,7 @@ namespace PepperDash.Essentials.Core /// /// /// - public abstract class DisplayBase : EssentialsDevice, IHasFeedback, IRoutingSinkWithSwitching, IPower, IWarmingCooling, IUsageTracking + public abstract class DisplayBase : EssentialsBridgeableDevice, IHasFeedback, IRoutingSinkWithSwitching, IPower, IWarmingCooling, IUsageTracking { public event SourceInfoChangeHandler CurrentSourceChange; @@ -121,24 +121,22 @@ namespace PepperDash.Essentials.Core var inputNumber = 0; var inputKeys = new List(); - var joinMap = new DisplayControllerJoinMap(); + var joinMap = new DisplayControllerJoinMap(joinStart); var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); if (!string.IsNullOrEmpty(joinMapSerialized)) joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - joinMap.OffsetJoinNumbers(joinStart); - Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); Debug.Console(0, "Linking to Display: {0}", displayDevice.Name); - trilist.StringInput[joinMap.Name].StringValue = displayDevice.Name; + trilist.StringInput[joinMap.Name.JoinNumber].StringValue = displayDevice.Name; var commMonitor = displayDevice as ICommunicationMonitor; if (commMonitor != null) { - commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); + commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); } var inputNumberFeedback = new IntFeedback(() => inputNumber); @@ -148,16 +146,16 @@ namespace PepperDash.Essentials.Core if (twoWayDisplay != null) { - trilist.SetBool(joinMap.IsTwoWayDisplay, true); + trilist.SetBool(joinMap.IsTwoWayDisplay.JoinNumber, true); twoWayDisplay.CurrentInputFeedback.OutputChange += (o, a) => Debug.Console(0, "CurrentInputFeedback_OutputChange {0}", a.StringValue); - inputNumberFeedback.LinkInputSig(trilist.UShortInput[joinMap.InputSelect]); + inputNumberFeedback.LinkInputSig(trilist.UShortInput[joinMap.InputSelect.JoinNumber]); } // Power Off - trilist.SetSigTrueAction(joinMap.PowerOff, () => + trilist.SetSigTrueAction(joinMap.PowerOff.JoinNumber, () => { inputNumber = 102; inputNumberFeedback.FireUpdate(); @@ -179,10 +177,10 @@ namespace PepperDash.Essentials.Core } }; - displayDevice.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PowerOff]); + displayDevice.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PowerOff.JoinNumber]); // PowerOn - trilist.SetSigTrueAction(joinMap.PowerOn, () => + trilist.SetSigTrueAction(joinMap.PowerOn.JoinNumber, () => { inputNumber = 0; inputNumberFeedback.FireUpdate(); @@ -190,21 +188,27 @@ namespace PepperDash.Essentials.Core }); - displayDevice.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn]); + displayDevice.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn.JoinNumber]); - var count = 1; - foreach (var input in displayDevice.InputPorts) + for (int i = 0; i < displayDevice.InputPorts.Count; i++) { - inputKeys.Add(input.Key); - var tempKey = inputKeys.ElementAt(count - 1); - trilist.SetSigTrueAction((ushort)(joinMap.InputSelectOffset + count), () => displayDevice.ExecuteSwitch(displayDevice.InputPorts[tempKey].Selector)); - Debug.Console(2, displayDevice, "Setting Input Select Action on Digital Join {0} to Input: {1}", joinMap.InputSelectOffset + count, displayDevice.InputPorts[tempKey].Key.ToString()); - trilist.StringInput[(ushort)(joinMap.InputNamesOffset + count)].StringValue = input.Key.ToString(); - count++; + if (i < joinMap.InputNamesOffset.JoinSpan) + { + inputKeys.Add(displayDevice.InputPorts[i].Key); + var tempKey = inputKeys.ElementAt(i); + trilist.SetSigTrueAction((ushort)(joinMap.InputSelectOffset.JoinNumber + i), + () => displayDevice.ExecuteSwitch(displayDevice.InputPorts[tempKey].Selector)); + Debug.Console(2, displayDevice, "Setting Input Select Action on Digital Join {0} to Input: {1}", + joinMap.InputSelectOffset.JoinNumber + i, displayDevice.InputPorts[tempKey].Key.ToString()); + trilist.StringInput[(ushort)(joinMap.InputNamesOffset.JoinNumber + i)].StringValue = displayDevice.InputPorts[i].Key.ToString(); + } + else + Debug.Console(0, displayDevice, Debug.ErrorLogLevel.Warning, "Device has {0} inputs. The Join Map allows up to {1} inputs. Discarding inputs {2} - {3} from bridge.", + displayDevice.InputPorts.Count, joinMap.InputNamesOffset.JoinSpan, i + 1, displayDevice.InputPorts.Count); } Debug.Console(2, displayDevice, "Setting Input Select Action on Analog Join {0}", joinMap.InputSelect); - trilist.SetUShortSigAction(joinMap.InputSelect, (a) => + trilist.SetUShortSigAction(joinMap.InputSelect.JoinNumber, (a) => { if (a == 0) { @@ -229,17 +233,22 @@ namespace PepperDash.Essentials.Core var volumeDisplay = displayDevice as IBasicVolumeControls; if (volumeDisplay == null) return; - trilist.SetBoolSigAction(joinMap.VolumeUp, volumeDisplay.VolumeUp); - trilist.SetBoolSigAction(joinMap.VolumeDown, volumeDisplay.VolumeDown); - trilist.SetSigTrueAction(joinMap.VolumeMute, volumeDisplay.MuteToggle); + trilist.SetBoolSigAction(joinMap.VolumeUp.JoinNumber, volumeDisplay.VolumeUp); + trilist.SetBoolSigAction(joinMap.VolumeDown.JoinNumber, volumeDisplay.VolumeDown); + trilist.SetSigTrueAction(joinMap.VolumeMute.JoinNumber, volumeDisplay.MuteToggle); var volumeDisplayWithFeedback = volumeDisplay as IBasicVolumeWithFeedback; if (volumeDisplayWithFeedback == null) return; + trilist.SetSigTrueAction(joinMap.VolumeMuteOn.JoinNumber, volumeDisplayWithFeedback.MuteOn); + trilist.SetSigTrueAction(joinMap.VolumeMuteOff.JoinNumber, volumeDisplayWithFeedback.MuteOff); - trilist.SetUShortSigAction(joinMap.VolumeLevel, volumeDisplayWithFeedback.SetVolume); - volumeDisplayWithFeedback.VolumeLevelFeedback.LinkInputSig(trilist.UShortInput[joinMap.VolumeLevel]); - volumeDisplayWithFeedback.MuteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VolumeMute]); + + trilist.SetUShortSigAction(joinMap.VolumeLevel.JoinNumber, volumeDisplayWithFeedback.SetVolume); + volumeDisplayWithFeedback.VolumeLevelFeedback.LinkInputSig(trilist.UShortInput[joinMap.VolumeLevel.JoinNumber]); + volumeDisplayWithFeedback.MuteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VolumeMute.JoinNumber]); + volumeDisplayWithFeedback.MuteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VolumeMuteOn.JoinNumber]); + volumeDisplayWithFeedback.MuteFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.VolumeMuteOff.JoinNumber]); } } diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs index 0c642d5c..3b288290 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs @@ -89,6 +89,15 @@ namespace PepperDash.Essentials.Core IntFeedback VideoSourceNumericFeedback { get; } IntFeedback AudioSourceNumericFeedback { get; } void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type); + } + + /// + /// Defines a receiver that has internal routing (DM-RMC-4K-Z-SCALER-C) + /// + public interface IRmcRouting : IRouting + { + IntFeedback AudioVideoSourceNumericFeedback { get; } + void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type); } /// diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZ100CController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZ100CController.cs new file mode 100644 index 00000000..33705c0a --- /dev/null +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZ100CController.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Endpoints; +using Crestron.SimplSharpPro.DM.Endpoints.Receivers; + +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; + +namespace PepperDash.Essentials.DM +{ + public class DmRmc4kZ100CController : DmRmcX100CController + { + private readonly DmRmc4kz100C _rmc; + + public DmRmc4kZ100CController(string key, string name, DmRmc4kz100C rmc) + : base(key, name, rmc) + { + _rmc = rmc; + + /* removed this logic because it's done in the base constructor and doesn't need to be duplicated here + DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.DmCat, 0, this); + HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, null, this) {Port = _rmc}; + */ + + // Set Ports for CEC + + //TODO: We need to look at this class inheritance design...not so sure these properties need to be virtual and/or abstract. + EdidManufacturerFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Manufacturer.StringValue); + EdidNameFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Name.StringValue); + EdidPreferredTimingFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.PreferredTiming.StringValue); + EdidSerialNumberFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.SerialNumber.StringValue); + + _rmc.HdmiOutput.OutputStreamChange += HdmiOutput_OutputStreamChange; + _rmc.HdmiOutput.ConnectedDevice.DeviceInformationChange += ConnectedDevice_DeviceInformationChange; + } + + void HdmiOutput_OutputStreamChange(EndpointOutputStream outputStream, EndpointOutputStreamEventArgs args) + { + if (args.EventId == EndpointOutputStreamEventIds.HorizontalResolutionFeedbackEventId || args.EventId == EndpointOutputStreamEventIds.VerticalResolutionFeedbackEventId || + args.EventId == EndpointOutputStreamEventIds.FramesPerSecondFeedbackEventId) + { + VideoOutputResolutionFeedback.FireUpdate(); + } + } + + void ConnectedDevice_DeviceInformationChange(ConnectedDeviceInformation connectedDevice, ConnectedDeviceEventArgs args) + { + if (args.EventId == ConnectedDeviceEventIds.ManufacturerEventId) + { + EdidManufacturerFeedback.FireUpdate(); + } + else if (args.EventId == ConnectedDeviceEventIds.NameEventId) + { + EdidNameFeedback.FireUpdate(); + } + else if (args.EventId == ConnectedDeviceEventIds.PreferredTimingEventId) + { + EdidPreferredTimingFeedback.FireUpdate(); + } + else if (args.EventId == ConnectedDeviceEventIds.SerialNumberEventId) + { + EdidSerialNumberFeedback.FireUpdate(); + } + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + LinkDmRmcToApi(this, trilist, joinStart, joinMapKey, bridge); + } + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZScalerCController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZScalerCController.cs new file mode 100644 index 00000000..a42b6771 --- /dev/null +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZScalerCController.cs @@ -0,0 +1,151 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Endpoints; +using Crestron.SimplSharpPro.DM.Endpoints.Receivers; + +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Core; + +namespace PepperDash.Essentials.DM +{ + public class DmRmc4kZScalerCController : DmRmcControllerBase, IRmcRouting, + IIROutputPorts, IComPorts, ICec + { + public DmRmc4kzScalerC Rmc { get; private set; } + + public RoutingInputPort DmIn { get; private set; } + public RoutingInputPort HdmiIn { get; private set; } + public RoutingOutputPort HdmiOut { get; private set; } + + /// + /// The value of the current video source for the HDMI output on the receiver + /// + public IntFeedback AudioVideoSourceNumericFeedback { get; private set; } + + public RoutingPortCollection InputPorts + { + get { return new RoutingPortCollection { DmIn, HdmiIn }; } + } + + public RoutingPortCollection OutputPorts + { + get { return new RoutingPortCollection { HdmiOut }; } + } + + public DmRmc4kZScalerCController(string key, string name, DmRmc4kzScalerC rmc) + : base(key, name, rmc) + { + Rmc = rmc; + DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.DmCat, 0, this); + HdmiIn = new RoutingInputPort(DmPortName.HdmiIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, 0, this); + HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, null, this); + + EdidManufacturerFeedback = new StringFeedback(() => Rmc.HdmiOutput.ConnectedDevice.Manufacturer.StringValue); + EdidNameFeedback = new StringFeedback(() => Rmc.HdmiOutput.ConnectedDevice.Name.StringValue); + EdidPreferredTimingFeedback = new StringFeedback(() => Rmc.HdmiOutput.ConnectedDevice.PreferredTiming.StringValue); + EdidSerialNumberFeedback = new StringFeedback(() => Rmc.HdmiOutput.ConnectedDevice.SerialNumber.StringValue); + + VideoOutputResolutionFeedback = new StringFeedback(() => Rmc.HdmiOutput.GetVideoResolutionString()); + + Rmc.HdmiOutput.OutputStreamChange += HdmiOutput_OutputStreamChange; + Rmc.HdmiOutput.ConnectedDevice.DeviceInformationChange += ConnectedDevice_DeviceInformationChange; + + // Set Ports for CEC + HdmiOut.Port = Rmc.HdmiOutput; + + AudioVideoSourceNumericFeedback = new IntFeedback(() => (ushort)(Rmc.SelectedSourceFeedback)); + } + + void HdmiOutput_OutputStreamChange(EndpointOutputStream outputStream, EndpointOutputStreamEventArgs args) + { + if (args.EventId == EndpointOutputStreamEventIds.HorizontalResolutionFeedbackEventId || args.EventId == EndpointOutputStreamEventIds.VerticalResolutionFeedbackEventId || + args.EventId == EndpointOutputStreamEventIds.FramesPerSecondFeedbackEventId) + { + VideoOutputResolutionFeedback.FireUpdate(); + } + + if (args.EventId == EndpointOutputStreamEventIds.SelectedSourceFeedbackEventId) + { + AudioVideoSourceNumericFeedback.FireUpdate(); + } + } + + void ConnectedDevice_DeviceInformationChange(ConnectedDeviceInformation connectedDevice, ConnectedDeviceEventArgs args) + { + if (args.EventId == ConnectedDeviceEventIds.ManufacturerEventId) + { + EdidManufacturerFeedback.FireUpdate(); + } + else if (args.EventId == ConnectedDeviceEventIds.NameEventId) + { + EdidNameFeedback.FireUpdate(); + } + else if (args.EventId == ConnectedDeviceEventIds.PreferredTimingEventId) + { + EdidPreferredTimingFeedback.FireUpdate(); + } + else if (args.EventId == ConnectedDeviceEventIds.SerialNumberEventId) + { + EdidSerialNumberFeedback.FireUpdate(); + } + } + + public override bool CustomActivate() + { + // Base does register and sets up comm monitoring. + return base.CustomActivate(); + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + LinkDmRmcToApi(this, trilist, joinStart, joinMapKey, bridge); + } + + #region IIROutputPorts Members + public CrestronCollection IROutputPorts { get { return Rmc.IROutputPorts; } } + public int NumberOfIROutputPorts { get { return Rmc.NumberOfIROutputPorts; } } + #endregion + + #region IComPorts Members + public CrestronCollection ComPorts { get { return Rmc.ComPorts; } } + public int NumberOfComPorts { get { return Rmc.NumberOfComPorts; } } + #endregion + + #region ICec Members + /// + /// Gets the CEC stream directly from the HDMI port. + /// + public Cec StreamCec { get { return Rmc.HdmiOutput.StreamCec; } } + #endregion + + + #region IRmcRouting Members + public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) + { + Debug.Console(2, this, "Attempting a route from input {0} to HDMI Output", inputSelector); + + var number = Convert.ToUInt16(inputSelector); + + Rmc.AudioVideoSource = (DmRmc4kzScalerC.eAudioVideoSource)number; + } + + public void ExecuteNumericSwitch(ushort inputSelector, ushort outputSelector, eRoutingSignalType signalType) + { + Debug.Console(2, this, "Attempting a route from input {0} to HDMI Output", inputSelector); + + Rmc.AudioVideoSource = (DmRmc4kzScalerC.eAudioVideoSource)inputSelector; + } + #endregion + + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs index da3e587a..91085fca 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs @@ -1,307 +1,326 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Receivers; -using Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.DM.Config; -using PepperDash.Essentials.Core.Config; - -namespace PepperDash.Essentials.DM -{ - [Description("Wrapper class for all DM-RMC variants")] - public abstract class DmRmcControllerBase : CrestronGenericBridgeableBaseDevice - { - public virtual StringFeedback VideoOutputResolutionFeedback { get; protected set; } - public virtual StringFeedback EdidManufacturerFeedback { get; protected set; } - public virtual StringFeedback EdidNameFeedback { get; protected set; } - public virtual StringFeedback EdidPreferredTimingFeedback { get; protected set; } - public virtual StringFeedback EdidSerialNumberFeedback { get; protected set; } - - public DmRmcControllerBase(string key, string name, EndpointReceiverBase device) - : base(key, name, device) - { - // if wired to a chassis, skip registration step in base class - if (device.DMOutput != null) - { - this.PreventRegistration = true; - } - AddToFeedbackList(VideoOutputResolutionFeedback, EdidManufacturerFeedback, EdidSerialNumberFeedback, EdidNameFeedback, EdidPreferredTimingFeedback); - } - - protected void LinkDmRmcToApi(DmRmcControllerBase rmc, BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new DmRmcControllerJoinMap(); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - joinMap.OffsetJoinNumbers(joinStart); - - Debug.Console(1, rmc, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - - rmc.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); - if (rmc.VideoOutputResolutionFeedback != null) - rmc.VideoOutputResolutionFeedback.LinkInputSig(trilist.StringInput[joinMap.CurrentOutputResolution]); - if (rmc.EdidManufacturerFeedback != null) - rmc.EdidManufacturerFeedback.LinkInputSig(trilist.StringInput[joinMap.EdidManufacturer]); - if (rmc.EdidNameFeedback != null) - rmc.EdidNameFeedback.LinkInputSig(trilist.StringInput[joinMap.EdidName]); - if (rmc.EdidPreferredTimingFeedback != null) - rmc.EdidPreferredTimingFeedback.LinkInputSig(trilist.StringInput[joinMap.EdidPrefferedTiming]); - if (rmc.EdidSerialNumberFeedback != null) - rmc.EdidSerialNumberFeedback.LinkInputSig(trilist.StringInput[joinMap.EdidSerialNumber]); - } - } - - public abstract class DmHdBaseTControllerBase : CrestronGenericBaseDevice - { - public HDBaseTBase Rmc { get; protected set; } - - /// - /// Make a Crestron RMC and put it in here - /// - public DmHdBaseTControllerBase(string key, string name, HDBaseTBase rmc) - : base(key, name, rmc) - { - - } - } - - public class DmRmcHelper - { - /// - /// A factory method for various DmTxControllers - /// - /// - /// - /// - /// - public static CrestronGenericBaseDevice GetDmRmcController(string key, string name, string typeName, DmRmcPropertiesConfig props) - { - // switch on type name... later... - - typeName = typeName.ToLower(); - uint ipid = props.Control.IpIdInt; // Convert.ToUInt16(props.Id, 16); - - - - // right here, we need to grab the tie line that associates this - // RMC with a chassis or processor. If the RMC input's tie line is not - // connected to a chassis, then it's parent is the processor. - // If the RMC is connected to a chassis, then we need to grab the - // output number from the tie line and use that to plug it in. - // Example of chassis-connected: - //{ - // "sourceKey": "dmMd8x8-1", - // "sourcePort": "anyOut2", - // "destinationKey": "dmRmc100C-2", - // "destinationPort": "DmIn" - //} - - // Tx -> RMC link: - //{ - // "sourceKey": "dmTx201C-1", - // "sourcePort": "DmOut", - // "destinationKey": "dmRmc100C-2", - // "destinationPort": "DmIn" - //} - - var tlc = TieLineCollection.Default; - // grab the tie line that has this key as - // THIS DOESN'T WORK BECAUSE THE RMC THAT WE NEED (THIS) HASN'T BEEN MADE - // YET AND THUS WILL NOT HAVE A TIE LINE... - var inputTieLine = tlc.FirstOrDefault(t => - { - var d = t.DestinationPort.ParentDevice; - return d.Key.Equals(key, StringComparison.OrdinalIgnoreCase) - && d is DmChassisController; - }); - - var pKey = props.ParentDeviceKey.ToLower(); - - - - - // Non-DM-chassis endpoints - if (pKey == "processor") - { - // Catch constructor failures, mainly dues to IPID - try - { - if (typeName.StartsWith("dmrmc100c")) - return new DmRmcX100CController(key, name, new DmRmc100C(ipid, Global.ControlSystem)); - if (typeName.StartsWith("dmrmc100s")) - return new DmRmc100SController(key, name, new DmRmc100S(ipid, Global.ControlSystem)); - if (typeName.StartsWith("dmrmc4k100c")) - return new DmRmcX100CController(key, name, new DmRmc4k100C(ipid, Global.ControlSystem)); - if (typeName.StartsWith("dmrmc4kz100c")) - return new DmRmcX100CController(key, name, new DmRmc4kz100C(ipid, Global.ControlSystem)); - if (typeName.StartsWith("dmrmc150s")) - return new DmRmc150SController(key, name, new DmRmc150S(ipid, Global.ControlSystem)); - if (typeName.StartsWith("dmrmc200c")) - return new DmRmc200CController(key, name, new DmRmc200C(ipid, Global.ControlSystem)); - if (typeName.StartsWith("dmrmc200s")) - return new DmRmc200SController(key, name, new DmRmc200S(ipid, Global.ControlSystem)); - if (typeName.StartsWith("dmrmc200s2")) - return new DmRmc200S2Controller(key, name, new DmRmc200S2(ipid, Global.ControlSystem)); - if (typeName.StartsWith("dmrmcscalerc")) - return new DmRmcScalerCController(key, name, new DmRmcScalerC(ipid, Global.ControlSystem)); - if (typeName.StartsWith("dmrmcscalers")) - return new DmRmcScalerSController(key, name, new DmRmcScalerS(ipid, Global.ControlSystem)); - if (typeName.StartsWith("dmrmcscalers2")) - return new DmRmcScalerS2Controller(key, name, new DmRmcScalerS2(ipid, Global.ControlSystem)); - if (typeName.StartsWith("dmrmc4kscalerc")) - return new DmRmc4kScalerCController(key, name, new DmRmc4kScalerC(ipid, Global.ControlSystem)); - if (typeName.StartsWith("dmrmc4kscalercdsp")) - return new DmRmc4kScalerCDspController(key, name, new DmRmc4kScalerCDsp(ipid, Global.ControlSystem)); - } - catch (Exception e) - { - Debug.Console(0, "[{0}] WARNING: Cannot create DM-RMC device: {1}", key, e.Message); - } - - - Debug.Console(0, "Cannot create DM-RMC of type: '{0}'", typeName); - } - // Endpoints attached to DM Chassis - else - { - var parentDev = DeviceManager.GetDeviceForKey(pKey); - if (!(parentDev is IDmSwitch)) - { - Debug.Console(0, "Cannot create DM device '{0}'. '{1}' is not a DM Chassis.", - key, pKey); - return null; - } - - var chassis = (parentDev as IDmSwitch).Chassis; - var num = props.ParentOutputNumber; - if (num <= 0 || num > chassis.NumberOfOutputs) - { - Debug.Console(0, "Cannot create DM device '{0}'. Output number '{1}' is out of range", - key, num); - return null; - } - else - { - var controller = (parentDev as IDmSwitch); - controller.RxDictionary.Add(num, key); - } - // Catch constructor failures, mainly dues to IPID - try - { - - // Must use different constructor for CPU3 chassis types. No IPID - if (chassis is DmMd8x8Cpu3 || chassis is DmMd16x16Cpu3 || - chassis is DmMd32x32Cpu3 || chassis is DmMd8x8Cpu3rps || - chassis is DmMd16x16Cpu3rps || chassis is DmMd32x32Cpu3rps || - chassis is DmMd128x128 || chassis is DmMd64x64) - { - if (typeName.StartsWith("hdbasetrx")) - return new HDBaseTRxController(key, name, new HDRx3CB(chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc4k100c1g")) - return new DmRmc4k100C1GController(key, name, new DmRmc4K100C1G(chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc100c")) - return new DmRmcX100CController(key, name, new DmRmc100C(chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc100s")) - return new DmRmc100SController(key, name, new DmRmc100S(chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc4k100c")) - return new DmRmcX100CController(key, name, new DmRmc4k100C(chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc4kz100c")) - return new DmRmcX100CController(key, name, new DmRmc4kz100C(chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc150s")) - return new DmRmc150SController(key, name, new DmRmc150S(chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc200c")) - return new DmRmc200CController(key, name, new DmRmc200C(chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc200s")) - return new DmRmc200SController(key, name, new DmRmc200S(chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc200s2")) - return new DmRmc200S2Controller(key, name, new DmRmc200S2(chassis.Outputs[num])); - if (typeName.StartsWith("dmrmcscalerc")) - return new DmRmcScalerCController(key, name, new DmRmcScalerC(chassis.Outputs[num])); - if (typeName.StartsWith("dmrmcscalers")) - return new DmRmcScalerSController(key, name, new DmRmcScalerS(chassis.Outputs[num])); - if (typeName.StartsWith("dmrmcscalers2")) - return new DmRmcScalerS2Controller(key, name, new DmRmcScalerS2(chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc4kscalerc")) - return new DmRmc4kScalerCController(key, name, new DmRmc4kScalerC(chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc4kscalercdsp")) - return new DmRmc4kScalerCDspController(key, name, new DmRmc4kScalerCDsp(chassis.Outputs[num])); - } - else - { - if (typeName.StartsWith("hdbasetrx")) - return new HDBaseTRxController(key, name, new HDRx3CB(ipid, chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc4k100c1g")) - return new DmRmc4k100C1GController(key, name, new DmRmc4K100C1G(ipid, chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc100c")) - return new DmRmcX100CController(key, name, new DmRmc100C(ipid, chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc100s")) - return new DmRmc100SController(key, name, new DmRmc100S(ipid, chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc4k100c")) - return new DmRmcX100CController(key, name, new DmRmc4k100C(ipid, chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc4kz100c")) - return new DmRmcX100CController(key, name, new DmRmc4kz100C(ipid, chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc150s")) - return new DmRmc150SController(key, name, new DmRmc150S(ipid, chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc200c")) - return new DmRmc200CController(key, name, new DmRmc200C(ipid, chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc200s")) - return new DmRmc200SController(key, name, new DmRmc200S(ipid, chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc200s2")) - return new DmRmc200S2Controller(key, name, new DmRmc200S2(ipid, chassis.Outputs[num])); - if (typeName.StartsWith("dmrmcscalerc")) - return new DmRmcScalerCController(key, name, new DmRmcScalerC(ipid, chassis.Outputs[num])); - if (typeName.StartsWith("dmrmcscalers")) - return new DmRmcScalerSController(key, name, new DmRmcScalerS(ipid, chassis.Outputs[num])); - if (typeName.StartsWith("dmrmcscalers2")) - return new DmRmcScalerS2Controller(key, name, new DmRmcScalerS2(ipid, chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc4kscalerc")) - return new DmRmc4kScalerCController(key, name, new DmRmc4kScalerC(ipid, chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc4kscalercdsp")) - return new DmRmc4kScalerCDspController(key, name, new DmRmc4kScalerCDsp(ipid, chassis.Outputs[num])); - } - } - catch (Exception e) - { - Debug.Console(0, "[{0}] WARNING: Cannot create DM-RMC device: {1}", key, e.Message); - } - } - - return null; - } - } - - public class DmRmcControllerFactory : EssentialsDeviceFactory - { - public DmRmcControllerFactory() - { - TypeNames = new List() { "hdbasetrx", "dmrmc4k100c1g", "dmrmc100c", "dmrmc100s", "dmrmc4k100c", "dmrmc150s", - "dmrmc200c", "dmrmc200s", "dmrmc200s2", "dmrmcscalerc", "dmrmcscalers", "dmrmcscalers2", "dmrmc4kscalerc", "dmrmc4kscalercdsp" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - var type = dc.Type.ToLower(); - - Debug.Console(1, "Factory Attempting to create new DM-RMC Device"); - - var props = JsonConvert.DeserializeObject - (dc.Properties.ToString()); - return PepperDash.Essentials.DM.DmRmcHelper.GetDmRmcController(dc.Key, dc.Name, type, props); - - } - } - +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Endpoints; +using Crestron.SimplSharpPro.DM.Endpoints.Receivers; +using Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.DM.Config; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.DM +{ + [Description("Wrapper class for all DM-RMC variants")] + public abstract class DmRmcControllerBase : CrestronGenericBridgeableBaseDevice + { + public virtual StringFeedback VideoOutputResolutionFeedback { get; protected set; } + public virtual StringFeedback EdidManufacturerFeedback { get; protected set; } + public virtual StringFeedback EdidNameFeedback { get; protected set; } + public virtual StringFeedback EdidPreferredTimingFeedback { get; protected set; } + public virtual StringFeedback EdidSerialNumberFeedback { get; protected set; } + + protected DmRmcControllerBase(string key, string name, EndpointReceiverBase device) + : base(key, name, device) + { + // if wired to a chassis, skip registration step in base class + if (device.DMOutput != null) + { + this.PreventRegistration = true; + } + AddToFeedbackList(VideoOutputResolutionFeedback, EdidManufacturerFeedback, EdidSerialNumberFeedback, EdidNameFeedback, EdidPreferredTimingFeedback); + } + + protected void LinkDmRmcToApi(DmRmcControllerBase rmc, BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = new DmRmcControllerJoinMap(); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + joinMap.OffsetJoinNumbers(joinStart); + + Debug.Console(1, rmc, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + rmc.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); + if (rmc.VideoOutputResolutionFeedback != null) + rmc.VideoOutputResolutionFeedback.LinkInputSig(trilist.StringInput[joinMap.CurrentOutputResolution]); + if (rmc.EdidManufacturerFeedback != null) + rmc.EdidManufacturerFeedback.LinkInputSig(trilist.StringInput[joinMap.EdidManufacturer]); + if (rmc.EdidNameFeedback != null) + rmc.EdidNameFeedback.LinkInputSig(trilist.StringInput[joinMap.EdidName]); + if (rmc.EdidPreferredTimingFeedback != null) + rmc.EdidPreferredTimingFeedback.LinkInputSig(trilist.StringInput[joinMap.EdidPrefferedTiming]); + if (rmc.EdidSerialNumberFeedback != null) + rmc.EdidSerialNumberFeedback.LinkInputSig(trilist.StringInput[joinMap.EdidSerialNumber]); + + //If the device is an DM-RMC-4K-Z-SCALER-C + var routing = rmc as IRmcRouting; + + if (routing != null) + { + if (routing.AudioVideoSourceNumericFeedback != null) + routing.AudioVideoSourceNumericFeedback.LinkInputSig(trilist.UShortInput[joinMap.AudioVideoSource]); + + trilist.SetUShortSigAction(joinMap.AudioVideoSource, (a) => routing.ExecuteNumericSwitch(a, 1, eRoutingSignalType.AudioVideo)); + } + } + } + + public abstract class DmHdBaseTControllerBase : CrestronGenericBaseDevice + { + public HDBaseTBase Rmc { get; protected set; } + + /// + /// Make a Crestron RMC and put it in here + /// + public DmHdBaseTControllerBase(string key, string name, HDBaseTBase rmc) + : base(key, name, rmc) + { + + } + } + + public class DmRmcHelper + { + /// + /// A factory method for various DmTxControllers + /// + /// + /// + /// + /// + public static CrestronGenericBaseDevice GetDmRmcController(string key, string name, string typeName, DmRmcPropertiesConfig props) + { + // switch on type name... later... + + typeName = typeName.ToLower(); + uint ipid = props.Control.IpIdInt; // Convert.ToUInt16(props.Id, 16); + + + + // right here, we need to grab the tie line that associates this + // RMC with a chassis or processor. If the RMC input's tie line is not + // connected to a chassis, then it's parent is the processor. + // If the RMC is connected to a chassis, then we need to grab the + // output number from the tie line and use that to plug it in. + // Example of chassis-connected: + //{ + // "sourceKey": "dmMd8x8-1", + // "sourcePort": "anyOut2", + // "destinationKey": "dmRmc100C-2", + // "destinationPort": "DmIn" + //} + + // Tx -> RMC link: + //{ + // "sourceKey": "dmTx201C-1", + // "sourcePort": "DmOut", + // "destinationKey": "dmRmc100C-2", + // "destinationPort": "DmIn" + //} + + var tlc = TieLineCollection.Default; + // grab the tie line that has this key as + // THIS DOESN'T WORK BECAUSE THE RMC THAT WE NEED (THIS) HASN'T BEEN MADE + // YET AND THUS WILL NOT HAVE A TIE LINE... + var inputTieLine = tlc.FirstOrDefault(t => + { + var d = t.DestinationPort.ParentDevice; + return d.Key.Equals(key, StringComparison.OrdinalIgnoreCase) + && d is DmChassisController; + }); + + var pKey = props.ParentDeviceKey.ToLower(); + + + + + // Non-DM-chassis endpoints + if (pKey == "processor") + { + // Catch constructor failures, mainly dues to IPID + try + { + if (typeName.StartsWith("dmrmc100c")) + return new DmRmcX100CController(key, name, new DmRmc100C(ipid, Global.ControlSystem)); + if (typeName.StartsWith("dmrmc100s")) + return new DmRmc100SController(key, name, new DmRmc100S(ipid, Global.ControlSystem)); + if (typeName.StartsWith("dmrmc4k100c")) + return new DmRmcX100CController(key, name, new DmRmc4k100C(ipid, Global.ControlSystem)); + if (typeName.StartsWith("dmrmc4kz100c")) + return new DmRmc4kZ100CController(key, name, new DmRmc4kz100C(ipid, Global.ControlSystem)); + if (typeName.StartsWith("dmrmc150s")) + return new DmRmc150SController(key, name, new DmRmc150S(ipid, Global.ControlSystem)); + if (typeName.StartsWith("dmrmc200c")) + return new DmRmc200CController(key, name, new DmRmc200C(ipid, Global.ControlSystem)); + if (typeName.StartsWith("dmrmc200s")) + return new DmRmc200SController(key, name, new DmRmc200S(ipid, Global.ControlSystem)); + if (typeName.StartsWith("dmrmc200s2")) + return new DmRmc200S2Controller(key, name, new DmRmc200S2(ipid, Global.ControlSystem)); + if (typeName.StartsWith("dmrmcscalerc")) + return new DmRmcScalerCController(key, name, new DmRmcScalerC(ipid, Global.ControlSystem)); + if (typeName.StartsWith("dmrmcscalers")) + return new DmRmcScalerSController(key, name, new DmRmcScalerS(ipid, Global.ControlSystem)); + if (typeName.StartsWith("dmrmcscalers2")) + return new DmRmcScalerS2Controller(key, name, new DmRmcScalerS2(ipid, Global.ControlSystem)); + if (typeName.StartsWith("dmrmc4kscalerc")) + return new DmRmc4kScalerCController(key, name, new DmRmc4kScalerC(ipid, Global.ControlSystem)); + if (typeName.StartsWith("dmrmc4kscalercdsp")) + return new DmRmc4kScalerCDspController(key, name, new DmRmc4kScalerCDsp(ipid, Global.ControlSystem)); + if (typeName.StartsWith("dmrmc4kzscalerc")) + return new DmRmc4kZScalerCController(key, name, new DmRmc4kzScalerC(ipid, Global.ControlSystem)); + } + catch (Exception e) + { + Debug.Console(0, "[{0}] WARNING: Cannot create DM-RMC device: {1}", key, e.Message); + } + + + Debug.Console(0, "Cannot create DM-RMC of type: '{0}'", typeName); + } + // Endpoints attached to DM Chassis + else + { + var parentDev = DeviceManager.GetDeviceForKey(pKey); + if (!(parentDev is IDmSwitch)) + { + Debug.Console(0, "Cannot create DM device '{0}'. '{1}' is not a DM Chassis.", + key, pKey); + return null; + } + + var chassis = (parentDev as IDmSwitch).Chassis; + var num = props.ParentOutputNumber; + if (num <= 0 || num > chassis.NumberOfOutputs) + { + Debug.Console(0, "Cannot create DM device '{0}'. Output number '{1}' is out of range", + key, num); + return null; + } + else + { + var controller = (parentDev as IDmSwitch); + controller.RxDictionary.Add(num, key); + } + // Catch constructor failures, mainly dues to IPID + try + { + + // Must use different constructor for CPU3 chassis types. No IPID + if (chassis is DmMd8x8Cpu3 || chassis is DmMd16x16Cpu3 || + chassis is DmMd32x32Cpu3 || chassis is DmMd8x8Cpu3rps || + chassis is DmMd16x16Cpu3rps || chassis is DmMd32x32Cpu3rps || + chassis is DmMd128x128 || chassis is DmMd64x64) + { + if (typeName.StartsWith("hdbasetrx")) + return new HDBaseTRxController(key, name, new HDRx3CB(chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc4k100c1g")) + return new DmRmc4k100C1GController(key, name, new DmRmc4K100C1G(chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc100c")) + return new DmRmcX100CController(key, name, new DmRmc100C(chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc100s")) + return new DmRmc100SController(key, name, new DmRmc100S(chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc4k100c")) + return new DmRmcX100CController(key, name, new DmRmc4k100C(chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc4kz100c")) + return new DmRmc4kZ100CController(key, name, new DmRmc4kz100C(chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc150s")) + return new DmRmc150SController(key, name, new DmRmc150S(chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc200c")) + return new DmRmc200CController(key, name, new DmRmc200C(chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc200s")) + return new DmRmc200SController(key, name, new DmRmc200S(chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc200s2")) + return new DmRmc200S2Controller(key, name, new DmRmc200S2(chassis.Outputs[num])); + if (typeName.StartsWith("dmrmcscalerc")) + return new DmRmcScalerCController(key, name, new DmRmcScalerC(chassis.Outputs[num])); + if (typeName.StartsWith("dmrmcscalers")) + return new DmRmcScalerSController(key, name, new DmRmcScalerS(chassis.Outputs[num])); + if (typeName.StartsWith("dmrmcscalers2")) + return new DmRmcScalerS2Controller(key, name, new DmRmcScalerS2(chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc4kscalerc")) + return new DmRmc4kScalerCController(key, name, new DmRmc4kScalerC(chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc4kscalercdsp")) + return new DmRmc4kScalerCDspController(key, name, new DmRmc4kScalerCDsp(chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc4kzscalerc")) + return new DmRmc4kZScalerCController(key, name, new DmRmc4kzScalerC(chassis.Outputs[num])); + } + else + { + if (typeName.StartsWith("hdbasetrx")) + return new HDBaseTRxController(key, name, new HDRx3CB(ipid, chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc4k100c1g")) + return new DmRmc4k100C1GController(key, name, new DmRmc4K100C1G(ipid, chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc100c")) + return new DmRmcX100CController(key, name, new DmRmc100C(ipid, chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc100s")) + return new DmRmc100SController(key, name, new DmRmc100S(ipid, chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc4k100c")) + return new DmRmcX100CController(key, name, new DmRmc4k100C(ipid, chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc4kz100c")) + return new DmRmc4kZ100CController(key, name, new DmRmc4kz100C(ipid, chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc150s")) + return new DmRmc150SController(key, name, new DmRmc150S(ipid, chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc200c")) + return new DmRmc200CController(key, name, new DmRmc200C(ipid, chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc200s")) + return new DmRmc200SController(key, name, new DmRmc200S(ipid, chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc200s2")) + return new DmRmc200S2Controller(key, name, new DmRmc200S2(ipid, chassis.Outputs[num])); + if (typeName.StartsWith("dmrmcscalerc")) + return new DmRmcScalerCController(key, name, new DmRmcScalerC(ipid, chassis.Outputs[num])); + if (typeName.StartsWith("dmrmcscalers")) + return new DmRmcScalerSController(key, name, new DmRmcScalerS(ipid, chassis.Outputs[num])); + if (typeName.StartsWith("dmrmcscalers2")) + return new DmRmcScalerS2Controller(key, name, new DmRmcScalerS2(ipid, chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc4kscalerc")) + return new DmRmc4kScalerCController(key, name, new DmRmc4kScalerC(ipid, chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc4kscalercdsp")) + return new DmRmc4kScalerCDspController(key, name, new DmRmc4kScalerCDsp(ipid, chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc4kzscalerc")) + return new DmRmc4kZScalerCController(key, name, new DmRmc4kzScalerC(chassis.Outputs[num])); + + } + } + catch (Exception e) + { + Debug.Console(0, "[{0}] WARNING: Cannot create DM-RMC device: {1}", key, e.Message); + } + } + + return null; + } + } + + public class DmRmcControllerFactory : EssentialsDeviceFactory + { + public DmRmcControllerFactory() + { + TypeNames = new List() { "hdbasetrx", "dmrmc4k100c1g", "dmrmc100c", "dmrmc100s", "dmrmc4k100c", "dmrmc150s", + "dmrmc200c", "dmrmc200s", "dmrmc200s2", "dmrmcscalerc", "dmrmcscalers", "dmrmcscalers2", "dmrmc4kscalerc", "dmrmc4kscalercdsp", + "dmrmc4kz100c", "dmrmckzscalerc" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + var type = dc.Type.ToLower(); + + Debug.Console(1, "Factory Attempting to create new DM-RMC Device"); + + var props = JsonConvert.DeserializeObject + (dc.Properties.ToString()); + return PepperDash.Essentials.DM.DmRmcHelper.GetDmRmcController(dc.Key, dc.Name, type, props); + + } + } + } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcX100CController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcX100CController.cs index a7260813..16526bc0 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcX100CController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcX100CController.cs @@ -21,10 +21,10 @@ namespace PepperDash.Essentials.DM public class DmRmcX100CController : DmRmcControllerBase, IRoutingInputsOutputs, IIROutputPorts, IComPorts, ICec { - public DmRmc100C Rmc { get; private set; } + public DmRmc100C Rmc { get; protected set; } - public RoutingInputPort DmIn { get; private set; } - public RoutingOutputPort HdmiOut { get; private set; } + public RoutingInputPort DmIn { get; protected set; } + public RoutingOutputPort HdmiOut { get; protected set; } public RoutingPortCollection InputPorts { diff --git a/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj b/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj index 7ab8a5a9..e08b30f6 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj +++ b/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj @@ -100,6 +100,8 @@ + +