From 4d433ebf22314bfdec9aaa7c492156d774e5175f Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Tue, 28 Apr 2020 12:19:23 -0500 Subject: [PATCH 01/14] resolve #130 Add new interface IRmcRouting add DmRmc4kZScalerC endpoint and associated changes to bridge and joinmap add DmRmc4kZScalerCController --- .../Routing/RoutingInterfaces.cs | 7 + .../Receivers/DmRmc4kZScalerCController.cs | 151 ++++++++++++++++++ .../Endpoints/Receivers/DmRmcHelper.cs | 27 +++- 3 files changed, 181 insertions(+), 4 deletions(-) create mode 100644 essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZScalerCController.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs index 0c642d5c..6c3707a7 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs @@ -89,6 +89,13 @@ namespace PepperDash.Essentials.Core IntFeedback VideoSourceNumericFeedback { get; } IntFeedback AudioSourceNumericFeedback { get; } void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type); + } + + 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/DmRmc4kZScalerCController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZScalerCController.cs new file mode 100644 index 00000000..72845c70 --- /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, + IIRInputPort, IComPorts, ICec + { + 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(uint inputSelector, uint 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..ad65b285 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs @@ -37,8 +37,8 @@ namespace PepperDash.Essentials.DM AddToFeedbackList(VideoOutputResolutionFeedback, EdidManufacturerFeedback, EdidSerialNumberFeedback, EdidNameFeedback, EdidPreferredTimingFeedback); } - protected void LinkDmRmcToApi(DmRmcControllerBase rmc, BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { + protected void LinkDmRmcToApi(DmRmcControllerBase rmc, BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { var joinMap = new DmRmcControllerJoinMap(); var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); @@ -61,7 +61,18 @@ namespace PepperDash.Essentials.DM 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 @@ -165,6 +176,8 @@ namespace PepperDash.Essentials.DM 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) { @@ -238,6 +251,8 @@ namespace PepperDash.Essentials.DM 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 { @@ -271,6 +286,9 @@ namespace PepperDash.Essentials.DM 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) @@ -288,7 +306,8 @@ namespace PepperDash.Essentials.DM public DmRmcControllerFactory() { TypeNames = new List() { "hdbasetrx", "dmrmc4k100c1g", "dmrmc100c", "dmrmc100s", "dmrmc4k100c", "dmrmc150s", - "dmrmc200c", "dmrmc200s", "dmrmc200s2", "dmrmcscalerc", "dmrmcscalers", "dmrmcscalers2", "dmrmc4kscalerc", "dmrmc4kscalercdsp" }; + "dmrmc200c", "dmrmc200s", "dmrmc200s2", "dmrmcscalerc", "dmrmcscalers", "dmrmcscalers2", "dmrmc4kscalerc", "dmrmc4kscalercdsp", + "dmrmc4kzscalerc" }; } public override EssentialsDevice BuildDevice(DeviceConfig dc) From 79253c6b31ca7a887b2c41b01ba75876b86d92a7 Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Tue, 28 Apr 2020 12:27:06 -0500 Subject: [PATCH 02/14] Fixed minor Interface Implementation Issues --- .../JoinMaps/DmRmcControllerJoinMap.cs | 14 +- .../JoinMaps/DmRmcControllerJoinMap.cs | 60 ++-- .../Routing/RoutingInterfaces.cs | 6 +- .../Receivers/DmRmc4kZScalerCController.cs | 6 +- .../PepperDash_Essentials_DM.csproj | 317 +++++++++--------- 5 files changed, 211 insertions(+), 192 deletions(-) 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/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/Routing/RoutingInterfaces.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs index 6c3707a7..3b288290 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs @@ -91,11 +91,13 @@ namespace PepperDash.Essentials.Core 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); - + void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type); } /// diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZScalerCController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZScalerCController.cs index 72845c70..a42b6771 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZScalerCController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZScalerCController.cs @@ -16,9 +16,9 @@ using PepperDash.Core; namespace PepperDash.Essentials.DM { public class DmRmc4kZScalerCController : DmRmcControllerBase, IRmcRouting, - IIRInputPort, IComPorts, ICec + IIROutputPorts, IComPorts, ICec { - DmRmc4kzScalerC Rmc { get; private set; } + public DmRmc4kzScalerC Rmc { get; private set; } public RoutingInputPort DmIn { get; private set; } public RoutingInputPort HdmiIn { get; private set; } @@ -139,7 +139,7 @@ namespace PepperDash.Essentials.DM Rmc.AudioVideoSource = (DmRmc4kzScalerC.eAudioVideoSource)number; } - public void ExecuteNumericSwitch(uint inputSelector, uint outputSelector, eRoutingSignalType signalType) + public void ExecuteNumericSwitch(ushort inputSelector, ushort outputSelector, eRoutingSignalType signalType) { Debug.Console(2, this, "Attempting a route from input {0} to HDMI Output", inputSelector); 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 f8ea57a9..c32d3597 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj +++ b/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj @@ -1,159 +1,160 @@ - - - Release - AnyCPU - 9.0.30729 - 2.0 - {9199CE8A-0C9F-4952-8672-3EED798B284F} - Library - Properties - PepperDash_Essentials_DM - PepperDash_Essentials_DM - {0B4745B0-194B-4BB6-8E21-E9057CA92300};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - WindowsCE - E2BECB1F-8C8C-41ba-B736-9BE7D946A398 - 5.0 - SmartDeviceProject1 - v3.5 - Windows CE - - - - - .allowedReferenceRelatedFileExtensions - true - full - false - bin\ - DEBUG;TRACE; - prompt - 4 - 512 - true - true - off - - - .allowedReferenceRelatedFileExtensions - none - true - bin\ - prompt - 4 - 512 - true - true - off - - - - False - ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll - - - False - ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DM.dll - - - False - ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll - - - - False - ..\..\pepperdashcore-builds\PepperDash_Core.dll - - - False - ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll - False - - - False - ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll - False - - - False - ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpNewtonsoft.dll - - - False - ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe - False - - - False - ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpReflectionInterface.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} - PepperDash_Essentials_Core - - - - - - - - - rem S# Pro preparation will execute after these operations - + + + Release + AnyCPU + 9.0.30729 + 2.0 + {9199CE8A-0C9F-4952-8672-3EED798B284F} + Library + Properties + PepperDash_Essentials_DM + PepperDash_Essentials_DM + {0B4745B0-194B-4BB6-8E21-E9057CA92300};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + WindowsCE + E2BECB1F-8C8C-41ba-B736-9BE7D946A398 + 5.0 + SmartDeviceProject1 + v3.5 + Windows CE + + + + + .allowedReferenceRelatedFileExtensions + true + full + false + bin\ + DEBUG;TRACE; + prompt + 4 + 512 + true + true + off + + + .allowedReferenceRelatedFileExtensions + none + true + bin\ + prompt + 4 + 512 + true + true + off + + + + False + ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll + + + False + ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DM.dll + + + False + ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll + + + + False + ..\..\pepperdashcore-builds\PepperDash_Core.dll + + + False + ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll + False + + + False + ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll + False + + + False + ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpNewtonsoft.dll + + + False + ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe + False + + + False + ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpReflectionInterface.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} + PepperDash_Essentials_Core + + + + + + + + + rem S# Pro preparation will execute after these operations + \ No newline at end of file From 531c37c7528e463b8ebcbca34cb65e193e006f85 Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Tue, 28 Apr 2020 17:15:38 -0500 Subject: [PATCH 03/14] resolves #135 - Adds new controller class for DM-RMC-4K-Z-100-C Extends existing controller class for RmcX100C devices and gives it additional connection metadata to report --- .../Receivers/DmRmc4kZScalerCController.cs | 151 +++++++++ .../Endpoints/Receivers/DmRmcHelper.cs | 9 +- .../Receivers/RmRmc4kZ100CController.cs | 95 ++++++ .../PepperDash_Essentials_DM.csproj | 317 +++++++++--------- 4 files changed, 410 insertions(+), 162 deletions(-) create mode 100644 essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZScalerCController.cs create mode 100644 essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/RmRmc4kZ100CController.cs 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..64b84fe9 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs @@ -146,7 +146,7 @@ namespace PepperDash.Essentials.DM 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)); + return new RmRmc4kZ100CController(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")) @@ -219,7 +219,7 @@ namespace PepperDash.Essentials.DM 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])); + return new RmRmc4kZ100CController(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")) @@ -252,7 +252,7 @@ namespace PepperDash.Essentials.DM 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])); + return new RmRmc4kZ100CController(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")) @@ -288,7 +288,8 @@ namespace PepperDash.Essentials.DM public DmRmcControllerFactory() { TypeNames = new List() { "hdbasetrx", "dmrmc4k100c1g", "dmrmc100c", "dmrmc100s", "dmrmc4k100c", "dmrmc150s", - "dmrmc200c", "dmrmc200s", "dmrmc200s2", "dmrmcscalerc", "dmrmcscalers", "dmrmcscalers2", "dmrmc4kscalerc", "dmrmc4kscalercdsp" }; + "dmrmc200c", "dmrmc200s", "dmrmc200s2", "dmrmcscalerc", "dmrmcscalers", "dmrmcscalers2", "dmrmc4kscalerc", "dmrmc4kscalercdsp", + "dmrmc4kz100c" }; } public override EssentialsDevice BuildDevice(DeviceConfig dc) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/RmRmc4kZ100CController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/RmRmc4kZ100CController.cs new file mode 100644 index 00000000..1ff5ec80 --- /dev/null +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/RmRmc4kZ100CController.cs @@ -0,0 +1,95 @@ +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 RmRmc4kZ100CController : DmRmcX100CController + { + public new DmRmc4kz100C Rmc { get; private set; } + + public RoutingInputPort DmIn { get; private set; } + public RoutingOutputPort HdmiOut { get; private set; } + + public RoutingPortCollection InputPorts + { + get { return new RoutingPortCollection { DmIn }; } + } + + public RoutingPortCollection OutputPorts + { + get { return new RoutingPortCollection { HdmiOut }; } + } + + public RmRmc4kZ100CController(string key, string name, DmRmc4kz100C rmc) + : base(key, name, rmc) + { + Rmc = rmc; + 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); + + // Set Ports for CEC + HdmiOut.Port = Rmc; // Unique case, this class has no HdmiOutput port and ICec is implemented on the receiver class itself + + 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 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); + } + } +} \ No newline at end of file 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 f8ea57a9..bb165f92 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj +++ b/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj @@ -1,159 +1,160 @@ - - - Release - AnyCPU - 9.0.30729 - 2.0 - {9199CE8A-0C9F-4952-8672-3EED798B284F} - Library - Properties - PepperDash_Essentials_DM - PepperDash_Essentials_DM - {0B4745B0-194B-4BB6-8E21-E9057CA92300};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - WindowsCE - E2BECB1F-8C8C-41ba-B736-9BE7D946A398 - 5.0 - SmartDeviceProject1 - v3.5 - Windows CE - - - - - .allowedReferenceRelatedFileExtensions - true - full - false - bin\ - DEBUG;TRACE; - prompt - 4 - 512 - true - true - off - - - .allowedReferenceRelatedFileExtensions - none - true - bin\ - prompt - 4 - 512 - true - true - off - - - - False - ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll - - - False - ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DM.dll - - - False - ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll - - - - False - ..\..\pepperdashcore-builds\PepperDash_Core.dll - - - False - ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll - False - - - False - ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll - False - - - False - ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpNewtonsoft.dll - - - False - ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe - False - - - False - ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpReflectionInterface.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} - PepperDash_Essentials_Core - - - - - - - - - rem S# Pro preparation will execute after these operations - + + + Release + AnyCPU + 9.0.30729 + 2.0 + {9199CE8A-0C9F-4952-8672-3EED798B284F} + Library + Properties + PepperDash_Essentials_DM + PepperDash_Essentials_DM + {0B4745B0-194B-4BB6-8E21-E9057CA92300};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + WindowsCE + E2BECB1F-8C8C-41ba-B736-9BE7D946A398 + 5.0 + SmartDeviceProject1 + v3.5 + Windows CE + + + + + .allowedReferenceRelatedFileExtensions + true + full + false + bin\ + DEBUG;TRACE; + prompt + 4 + 512 + true + true + off + + + .allowedReferenceRelatedFileExtensions + none + true + bin\ + prompt + 4 + 512 + true + true + off + + + + False + ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll + + + False + ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DM.dll + + + False + ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll + + + + False + ..\..\pepperdashcore-builds\PepperDash_Core.dll + + + False + ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll + False + + + False + ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll + False + + + False + ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpNewtonsoft.dll + + + False + ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe + False + + + False + ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpReflectionInterface.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} + PepperDash_Essentials_Core + + + + + + + + + rem S# Pro preparation will execute after these operations + \ No newline at end of file From 618fa680000b8661c912445d9b654800cd90ecba Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Tue, 28 Apr 2020 21:00:50 -0600 Subject: [PATCH 04/14] removes properties in inherited class --- ...ontroller.cs => DmRmc4kZ100CController.cs} | 156 ++++++++---------- .../Endpoints/Receivers/DmRmcHelper.cs | 2 +- .../Receivers/DmRmcX100CController.cs | 6 +- 3 files changed, 72 insertions(+), 92 deletions(-) rename essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/{RmRmc4kZ100CController.cs => DmRmc4kZ100CController.cs} (61%) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/RmRmc4kZ100CController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZ100CController.cs similarity index 61% rename from essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/RmRmc4kZ100CController.cs rename to essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZ100CController.cs index 1ff5ec80..bc1829a3 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/RmRmc4kZ100CController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZ100CController.cs @@ -1,95 +1,75 @@ -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 RmRmc4kZ100CController : DmRmcX100CController - { - public new DmRmc4kz100C Rmc { get; private set; } - - public RoutingInputPort DmIn { get; private set; } - public RoutingOutputPort HdmiOut { get; private set; } - - public RoutingPortCollection InputPorts - { - get { return new RoutingPortCollection { DmIn }; } - } - - public RoutingPortCollection OutputPorts - { - get { return new RoutingPortCollection { HdmiOut }; } - } - - public RmRmc4kZ100CController(string key, string name, DmRmc4kz100C rmc) +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; + { + _rmc = rmc; 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); + eRoutingPortConnectionType.Hdmi, null, this) {Port = _rmc}; // Set Ports for CEC - HdmiOut.Port = Rmc; // Unique case, this class has no HdmiOutput port and ICec is implemented on the receiver class itself - - 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 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); - } - } + + 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/DmRmcHelper.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs index 64b84fe9..2c0a3134 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs @@ -26,7 +26,7 @@ namespace PepperDash.Essentials.DM public virtual StringFeedback EdidPreferredTimingFeedback { get; protected set; } public virtual StringFeedback EdidSerialNumberFeedback { get; protected set; } - public DmRmcControllerBase(string key, string name, EndpointReceiverBase device) + protected DmRmcControllerBase(string key, string name, EndpointReceiverBase device) : base(key, name, device) { // if wired to a chassis, skip registration step in base class 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 { From d2c8da68a51621d6a9ff4eb1835729f70913a28d Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Tue, 28 Apr 2020 21:02:34 -0600 Subject: [PATCH 05/14] adds todo for examining class inheritance design --- .../Essentials_DM/Endpoints/Receivers/DmRmc4kZ100CController.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZ100CController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZ100CController.cs index bc1829a3..e476ef78 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZ100CController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZ100CController.cs @@ -29,6 +29,7 @@ namespace PepperDash.Essentials.DM // 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); From ef8a61c3ebf64edce11b06238cc06fbce62d9634 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Tue, 28 Apr 2020 21:12:52 -0600 Subject: [PATCH 06/14] removed duplicated logic from constructor --- .../Endpoints/Receivers/DmRmc4kZ100CController.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZ100CController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZ100CController.cs index e476ef78..33705c0a 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZ100CController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZ100CController.cs @@ -22,10 +22,13 @@ namespace PepperDash.Essentials.DM : 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 From b993419c3d2bd6f7aeaafac4f86d1cff07a24c12 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Tue, 28 Apr 2020 21:20:56 -0600 Subject: [PATCH 07/14] fixes file name for 4kz100C everywhere --- .../Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs | 2 +- .../Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 2c0a3134..7ff33957 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs @@ -146,7 +146,7 @@ namespace PepperDash.Essentials.DM if (typeName.StartsWith("dmrmc4k100c")) return new DmRmcX100CController(key, name, new DmRmc4k100C(ipid, Global.ControlSystem)); if (typeName.StartsWith("dmrmc4kz100c")) - return new RmRmc4kZ100CController(key, name, new DmRmc4kz100C(ipid, Global.ControlSystem)); + 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")) 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 bb165f92..96533e96 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj +++ b/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj @@ -100,7 +100,7 @@ - + From 02c71f709c097e9bbbc4790ced56871712069407 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Tue, 28 Apr 2020 21:35:52 -0600 Subject: [PATCH 08/14] replaces 2 more occasions of Rm with Dm --- .../Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 7ff33957..1a5fe034 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs @@ -219,7 +219,7 @@ namespace PepperDash.Essentials.DM if (typeName.StartsWith("dmrmc4k100c")) return new DmRmcX100CController(key, name, new DmRmc4k100C(chassis.Outputs[num])); if (typeName.StartsWith("dmrmc4kz100c")) - return new RmRmc4kZ100CController(key, name, new DmRmc4kz100C(chassis.Outputs[num])); + 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")) @@ -252,7 +252,7 @@ namespace PepperDash.Essentials.DM if (typeName.StartsWith("dmrmc4k100c")) return new DmRmcX100CController(key, name, new DmRmc4k100C(ipid, chassis.Outputs[num])); if (typeName.StartsWith("dmrmc4kz100c")) - return new RmRmc4kZ100CController(key, name, new DmRmc4kz100C(ipid, chassis.Outputs[num])); + 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")) From 18c35b103e4ab038f5abe4ba82920801e0d95460 Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Tue, 5 May 2020 12:09:53 -0500 Subject: [PATCH 09/14] resolves #143 - Joinmap and Bridge updated --- .../JoinMaps/DisplayControllerJoinMap.cs | 162 +++++++----------- .../Display/DisplayBase.cs | 67 ++++---- 2 files changed, 96 insertions(+), 133 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DisplayControllerJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DisplayControllerJoinMap.cs index c2fe8573..c50321dc 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DisplayControllerJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DisplayControllerJoinMap.cs @@ -7,111 +7,71 @@ 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 + 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 }); - #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 + [JoinName("PowerOff")] + public JoinDataComplete PowerOff = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata() { Label = "Power Off", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - #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 + [JoinName("PowerOn")] + public JoinDataComplete PowerOn = new JoinDataComplete(new JoinData() { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata() { Label = "Power On", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - public DisplayControllerJoinMap() + [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)) { - // 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; } } } \ 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 415eed5b..b4f4fddf 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/DisplayBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/DisplayBase.cs @@ -119,26 +119,24 @@ namespace PepperDash.Essentials.Core EiscApiAdvanced bridge) { var inputNumber = 0; - var inputKeys = new List(); - - var joinMap = new DisplayControllerJoinMap(); + var inputKeys = new List(); + + 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); @@ -147,17 +145,17 @@ namespace PepperDash.Essentials.Core var twoWayDisplay = displayDevice as TwoWayDisplayBase; 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]); + twoWayDisplay.CurrentInputFeedback.OutputChange += (o, a) => Debug.Console(0, "CurrentInputFeedback_OutputChange {0}", a.StringValue); + + + inputNumberFeedback.LinkInputSig(trilist.UShortInput[joinMap.InputSelect.JoinNumber]); } - // Power Off - trilist.SetSigTrueAction(joinMap.PowerOff, () => + // Power Off + 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,21 @@ namespace PepperDash.Essentials.Core }); - displayDevice.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn]); + displayDevice.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn.JoinNumber]); - var count = 1; + var count = 0; foreach (var input in displayDevice.InputPorts) { 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(); + trilist.SetSigTrueAction((ushort)(joinMap.InputSelectOffset.JoinNumber + count), () => displayDevice.ExecuteSwitch(displayDevice.InputPorts[tempKey].Selector)); + Debug.Console(2, displayDevice, "Setting Input Select Action on Digital Join {0} to Input: {1}", joinMap.InputSelectOffset.JoinNumber + count, displayDevice.InputPorts[tempKey].Key.ToString()); + trilist.StringInput[(ushort)(joinMap.InputNamesOffset.JoinNumber + count)].StringValue = input.Key.ToString(); 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 +227,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.SetUShortSigAction(joinMap.VolumeLevel, volumeDisplayWithFeedback.SetVolume); - volumeDisplayWithFeedback.VolumeLevelFeedback.LinkInputSig(trilist.UShortInput[joinMap.VolumeLevel]); - volumeDisplayWithFeedback.MuteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VolumeMute]); + if (volumeDisplayWithFeedback == null) return; + trilist.SetSigTrueAction(joinMap.VolumeMuteOn.JoinNumber, volumeDisplayWithFeedback.MuteOn); + trilist.SetSigTrueAction(joinMap.VolumeMuteOff.JoinNumber, volumeDisplayWithFeedback.MuteOff); + + + 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]); } } From 0b660966ac88b0e6373e808c084d7595ea633c10 Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Tue, 5 May 2020 12:35:01 -0500 Subject: [PATCH 10/14] resolves #145 - Updated IBasicCommunicationJoinMap --- .../JoinMaps/IBasicCommunicationJoinMap.cs | 89 +++++++------------ .../Config/Comm and IR/GenericComm.cs | 25 +++--- 2 files changed, 44 insertions(+), 70 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs index 3669738e..d9b361b4 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs @@ -6,62 +6,37 @@ 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; - } +{ + 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..b1dd55ee 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 @@ -59,14 +59,13 @@ namespace PepperDash.Essentials.Core } public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new IBasicCommunicationJoinMap(); + { + var joinMap = new IBasicCommunicationJoinMap(joinStart); var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); if (!string.IsNullOrEmpty(joinMapSerialized)) joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - joinMap.OffsetJoinNumbers(joinStart); if (CommPort == null) { @@ -80,22 +79,22 @@ namespace PepperDash.Essentials.Core 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); + 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, (ushort)(a.Client.ClientStatus)); - trilist.SetBool(joinMap.Connected, a.Client.ClientStatus == + { + 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, b => + }; + + trilist.SetBoolSigAction(joinMap.Connect.JoinNumber, b => { if (b) { From 64b5bc8cb8279248751eea09364975636eacd751 Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Tue, 5 May 2020 15:04:55 -0500 Subject: [PATCH 11/14] Added a check to verify that the number of inputs on a display is not greater than the size of the joinspan --- .../JoinMaps/DisplayControllerJoinMap.cs | 102 ++-- .../Display/DisplayBase.cs | 529 +++++++++--------- 2 files changed, 317 insertions(+), 314 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DisplayControllerJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DisplayControllerJoinMap.cs index c50321dc..a57c35e8 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DisplayControllerJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DisplayControllerJoinMap.cs @@ -1,77 +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 : JoinMapBaseAdvanced +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 }); - + 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 }); - + 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 }); - + 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 }); - + 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 }, + 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 }); - + 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 }); - + 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 }); - + 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 }); - + 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 }); - + 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 }); - + 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 }, + 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 }); - + 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 }); - + 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 }, + 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)) - { - } - } + public DisplayControllerJoinMap(uint joinStart) + : base(joinStart, typeof(CameraControllerJoinMap)) + { + } + } } \ 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 b4f4fddf..dd008b08 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/DisplayBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/DisplayBase.cs @@ -1,238 +1,241 @@ -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.Transmitters; -using Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Essentials.Core.Bridges; - - -namespace PepperDash.Essentials.Core -{ - /// - /// - /// - public abstract class DisplayBase : EssentialsBridgeableDevice, IHasFeedback, IRoutingSinkWithSwitching, IPower, IWarmingCooling, IUsageTracking - { - public event SourceInfoChangeHandler CurrentSourceChange; - - public string CurrentSourceInfoKey { get; set; } - public SourceListItem CurrentSourceInfo - { - get - { - return _CurrentSourceInfo; - } - set - { - if (value == _CurrentSourceInfo) return; - - var handler = CurrentSourceChange; - - if (handler != null) - handler(_CurrentSourceInfo, ChangeType.WillChange); - - _CurrentSourceInfo = value; - - if (handler != null) - handler(_CurrentSourceInfo, ChangeType.DidChange); - } - } - SourceListItem _CurrentSourceInfo; - - public BoolFeedback PowerIsOnFeedback { get; protected set; } - public BoolFeedback IsCoolingDownFeedback { get; protected set; } - public BoolFeedback IsWarmingUpFeedback { get; private set; } - - public UsageTracking UsageTracker { get; set; } - - public uint WarmupTime { get; set; } - public uint CooldownTime { get; set; } - - /// - /// Bool Func that will provide a value for the PowerIsOn Output. Must be implemented - /// by concrete sub-classes - /// - abstract protected Func PowerIsOnFeedbackFunc { get; } - abstract protected Func IsCoolingDownFeedbackFunc { get; } - abstract protected Func IsWarmingUpFeedbackFunc { get; } - - - protected CTimer WarmupTimer; - protected CTimer CooldownTimer; - - #region IRoutingInputs Members - - public RoutingPortCollection InputPorts { get; private set; } - - #endregion - - protected DisplayBase(string key, string name) - : base(key, name) - { - PowerIsOnFeedback = new BoolFeedback("PowerOnFeedback", PowerIsOnFeedbackFunc); - IsCoolingDownFeedback = new BoolFeedback("IsCoolingDown", IsCoolingDownFeedbackFunc); - IsWarmingUpFeedback = new BoolFeedback("IsWarmingUp", IsWarmingUpFeedbackFunc); - - InputPorts = new RoutingPortCollection(); - - PowerIsOnFeedback.OutputChange += PowerIsOnFeedback_OutputChange; - } - - void PowerIsOnFeedback_OutputChange(object sender, EventArgs e) - { - if (UsageTracker != null) - { - if (PowerIsOnFeedback.BoolValue) - UsageTracker.StartDeviceUsage(); - else - UsageTracker.EndDeviceUsage(); - } - } - - public abstract void PowerOn(); - public abstract void PowerOff(); - public abstract void PowerToggle(); - - public virtual FeedbackCollection Feedbacks - { - get - { - return new FeedbackCollection - { - PowerIsOnFeedback, - IsCoolingDownFeedback, - IsWarmingUpFeedback - }; - } - } - - public abstract void ExecuteSwitch(object selector); - - protected void LinkDisplayToApi(DisplayBase displayDevice, BasicTriList trilist, uint joinStart, string joinMapKey, - EiscApiAdvanced bridge) - { - var inputNumber = 0; +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.Transmitters; +using Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Essentials.Core.Bridges; + + +namespace PepperDash.Essentials.Core +{ + /// + /// + /// + public abstract class DisplayBase : EssentialsBridgeableDevice, IHasFeedback, IRoutingSinkWithSwitching, IPower, IWarmingCooling, IUsageTracking + { + public event SourceInfoChangeHandler CurrentSourceChange; + + public string CurrentSourceInfoKey { get; set; } + public SourceListItem CurrentSourceInfo + { + get + { + return _CurrentSourceInfo; + } + set + { + if (value == _CurrentSourceInfo) return; + + var handler = CurrentSourceChange; + + if (handler != null) + handler(_CurrentSourceInfo, ChangeType.WillChange); + + _CurrentSourceInfo = value; + + if (handler != null) + handler(_CurrentSourceInfo, ChangeType.DidChange); + } + } + SourceListItem _CurrentSourceInfo; + + public BoolFeedback PowerIsOnFeedback { get; protected set; } + public BoolFeedback IsCoolingDownFeedback { get; protected set; } + public BoolFeedback IsWarmingUpFeedback { get; private set; } + + public UsageTracking UsageTracker { get; set; } + + public uint WarmupTime { get; set; } + public uint CooldownTime { get; set; } + + /// + /// Bool Func that will provide a value for the PowerIsOn Output. Must be implemented + /// by concrete sub-classes + /// + abstract protected Func PowerIsOnFeedbackFunc { get; } + abstract protected Func IsCoolingDownFeedbackFunc { get; } + abstract protected Func IsWarmingUpFeedbackFunc { get; } + + + protected CTimer WarmupTimer; + protected CTimer CooldownTimer; + + #region IRoutingInputs Members + + public RoutingPortCollection InputPorts { get; private set; } + + #endregion + + protected DisplayBase(string key, string name) + : base(key, name) + { + PowerIsOnFeedback = new BoolFeedback("PowerOnFeedback", PowerIsOnFeedbackFunc); + IsCoolingDownFeedback = new BoolFeedback("IsCoolingDown", IsCoolingDownFeedbackFunc); + IsWarmingUpFeedback = new BoolFeedback("IsWarmingUp", IsWarmingUpFeedbackFunc); + + InputPorts = new RoutingPortCollection(); + + PowerIsOnFeedback.OutputChange += PowerIsOnFeedback_OutputChange; + } + + void PowerIsOnFeedback_OutputChange(object sender, EventArgs e) + { + if (UsageTracker != null) + { + if (PowerIsOnFeedback.BoolValue) + UsageTracker.StartDeviceUsage(); + else + UsageTracker.EndDeviceUsage(); + } + } + + public abstract void PowerOn(); + public abstract void PowerOff(); + public abstract void PowerToggle(); + + public virtual FeedbackCollection Feedbacks + { + get + { + return new FeedbackCollection + { + PowerIsOnFeedback, + IsCoolingDownFeedback, + IsWarmingUpFeedback + }; + } + } + + public abstract void ExecuteSwitch(object selector); + + protected void LinkDisplayToApi(DisplayBase displayDevice, BasicTriList trilist, uint joinStart, string joinMapKey, + EiscApiAdvanced bridge) + { + var inputNumber = 0; var inputKeys = new List(); - var joinMap = new DisplayControllerJoinMap(joinStart); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - Debug.Console(0, "Linking to Display: {0}", displayDevice.Name); - - trilist.StringInput[joinMap.Name.JoinNumber].StringValue = displayDevice.Name; - - var commMonitor = displayDevice as ICommunicationMonitor; - if (commMonitor != null) + var joinMap = new DisplayControllerJoinMap(joinStart); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.Console(0, "Linking to Display: {0}", 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.JoinNumber]); - } - - var inputNumberFeedback = new IntFeedback(() => inputNumber); - - // Two way feedbacks - var twoWayDisplay = displayDevice as TwoWayDisplayBase; - - if (twoWayDisplay != null) + commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); + } + + var inputNumberFeedback = new IntFeedback(() => inputNumber); + + // Two way feedbacks + var twoWayDisplay = displayDevice as TwoWayDisplayBase; + + if (twoWayDisplay != null) { - trilist.SetBool(joinMap.IsTwoWayDisplay.JoinNumber, 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.JoinNumber]); - } - + inputNumberFeedback.LinkInputSig(trilist.UShortInput[joinMap.InputSelect.JoinNumber]); + } + // Power Off - trilist.SetSigTrueAction(joinMap.PowerOff.JoinNumber, () => - { - inputNumber = 102; - inputNumberFeedback.FireUpdate(); - displayDevice.PowerOff(); - }); - - displayDevice.PowerIsOnFeedback.OutputChange += (o, a) => - { - if (!a.BoolValue) - { - inputNumber = 102; - inputNumberFeedback.FireUpdate(); - - } - else - { - inputNumber = 0; - inputNumberFeedback.FireUpdate(); - } - }; - - displayDevice.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PowerOff.JoinNumber]); - - // PowerOn - trilist.SetSigTrueAction(joinMap.PowerOn.JoinNumber, () => - { - inputNumber = 0; - inputNumberFeedback.FireUpdate(); - displayDevice.PowerOn(); - }); - - - displayDevice.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn.JoinNumber]); - - var count = 0; - foreach (var input in displayDevice.InputPorts) - { - inputKeys.Add(input.Key); - var tempKey = inputKeys.ElementAt(count - 1); - trilist.SetSigTrueAction((ushort)(joinMap.InputSelectOffset.JoinNumber + count), () => displayDevice.ExecuteSwitch(displayDevice.InputPorts[tempKey].Selector)); - Debug.Console(2, displayDevice, "Setting Input Select Action on Digital Join {0} to Input: {1}", joinMap.InputSelectOffset.JoinNumber + count, displayDevice.InputPorts[tempKey].Key.ToString()); - trilist.StringInput[(ushort)(joinMap.InputNamesOffset.JoinNumber + count)].StringValue = input.Key.ToString(); - count++; - } - - Debug.Console(2, displayDevice, "Setting Input Select Action on Analog Join {0}", joinMap.InputSelect); - trilist.SetUShortSigAction(joinMap.InputSelect.JoinNumber, (a) => - { - if (a == 0) - { - displayDevice.PowerOff(); - inputNumber = 0; - } - else if (a > 0 && a < displayDevice.InputPorts.Count && a != inputNumber) - { - displayDevice.ExecuteSwitch(displayDevice.InputPorts.ElementAt(a - 1).Selector); - inputNumber = a; - } - else if (a == 102) - { - displayDevice.PowerToggle(); - - } - if (twoWayDisplay != null) - inputNumberFeedback.FireUpdate(); - }); - - - var volumeDisplay = displayDevice as IBasicVolumeControls; - if (volumeDisplay == null) return; - + trilist.SetSigTrueAction(joinMap.PowerOff.JoinNumber, () => + { + inputNumber = 102; + inputNumberFeedback.FireUpdate(); + displayDevice.PowerOff(); + }); + + displayDevice.PowerIsOnFeedback.OutputChange += (o, a) => + { + if (!a.BoolValue) + { + inputNumber = 102; + inputNumberFeedback.FireUpdate(); + + } + else + { + inputNumber = 0; + inputNumberFeedback.FireUpdate(); + } + }; + + displayDevice.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PowerOff.JoinNumber]); + + // PowerOn + trilist.SetSigTrueAction(joinMap.PowerOn.JoinNumber, () => + { + inputNumber = 0; + inputNumberFeedback.FireUpdate(); + displayDevice.PowerOn(); + }); + + + displayDevice.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn.JoinNumber]); + + var count = 0; + foreach (var input in displayDevice.InputPorts) + { + if (count < joinMap.InputSelectOffset.JoinSpan) + { + inputKeys.Add(input.Key); + var tempKey = inputKeys.ElementAt(count - 1); + trilist.SetSigTrueAction((ushort)(joinMap.InputSelectOffset.JoinNumber + count), () => displayDevice.ExecuteSwitch(displayDevice.InputPorts[tempKey].Selector)); + Debug.Console(2, displayDevice, "Setting Input Select Action on Digital Join {0} to Input: {1}", joinMap.InputSelectOffset.JoinNumber + count, displayDevice.InputPorts[tempKey].Key.ToString()); + trilist.StringInput[(ushort)(joinMap.InputNamesOffset.JoinNumber + count)].StringValue = input.Key.ToString(); + count++; + } + } + + Debug.Console(2, displayDevice, "Setting Input Select Action on Analog Join {0}", joinMap.InputSelect); + trilist.SetUShortSigAction(joinMap.InputSelect.JoinNumber, (a) => + { + if (a == 0) + { + displayDevice.PowerOff(); + inputNumber = 0; + } + else if (a > 0 && a < displayDevice.InputPorts.Count && a != inputNumber) + { + displayDevice.ExecuteSwitch(displayDevice.InputPorts.ElementAt(a - 1).Selector); + inputNumber = a; + } + else if (a == 102) + { + displayDevice.PowerToggle(); + + } + if (twoWayDisplay != null) + inputNumberFeedback.FireUpdate(); + }); + + + var volumeDisplay = displayDevice as IBasicVolumeControls; + if (volumeDisplay == null) return; + 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; - + + var volumeDisplayWithFeedback = volumeDisplay as IBasicVolumeWithFeedback; + if (volumeDisplayWithFeedback == null) return; trilist.SetSigTrueAction(joinMap.VolumeMuteOn.JoinNumber, volumeDisplayWithFeedback.MuteOn); trilist.SetSigTrueAction(joinMap.VolumeMuteOff.JoinNumber, volumeDisplayWithFeedback.MuteOff); @@ -242,43 +245,43 @@ namespace PepperDash.Essentials.Core 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]); - } - } - - /// - /// - /// - public abstract class TwoWayDisplayBase : DisplayBase - { - public StringFeedback CurrentInputFeedback { get; private set; } - - abstract protected Func CurrentInputFeedbackFunc { get; } - - - public static MockDisplay DefaultDisplay - { - get - { - if (_DefaultDisplay == null) - _DefaultDisplay = new MockDisplay("default", "Default Display"); - return _DefaultDisplay; - } - } - static MockDisplay _DefaultDisplay; - - public TwoWayDisplayBase(string key, string name) - : base(key, name) - { - CurrentInputFeedback = new StringFeedback(CurrentInputFeedbackFunc); - - WarmupTime = 7000; - CooldownTime = 15000; - - Feedbacks.Add(CurrentInputFeedback); - - - } - - } + volumeDisplayWithFeedback.MuteFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.VolumeMuteOff.JoinNumber]); + } + } + + /// + /// + /// + public abstract class TwoWayDisplayBase : DisplayBase + { + public StringFeedback CurrentInputFeedback { get; private set; } + + abstract protected Func CurrentInputFeedbackFunc { get; } + + + public static MockDisplay DefaultDisplay + { + get + { + if (_DefaultDisplay == null) + _DefaultDisplay = new MockDisplay("default", "Default Display"); + return _DefaultDisplay; + } + } + static MockDisplay _DefaultDisplay; + + public TwoWayDisplayBase(string key, string name) + : base(key, name) + { + CurrentInputFeedback = new StringFeedback(CurrentInputFeedbackFunc); + + WarmupTime = 7000; + CooldownTime = 15000; + + Feedbacks.Add(CurrentInputFeedback); + + + } + + } } \ No newline at end of file From 250f62d79cfc742b41346b2849fe87b5e5758285 Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Tue, 5 May 2020 15:14:53 -0500 Subject: [PATCH 12/14] Changed displayDevice.InputPorts API Linking to for loop --- .../Display/DisplayBase.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/DisplayBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/DisplayBase.cs index dd008b08..03068a15 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/DisplayBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/DisplayBase.cs @@ -190,17 +190,17 @@ namespace PepperDash.Essentials.Core displayDevice.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn.JoinNumber]); - var count = 0; - foreach (var input in displayDevice.InputPorts) + for (int i = 0; i < displayDevice.InputPorts.Count; i++) { - if (count < joinMap.InputSelectOffset.JoinSpan) + if (i < joinMap.InputNamesOffset.JoinSpan) { - inputKeys.Add(input.Key); - var tempKey = inputKeys.ElementAt(count - 1); - trilist.SetSigTrueAction((ushort)(joinMap.InputSelectOffset.JoinNumber + count), () => displayDevice.ExecuteSwitch(displayDevice.InputPorts[tempKey].Selector)); - Debug.Console(2, displayDevice, "Setting Input Select Action on Digital Join {0} to Input: {1}", joinMap.InputSelectOffset.JoinNumber + count, displayDevice.InputPorts[tempKey].Key.ToString()); - trilist.StringInput[(ushort)(joinMap.InputNamesOffset.JoinNumber + count)].StringValue = input.Key.ToString(); - count++; + 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(); } } From b3821e90d13a38967ea16ebe03e69f362470b15a Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Tue, 5 May 2020 16:49:50 -0500 Subject: [PATCH 13/14] Added debug statement if there are more inputs than allowed bu the joinspan. --- .../JoinMaps/IBasicCommunicationJoinMap.cs | 18 +- .../Config/Comm and IR/GenericComm.cs | 232 +++++++++--------- .../Display/DisplayBase.cs | 5 +- 3 files changed, 129 insertions(+), 126 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs index d9b361b4..612ace4f 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs @@ -1,11 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using PepperDash.Essentials.Core; - -namespace PepperDash.Essentials.Core.Bridges +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 { @@ -38,5 +38,5 @@ namespace PepperDash.Essentials.Core.Bridges : 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 b1dd55ee..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,124 +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) +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) { - 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); + 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.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.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); - } - } + 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 03068a15..9d3bed17 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/DisplayBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/DisplayBase.cs @@ -198,10 +198,13 @@ namespace PepperDash.Essentials.Core 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}", + 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(2, displayDevice, "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); From e90436081a6d3f9b81305a3a602c0b177647f9c9 Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Tue, 5 May 2020 17:32:31 -0500 Subject: [PATCH 14/14] Fixes to Logging related to DisplayBase input joinmap --- .../PepperDashEssentialsBase/Display/DisplayBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/DisplayBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/DisplayBase.cs index 9d3bed17..c8d46377 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/DisplayBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/DisplayBase.cs @@ -203,7 +203,7 @@ namespace PepperDash.Essentials.Core trilist.StringInput[(ushort)(joinMap.InputNamesOffset.JoinNumber + i)].StringValue = displayDevice.InputPorts[i].Key.ToString(); } else - Debug.Console(2, displayDevice, "Device has {0} inputs. The Join Map allows up to {1} inputs. Discarding inputs {2} - {3} from bridge.", + 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); }