diff --git a/.github/workflows/add-issues-to-project.yml b/.github/workflows/add-issues-to-project.yml deleted file mode 100644 index 8811c0cc..00000000 --- a/.github/workflows/add-issues-to-project.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Add bugs to bugs project - -on: - issues: - types: - - opened - - labeled - -jobs: - check-secret: - runs-on: ubuntu-latest - outputs: - my-key: ${{ steps.my-key.outputs.defined }} - steps: - - id: my-key - if: "${{ env.MY_KEY != '' }}" - run: echo "::set-output name=defined::true" - env: - MY_KEY: ${{ secrets.PROJECT_URL }} - throw-error: - name: Check - runs-on: ubuntu-latest - needs: [check-secret] - if: needs.check-secret.outputs.my-key != 'true' - steps: - - run: echo "The Project URL Repo Secret is empty" - add-to-project: - name: Add issue to project - runs-on: ubuntu-latest - needs: [check-secret] - if: needs.check-secret.outputs.my-key == 'true' - steps: - - uses: actions/add-to-project@main - with: - project-url: ${{ secrets.PROJECT_URL }} - github-token: ${{ secrets.GH_PROJECTS_PASSWORD }} - diff --git a/.gitignore b/.gitignore index 94b7d400..739a60ab 100644 --- a/.gitignore +++ b/.gitignore @@ -389,3 +389,4 @@ MigrationBackup/ # Fody - auto-generated XML schema FodyWeavers.xsd essentials-framework/Essentials Interfaces/PepperDash_Essentials_Interfaces/PepperDash_Essentials_Interfaces.csproj +.DS_Store diff --git a/PepperDash.Essentials.sln b/PepperDash.Essentials.sln index 4a9ffd83..40da3b9b 100644 --- a/PepperDash.Essentials.sln +++ b/PepperDash.Essentials.sln @@ -3,13 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.4.33213.308 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PepperDash.Essentials.Devices.Common", "src\PepperDash.Essentials.Devices.Common\PepperDash.Essentials.Devices.Common.csproj", "{53E204B7-97DD-441D-A96C-721DF014DF82}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PepperDash.Essentials.Devices.Common", "src\PepperDash.Essentials.Devices.Common\PepperDash.Essentials.Devices.Common.csproj", "{53E204B7-97DD-441D-A96C-721DF014DF82}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PepperDash.Essentials.DM", "src\PepperDash.Essentials.DM\PepperDash.Essentials.DM.csproj", "{08EB4B98-9B4D-455A-81E0-4F913E08ADB5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PepperDash.Essentials", "src\PepperDash.Essentials\PepperDash.Essentials.csproj", "{CB3B11BA-625C-4D35-B663-FDC5BE9A230E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PepperDash.Essentials", "src\PepperDash.Essentials\PepperDash.Essentials.csproj", "{CB3B11BA-625C-4D35-B663-FDC5BE9A230E}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PepperDash.Essentials.Core", "src\PepperDash.Essentials.Core\PepperDash.Essentials.Core.csproj", "{3D192FED-8FFC-4CB5-B5F7-BA307ABA254B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PepperDash.Essentials.Core", "src\PepperDash.Essentials.Core\PepperDash.Essentials.Core.csproj", "{3D192FED-8FFC-4CB5-B5F7-BA307ABA254B}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -21,10 +19,6 @@ Global {53E204B7-97DD-441D-A96C-721DF014DF82}.Debug|Any CPU.Build.0 = Debug|Any CPU {53E204B7-97DD-441D-A96C-721DF014DF82}.Release|Any CPU.ActiveCfg = Release|Any CPU {53E204B7-97DD-441D-A96C-721DF014DF82}.Release|Any CPU.Build.0 = Release|Any CPU - {08EB4B98-9B4D-455A-81E0-4F913E08ADB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {08EB4B98-9B4D-455A-81E0-4F913E08ADB5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {08EB4B98-9B4D-455A-81E0-4F913E08ADB5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {08EB4B98-9B4D-455A-81E0-4F913E08ADB5}.Release|Any CPU.Build.0 = Release|Any CPU {CB3B11BA-625C-4D35-B663-FDC5BE9A230E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CB3B11BA-625C-4D35-B663-FDC5BE9A230E}.Debug|Any CPU.Build.0 = Debug|Any CPU {CB3B11BA-625C-4D35-B663-FDC5BE9A230E}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets index 81304ace..807679e4 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets @@ -19,8 +19,8 @@ - - + + diff --git a/src/PepperDash.Essentials.Core/Bridges/BridgeBase.cs b/src/PepperDash.Essentials.Core/Bridges/BridgeBase.cs index 19c0f501..58917199 100644 --- a/src/PepperDash.Essentials.Core/Bridges/BridgeBase.cs +++ b/src/PepperDash.Essentials.Core/Bridges/BridgeBase.cs @@ -167,7 +167,7 @@ namespace PepperDash.Essentials.Core.Bridges Debug.Console(1, this, "Linking Device: '{0}'", device.Key); - if (!typeof (IBridgeAdvanced).IsAssignableFrom(device.GetType().GetCType())) + if (!typeof(IBridgeAdvanced).IsAssignableFrom(device.GetType().GetCType())) { Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "{0} is not compatible with this bridge type. Please use 'eiscapi' instead, or updae the device.", @@ -411,7 +411,7 @@ namespace PepperDash.Essentials.Core.Bridges public List Devices { get; set; } [JsonProperty("rooms")] - public List Rooms { get; set; } + public List Rooms { get; set; } public class ApiDevicePropertiesConfig @@ -444,7 +444,7 @@ namespace PepperDash.Essentials.Core.Bridges { public EiscApiAdvancedFactory() { - TypeNames = new List { "eiscapiadv", "eiscapiadvanced", "eiscapiadvancedserver", "eiscapiadvancedclient", "vceiscapiadv", "vceiscapiadvanced" }; + TypeNames = new List { "eiscapiadv", "eiscapiadvanced", "eiscapiadvancedserver", "eiscapiadvancedclient", "vceiscapiadv", "vceiscapiadvanced" }; } public override EssentialsDevice BuildDevice(DeviceConfig dc) @@ -459,34 +459,34 @@ namespace PepperDash.Essentials.Core.Bridges { case "eiscapiadv": case "eiscapiadvanced": - { - eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(controlProperties.IpIdInt, - controlProperties.TcpSshProperties.Address, Global.ControlSystem); - break; - } - case "eiscapiadvancedserver": - { - eisc = new EISCServer(controlProperties.IpIdInt, Global.ControlSystem); - break; - } - case "eiscapiadvancedclient": - { - eisc = new EISCClient(controlProperties.IpIdInt, controlProperties.TcpSshProperties.Address, Global.ControlSystem); - break; - } - case "vceiscapiadv": - case "vceiscapiadvanced": - { - if (string.IsNullOrEmpty(controlProperties.RoomId)) { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to build VC-4 EISC Client for device {0}. Room ID is missing or empty", dc.Key); - eisc = null; + eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(controlProperties.IpIdInt, + controlProperties.TcpSshProperties.Address, Global.ControlSystem); + break; + } + case "eiscapiadvancedserver": + { + eisc = new EISCServer(controlProperties.IpIdInt, Global.ControlSystem); + break; + } + case "eiscapiadvancedclient": + { + eisc = new EISCClient(controlProperties.IpIdInt, controlProperties.TcpSshProperties.Address, Global.ControlSystem); + break; + } + case "vceiscapiadv": + case "vceiscapiadvanced": + { + if (string.IsNullOrEmpty(controlProperties.RoomId)) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to build VC-4 EISC Client for device {0}. Room ID is missing or empty", dc.Key); + eisc = null; + break; + } + eisc = new VirtualControlEISCClient(controlProperties.IpIdInt, controlProperties.RoomId, + Global.ControlSystem); break; } - eisc = new VirtualControlEISCClient(controlProperties.IpIdInt, controlProperties.RoomId, - Global.ControlSystem); - break; - } default: eisc = null; break; diff --git a/src/PepperDash.Essentials.Core/Bridges/JoinMaps/DmRmcControllerJoinMap.cs b/src/PepperDash.Essentials.Core/Bridges/JoinMaps/DmRmcControllerJoinMap.cs index 8c2386fd..56f0825c 100644 --- a/src/PepperDash.Essentials.Core/Bridges/JoinMaps/DmRmcControllerJoinMap.cs +++ b/src/PepperDash.Essentials.Core/Bridges/JoinMaps/DmRmcControllerJoinMap.cs @@ -8,6 +8,18 @@ namespace PepperDash.Essentials.Core.Bridges public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, new JoinMetadata { Description = "DM RMC Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("VideoMuteOn")] + public JoinDataComplete VideoMuteOn = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata { Description = "DM RMC Mute Video", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("VideoMuteOff")] + public JoinDataComplete VideoMuteOff = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, + new JoinMetadata { Description = "DM RMC UnMute Video", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("VideoMuteToggle")] + public JoinDataComplete VideoMuteToggle = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, + new JoinMetadata { Description = "DM RMC Mute Video Toggle", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("CurrentOutputResolution")] public JoinDataComplete CurrentOutputResolution = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, new JoinMetadata { Description = "DM RMC Current Output Resolution", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); @@ -36,6 +48,28 @@ namespace PepperDash.Essentials.Core.Bridges public JoinDataComplete AudioVideoSource = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, new JoinMetadata { Description = "DM RMC Audio Video Source Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + [JoinName("HdcpSupportCapability")] + public JoinDataComplete HdcpSupportCapability = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "DM RMC HDCP Support Capability", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("Port1HdcpState")] + public JoinDataComplete Port1HdcpState = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata { Description = "DM RMC Port 1 (DM) HDCP State Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("Port2HdcpState")] + public JoinDataComplete Port2HdcpState = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, + new JoinMetadata { Description = "DM TX Port 2 (HDMI) HDCP State Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("HdmiInputSync")] + public JoinDataComplete HdmiInputSync = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "DM RMC HDMI Input Sync", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("HdcpInputPortCount")] + public JoinDataComplete HdcpInputPortCount = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, + new JoinMetadata { Description = "Number of Input Ports that support HDCP", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + + /// /// Constructor to use when instantiating this Join Map without inheriting from it /// @@ -50,7 +84,8 @@ namespace PepperDash.Essentials.Core.Bridges /// /// Join this join map will start at /// Type of the child join map - protected DmRmcControllerJoinMap(uint joinStart, Type type) : base(joinStart, type) + protected DmRmcControllerJoinMap(uint joinStart, Type type) + : base(joinStart, type) { } } diff --git a/src/PepperDash.Essentials.Core/Bridges/JoinMaps/DmTxControllerJoinMap.cs b/src/PepperDash.Essentials.Core/Bridges/JoinMaps/DmTxControllerJoinMap.cs index 23d240d5..c6f8f89f 100644 --- a/src/PepperDash.Essentials.Core/Bridges/JoinMaps/DmTxControllerJoinMap.cs +++ b/src/PepperDash.Essentials.Core/Bridges/JoinMaps/DmTxControllerJoinMap.cs @@ -64,6 +64,16 @@ namespace PepperDash.Essentials.Core.Bridges public JoinDataComplete VgaContrast = new JoinDataComplete(new JoinData { JoinNumber = 7, JoinSpan = 1 }, new JoinMetadata { Description = "DM TX Online", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + [JoinName("Port3HdcpState")] + public JoinDataComplete Port3HdcpState = new JoinDataComplete(new JoinData { JoinNumber = 8, JoinSpan = 1 }, + new JoinMetadata { Description = "DM TX Port 3 HDCP State Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("HdcpInputPortCount")] + public JoinDataComplete HdcpInputPortCount = new JoinDataComplete(new JoinData { JoinNumber = 9, JoinSpan = 1 }, + new JoinMetadata { Description = "Number of Input Ports that support HDCP", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + + /// /// Constructor to use when instantiating this Join Map without inheriting from it /// @@ -78,7 +88,8 @@ namespace PepperDash.Essentials.Core.Bridges /// /// Join this join map will start at /// Type of the child join map - protected DmTxControllerJoinMap(uint joinStart, Type type) : base(joinStart, type) + protected DmTxControllerJoinMap(uint joinStart, Type type) + : base(joinStart, type) { } } diff --git a/src/PepperDash.Essentials.Core/Bridges/JoinMaps/GenericIrControllerJoinMap.cs b/src/PepperDash.Essentials.Core/Bridges/JoinMaps/GenericIrControllerJoinMap.cs new file mode 100644 index 00000000..288141bb --- /dev/null +++ b/src/PepperDash.Essentials.Core/Bridges/JoinMaps/GenericIrControllerJoinMap.cs @@ -0,0 +1,827 @@ +using PepperDash.Essentials.Core; + +namespace PepperDash_Essentials_Core.Bridges.JoinMaps +{ + public sealed class GenericIrControllerJoinMap : JoinMapBaseAdvanced + { + [JoinName("PLAY")] + public JoinDataComplete Play = new JoinDataComplete( + new JoinData + { + JoinNumber = 1, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "PLAY", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("STOP")] + public JoinDataComplete Stop = new JoinDataComplete( + new JoinData + { + JoinNumber = 2, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "STOP", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("PAUSE")] + public JoinDataComplete Pause = new JoinDataComplete( + new JoinData + { + JoinNumber = 3, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "PAUSE", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("FSCAN")] + public JoinDataComplete ForwardScan = new JoinDataComplete( + new JoinData + { + JoinNumber = 4, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "FSCAN", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("RSCAN")] + public JoinDataComplete ReverseScan = new JoinDataComplete( + new JoinData + { + JoinNumber = 5, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "RSCAN", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("F_SKIP")] + public JoinDataComplete ForwardSkip = new JoinDataComplete( + new JoinData + { + JoinNumber = 6, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "F_SKIP", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("R_SKIP")] + public JoinDataComplete ReverseSkip = new JoinDataComplete( + new JoinData + { + JoinNumber = 7, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "R_SKIP", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("RECORD")] + public JoinDataComplete Record = new JoinDataComplete( + new JoinData + { + JoinNumber = 8, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "RECORD", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("POWER")] + public JoinDataComplete Power = new JoinDataComplete( + new JoinData + { + JoinNumber = 9, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "POWER", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("0")] + public JoinDataComplete Kp0 = new JoinDataComplete( + new JoinData + { + JoinNumber = 10, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "0", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("1")] + public JoinDataComplete Kp1 = new JoinDataComplete( + new JoinData + { + JoinNumber = 11, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "1", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("2")] + public JoinDataComplete Kp2 = new JoinDataComplete( + new JoinData + { + JoinNumber = 12, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "2", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("3")] + public JoinDataComplete Kp3 = new JoinDataComplete( + new JoinData + { + JoinNumber = 13, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "3", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("4")] + public JoinDataComplete Kp4 = new JoinDataComplete( + new JoinData + { + JoinNumber = 14, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "4", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("5")] + public JoinDataComplete Kp5 = new JoinDataComplete( + new JoinData + { + JoinNumber = 15, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "5", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("6")] + public JoinDataComplete Kp6 = new JoinDataComplete( + new JoinData + { + JoinNumber = 16, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "6", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("7")] + public JoinDataComplete Kp7 = new JoinDataComplete( + new JoinData + { + JoinNumber = 17, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "7", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("8")] + public JoinDataComplete Kp8 = new JoinDataComplete( + new JoinData + { + JoinNumber = 18, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "8", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("9")] + public JoinDataComplete Kp9 = new JoinDataComplete( + new JoinData + { + JoinNumber = 19, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "9", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + // [JoinName("+10")] + // public JoinDataComplete Kp9 = new JoinDataComplete( + // new JoinData + // { + // JoinNumber = 20, + // JoinSpan = 1 + // }, + // new JoinMetadata + // { + // Description = "+10", + // JoinCapabilities = eJoinCapabilities.FromSIMPL, + // JoinType = eJoinType.Digital + // }); + + [JoinName("ENTER")] + public JoinDataComplete Enter = new JoinDataComplete( + new JoinData + { + JoinNumber = 21, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "ENTER", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CH+")] + public JoinDataComplete ChannelUp = new JoinDataComplete( + new JoinData + { + JoinNumber = 22, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "CH+", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CH-")] + public JoinDataComplete ChannelDown = new JoinDataComplete( + new JoinData + { + JoinNumber = 23, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "CH-", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("*")] + public JoinDataComplete KpStar = new JoinDataComplete( + new JoinData + { + JoinNumber = 24, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "*", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("#")] + public JoinDataComplete KpPound = new JoinDataComplete( + new JoinData + { + JoinNumber = 25, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "#", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + // [JoinName(".")] + // public JoinDataComplete KpPound = new JoinDataComplete( + // new JoinData + // { + // JoinNumber = 26, + // JoinSpan = 1 + // }, + // new JoinMetadata + // { + // Description = ".", + // JoinCapabilities = eJoinCapabilities.FromSIMPL, + // JoinType = eJoinType.Digital + // }); + + [JoinName("POWER_ON")] + public JoinDataComplete PowerOn = new JoinDataComplete( + new JoinData + { + JoinNumber = 27, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "POWER_ON", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("POWER_OFF")] + public JoinDataComplete PowerOff = new JoinDataComplete( + new JoinData + { + JoinNumber = 28, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "POWER_OFF", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("PLAY_PAUSE")] + public JoinDataComplete PlayPause = new JoinDataComplete( + new JoinData + { + JoinNumber = 29, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "PLAY_PAUSE", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("LAST")] + public JoinDataComplete Last = new JoinDataComplete( + new JoinData + { + JoinNumber = 30, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "LAST", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("HOME")] + public JoinDataComplete Home = new JoinDataComplete( + new JoinData + { + JoinNumber = 40, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "HOME", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("BACK")] + public JoinDataComplete Back = new JoinDataComplete( + new JoinData + { + JoinNumber = 41, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "BACK", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + + [JoinName("GUIDE")] + public JoinDataComplete Guide = new JoinDataComplete( + new JoinData + { + JoinNumber = 42, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "GUIDE", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("INFO")] + public JoinDataComplete Info = new JoinDataComplete( + new JoinData + { + JoinNumber = 43, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "INFO", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("MENU")] + public JoinDataComplete Menu = new JoinDataComplete( + new JoinData + { + JoinNumber = 44, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "MENU", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("UP_ARROW")] + public JoinDataComplete DpadUp = new JoinDataComplete( + new JoinData + { + JoinNumber = 45, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "UP_ARROW", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DN_ARROW")] + public JoinDataComplete DpadDown = new JoinDataComplete( + new JoinData + { + JoinNumber = 46, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "DN_ARROW", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("LEFT_ARROW")] + public JoinDataComplete DpadLeft = new JoinDataComplete( + new JoinData + { + JoinNumber = 47, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "LEFT_ARROW", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("RIGHT_ARROW")] + public JoinDataComplete DpadRight = new JoinDataComplete( + new JoinData + { + JoinNumber = 48, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "RIGHT_ARROW", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("SELECT")] + public JoinDataComplete DpadSelect = new JoinDataComplete( + new JoinData + { + JoinNumber = 49, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "SELECT", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("OPTIONS")] + public JoinDataComplete Options = new JoinDataComplete( + new JoinData + { + JoinNumber = 50, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "OPTIONS", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("RETURN")] + public JoinDataComplete Return = new JoinDataComplete( + new JoinData + { + JoinNumber = 51, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "RETURN", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DVR")] + public JoinDataComplete Dvr = new JoinDataComplete( + new JoinData + { + JoinNumber = 52, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "DVR", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + + [JoinName("ON_DEMAND")] + public JoinDataComplete OnDemand = new JoinDataComplete( + new JoinData + { + JoinNumber = 53, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "ON_DEMAND", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + + [JoinName("PAGE_UP")] + public JoinDataComplete PageUp = new JoinDataComplete( + new JoinData + { + JoinNumber = 54, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "PAGE_UP", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("PAGE_DOWN")] + public JoinDataComplete PageDown = new JoinDataComplete( + new JoinData + { + JoinNumber = 55, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "PAGE_DOWN", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("F_SRCH")] + public JoinDataComplete ForwardSearch = new JoinDataComplete( + new JoinData + { + JoinNumber = 56, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "F_SRCH", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("R_SRCH")] + public JoinDataComplete ReverseSearch = new JoinDataComplete( + new JoinData + { + JoinNumber = 57, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "R_SRCH", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("TRACK+")] + public JoinDataComplete TrackPlus = new JoinDataComplete( + new JoinData + { + JoinNumber = 58, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "TRACK+", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("TRACK-")] + public JoinDataComplete TrackMinus = new JoinDataComplete( + new JoinData + { + JoinNumber = 59, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "TRACK-", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("A")] + public JoinDataComplete KpA = new JoinDataComplete( + new JoinData + { + JoinNumber = 61, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "A", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("B")] + public JoinDataComplete KpB = new JoinDataComplete( + new JoinData + { + JoinNumber = 62, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "B", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("C")] + public JoinDataComplete KpC = new JoinDataComplete( + new JoinData + { + JoinNumber = 63, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "C", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("D")] + public JoinDataComplete KpD = new JoinDataComplete( + new JoinData + { + JoinNumber = 64, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "D", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("RED")] + public JoinDataComplete KpRed = new JoinDataComplete( + new JoinData + { + JoinNumber = 65, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "RED", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("GREEN")] + public JoinDataComplete KpGreen = new JoinDataComplete( + new JoinData + { + JoinNumber = 66, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "GREEN", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("YELLOW")] + public JoinDataComplete KpYellow = new JoinDataComplete( + new JoinData + { + JoinNumber = 67, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "YELLOW", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("BLUE")] + public JoinDataComplete KpBlue = new JoinDataComplete( + new JoinData + { + JoinNumber = 68, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "BLUE", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + public GenericIrControllerJoinMap(uint joinStart) + : base(joinStart, typeof(GenericIrControllerJoinMap)) + { + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Bridges/JoinMaps/HdPsXxxControllerJoinMap.cs b/src/PepperDash.Essentials.Core/Bridges/JoinMaps/HdPsXxxControllerJoinMap.cs new file mode 100644 index 00000000..3f2901c9 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Bridges/JoinMaps/HdPsXxxControllerJoinMap.cs @@ -0,0 +1,190 @@ +using System; +using PepperDash.Essentials.Core; + +namespace PepperDash_Essentials_Core.Bridges +{ + public class HdPsXxxControllerJoinMap : JoinMapBaseAdvanced + { + + #region Digital + + [JoinName("EnableAutoRoute")] + public JoinDataComplete EnableAutoRoute = new JoinDataComplete( + new JoinData + { + JoinNumber = 1, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Enable Automatic Routing on Xx1 Switchers", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + + [JoinName("InputSync")] + public JoinDataComplete InputSync = new JoinDataComplete( + new JoinData + { + JoinNumber = 2, + JoinSpan = 8 + }, + new JoinMetadata + { + Description = "Device Input Sync", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + + [JoinName("EnableInputHdcp")] + public JoinDataComplete EnableInputHdcp = new JoinDataComplete( + new JoinData + { + JoinNumber = 11, + JoinSpan = 8 + }, + new JoinMetadata + { + Description = "Device Enable Input Hdcp", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + + [JoinName("DisableInputHdcp")] + public JoinDataComplete DisableInputHdcp = new JoinDataComplete( + new JoinData + { + JoinNumber = 21, + JoinSpan = 8 + }, + new JoinMetadata + { + Description = "Device Disnable Input Hdcp", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + + [JoinName("IsOnline")] + public JoinDataComplete IsOnline = new JoinDataComplete( + new JoinData + { + JoinNumber = 30, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Device Onlne", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + #endregion + + + #region Analog + + [JoinName("OutputRoute")] + public JoinDataComplete OutputRoute = new JoinDataComplete( + new JoinData + { + JoinNumber = 11, + JoinSpan = 2 + }, + new JoinMetadata + { + Description = "Device Output Route Set/Get", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Analog + }); + + #endregion + + + #region Serial + + [JoinName("Name")] + public JoinDataComplete Name = new JoinDataComplete( + new JoinData + { + JoinNumber = 1, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Device Name", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + + [JoinName("InputName")] + public JoinDataComplete InputName = new JoinDataComplete( + new JoinData + { + JoinNumber = 2, + JoinSpan = 8 + }, + new JoinMetadata + { + Description = "Device Input Name", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + + [JoinName("OutputName")] + public JoinDataComplete OutputName = new JoinDataComplete( + new JoinData + { + JoinNumber = 11, + JoinSpan = 2 + }, + new JoinMetadata + { + Description = "Device Output Name", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + + [JoinName("OutputRoutedName")] + public JoinDataComplete OutputRoutedName = new JoinDataComplete( + new JoinData + { + JoinNumber = 16, + JoinSpan = 2 + }, + new JoinMetadata + { + Description = "Device Output Route Name", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + + #endregion + + /// + /// Constructor to use when instantiating this join map without inheriting from it + /// + /// Join this join map will start at + public HdPsXxxControllerJoinMap(uint joinStart) + : this(joinStart, typeof(HdPsXxxControllerJoinMap)) + { + } + + /// + /// Constructor to use when extending this Join map + /// + /// Join this join map will start at + /// Type of the child join map + protected HdPsXxxControllerJoinMap(uint joinStart, Type type) + : base(joinStart, type) + { + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Bridges/JoinMaps/PduJoinMapBase.cs b/src/PepperDash.Essentials.Core/Bridges/JoinMaps/PduJoinMapBase.cs index 2ac56ff1..0c2e9ed9 100644 --- a/src/PepperDash.Essentials.Core/Bridges/JoinMaps/PduJoinMapBase.cs +++ b/src/PepperDash.Essentials.Core/Bridges/JoinMaps/PduJoinMapBase.cs @@ -10,7 +10,7 @@ namespace PepperDash.Essentials.Core.Bridges [JoinName("Online")] public JoinDataComplete Online = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "PDU Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + new JoinMetadata { Description = "Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); [JoinName("OutletCount")] public JoinDataComplete OutletCount = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, diff --git a/src/PepperDash.Essentials.Core/Bridges/JoinMaps/SystemMonitorJoinMap.cs b/src/PepperDash.Essentials.Core/Bridges/JoinMaps/SystemMonitorJoinMap.cs index ffcd5777..9adabfce 100644 --- a/src/PepperDash.Essentials.Core/Bridges/JoinMaps/SystemMonitorJoinMap.cs +++ b/src/PepperDash.Essentials.Core/Bridges/JoinMaps/SystemMonitorJoinMap.cs @@ -47,7 +47,7 @@ namespace PepperDash.Essentials.Core.Bridges [JoinName("ProgramOffsetJoin")] public JoinDataComplete ProgramOffsetJoin = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 5 }, new JoinMetadata { Description = "All Program Data is offset between slots by 5 - First Joins Start at 11", JoinCapabilities = eJoinCapabilities.None, JoinType = eJoinType.None }); - + [JoinName("ProgramStart")] public JoinDataComplete ProgramStart = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 1 }, new JoinMetadata { Description = "Processor Program Start / Fb", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); @@ -132,6 +132,23 @@ namespace PepperDash.Essentials.Core.Bridges public JoinDataComplete DhcpStatus = new JoinDataComplete(new JoinData { JoinNumber = 86, JoinSpan = 1 }, new JoinMetadata { Description = "Processor Ethernet Dhcp Status", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("ProcessorRebot")] + public JoinDataComplete ProcessorReboot = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Reboot processor", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("IsAppliance")] + public JoinDataComplete IsAppliance = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Is appliance Fb", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("IsServer")] + public JoinDataComplete IsServer = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "Is server Fb", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("ProgramReset")] + public JoinDataComplete ProgramReset = new JoinDataComplete(new JoinData { JoinNumber = 15, JoinSpan = 1 }, + new JoinMetadata { Description = "Resets the program", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + /// /// Constructor to use when instantiating this Join Map without inheriting from it /// diff --git a/src/PepperDash.Essentials.Core/Comm and IR/CommFactory.cs b/src/PepperDash.Essentials.Core/Comm and IR/CommFactory.cs index 892caa92..8c132a1b 100644 --- a/src/PepperDash.Essentials.Core/Comm and IR/CommFactory.cs +++ b/src/PepperDash.Essentials.Core/Comm and IR/CommFactory.cs @@ -83,6 +83,15 @@ namespace PepperDash.Essentials.Core } case eControlMethod.Telnet: break; + case eControlMethod.SecureTcpIp: + { + var secureTcp = new GenericSecureTcpIpClient(deviceConfig.Key + "-secureTcp", c.Address, c.Port, c.BufferSize); + secureTcp.AutoReconnect = c.AutoReconnect; + if (secureTcp.AutoReconnect) + secureTcp.AutoReconnectIntervalMs = c.AutoReconnectIntervalMs; + comm = secureTcp; + break; + } default: break; } @@ -117,41 +126,54 @@ namespace PepperDash.Essentials.Core /// public static ICec GetCecPort(ControlPropertiesConfig config) { - var dev = DeviceManager.GetDeviceForKey(config.ControlPortDevKey); + try + { + var dev = DeviceManager.GetDeviceForKey(config.ControlPortDevKey); - if (dev != null) - { - if (!String.IsNullOrEmpty(config.ControlPortName)) - { + Debug.Console(0, "GetCecPort: device '{0}' {1}", config.ControlPortDevKey, dev == null + ? "is not valid, failed to get cec port" + : "found in device manager, attempting to get cec port"); - var inputPort = (dev as IRoutingInputsOutputs).InputPorts[config.ControlPortName]; + if (dev == null) + return null; - if (inputPort != null) - { - if (inputPort.Port is ICec) - return inputPort.Port as ICec; - } + if (String.IsNullOrEmpty(config.ControlPortName)) + { + Debug.Console(0, "GetCecPort: '{0}' - Configuration missing 'ControlPortName'", config.ControlPortDevKey); + return null; + } - var outputPort = (dev as IRoutingInputsOutputs).OutputPorts[config.ControlPortName]; - if (outputPort != null) - { - if (outputPort.Port is ICec) - return outputPort.Port as ICec; - } + var inputsOutputs = dev as IRoutingInputsOutputs; + if (inputsOutputs == null) + { + Debug.Console(0, "GetCecPort: Device '{0}' does not support IRoutingInputsOutputs, failed to get CEC port called '{1}'", + config.ControlPortDevKey, config.ControlPortName); - else - Debug.Console(0, "GetCecPort: Device '{0}' does not have a CEC port called: '{1}'", - config.ControlPortDevKey, config.ControlPortName); - } - else - { - Debug.Console(0, "GetCecPort: '{0}' - Configuration missing 'ControlPortName'", config.ControlPortDevKey); - } - } - Debug.Console(0, "GetCecPort: Device '{0}' is not a valid device.", config.ControlPortDevKey); + return null; + } - return null; + var inputPort = inputsOutputs.InputPorts[config.ControlPortName]; + if (inputPort != null && inputPort.Port is ICec) + return inputPort.Port as ICec; + + + var outputPort = inputsOutputs.OutputPorts[config.ControlPortName]; + if (outputPort != null && outputPort.Port is ICec) + return outputPort.Port as ICec; + } + catch (Exception ex) + { + Debug.Console(1, "GetCecPort Exception Message: {0}", ex.Message); + Debug.Console(2, "GetCecPort Exception StackTrace: {0}", ex.StackTrace); + if (ex.InnerException != null) + Debug.Console(0, "GetCecPort Exception InnerException: {0}", ex.InnerException); + } + + Debug.Console(0, "GetCecPort: Device '{0}' does not have a CEC port called '{1}'", + config.ControlPortDevKey, config.ControlPortName); + + return null; } /// diff --git a/src/PepperDash.Essentials.Core/Comm and IR/IRPortHelper.cs b/src/PepperDash.Essentials.Core/Comm and IR/IRPortHelper.cs index b682af71..4d99edc0 100644 --- a/src/PepperDash.Essentials.Core/Comm and IR/IRPortHelper.cs +++ b/src/PepperDash.Essentials.Core/Comm and IR/IRPortHelper.cs @@ -226,12 +226,18 @@ namespace PepperDash.Essentials.Core /// public class IrOutPortConfig { + [JsonProperty("port")] public IROutputPort Port { get; set; } + + [JsonProperty("fileName")] public string FileName { get; set; } + [JsonProperty("useBridgeJoinMap")] + public bool UseBridgeJoinMap { get; set; } + public IrOutPortConfig() { - FileName = ""; + FileName = ""; } } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Device Info/NetworkDeviceHelpers.cs b/src/PepperDash.Essentials.Core/Device Info/NetworkDeviceHelpers.cs new file mode 100644 index 00000000..04e697c9 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Device Info/NetworkDeviceHelpers.cs @@ -0,0 +1,218 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using PepperDash.Core; +using Crestron.SimplSharp; +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.Core.DeviceInfo +{ + public static class NetworkDeviceHelpers + { + /// + /// Event raised when ArpTable changes + /// + public static event ArpTableEventHandler ArpTableUpdated; + + /// + /// Delegate called by ArpTableUpdated + /// + /// contains the entire ARP table and a bool to note if there was an error in retrieving the data + public delegate void ArpTableEventHandler(ArpTableEventArgs args); + + private static readonly char NewLineSplitter = CrestronEnvironment.NewLine.ToCharArray().First(); + private static readonly string NewLine = CrestronEnvironment.NewLine; + + private static readonly CCriticalSection Lock = new CCriticalSection(); + + /// + /// Last resolved ARP table - it is recommended to refresh the arp before using this. + /// + public static List ArpTable { get; private set; } + + /// + /// Force recheck of ARP table + /// + public static void RefreshArp() + { + var error = false; + try + { + Lock.Enter(); + var consoleResponse = string.Empty; + if (!CrestronConsole.SendControlSystemCommand("showarptable", ref consoleResponse)) return; + if (string.IsNullOrEmpty(consoleResponse)) + { + error = true; + return; + } + ArpTable.Clear(); + + Debug.Console(2, "ConsoleResponse of 'showarptable' : {0}{1}", NewLine, consoleResponse); + + var myLines = + consoleResponse.Split(NewLineSplitter) + .ToList() + .Where(o => (o.Contains(':') && !o.Contains("Type", StringComparison.OrdinalIgnoreCase))) + .ToList(); + foreach (var line in myLines) + { + var item = line; + var seperator = item.Contains('\t') ? '\t' : ' '; + var dataPoints = item.Split(seperator); + if (dataPoints == null || dataPoints.Length < 2) continue; + var ipAddress = SanitizeIpAddress(dataPoints.First().TrimAll()); + var macAddress = dataPoints.Last(); + ArpTable.Add(new ArpEntry(ipAddress, macAddress)); + } + } + catch (Exception ex) + { + Debug.Console(0, "Exception in \"RefreshArp\" : {0}", ex.Message); + error = true; + } + finally + { + Lock.Leave(); + OnArpTableUpdated(new ArpTableEventArgs(ArpTable, error)); + } + } + + + private static void OnArpTableUpdated(ArpTableEventArgs args) + { + if (args == null) return; + var handler = ArpTableUpdated; + if (handler == null) return; + handler.Invoke(args); + } + + static NetworkDeviceHelpers() + { + ArpTable = new List(); + } + + /// + /// Removes leading zeros, leading whitespace, and trailing whitespace from an IPAddress string + /// + /// Ip Address to Santitize + /// Sanitized Ip Address + public static string SanitizeIpAddress(string ipAddressIn) + { + try + { + var ipAddress = IPAddress.Parse(ipAddressIn.TrimStart('0')); + return ipAddress.ToString(); + } + catch (Exception ex) + { + Debug.Console(0, "Unable to Santize Ip : {0}", ex.Message); + return ipAddressIn; + } + } + + /// + /// Resolves a hostname by IP Address using DNS + /// + /// IP Address to resolve from + /// Resolved Hostname - on failure to determine hostname, will return IP Address + public static string ResolveHostnameFromIp(string ipAddress) + { + try + { + var santitizedIp = SanitizeIpAddress(ipAddress); + var hostEntry = Dns.GetHostEntry(santitizedIp); + return hostEntry == null ? ipAddress : hostEntry.HostName; + } + catch (Exception ex) + { + Debug.Console(0, "Exception Resolving Hostname from IP Address : {0}", ex.Message); + return ipAddress; + } + } + + /// + /// Resolves an IP Address by hostname using DNS + /// + /// Hostname to resolve from + /// Resolved IP Address - on a failure to determine IP Address, will return hostname + public static string ResolveIpFromHostname(string hostName) + { + try + { + var hostEntry = Dns.GetHostEntry(hostName); + return hostEntry == null ? hostName : hostEntry.AddressList.First().ToString(); + } + catch (Exception ex) + { + Debug.Console(0, "Exception Resolving IP Address from Hostname : {0}", ex.Message); + return hostName; + } + } + + } + + /// + /// Object to hold data about an arp entry + /// + public class ArpEntry + { + public readonly IPAddress IpAddress; + public readonly string MacAddress; + + /// + /// Constructs new ArpEntry object + /// + /// string formatted as ipv4 address + /// mac address string - format is unimportant + public ArpEntry(string ipAddress, string macAddress) + { + if (string.IsNullOrEmpty(ipAddress)) + { + throw new ArgumentException("\"ipAddress\" cannot be null or empty"); + } + if (string.IsNullOrEmpty(macAddress)) + { + throw new ArgumentException("\"macAddress\" cannot be null or empty"); + } + IpAddress = IPAddress.Parse(ipAddress.TrimStart().TrimStart('0').TrimEnd()); + MacAddress = macAddress; + } + } + + /// + /// Arguments passed by the ArpTableUpdated event + /// + public class ArpTableEventArgs : EventArgs + { + /// + /// The retrieved ARP Table + /// + public readonly List ArpTable; + /// + /// True if there was a problem retrieving the ARP Table + /// + public readonly bool Error; + + /// + /// Constructor for ArpTableEventArgs + /// + /// The entirety of the retrieved ARP table + /// True of an error was encountered updating the ARP table + public ArpTableEventArgs(List arpTable, bool error) + { + ArpTable = arpTable; + Error = error; + } + + /// + /// Constructor for ArpTableEventArgs - assumes no error encountered in retrieving ARP Table + /// + /// The entirety of the retrieved ARP table + public ArpTableEventArgs(List arpTable) + { + ArpTable = arpTable; + Error = false; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/DeviceManager.cs b/src/PepperDash.Essentials.Core/Devices/DeviceManager.cs index 12b3b948..f0101c6c 100644 --- a/src/PepperDash.Essentials.Core/Devices/DeviceManager.cs +++ b/src/PepperDash.Essentials.Core/Devices/DeviceManager.cs @@ -379,30 +379,28 @@ namespace PepperDash.Essentials.Core /// Prints a list of routing inputs and outputs by device key. /// /// Device key from which to report data - public static void GetRoutingPorts(string s) - { - var device = GetDeviceForKey(s); + public static void GetRoutingPorts(string s) + { + var device = GetDeviceForKey(s); if (device == null) return; var inputPorts = ((device as IRoutingInputs) != null) ? (device as IRoutingInputs).InputPorts : null; var outputPorts = ((device as IRoutingOutputs) != null) ? (device as IRoutingOutputs).OutputPorts : null; - if (inputPorts != null) - { - Debug.Console(0, "Device {0} has {1} Input Ports:", s, inputPorts.Count); - foreach (var routingInputPort in inputPorts) - { - Debug.Console(0, "{0}", routingInputPort.Key); - } - } - if (outputPorts != null) - { - Debug.Console(0, "Device {0} has {1} Output Ports:", s, outputPorts.Count); - foreach (var routingOutputPort in outputPorts) - { - Debug.Console(0, "{0}", routingOutputPort.Key); - } - } - } + if (inputPorts != null) + { + CrestronConsole.ConsoleCommandResponse("Device {0} has {1} Input Ports:{2}", s, inputPorts.Count, CrestronEnvironment.NewLine); + foreach (var routingInputPort in inputPorts) + { + CrestronConsole.ConsoleCommandResponse("{0}{1}", routingInputPort.Key, CrestronEnvironment.NewLine); + } + } + if (outputPorts == null) return; + CrestronConsole.ConsoleCommandResponse("Device {0} has {1} Output Ports:{2}", s, outputPorts.Count, CrestronEnvironment.NewLine); + foreach (var routingOutputPort in outputPorts) + { + CrestronConsole.ConsoleCommandResponse("{0}{1}", routingOutputPort.Key, CrestronEnvironment.NewLine); + } + } /// /// Attempts to set the debug level of a device @@ -435,7 +433,7 @@ namespace PepperDash.Essentials.Core if (device == null) { - Debug.Console(0, "Unable to get device with key: {0}", deviceKey); + CrestronConsole.ConsoleCommandResponse("Unable to get device with key: {0}", deviceKey); return; } @@ -447,7 +445,7 @@ namespace PepperDash.Essentials.Core } catch { - Debug.Console(0, "Unable to convert setting value. Please use off/rx/tx/both"); + CrestronConsole.ConsoleCommandResponse("Unable to convert setting value. Please use off/rx/tx/both"); return; } @@ -458,18 +456,18 @@ namespace PepperDash.Essentials.Core var min = Convert.ToUInt32(timeout); device.StreamDebugging.SetDebuggingWithSpecificTimeout(debugSetting, min); - Debug.Console(0, "Device: '{0}' debug level set to {1} for {2} minutes", deviceKey, debugSetting, min); + CrestronConsole.ConsoleCommandResponse("Device: '{0}' debug level set to {1} for {2} minutes", deviceKey, debugSetting, min); } catch (Exception e) { - Debug.Console(0, "Unable to convert minutes or settings value. Please use an integer value for minutes. Errro: {0}", e); + CrestronConsole.ConsoleCommandResponse("Unable to convert minutes or settings value. Please use an integer value for minutes. Error: {0}", e); } } else { device.StreamDebugging.SetDebuggingWithDefaultTimeout(debugSetting); - Debug.Console(0, "Device: '{0}' debug level set to {1} for default time (30 minutes)", deviceKey, debugSetting); + CrestronConsole.ConsoleCommandResponse("Device: '{0}' debug level set to {1} for default time (30 minutes)", deviceKey, debugSetting); } } diff --git a/src/PepperDash.Essentials.Core/Devices/EssentialsDevice.cs b/src/PepperDash.Essentials.Core/Devices/EssentialsDevice.cs index bc8af721..1846a512 100644 --- a/src/PepperDash.Essentials.Core/Devices/EssentialsDevice.cs +++ b/src/PepperDash.Essentials.Core/Devices/EssentialsDevice.cs @@ -121,6 +121,41 @@ namespace PepperDash.Essentials.Core #endregion } + public abstract class ProcessorExtensionDeviceFactory : IProcessorExtensionDeviceFactory where T: EssentialsDevice + { + #region IProcessorExtensionDeviceFactory Members + + /// + /// A list of strings that can be used in the type property of a DeviceConfig object to build an instance of this device + /// + public List TypeNames { get; protected set; } + + /// + /// Loads an item to the ProcessorExtensionDeviceFactory.ProcessorExtensionFactoryMethods dictionary for each entry in the TypeNames list + /// + public void LoadFactories() + { + foreach (var typeName in TypeNames) + { + //Debug.Console(2, "Getting Description Attribute from class: '{0}'", typeof(T).FullName); + var descriptionAttribute = typeof(T).GetCustomAttributes(typeof(DescriptionAttribute), true) as DescriptionAttribute[]; + string description = descriptionAttribute[0].Description; + var snippetAttribute = typeof(T).GetCustomAttributes(typeof(ConfigSnippetAttribute), true) as ConfigSnippetAttribute[]; + ProcessorExtensionDeviceFactory.AddFactoryForType(typeName.ToLower(), description, typeof(T), BuildDevice); + } + } + + /// + /// The method that will build the device + /// + /// The device config + /// An instance of the device + public abstract EssentialsDevice BuildDevice(DeviceConfig dc); + + #endregion + + } + /// /// Devices the basic needs for a Device Factory /// diff --git a/src/PepperDash.Essentials.Core/Devices/GenericIRController.cs b/src/PepperDash.Essentials.Core/Devices/GenericIRController.cs index 3c35b686..178e0c30 100644 --- a/src/PepperDash.Essentials.Core/Devices/GenericIRController.cs +++ b/src/PepperDash.Essentials.Core/Devices/GenericIRController.cs @@ -2,12 +2,13 @@ using System; using System.Collections.Generic; +using System.Linq; using Crestron.SimplSharpPro.DeviceSupport; using Full.Newtonsoft.Json; using PepperDash.Core; -using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Config; +using PepperDash_Essentials_Core.Bridges.JoinMaps; namespace PepperDash.Essentials.Core.Devices { @@ -21,12 +22,11 @@ namespace PepperDash.Essentials.Core.Devices private readonly IrOutputPortController _port; - public string[] IrCommands {get { return _port.IrFileCommands; }} + public string[] IrCommands {get { return _port.IrFileCommands; }} public GenericIrController(string key, string name, IrOutputPortController irPort) : base(key, name) { _port = irPort; - if (_port == null) { Debug.Console(0, this, Debug.ErrorLogLevel.Error, "IR Port is null, device will not function"); @@ -73,23 +73,65 @@ namespace PepperDash.Essentials.Core.Devices if (!string.IsNullOrEmpty(joinMapSerialized)) joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - for (uint i = 0; i < _port.IrFileCommands.Length; i++) - { - var cmd = _port.IrFileCommands[i]; - var joinData = new JoinDataComplete(new JoinData {JoinNumber = i, JoinSpan = 1}, - new JoinMetadata - { - Description = cmd, - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); + if (_port.UseBridgeJoinMap) + { + Debug.Console(0, this, "Using new IR bridge join map"); - joinData.SetJoinOffset(joinStart); + var bridgeJoins = joinMap.Joins.Where((kv) => _port.IrFileCommands.Any(cmd => cmd == kv.Key)).ToDictionary(kv => kv.Key); + if (bridgeJoins == null) + { + Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Failed to link new IR bridge join map"); + return; + } - joinMap.Joins.Add(cmd,joinData); + joinMap.Joins.Clear(); - trilist.SetBoolSigAction(joinData.JoinNumber, (b) => Press(cmd, b)); - } + foreach (var bridgeJoin in bridgeJoins) + { + var key = bridgeJoin.Key; + var joinDataKey = bridgeJoin.Value.Key; + var joinDataValue = bridgeJoin.Value.Value; + var joinNumber = bridgeJoin.Value.Value.JoinNumber; + + Debug.Console(2, this, @"bridgeJoin: Key-'{0}' +Value.Key-'{1}' +Value.JoinNumber-'{2}' +Value.Metadata.Description-'{3}'", + key, + joinDataKey, + joinNumber, + joinDataValue.Metadata.Description); + + + joinMap.Joins.Add(key, joinDataValue); + + trilist.SetBoolSigAction(joinNumber, (b) => Press(key, b)); + } + } + else + { + Debug.Console(0, this, "Using legacy IR join mapping based on available IR commands"); + + joinMap.Joins.Clear(); + + for (uint i = 0; i < _port.IrFileCommands.Length; i++) + { + var cmd = _port.IrFileCommands[i]; + var joinData = new JoinDataComplete(new JoinData { JoinNumber = i, JoinSpan = 1 }, + new JoinMetadata + { + Description = cmd, + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + joinData.SetJoinOffset(joinStart); + + joinMap.Joins.Add(cmd, joinData); + + trilist.SetBoolSigAction(joinData.JoinNumber, (b) => Press(cmd, b)); + } + } joinMap.PrintJoinMapInfo(); @@ -111,13 +153,6 @@ namespace PepperDash.Essentials.Core.Devices } } - public sealed class GenericIrControllerJoinMap : JoinMapBaseAdvanced - { - public GenericIrControllerJoinMap(uint joinStart) : base(joinStart) - { - } - } - public class GenericIrControllerFactory : EssentialsDeviceFactory { public GenericIrControllerFactory() diff --git a/src/PepperDash.Essentials.Core/Devices/IVolumeAndAudioInterfaces.cs b/src/PepperDash.Essentials.Core/Devices/IVolumeAndAudioInterfaces.cs index c8a5df39..c8033b92 100644 --- a/src/PepperDash.Essentials.Core/Devices/IVolumeAndAudioInterfaces.cs +++ b/src/PepperDash.Essentials.Core/Devices/IVolumeAndAudioInterfaces.cs @@ -72,6 +72,10 @@ namespace PepperDash.Essentials.Core { IBasicVolumeControls CurrentVolumeControls { get; } event EventHandler CurrentVolumeDeviceChange; + + void SetDefaultLevels(); + + bool ZeroVolumeWhenSwtichingVolumeDevices { get; } } diff --git a/src/PepperDash.Essentials.Core/Devices/IrOutputPortController.cs b/src/PepperDash.Essentials.Core/Devices/IrOutputPortController.cs index d3d6e19e..6ffee074 100644 --- a/src/PepperDash.Essentials.Core/Devices/IrOutputPortController.cs +++ b/src/PepperDash.Essentials.Core/Devices/IrOutputPortController.cs @@ -31,6 +31,8 @@ namespace PepperDash.Essentials.Core public string[] IrFileCommands { get { return IrPort.AvailableStandardIRCmds(IrPortUid); } } + public bool UseBridgeJoinMap { get; private set; } + /// /// Constructor for IrDevice base class. If a null port is provided, this class will /// still function without trying to talk to a port. @@ -55,9 +57,10 @@ namespace PepperDash.Essentials.Core : base(key) { DriverLoaded = new BoolFeedback(() => DriverIsLoaded); + UseBridgeJoinMap = config.Properties["control"].Value("useBridgeJoinMap"); AddPostActivationAction(() => { - IrPort = postActivationFunc(config); + IrPort = postActivationFunc(config); if (IrPort == null) { @@ -69,8 +72,8 @@ namespace PepperDash.Essentials.Core Debug.Console(1, "*************Attempting to load IR file: {0}***************", filePath); LoadDriver(filePath); - - PrintAvailableCommands(); + + PrintAvailableCommands(); }); } diff --git a/src/PepperDash.Essentials.Core/Devices/PduInterfaces.cs b/src/PepperDash.Essentials.Core/Devices/PduInterfaces.cs index 0f3b3fbf..94aa71ac 100644 --- a/src/PepperDash.Essentials.Core/Devices/PduInterfaces.cs +++ b/src/PepperDash.Essentials.Core/Devices/PduInterfaces.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using Crestron.SimplSharp; using PepperDash.Core; using PepperDash.Essentials.Core; @@ -8,6 +9,7 @@ namespace PepperDash_Essentials_Core.Devices /// /// Interface for any device that is able to control it'spower and has a configurable reboot time /// + [Obsolete("PepperDash_Essentials_Core.Devices is Deprecated - use PepperDash.Essentials.Core")] public interface IHasPowerCycle : IKeyName, IHasPowerControlWithFeedback { /// @@ -24,6 +26,7 @@ namespace PepperDash_Essentials_Core.Devices /// /// Interface for any device that contains a collection of IHasPowerReboot Devices /// + [Obsolete("PepperDash_Essentials_Core.Devices is Deprecated - use PepperDash.Essentials.Core")] public interface IHasControlledPowerOutlets : IKeyName { /// diff --git a/src/PepperDash.Essentials.Core/Devices/PowerInterfaces.cs b/src/PepperDash.Essentials.Core/Devices/PowerInterfaces.cs new file mode 100644 index 00000000..1fc6672a --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/PowerInterfaces.cs @@ -0,0 +1,87 @@ +using Crestron.SimplSharp; +using PepperDash.Core; + +namespace PepperDash.Essentials.Core +{ + /// + /// Interface for any device that has a battery that can be monitored + /// + public interface IHasBatteryStats : IKeyName + { + int BatteryPercentage { get; } + int BatteryCautionThresholdPercentage { get; } + int BatteryWarningThresholdPercentage { get; } + BoolFeedback BatteryIsWarningFeedback { get; } + BoolFeedback BatteryIsCautionFeedback { get; } + BoolFeedback BatteryIsOkFeedback { get; } + IntFeedback BatteryPercentageFeedback { get; } + } + + /// + /// Interface for any device that has a battery that can be monitored and the ability to charge and discharge + /// + public interface IHasBatteryCharging : IHasBatteryStats + { + BoolFeedback BatteryIsCharging { get; } + } + + /// + /// Interface for any device that has multiple batteries that can be monitored + /// + public interface IHasBatteries : IKeyName + { + ReadOnlyDictionary Batteries { get; } + } + + public interface IHasBatteryStatsExtended : IHasBatteryStats + { + int InputVoltage { get; } + int OutputVoltage { get; } + int InptuCurrent { get; } + int OutputCurrent { get; } + + IntFeedback InputVoltageFeedback { get; } + IntFeedback OutputVoltageFeedback { get; } + IntFeedback InputCurrentFeedback { get; } + IntFeedback OutputCurrentFeedback { get; } + } + + /// + /// Interface for any device that is able to control its power, has a configurable reboot time, and has batteries that can be monitored + /// + public interface IHasPowerCycleWithBattery : IHasPowerCycle, IHasBatteryStats + { + + } + + /// + /// Interface for any device that is able to control it's power and has a configurable reboot time + /// + public interface IHasPowerCycle : IKeyName, IHasPowerControlWithFeedback + { + /// + /// Delay between power off and power on for reboot + /// + int PowerCycleTimeMs { get; } + + /// + /// Reboot outlet + /// + void PowerCycle(); + } + + /// + /// Interface for any device that contains a collection of IHasPowerReboot Devices + /// + public interface IHasControlledPowerOutlets : IKeyName + { + /// + /// Collection of IPduOutlets + /// + ReadOnlyDictionary PduOutlets { get; } + + } + + + +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Extensions/StringExtensions.cs b/src/PepperDash.Essentials.Core/Extensions/StringExtensions.cs index 39501387..7bf8d5a5 100644 --- a/src/PepperDash.Essentials.Core/Extensions/StringExtensions.cs +++ b/src/PepperDash.Essentials.Core/Extensions/StringExtensions.cs @@ -1,4 +1,5 @@ using System; +using System.ComponentModel; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,17 +9,70 @@ namespace PepperDash.Essentials.Core { public static class StringExtensions { + /// + /// Returns null if a string is empty, otherwise returns the string + /// + /// string input + /// null if the string is emtpy, otherwise returns the string public static string NullIfEmpty(this string s) { return string.IsNullOrEmpty(s) ? null : s; } + + /// + /// Returns null if a string is empty or made of only whitespace characters, otherwise returns the string + /// + /// string input + /// null if the string is wempty or made of only whitespace characters, otherwise returns the string public static string NullIfWhiteSpace(this string s) { return string.IsNullOrEmpty(s.Trim()) ? null : s; } + + /// + /// Returns a replacement string if the input string is empty or made of only whitespace characters, otherwise returns the input string + /// + /// input string + /// string to replace with if input string is empty or whitespace + /// returns newString if s is null, emtpy, or made of whitespace characters, otherwise returns s public static string ReplaceIfNullOrEmpty(this string s, string newString) { return string.IsNullOrEmpty(s) ? newString : s; } + + /// + /// Overload for Contains that allows setting an explicit String Comparison + /// + /// Source String + /// String to check in Source String + /// Comparison parameters + /// true of string contains "toCheck" + public static bool Contains(this string source, string toCheck, StringComparison comp) + { + if (string.IsNullOrEmpty(source)) return false; + return source.IndexOf(toCheck, comp) >= 0; + } + + /// + /// Performs TrimStart() and TrimEnd() on source string + /// + /// String to Trim + /// Trimmed String + public static string TrimAll(this string source) + { + return string.IsNullOrEmpty(source) ? string.Empty : source.TrimStart().TrimEnd(); + } + + /// + /// Performs TrimStart(chars char[]) and TrimEnd(chars char[]) on source string. + /// + /// String to Trim + /// Char Array to trim from string + /// Trimmed String + public static string TrimAll(this string source, char[] chars) + { + return string.IsNullOrEmpty(source) ? string.Empty : source.TrimStart(chars).TrimEnd(chars); + } + } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Factory/DeviceFactory.cs b/src/PepperDash.Essentials.Core/Factory/DeviceFactory.cs index d53aef19..bfc32661 100644 --- a/src/PepperDash.Essentials.Core/Factory/DeviceFactory.cs +++ b/src/PepperDash.Essentials.Core/Factory/DeviceFactory.cs @@ -1,20 +1,13 @@ extern alias Full; +using Crestron.SimplSharp; +using Crestron.SimplSharp.Reflection; +using Full.Newtonsoft.Json.Linq; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.GeneralIO; -using Crestron.SimplSharp.Reflection; -using PepperDash.Core; -using Full.Newtonsoft.Json.Linq; -using Full.Newtonsoft.Json; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; -using PepperDash.Essentials.Core.CrestronIO; -using PepperDash.Essentials.Core.Touchpanels; namespace PepperDash.Essentials.Core { @@ -174,33 +167,26 @@ namespace PepperDash.Essentials.Core /// /// Prints the type names and associated metadata from the FactoryMethods collection. /// - /// + /// public static void GetDeviceFactoryTypes(string filter) { - Dictionary types = new Dictionary(); + var types = !string.IsNullOrEmpty(filter) + ? FactoryMethods.Where(k => k.Key.Contains(filter)).ToDictionary(k => k.Key, k => k.Value) + : FactoryMethods; - if (!string.IsNullOrEmpty(filter)) - { - types = FactoryMethods.Where(k => k.Key.Contains(filter)).ToDictionary(k => k.Key, k => k.Value); - } - else - { - types = FactoryMethods; - } - - Debug.Console(0, "Device Types:"); + CrestronConsole.ConsoleCommandResponse("Device Types:"); foreach (var type in types.OrderBy(t => t.Key)) { var description = type.Value.Description; var cType = "Not Specified by Plugin"; - if(type.Value.CType != null) + if (type.Value.CType != null) { cType = type.Value.CType.FullName; } - Debug.Console(0, + CrestronConsole.ConsoleCommandResponse( @"Type: '{0}' CType: '{1}' Description: {2}", type.Key, cType, description); diff --git a/src/PepperDash.Essentials.Core/Factory/IProcessorExtensionDeviceFactory.cs b/src/PepperDash.Essentials.Core/Factory/IProcessorExtensionDeviceFactory.cs new file mode 100644 index 00000000..a50ab16d --- /dev/null +++ b/src/PepperDash.Essentials.Core/Factory/IProcessorExtensionDeviceFactory.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PepperDash.Essentials.Core +{ + public interface IProcessorExtensionDeviceFactory + { + /// + /// Loads all the extension factories to the ProcessorExtensionDeviceFactory + /// + void LoadFactories(); + } +} diff --git a/src/PepperDash.Essentials.Core/Factory/ProcessorExtensionDeviceFactory.cs b/src/PepperDash.Essentials.Core/Factory/ProcessorExtensionDeviceFactory.cs new file mode 100644 index 00000000..a5b57ad3 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Factory/ProcessorExtensionDeviceFactory.cs @@ -0,0 +1,155 @@ +extern alias Full; +using Crestron.SimplSharp.Reflection; +using Full.Newtonsoft.Json.Linq; +using Newtonsoft.Json.Linq; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace PepperDash.Essentials.Core +{ + + public class ProcessorExtensionDeviceFactory + { + public ProcessorExtensionDeviceFactory() { + var assy = Assembly.GetExecutingAssembly(); + PluginLoader.SetEssentialsAssembly(assy.GetName().Name, assy); + + var extensions = assy.GetTypes().Where(ct => typeof(IProcessorExtensionDeviceFactory) + .IsAssignableFrom(ct) && !ct.IsInterface && !ct.IsAbstract); + + if (extensions != null ) + { + foreach ( var extension in extensions ) + { + try + { + var factory = (IProcessorExtensionDeviceFactory)Crestron.SimplSharp.Reflection.Activator.CreateInstance(extension); + factory.LoadFactories(); + } + catch( Exception e ) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to load extension device: '{1}' ProcessorExtensionDeviceFactory: {0}", e, extension.Name); + } + } + } + } + + /// + /// A dictionary of factory methods, keyed by config types, added by plugins. + /// These methods are looked up and called by GetDevice in this class. + /// + static Dictionary ProcessorExtensionFactoryMethods = + new Dictionary(StringComparer.OrdinalIgnoreCase); + + + /// + /// Adds a plugin factory method + /// + /// + /// + public static void AddFactoryForType(string extensionName, Func method) + { + //Debug.Console(1, Debug.ErrorLogLevel.Notice, "Adding factory method for type '{0}'", typeName); + ProcessorExtensionDeviceFactory.ProcessorExtensionFactoryMethods.Add(extensionName, new DeviceFactoryWrapper() { FactoryMethod = method }); + } + + public static void AddFactoryForType(string extensionName, string description, CType cType, Func method) + { + //Debug.Console(1, Debug.ErrorLogLevel.Notice, "Adding factory method for type '{0}'", typeName); + + if (ProcessorExtensionFactoryMethods.ContainsKey(extensionName)) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to add extension device: '{0}'. Already exists in ProcessorExtensionDeviceFactory", extensionName); + return; + } + + var wrapper = new DeviceFactoryWrapper() { CType = cType, Description = description, FactoryMethod = method }; + ProcessorExtensionDeviceFactory.ProcessorExtensionFactoryMethods.Add(extensionName, wrapper); + } + + private static void CheckForSecrets(IEnumerable obj) + { + foreach (var prop in obj.Where(prop => prop.Value as Full.Newtonsoft.Json.Linq.JObject != null)) + { + if (prop.Name.ToLower() == "secret") + { + var secret = GetSecret(prop.Children().First().ToObject()); + //var secret = GetSecret(JsonConvert.DeserializeObject(prop.Children().First().ToString())); + prop.Parent.Replace(secret); + } + var recurseProp = prop.Value as Full.Newtonsoft.Json.Linq.JObject; + if (recurseProp == null) return; + CheckForSecrets(recurseProp.Properties()); + } + } + + private static string GetSecret(SecretsPropertiesConfig data) + { + var secretProvider = SecretsManager.GetSecretProviderByKey(data.Provider); + if (secretProvider == null) return null; + var secret = secretProvider.GetSecret(data.Key); + if (secret != null) return (string)secret.Value; + Debug.Console(1, + "Unable to retrieve secret {0}{1} - Make sure you've added it to the secrets provider", + data.Provider, data.Key); + return String.Empty; + } + + /// + /// The factory method for processor extension devices. Also iterates the Factory methods that have + /// been loaded from plugins + /// + /// + /// + public static IKeyed GetExtensionDevice(DeviceConfig dc) + { + try + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading '{0}' from Essentials Core", dc.Type); + + var localDc = new DeviceConfig(dc); + + var key = localDc.Key; + var name = localDc.Name; + var type = localDc.Type; + var properties = localDc.Properties; + //var propRecurse = properties; + + var typeName = localDc.Type.ToLower(); + + var jObject = properties as Full.Newtonsoft.Json.Linq.JObject; + if (jObject != null) + { + var jProp = jObject.Properties(); + + CheckForSecrets(jProp); + } + + Debug.Console(2, "typeName = {0}", typeName); + // Check for types that have been added by plugin dlls. + return !ProcessorExtensionFactoryMethods.ContainsKey(typeName) ? null : ProcessorExtensionFactoryMethods[typeName].FactoryMethod(localDc); + } + catch (Exception ex) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, "Exception occurred while creating device {0}: {1}", dc.Key, ex.Message); + + Debug.Console(2, "{0}", ex.StackTrace); + + if (ex.InnerException == null) + { + return null; + } + + Debug.Console(0, Debug.ErrorLogLevel.Error, "Inner exception while creating device {0}: {1}", dc.Key, + ex.InnerException.Message); + Debug.Console(2, "{0}", ex.InnerException.StackTrace); + return null; + } + } + + } + +} diff --git a/src/PepperDash.Essentials.Core/File/FileIO.cs b/src/PepperDash.Essentials.Core/File/FileIO.cs index 51d64230..49b70a0c 100644 --- a/src/PepperDash.Essentials.Core/File/FileIO.cs +++ b/src/PepperDash.Essentials.Core/File/FileIO.cs @@ -21,35 +21,37 @@ namespace PepperDash.Essentials.Core /// /// /// - public static FileInfo[] GetFiles(string fileName) - { - DirectoryInfo dirInfo = new DirectoryInfo(Path.GetDirectoryName(fileName)); - var files = dirInfo.GetFiles(Path.GetFileName(fileName)); - Debug.Console(0, "FileIO found: {0}, {1}", files.Count(), fileName); - if (files.Count() > 0) - { - return files; - } - else - { - return null; - } - } + public static FileInfo[] GetFiles(string fileName) + { + string fullFilePath = Global.FilePathPrefix + fileName; + DirectoryInfo dirInfo = new DirectoryInfo(Path.GetDirectoryName(fullFilePath)); + var files = dirInfo.GetFiles(Path.GetFileName(fullFilePath)); + Debug.Console(0, "FileIO found: {0}, {1}", files.Count(), fullFilePath); + if (files.Count() > 0) + { + return files; + } + else + { + return null; + } + } - public static FileInfo GetFile(string fileName) - { - DirectoryInfo dirInfo = new DirectoryInfo(Path.GetDirectoryName(fileName)); - var files = dirInfo.GetFiles(Path.GetFileName(fileName)); - Debug.Console(0, "FileIO found: {0}, {1}", files.Count(), fileName); - if (files.Count() > 0) - { - return files.FirstOrDefault(); - } - else - { - return null; - } - } + public static FileInfo GetFile(string fileName) + { + string fullFilePath = Global.FilePathPrefix + fileName; + DirectoryInfo dirInfo = new DirectoryInfo(Path.GetDirectoryName(fullFilePath)); + var files = dirInfo.GetFiles(Path.GetFileName(fullFilePath)); + Debug.Console(0, "FileIO found: {0}, {1}", files.Count(), fullFilePath); + if (files.Count() > 0) + { + return files.FirstOrDefault(); + } + else + { + return null; + } + } /// @@ -81,7 +83,7 @@ namespace PepperDash.Essentials.Core { if (fileLock.TryEnter()) { - DirectoryInfo dirInfo = new DirectoryInfo(file.Name); + DirectoryInfo dirInfo = new DirectoryInfo(file.DirectoryName); Debug.Console(2, "FileIO Getting Data {0}", file.FullName); if (File.Exists(file.FullName)) @@ -202,7 +204,7 @@ namespace PepperDash.Essentials.Core public static void WriteDataToFile(string data, string filePath) { Thread _WriteFileThread; - _WriteFileThread = new Thread((O) => _WriteFileMethod(data, filePath), null, Thread.eThreadStartOptions.CreateSuspended); + _WriteFileThread = new Thread((O) => _WriteFileMethod(data, Global.FilePathPrefix + "/" + filePath), null, Thread.eThreadStartOptions.CreateSuspended); _WriteFileThread.Priority = Thread.eThreadPriority.LowestPriority; _WriteFileThread.Start(); Debug.Console(0, Debug.ErrorLogLevel.Notice, "New WriteFile Thread"); @@ -217,7 +219,8 @@ namespace PepperDash.Essentials.Core { if (fileLock.TryEnter()) { - using (StreamWriter sw = new StreamWriter(filePath)) + + using (StreamWriter sw = new StreamWriter(filePath)) { sw.Write(data); sw.Flush(); diff --git a/src/PepperDash.Essentials.Core/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs b/src/PepperDash.Essentials.Core/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs index f3827d0a..597a31fd 100644 --- a/src/PepperDash.Essentials.Core/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs +++ b/src/PepperDash.Essentials.Core/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs @@ -150,15 +150,20 @@ namespace PepperDash.Essentials.Core.Fusion ReadGuidFile(guidFilePath); } - if (Room.RoomOccupancy != null) + var occupancyRoom = Room as IRoomOccupancy; + + if (occupancyRoom != null) { - if (Room.OccupancyStatusProviderIsRemote) + if (occupancyRoom.RoomOccupancy != null) { - SetUpRemoteOccupancy(); - } - else - { - SetUpLocalOccupancy(); + if (occupancyRoom.OccupancyStatusProviderIsRemote) + { + SetUpRemoteOccupancy(); + } + else + { + SetUpLocalOccupancy(); + } } } @@ -1525,10 +1530,15 @@ namespace PepperDash.Essentials.Core.Fusion // Tie to method on occupancy object //occSensorShutdownMinutes.OutputSig.UserObject(new Action(ushort)(b => Room.OccupancyObj.SetShutdownMinutes(b)); + var occRoom = Room as IRoomOccupancy; + if (occRoom != null) + { + occRoom.RoomOccupancy.RoomIsOccupiedFeedback.LinkInputSig(occSensorAsset.RoomOccupied.InputSig); + occRoom.RoomOccupancy.RoomIsOccupiedFeedback.OutputChange += RoomIsOccupiedFeedback_OutputChange; + } RoomOccupancyRemoteStringFeedback = new StringFeedback(() => _roomOccupancyRemoteString); - Room.RoomOccupancy.RoomIsOccupiedFeedback.LinkInputSig(occSensorAsset.RoomOccupied.InputSig); - Room.RoomOccupancy.RoomIsOccupiedFeedback.OutputChange += RoomIsOccupiedFeedback_OutputChange; + RoomOccupancyRemoteStringFeedback.LinkInputSig(occSensorAsset.RoomOccupancyInfo.InputSig); //} diff --git a/src/PepperDash.Essentials.Core/JoinMaps/JoinMapBase.cs b/src/PepperDash.Essentials.Core/JoinMaps/JoinMapBase.cs index e16640ce..6dff477d 100644 --- a/src/PepperDash.Essentials.Core/JoinMaps/JoinMapBase.cs +++ b/src/PepperDash.Essentials.Core/JoinMaps/JoinMapBase.cs @@ -2,10 +2,8 @@ using System; using System.Collections.Generic; -using System.Data; using System.Globalization; using System.Linq; -using System.Runtime.InteropServices; using System.Text; using Crestron.SimplSharp.Reflection; using Crestron.SimplSharp.CrestronIO; @@ -105,22 +103,22 @@ namespace PepperDash.Essentials.Core /// public void PrintJoinMapInfo() { - Debug.Console(0, "{0}:\n", GetType().Name); + CrestronConsole.ConsoleCommandResponse("{0}:\n", GetType().Name); // Get the joins of each type and print them - Debug.Console(0, "Digitals:"); + CrestronConsole.ConsoleCommandResponse("Digitals:"); var digitals = Joins.Where(j => (j.Value.JoinType & eJoinType.Digital) == eJoinType.Digital).ToDictionary(j => j.Key, j => j.Value); - Debug.Console(2, "Found {0} Digital Joins", digitals.Count); + CrestronConsole.ConsoleCommandResponse("Found {0} Digital Joins", digitals.Count); PrintJoinList(GetSortedJoins(digitals)); - Debug.Console(0, "Analogs:"); + CrestronConsole.ConsoleCommandResponse("Analogs:"); var analogs = Joins.Where(j => (j.Value.JoinType & eJoinType.Analog) == eJoinType.Analog).ToDictionary(j => j.Key, j => j.Value); - Debug.Console(2, "Found {0} Analog Joins", analogs.Count); + CrestronConsole.ConsoleCommandResponse("Found {0} Analog Joins", analogs.Count); PrintJoinList(GetSortedJoins(analogs)); - Debug.Console(0, "Serials:"); + CrestronConsole.ConsoleCommandResponse("Serials:"); var serials = Joins.Where(j => (j.Value.JoinType & eJoinType.Serial) == eJoinType.Serial).ToDictionary(j => j.Key, j => j.Value); - Debug.Console(2, "Found {0} Serial Joins", serials.Count); + CrestronConsole.ConsoleCommandResponse("Found {0} Serial Joins", serials.Count); PrintJoinList(GetSortedJoins(serials)); } @@ -143,7 +141,7 @@ namespace PepperDash.Essentials.Core { foreach (var join in joins) { - Debug.Console(0, + CrestronConsole.ConsoleCommandResponse( @"Join Number: {0} | Label: '{1}' | JoinSpan: '{2}' | Type: '{3}' | Capabilities: '{4}'", join.Value.JoinNumber, join.Value.Label, @@ -238,25 +236,45 @@ namespace PepperDash.Essentials.Core /// public void PrintJoinMapInfo() { - Debug.Console(0, "{0}:\n", GetType().Name); + var sb = JoinmapStringBuilder(); + + CrestronConsole.ConsoleCommandResponse(sb.ToString()); + } + + private StringBuilder JoinmapStringBuilder() + { + var sb = new StringBuilder(); // Get the joins of each type and print them - Debug.Console(0, "Digitals:"); - var digitals = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Digital) == eJoinType.Digital).ToDictionary(j => j.Key, j => j.Value); - Debug.Console(2, "Found {0} Digital Joins", digitals.Count); - PrintJoinList(GetSortedJoins(digitals)); + sb.AppendLine(String.Format("# {0}", GetType().Name)); + sb.AppendLine(); + sb.AppendLine("## Digitals"); + sb.AppendLine(); + // Get the joins of each type and print them + var digitals = + Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Digital) == eJoinType.Digital) + .ToDictionary(j => j.Key, j => j.Value); + var digitalSb = AppendJoinList(GetSortedJoins(digitals)); + digitalSb.AppendLine("## Analogs"); + digitalSb.AppendLine(); - Debug.Console(0, "Analogs:"); - var analogs = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Analog) == eJoinType.Analog).ToDictionary(j => j.Key, j => j.Value); - Debug.Console(2, "Found {0} Analog Joins", analogs.Count); - PrintJoinList(GetSortedJoins(analogs)); + var analogs = + Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Analog) == eJoinType.Analog) + .ToDictionary(j => j.Key, j => j.Value); + var analogSb = AppendJoinList(GetSortedJoins(analogs)); + analogSb.AppendLine("## Serials"); + analogSb.AppendLine(); - Debug.Console(0, "Serials:"); - var serials = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Serial) == eJoinType.Serial).ToDictionary(j => j.Key, j => j.Value); - Debug.Console(2, "Found {0} Serial Joins", serials.Count); - PrintJoinList(GetSortedJoins(serials)); + var serials = + Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Serial) == eJoinType.Serial) + .ToDictionary(j => j.Key, j => j.Value); + var serialSb = AppendJoinList(GetSortedJoins(serials)); + sb.EnsureCapacity(sb.Length + digitalSb.Length + analogSb.Length + serialSb.Length); + sb.Append(digitalSb).Append(analogSb).Append(serialSb); + return sb; } + /// /// Prints the join information to console /// @@ -264,37 +282,11 @@ namespace PepperDash.Essentials.Core { var pluginType = GetType().Name; - Debug.Console(0, "{0}:\n", pluginType); + CrestronConsole.ConsoleCommandResponse("{0}:\n", pluginType); - var sb = new StringBuilder(); - sb.AppendLine(String.Format("# {0}", GetType().Name)); - sb.AppendLine(String.Format("Generated from '{0}' on bridge '{1}'", deviceKey, bridgeKey)); - sb.AppendLine(); - sb.AppendLine("## Digitals"); - // Get the joins of each type and print them - var digitals = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Digital) == eJoinType.Digital).ToDictionary(j => j.Key, j => j.Value); - Debug.Console(2, "Found {0} Digital Joins", digitals.Count); - var digitalSb = AppendJoinList(GetSortedJoins(digitals)); - digitalSb.AppendLine("## Analogs"); - digitalSb.AppendLine(); - Debug.Console(0, "Analogs:"); - var analogs = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Analog) == eJoinType.Analog).ToDictionary(j => j.Key, j => j.Value); - Debug.Console(2, "Found {0} Analog Joins", analogs.Count); - var analogSb = AppendJoinList(GetSortedJoins(analogs)); - analogSb.AppendLine("## Serials"); - analogSb.AppendLine(); - - Debug.Console(0, "Serials:"); - var serials = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Serial) == eJoinType.Serial).ToDictionary(j => j.Key, j => j.Value); - Debug.Console(2, "Found {0} Serial Joins", serials.Count); - var serialSb = AppendJoinList(GetSortedJoins(serials)); - - sb.EnsureCapacity(sb.Length + digitalSb.Length + analogSb.Length + serialSb.Length); - sb.Append(digitalSb).Append(analogSb).Append(serialSb); - - WriteJoinmapMarkdown(sb, pluginType, bridgeKey, deviceKey); + WriteJoinmapMarkdown(JoinmapStringBuilder(), pluginType, bridgeKey, deviceKey); } @@ -305,7 +297,7 @@ namespace PepperDash.Essentials.Core using (var sw = new StreamWriter(fileName)) { sw.WriteLine(stringBuilder.ToString()); - Debug.Console(0, "Joinmap Readme generated and written to {0}", fileName); + CrestronConsole.ConsoleCommandResponse("Joinmap Readme generated and written to {0}", fileName); } } @@ -315,7 +307,7 @@ namespace PepperDash.Essentials.Core /// /// /// - List> GetSortedJoins(Dictionary joins) + static List> GetSortedJoins(Dictionary joins) { var sortedJoins = joins.ToList(); @@ -324,20 +316,6 @@ namespace PepperDash.Essentials.Core return sortedJoins; } - void PrintJoinList(List> joins) - { - foreach (var join in joins) - { - Debug.Console(0, - @"Join Number: {0} | JoinSpan: '{1}' | JoinName: {2} | Description: '{3}' | Type: '{4}' | Capabilities: '{5}'", - join.Value.JoinNumber, - join.Value.JoinSpan, - join.Key, - String.IsNullOrEmpty(join.Value.AttributeName) ? join.Value.Metadata.Label : join.Value.AttributeName, - join.Value.Metadata.JoinType.ToString(), - join.Value.Metadata.JoinCapabilities.ToString()); - } - } static StringBuilder AppendJoinList(List> joins) { @@ -380,16 +358,18 @@ namespace PepperDash.Essentials.Core { foreach (var customJoinData in joinData) { - var join = Joins[customJoinData.Key]; + JoinDataComplete join; + + if (!Joins.TryGetValue(customJoinData.Key, out join)) + { + Debug.Console(2, "No matching key found in join map for: '{0}'", customJoinData.Key); + continue; + } if (join != null) { join.SetCustomJoinData(customJoinData.Value); } - else - { - Debug.Console(2, "No matching key found in join map for: '{0}'", customJoinData.Key); - } } PrintJoinMapInfo(); diff --git a/src/PepperDash.Essentials.Core/Monitoring/SystemMonitorController.cs b/src/PepperDash.Essentials.Core/Monitoring/SystemMonitorController.cs index b9d25127..1066637c 100644 --- a/src/PepperDash.Essentials.Core/Monitoring/SystemMonitorController.cs +++ b/src/PepperDash.Essentials.Core/Monitoring/SystemMonitorController.cs @@ -45,7 +45,20 @@ namespace PepperDash.Essentials.Core.Monitoring public StringFeedback UptimeFeedback { get; set; } public StringFeedback LastStartFeedback { get; set; } - public SystemMonitorController(string key) + public BoolFeedback IsApplianceFeedback { get; protected set; } + private bool _isApplianceFb + { + get { return CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance; } + } + + public BoolFeedback IsServerFeedback { get; protected set; } + private bool _isServerFb + { + get { return CrestronEnvironment.DevicePlatform == eDevicePlatform.Server; } + } + + + public SystemMonitorController(string key) : base(key) { Debug.Console(2, this, "Adding SystemMonitorController."); @@ -65,6 +78,9 @@ namespace PepperDash.Essentials.Core.Monitoring UptimeFeedback = new StringFeedback(() => _uptime); LastStartFeedback = new StringFeedback(()=> _lastStart); + IsApplianceFeedback = new BoolFeedback(() => _isApplianceFb); + IsServerFeedback = new BoolFeedback(() => _isServerFb); + ProgramStatusFeedbackCollection = new Dictionary(); foreach (var prog in SystemMonitor.ProgramCollection) @@ -125,6 +141,26 @@ namespace PepperDash.Essentials.Core.Monitoring _uptime = uptimeRaw.Substring(forIndex + 4); } + private static void ProcessorReboot() + { + if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Server) return; + + var response = string.Empty; + CrestronConsole.SendControlSystemCommand("reboot", ref response); + } + + private static void ProgramReset(uint index) + { + if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Server) return; + + if (index <= 0 || index > 10) return; + + var cmd = string.Format("progreset -p:{0}", index); + + var response = string.Empty; + CrestronConsole.SendControlSystemCommand(cmd, ref response); + } + private void CrestronEnvironmentOnEthernetEventHandler(EthernetEventArgs ethernetEventArgs) { if (ethernetEventArgs.EthernetEventType != eEthernetEventType.LinkUp) return; @@ -187,6 +223,9 @@ namespace PepperDash.Essentials.Core.Monitoring SerialNumberFeedback.FireUpdate(); ModelFeedback.FireUpdate(); + IsApplianceFeedback.FireUpdate(); + IsServerFeedback.FireUpdate(); + OnSystemMonitorPropertiesChanged(); } @@ -239,6 +278,11 @@ namespace PepperDash.Essentials.Core.Monitoring UptimeFeedback.LinkInputSig(trilist.StringInput[joinMap.Uptime.JoinNumber]); LastStartFeedback.LinkInputSig(trilist.StringInput[joinMap.LastBoot.JoinNumber]); + trilist.SetSigHeldAction(joinMap.ProcessorReboot.JoinNumber, 10000, ProcessorReboot); + + IsApplianceFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsAppliance.JoinNumber]); + IsServerFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsServer.JoinNumber]); + // iterate the program status feedback collection and map all the joins LinkProgramInfoJoins(this, trilist, joinMap); @@ -303,11 +347,13 @@ namespace PepperDash.Essentials.Core.Monitoring p.Value.AggregatedProgramInfoFeedback.LinkInputSig( trilist.StringInput[programSlotJoinStart + joinMap.AggregatedProgramInfo.JoinNumber]); + trilist.SetSigHeldAction(programSlotJoinStart + joinMap.ProgramReset.JoinNumber, 10000, () => ProgramReset(programNumber)); + programSlotJoinStart = programSlotJoinStart + joinMap.ProgramOffsetJoin.JoinSpan; } - } + } - //// Sets the time zone + //// Sets the time zone //public void SetTimeZone(int timeZone) //{ // SystemMonitor.TimeZoneInformation.TimeZoneNumber = timeZone; @@ -519,11 +565,11 @@ namespace PepperDash.Essentials.Core.Monitoring ProgramUnregisteredFeedback = new BoolFeedback(() => Program.RegistrationState == eProgramRegistrationState.Unregister); ProgramUnregisteredFeedback.FireUpdate(); - - ProgramNameFeedback = new StringFeedback(() => ProgramInfo.ProgramFile); + + ProgramNameFeedback = new StringFeedback(() => ProgramInfo.ProgramFile); + CrestronDataBaseVersionFeedback = new StringFeedback(() => ProgramInfo.CrestronDb); + EnvironmentVersionFeedback = new StringFeedback(() => ProgramInfo.Environment); ProgramCompileTimeFeedback = new StringFeedback(() => ProgramInfo.CompileTime); - CrestronDataBaseVersionFeedback = new StringFeedback(() => ProgramInfo.CrestronDb); - EnvironmentVersionFeedback = new StringFeedback(() => ProgramInfo.Environment); AggregatedProgramInfoFeedback = new StringFeedback(() => JsonConvert.SerializeObject(ProgramInfo)); GetProgramInfo(); @@ -576,9 +622,9 @@ namespace PepperDash.Essentials.Core.Monitoring // Assume no valid program info. Constructing a new object will wipe all properties ProgramInfo = new ProgramInfo(Program.Number) { - OperatingState = Program.OperatingState, + OperatingState = Program.OperatingState, RegistrationState = Program.RegistrationState - }; + }; UpdateFeedbacks(); @@ -595,13 +641,20 @@ namespace PepperDash.Essentials.Core.Monitoring if (ProgramInfo.ProgramFile.Contains(".dll")) { - // SSP Program + // SSP Program ProgramInfo.FriendlyName = ParseConsoleData(response, "Friendly Name", ": ", "\n"); ProgramInfo.ApplicationName = ParseConsoleData(response, "Application Name", ": ", "\n"); ProgramInfo.ProgramTool = ParseConsoleData(response, "Program Tool", ": ", "\n"); ProgramInfo.MinFirmwareVersion = ParseConsoleData(response, "Min Firmware Version", ": ", "\n"); ProgramInfo.PlugInVersion = ParseConsoleData(response, "PlugInVersion", ": ", "\n"); + + ProgramInfo.ProgramFile += string.Format(" {0}.{1}.{2}", + ProgramInfo.CompilerRevisionInfo.Major, + ProgramInfo.CompilerRevisionInfo.Minor, + ProgramInfo.CompilerRevisionInfo.Build); + + ProgramInfo.Environment = ProgramInfo.ProgramTool; } else if (ProgramInfo.ProgramFile.Contains(".smw")) { @@ -692,6 +745,15 @@ namespace PepperDash.Essentials.Core.Monitoring [JsonProperty("compilerRevision")] public string CompilerRevision { get; set; } + [JsonIgnore] + public Version CompilerRevisionInfo + { + get + { + return new Version(CompilerRevision); + } + } + [JsonProperty("compileTime")] public string CompileTime { get; set; } @@ -732,7 +794,7 @@ namespace PepperDash.Essentials.Core.Monitoring ProgramFile = ""; FriendlyName = ""; CompilerRevision = ""; - CompileTime = ""; + CompileTime = ""; Include4Dat = ""; SystemName = ""; diff --git a/src/PepperDash.Essentials.Core/PartitionSensor/GlsPartitionSensorController.cs b/src/PepperDash.Essentials.Core/PartitionSensor/GlsPartitionSensorController.cs index 7298e303..511eda66 100644 --- a/src/PepperDash.Essentials.Core/PartitionSensor/GlsPartitionSensorController.cs +++ b/src/PepperDash.Essentials.Core/PartitionSensor/GlsPartitionSensorController.cs @@ -87,18 +87,32 @@ namespace PepperDash.Essentials.Core { if (_partitionSensor.IsOnline == false) return; - Debug.Console(1, this, "Attempting to apply settings to sensor from config"); + // Default to enable + _partitionSensor.Enable.BoolValue = true; - if (PropertiesConfig.Sensitivity != null) - { - Debug.Console(1, this, "Sensitivity found, attempting to set value '{0}' from config", - PropertiesConfig.Sensitivity); - _partitionSensor.Sensitivity.UShortValue = (ushort) PropertiesConfig.Sensitivity; - } - else - { - Debug.Console(1, this, "Sensitivity null, no value specified in config"); - } + Debug.Console(1, this, "Attempting to apply settings to sensor from config"); + + if (PropertiesConfig.Sensitivity != null) + { + Debug.Console(1, this, "Sensitivity found, attempting to set value '{0}' from config", + PropertiesConfig.Sensitivity); + _partitionSensor.Sensitivity.UShortValue = (ushort)PropertiesConfig.Sensitivity; + } + else + { + Debug.Console(1, this, "Sensitivity null, no value specified in config"); + } + + if (PropertiesConfig.Enable != null) + { + Debug.Console(1, this, "Enable found, attempting to set value '{0}' from config", + PropertiesConfig.Enable); + _partitionSensor.Enable.BoolValue = (bool)PropertiesConfig.Enable; + } + else + { + Debug.Console(1, this, "Enable null, no value specified in config"); + } } diff --git a/src/PepperDash.Essentials.Core/PartitionSensor/GlsPartitionSensorPropertiesConfig.cs b/src/PepperDash.Essentials.Core/PartitionSensor/GlsPartitionSensorPropertiesConfig.cs index 635b8962..03611dd2 100644 --- a/src/PepperDash.Essentials.Core/PartitionSensor/GlsPartitionSensorPropertiesConfig.cs +++ b/src/PepperDash.Essentials.Core/PartitionSensor/GlsPartitionSensorPropertiesConfig.cs @@ -18,6 +18,9 @@ namespace PepperDash_Essentials_Core.PartitionSensor /// The sensitivity range shall be between 1(lowest) to 10 (highest). /// [JsonProperty("sensitivity")] - public ushort? Sensitivity { get; set; } + public ushort? Sensitivity { get; set; } + + [JsonProperty("enable")] + public bool? Enable { get; set; } } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/PepperDash.Essentials.Core.csproj b/src/PepperDash.Essentials.Core/PepperDash.Essentials.Core.csproj index 7360df12..db87a84d 100644 --- a/src/PepperDash.Essentials.Core/PepperDash.Essentials.Core.csproj +++ b/src/PepperDash.Essentials.Core/PepperDash.Essentials.Core.csproj @@ -27,7 +27,7 @@ - + Full diff --git a/src/PepperDash.Essentials.Core/PepperDash_Essentials_Core.csproj b/src/PepperDash.Essentials.Core/PepperDash_Essentials_Core.csproj index 6020fbac..bd727697 100644 --- a/src/PepperDash.Essentials.Core/PepperDash_Essentials_Core.csproj +++ b/src/PepperDash.Essentials.Core/PepperDash_Essentials_Core.csproj @@ -83,7 +83,7 @@ ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll - + False ..\..\..\packages\PepperDashCore\lib\net35\PepperDash_Core.dll @@ -94,7 +94,7 @@ False - ..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCWSHelperInterface.dll + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCWSHelperInterface.dll False @@ -127,6 +127,8 @@ + + @@ -200,6 +202,8 @@ + + @@ -417,12 +421,6 @@ - - - {E51D7C84-4906-486C-B2BA-EEB3B4E9731B} - PepperDash_Essentials_Interfaces - - diff --git a/src/PepperDash.Essentials.Core/Plugins/PluginLoader.cs b/src/PepperDash.Essentials.Core/Plugins/PluginLoader.cs index 9da843b8..dcc492df 100644 --- a/src/PepperDash.Essentials.Core/Plugins/PluginLoader.cs +++ b/src/PepperDash.Essentials.Core/Plugins/PluginLoader.cs @@ -194,13 +194,13 @@ namespace PepperDash.Essentials /// public static void ReportAssemblyVersions(string command) { - Debug.Console(0, "Loaded Assemblies:"); + + CrestronConsole.ConsoleCommandResponse("Loaded Assemblies:" + CrestronEnvironment.NewLine); foreach (var assembly in LoadedAssemblies) { - Debug.Console(0, "{0} Version: {1}", assembly.Name, assembly.Version); + CrestronConsole.ConsoleCommandResponse("{0} Version: {1}" + CrestronEnvironment.NewLine, assembly.Name, assembly.Version); } } - /// /// Moves any .dll assemblies not already loaded from the plugins folder to loadedPlugins folder /// diff --git a/src/PepperDash.Essentials.Core/Room/Behaviours/RoomOnToDefaultSourceWhenOccupied.cs b/src/PepperDash.Essentials.Core/Room/Behaviours/RoomOnToDefaultSourceWhenOccupied.cs index e46e93cb..c3bc0ca2 100644 --- a/src/PepperDash.Essentials.Core/Room/Behaviours/RoomOnToDefaultSourceWhenOccupied.cs +++ b/src/PepperDash.Essentials.Core/Room/Behaviours/RoomOnToDefaultSourceWhenOccupied.cs @@ -40,7 +40,7 @@ namespace PepperDash.Essentials.Core ScheduledEventGroup FeatureEventGroup; - public IEssentialsRoom Room { get; private set; } + public IRoomOccupancy Room { get; private set; } private Fusion.EssentialsHuddleSpaceFusionSystemControllerBase FusionRoom; @@ -86,7 +86,7 @@ namespace PepperDash.Essentials.Core /// void SetUpDevice() { - Room = DeviceManager.GetDeviceForKey(PropertiesConfig.RoomKey) as IEssentialsRoom; + Room = DeviceManager.GetDeviceForKey(PropertiesConfig.RoomKey) as IRoomOccupancy; if (Room != null) { @@ -237,12 +237,23 @@ namespace PepperDash.Essentials.Core if (FeatureEnabled) { - // Check room power state first - if (!Room.OnFeedback.BoolValue) - { - Debug.Console(1, this, "Powering Room on to default source"); - Room.RunDefaultPresentRoute(); + var essentialsRoom = Room as IEssentialsRoom; + + if (essentialsRoom != null) { + if (!essentialsRoom.OnFeedback.BoolValue) + { + Debug.Console(1, this, "Powering Room on to default source"); + + var defaultRouteRoom = Room as IRunDefaultPresentRoute; + + if (defaultRouteRoom != null) + { + defaultRouteRoom.RunDefaultPresentRoute(); + } + } } + // Check room power state first + } } } diff --git a/src/PepperDash.Essentials.Core/Room/EssentialsRoomBase.cs b/src/PepperDash.Essentials.Core/Room/EssentialsRoomBase.cs index 72bf9060..abfc34b8 100644 --- a/src/PepperDash.Essentials.Core/Room/EssentialsRoomBase.cs +++ b/src/PepperDash.Essentials.Core/Room/EssentialsRoomBase.cs @@ -1,6 +1,4 @@ -extern alias Full; - -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -13,8 +11,6 @@ using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Devices; using PepperDash.Essentials.Core.DeviceTypeInterfaces; -using Full.Newtonsoft.Json; - namespace PepperDash.Essentials.Core { /// @@ -37,7 +33,7 @@ namespace PepperDash.Essentials.Core public BoolFeedback IsWarmingUpFeedback { get; private set; } public BoolFeedback IsCoolingDownFeedback { get; private set; } - public IOccupancyStatusProvider RoomOccupancy { get; private set; } + public IOccupancyStatusProvider RoomOccupancy { get; protected set; } public bool OccupancyStatusProviderIsRemote { get; private set; } diff --git a/src/PepperDash.Essentials.Core/Room/IEssentialsRoom.cs b/src/PepperDash.Essentials.Core/Room/IEssentialsRoom.cs index 2273690f..9a70f980 100644 --- a/src/PepperDash.Essentials.Core/Room/IEssentialsRoom.cs +++ b/src/PepperDash.Essentials.Core/Room/IEssentialsRoom.cs @@ -17,15 +17,10 @@ namespace PepperDash.Essentials.Core /// public interface IEssentialsRoom : IKeyName, IReconfigurableDevice, IRunDefaultPresentRoute, IEnvironmentalControls { - BoolFeedback OnFeedback { get; } - - event EventHandler RoomOccupancyIsSet; + BoolFeedback OnFeedback { get; } BoolFeedback IsWarmingUpFeedback { get; } - BoolFeedback IsCoolingDownFeedback { get; } - - IOccupancyStatusProvider RoomOccupancy { get; } - bool OccupancyStatusProviderIsRemote { get; } + BoolFeedback IsCoolingDownFeedback { get; } bool IsMobileControlEnabled { get; } IMobileControlRoomBridge MobileControlRoomBridge { get; } @@ -35,31 +30,16 @@ namespace PepperDash.Essentials.Core SecondsCountdownTimer ShutdownPromptTimer { get; } int ShutdownPromptSeconds { get; } int ShutdownVacancySeconds { get; } - eShutdownType ShutdownType { get; } - - EssentialsRoomEmergencyBase Emergency { get; } - - Core.Privacy.MicrophonePrivacyController MicrophonePrivacy { get; } + eShutdownType ShutdownType { get; } string LogoUrlLightBkgnd { get; } string LogoUrlDarkBkgnd { get; } - eVacancyMode VacancyMode { get; } + void StartShutdown(eShutdownType type); - bool ZeroVolumeWhenSwtichingVolumeDevices { get; } + void Shutdown(); - void StartShutdown(eShutdownType type); - void StartRoomVacancyTimer(eVacancyMode mode); - - void Shutdown(); - - void SetRoomOccupancy(IOccupancyStatusProvider statusProvider, int timeoutMinutes); - - void PowerOnToDefaultOrLastSource(); - - void SetDefaultLevels(); - - void RoomVacatedForTimeoutPeriod(object o); + void PowerOnToDefaultOrLastSource(); } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Room/Interfaces.cs b/src/PepperDash.Essentials.Core/Room/Interfaces.cs index b5121e9c..e962e604 100644 --- a/src/PepperDash.Essentials.Core/Room/Interfaces.cs +++ b/src/PepperDash.Essentials.Core/Room/Interfaces.cs @@ -41,7 +41,6 @@ namespace PepperDash.Essentials.Core void RunRouteAction(string routeKey, string sourceListKey); void RunRouteAction(string routeKey, string sourceListKey, Action successCallback); - } /// @@ -78,4 +77,30 @@ namespace PepperDash.Essentials.Core bool HasEnvironmentalControlDevices { get; } } + public interface IRoomOccupancy:IKeyed + { + IOccupancyStatusProvider RoomOccupancy { get; } + bool OccupancyStatusProviderIsRemote { get; } + + void SetRoomOccupancy(IOccupancyStatusProvider statusProvider, int timeoutMinutes); + + void RoomVacatedForTimeoutPeriod(object o); + + void StartRoomVacancyTimer(eVacancyMode mode); + + eVacancyMode VacancyMode { get; } + + event EventHandler RoomOccupancyIsSet; + } + + public interface IEmergency + { + EssentialsRoomEmergencyBase Emergency { get; } + } + + public interface IMicrophonePrivacy + { + Core.Privacy.MicrophonePrivacyController MicrophonePrivacy { get; } + } + } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/RoutingInterfaces.cs b/src/PepperDash.Essentials.Core/Routing/RoutingInterfaces.cs index 952a48b1..dcec7ae2 100644 --- a/src/PepperDash.Essentials.Core/Routing/RoutingInterfaces.cs +++ b/src/PepperDash.Essentials.Core/Routing/RoutingInterfaces.cs @@ -204,4 +204,9 @@ namespace PepperDash.Essentials.Core SigType = sigType; } } + + public interface IRoutingHasVideoInputSyncFeedbacks + { + FeedbackCollection VideoInputSyncFeedbacks { get; } + } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/RoutingPort.cs b/src/PepperDash.Essentials.Core/Routing/RoutingPort.cs index 79dd4eda..ab64f15e 100644 --- a/src/PepperDash.Essentials.Core/Routing/RoutingPort.cs +++ b/src/PepperDash.Essentials.Core/Routing/RoutingPort.cs @@ -42,7 +42,7 @@ namespace PepperDash.Essentials.Core public enum eRoutingPortConnectionType { None, BackplaneOnly, DisplayPort, Dvi, Hdmi, Rgb, Vga, LineAudio, DigitalAudio, Sdi, - Composite, Component, DmCat, DmMmFiber, DmSmFiber, Speaker, Streaming + Composite, Component, DmCat, DmMmFiber, DmSmFiber, Speaker, Streaming, UsbC, HdBaseT } /// diff --git a/src/PepperDash.Essentials.Core/Routing/RoutingPortNames.cs b/src/PepperDash.Essentials.Core/Routing/RoutingPortNames.cs index 00e85191..7029443b 100644 --- a/src/PepperDash.Essentials.Core/Routing/RoutingPortNames.cs +++ b/src/PepperDash.Essentials.Core/Routing/RoutingPortNames.cs @@ -199,5 +199,45 @@ namespace PepperDash.Essentials.Core.Routing /// MediaPlayer /// public const string MediaPlayer = "mediaPlayer"; - } + /// + /// UsbCIn + /// + public const string UsbCIn = "usbCIn"; + /// + /// UsbCIn1 + /// + public const string UsbCIn1 = "usbCIn1"; + /// + /// UsbCIn2 + /// + public const string UsbCIn2 = "usbCIn2"; + /// + /// UsbCIn3 + /// + public const string UsbCIn3 = "usbCIn3"; + /// + /// UsbCOut + /// + public const string UsbCOut = "usbCOut"; + /// + /// UsbCOut1 + /// + public const string UsbCOut1 = "usbCOut1"; + /// + /// UsbCOut2 + /// + public const string UsbCOut2 = "usbCOut2"; + /// + /// UsbCOut3 + /// + public const string UsbCOut3 = "usbCOut3"; + /// + /// HdBaseTIn + /// + public const string HdBaseTIn = "hdBaseTIn"; + /// + /// HdBaseTOut + /// + public const string HdBaseTOut = "hdBaseTOut"; + } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Touchpanels/Mpc3Touchpanel.cs b/src/PepperDash.Essentials.Core/Touchpanels/Mpc3Touchpanel.cs index c9a5f605..2f6074dd 100644 --- a/src/PepperDash.Essentials.Core/Touchpanels/Mpc3Touchpanel.cs +++ b/src/PepperDash.Essentials.Core/Touchpanels/Mpc3Touchpanel.cs @@ -1,144 +1,352 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; +using System.Globalization; using Crestron.SimplSharpPro; - +using Newtonsoft.Json; using PepperDash.Core; -using PepperDash.Essentials.Core; namespace PepperDash.Essentials.Core.Touchpanels { - /// - /// A wrapper class for the touchpanel portion of an MPC3 class process to allow for configurable - /// behavior of the keybad buttons - /// - public class Mpc3TouchpanelController : Device - { - MPC3Basic _Touchpanel; + /// + /// A wrapper class for the touchpanel portion of an MPC3 class process to allow for configurable + /// behavior of the keybad buttons + /// + public class Mpc3TouchpanelController : Device + { + readonly MPC3Basic _touchpanel; - Dictionary _Buttons; + readonly Dictionary _buttons; - public Mpc3TouchpanelController(string key, string name, CrestronControlSystem processor, Dictionary buttons) - : base(key, name) - { - _Touchpanel = processor.ControllerTouchScreenSlotDevice as MPC3Basic; - _Buttons = buttons; + public Mpc3TouchpanelController(string key, string name, CrestronControlSystem processor, Dictionary buttons) + : base(key, name) + { + _touchpanel = processor.ControllerTouchScreenSlotDevice as MPC3Basic; + if (_touchpanel == null) + { + Debug.Console(1, this, "Failed to construct MPC3 Touchpanel Controller with key {0}, check configuration", key); + return; + } - _Touchpanel.ButtonStateChange += new Crestron.SimplSharpPro.DeviceSupport.ButtonEventHandler(_Touchpanel_ButtonStateChange); + if (_touchpanel.Registerable) + { + var registrationResponse = _touchpanel.Register(); + Debug.Console(0, this, "touchpanel registration response: {0}", registrationResponse); + } - AddPostActivationAction(() => - { - // Link up the button feedbacks to the specified BoolFeedbacks - foreach (var button in _Buttons) - { - var feedbackConfig = button.Value.Feedback; - var device = DeviceManager.GetDeviceForKey(feedbackConfig.DeviceKey) as Device; - if (device != null) - { - var bKey = button.Key.ToLower(); + _touchpanel.BaseEvent += _touchpanel_BaseEvent; + _touchpanel.ButtonStateChange += _touchpanel_ButtonStateChange; + _touchpanel.PanelStateChange += _touchpanel_PanelStateChange; - var feedback = device.GetFeedbackProperty(feedbackConfig.FeedbackName); + _buttons = buttons; + if (_buttons == null) + { + Debug.Console(1, this, + "Button properties are null, failed to setup MPC3 Touch Controller, check configuration"); + return; + } - var bFeedback = feedback as BoolFeedback; - var iFeedback = feedback as IntFeedback; - if (bFeedback != null) - { + AddPostActivationAction(() => + { + foreach (var button in _buttons) + { + var buttonKey = button.Key.ToLower(); + var buttonConfig = button.Value; - if (bKey == "power") - { - bFeedback.LinkCrestronFeedback(_Touchpanel.FeedbackPower); - continue; - } - else if (bKey == "mute") - { - bFeedback.LinkCrestronFeedback(_Touchpanel.FeedbackMute); - continue; - } + InitializeButton(buttonKey, buttonConfig); + InitializeButtonFeedback(buttonKey, buttonConfig); + } + }); + } - // Link to the Crestron Feedback corresponding to the button number - bFeedback.LinkCrestronFeedback(_Touchpanel.Feedbacks[UInt16.Parse(button.Key)]); - } - else if (iFeedback != null) - { - if (bKey == "volumefeedback") - { - var volFeedback = feedback as IntFeedback; - // TODO: Figure out how to subsribe to a volume IntFeedback and link it to the voluem - volFeedback.LinkInputSig(_Touchpanel.VolumeBargraph); - } - } - else - { - Debug.Console(1, this, "Unable to get BoolFeedback with name: {0} from device: {1}", feedbackConfig.FeedbackName, device.Key); - } - } - else - { - Debug.Console(1, this, "Unable to get device with key: {0}", feedbackConfig.DeviceKey); - } - } - }); - } + /// + /// Enables/disables buttons based on event type configuration + /// + /// + /// + public void InitializeButton(string key, KeypadButton config) + { + if (config == null) + { + Debug.Console(1, this, "Button '{0}' config is null, unable to initialize", key); + return; + } - void _Touchpanel_ButtonStateChange(GenericBase device, Crestron.SimplSharpPro.DeviceSupport.ButtonEventArgs args) - { - Debug.Console(1, this, "Button {0} ({1}), {2}", args.Button.Number, args.Button.Name, args.NewButtonState); - var type = args.NewButtonState.ToString(); + int buttonNumber; + TryParseInt(key, out buttonNumber); - if (_Buttons.ContainsKey(args.Button.Number.ToString())) - { - Press(args.Button.Number.ToString(), type); - } - else if(_Buttons.ContainsKey(args.Button.Name.ToString())) - { - Press(args.Button.Name.ToString(), type); - } - } + var buttonEventTypes = config.EventTypes; + BoolOutputSig enabledFb = null; + BoolOutputSig disabledFb = null; - /// - /// Runs the function associated with this button/type. One of the following strings: - /// Pressed, Released, Tapped, DoubleTapped, Held, HeldReleased - /// - /// - /// - public void Press(string number, string type) - { - // TODO: In future, consider modifying this to generate actions at device activation time - // to prevent the need to dynamically call the method via reflection on each button press - if (!_Buttons.ContainsKey(number)) { return; } - var but = _Buttons[number]; - if (but.EventTypes.ContainsKey(type)) - { - foreach (var a in but.EventTypes[type]) { DeviceJsonApi.DoDeviceAction(a); } - } - } + switch (key) + { + case ("power"): + { + if (buttonEventTypes == null || buttonEventTypes.Keys == null) + _touchpanel.DisablePowerButton(); + else + _touchpanel.EnablePowerButton(); - } + enabledFb = _touchpanel.PowerButtonEnabledFeedBack; + disabledFb = _touchpanel.PowerButtonDisabledFeedBack; - /// - /// Represents the configuration of a keybad buggon - /// - public class KeypadButton - { - public Dictionary EventTypes { get; set; } - public KeypadButtonFeedback Feedback { get; set; } + break; + } + //case ("volumeup"): + // { + // break; + // } + //case ("volumedown"): + // { + // break; + // } + //case ("volumefeedback"): + // { + // break; + // } + case ("mute"): + { + if (buttonEventTypes == null || buttonEventTypes.Keys == null) + _touchpanel.DisableMuteButton(); + else + _touchpanel.EnableMuteButton(); - public KeypadButton() - { - EventTypes = new Dictionary(); - Feedback = new KeypadButtonFeedback(); - } - } - /// - /// - /// - public class KeypadButtonFeedback - { - public string DeviceKey { get; set; } - public string FeedbackName { get; set; } - } + enabledFb = _touchpanel.MuteButtonEnabledFeedBack; + disabledFb = _touchpanel.MuteButtonDisabledFeedBack; + + break; + } + default: + { + if (buttonNumber == 0 || buttonNumber > 9) + break; + + if (buttonEventTypes == null || buttonEventTypes.Keys == null) + _touchpanel.DisableNumericalButton((uint)buttonNumber); + else + _touchpanel.EnableNumericalButton((uint)buttonNumber); + + + if (_touchpanel.NumericalButtonEnabledFeedBack != null) + enabledFb = _touchpanel.NumericalButtonEnabledFeedBack[(uint)buttonNumber]; + + if (_touchpanel.NumericalButtonDisabledFeedBack != null) + disabledFb = _touchpanel.NumericalButtonDisabledFeedBack[(uint)buttonNumber]; + + break; + } + } + + Debug.Console(0, this, "InitializeButton: key-'{0}' enabledFb-'{1}', disabledFb-'{2}'", + key, enabledFb ?? (object)"null", disabledFb ?? (object)"null"); + } + + /// + /// Links button feedback if configured + /// + /// + /// + public void InitializeButtonFeedback(string key, KeypadButton config) + { + //Debug.Console(1, this, "Initializing button '{0}' feedback...", key); + + if (config == null) + { + Debug.Console(1, this, "Button '{0}' config is null, skipping.", key); + return; + } + + int buttonNumber; + TryParseInt(key, out buttonNumber); + + // Link up the button feedbacks to the specified device feedback + var buttonFeedback = config.Feedback; + if (buttonFeedback == null || string.IsNullOrEmpty(buttonFeedback.DeviceKey)) + { + Debug.Console(1, this, "Button '{0}' feedback not configured, skipping.", + key); + return; + } + + Feedback deviceFeedback; + + try + { + var device = DeviceManager.GetDeviceForKey(buttonFeedback.DeviceKey) as Device; + if (device == null) + { + Debug.Console(1, this, "Button '{0}' feedback deviceKey '{1}' not found.", + key, buttonFeedback.DeviceKey); + return; + } + + deviceFeedback = device.GetFeedbackProperty(buttonFeedback.FeedbackName); + if (deviceFeedback == null) + { + Debug.Console(1, this, "Button '{0}' feedbackName property '{1}' not found.", + key, buttonFeedback.FeedbackName); + return; + } + + // TODO [ ] verify if this can replace the current method + //Debug.Console(0, this, "deviceFeedback.GetType().Name: '{0}'", deviceFeedback.GetType().Name); + //switch (feedback.GetType().Name.ToLower()) + //{ + // case("boolfeedback"): + // { + // break; + // } + // case("intfeedback"): + // { + // break; + // } + // case("stringfeedback"): + // { + // break; + // } + //} + } + catch (Exception ex) + { + Debug.Console(1, this, "InitializeButtonFeedback (button '{1}', deviceKey '{2}') Exception Message: {0}", + ex.Message, key, buttonFeedback.DeviceKey); + Debug.Console(2, this, "InitializeButtonFeedback (button '{1}', deviceKey '{2}') Exception StackTrace: {0}", + ex.StackTrace, key, buttonFeedback.DeviceKey); + if (ex.InnerException != null) Debug.Console(2, this, "InitializeButtonFeedback (button '{1}', deviceKey '{2}') InnerException: {0}", + ex.InnerException, key, buttonFeedback.DeviceKey); + + return; + } + + var boolFeedback = deviceFeedback as BoolFeedback; + var intFeedback = deviceFeedback as IntFeedback; + + switch (key) + { + case ("power"): + { + if (boolFeedback != null) boolFeedback.LinkCrestronFeedback(_touchpanel.FeedbackPower); + break; + } + case ("volumeup"): + case ("volumedown"): + case ("volumefeedback"): + { + if (intFeedback != null) + { + var volumeFeedback = intFeedback; + volumeFeedback.LinkInputSig(_touchpanel.VolumeBargraph); + } + break; + } + case ("mute"): + { + if (boolFeedback != null) boolFeedback.LinkCrestronFeedback(_touchpanel.FeedbackMute); + break; + } + default: + { + if (boolFeedback != null) boolFeedback.LinkCrestronFeedback(_touchpanel.Feedbacks[(uint)buttonNumber]); + break; + } + } + } + + /// + /// Try parse int helper method + /// + /// + /// + /// + public bool TryParseInt(string str, out int result) + { + try + { + result = int.Parse(str); + return true; + } + catch + { + result = 0; + return false; + } + } + + private void _touchpanel_BaseEvent(GenericBase device, BaseEventArgs args) + { + Debug.Console(1, this, "BaseEvent: eventId-'{0}', index-'{1}'", args.EventId, args.Index); + } + + private void _touchpanel_ButtonStateChange(GenericBase device, Crestron.SimplSharpPro.DeviceSupport.ButtonEventArgs args) + { + Debug.Console(1, this, "ButtonStateChange: buttonNumber-'{0}' buttonName-'{1}', buttonState-'{2}'", args.Button.Number, args.Button.Name, args.NewButtonState); + var type = args.NewButtonState.ToString(); + + if (_buttons.ContainsKey(args.Button.Number.ToString(CultureInfo.InvariantCulture))) + { + Press(args.Button.Number.ToString(CultureInfo.InvariantCulture), type); + } + else if (_buttons.ContainsKey(args.Button.Name.ToString())) + { + Press(args.Button.Name.ToString(), type); + } + } + + private void _touchpanel_PanelStateChange(GenericBase device, BaseEventArgs args) + { + Debug.Console(1, this, "PanelStateChange: eventId-'{0}', index-'{1}'", args.EventId, args.Index); + } + + /// + /// Runs the function associated with this button/type. One of the following strings: + /// Pressed, Released, Tapped, DoubleTapped, Held, HeldReleased + /// + /// + /// + public void Press(string buttonKey, string type) + { + Debug.Console(2, this, "Press: buttonKey-'{0}', type-'{1}'", buttonKey, type); + + // TODO: In future, consider modifying this to generate actions at device activation time + // to prevent the need to dynamically call the method via reflection on each button press + if (!_buttons.ContainsKey(buttonKey)) return; + + var button = _buttons[buttonKey]; + if (!button.EventTypes.ContainsKey(type)) return; + + foreach (var eventType in button.EventTypes[type]) DeviceJsonApi.DoDeviceAction(eventType); + } + } + + /// + /// Represents the configuration of a keypad button + /// + public class KeypadButton + { + [JsonProperty("eventTypes")] + public Dictionary EventTypes { get; set; } + + [JsonProperty("feedback")] + public KeypadButtonFeedback Feedback { get; set; } + + public KeypadButton() + { + EventTypes = new Dictionary(); + Feedback = new KeypadButtonFeedback(); + } + } + + /// + /// Represents the configuration of a keypad button feedback + /// + public class KeypadButtonFeedback + { + [JsonProperty("deviceKey")] + public string DeviceKey { get; set; } + + [JsonProperty("feedbackName")] + public string FeedbackName { get; set; } + } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Web/EssemtialsWebApi.cs b/src/PepperDash.Essentials.Core/Web/EssemtialsWebApi.cs index dc6b2efb..eb012378 100644 --- a/src/PepperDash.Essentials.Core/Web/EssemtialsWebApi.cs +++ b/src/PepperDash.Essentials.Core/Web/EssemtialsWebApi.cs @@ -3,9 +3,6 @@ using System.Collections.Generic; using System.Linq; using Crestron.SimplSharp; using Crestron.SimplSharp.WebScripting; -using Crestron.SimplSharpPro.Diagnostics; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using PepperDash.Core; using PepperDash.Core.Web; using PepperDash.Essentials.Core.Web.RequestHandlers; @@ -20,13 +17,13 @@ namespace PepperDash.Essentials.Core.Web /// http(s)://{ipaddress}/cws/{basePath} /// http(s)://{ipaddress}/VirtualControl/Rooms/{roomId}/cws/{basePath} /// - private readonly string _defaultBasePath = - CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance ? string.Format("/app{0:00}/api", InitialParametersClass.ApplicationNumber) : "/api"; + private readonly string _defaultBasePath = CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance + ? string.Format("/app{0:00}/api", InitialParametersClass.ApplicationNumber) + : "/api"; - // TODO [ ] Reset debug levels to proper value Trace = 0, Info = 1, Verbose = 2 private const int DebugTrace = 0; - private const int DebugInfo = 0; - private const int DebugVerbose = 0; + private const int DebugInfo = 1; + private const int DebugVerbose = 2; /// /// CWS base path @@ -98,11 +95,6 @@ namespace PepperDash.Essentials.Core.Web Name = "DevProps", RouteHandler = new DevPropsRequestHandler() }, - //new HttpCwsRoute("devprops/{key}") - //{ - // Name = "DevProps", - // RouteHandler = new DevPropsRequestHandler() - //}, new HttpCwsRoute("devjson") { Name = "DevJson", @@ -113,11 +105,6 @@ namespace PepperDash.Essentials.Core.Web Name = "SetDeviceStreamDebug", RouteHandler = new SetDeviceStreamDebugRequestHandler() }, - //new HttpCwsRoute("setdevicestreamdebug/{deviceKey}/{state}") - //{ - // Name = "SetDeviceStreamDebug", - // RouteHandler = new SetDeviceStreamDebugRequestHandler() - //}, new HttpCwsRoute("disableallstreamdebug") { Name = "DisableAllStreamDebug", @@ -173,12 +160,7 @@ namespace PepperDash.Essentials.Core.Web if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance) { /* - RMC4> WEBSERVER [ON | OFF | TIMEOUT | MAXSESSIONSPERUSER ] - WEBSERVER [TIMEOUT] will display current session timeout value - WEBSERVER MAXSESSIONSPERUSER will display current max web sessions per user - WEBSERVER ALLOWSHAREDSESSION will display whether 'samesite = none' would be set on cookies - No parameter - displays current setting */ var response = string.Empty; CrestronConsole.SendControlSystemCommand("webserver", ref response); diff --git a/src/PepperDash.Essentials.Core/Web/RequestHandlers/AppDebugRequestHandler.cs b/src/PepperDash.Essentials.Core/Web/RequestHandlers/AppDebugRequestHandler.cs index 91f45927..46a0f980 100644 --- a/src/PepperDash.Essentials.Core/Web/RequestHandlers/AppDebugRequestHandler.cs +++ b/src/PepperDash.Essentials.Core/Web/RequestHandlers/AppDebugRequestHandler.cs @@ -1,6 +1,4 @@ -using System; -using System.Text; -using Crestron.SimplSharp.WebScripting; +using Crestron.SimplSharp.WebScripting; using Newtonsoft.Json; using PepperDash.Core; using PepperDash.Core.Web.RequestHandlers; @@ -10,25 +8,14 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers public class AppDebugRequestHandler : WebApiBaseRequestHandler { /// - /// Handles CONNECT method requests + /// Constructor /// - /// - protected override void HandleConnect(HttpCwsContext context) + /// + /// base(true) enables CORS support by default + /// + public AppDebugRequestHandler() + : base(true) { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles DELETE method requests - /// - /// - protected override void HandleDelete(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); } /// @@ -37,7 +24,7 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers /// protected override void HandleGet(HttpCwsContext context) { - var appDebug = new AppDebug {Level = Debug.Level}; + var appDebug = new AppDebug { Level = Debug.Level }; var body = JsonConvert.SerializeObject(appDebug, Formatting.Indented); @@ -46,40 +33,7 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers context.Response.Write(body, false); context.Response.End(); } - - /// - /// Handles HEAD method requests - /// - /// - protected override void HandleHead(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles OPTIONS method requests - /// - /// - protected override void HandleOptions(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PATCH method requests - /// - /// - protected override void HandlePatch(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - + /// /// Handles POST method requests /// @@ -107,7 +61,7 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers var appDebug = new AppDebug(); var requestBody = JsonConvert.DeserializeAnonymousType(data, appDebug); - + Debug.SetDebugLevel(requestBody.Level); appDebug.Level = Debug.Level; @@ -118,33 +72,11 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers context.Response.Write(responseBody, false); context.Response.End(); } - - /// - /// Handles PUT method requests - /// - /// - protected override void HandlePut(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles TRACE method requests - /// - /// - protected override void HandleTrace(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } } public class AppDebug { [JsonProperty("level", NullValueHandling = NullValueHandling.Ignore)] - public int Level { get; set; } + public int Level { get; set; } } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Web/RequestHandlers/DefaultRequestHandler.cs b/src/PepperDash.Essentials.Core/Web/RequestHandlers/DefaultRequestHandler.cs index 1186dc0c..3320de7e 100644 --- a/src/PepperDash.Essentials.Core/Web/RequestHandlers/DefaultRequestHandler.cs +++ b/src/PepperDash.Essentials.Core/Web/RequestHandlers/DefaultRequestHandler.cs @@ -5,6 +5,17 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers { public class DefaultRequestHandler : WebApiBaseRequestHandler { + /// + /// Constructor + /// + /// + /// base(true) enables CORS support by default + /// + public DefaultRequestHandler() + : base(true) + { + } + /// /// Handles CONNECT method requests /// diff --git a/src/PepperDash.Essentials.Core/Web/RequestHandlers/DevJsonRequestHandler.cs b/src/PepperDash.Essentials.Core/Web/RequestHandlers/DevJsonRequestHandler.cs index ff3045b5..5c4f33a2 100644 --- a/src/PepperDash.Essentials.Core/Web/RequestHandlers/DevJsonRequestHandler.cs +++ b/src/PepperDash.Essentials.Core/Web/RequestHandlers/DevJsonRequestHandler.cs @@ -1,6 +1,6 @@ using System; -using System.Text; using Crestron.SimplSharp.WebScripting; +using PepperDash.Core; using PepperDash.Core.Web.RequestHandlers; namespace PepperDash.Essentials.Core.Web.RequestHandlers @@ -8,69 +8,14 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers public class DevJsonRequestHandler : WebApiBaseRequestHandler { /// - /// Handles CONNECT method requests + /// Constructor /// - /// - protected override void HandleConnect(HttpCwsContext context) + /// + /// base(true) enables CORS support by default + /// + public DevJsonRequestHandler() + : base(true) { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles DELETE method requests - /// - /// - protected override void HandleDelete(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles GET method requests - /// - /// - protected override void HandleGet(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles HEAD method requests - /// - /// - protected override void HandleHead(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles OPTIONS method requests - /// - /// - protected override void HandleOptions(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PATCH method requests - /// - /// - protected override void HandlePatch(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); } /// @@ -108,32 +53,14 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers } catch (Exception ex) { + Debug.Console(1, "Exception Message: {0}", ex.Message); + Debug.Console(2, "Exception Stack Trace: {0}", ex.StackTrace); + if(ex.InnerException != null) Debug.Console(2, "Exception Inner: {0}", ex.InnerException); + context.Response.StatusCode = 400; context.Response.StatusDescription = "Bad Request"; context.Response.End(); } } - - /// - /// Handles PUT method requests - /// - /// - protected override void HandlePut(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles TRACE method requests - /// - /// - protected override void HandleTrace(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Web/RequestHandlers/DevListRequestHandler.cs b/src/PepperDash.Essentials.Core/Web/RequestHandlers/DevListRequestHandler.cs index 1a548f29..e9df4347 100644 --- a/src/PepperDash.Essentials.Core/Web/RequestHandlers/DevListRequestHandler.cs +++ b/src/PepperDash.Essentials.Core/Web/RequestHandlers/DevListRequestHandler.cs @@ -8,25 +8,14 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers public class DevListRequestHandler : WebApiBaseRequestHandler { /// - /// Handles CONNECT method requests + /// Constructor /// - /// - protected override void HandleConnect(HttpCwsContext context) + /// + /// base(true) enables CORS support by default + /// + public DevListRequestHandler() + : base(true) { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles DELETE method requests - /// - /// - protected override void HandleDelete(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); } /// @@ -58,71 +47,5 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers context.Response.Write(js, false); context.Response.End(); } - - /// - /// Handles HEAD method requests - /// - /// - protected override void HandleHead(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles OPTIONS method requests - /// - /// - protected override void HandleOptions(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PATCH method requests - /// - /// - protected override void HandlePatch(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles POST method requests - /// - /// - protected override void HandlePost(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PUT method requests - /// - /// - protected override void HandlePut(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles TRACE method requests - /// - /// - protected override void HandleTrace(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Web/RequestHandlers/DevPropsRequestHandler.cs b/src/PepperDash.Essentials.Core/Web/RequestHandlers/DevPropsRequestHandler.cs index d7334591..25fadbce 100644 --- a/src/PepperDash.Essentials.Core/Web/RequestHandlers/DevPropsRequestHandler.cs +++ b/src/PepperDash.Essentials.Core/Web/RequestHandlers/DevPropsRequestHandler.cs @@ -1,5 +1,4 @@ -using System; -using System.Text; +using System.Text; using Crestron.SimplSharp.WebScripting; using Newtonsoft.Json; using PepperDash.Core.Web.RequestHandlers; @@ -9,69 +8,14 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers public class DevPropsRequestHandler : WebApiBaseRequestHandler { /// - /// Handles CONNECT method requests + /// Constructor /// - /// - protected override void HandleConnect(HttpCwsContext context) + /// + /// base(true) enables CORS support by default + /// + public DevPropsRequestHandler() + : base(true) { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles DELETE method requests - /// - /// - protected override void HandleDelete(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles GET method requests - /// - /// - protected override void HandleGet(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles HEAD method requests - /// - /// - protected override void HandleHead(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles OPTIONS method requests - /// - /// - protected override void HandleOptions(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PATCH method requests - /// - /// - protected override void HandlePatch(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); } /// @@ -128,27 +72,5 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers context.Response.Write(deviceProps, false); context.Response.End(); } - - /// - /// Handles PUT method requests - /// - /// - protected override void HandlePut(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles TRACE method requests - /// - /// - protected override void HandleTrace(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Web/RequestHandlers/DisableAllStreamDebugRequestHandler.cs b/src/PepperDash.Essentials.Core/Web/RequestHandlers/DisableAllStreamDebugRequestHandler.cs index 41dc4974..0e682d6c 100644 --- a/src/PepperDash.Essentials.Core/Web/RequestHandlers/DisableAllStreamDebugRequestHandler.cs +++ b/src/PepperDash.Essentials.Core/Web/RequestHandlers/DisableAllStreamDebugRequestHandler.cs @@ -6,69 +6,14 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers public class DisableAllStreamDebugRequestHandler : WebApiBaseRequestHandler { /// - /// Handles CONNECT method requests + /// Constructor /// - /// - protected override void HandleConnect(HttpCwsContext context) + /// + /// base(true) enables CORS support by default + /// + public DisableAllStreamDebugRequestHandler() + : base(true) { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles DELETE method requests - /// - /// - protected override void HandleDelete(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles GET method requests - /// - /// - protected override void HandleGet(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles HEAD method requests - /// - /// - protected override void HandleHead(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles OPTIONS method requests - /// - /// - protected override void HandleOptions(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PATCH method requests - /// - /// - protected override void HandlePatch(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); } /// @@ -83,27 +28,5 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers context.Response.StatusDescription = "OK"; context.Response.End(); } - - /// - /// Handles PUT method requests - /// - /// - protected override void HandlePut(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles TRACE method requests - /// - /// - protected override void HandleTrace(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Web/RequestHandlers/GetFeedbacksForDeviceRequestHandler.cs b/src/PepperDash.Essentials.Core/Web/RequestHandlers/GetFeedbacksForDeviceRequestHandler.cs index 1055dddd..5dd5495c 100644 --- a/src/PepperDash.Essentials.Core/Web/RequestHandlers/GetFeedbacksForDeviceRequestHandler.cs +++ b/src/PepperDash.Essentials.Core/Web/RequestHandlers/GetFeedbacksForDeviceRequestHandler.cs @@ -8,25 +8,14 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers public class GetFeedbacksForDeviceRequestHandler : WebApiBaseRequestHandler { /// - /// Handles CONNECT method requests + /// Constructor /// - /// - protected override void HandleConnect(HttpCwsContext context) + /// + /// base(true) enables CORS support by default + /// + public GetFeedbacksForDeviceRequestHandler() + : base(true) { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles DELETE method requests - /// - /// - protected override void HandleDelete(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); } /// @@ -109,71 +98,5 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers context.Response.Write(js, false); context.Response.End(); } - - /// - /// Handles HEAD method requests - /// - /// - protected override void HandleHead(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles OPTIONS method requests - /// - /// - protected override void HandleOptions(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PATCH method requests - /// - /// - protected override void HandlePatch(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles POST method requests - /// - /// - protected override void HandlePost(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PUT method requests - /// - /// - protected override void HandlePut(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles TRACE method requests - /// - /// - protected override void HandleTrace(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Web/RequestHandlers/GetJoinMapForBridgeKeyRequestHandler.cs b/src/PepperDash.Essentials.Core/Web/RequestHandlers/GetJoinMapForBridgeKeyRequestHandler.cs index f4ec3975..f2362f4b 100644 --- a/src/PepperDash.Essentials.Core/Web/RequestHandlers/GetJoinMapForBridgeKeyRequestHandler.cs +++ b/src/PepperDash.Essentials.Core/Web/RequestHandlers/GetJoinMapForBridgeKeyRequestHandler.cs @@ -9,25 +9,14 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers public class GetJoinMapForBridgeKeyRequestHandler : WebApiBaseRequestHandler { /// - /// Handles CONNECT method requests + /// Constructor /// - /// - protected override void HandleConnect(HttpCwsContext context) + /// + /// base(true) enables CORS support by default + /// + public GetJoinMapForBridgeKeyRequestHandler() + : base(true) { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles DELETE method requests - /// - /// - protected override void HandleDelete(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); } /// @@ -84,74 +73,6 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers context.Response.ContentEncoding = System.Text.Encoding.UTF8; context.Response.Write(js, false); context.Response.End(); - } - - /// - /// Handles HEAD method requests - /// - /// - protected override void HandleHead(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles OPTIONS method requests - /// - /// - protected override void HandleOptions(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PATCH method requests - /// - /// - protected override void HandlePatch(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles POST method requests - /// - /// - protected override void HandlePost(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PUT method requests - /// - /// - protected override void HandlePut(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles TRACE method requests - /// - /// - protected override void HandleTrace(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - + } } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Web/RequestHandlers/GetJoinMapForDeviceKeyRequestHandler.cs b/src/PepperDash.Essentials.Core/Web/RequestHandlers/GetJoinMapForDeviceKeyRequestHandler.cs index fe3fc999..6c669189 100644 --- a/src/PepperDash.Essentials.Core/Web/RequestHandlers/GetJoinMapForDeviceKeyRequestHandler.cs +++ b/src/PepperDash.Essentials.Core/Web/RequestHandlers/GetJoinMapForDeviceKeyRequestHandler.cs @@ -8,25 +8,14 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers public class GetJoinMapForDeviceKeyRequestHandler : WebApiBaseRequestHandler { /// - /// Handles CONNECT method requests + /// Constructor /// - /// - protected override void HandleConnect(HttpCwsContext context) + /// + /// base(true) enables CORS support by default + /// + public GetJoinMapForDeviceKeyRequestHandler() + : base(true) { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles DELETE method requests - /// - /// - protected override void HandleDelete(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); } /// @@ -102,71 +91,5 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers context.Response.Write(js, false); context.Response.End(); } - - /// - /// Handles HEAD method requests - /// - /// - protected override void HandleHead(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles OPTIONS method requests - /// - /// - protected override void HandleOptions(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PATCH method requests - /// - /// - protected override void HandlePatch(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles POST method requests - /// - /// - protected override void HandlePost(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PUT method requests - /// - /// - protected override void HandlePut(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles TRACE method requests - /// - /// - protected override void HandleTrace(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Web/RequestHandlers/GetTypesByFilterRequestHandler.cs b/src/PepperDash.Essentials.Core/Web/RequestHandlers/GetTypesByFilterRequestHandler.cs index 6636d914..105d2419 100644 --- a/src/PepperDash.Essentials.Core/Web/RequestHandlers/GetTypesByFilterRequestHandler.cs +++ b/src/PepperDash.Essentials.Core/Web/RequestHandlers/GetTypesByFilterRequestHandler.cs @@ -1,6 +1,8 @@ -using System.Linq; +extern alias Full + +using System.Linq; using Crestron.SimplSharp.WebScripting; -using Newtonsoft.Json; +using Full.Newtonsoft.Json; using PepperDash.Core.Web.RequestHandlers; namespace PepperDash.Essentials.Core.Web.RequestHandlers @@ -8,25 +10,14 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers public class GetTypesByFilterRequestHandler : WebApiBaseRequestHandler { /// - /// Handles CONNECT method requests + /// Constructor /// - /// - protected override void HandleConnect(HttpCwsContext context) + /// + /// base(true) enables CORS support by default + /// + public GetTypesByFilterRequestHandler() + : base(true) { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles DELETE method requests - /// - /// - protected override void HandleDelete(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); } /// @@ -75,71 +66,5 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers context.Response.Write(js, false); context.Response.End(); } - - /// - /// Handles HEAD method requests - /// - /// - protected override void HandleHead(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles OPTIONS method requests - /// - /// - protected override void HandleOptions(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PATCH method requests - /// - /// - protected override void HandlePatch(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles POST method requests - /// - /// - protected override void HandlePost(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PUT method requests - /// - /// - protected override void HandlePut(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles TRACE method requests - /// - /// - protected override void HandleTrace(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Web/RequestHandlers/GetTypesRequestHandler.cs b/src/PepperDash.Essentials.Core/Web/RequestHandlers/GetTypesRequestHandler.cs index 094d22f4..a72fe7e4 100644 --- a/src/PepperDash.Essentials.Core/Web/RequestHandlers/GetTypesRequestHandler.cs +++ b/src/PepperDash.Essentials.Core/Web/RequestHandlers/GetTypesRequestHandler.cs @@ -1,6 +1,8 @@ -using System.Linq; +extern alias Full + +using System.Linq; using Crestron.SimplSharp.WebScripting; -using Newtonsoft.Json; +using Full.Newtonsoft.Json; using PepperDash.Core.Web.RequestHandlers; namespace PepperDash.Essentials.Core.Web.RequestHandlers @@ -8,25 +10,14 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers public class GetTypesRequestHandler : WebApiBaseRequestHandler { /// - /// Handles CONNECT method requests + /// Constructor /// - /// - protected override void HandleConnect(HttpCwsContext context) + /// + /// base(true) enables CORS support by default + /// + public GetTypesRequestHandler() + : base(true) { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles DELETE method requests - /// - /// - protected override void HandleDelete(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); } /// @@ -65,71 +56,5 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers context.Response.Write(js, false); context.Response.End(); } - - /// - /// Handles HEAD method requests - /// - /// - protected override void HandleHead(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles OPTIONS method requests - /// - /// - protected override void HandleOptions(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PATCH method requests - /// - /// - protected override void HandlePatch(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles POST method requests - /// - /// - protected override void HandlePost(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PUT method requests - /// - /// - protected override void HandlePut(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles TRACE method requests - /// - /// - protected override void HandleTrace(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Web/RequestHandlers/ReportVersionsRequestHandler.cs b/src/PepperDash.Essentials.Core/Web/RequestHandlers/ReportVersionsRequestHandler.cs index 321c5bfc..925a95f0 100644 --- a/src/PepperDash.Essentials.Core/Web/RequestHandlers/ReportVersionsRequestHandler.cs +++ b/src/PepperDash.Essentials.Core/Web/RequestHandlers/ReportVersionsRequestHandler.cs @@ -1,6 +1,8 @@ -using System.Linq; +extern alias Full + +using System.Linq; using Crestron.SimplSharp.WebScripting; -using Newtonsoft.Json; +using Full.Newtonsoft.Json; using PepperDash.Core.Web.RequestHandlers; namespace PepperDash.Essentials.Core.Web.RequestHandlers @@ -8,25 +10,14 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers public class ReportVersionsRequestHandler : WebApiBaseRequestHandler { /// - /// Handles CONNECT method requests + /// Constructor /// - /// - protected override void HandleConnect(HttpCwsContext context) + /// + /// base(true) enables CORS support by default + /// + public ReportVersionsRequestHandler() + : base(true) { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles DELETE method requests - /// - /// - protected override void HandleDelete(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); } /// @@ -56,71 +47,5 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers context.Response.Write(js, false); context.Response.End(); } - - /// - /// Handles HEAD method requests - /// - /// - protected override void HandleHead(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles OPTIONS method requests - /// - /// - protected override void HandleOptions(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PATCH method requests - /// - /// - protected override void HandlePatch(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles POST method requests - /// - /// - protected override void HandlePost(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PUT method requests - /// - /// - protected override void HandlePut(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles TRACE method requests - /// - /// - protected override void HandleTrace(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Web/RequestHandlers/ShowConfigRequestHandler.cs b/src/PepperDash.Essentials.Core/Web/RequestHandlers/ShowConfigRequestHandler.cs index 16c05abf..b017627d 100644 --- a/src/PepperDash.Essentials.Core/Web/RequestHandlers/ShowConfigRequestHandler.cs +++ b/src/PepperDash.Essentials.Core/Web/RequestHandlers/ShowConfigRequestHandler.cs @@ -1,5 +1,7 @@ -using Crestron.SimplSharp.WebScripting; -using Newtonsoft.Json; +extern alias Full + +using Crestron.SimplSharp.WebScripting; +using Full.Newtonsoft.Json; using PepperDash.Core.Web.RequestHandlers; using PepperDash.Essentials.Core.Config; @@ -8,25 +10,14 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers public class ShowConfigRequestHandler : WebApiBaseRequestHandler { /// - /// Handles CONNECT method requests + /// Constructor /// - /// - protected override void HandleConnect(HttpCwsContext context) + /// + /// base(true) enables CORS support by default + /// + public ShowConfigRequestHandler() + : base(true) { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles DELETE method requests - /// - /// - protected override void HandleDelete(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); } /// @@ -44,71 +35,5 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers context.Response.Write(config, false); context.Response.End(); } - - /// - /// Handles HEAD method requests - /// - /// - protected override void HandleHead(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles OPTIONS method requests - /// - /// - protected override void HandleOptions(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PATCH method requests - /// - /// - protected override void HandlePatch(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles POST method requests - /// - /// - protected override void HandlePost(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PUT method requests - /// - /// - protected override void HandlePut(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles TRACE method requests - /// - /// - protected override void HandleTrace(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/AirMedia/AirMediaController.cs b/src/PepperDash.Essentials.DM/AirMedia/AirMediaController.cs deleted file mode 100644 index 80f8e64d..00000000 --- a/src/PepperDash.Essentials.DM/AirMedia/AirMediaController.cs +++ /dev/null @@ -1,368 +0,0 @@ -extern alias Full; - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.DeviceSupport.Support; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.AirMedia; -using Full.Newtonsoft.Json; -using Full.Newtonsoft.Json.Linq; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Config; - -namespace PepperDash.Essentials.DM.AirMedia -{ - [Description("Wrapper class for an AM-200 or AM-300")] - public class AirMediaController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback, IIROutputPorts, IComPorts - { - public AmX00 AirMedia { get; private set; } - - public DeviceConfig DeviceConfig { get; private set; } - - AirMediaPropertiesConfig PropertiesConfig; - - public RoutingPortCollection InputPorts { get; private set; } - - public RoutingPortCollection OutputPorts { get; private set; } - - - //IroutingNumericEvent - public event EventHandler NumericSwitchChange; - - public BoolFeedback IsInSessionFeedback { get; private set; } - public IntFeedback ErrorFeedback { get; private set; } - public IntFeedback NumberOfUsersConnectedFeedback { get; set; } - public IntFeedback LoginCodeFeedback { get; set; } - public StringFeedback ConnectionAddressFeedback { get; set; } - public StringFeedback HostnameFeedback { get; set; } - public IntFeedback VideoOutFeedback { get; private set; } - public BoolFeedback HdmiVideoSyncDetectedFeedback { get; private set; } - public StringFeedback SerialNumberFeedback { get; private set; } - public BoolFeedback AutomaticInputRoutingEnabledFeedback { get; private set; } - - public AirMediaController(string key, string name, AmX00 device, DeviceConfig dc, AirMediaPropertiesConfig props) - : base(key, name, device) - { - - AirMedia = device; - - DeviceConfig = dc; - - PropertiesConfig = props; - - InputPorts = new RoutingPortCollection(); - OutputPorts = new RoutingPortCollection(); - - InputPorts.Add(new RoutingInputPort(DmPortName.Osd, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.None, new Action(SelectPinPointUxLandingPage), this) - { - FeedbackMatchObject = 0 - }); - - InputPorts.Add(new RoutingInputPort(DmPortName.AirMediaIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.Streaming, new Action(SelectAirMedia), this) - { - FeedbackMatchObject = 1 - }); - - InputPorts.Add(new RoutingInputPort(DmPortName.HdmiIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.Hdmi, new Action(SelectHdmiIn), this) - { - FeedbackMatchObject = 2 - }); - - InputPorts.Add(new RoutingInputPort(DmPortName.AirBoardIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.None, new Action(SelectAirboardIn), this) - { - FeedbackMatchObject = 4 - }); - - if (AirMedia is Am300) - { - InputPorts.Add(new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.DmCat, new Action(SelectDmIn), this) - { - FeedbackMatchObject = 3 - }); - } - - OutputPorts.Add(new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.Hdmi, null, this)); - - AirMedia.AirMedia.AirMediaChange += new Crestron.SimplSharpPro.DeviceSupport.GenericEventHandler(AirMedia_AirMediaChange); - - IsInSessionFeedback = new BoolFeedback(new Func(() => AirMedia.AirMedia.StatusFeedback.UShortValue == 0)); - ErrorFeedback = new IntFeedback(new Func(() => AirMedia.AirMedia.ErrorFeedback.UShortValue)); - NumberOfUsersConnectedFeedback = new IntFeedback(new Func(() => AirMedia.AirMedia.NumberOfUsersConnectedFeedback.UShortValue)); - LoginCodeFeedback = new IntFeedback(new Func(() => AirMedia.AirMedia.LoginCodeFeedback.UShortValue)); - ConnectionAddressFeedback = new StringFeedback(new Func(() => AirMedia.AirMedia.ConnectionAddressFeedback.StringValue)); - HostnameFeedback = new StringFeedback(new Func(() => AirMedia.AirMedia.HostNameFeedback.StringValue)); - - // TODO: Figure out if we can actually get the TSID/Serial - SerialNumberFeedback = new StringFeedback(new Func(() => "unknown")); - - AirMedia.DisplayControl.DisplayControlChange += new Crestron.SimplSharpPro.DeviceSupport.GenericEventHandler(DisplayControl_DisplayControlChange); - - VideoOutFeedback = new IntFeedback(new Func(() => Convert.ToInt16(AirMedia.DisplayControl.VideoOutFeedback))); - AutomaticInputRoutingEnabledFeedback = new BoolFeedback(new Func(() => AirMedia.DisplayControl.EnableAutomaticRoutingFeedback.BoolValue)); - - AirMedia.HdmiIn.StreamChange += new Crestron.SimplSharpPro.DeviceSupport.StreamEventHandler(HdmiIn_StreamChange); - - HdmiVideoSyncDetectedFeedback = new BoolFeedback(new Func(() => AirMedia.HdmiIn.SyncDetectedFeedback.BoolValue)); - } - - public override bool CustomActivate() - { - if (PropertiesConfig.AutoSwitchingEnabled) - AirMedia.DisplayControl.EnableAutomaticRouting(); - else - AirMedia.DisplayControl.DisableAutomaticRouting(); - - return base.CustomActivate(); - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new AirMediaControllerJoinMap(joinStart); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - - Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - Debug.Console(0, "Linking to Airmedia: {0}", Name); - - trilist.StringInput[joinMap.Name.JoinNumber].StringValue = Name; - - var commMonitor = this as ICommunicationMonitor; - - commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - - IsInSessionFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsInSession.JoinNumber]); - HdmiVideoSyncDetectedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.HdmiVideoSync.JoinNumber]); - - trilist.SetSigTrueAction(joinMap.AutomaticInputRoutingEnabled.JoinNumber, AirMedia.DisplayControl.EnableAutomaticRouting); - trilist.SetSigFalseAction(joinMap.AutomaticInputRoutingEnabled.JoinNumber, AirMedia.DisplayControl.DisableAutomaticRouting); - AutomaticInputRoutingEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.AutomaticInputRoutingEnabled.JoinNumber]); - - trilist.SetUShortSigAction(joinMap.VideoOut.JoinNumber, (u) => SelectVideoOut(u)); - - VideoOutFeedback.LinkInputSig(trilist.UShortInput[joinMap.VideoOut.JoinNumber]); - ErrorFeedback.LinkInputSig(trilist.UShortInput[joinMap.ErrorFB.JoinNumber]); - NumberOfUsersConnectedFeedback.LinkInputSig(trilist.UShortInput[joinMap.NumberOfUsersConnectedFB.JoinNumber]); - - trilist.SetUShortSigAction(joinMap.LoginCode.JoinNumber, (u) => AirMedia.AirMedia.LoginCode.UShortValue = u); - LoginCodeFeedback.LinkInputSig(trilist.UShortInput[joinMap.LoginCode.JoinNumber]); - - ConnectionAddressFeedback.LinkInputSig(trilist.StringInput[joinMap.ConnectionAddressFB.JoinNumber]); - HostnameFeedback.LinkInputSig(trilist.StringInput[joinMap.HostnameFB.JoinNumber]); - SerialNumberFeedback.LinkInputSig(trilist.StringInput[joinMap.SerialNumberFeedback.JoinNumber]); - } - - /// - /// Raise an event when the status of a switch object changes. - /// - /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType - private void OnSwitchChange(RoutingNumericEventArgs e) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, e); - } - - - void AirMedia_AirMediaChange(object sender, Crestron.SimplSharpPro.DeviceSupport.GenericEventArgs args) - { - if (args.EventId == AirMediaInputSlot.AirMediaStatusFeedbackEventId) - IsInSessionFeedback.FireUpdate(); - else if (args.EventId == AirMediaInputSlot.AirMediaErrorFeedbackEventId) - ErrorFeedback.FireUpdate(); - else if (args.EventId == AirMediaInputSlot.AirMediaNumberOfUserConnectedEventId) - NumberOfUsersConnectedFeedback.FireUpdate(); - else if (args.EventId == AirMediaInputSlot.AirMediaLoginCodeEventId) - LoginCodeFeedback.FireUpdate(); - else if (args.EventId == AirMediaInputSlot.AirMediaConnectionAddressFeedbackEventId) - ConnectionAddressFeedback.FireUpdate(); - else if (args.EventId == AirMediaInputSlot.AirMediaHostNameFeedbackEventId) - HostnameFeedback.FireUpdate(); - } - - void DisplayControl_DisplayControlChange(object sender, Crestron.SimplSharpPro.DeviceSupport.GenericEventArgs args) - { - if (args.EventId == AmX00.VideoOutFeedbackEventId) - { - VideoOutFeedback.FireUpdate(); - - var localInputPort = - InputPorts.FirstOrDefault(p => (int) p.FeedbackMatchObject == VideoOutFeedback.UShortValue); - - OnSwitchChange(new RoutingNumericEventArgs(1, VideoOutFeedback.UShortValue, OutputPorts.First(), - localInputPort, eRoutingSignalType.AudioVideo)); - } - else if (args.EventId == AmX00.EnableAutomaticRoutingFeedbackEventId) - AutomaticInputRoutingEnabledFeedback.FireUpdate(); - } - - void HdmiIn_StreamChange(Stream stream, Crestron.SimplSharpPro.DeviceSupport.StreamEventArgs args) - { - if (args.EventId == DMInputEventIds.SourceSyncEventId) - HdmiVideoSyncDetectedFeedback.FireUpdate(); - } - - /// - /// Sets the VideoOut source ( 0 = PinpointUX, 1 = AirMedia, 2 = HDMI, 3 = DM, 4 = Airboard ) - /// - /// source number - public void SelectVideoOut(uint source) - { - AirMedia.DisplayControl.VideoOut = (AmX00DisplayControl.eAirMediaX00VideoSource)source; - } - - /// - /// Selects the PinPointUXLandingPage input - /// - public void SelectPinPointUxLandingPage() - { - AirMedia.DisplayControl.VideoOut = AmX00DisplayControl.eAirMediaX00VideoSource.PinPointUxLandingPage; - } - - /// - /// Selects the AirMedia input - /// - public void SelectAirMedia() - { - AirMedia.DisplayControl.VideoOut = AmX00DisplayControl.eAirMediaX00VideoSource.AirMedia; - } - - /// - /// Selects the DM input - /// - public void SelectDmIn() - { - AirMedia.DisplayControl.VideoOut = AmX00DisplayControl.eAirMediaX00VideoSource.DM; - } - - /// - /// Selects the HDMI INput - /// - public void SelectHdmiIn() - { - AirMedia.DisplayControl.VideoOut = AmX00DisplayControl.eAirMediaX00VideoSource.HDMI; - } - - public void SelectAirboardIn() - { - AirMedia.DisplayControl.VideoOut = AmX00DisplayControl.eAirMediaX00VideoSource.AirBoard; - } - - /// - /// Reboots the device - /// - public void RebootDevice() - { - AirMedia.AirMedia.DeviceReboot(); - } - - #region IIROutputPorts Members - - public CrestronCollection IROutputPorts - { - get { return AirMedia.IROutputPorts; } - } - - public int NumberOfIROutputPorts - { - get { return AirMedia.NumberOfIROutputPorts; } - } - - - - #endregion - - - - #region IComPorts Members - - public CrestronCollection ComPorts - { - get { return AirMedia.ComPorts; } - } - - public int NumberOfComPorts - { - get { return AirMedia.NumberOfComPorts; } - } - - #endregion - - - - #region IRoutingNumeric Members - - public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType signalType) - { - if ((signalType & eRoutingSignalType.Video) != eRoutingSignalType.Video) return; - if (!Enum.IsDefined(typeof (AmX00DisplayControl.eAirMediaX00VideoSource), input)) - { - Debug.Console(2, this, "Invalid Video Source Index : {0}", input); - return; - } - AirMedia.DisplayControl.VideoOut = (AmX00DisplayControl.eAirMediaX00VideoSource) input; - } - - #endregion - - #region IRouting Members - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - Debug.Console(2, this, "Input Selector = {0}", inputSelector.ToString()); - var handler = inputSelector as Action; - if (handler == null) return; - handler(); - } - - #endregion - } - - public class AirMediaControllerFactory : EssentialsDeviceFactory - { - public AirMediaControllerFactory() - { - TypeNames = new List() { "am200", "am300" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - var type = dc.Type.ToLower(); - - Debug.Console(1, "Factory Attempting to create new AirMedia Device"); - - var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); - AmX00 amDevice = null; - if (type == "am200") - amDevice = new Crestron.SimplSharpPro.DM.AirMedia.Am200(props.Control.IpIdInt, Global.ControlSystem); - else if (type == "am300") - amDevice = new Crestron.SimplSharpPro.DM.AirMedia.Am300(props.Control.IpIdInt, Global.ControlSystem); - - return new AirMediaController(dc.Key, dc.Name, amDevice, dc, props); - - } - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/AirMedia/AirMediaPropertiesConfig.cs b/src/PepperDash.Essentials.DM/AirMedia/AirMediaPropertiesConfig.cs deleted file mode 100644 index be46505b..00000000 --- a/src/PepperDash.Essentials.DM/AirMedia/AirMediaPropertiesConfig.cs +++ /dev/null @@ -1,23 +0,0 @@ -extern alias Full; - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; - -using PepperDash.Core; - -using Full.Newtonsoft.Json; - -namespace PepperDash.Essentials.DM.AirMedia -{ - public class AirMediaPropertiesConfig - { - [JsonProperty("control")] - public ControlPropertiesConfig Control { get; set; } - - [JsonProperty("autoSwitching")] - public bool AutoSwitchingEnabled { get; set; } - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Chassis/Config/Schema/DmChassisControllerPropertiesConfigSchema.json b/src/PepperDash.Essentials.DM/Chassis/Config/Schema/DmChassisControllerPropertiesConfigSchema.json deleted file mode 100644 index 7769bdbc..00000000 --- a/src/PepperDash.Essentials.DM/Chassis/Config/Schema/DmChassisControllerPropertiesConfigSchema.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-03/schema#", - "title": "DmChassisController Properties Config Schema", - "description": "", - "$ref": "EssentialsConfigSchema.json#definitions/Device", - "properties": { - "properties": { - "$ref": "#/propertiesConfig" - } - }, - "propertiesConfig": { - "type": "object", - "additionalProperties": true, - "properties": { - "control": { - "required":true, - "type": "object", - "$ref": "../../ControlPropertiesConfigSchema.json#/ControlPropertiesConfig" - }, - "volumeControls": { - "title": "Volume Controls", - "type": "object", - "additionalProperties": { - "type": "object", - "$ref": "#/dmAudioCardPropertiesConfig" - } - }, - "inputSlots": { - "required":true, - "title": "Input Slots", - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "outputSlots": { - "required":true, - "title": "Output Slots", - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "inputNames": { - "title": "Input Names", - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "outputNames": { - "title": "Output Names", - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "noRouteText": { - "title": "No Route Text", - "type": "string" - }, - "inputSlotSupportsHdcp2": { - "type": "object", - "additionalProperties": { - "type": "boolean" - } - } - } - }, - "dmAudioCardPropertiesConfig": { - "type": "object", - "properties": { - "OutLevel": { - "title": "Output Level", - "type": "integer" - }, - "isVolumeControlPoint": { - "title": "Volume Control Point?", - "type": "boolean" - } - } - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Chassis/DmBladeChassisController.cs b/src/PepperDash.Essentials.DM/Chassis/DmBladeChassisController.cs deleted file mode 100644 index 841c239a..00000000 --- a/src/PepperDash.Essentials.DM/Chassis/DmBladeChassisController.cs +++ /dev/null @@ -1,1001 +0,0 @@ -extern alias Full; - -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.Cards; -using Crestron.SimplSharpPro.DM.Blades; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Receivers; -using Full.Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.DM.Config; - -namespace PepperDash.Essentials.DM -{ - /// - /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions - /// - /// - public class DmBladeChassisController : CrestronGenericBridgeableBaseDevice, IDmSwitch, IRoutingNumericWithFeedback - { - private const string NonePortKey = "inputCard0--None"; - - public DMChassisPropertiesConfig PropertiesConfig { get; set; } - - public Switch Chassis { get; private set; } - - //IroutingNumericEvent - public event EventHandler NumericSwitchChange; - - // Feedbacks for EssentialDM - public Dictionary VideoOutputFeedbacks { get; private set; } - public Dictionary AudioOutputFeedbacks { get; private set; } - public Dictionary VideoInputSyncFeedbacks { get; private set; } - public Dictionary InputEndpointOnlineFeedbacks { get; private set; } - public Dictionary OutputEndpointOnlineFeedbacks { get; private set; } - public Dictionary InputNameFeedbacks { get; private set; } - public Dictionary OutputNameFeedbacks { get; private set; } - public Dictionary OutputVideoRouteNameFeedbacks { get; private set; } - public Dictionary OutputAudioRouteNameFeedbacks { get; private set; } - public Dictionary UsbOutputRoutedToFeebacks { get; private set; } - public Dictionary UsbInputRoutedToFeebacks { get; private set; } - - public IntFeedback SystemIdFeebdack { get; private set; } - public BoolFeedback SystemIdBusyFeedback { get; private set; } - - - public Dictionary InputCardHdcpCapabilityFeedbacks { get; private set; } - - public Dictionary InputCardHdcpCapabilityTypes { get; private set; } - - - // Need a couple Lists of generic Backplane ports - public RoutingPortCollection InputPorts { get; private set; } - public RoutingPortCollection OutputPorts { get; private set; } - - public Dictionary TxDictionary { get; set; } - public Dictionary RxDictionary { get; set; } - - //public Dictionary InputCards { get; private set; } - //public Dictionary OutputCards { get; private set; } - - public Dictionary InputNames { get; set; } - public Dictionary OutputNames { get; set; } - public Dictionary VolumeControls { get; private set; } - - public const int RouteOffTime = 500; - Dictionary RouteOffTimers = new Dictionary(); - - /// - /// Factory method to create a new chassis controller from config data. Limited to 8x8 right now - /// - public static DmBladeChassisController GetDmChassisController(string key, string name, - string type, DMChassisPropertiesConfig properties) - { - try - { - type = type.ToLower(); - uint ipid = properties.Control.IpIdInt; - - BladeSwitch chassis = null; - if (type == "dmmd64x64") { chassis = new DmMd64x64(ipid, Global.ControlSystem); } - else if (type == "dmmd128x128") { chassis = new DmMd128x128(ipid, Global.ControlSystem); } - - - if (chassis == null) - { - return null; - } - - var controller = new DmBladeChassisController(key, name, chassis); - // add the cards and port names - foreach (var kvp in properties.InputSlots) - controller.AddInputBlade(kvp.Value, kvp.Key); - foreach (var kvp in properties.OutputSlots) - { - controller.AddOutputBlade(kvp.Value, kvp.Key); - } - - foreach (var kvp in properties.VolumeControls) - { - // get the card - // check it for an audio-compatible type - // make a something-something that will make it work - // retire to mountain village - var outNum = kvp.Key; - - var card = controller.Chassis.Outputs[outNum].Card; - Audio.Output audio = null; - if (card is DmHdmi4kOutputBladeCard) - audio = (card as DmHdmi4kOutputBladeCard).Hdmi4kOutput.Audio; - if (audio == null) - continue; - // wire up the audio to something here... - controller.AddVolumeControl(outNum, audio); - } - - controller.InputPorts.Add(new RoutingInputPort(NonePortKey, eRoutingSignalType.Video, - eRoutingPortConnectionType.None, null, controller)); - - - controller.InputNames = properties.InputNames; - controller.OutputNames = properties.OutputNames; - controller.PropertiesConfig = properties; - return controller; - } - catch (System.Exception e) - { - Debug.Console(0, "Error creating DM chassis:\r{0}", e); - } - return null; - } - - - /// - /// - /// - /// - /// - /// - public DmBladeChassisController(string key, string name, BladeSwitch chassis) - : base(key, name, chassis) - { - Chassis = chassis; - InputPorts = new RoutingPortCollection(); - OutputPorts = new RoutingPortCollection(); - VolumeControls = new Dictionary(); - TxDictionary = new Dictionary(); - RxDictionary = new Dictionary(); - IsOnline.OutputChange += new EventHandler(IsOnline_OutputChange); - Chassis.DMInputChange += new DMInputEventHandler(Chassis_DMInputChange); - Chassis.DMOutputChange += new DMOutputEventHandler(Chassis_DMOutputChange); - VideoOutputFeedbacks = new Dictionary(); - UsbOutputRoutedToFeebacks = new Dictionary(); - UsbInputRoutedToFeebacks = new Dictionary(); - VideoInputSyncFeedbacks = new Dictionary(); - InputNameFeedbacks = new Dictionary(); - OutputNameFeedbacks = new Dictionary(); - OutputVideoRouteNameFeedbacks = new Dictionary(); - OutputAudioRouteNameFeedbacks = new Dictionary(); - InputEndpointOnlineFeedbacks = new Dictionary(); - OutputEndpointOnlineFeedbacks = new Dictionary(); - - InputCardHdcpCapabilityFeedbacks = new Dictionary(); - InputCardHdcpCapabilityTypes = new Dictionary(); - - for (uint x = 1; x <= Chassis.NumberOfOutputs; x++) - { - var tempX = x; - - if (Chassis.Outputs[tempX] != null) - { - VideoOutputFeedbacks[tempX] = new IntFeedback(() => - { - if (Chassis.Outputs[tempX].VideoOutFeedback != null) { return (ushort)Chassis.Outputs[tempX].VideoOutFeedback.Number; } - else { return 0; }; - }); - - OutputNameFeedbacks[tempX] = new StringFeedback(() => - { - if (Chassis.Outputs[tempX].NameFeedback != null) - { - return Chassis.Outputs[tempX].NameFeedback.StringValue; - } - else - { - return ""; - } - }); - OutputVideoRouteNameFeedbacks[tempX] = new StringFeedback(() => - { - if (Chassis.Outputs[tempX].VideoOutFeedback != null) - { - return Chassis.Outputs[tempX].VideoOutFeedback.NameFeedback.StringValue; - } - else - { - return ""; - } - }); - - OutputEndpointOnlineFeedbacks[tempX] = new BoolFeedback(() => - { - //if (Chassis.Outputs[tempX].Endpoint != null) - // return Chassis.Outputs[tempX].Endpoint.IsOnline; - //else - return Chassis.Outputs[tempX].EndpointOnlineFeedback; - }); - } - - if (Chassis.Inputs[tempX] != null) - { - UsbInputRoutedToFeebacks[tempX] = new IntFeedback(() => - { - if (Chassis.Inputs[tempX].USBRoutedToFeedback != null) { return (ushort)Chassis.Inputs[tempX].USBRoutedToFeedback.Number; } - else { return 0; }; - }); - VideoInputSyncFeedbacks[tempX] = new BoolFeedback(() => - { - if (Chassis.Inputs[tempX].VideoDetectedFeedback != null) - return Chassis.Inputs[tempX].VideoDetectedFeedback.BoolValue; - else - return false; - }); - InputNameFeedbacks[tempX] = new StringFeedback(() => - { - if (Chassis.Inputs[tempX].NameFeedback != null) - { - return Chassis.Inputs[tempX].NameFeedback.StringValue; - } - else - { - return ""; - } - }); - - InputEndpointOnlineFeedbacks[tempX] = new BoolFeedback(() => - { - return Chassis.Inputs[tempX].EndpointOnlineFeedback; - }); - - InputCardHdcpCapabilityFeedbacks[tempX] = new IntFeedback(() => - { - var inputCard = Chassis.Inputs[tempX]; - - if (inputCard.Card is DmHdmi4kInputBladeCard) - { - InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.Hdcp2_2Support; - - if ((inputCard.Card as DmHdmi4kInputBladeCard).Hdmi4kInput.HdcpSupportOnFeedback.BoolValue) - return 1; - else - return 0; - } - - if (inputCard.Card is DmC4kInputBladeCard) - { - InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.Hdcp2_2Support; - - if ((inputCard.Card as DmC4kInputBladeCard).DmInput.HdcpCapabilityFeedback.Equals(eHdcpCapabilityType.HdcpSupportOff)) - return 0; - else - return 1; - } - - else - return 0; - }); - } - } - } - - /// - /// - /// - /// - /// - public void AddInputBlade(string type, uint number) - { - Debug.Console(2, this, "Adding input blade '{0}', slot {1}", type, number); - - type = type.ToLower(); - - if (type == "dmb4kihd") - { - var inputBlade = new Dmb4kIHd(number, this.Chassis); - foreach (var item in inputBlade.Inputs) - { - var card = (item.Card as DmHdmi4kInputBladeCard).Hdmi4kInput; - var cecPort = card as ICec; - AddHdmiInBladePorts(item.Number, cecPort); - } - } - - else if (type == "dmb4kihddnt") - { - var inputBlade = new Dmb4kIHd(number, this.Chassis); - foreach (var item in inputBlade.Inputs) - { - var card = (item.Card as DmHdmi4kInputBladeCard).Hdmi4kInput; - var cecPort = card as ICec; - AddHdmiInBladePorts(item.Number, cecPort); - } - } - - else if (type == "dmb4kic") - { - var inputBlade = new Dmb4kIC(number, this.Chassis); - foreach (var item in inputBlade.Inputs) - { - AddDmInBladePorts(item.Number); - } - } - - else if (type == "dmbis") - { - var inputBlade = new DmbIS(number, this.Chassis); - foreach (var item in inputBlade.Inputs) - { - AddDmInMmFiberPorts(item.Number); - } - } - else if (type == "dmbis2") - { - var inputBlade = new DmbIS2(number, this.Chassis); - foreach (var item in inputBlade.Inputs) - { - AddDmInSmFiberPorts(item.Number); - } - } - } - - /// - /// Raise an event when the status of a switch object changes. - /// - /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType - private void OnSwitchChange(RoutingNumericEventArgs e) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, e); - } - - - void AddHdmiInBladePorts(uint number, ICec cecPort) - { - AddInputPortWithDebug(number, "hdmiIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat, cecPort); - } - - void AddDmInBladePorts(uint number) - { - AddInputPortWithDebug(number, "dmCIn", eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat); - } - - void AddDmInMmFiberPorts(uint number) - { - AddInputPortWithDebug(number, "dmMmIn", eRoutingSignalType.Video, eRoutingPortConnectionType.DmMmFiber); - } - - void AddDmInSmFiberPorts(uint number) - { - AddInputPortWithDebug(number, "dmSmIn", eRoutingSignalType.Video, eRoutingPortConnectionType.DmSmFiber); - } - - /// - /// - /// - /// - /// - public void AddOutputBlade(string type, uint number) - { - type = type.ToLower(); - - Debug.Console(2, this, "Adding output blade '{0}', slot {1}", type, number); - if (type == "dmb4kohd") - { - var outputBlade = new Dmb4KOHD(number, Chassis); - foreach (var item in outputBlade.Outputs) - { - AddHdmiOutBladePorts(item.Number); - } - } - - else if (type == "dmb4kohddnt") - { - var outputBlade = new Dmb4KOHD(number, Chassis); - foreach (var item in outputBlade.Outputs) - { - AddHdmiOutBladePorts(item.Number); - } - } - - else if (type == "dmb4koc") - { - var outputBlade = new Dmb4KOC(number, Chassis); - foreach (var item in outputBlade.Outputs) - { - AddDmOutBladePorts(item.Number); - } - } - else if (type == "dmb4koc") - { - var outputBlade = new Dmb4KOC(number, Chassis); - foreach (var item in outputBlade.Outputs) - { - AddDmOutBladePorts(item.Number); - } - } - else if (type == "dmbos") - { - var outputBlade = new DmbOS(number, Chassis); - foreach (var item in outputBlade.Outputs) - { - AddDmOutMmFiberBladePorts(item.Number); - } - } - else if (type == "dmbos2") - { - var outputBlade = new DmbOS2(number, Chassis); - foreach (var item in outputBlade.Outputs) - { - AddDmOutSmFiberBladePorts(item.Number); - } - } - } - - void AddHdmiOutBladePorts(uint number) - { - AddOutputPortWithDebug(number, "hdmiOut", eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, Chassis.Outputs[number]); - } - - void AddDmOutBladePorts(uint number) - { - AddOutputPortWithDebug(number, "dmOut", eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat, Chassis.Outputs[number]); - } - - void AddDmOutMmFiberBladePorts(uint number) - { - AddOutputPortWithDebug(number, "dmMmOut", eRoutingSignalType.Video, eRoutingPortConnectionType.DmMmFiber, Chassis.Outputs[number]); - } - - void AddDmOutSmFiberBladePorts(uint number) - { - AddOutputPortWithDebug(number, "dmSmOut", eRoutingSignalType.Video, eRoutingPortConnectionType.DmSmFiber, Chassis.Outputs[number]); - } - - - /// - /// Adds InputPort - /// - void AddInputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType) - { - AddInputPortWithDebug(cardNum, portName, sigType, portType, null); - } - - /// - /// Adds InputPort and sets Port as ICec object - /// - private void AddInputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, - eRoutingPortConnectionType portType, ICec cecPort) - { - var portKey = string.Format("inputCard{0}--{1}", cardNum, portName); - Debug.Console(2, this, "Adding input port '{0}'", portKey); - var inputPort = new RoutingInputPort(portKey, sigType, portType, Chassis.Inputs[cardNum], this) - { - FeedbackMatchObject = Chassis.Inputs[cardNum] - }; - - if (cecPort != null) - inputPort.Port = cecPort; - - InputPorts.Add(inputPort); - } - - - - /*void AddOutputPortWithDebug(string cardName, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, object selector) { - var portKey = string.Format("{0}--{1}", cardName, portName); - Debug.Console(2, this, "Adding output port '{0}'", portKey); - OutputPorts.Add(new RoutingOutputPort(portKey, sigType, portType, selector, this) - { - FeedbackMatchObject = selector - }); - }*/ - - /// - /// Adds OutputPort - /// - void AddOutputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, object selector) - { - try - { - var portKey = string.Format("outputCard{0}--{1}", cardNum, portName); - Debug.Console(2, this, "Adding output port '{0}'", portKey); - var outputPort = new RoutingOutputPort(portKey, sigType, portType, selector, this) - { - FeedbackMatchObject = Chassis.Outputs[cardNum] - }; - OutputPorts.Add(outputPort); - } - catch (Exception ex) - { - Debug.Console(0, this, "Exception : {0}", ex); - } - - } - - - /// - /// - /// - void AddVolumeControl(uint number, Audio.Output audio) - { - VolumeControls.Add(number, new DmCardAudioOutputController(audio)); - } - - //public void SetInputHdcpSupport(uint input, ePdtHdcpSupport hdcpSetting) - //{ - - //} - - - void Chassis_DMInputChange(Switch device, DMInputEventArgs args) - { - - switch (args.EventId) - { - case DMInputEventIds.EndpointOnlineEventId: - { - Debug.Console(2, this, "DM Input EndpointOnlineEventId for input: {0}. State: {1}", args.Number, device.Inputs[args.Number].EndpointOnlineFeedback); - InputEndpointOnlineFeedbacks[args.Number].FireUpdate(); - break; - } - case DMInputEventIds.OnlineFeedbackEventId: - { - Debug.Console(2, this, "DM Input OnlineFeedbackEventId for input: {0}. State: {1}", args.Number, device.Inputs[args.Number].EndpointOnlineFeedback); - InputEndpointOnlineFeedbacks[args.Number].FireUpdate(); - break; - } - case DMInputEventIds.VideoDetectedEventId: - { - Debug.Console(2, this, "DM Input {0} VideoDetectedEventId", args.Number); - VideoInputSyncFeedbacks[args.Number].FireUpdate(); - break; - } - case DMInputEventIds.InputNameEventId: - { - Debug.Console(2, this, "DM Input {0} NameFeedbackEventId", args.Number); - InputNameFeedbacks[args.Number].FireUpdate(); - break; - } - case DMInputEventIds.HdcpCapabilityFeedbackEventId: - { - Debug.Console(2, this, "DM Input {0} HdcpCapabilityFeedbackEventId", args.Number); - InputCardHdcpCapabilityFeedbacks[args.Number].FireUpdate(); - break; - } - default: - { - Debug.Console(2, this, "DMInputChange fired for Input {0} with Unhandled EventId: {1}", args.Number, args.EventId); - break; - } - } - } - - /// - /// - private void Chassis_DMOutputChange(Switch device, DMOutputEventArgs args) - { - var output = args.Number; - - switch (args.EventId) - { - case DMOutputEventIds.VolumeEventId: - { - if (VolumeControls.ContainsKey(output)) - { - VolumeControls[args.Number].VolumeEventFromChassis(); - } - break; - } - case DMOutputEventIds.EndpointOnlineEventId: - { - Debug.Console(2, this, - "Output {0} DMOutputEventIds.EndpointOnlineEventId fired. EndpointOnlineFeedback State: {1}", - args.Number, Chassis.Outputs[output].EndpointOnlineFeedback); - if (Chassis.Outputs[output].Endpoint != null) - Debug.Console(2, this, - "Output {0} DMOutputEventIds.EndpointOnlineEventId fired. Endpoint.IsOnline State: {1}", - args.Number, Chassis.Outputs[output].Endpoint.IsOnline); - - OutputEndpointOnlineFeedbacks[output].FireUpdate(); - break; - } - case DMOutputEventIds.OnlineFeedbackEventId: - { - Debug.Console(2, this, "Output {0} DMInputEventIds.OnlineFeedbackEventId fired. State: {1}", - args.Number, Chassis.Outputs[output].EndpointOnlineFeedback); - OutputEndpointOnlineFeedbacks[output].FireUpdate(); - break; - } - case DMOutputEventIds.VideoOutEventId: - { - - var inputNumber = Chassis.Outputs[output].VideoOutFeedback == null ? 0 : Chassis.Outputs[output].VideoOutFeedback.Number; - - Debug.Console(2, this, "DMSwitchAudioVideo:{0} Routed Input:{1} Output:{2}'", this.Name, - inputNumber, output); - - if (VideoOutputFeedbacks.ContainsKey(output)) - { - var localInputPort = InputPorts.FirstOrDefault(p => (DMInput)p.FeedbackMatchObject == Chassis.Outputs[output].VideoOutFeedback); - var localOutputPort = - OutputPorts.FirstOrDefault(p => (DMOutput)p.FeedbackMatchObject == Chassis.Outputs[output]); - - - VideoOutputFeedbacks[output].FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(output, - inputNumber, - localOutputPort, - localInputPort, - eRoutingSignalType.AudioVideo)); - - } - if (OutputVideoRouteNameFeedbacks.ContainsKey(output)) - { - OutputVideoRouteNameFeedbacks[output].FireUpdate(); - } - break; - } - case DMOutputEventIds.OutputNameEventId: - { - Debug.Console(2, this, "DM Output {0} NameFeedbackEventId", output); - OutputNameFeedbacks[output].FireUpdate(); - break; - } - default: - { - Debug.Console(2, this, "DMOutputChange fired for Output {0} with Unhandled EventId: {1}", - args.Number, args.EventId); - break; - } - } - - } - - - /// - /// - /// - /// - void StartOffTimer(PortNumberType pnt) - { - if (RouteOffTimers.ContainsKey(pnt)) - return; - RouteOffTimers[pnt] = new CTimer(o => ExecuteSwitch(null, pnt.Selector, pnt.Type), RouteOffTime); - } - - - // Send out sigs when coming online - void IsOnline_OutputChange(object sender, EventArgs e) - { - if (IsOnline.BoolValue) - { - Chassis.EnableUSBBreakaway.BoolValue = true; - - if (InputNames != null) - foreach (var kvp in InputNames) - Chassis.Inputs[kvp.Key].Name.StringValue = kvp.Value; - if (OutputNames != null) - foreach (var kvp in OutputNames) - Chassis.Outputs[kvp.Key].Name.StringValue = kvp.Value; - } - } - - #region IRouting Members - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType sigType) - { - Debug.Console(2, this, "Making an awesome DM route from {0} to {1} {2}", inputSelector, outputSelector, sigType); - - var input = inputSelector as DMInput; // Cast can sometimes fail - var output = outputSelector as DMOutput; - - - if (output == null) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Warning, - "Unable to execute switch for inputSelector {0} to outputSelector {1}", inputSelector, - outputSelector); - return; - } - - // Check to see if there's an off timer waiting on this and if so, cancel - var key = new PortNumberType(output, sigType); - - if (input == null) - { - StartOffTimer(key); - } - else - { - if (RouteOffTimers.ContainsKey(key)) - { - Debug.Console(2, this, "{0} cancelling route off due to new source", output); - RouteOffTimers[key].Stop(); - RouteOffTimers.Remove(key); - } - } - - - - /*var inCard = input == 0 ? null : Chassis.Inputs[input]; - var outCard = input == 0 ? null : Chassis.Outputs[output];*/ - - // NOTE THAT BITWISE COMPARISONS - TO CATCH ALL ROUTING TYPES - if ((sigType & eRoutingSignalType.Video) != eRoutingSignalType.Video) return; - Chassis.VideoEnter.BoolValue = true; - output.VideoOut = input; - } - - #endregion - - #region IRoutingNumeric Members - - public void ExecuteNumericSwitch(ushort inputSelector, ushort outputSelector, eRoutingSignalType sigType) - { - var input = inputSelector == 0 ? null : Chassis.Inputs[inputSelector]; - var output = Chassis.Outputs[outputSelector]; - - ExecuteSwitch(input, output, sigType); - } - - #endregion - - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new DmBladeChassisControllerJoinMap(joinStart); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - - Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - - IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - - // Link up outputs - for (uint i = 1; i <= Chassis.NumberOfOutputs; i++) - { - var ioSlot = i; - var ioSlotJoin = ioSlot - 1; - - // Control - trilist.SetUShortSigAction(joinMap.OutputVideo.JoinNumber + ioSlotJoin, o => ExecuteNumericSwitch(o, (ushort)ioSlot, eRoutingSignalType.Video)); - - if (TxDictionary.ContainsKey(ioSlot)) - { - Debug.Console(2, "Creating Tx Feedbacks {0}", ioSlot); - var txKey = TxDictionary[ioSlot]; - var basicTxDevice = DeviceManager.GetDeviceForKey(txKey) as BasicDmTxControllerBase; - - var advancedTxDevice = basicTxDevice as DmTxControllerBase; - - if (Chassis is DmMd128x128 || Chassis is DmMd64x64) - { - InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline.JoinNumber + ioSlotJoin]); - } - else - { - if (advancedTxDevice != null) - { - advancedTxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline.JoinNumber + ioSlotJoin]); - Debug.Console(2, "Linking Tx Online Feedback from Advanced Transmitter at input {0}", ioSlot); - } - else if (InputEndpointOnlineFeedbacks[ioSlot] != null) - { - Debug.Console(2, "Linking Tx Online Feedback from Input Card {0}", ioSlot); - InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline.JoinNumber + ioSlotJoin]); - } - } - - if (basicTxDevice != null && advancedTxDevice == null) - trilist.BooleanInput[joinMap.TxAdvancedIsPresent.JoinNumber + ioSlotJoin].BoolValue = true; - - if (advancedTxDevice != null) - { - advancedTxDevice.AnyVideoInput.VideoStatus.VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus.JoinNumber + ioSlotJoin]); - } - else - { - Debug.Console(1, "Setting up actions and feedbacks on input card {0}", ioSlot); - VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus.JoinNumber + ioSlotJoin]); - - var inputPort = InputPorts[string.Format("inputCard{0}--hdmiIn", ioSlot)]; - if (inputPort != null) - { - Debug.Console(1, "Port value for input card {0} is set", ioSlot); - var port = inputPort.Port; - - if (port != null) - { - if (port is HdmiInputWithCEC) - { - Debug.Console(1, "Port is HdmiInputWithCec"); - - var hdmiInPortWCec = port as HdmiInputWithCEC; - - if (hdmiInPortWCec.HdcpSupportedLevel != eHdcpSupportedLevel.Unknown) - { - SetHdcpStateAction(true, hdmiInPortWCec, joinMap.HdcpSupportState.JoinNumber + ioSlotJoin, trilist); - } - - InputCardHdcpCapabilityFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.HdcpSupportState.JoinNumber + ioSlotJoin]); - - if (InputCardHdcpCapabilityTypes.ContainsKey(ioSlot)) - trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber + ioSlotJoin].UShortValue = (ushort)InputCardHdcpCapabilityTypes[ioSlot]; - else - trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber + ioSlotJoin].UShortValue = 1; - } - } - } - else - { - inputPort = InputPorts[string.Format("inputCard{0}--dmIn", ioSlot)]; - - if (inputPort != null) - { - var port = inputPort.Port; - - if (port is DMInputPortWithCec) - { - Debug.Console(1, "Port is DMInputPortWithCec"); - - var dmInPortWCec = port as DMInputPortWithCec; - - SetHdcpStateAction(PropertiesConfig.InputSlotSupportsHdcp2[ioSlot], dmInPortWCec, joinMap.HdcpSupportState.JoinNumber + ioSlotJoin, trilist); - - InputCardHdcpCapabilityFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.HdcpSupportState.JoinNumber + ioSlotJoin]); - - if (InputCardHdcpCapabilityTypes.ContainsKey(ioSlot)) - trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber + ioSlotJoin].UShortValue = (ushort)InputCardHdcpCapabilityTypes[ioSlot]; - else - trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber + ioSlotJoin].UShortValue = 1; - } - } - } - } - } - else - { - VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus.JoinNumber + ioSlotJoin]); - - var inputPort = InputPorts[string.Format("inputCard{0}--hdmiIn", ioSlot)]; - if (inputPort != null) - { - var hdmiPort = inputPort.Port as EndpointHdmiInput; - - if (hdmiPort != null) - { - SetHdcpStateAction(true, hdmiPort, joinMap.HdcpSupportState.JoinNumber + ioSlotJoin, trilist); - InputCardHdcpCapabilityFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.HdcpSupportState.JoinNumber + ioSlotJoin]); - } - } - } - if (RxDictionary.ContainsKey(ioSlot)) - { - Debug.Console(2, "Creating Rx Feedbacks {0}", ioSlot); - //var rxKey = RxDictionary[ioSlot]; - //var rxDevice = DeviceManager.GetDeviceForKey(rxKey) as DmRmcControllerBase; - //var hdBaseTDevice = DeviceManager.GetDeviceForKey(rxKey) as DmHdBaseTControllerBase; - //if (hdBaseTDevice != null) { - OutputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline.JoinNumber + ioSlotJoin]); - //} - //else if (rxDevice != null) { - // rxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]); - //} - } - - // Feedback - VideoOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputVideo.JoinNumber + ioSlotJoin]); - - - OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputNames.JoinNumber + ioSlotJoin]); - InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputNames.JoinNumber + ioSlotJoin]); - OutputVideoRouteNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentVideoInputNames.JoinNumber + ioSlotJoin]); - } - } - - private void SetHdcpStateAction(bool hdcpTypeSimple, HdmiInputWithCEC port, uint join, BasicTriList trilist) - { - if (hdcpTypeSimple) - { - trilist.SetUShortSigAction(join, - s => - { - if (s == 0) - { - port.HdcpSupportOff(); - } - else if (s > 0) - { - port.HdcpSupportOn(); - } - }); - } - else - { - trilist.SetUShortSigAction(join, - u => - { - port.HdcpReceiveCapability = (eHdcpCapabilityType)u; - }); - } - } - - private void SetHdcpStateAction(bool hdcpTypeSimple, EndpointHdmiInput port, uint join, BasicTriList trilist) - { - if (hdcpTypeSimple) - { - trilist.SetUShortSigAction(join, - s => - { - if (s == 0) - { - port.HdcpSupportOff(); - } - else if (s > 0) - { - port.HdcpSupportOn(); - } - }); - } - else - { - trilist.SetUShortSigAction(join, - u => - { - port.HdcpCapability = (eHdcpCapabilityType)u; - }); - } - } - - private void SetHdcpStateAction(bool supportsHdcp2, DMInputPortWithCec port, uint join, BasicTriList trilist) - { - if (!supportsHdcp2) - { - trilist.SetUShortSigAction(join, - s => - { - if (s == 0) - { - port.HdcpSupportOff(); - } - else if (s > 0) - { - port.HdcpSupportOn(); - } - }); - } - else - { - trilist.SetUShortSigAction(join, - u => - { - port.HdcpReceiveCapability = (eHdcpCapabilityType)u; - }); - } - } - - } - - /* - public struct PortNumberType { - public uint Number { get; private set; } - public eRoutingSignalType Type { get; private set; } - - public PortNumberType(uint number, eRoutingSignalType type) - : this() { - Number = number; - Type = type; - } - }*/ -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Chassis/DmCardAudioOutput.cs b/src/PepperDash.Essentials.DM/Chassis/DmCardAudioOutput.cs deleted file mode 100644 index 4b4a927e..00000000 --- a/src/PepperDash.Essentials.DM/Chassis/DmCardAudioOutput.cs +++ /dev/null @@ -1,116 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.DM; - -using PepperDash.Core; -using PepperDash.Essentials.Core; - -namespace PepperDash.Essentials.DM -{ - public class DmCardAudioOutputController : IBasicVolumeWithFeedback - { - public Audio.Output Output { get; private set; } - - public IntFeedback VolumeLevelFeedback { get; private set; } - - public BoolFeedback MuteFeedback { get; private set; } - - ushort PreMuteVolumeLevel; - bool IsMuted; - - public DmCardAudioOutputController(Audio.Output output) - { - Output = output; - VolumeLevelFeedback = new IntFeedback(() => Output.VolumeFeedback.UShortValue); - MuteFeedback = new BoolFeedback(() => IsMuted); - } - - #region IBasicVolumeWithFeedback Members - - /// - /// - /// - public void MuteOff() - { - SetVolume(PreMuteVolumeLevel); - IsMuted = false; - MuteFeedback.FireUpdate(); - } - - /// - /// - /// - public void MuteOn() - { - PreMuteVolumeLevel = Output.VolumeFeedback.UShortValue; - SetVolume(0); - IsMuted = true; - MuteFeedback.FireUpdate(); - } - - /// - /// - /// - public void SetVolume(ushort level) - { - Debug.Console(2, "Set volume out {0}", level); - Output.Volume.UShortValue = level; - } - - /// - /// - /// - internal void VolumeEventFromChassis() - { - VolumeLevelFeedback.FireUpdate(); - } - - #endregion - - #region IBasicVolumeControls Members - - /// - /// - /// - public void MuteToggle() - { - if (IsMuted) - MuteOff(); - else - MuteOn(); - } - - /// - /// - /// - public void VolumeDown(bool pressRelease) - { - if (pressRelease) - { - var remainingRatio = Output.Volume.UShortValue / 65535; - Output.Volume.CreateRamp(0, (uint)(400 * remainingRatio)); - } - else - Output.Volume.StopRamp(); - } - - /// - /// - /// - public void VolumeUp(bool pressRelease) - { - if (pressRelease) - { - var remainingRatio = (65535 - Output.Volume.UShortValue) / 65535; - Output.Volume.CreateRamp(65535, 400); - } - else - Output.Volume.StopRamp(); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Chassis/DmChassisController.cs b/src/PepperDash.Essentials.DM/Chassis/DmChassisController.cs deleted file mode 100644 index e5690166..00000000 --- a/src/PepperDash.Essentials.DM/Chassis/DmChassisController.cs +++ /dev/null @@ -1,2128 +0,0 @@ -extern alias Full; - -using System; -using System.Collections.Generic; -using System.Linq; -using Crestron.SimplSharp; -using Crestron.SimplSharp.Reflection; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Cards; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpProInternal; -using Full.Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.DM.Config; -using PepperDash.Essentials.Core.Config; - -namespace PepperDash.Essentials.DM -{ - /// - /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions - /// - /// - [Description("Wrapper class for all DM-MD chassis variants from 8x8 to 32x32")] - public class DmChassisController : CrestronGenericBridgeableBaseDevice, IDmSwitch, IRoutingNumericWithFeedback - { - private const string NonePortKey = "inputCard0--None"; - public DMChassisPropertiesConfig PropertiesConfig { get; set; } - - public Switch Chassis { get; private set; } - - //IroutingNumericEvent - public event EventHandler NumericSwitchChange; - - // Feedbacks for EssentialDM - public Dictionary VideoOutputFeedbacks { get; private set; } - public Dictionary AudioOutputFeedbacks { get; private set; } - public Dictionary VideoInputSyncFeedbacks { get; private set; } - public Dictionary InputEndpointOnlineFeedbacks { get; private set; } - public Dictionary OutputEndpointOnlineFeedbacks { get; private set; } - public Dictionary InputNameFeedbacks { get; private set; } - public Dictionary OutputNameFeedbacks { get; private set; } - public Dictionary OutputVideoRouteNameFeedbacks { get; private set; } - public Dictionary OutputAudioRouteNameFeedbacks { get; private set; } - public Dictionary UsbOutputRoutedToFeebacks { get; private set; } - public Dictionary UsbInputRoutedToFeebacks { get; private set; } - public Dictionary OutputDisabledByHdcpFeedbacks { get; private set; } - - public IntFeedback SystemIdFeebdack { get; private set; } - public BoolFeedback SystemIdBusyFeedback { get; private set; } - public BoolFeedback EnableAudioBreakawayFeedback { get; private set; } - public BoolFeedback EnableUsbBreakawayFeedback { get; private set; } - - public Dictionary InputCardHdcpStateFeedbacks { get; private set; } - public Dictionary InputStreamCardStateFeedbacks { get; private set; } - public Dictionary OutputStreamCardStateFeedbacks { get; private set; } - - public Dictionary InputCardHdcpCapabilityTypes { get; private set; } - - // Need a couple Lists of generic Backplane ports - public RoutingPortCollection InputPorts { get; private set; } - public RoutingPortCollection OutputPorts { get; private set; } - - public Dictionary TxDictionary { get; set; } - public Dictionary RxDictionary { get; set; } - - //public Dictionary InputCards { get; private set; } - //public Dictionary OutputCards { get; private set; } - - public Dictionary InputNames { get; set; } - public Dictionary OutputNames { get; set; } - public Dictionary VolumeControls { get; private set; } - - public const int RouteOffTime = 500; - Dictionary RouteOffTimers = new Dictionary(); - - /// - /// Text that represents when an output has no source routed to it - /// - public string NoRouteText = ""; - - /// - /// Factory method to create a new chassis controller from config data. Limited to 8x8 right now - /// - public static DmChassisController GetDmChassisController(string key, string name, - string type, DMChassisPropertiesConfig properties) - { - try - { - type = type.ToLower(); - uint ipid = properties.Control.IpIdInt; - - DmMDMnxn chassis = null; - switch (type) { - case "dmmd8x8": - chassis = new DmMd8x8(ipid, Global.ControlSystem); - break; - case "dmmd8x8rps": - chassis = new DmMd8x8rps(ipid, Global.ControlSystem); - break; - case "dmmd8x8cpu3": - chassis = new DmMd8x8Cpu3(ipid, Global.ControlSystem); - break; - case "dmmd8x8cpu3rps": - chassis = new DmMd8x8Cpu3rps(ipid, Global.ControlSystem); - break; - case "dmmd16x16": - chassis = new DmMd16x16(ipid, Global.ControlSystem); - break; - case "dmmd16x16rps": - chassis = new DmMd16x16rps(ipid, Global.ControlSystem); - break; - case "dmmd16x16cpu3": - chassis = new DmMd16x16Cpu3(ipid, Global.ControlSystem); - break; - case "dmmd16x16cpu3rps": - chassis = new DmMd16x16Cpu3rps(ipid, Global.ControlSystem); - break; - case "dmmd32x32": - chassis = new DmMd32x32(ipid, Global.ControlSystem); - break; - case "dmmd32x32rps": - chassis = new DmMd32x32rps(ipid, Global.ControlSystem); - break; - case "dmmd32x32cpu3": - chassis = new DmMd32x32Cpu3(ipid, Global.ControlSystem); - break; - case "dmmd32x32cpu3rps": - chassis = new DmMd32x32Cpu3rps(ipid, Global.ControlSystem); - break; - } - - if (chassis == null) - return null; - - var controller = new DmChassisController(key, name, chassis); - - // - var clearInputPort = new RoutingInputPort(NonePortKey, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.None, null, controller); - - controller.InputPorts.Add(clearInputPort); - - // add the cards and port names - foreach (var kvp in properties.InputSlots) - controller.AddInputCard(kvp.Value, kvp.Key); - - foreach (var kvp in properties.OutputSlots) - controller.AddOutputCard(kvp.Value, kvp.Key); - - foreach (var kvp in properties.VolumeControls) - { - // get the card - // check it for an audio-compatible type - // make a something-something that will make it work - // retire to mountain village - var outNum = kvp.Key; - var card = controller.Chassis.Outputs[outNum].Card; - Audio.Output audio = null; - if (card is DmcHdo) - audio = (card as DmcHdo).Audio; - else if (card is Dmc4kHdo) - audio = (card as Dmc4kHdo).Audio; - if (audio == null) - continue; - - // wire up the audio to something here... - controller.AddVolumeControl(outNum, audio); - } - - controller.InputNames = properties.InputNames; - controller.OutputNames = properties.OutputNames; - - if (!string.IsNullOrEmpty(properties.NoRouteText)) - { - controller.NoRouteText = properties.NoRouteText; - Debug.Console(1, controller, "Setting No Route Text value to: {0}", controller.NoRouteText); - } - else - { - Debug.Console(1, controller, "NoRouteText not specified. Defaulting to blank string.", controller.NoRouteText); - } - - controller.PropertiesConfig = properties; - return controller; - } - catch (Exception e) - { - Debug.Console(0, "Error creating DM chassis:\r{0}", e); - } - - return null; - } - - /// - /// - /// - /// - /// - /// - public DmChassisController(string key, string name, DmMDMnxn chassis) - : base(key, name, chassis) - { - - Chassis = chassis; - InputPorts = new RoutingPortCollection(); - OutputPorts = new RoutingPortCollection(); - VolumeControls = new Dictionary(); - TxDictionary = new Dictionary(); - RxDictionary = new Dictionary(); - IsOnline.OutputChange += new EventHandler(IsOnline_OutputChange); - Chassis.DMInputChange += new DMInputEventHandler(Chassis_DMInputChange); - Chassis.DMSystemChange += new DMSystemEventHandler(Chassis_DMSystemChange); - Chassis.DMOutputChange += new DMOutputEventHandler(Chassis_DMOutputChange); - Chassis.BaseEvent += ChassisOnBaseEvent; - VideoOutputFeedbacks = new Dictionary(); - AudioOutputFeedbacks = new Dictionary(); - UsbOutputRoutedToFeebacks = new Dictionary(); - UsbInputRoutedToFeebacks = new Dictionary(); - OutputDisabledByHdcpFeedbacks = new Dictionary(); - VideoInputSyncFeedbacks = new Dictionary(); - InputNameFeedbacks = new Dictionary(); - OutputNameFeedbacks = new Dictionary(); - OutputVideoRouteNameFeedbacks = new Dictionary(); - OutputAudioRouteNameFeedbacks = new Dictionary(); - InputEndpointOnlineFeedbacks = new Dictionary(); - OutputEndpointOnlineFeedbacks = new Dictionary(); - - SystemIdFeebdack = new IntFeedback(() => { return (Chassis as DmMDMnxn).SystemIdFeedback.UShortValue; }); - SystemIdBusyFeedback = new BoolFeedback(() => { return (Chassis as DmMDMnxn).SystemIdBusy.BoolValue; }); - EnableAudioBreakawayFeedback = - new BoolFeedback(() => (Chassis as DmMDMnxn).EnableAudioBreakawayFeedback.BoolValue); - EnableUsbBreakawayFeedback = - new BoolFeedback(() => (Chassis as DmMDMnxn).EnableUSBBreakawayFeedback.BoolValue); - - InputCardHdcpStateFeedbacks = new Dictionary(); - InputStreamCardStateFeedbacks = new Dictionary(); - OutputStreamCardStateFeedbacks = new Dictionary(); - InputCardHdcpCapabilityTypes = new Dictionary(); - - for (uint x = 1; x <= Chassis.NumberOfOutputs; x++) - { - var tempX = x; - - if (Chassis.Outputs[tempX] != null) - { - VideoOutputFeedbacks[tempX] = new IntFeedback(() => { - if (Chassis.Outputs[tempX].VideoOutFeedback != null) - return (ushort)Chassis.Outputs[tempX].VideoOutFeedback.Number; - - return 0; - }); - AudioOutputFeedbacks[tempX] = new IntFeedback(() => { - if (Chassis.Outputs[tempX].AudioOutFeedback != null) - return (ushort)Chassis.Outputs[tempX].AudioOutFeedback.Number; - - return 0; - }); - UsbOutputRoutedToFeebacks[tempX] = new IntFeedback(() => { - if (Chassis.Outputs[tempX].USBRoutedToFeedback != null) - return (ushort)Chassis.Outputs[tempX].USBRoutedToFeedback.Number; - - return 0; - }); - - OutputNameFeedbacks[tempX] = new StringFeedback(() => { - if (Chassis.Outputs[tempX].NameFeedback != null) - return Chassis.Outputs[tempX].NameFeedback.StringValue; - - return ""; - }); - OutputVideoRouteNameFeedbacks[tempX] = new StringFeedback(() => { - if (Chassis.Outputs[tempX].VideoOutFeedback != null) - return Chassis.Outputs[tempX].VideoOutFeedback.NameFeedback.StringValue; - - return NoRouteText; - }); - OutputAudioRouteNameFeedbacks[tempX] = new StringFeedback(() => { - if (Chassis.Outputs[tempX].AudioOutFeedback != null) - return Chassis.Outputs[tempX].AudioOutFeedback.NameFeedback.StringValue; - - return NoRouteText; - }); - OutputEndpointOnlineFeedbacks[tempX] = new BoolFeedback(() => Chassis.Outputs[tempX].EndpointOnlineFeedback); - - OutputDisabledByHdcpFeedbacks[tempX] = new BoolFeedback(() => { - var output = Chassis.Outputs[tempX]; - - var hdmiTxOutput = output as Card.HdmiTx; - if (hdmiTxOutput != null) - return hdmiTxOutput.HdmiOutput.DisabledByHdcp.BoolValue; - - var dmHdmiOutput = output as Card.DmHdmiOutput; - if (dmHdmiOutput != null) - return dmHdmiOutput.DisabledByHdcpFeedback.BoolValue; - - var dmsDmOutAdvanced = output as Card.DmsDmOutAdvanced; - if (dmsDmOutAdvanced != null) - return dmsDmOutAdvanced.DisabledByHdcpFeedback.BoolValue; - - var dmps3HdmiAudioOutput = output as Card.Dmps3HdmiAudioOutput; - if (dmps3HdmiAudioOutput != null) - return dmps3HdmiAudioOutput.HdmiOutputPort.DisabledByHdcpFeedback.BoolValue; - - var dmps3HdmiOutput = output as Card.Dmps3HdmiOutput; - if (dmps3HdmiOutput != null) - return dmps3HdmiOutput.HdmiOutputPort.DisabledByHdcpFeedback.BoolValue; - - var dmps3HdmiOutputBackend = output as Card.Dmps3HdmiOutputBackend; - if (dmps3HdmiOutputBackend != null) - return dmps3HdmiOutputBackend.HdmiOutputPort.DisabledByHdcpFeedback.BoolValue; - - // var hdRx4kX10HdmiOutput = output as HdRx4kX10HdmiOutput; - // if (hdRx4kX10HdmiOutput != null) - // return hdRx4kX10HdmiOutput.HdmiOutputPort.DisabledByHdcpFeedback.BoolValue; - - // var hdMdNxMHdmiOutput = output as HdMdNxMHdmiOutput; - // if (hdMdNxMHdmiOutput != null) - // return hdMdNxMHdmiOutput.HdmiOutputPort.DisabledByHdcpFeedback.BoolValue; - - return false; - }); - OutputStreamCardStateFeedbacks[tempX] = new IntFeedback(() => - { - try - { - var outputCard = Chassis.Outputs[tempX]; - - if (outputCard.Card is DmcStroAV) - { - Debug.Console(2, "Found output stream card in slot: {0}.", tempX); - var streamCard = outputCard.Card as DmcStroAV; - if (streamCard.Control.StartFeedback.BoolValue == true) - return 1; - else if (streamCard.Control.StopFeedback.BoolValue == true) - return 2; - else if (streamCard.Control.PauseFeedback.BoolValue == true) - return 3; - else - return 0; - } - return 0; - } - catch (InvalidOperationException iopex) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Warning, "Error adding output stream card in slot: {0}. Error: {1}", tempX, iopex); - return 0; - } - }); - } - - if (Chassis.Inputs[tempX] != null) - { - UsbInputRoutedToFeebacks[tempX] = new IntFeedback(() => { - if (Chassis.Inputs[tempX].USBRoutedToFeedback != null) - return (ushort)Chassis.Inputs[tempX].USBRoutedToFeedback.Number; - - return 0; - }); - VideoInputSyncFeedbacks[tempX] = new BoolFeedback(() => { - if (Chassis.Inputs[tempX].VideoDetectedFeedback != null) - return Chassis.Inputs[tempX].VideoDetectedFeedback.BoolValue; - - return false; - }); - InputNameFeedbacks[tempX] = new StringFeedback(() => { - if (Chassis.Inputs[tempX].NameFeedback != null) - return Chassis.Inputs[tempX].NameFeedback.StringValue; - - return ""; - }); - - InputEndpointOnlineFeedbacks[tempX] = new BoolFeedback(() => { return Chassis.Inputs[tempX].EndpointOnlineFeedback; }); - - InputCardHdcpStateFeedbacks[tempX] = new IntFeedback(() => { - try - { - var inputCard = Chassis.Inputs[tempX]; - - if (inputCard.Card is DmcHd) - { - InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.HdcpAutoSupport; - - if ((inputCard.Card as DmcHd).HdmiInput.HdcpSupportOnFeedback.BoolValue) - return 1; - return 0; - } - - if (inputCard.Card is DmcHdDsp) - { - InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.HdcpAutoSupport; - - if ((inputCard.Card as DmcHdDsp).HdmiInput.HdcpSupportOnFeedback.BoolValue) - return 1; - return 0; - } - if (inputCard.Card is Dmc4kHdBase) - { - InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.Hdcp2_2Support; - return (int)(inputCard.Card as Dmc4kHdBase).HdmiInput.HdcpReceiveCapability; - } - if (inputCard.Card is Dmc4kHdDspBase) - { - if (PropertiesConfig.InputSlotSupportsHdcp2[tempX]) - { - InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.Hdcp2_2Support; - return (int)(inputCard.Card as Dmc4kHdDspBase).HdmiInput.HdcpReceiveCapability; - } - - InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.HdcpAutoSupport; - if ((inputCard.Card as Dmc4kHdDspBase).HdmiInput.HdcpSupportOnFeedback.BoolValue) - return 1; - return 0; - } - - if (inputCard.Card is Dmc4kCBase) - { - if (PropertiesConfig.InputSlotSupportsHdcp2[tempX]) - { - InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.HdcpAutoSupport; - return (int)(inputCard.Card as Dmc4kCBase).DmInput.HdcpReceiveCapability; - } - - if ((inputCard.Card as Dmc4kCBase).DmInput.HdcpSupportOnFeedback.BoolValue) - return 1; - return 0; - } - if (inputCard.Card is Dmc4kCDspBase) - { - if (PropertiesConfig.InputSlotSupportsHdcp2[tempX]) - { - InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.HdcpAutoSupport; - return (int)(inputCard.Card as Dmc4kCDspBase).DmInput.HdcpReceiveCapability; - } - - if ((inputCard.Card as Dmc4kCDspBase).DmInput.HdcpSupportOnFeedback.BoolValue) - return 1; - - return 0; - } - return 0; - } - catch (InvalidOperationException iopex) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Warning, "The Input Card in slot: {0} supports HDCP 2. Please update the configuration value in the inputCardSupportsHdcp2 object to true. Error: {1}", tempX, iopex); - return 0; - } - }); - InputStreamCardStateFeedbacks[tempX] = new IntFeedback(() => - { - try - { - var inputCard = Chassis.Inputs[tempX]; - - if (inputCard.Card is DmcStr) - { - Debug.Console(2, "Found input stream card in slot: {0}.", tempX); - var streamCard = inputCard.Card as DmcStr; - if (streamCard.Control.StartFeedback.BoolValue == true) - return 1; - else if (streamCard.Control.StopFeedback.BoolValue == true) - return 2; - else if (streamCard.Control.PauseFeedback.BoolValue == true) - return 3; - else - return 0; - } - return 0; - } - catch (InvalidOperationException iopex) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Warning, "Error adding input stream card in slot: {0}. Error: {1}", tempX, iopex); - return 0; - } - }); - } - } - } - - private void ChassisOnBaseEvent(GenericBase device, BaseEventArgs args) - { - - } - - private void RegisterForInputResolutionFeedback(IVideoAttributesBasic input, uint number, RoutingInputPortWithVideoStatuses inputPort) - { - if (input == null) - { - return; - } - - Debug.Console(1, this, "Registering for resolution feedback for input {0} using Routing Port {1}", number, inputPort.Key); - - input.VideoAttributes.AttributeChange += (sender, args) => - { - Debug.Console(1, this, "Input {0} resolution updated", number); - - Debug.Console(1, this, "Updating resolution feedback for input {0}", number); - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - }; - } - - /// - /// - /// - /// - /// - public void AddInputCard(string type, uint number) - { - Debug.Console(2, this, "Adding input card '{0}', slot {1}", type, number); - - type = type.ToLower(); - - switch (type) - { - case "dmchd": - { - var inputCard = new DmcHd(number, Chassis); - AddHdmiInCardPorts(number, inputCard.HdmiInput, inputCard.HdmiInput); - } - break; - case "dmchddsp": - { - var inputCard = new DmcHdDsp(number, Chassis); - AddHdmiInCardPorts(number, inputCard.HdmiInput, inputCard.HdmiInput); - } - break; - case "dmc4khd": - { - var inputCard = new Dmc4kHd(number, Chassis); - AddHdmiInCardPorts(number, inputCard.HdmiInput, inputCard.HdmiInput); - } - break; - case "dmc4khddsp": - { - var inputCard = new Dmc4kHdDsp(number, Chassis); - AddHdmiInCardPorts(number, inputCard.HdmiInput, inputCard.HdmiInput); - } - break; - case "dmc4kzhd": - { - var inputCard = new Dmc4kzHd(number, Chassis); - AddHdmiInCardPorts(number, inputCard.HdmiInput, inputCard.HdmiInput); - break; - } - case "dmc4kzhddsp": - { - var inputCard = new Dmc4kzHdDsp(number, Chassis); - AddHdmiInCardPorts(number, inputCard.HdmiInput, inputCard.HdmiInput); - break; - } - case "dmcc": - { - var inputCard = new DmcC(number, Chassis); - //DmInput doesn't implement ICec...cast was resulting in null anyway - AddDmInCardPorts(number, null, inputCard.DmInput); - } - break; - case "dmccdsp": - { - var inputCard = new DmcCDsp(number, Chassis); - //DmInput doesn't implement ICec...cast was resulting in null anyway - AddDmInCardPorts(number, null, inputCard.DmInput); - break; - } - - case "dmc4kc": - { - var inputCard = new Dmc4kC(number, Chassis); - AddDmInCardPorts(number, inputCard.DmInput,inputCard.DmInput); - break; - } - - case "dmc4kcdsp": - { - var inputCard = new Dmc4kCDsp(number, Chassis); - AddDmInCardPorts(number, inputCard.DmInput,inputCard.DmInput); - break; - } - - case "dmc4kzc": - { - var inputCard = new Dmc4kzC(number, Chassis); - AddDmInCardPorts(number, inputCard.DmInput,inputCard.DmInput); - break; - } - - case "dmc4kzcdsp": - { - var inputCard = new Dmc4kzCDsp(number, Chassis); - AddDmInCardPorts(number, inputCard.DmInput, inputCard.DmInput); - break; - } - - case "dmccat": - { - var inputCard = new DmcCat(number, Chassis); - AddDmInCardPorts(number, null, inputCard.DmInput); - break; - } - case "dmccatdsp": - { - var inputCard = new DmcCatDsp(number, Chassis); - AddDmInCardPorts(number, null, inputCard.DmInput); - break; - } - case "dmcs": - { - var inputCard = new DmcS(number, Chassis); - AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmMmFiber, null, inputCard.DmInput); - AddInCardHdmiAndAudioLoopPorts(number); - break; - } - case "dmcsdsp": - { - var inputCard = new DmcSDsp(number, Chassis); - AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmMmFiber, null, inputCard.DmInput); - AddInCardHdmiAndAudioLoopPorts(number); - break; - } - case "dmcs2": - { - var inputCard = new DmcS2(number, Chassis); - AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmSmFiber, null, inputCard.DmInput); - AddInCardHdmiAndAudioLoopPorts(number); - break; - } - case "dmcs2dsp": - { - var inputCard = new DmcS2Dsp(number, Chassis); - AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmSmFiber, null, inputCard.DmInput); - AddInCardHdmiAndAudioLoopPorts(number); - break; - } - case "dmcsdi": - { - var inputCard = new DmcSdi(number, Chassis); - AddInputPortWithDebug(number, "sdiIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Sdi, null, inputCard.SdiInput); - AddOutputPortWithDebug(string.Format("inputCard{0}", number), "sdiOut", eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Sdi, null); - AddInCardHdmiAndAudioLoopPorts(number); - break; - } - case "dmcdvi": - { - var inputCard = new DmcDvi(number, Chassis); - AddInputPortWithDebug(number, "dviIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Dvi, null, inputCard.DviInput); - AddInputPortWithDebug(number, "audioIn", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio); - AddInCardHdmiLoopPort(number); - break; - } - case "dmcvga": - { - var inputCard = new DmcVga(number, Chassis); - AddInputPortWithDebug(number, "vgaIn", eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, null, inputCard.VgaInput); - AddInputPortWithDebug(number, "audioIn", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio); - AddInCardHdmiLoopPort(number); - break; - } - case "dmcvidbnc": - { - var inputCard = new DmcVidBnc(number, Chassis); - AddInputPortWithDebug(number, "componentIn", eRoutingSignalType.Video, eRoutingPortConnectionType.Component, null, inputCard.VideoInput); - AddInputPortWithDebug(number, "audioIn", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio); - AddInCardHdmiLoopPort(number); - break; - } - case "dmcvidrcaa": - { - var inputCard = new DmcVidRcaA(number, Chassis); - AddInputPortWithDebug(number, "componentIn", eRoutingSignalType.Video, eRoutingPortConnectionType.Component, null, inputCard.VideoInput); - AddInputPortWithDebug(number, "audioIn", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio); - AddInCardHdmiLoopPort(number); - break; - } - case "dmcvidrcad": - { - var inputCard = new DmcVidRcaD(number, Chassis); - AddInputPortWithDebug(number, "componentIn", eRoutingSignalType.Video, eRoutingPortConnectionType.Component, null, inputCard.VideoInput); - AddInputPortWithDebug(number, "audioIn", eRoutingSignalType.Audio, eRoutingPortConnectionType.DigitalAudio); - AddInCardHdmiLoopPort(number); - break; - } - case "dmcvid4": - { - var inputCard = new DmcVid4(number, Chassis); - AddInputPortWithDebug(number, "compositeIn1", eRoutingSignalType.Video, eRoutingPortConnectionType.Composite); - AddInputPortWithDebug(number, "compositeIn2", eRoutingSignalType.Video, eRoutingPortConnectionType.Composite); - AddInputPortWithDebug(number, "compositeIn3", eRoutingSignalType.Video, eRoutingPortConnectionType.Composite); - AddInputPortWithDebug(number, "compositeIn4", eRoutingSignalType.Video, eRoutingPortConnectionType.Composite); - AddInCardHdmiLoopPort(number); - break; - } - case "dmcstr": - { - var inputCard = new DmcStr(number, Chassis); - AddInputPortWithDebug(number, "streamIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Streaming, null, inputCard.Source); - AddInCardHdmiAndAudioLoopPorts(number); - break; - } - } - } - - void AddDmInCardPorts(uint number) - { - AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat); - AddInCardHdmiAndAudioLoopPorts(number); - } - - void AddDmInCardPorts(uint number, ICec cecPort) - { - AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat, cecPort); - AddInCardHdmiAndAudioLoopPorts(number); - } - - void AddDmInCardPorts(uint number, ICec cecPort, IVideoAttributesBasic videoAttributes) - { - AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat, cecPort, videoAttributes); - AddInCardHdmiAndAudioLoopPorts(number); - } - - void AddHdmiInCardPorts(uint number, ICec cecPort) - { - AddInputPortWithDebug(number, "hdmiIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, cecPort); - AddInCardHdmiAndAudioLoopPorts(number); - } - - void AddHdmiInCardPorts(uint number, ICec cecPort, IVideoAttributesBasic videoAttributes) - { - AddInputPortWithDebug(number, "hdmiIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, cecPort, videoAttributes); - AddInCardHdmiAndAudioLoopPorts(number); - } - - void AddInCardHdmiAndAudioLoopPorts(uint number) - { - AddOutputPortWithDebug(string.Format("inputCard{0}", number), "hdmiLoopOut", eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, null); - AddOutputPortWithDebug(string.Format("inputCard{0}", number), "audioLoopOut", eRoutingSignalType.Audio, eRoutingPortConnectionType.Hdmi, null); - } - - void AddInCardHdmiLoopPort(uint number) - { - AddOutputPortWithDebug(string.Format("inputCard{0}", number), "hdmiLoopOut", eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, null); - } - - /// - /// - /// - /// - /// - public void AddOutputCard(string type, uint number) - { - type = type.ToLower(); - - Debug.Console(2, this, "Adding output card '{0}', slot {1}", type, number); - switch (type) - { - case "dmc4khdo": - { - var outputCard = new Dmc4kHdoSingle(number, Chassis); - var cecPort1 = outputCard.Card1.HdmiOutput; - var cecPort2 = outputCard.Card2.HdmiOutput; - AddDmcHdoPorts(number, cecPort1, cecPort2); - } - break; - case "dmc4kzhdo": - { - var outputCard = new Dmc4kzHdoSingle(number, Chassis); - var cecPort1 = outputCard.Card1.HdmiOutput; - var cecPort2 = outputCard.Card2.HdmiOutput; - AddDmcHdoPorts(number, cecPort1, cecPort2); - } - break; - case "dmchdo": - { - var outputCard = new DmcHdoSingle(number, Chassis); - var cecPort1 = outputCard.Card1.HdmiOutput; - var cecPort2 = outputCard.Card2.HdmiOutput; - AddDmcHdoPorts(number, cecPort1, cecPort2); - } - break; - case "dmc4kcohd": - { - var outputCard = new Dmc4kCoHdSingle(number, Chassis); - var cecPort1 = outputCard.Card1.HdmiOutput; - AddDmcCoPorts(number, cecPort1); - } - break; - case "dmc4kzcohd": - { - var outputCard = new Dmc4kzCoHdSingle(number, Chassis); - var cecPort1 = outputCard.Card1.HdmiOutput; - AddDmcCoPorts(number, cecPort1); - } - break; - case "dmccohd": - { - var outputCard = new DmcCoHdSingle(number, Chassis); - var cecPort1 = outputCard.Card1.HdmiOutput; - AddDmcCoPorts(number, cecPort1); - } - break; - case "dmccatohd": - { - var outputCard = new DmcCatoHdSingle(number, Chassis); - var cecPort1 = outputCard.Card1.HdmiOutput; - AddDmcCoPorts(number, cecPort1); - } - break; - case "dmcsohd": - { - var outputCard = new DmcSoHdSingle(number, Chassis); - var cecPort1 = outputCard.Card1.HdmiOutput; - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "dmOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmMmFiber, Chassis.Outputs[2 * (number - 1) + 1]); - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "hdmiOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, Chassis.Outputs[2 * (number - 1) + 1], cecPort1); - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "dmOut2", eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmMmFiber, Chassis.Outputs[2 * (number - 1) + 2]); - } - break; - case "dmcs2ohd": - { - var outputCard = new DmcS2oHdSingle(number, Chassis); - var cecPort1 = outputCard.Card1.HdmiOutput; - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "dmOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmSmFiber, Chassis.Outputs[2 * (number - 1) + 1]); - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "hdmiOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, Chassis.Outputs[2 * (number - 1) + 1], cecPort1); - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "dmOut2", eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmSmFiber, Chassis.Outputs[2 * (number - 1) + 2]); - } - break; - case "dmcstro": - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "streamOut", eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Streaming, Chassis.Outputs[2 * (number - 1) + 1]); - break; - default: - Debug.Console(1, this, " WARNING: Output card type '{0}' is not available", type); - break; - } - } - - void AddDmcHdoPorts(uint number, ICec cecPort1, ICec cecPort2) - { - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "hdmiOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, Chassis.Outputs[2 * (number - 1) + 1], cecPort1); - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "audioOut1", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio, - Chassis.Outputs[2 * (number - 1) + 1]); - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "hdmiOut2", eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, Chassis.Outputs[2 * (number - 1) + 2], cecPort2); - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "audioOut2", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio, - Chassis.Outputs[2 * (number - 1) + 2]); - } - - void AddDmcCoPorts(uint number, ICec cecPort1) - { - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "dmOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmCat, Chassis.Outputs[2 * (number - 1) + 1]); - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "hdmiOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, Chassis.Outputs[2 * (number - 1) + 1], cecPort1); - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "dmOut2", eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmCat, Chassis.Outputs[2 * (number - 1) + 2]); - } - - /// - /// Adds InputPort - /// - void AddInputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType) - { - //Cast is necessary here to determine the correct overload - AddInputPortWithDebug(cardNum, portName, sigType, portType, null, null); - } - - private void AddInputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, - eRoutingPortConnectionType portType, ICec cecPort) - { - //Cast is necessary here to determine the correct overload - AddInputPortWithDebug(cardNum, portName, sigType, portType, cecPort, null); - } - - /// - /// Adds InputPort and sets Port as ICec object. If videoAttributesBasic is defined, RoutingPort will be RoutingInputPortWithVideoStatuses - /// - void AddInputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, ICec cecPort, IVideoAttributesBasic videoAttributesBasic) - { - var portKey = string.Format("inputCard{0}--{1}", cardNum, portName); - Debug.Console(2, this, "Adding input port '{0}'", portKey); - - RoutingInputPort inputPort; - - if (videoAttributesBasic != null) - { - Debug.Console(1, this, "card {0} supports IVideoAttributesBasic", cardNum); - var statusFuncs = new VideoStatusFuncsWrapper - { - VideoResolutionFeedbackFunc = () => - { - var resolution = videoAttributesBasic.VideoAttributes.GetVideoResolutionString(); - Debug.Console(1, this, "Updating resolution for input {0}. New resolution: {1}", cardNum, resolution); - return resolution; - } - }; - inputPort = new RoutingInputPortWithVideoStatuses(portKey, sigType, portType, - Chassis.Inputs[cardNum], this, statusFuncs) - { - FeedbackMatchObject = Chassis.Inputs[cardNum] - }; - - RegisterForInputResolutionFeedback(videoAttributesBasic, cardNum, inputPort as RoutingInputPortWithVideoStatuses); - } - else - { - inputPort = new RoutingInputPort(portKey, sigType, portType, - Chassis.Inputs[cardNum], this) - { - FeedbackMatchObject = Chassis.Inputs[cardNum] - }; - } - - if (cecPort != null) - inputPort.Port = cecPort; - - InputPorts.Add(inputPort); - } - - /// - /// Adds OutputPort - /// - void AddOutputPortWithDebug(string cardName, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, object selector) - { - AddOutputPortWithDebug(cardName, portName, sigType, portType, selector, null); - } - - /// - /// Adds OutputPort and sets Port as ICec object - /// - void AddOutputPortWithDebug(string cardName, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, object selector, ICec cecPort) - { - var portKey = string.Format("{0}--{1}", cardName, portName); - Debug.Console(2, this, "Adding output port '{0}'", portKey); - var outputPort = new RoutingOutputPort(portKey, sigType, portType, selector, this); - - if (portName.IndexOf("Loop", StringComparison.InvariantCultureIgnoreCase) < 0) - { - outputPort.FeedbackMatchObject = selector; - } - if (cecPort != null) - outputPort.Port = cecPort; - - OutputPorts.Add(outputPort); - } - - /// - /// - /// - void AddVolumeControl(uint number, Audio.Output audio) - { - VolumeControls.Add(number, new DmCardAudioOutputController(audio)); - } - - //public void SetInputHdcpSupport(uint input, ePdtHdcpSupport hdcpSetting) - //{ - - //} - - void Chassis_DMSystemChange(Switch device, DMSystemEventArgs args) - { - switch (args.EventId) - { - case DMSystemEventIds.SystemIdEventId: - { - Debug.Console(2, this, "SystemIdEvent Value: {0}", (Chassis as DmMDMnxn).SystemIdFeedback.UShortValue); - SystemIdFeebdack.FireUpdate(); - break; - } - case DMSystemEventIds.SystemIdBusyEventId: - { - Debug.Console(2, this, "SystemIdBusyEvent State: {0}", (Chassis as DmMDMnxn).SystemIdBusy.BoolValue); - SystemIdBusyFeedback.FireUpdate(); - break; - } - case DMSystemEventIds.AudioBreakawayEventId: - { - Debug.Console(2, this, "AudioBreakaway Event: value: {0}", - (Chassis as DmMDMnxn).EnableAudioBreakawayFeedback.BoolValue); - EnableAudioBreakawayFeedback.FireUpdate(); - break; - } - case DMSystemEventIds.USBBreakawayEventId: - { - Debug.Console(2, this, "USBBreakaway Event: value: {0}", - (Chassis as DmMDMnxn).EnableUSBBreakawayFeedback.BoolValue); - EnableUsbBreakawayFeedback.FireUpdate(); - break; - } - } - } - - void Chassis_DMInputChange(Switch device, DMInputEventArgs args) - { - try - { - switch (args.EventId) - { - case DMInputEventIds.EndpointOnlineEventId: - { - Debug.Console(2, this, "DM Input EndpointOnlineEventId for input: {0}. State: {1}", args.Number, device.Inputs[args.Number].EndpointOnlineFeedback); - InputEndpointOnlineFeedbacks[args.Number].FireUpdate(); - break; - } - case DMInputEventIds.OnlineFeedbackEventId: - { - Debug.Console(2, this, "DM Input OnlineFeedbackEventId for input: {0}. State: {1}", args.Number, device.Inputs[args.Number].EndpointOnlineFeedback); - InputEndpointOnlineFeedbacks[args.Number].FireUpdate(); - break; - } - case DMInputEventIds.VideoDetectedEventId: - { - Debug.Console(2, this, "DM Input {0} VideoDetectedEventId", args.Number); - VideoInputSyncFeedbacks[args.Number].FireUpdate(); - break; - } - case DMInputEventIds.InputNameEventId: - { - Debug.Console(2, this, "DM Input {0} NameFeedbackEventId", args.Number); - InputNameFeedbacks[args.Number].FireUpdate(); - break; - } - case DMInputEventIds.UsbRoutedToEventId: - { - Debug.Console(2, this, "DM Input {0} UsbRoutedToEventId", args.Number); - if (UsbInputRoutedToFeebacks[args.Number] != null) - UsbInputRoutedToFeebacks[args.Number].FireUpdate(); - else - Debug.Console(1, this, "No index of {0} found in UsbInputRoutedToFeedbacks"); - break; - } - case DMInputEventIds.HdcpCapabilityFeedbackEventId: - { - Debug.Console(2, this, "DM Input {0} HdcpCapabilityFeedbackEventId", args.Number); - if (InputCardHdcpStateFeedbacks[args.Number] != null) - InputCardHdcpStateFeedbacks[args.Number].FireUpdate(); - else - Debug.Console(1, this, "No index of {0} found in InputCardHdcpCapabilityFeedbacks"); - break; - } - case DMInputEventIds.HdcpSupportOffEventId: - { - Debug.Console(2, this, "DM Input {0} HdcpSupportOffEventId", args.Number); - if (InputCardHdcpStateFeedbacks[args.Number] != null) - InputCardHdcpStateFeedbacks[args.Number].FireUpdate(); - else - Debug.Console(1, this, "No index of {0} found in InputCardHdcpCapabilityFeedbacks"); - break; - } - case DMInputEventIds.HdcpSupportOnEventId: - { - Debug.Console(2, this, "DM Input {0} HdcpSupportOnEventId", args.Number); - if (InputCardHdcpStateFeedbacks[args.Number] != null) - InputCardHdcpStateFeedbacks[args.Number].FireUpdate(); - else - Debug.Console(1, this, "No index of {0} found in InputCardHdcpCapabilityFeedbacks"); - break; - } - case DMInputEventIds.StartEventId: - case DMInputEventIds.StopEventId: - case DMInputEventIds.PauseEventId: - { - Debug.Console(2, this, "DM Input {0} Stream Status EventId", args.Number); - if (InputStreamCardStateFeedbacks[args.Number] != null) - { - InputStreamCardStateFeedbacks[args.Number].FireUpdate(); - } - else - Debug.Console(2, this, "No index of {0} found in InputStreamCardStateFeedbacks"); - break; - } - case DMInputEventIds.HorizontalResolutionFeedbackEventId: - case DMInputEventIds.VerticalResolutionFeedbackEventId: - case DMInputEventIds.FramesPerSecondFeedbackEventId: - case DMInputEventIds.ResolutionEventId: - { - Debug.Console(1, this, "Input {0} resolution updated", args.Number); - var inputPort = - InputPorts.Cast() - .FirstOrDefault((ip) => ip.Key.Contains(String.Format("inputCard{0}", args.Number))); - - if (inputPort != null) - { - Debug.Console(1, this, "Updating resolution feedback for input {0}", args.Number); - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - } - break; - } - default: - { - Debug.Console(2, this, "DMInputChange fired for Input {0} with Unhandled EventId: {1}", args.Number, args.EventId); - break; - } - } - } - catch (Exception ex) - { - Debug.Console(2, this, Debug.ErrorLogLevel.Error, "Error in Chassis_DMInputChange: {0}", ex); - } - } - - /// - /// - /// Raise an event when the status of a switch object changes. - /// - /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType - private void OnSwitchChange(RoutingNumericEventArgs e) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, e); - } - - /// - /// - void Chassis_DMOutputChange(Switch device, DMOutputEventArgs args) - { - var output = args.Number; - - switch (args.EventId) - { - case DMOutputEventIds.VolumeEventId: - { - if (VolumeControls.ContainsKey(output)) - { - VolumeControls[args.Number].VolumeEventFromChassis(); - } - - break; - } - case DMOutputEventIds.EndpointOnlineEventId: - { - Debug.Console(2, this, "Output {0} DMOutputEventIds.EndpointOnlineEventId fired. State: {1}", args.Number, - Chassis.Outputs[output].EndpointOnlineFeedback); - OutputEndpointOnlineFeedbacks[output].FireUpdate(); - break; - } - case DMOutputEventIds.OnlineFeedbackEventId: - { - Debug.Console(2, this, "Output {0} DMInputEventIds.OnlineFeedbackEventId fired. State: {1}", args.Number, - Chassis.Outputs[output].EndpointOnlineFeedback); - OutputEndpointOnlineFeedbacks[output].FireUpdate(); - break; - } - case DMOutputEventIds.VideoOutEventId: - { - - var inputNumber = Chassis.Outputs[output].VideoOutFeedback == null ? 0 : Chassis. - Outputs[output].VideoOutFeedback.Number; - - Debug.Console(2, this, "DMSwitchVideo:{0} Routed Input:{1} Output:{2}'", Name, inputNumber, output); - - if (VideoOutputFeedbacks.ContainsKey(output)) - { - var localInputPort = InputPorts.FirstOrDefault(p => (DMInput)p.FeedbackMatchObject == Chassis.Outputs[output].VideoOutFeedback); - var localOutputPort = - OutputPorts.FirstOrDefault(p => (DMOutput) p.FeedbackMatchObject == Chassis.Outputs[output]); - - - VideoOutputFeedbacks[output].FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(output, - inputNumber, - localOutputPort, - localInputPort, - eRoutingSignalType.Video)); - } - - if (OutputVideoRouteNameFeedbacks.ContainsKey(output)) - OutputVideoRouteNameFeedbacks[output].FireUpdate(); - - break; - } - case DMOutputEventIds.AudioOutEventId: - { - var inputNumber = Chassis.Outputs[output].AudioOutFeedback == null ? 0 : Chassis. - Outputs[output].AudioOutFeedback.Number; - - Debug.Console(2, this, "DMSwitchAudio:{0} Routed Input:{1} Output:{2}'", Name, inputNumber, output); - - if (AudioOutputFeedbacks.ContainsKey(output)) - { - var localInputPort = InputPorts.FirstOrDefault(p => (DMInput)p.FeedbackMatchObject == Chassis.Outputs[output].AudioOutFeedback); - var localOutputPort = - OutputPorts.FirstOrDefault(p => (DMOutput)p.FeedbackMatchObject == Chassis.Outputs[output]); - - - AudioOutputFeedbacks[output].FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(output, - inputNumber, - localOutputPort, - localInputPort, - eRoutingSignalType.Audio)); - } - - if (OutputAudioRouteNameFeedbacks.ContainsKey(output)) - OutputAudioRouteNameFeedbacks[output].FireUpdate(); - - break; - } - case DMOutputEventIds.OutputNameEventId: - { - Debug.Console(2, this, "DM Output {0} NameFeedbackEventId", output); - OutputNameFeedbacks[output].FireUpdate(); - break; - } - case DMOutputEventIds.UsbRoutedToEventId: - { - Debug.Console(2, this, "DM Output {0} UsbRoutedToEventId", args.Number); - UsbOutputRoutedToFeebacks[args.Number].FireUpdate(); - break; - } - case DMOutputEventIds.DisabledByHdcpEventId: - { - Debug.Console(2, this, "DM Output {0} DisabledByHdcpEventId", args.Number); - OutputDisabledByHdcpFeedbacks[args.Number].FireUpdate(); - break; - } - case DMOutputEventIds.StartEventId: - case DMOutputEventIds.StopEventId: - case DMOutputEventIds.PauseEventId: - { - Debug.Console(2, this, "DM Output {0} Stream Status EventId", args.Number); - if (OutputStreamCardStateFeedbacks[args.Number] != null) - { - OutputStreamCardStateFeedbacks[args.Number].FireUpdate(); - } - else - Debug.Console(2, this, "No index of {0} found in OutputStreamCardStateFeedbacks"); - break; - } - default: - { - Debug.Console(2, this, "DMOutputChange fired for Output {0} with Unhandled EventId: {1}", args.Number, args.EventId); - break; - } - } - } - - /// - /// - /// - /// - void StartOffTimer(PortNumberType pnt) - { - if (RouteOffTimers.ContainsKey(pnt)) - return; - RouteOffTimers[pnt] = new CTimer(o => ExecuteSwitch(null, pnt.Selector, pnt.Type), RouteOffTime); - } - - // Send out sigs when coming online - void IsOnline_OutputChange(object sender, EventArgs e) - { - if (IsOnline.BoolValue) - { - (Chassis as DmMDMnxn).EnableAudioBreakaway.BoolValue = true; - (Chassis as DmMDMnxn).EnableUSBBreakaway.BoolValue = true; - - - EnableAudioBreakawayFeedback.FireUpdate(); - EnableUsbBreakawayFeedback.FireUpdate(); - - if (InputNames != null) - foreach (var kvp in InputNames) - Chassis.Inputs[kvp.Key].Name.StringValue = kvp.Value; - if (OutputNames != null) - foreach (var kvp in OutputNames) - Chassis.Outputs[kvp.Key].Name.StringValue = kvp.Value; - } - } - - #region IRouting Members - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType sigType) - { - Debug.Console(2, this, "Making an awesome DM route from {0} to {1} {2}", inputSelector, outputSelector, sigType); - - var input = inputSelector as DMInput;//Input Selector could be null... - - var output = outputSelector as DMOutput; - - var isUsbInput = (sigType & eRoutingSignalType.UsbInput) == eRoutingSignalType.UsbInput; - var isUsbOutput = (sigType & eRoutingSignalType.UsbOutput) == eRoutingSignalType.UsbOutput; - - if (output == null && !(isUsbOutput || isUsbInput)) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Warning, - "Unable to execute switch for inputSelector {0} to outputSelector {1}", inputSelector, - outputSelector); - return; - } - - // Check to see if there's an off timer waiting on this and if so, cancel - var key = new PortNumberType(output, sigType); - if (input == null) - { - StartOffTimer(key); - } - else - { - if (RouteOffTimers.ContainsKey(key)) - { - Debug.Console(2, this, "{0} cancelling route off due to new source", output); - RouteOffTimers[key].Stop(); - RouteOffTimers.Remove(key); - } - } - - //var inCard = input == 0 ? null : Chassis.Inputs[input]; - //var outCard = input == 0 ? null : Chassis.Outputs[output]; - - // NOTE THAT BITWISE COMPARISONS - TO CATCH ALL ROUTING TYPES - if ((sigType & eRoutingSignalType.Video) == eRoutingSignalType.Video) - { - Chassis.VideoEnter.BoolValue = true; - if (output != null) - { - output.VideoOut = input; //Chassis.Outputs[output].VideoOut = inCard; - } - } - - if ((sigType & eRoutingSignalType.Audio) == eRoutingSignalType.Audio) - { - var dmMdMnxn = Chassis as DmMDMnxn; - if (dmMdMnxn != null) - { - dmMdMnxn.AudioEnter.BoolValue = true; - } - if (output != null) - { - output.AudioOut = input; - } - } - - if ((sigType & eRoutingSignalType.UsbOutput) == eRoutingSignalType.UsbOutput) - - { - Chassis.USBEnter.BoolValue = true; - if (inputSelector == null && output != null) - { - //clearing the route is intended - output.USBRoutedTo = null; - return; - } - - if (inputSelector != null && input == null) - { - //input selector is DMOutput...we're doing a out to out route - var tempInput = inputSelector as DMOutput; - - if (tempInput == null || output == null) - { - return; - } - output.USBRoutedTo = tempInput; - return; - } - - if (input != null & output != null) - { - output.USBRoutedTo = input; - } - } - - if((sigType & eRoutingSignalType.UsbInput) != eRoutingSignalType.UsbInput) - { - return; - } - - Chassis.USBEnter.BoolValue = true; - if (output != null) - { - output.USBRoutedTo = input; - return; - } - var tempOutput = outputSelector as DMInput; - - if (tempOutput == null) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Warning, - "Unable to execute switch for inputSelector {0} to outputSelector {1}", inputSelector, - outputSelector); - return; - } - - tempOutput.USBRoutedTo = input; - } - - #endregion - - #region IRoutingNumeric Members - - public void ExecuteNumericSwitch(ushort inputSelector, ushort outputSelector, eRoutingSignalType sigType) - { - var chassisSize = (uint)Chassis.NumberOfInputs; //need this to determine USB routing values 8x8 -> 1-8 is inputs 1-8, 17-24 is outputs 1-8 - //16x16 1-16 is inputs 1-16, 17-32 is outputs 1-16 - //32x32 1-32 is inputs 1-32, 33-64 is outputs 1-32 - - DMInputOutputBase dmCard; - - //Routing Input to Input or Output to Input - if ((sigType & eRoutingSignalType.UsbInput) == eRoutingSignalType.UsbInput) - { - Debug.Console(2, this, "Executing USB Input switch.\r\n in:{0} output: {1}", inputSelector, outputSelector); - if (outputSelector > chassisSize) - { - uint outputIndex; - - if (chassisSize == 8) - { - outputIndex = (uint) inputSelector - 16; - } - else - { - outputIndex = inputSelector - chassisSize; - } - dmCard = Chassis.Outputs[outputIndex]; - } - else - { - dmCard = Chassis.Inputs[inputSelector]; - } - - ExecuteSwitch(dmCard, Chassis.Inputs[outputSelector], sigType); - return; - } - if ((sigType & eRoutingSignalType.UsbOutput) == eRoutingSignalType.UsbOutput) - { - Debug.Console(2, this, "Executing USB Output switch.\r\n in:{0} output: {1}", inputSelector, outputSelector); - - //routing Output to Output or Input to Output - if (inputSelector > chassisSize) - { - //wanting to route an output to an output. Subtract chassis size and get output, unless it's 8x8 - //need this to determine USB routing values - //8x8 -> 1-8 is inputs 1-8, 17-24 is outputs 1-8 - //16x16 1-16 is inputs 1-16, 17-32 is outputs 1-16 - //32x32 1-32 is inputs 1-32, 33-64 is outputs 1-32 - uint outputIndex; - - if (chassisSize == 8) - { - outputIndex = (uint) inputSelector - 16; - } - else - { - outputIndex = inputSelector - chassisSize; - } - - dmCard = Chassis.Outputs[outputIndex]; - } - else - { - dmCard = Chassis.Inputs[inputSelector]; - } - Chassis.USBEnter.BoolValue = true; - - Debug.Console(2, this, "Routing USB for input {0} to {1}", inputSelector, dmCard); - ExecuteSwitch(dmCard, Chassis.Outputs[outputSelector], sigType); - return; - } - - var inputCard = inputSelector == 0 ? null : Chassis.Inputs[inputSelector]; - var outputCard = Chassis.Outputs[outputSelector]; - - ExecuteSwitch(inputCard, outputCard, sigType); - } - - #endregion - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = GetJoinMap(joinStart, joinMapKey, bridge); - - Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - - LinkChassisToApi(trilist, joinMap); - - trilist.StringInput[joinMap.Name.JoinNumber].StringValue = this.Name; - - // Link up inputs & outputs - for (uint i = 1; i <= Chassis.NumberOfOutputs; i++) - { - var ioSlot = i; - var ioSlotJoin = ioSlot - 1; - - LinkRoutingJoinsToApi(trilist, joinMap, ioSlotJoin, ioSlot); - - if (TxDictionary.ContainsKey(ioSlot)) - { - LinkTxToApi(trilist, ioSlot, joinMap, ioSlotJoin); - } - else - { - LinkHdmiInputToApi(trilist, ioSlot, joinMap, ioSlotJoin); - LinkStreamInputToApi(trilist, ioSlot, joinMap, ioSlotJoin); - } - - if (RxDictionary.ContainsKey(ioSlot)) - { - LinkRxToApi(trilist, ioSlot, joinMap, ioSlotJoin); - } - else - LinkStreamOutputToApi(trilist, ioSlot, joinMap, ioSlotJoin); - } - } - - private void LinkHdmiInputToApi(BasicTriList trilist, uint ioSlot, DmChassisControllerJoinMap joinMap, uint ioSlotJoin) - { - VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus.JoinNumber + ioSlotJoin]); - - var inputPort = InputPorts[string.Format("inputCard{0}--hdmiIn", ioSlot)]; - if (inputPort == null) - { - return; - } - - Debug.Console(1, "Port value for input card {0} is set", ioSlot); - var port = inputPort.Port; - - if (port == null) - { - return; - } - if (!(port is HdmiInputWithCEC)) - { - Debug.Console(0, this, "HDMI Input port on card {0} does not support HDCP settings.", ioSlot); - return; - } - - Debug.Console(1, "Port is HdmiInputWithCec"); - - var hdmiInPortWCec = port as HdmiInputWithCEC; - - - SetHdcpStateAction(PropertiesConfig.InputSlotSupportsHdcp2[ioSlot], hdmiInPortWCec, joinMap.HdcpSupportState.JoinNumber + ioSlotJoin, trilist); - - - InputCardHdcpStateFeedbacks[ioSlot].LinkInputSig( - trilist.UShortInput[joinMap.HdcpSupportState.JoinNumber + ioSlotJoin]); - - if (InputCardHdcpCapabilityTypes.ContainsKey(ioSlot)) - { - trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber + ioSlotJoin].UShortValue = - (ushort)InputCardHdcpCapabilityTypes[ioSlot]; - } - else - { - trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber + ioSlotJoin].UShortValue = 1; - } - - var videoStatus = inputPort as RoutingInputPortWithVideoStatuses; - - if (videoStatus == null) - { - return; - } - - Debug.Console(1, this, "Linking {0} to join {1} for resolution feedback.", videoStatus.Key, joinMap.InputCurrentResolution.JoinNumber + ioSlotJoin); - videoStatus.VideoStatus.VideoResolutionFeedback.LinkInputSig(trilist.StringInput[joinMap.InputCurrentResolution.JoinNumber + ioSlotJoin]); - } - - private void LinkStreamInputToApi(BasicTriList trilist, uint ioSlot, DmChassisControllerJoinMap joinMap, uint ioSlotJoin) - { - var inputPort = InputPorts[string.Format("inputCard{0}--streamIn", ioSlot)]; - if (inputPort == null) - { - return; - } - var streamCard = Chassis.Inputs[ioSlot].Card as DmcStr; - var join = joinMap.InputStreamCardState.JoinNumber + ioSlotJoin; - - Debug.Console(1, "Port value for input card {0} is set as a stream card", ioSlot); - - trilist.SetUShortSigAction(join, s => - { - if (s == 1) - { - Debug.Console(2, this, "Join {0} value {1}: Setting stream state to start", join, s); - streamCard.Control.Start(); - } - else if (s == 2) - { - Debug.Console(2, this, "Join {0} value {1}: Setting stream state to stop", join, s); - streamCard.Control.Stop(); - } - else if (s == 3) - { - Debug.Console(2, this, "Join {0} value {1}: Setting stream state to pause", join, s); - streamCard.Control.Pause(); - } - else - { - Debug.Console(2, this, "Join {0} value {1}: Ignore stream state", join, s); - } - }); - - InputStreamCardStateFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[join]); - - trilist.UShortInput[join].UShortValue = InputStreamCardStateFeedbacks[ioSlot].UShortValue; - - var videoStatus = inputPort as RoutingInputPortWithVideoStatuses; - - if (videoStatus != null) - { - videoStatus.VideoStatus.VideoResolutionFeedback.LinkInputSig(trilist.StringInput[joinMap.InputCurrentResolution.JoinNumber + ioSlotJoin]); - } - } - - private void LinkStreamOutputToApi(BasicTriList trilist, uint ioSlot, DmChassisControllerJoinMap joinMap, uint ioSlotJoin) - { - var outputPort = OutputPorts[string.Format("outputCard{0}--streamOut", ioSlot)]; - if (outputPort == null) - { - return; - } - var streamCard = Chassis.Outputs[ioSlot].Card as DmcStroAV; - var join = joinMap.OutputStreamCardState.JoinNumber + ioSlotJoin; - - Debug.Console(1, "Port value for output card {0} is set as a stream card", ioSlot); - - trilist.SetUShortSigAction(join, s => - { - if (s == 1) - { - Debug.Console(2, this, "Join {0} value {1}: Setting stream state to start", join, s); - streamCard.Control.Start(); - } - else if (s == 2) - { - Debug.Console(2, this, "Join {0} value {1}: Setting stream state to stop", join, s); - streamCard.Control.Stop(); - } - else if (s == 3) - { - Debug.Console(2, this, "Join {0} value {1}: Setting stream state to pause", join, s); - streamCard.Control.Pause(); - } - else - { - Debug.Console(2, this, "Join {0} value {1}: Ignore stream state", join, s); - } - }); - - OutputStreamCardStateFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[join]); - - trilist.UShortInput[join].UShortValue = OutputStreamCardStateFeedbacks[ioSlot].UShortValue; - } - - private void LinkRxToApi(BasicTriList trilist, uint ioSlot, DmChassisControllerJoinMap joinMap, uint ioSlotJoin) - { - Debug.Console(2, "Creating Rx Feedbacks {0}", ioSlot); - var rxKey = RxDictionary[ioSlot]; - var rxDevice = DeviceManager.GetDeviceForKey(rxKey) as DmRmcControllerBase; - var hdBaseTDevice = DeviceManager.GetDeviceForKey(rxKey) as DmHdBaseTControllerBase; - if (Chassis is DmMd8x8Cpu3 || Chassis is DmMd8x8Cpu3rps - || Chassis is DmMd16x16Cpu3 || Chassis is DmMd16x16Cpu3rps - || Chassis is DmMd32x32Cpu3 || Chassis is DmMd32x32Cpu3rps || hdBaseTDevice != null) - { - OutputEndpointOnlineFeedbacks[ioSlot].LinkInputSig( - trilist.BooleanInput[joinMap.OutputEndpointOnline.JoinNumber + ioSlotJoin]); - } - else if (rxDevice != null) - { - rxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline.JoinNumber + ioSlotJoin]); - } - } - - private void LinkTxToApi(BasicTriList trilist, uint ioSlot, DmChassisControllerJoinMap joinMap, uint ioSlotJoin) - { - Debug.Console(1, "Setting up actions and feedbacks on input card {0}", ioSlot); - VideoInputSyncFeedbacks[ioSlot].LinkInputSig( - trilist.BooleanInput[joinMap.VideoSyncStatus.JoinNumber + ioSlotJoin]); - - Debug.Console(2, "Creating Tx Feedbacks {0}", ioSlot); - var txKey = TxDictionary[ioSlot]; - var txDevice = DeviceManager.GetDeviceForKey(txKey) as BasicDmTxControllerBase; - - if (txDevice == null) - { - return; - } - - LinkTxOnlineFeedbackToApi(trilist, ioSlot, joinMap, ioSlotJoin, txDevice); - - LinkBasicTxToApi(trilist, joinMap, ioSlot, ioSlotJoin, txDevice); - - LinkAdvancedTxToApi(trilist, joinMap, ioSlot, ioSlotJoin, txDevice); - } - - private void LinkBasicTxToApi(BasicTriList trilist, DmChassisControllerJoinMap joinMap, uint ioSlot, - uint ioSlotJoin, BasicDmTxControllerBase basicTransmitter) - { - var advTx = basicTransmitter as DmTxControllerBase; - - if (advTx != null) - { - return; - } - var inputPort = InputPorts[string.Format("inputCard{0}--dmIn", ioSlot)]; - - if (inputPort == null) - { - return; - } - var port = inputPort.Port; - - if (!(port is DMInputPortWithCec)) - { - Debug.Console(0, this, "DM Input port on card {0} does not support HDCP settings.", ioSlot); - return; - } - Debug.Console(1, "Port is DMInputPortWithCec"); - - var dmInPortWCec = port as DMInputPortWithCec; - - bool supportsHdcp2; - - //added in case the InputSlotSupportsHdcp2 section isn't included in the config, or this slot is left out. - //if the key isn't in the dictionary, supportsHdcp2 will be false - - if(!PropertiesConfig.InputSlotSupportsHdcp2.TryGetValue(ioSlot, out supportsHdcp2)) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Warning, - "Input Slot Supports HDCP2 setting not found for slot {0}. Setting to false. Program may not function as intended.", - ioSlot); - } - - SetHdcpStateAction(supportsHdcp2, dmInPortWCec, - joinMap.HdcpSupportState.JoinNumber + ioSlotJoin, trilist); - - InputCardHdcpStateFeedbacks[ioSlot].LinkInputSig( - trilist.UShortInput[joinMap.HdcpSupportState.JoinNumber + ioSlotJoin]); - - if (InputCardHdcpCapabilityTypes.ContainsKey(ioSlot)) - { - trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber + ioSlotJoin].UShortValue = - (ushort) InputCardHdcpCapabilityTypes[ioSlot]; - } - else - { - trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber + ioSlotJoin].UShortValue = 1; - } - - var videoStatus = inputPort as RoutingInputPortWithVideoStatuses; - - if (videoStatus == null) - { - return; - } - Debug.Console(1, this, "Linking {0} to join {1} for resolution feedback.", videoStatus.Key, joinMap.InputCurrentResolution.JoinNumber + ioSlotJoin); - videoStatus.VideoStatus.VideoResolutionFeedback.LinkInputSig(trilist.StringInput[joinMap.InputCurrentResolution.JoinNumber + ioSlotJoin]); - } - - private void LinkAdvancedTxToApi(BasicTriList trilist, DmChassisControllerJoinMap joinMap, - uint ioSlot, uint ioSlotJoin, BasicDmTxControllerBase basicTransmitter) - { - var transmitter = basicTransmitter as DmTxControllerBase; - if (transmitter == null) return; - - trilist.BooleanInput[joinMap.TxAdvancedIsPresent.JoinNumber + ioSlotJoin].BoolValue = true; - - transmitter.AnyVideoInput.VideoStatus.VideoSyncFeedback.LinkInputSig( - trilist.BooleanInput[joinMap.VideoSyncStatus.JoinNumber + ioSlotJoin]); - - var txRoutingInputs = transmitter as IRoutingInputs; - - if (txRoutingInputs == null) return; - - var inputPorts = - txRoutingInputs.InputPorts.Where( - (p) => p.Port is EndpointHdmiInput || p.Port is EndpointDisplayPortInput).ToList(); - - if (inputPorts.Count == 0) - { - Debug.Console(1, this, "No HDCP-capable input ports found on transmitter for slot {0}", ioSlot); - return; - } - - bool supportsHdcp2; - - if (!PropertiesConfig.InputSlotSupportsHdcp2.TryGetValue(ioSlot, out supportsHdcp2)) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Warning, - "Input Slot Supports HDCP2 setting not found for slot {0}. Setting to false. Program may not function as intended.", - ioSlot); - } - - SetHdcpStateAction(supportsHdcp2, inputPorts, joinMap.HdcpSupportState.JoinNumber + ioSlotJoin, trilist); - - if (transmitter.HdcpStateFeedback != null) - { - transmitter.HdcpStateFeedback.LinkInputSig( - trilist.UShortInput[joinMap.HdcpSupportState.JoinNumber + ioSlotJoin]); - } - else - { - Debug.Console(2, this, "Transmitter Hdcp Feedback null. Linking to card's feedback"); - InputCardHdcpStateFeedbacks[ioSlot].LinkInputSig( - trilist.UShortInput[joinMap.HdcpSupportState.JoinNumber + ioSlotJoin]); - } - - trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber + ioSlotJoin].UShortValue = - (ushort) transmitter.HdcpSupportCapability; - - - var videoStatus = - InputPorts[string.Format("inputCard{0}--dmIn", ioSlot)] as RoutingInputPortWithVideoStatuses; - - if (videoStatus == null) - { - return; - } - Debug.Console(1, this, "Linking {0} to join {1} for resolution feedback.", videoStatus.Key, - joinMap.InputCurrentResolution.JoinNumber + ioSlotJoin); - videoStatus.VideoStatus.VideoResolutionFeedback.LinkInputSig( - trilist.StringInput[joinMap.InputCurrentResolution.JoinNumber + ioSlotJoin]); - } - - private void LinkTxOnlineFeedbackToApi(BasicTriList trilist, uint ioSlot, DmChassisControllerJoinMap joinMap, - uint ioSlotJoin, BasicDmTxControllerBase txDevice) - { - var advancedTxDevice = txDevice as DmTxControllerBase; - - if ((Chassis is DmMd8x8Cpu3 || Chassis is DmMd8x8Cpu3rps - || Chassis is DmMd16x16Cpu3 || Chassis is DmMd16x16Cpu3rps - || Chassis is DmMd32x32Cpu3 || Chassis is DmMd32x32Cpu3rps) || - advancedTxDevice == null) - { - Debug.Console(2, "Linking Tx Online Feedback from Input Card {0}", ioSlot); - InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig( - trilist.BooleanInput[joinMap.InputEndpointOnline.JoinNumber + ioSlotJoin]); - return; - } - - Debug.Console(2, "Linking Tx Online Feedback from Advanced Transmitter at input {0}", ioSlot); - - advancedTxDevice.IsOnline.LinkInputSig( - trilist.BooleanInput[joinMap.InputEndpointOnline.JoinNumber + ioSlotJoin]); - } - - private void LinkRoutingJoinsToApi(BasicTriList trilist, DmChassisControllerJoinMap joinMap, uint ioSlotJoin, - uint ioSlot) - { - // Routing Control - trilist.SetUShortSigAction(joinMap.OutputVideo.JoinNumber + ioSlotJoin, - o => ExecuteNumericSwitch(o, (ushort) ioSlot, eRoutingSignalType.Video)); - trilist.SetUShortSigAction(joinMap.OutputAudio.JoinNumber + ioSlotJoin, - o => ExecuteNumericSwitch(o, (ushort) ioSlot, eRoutingSignalType.Audio)); - trilist.SetUShortSigAction(joinMap.OutputUsb.JoinNumber + ioSlotJoin, - o => ExecuteNumericSwitch(o, (ushort) ioSlot, eRoutingSignalType.UsbOutput)); - trilist.SetUShortSigAction(joinMap.InputUsb.JoinNumber + ioSlotJoin, - o => ExecuteNumericSwitch(o, (ushort) ioSlot, eRoutingSignalType.UsbInput)); - - //Routing Feedbacks - VideoOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputVideo.JoinNumber + ioSlotJoin]); - AudioOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputAudio.JoinNumber + ioSlotJoin]); - UsbOutputRoutedToFeebacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputUsb.JoinNumber + ioSlotJoin]); - UsbInputRoutedToFeebacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.InputUsb.JoinNumber + ioSlotJoin]); - - OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputNames.JoinNumber + ioSlotJoin]); - InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputNames.JoinNumber + ioSlotJoin]); - OutputVideoRouteNameFeedbacks[ioSlot].LinkInputSig( - trilist.StringInput[joinMap.OutputCurrentVideoInputNames.JoinNumber + ioSlotJoin]); - OutputAudioRouteNameFeedbacks[ioSlot].LinkInputSig( - trilist.StringInput[joinMap.OutputCurrentAudioInputNames.JoinNumber + ioSlotJoin]); - - OutputDisabledByHdcpFeedbacks[ioSlot].LinkInputSig( - trilist.BooleanInput[joinMap.OutputDisabledByHdcp.JoinNumber + ioSlotJoin]); - } - - private void LinkChassisToApi(BasicTriList trilist, DmChassisControllerJoinMap joinMap) - { - var chassis = Chassis as DmMDMnxn; - - IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - - trilist.SetUShortSigAction(joinMap.SystemId.JoinNumber, o => - { - if (chassis != null) - { - chassis.SystemId.UShortValue = o; - } - }); - - trilist.SetSigTrueAction(joinMap.SystemId.JoinNumber, () => - { - if (chassis != null) - { - chassis.ApplySystemId(); - } - }); - - SystemIdFeebdack.LinkInputSig(trilist.UShortInput[joinMap.SystemId.JoinNumber]); - SystemIdBusyFeedback.LinkInputSig(trilist.BooleanInput[joinMap.SystemId.JoinNumber]); - - EnableAudioBreakawayFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableAudioBreakaway.JoinNumber]); - EnableUsbBreakawayFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableUsbBreakaway.JoinNumber]); - - trilist.SetString(joinMap.NoRouteName.JoinNumber, NoRouteText); - - trilist.OnlineStatusChange += (o, a) => - { - if (!a.DeviceOnLine) - { - return; - } - - EnableAudioBreakawayFeedback.FireUpdate(); - EnableUsbBreakawayFeedback.FireUpdate(); - SystemIdBusyFeedback.FireUpdate(); - SystemIdFeebdack.FireUpdate(); - - trilist.SetString(joinMap.NoRouteName.JoinNumber, NoRouteText); - }; - } - - private DmChassisControllerJoinMap GetJoinMap(uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new DmChassisControllerJoinMap(joinStart); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - { - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - } - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, - "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - return joinMap; - } - - private void SetHdcpStateAction(bool supportsHdcp2, HdmiInputWithCEC port, uint join, BasicTriList trilist) - { - if (!supportsHdcp2) - { - trilist.SetUShortSigAction(join, - s => - { - if (s == 0) - { - Debug.Console(2, this, "Join {0} value {1} Setting HdcpSupport to off", join, s); - port.HdcpSupportOff(); - } - else if (s > 0) - { - Debug.Console(2, this, "Join {0} value {1} Setting HdcpSupport to on", join, s); - port.HdcpSupportOn(); - } - }); - } - else - { - trilist.SetUShortSigAction(join, - u => - { - Debug.Console(2, this, "Join {0} value {1} Setting HdcpReceiveCapability to: {2}", join, u, (eHdcpCapabilityType)u); - port.HdcpReceiveCapability = (eHdcpCapabilityType)u; - }); - } - } - - private void SetHdcpStateAction(bool supportsHdcp2, EndpointHdmiInput port, uint join, BasicTriList trilist) - { - if (!supportsHdcp2) - { - trilist.SetUShortSigAction(join, - s => - { - if (s == 0) - { - Debug.Console(2, this, "Join {0} value {1} Setting HdcpSupport to off", join, s); - port.HdcpSupportOff(); - } - else if (s > 0) - { - Debug.Console(2, this, "Join {0} value {1} Setting HdcpSupport to on", join, s); - port.HdcpSupportOn(); - } - }); - } - else - { - trilist.SetUShortSigAction(join, - u => - { - Debug.Console(2, this, "Join {0} value {1} Setting HdcpReceiveCapability to: {2}", join, u, (eHdcpCapabilityType)u); - port.HdcpCapability = (eHdcpCapabilityType)u; - }); - } - } - - private void SetHdcpStateAction(bool supportsHdcp2, List ports, uint join, - BasicTriList triList) - { - if (!supportsHdcp2) - { - triList.SetUShortSigAction(join, a => - { - foreach (var tempPort in ports.Select(port => port.Port).OfType()) - { - if (a == 0) - { - tempPort.HdcpSupportOff(); - } - else if (a > 0) - { - tempPort.HdcpSupportOn(); - } - } - }); - } - else - { - triList.SetUShortSigAction(join, a => - { - foreach (var tempPort in ports.Select(port => port.Port).OfType()) - { - tempPort.HdcpCapability = (eHdcpCapabilityType) a; - } - }); - } - } - - private void SetHdcpStateAction(bool supportsHdcp2, DMInputPortWithCec port, uint join, BasicTriList trilist) - { - if (!supportsHdcp2) - { - trilist.SetUShortSigAction(join, - s => - { - if (s == 0) - { - port.HdcpSupportOff(); - } - else if (s > 0) - { - port.HdcpSupportOn(); - } - }); - } - else - { - trilist.SetUShortSigAction(join, - u => - { - port.HdcpReceiveCapability = (eHdcpCapabilityType)u; - }); - } - } - } - - public struct PortNumberType - { - public uint Number { get; private set; } - public object Selector { get; private set; } - public eRoutingSignalType Type { get; private set; } - - public PortNumberType(object selector, eRoutingSignalType type) - : this() - { - Selector = selector; - Type = type; - - if (Selector is DMOutput) - { - Number = (selector as DMOutput).Number; - } - else if (Selector is uint) - { - Number = (uint) selector; - } - } - } - - public class DmChassisControllerFactory : EssentialsDeviceFactory - { - public DmChassisControllerFactory() - { - TypeNames = new List() { "dmmd8x8", "dmmd8x8rps", "dmmd8x8cpu3", "dmmd8x8cpu3rps", - "dmmd16x16", "dmmd16x16rps", "dmmd16x16cpu3", "dmmd16x16cpu3rps", - "dmmd32x32", "dmmd32x32rps", "dmmd32x32cpu3", "dmmd32x32cpu3rps", - "dmmd64x64", "dmmd128x128" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - var type = dc.Type.ToLower(); - - Debug.Console(1, "Factory Attempting to create new DmChassisController Device"); - - if (type.StartsWith("dmmd8x") || type.StartsWith("dmmd16x") || type.StartsWith("dmmd32x")) - { - - var props = JsonConvert.DeserializeObject - (dc.Properties.ToString()); - return DmChassisController. - GetDmChassisController(dc.Key, dc.Name, type, props); - } - else if (type.StartsWith("dmmd128x") || type.StartsWith("dmmd64x")) - { - var props = JsonConvert.DeserializeObject - (dc.Properties.ToString()); - return DmBladeChassisController. - GetDmChassisController(dc.Key, dc.Name, type, props); - } - - return null; - } - } - -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Chassis/DmpsAudioOutputController.cs b/src/PepperDash.Essentials.DM/Chassis/DmpsAudioOutputController.cs deleted file mode 100644 index 291492c9..00000000 --- a/src/PepperDash.Essentials.DM/Chassis/DmpsAudioOutputController.cs +++ /dev/null @@ -1,705 +0,0 @@ -extern alias Full; - -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.Cards; -using Full.Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.DM.Config; - - -namespace PepperDash.Essentials.DM -{ - /// - /// Exposes the volume levels for Program, Aux1, Aux2, Codec1, Codec2, and Digital outputs on a DMPS3 chassis - /// - public class DmpsAudioOutputController : EssentialsBridgeableDevice - { - public DmpsAudioOutput MasterVolumeLevel { get; private set; } - public DmpsAudioOutput SourceVolumeLevel { get; private set; } - public DmpsAudioOutput MicsMasterVolumeLevel { get; private set; } - public DmpsAudioOutput Codec1VolumeLevel { get; private set; } - public DmpsAudioOutput Codec2VolumeLevel { get; private set; } - - public DmpsAudioOutputController(string key, string name, DMOutput card, Card.Dmps3DmHdmiAudioOutput.Dmps3AudioOutputStream stream) - : base(key, name) - { - card.BaseDevice.DMOutputChange += new DMOutputEventHandler(BaseDevice_DMOutputChange); - var output = new Dmps3AudioOutputWithMixerBase(stream); - MasterVolumeLevel = new DmpsAudioOutputWithMixer(output, eDmpsLevelType.Master); - SourceVolumeLevel = new DmpsAudioOutput(output, eDmpsLevelType.Source); - } - public DmpsAudioOutputController(string key, string name, DMOutput card, Card.Dmps3DmHdmiAudioOutput.Dmps3DmHdmiOutputStream stream) - : base(key, name) - { - card.BaseDevice.DMOutputChange += new DMOutputEventHandler(BaseDevice_DMOutputChange); - var output = new Dmps3AudioOutputWithMixerBase(stream); - MasterVolumeLevel = new DmpsAudioOutputWithMixer(output, eDmpsLevelType.Master); - SourceVolumeLevel = new DmpsAudioOutput(output, eDmpsLevelType.Source); - } - - public DmpsAudioOutputController(string key, string name, Card.Dmps3OutputBase card) - : base(key, name) - { - card.BaseDevice.DMOutputChange += new DMOutputEventHandler(BaseDevice_DMOutputChange); - - if (card is Card.Dmps3ProgramOutput) - { - var programOutput = card as Card.Dmps3ProgramOutput; - var output = new Dmps3AudioOutputWithMixerBase(card, programOutput.OutputMixer); - MasterVolumeLevel = new DmpsAudioOutputWithMixerAndEq(output, eDmpsLevelType.Master, programOutput.OutputEqualizer); - SourceVolumeLevel = new DmpsAudioOutput(output, eDmpsLevelType.Source); - MicsMasterVolumeLevel = new DmpsAudioOutput(output, eDmpsLevelType.MicsMaster); - Codec1VolumeLevel = new DmpsAudioOutput(output, eDmpsLevelType.Codec1); - Codec2VolumeLevel = new DmpsAudioOutput(output, eDmpsLevelType.Codec2); - } - else if (card is Card.Dmps3Aux1Output) - { - var auxOutput = card as Card.Dmps3Aux1Output; - var output = new Dmps3AudioOutputWithMixerBase(card, auxOutput.OutputMixer); - MasterVolumeLevel = new DmpsAudioOutputWithMixerAndEq(output, eDmpsLevelType.Master, auxOutput.OutputEqualizer); - SourceVolumeLevel = new DmpsAudioOutput(output, eDmpsLevelType.Source); - MicsMasterVolumeLevel = new DmpsAudioOutput(output, eDmpsLevelType.MicsMaster); - Codec2VolumeLevel = new DmpsAudioOutput(output, eDmpsLevelType.Codec2); - } - else if (card is Card.Dmps3Aux2Output) - { - var auxOutput = card as Card.Dmps3Aux2Output; - var output = new Dmps3AudioOutputWithMixerBase(card, auxOutput.OutputMixer); - MasterVolumeLevel = new DmpsAudioOutputWithMixerAndEq(output, eDmpsLevelType.Master, auxOutput.OutputEqualizer); - SourceVolumeLevel = new DmpsAudioOutput(output, eDmpsLevelType.Source); - MicsMasterVolumeLevel = new DmpsAudioOutput(output, eDmpsLevelType.MicsMaster); - Codec1VolumeLevel = new DmpsAudioOutput(output, eDmpsLevelType.Codec1); - } - else if (card is Card.Dmps3DigitalMixOutput) - { - var mixOutput = card as Card.Dmps3DigitalMixOutput; - var output = new Dmps3AudioOutputWithMixerBase(card, mixOutput.OutputMixer); - MasterVolumeLevel = new DmpsAudioOutputWithMixer(output, eDmpsLevelType.Master); - SourceVolumeLevel = new DmpsAudioOutput(output, eDmpsLevelType.Source); - MicsMasterVolumeLevel = new DmpsAudioOutput(output, eDmpsLevelType.MicsMaster); - } - else if (card is Card.Dmps3HdmiOutput) - { - var hdmiOutput = card as Card.Dmps3HdmiOutput; - var output = new Dmps3AudioOutputWithMixerBase(card, hdmiOutput.OutputMixer); - MasterVolumeLevel = new DmpsAudioOutputWithMixer(output, eDmpsLevelType.Master); - SourceVolumeLevel = new DmpsAudioOutput(output, eDmpsLevelType.Source); - MicsMasterVolumeLevel = new DmpsAudioOutput(output, eDmpsLevelType.MicsMaster); - } - else if (card is Card.Dmps3DmOutput) - { - var dmOutput = card as Card.Dmps3DmOutput; - var output = new Dmps3AudioOutputWithMixerBase(card, dmOutput.OutputMixer); - MasterVolumeLevel = new DmpsAudioOutputWithMixer(output, eDmpsLevelType.Master); - SourceVolumeLevel = new DmpsAudioOutput(output, eDmpsLevelType.Source); - MicsMasterVolumeLevel = new DmpsAudioOutput(output, eDmpsLevelType.MicsMaster); - } - } - - void BaseDevice_DMOutputChange(Switch device, DMOutputEventArgs args) - { - Debug.Console(2, this, "Dmps Audio Controller Event Output: {0} EventId: {1}", args.Number, args.EventId.ToString()); - switch (args.EventId) - { - case DMOutputEventIds.OutputVuFeedBackEventId: - { - //Frequently called event that isn't needed - return; - } - case DMOutputEventIds.MasterVolumeFeedBackEventId: - { - MasterVolumeLevel.VolumeLevelFeedback.FireUpdate(); - MasterVolumeLevel.VolumeLevelScaledFeedback.FireUpdate(); - break; - } - case DMOutputEventIds.MasterMuteOnFeedBackEventId: - { - MasterVolumeLevel.MuteFeedback.FireUpdate(); - break; - } - case DMOutputEventIds.SourceLevelFeedBackEventId: - { - SourceVolumeLevel.VolumeLevelFeedback.FireUpdate(); - SourceVolumeLevel.VolumeLevelScaledFeedback.FireUpdate(); - break; - } - case DMOutputEventIds.SourceMuteOnFeedBackEventId: - { - SourceVolumeLevel.MuteFeedback.FireUpdate(); - break; - } - case DMOutputEventIds.MicMasterLevelFeedBackEventId: - { - MicsMasterVolumeLevel.VolumeLevelFeedback.FireUpdate(); - MicsMasterVolumeLevel.VolumeLevelScaledFeedback.FireUpdate(); - break; - } - case DMOutputEventIds.MicMasterMuteOnFeedBackEventId: - { - MicsMasterVolumeLevel.MuteFeedback.FireUpdate(); - break; - } - case DMOutputEventIds.Codec1LevelFeedBackEventId: - { - if (Codec1VolumeLevel != null) - { - Codec1VolumeLevel.VolumeLevelFeedback.FireUpdate(); - Codec1VolumeLevel.VolumeLevelScaledFeedback.FireUpdate(); - } - break; - } - case DMOutputEventIds.Codec1MuteOnFeedBackEventId: - { - if (Codec1VolumeLevel != null) - Codec1VolumeLevel.MuteFeedback.FireUpdate(); - break; - } - case DMOutputEventIds.Codec2LevelFeedBackEventId: - { - if (Codec2VolumeLevel != null) - { - Codec2VolumeLevel.VolumeLevelFeedback.FireUpdate(); - Codec2VolumeLevel.VolumeLevelScaledFeedback.FireUpdate(); - } - break; - } - case DMOutputEventIds.Codec2MuteOnFeedBackEventId: - { - if (Codec2VolumeLevel != null) - Codec2VolumeLevel.MuteFeedback.FireUpdate(); - break; - } - case DMOutputEventIds.MinVolumeFeedBackEventId: - { - Debug.Console(2, this, "MinVolumeFeedBackEventId: {0}", args.Index); - var level = MasterVolumeLevel as DmpsAudioOutputWithMixer; - if (level != null) - { - level.GetVolumeMin(); - } - break; - } - case DMOutputEventIds.MaxVolumeFeedBackEventId: - { - Debug.Console(2, this, "MaxVolumeFeedBackEventId: {0}", args.Index); - var level = MasterVolumeLevel as DmpsAudioOutputWithMixer; - if (level != null) - { - level.GetVolumeMax(); - } - break; - } - } - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new DmpsAudioOutputControllerJoinMap(joinStart); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - - Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - - if (MasterVolumeLevel != null) - { - SetUpDmpsAudioOutputJoins(trilist, MasterVolumeLevel, joinMap.MasterVolumeLevel.JoinNumber); - var mixer = MasterVolumeLevel as DmpsAudioOutputWithMixer; - if (mixer != null) - { - trilist.SetUShortSigAction(joinMap.MixerPresetRecall.JoinNumber, mixer.RecallPreset); - } - var eq = MasterVolumeLevel as DmpsAudioOutputWithMixerAndEq; - if (eq != null) - { - trilist.SetUShortSigAction(joinMap.MixerEqPresetRecall.JoinNumber, eq.RecallEqPreset); - } - } - - if (SourceVolumeLevel != null) - { - SetUpDmpsAudioOutputJoins(trilist, SourceVolumeLevel, joinMap.SourceVolumeLevel.JoinNumber); - } - - if (MicsMasterVolumeLevel != null) - { - SetUpDmpsAudioOutputJoins(trilist, MicsMasterVolumeLevel, joinMap.MicsMasterVolumeLevel.JoinNumber); - } - - if (Codec1VolumeLevel != null) - { - SetUpDmpsAudioOutputJoins(trilist, Codec1VolumeLevel, joinMap.Codec1VolumeLevel.JoinNumber); - } - - if (Codec2VolumeLevel != null) - { - SetUpDmpsAudioOutputJoins(trilist, Codec2VolumeLevel, joinMap.Codec2VolumeLevel.JoinNumber); - } - } - - static void SetUpDmpsAudioOutputJoins(BasicTriList trilist, DmpsAudioOutput output, uint joinStart) - { - var volumeLevelJoin = joinStart; - var volumeLevelScaledJoin = joinStart + 1; - var muteOnJoin = joinStart; - var muteOffJoin = joinStart + 1; - var volumeUpJoin = joinStart + 2; - var volumeDownJoin = joinStart + 3; - var sendScaledVolumeJoin = joinStart + 4; - - output.VolumeLevelFeedback.LinkInputSig(trilist.UShortInput[volumeLevelJoin]); - output.VolumeLevelScaledFeedback.LinkInputSig(trilist.UShortInput[volumeLevelScaledJoin]); - - trilist.SetSigTrueAction(muteOnJoin, output.MuteOn); - output.MuteFeedback.LinkInputSig(trilist.BooleanInput[muteOnJoin]); - trilist.SetSigTrueAction(muteOffJoin, output.MuteOff); - output.MuteFeedback.LinkComplementInputSig(trilist.BooleanInput[muteOffJoin]); - - trilist.SetBoolSigAction(volumeUpJoin, output.VolumeUp); - trilist.SetBoolSigAction(volumeDownJoin, output.VolumeDown); - trilist.SetBoolSigAction(sendScaledVolumeJoin, output.SendScaledVolume); - trilist.SetUShortSigAction(volumeLevelJoin, output.SetVolume); - trilist.SetUShortSigAction(volumeLevelScaledJoin, output.SetVolumeScaled); - } - } - - public class DmpsAudioOutputWithMixerAndEq : DmpsAudioOutputWithMixer - { - private CrestronControlSystem.Dmps3OutputEqualizer Eq; - public DmpsAudioOutputWithMixerAndEq(Dmps3AudioOutputWithMixerBase output, eDmpsLevelType type, CrestronControlSystem.Dmps3OutputEqualizer eq) - : base(output, type) - { - Eq = eq; - } - - public void RecallEqPreset(ushort preset) - { - Eq.PresetNumber.UShortValue = preset; - Eq.RecallPreset(); - } - } - - public class DmpsAudioOutputWithMixer : DmpsAudioOutput - { - Dmps3AudioOutputWithMixerBase Output; - - public DmpsAudioOutputWithMixer(Dmps3AudioOutputWithMixerBase output, eDmpsLevelType type) - : base(output, type) - { - Output = output; - GetVolumeMax(); - GetVolumeMin(); - } - - public void GetVolumeMin() - { - MinLevel = (short)Output.MinVolumeFeedback.UShortValue; - if (VolumeLevelScaledFeedback != null) - { - VolumeLevelScaledFeedback.FireUpdate(); - } - } - - public void GetVolumeMax() - { - MaxLevel = (short)Output.MaxVolumeFeedback.UShortValue; - if (VolumeLevelScaledFeedback != null) - { - VolumeLevelScaledFeedback.FireUpdate(); - } - } - - public void RecallPreset(ushort preset) - { - Output.PresetNumber.UShortValue = preset; - Output.RecallPreset(); - - if (!Global.ControlSystemIsDmps4k3xxType) - { - //Recall startup volume for main volume level as DMPS3(non-4K) presets don't affect the main volume - RecallStartupVolume(); - } - } - - public void RecallStartupVolume() - { - ushort startupVol = Output.StartupVolumeFeedback.UShortValue; - //Reset startup vol due to bug on DMPS3 where getting the value from above method clears the startup volume - Output.StartupVolume.UShortValue = startupVol; - Debug.Console(1, "DMPS Recalling Startup Volume {0}", startupVol); - SetVolume(startupVol); - MuteOff(); - } - } - - public class DmpsAudioOutput : IBasicVolumeWithFeedback - { - private UShortInputSig Level; - private bool EnableVolumeSend; - private ushort VolumeLevelInput; - protected short MinLevel { get; set; } - protected short MaxLevel { get; set; } - - public eDmpsLevelType Type { get; private set; } - public BoolFeedback MuteFeedback { get; private set; } - public IntFeedback VolumeLevelFeedback { get; private set; } - public IntFeedback VolumeLevelScaledFeedback { get; private set; } - - Action MuteOnAction; - Action MuteOffAction; - Action VolumeUpAction; - Action VolumeDownAction; - - public DmpsAudioOutput(Dmps3AudioOutputBase output, eDmpsLevelType type) - { - VolumeLevelInput = 0; - EnableVolumeSend = false; - Type = type; - MinLevel = -800; - MaxLevel = 100; - - switch (type) - { - case eDmpsLevelType.Master: - { - Level = output.MasterVolume; - MuteFeedback = new BoolFeedback(new Func(() => output.MasterMuteOnFeedBack.BoolValue)); - VolumeLevelFeedback = new IntFeedback(new Func(() => output.MasterVolumeFeedBack.UShortValue)); - MuteOnAction = new Action(output.MasterMuteOn); - MuteOffAction = new Action(output.MasterMuteOff); - VolumeUpAction = new Action((b) => output.MasterVolumeUp.BoolValue = b); - VolumeDownAction = new Action((b) => output.MasterVolumeDown.BoolValue = b); - break; - } - case eDmpsLevelType.MicsMaster: - { - if (output.Card is Card.Dmps3OutputBase) - { - var micOutput = output.Card as Card.Dmps3OutputBase; - Level = micOutput.MicMasterLevel; - MuteFeedback = new BoolFeedback(new Func(() => micOutput.MicMasterMuteOnFeedBack.BoolValue)); - VolumeLevelFeedback = new IntFeedback(new Func(() => micOutput.MicMasterLevelFeedBack.UShortValue)); - MuteOnAction = new Action(micOutput.MicMasterMuteOn); - MuteOffAction = new Action(micOutput.MicMasterMuteOff); - VolumeUpAction = new Action((b) => micOutput.MicMasterLevelUp.BoolValue = b); - VolumeDownAction = new Action((b) => micOutput.MicMasterLevelDown.BoolValue = b); - } - break; - } - case eDmpsLevelType.Source: - { - Level = output.SourceLevel; - MuteFeedback = new BoolFeedback(new Func(() => output.SourceMuteOnFeedBack.BoolValue)); - VolumeLevelFeedback = new IntFeedback(new Func(() => output.SourceLevelFeedBack.UShortValue)); - MuteOnAction = new Action(output.SourceMuteOn); - MuteOffAction = new Action(output.SourceMuteOff); - VolumeUpAction = new Action((b) => output.SourceLevelUp.BoolValue = b); - VolumeDownAction = new Action((b) => output.SourceLevelDown.BoolValue = b); - break; - } - case eDmpsLevelType.Codec1: - { - if (output.Card is Card.Dmps3ProgramOutput) - { - var programOutput = output.Card as Card.Dmps3ProgramOutput; - Level = programOutput.Codec1Level; - MuteFeedback = new BoolFeedback(new Func(() => programOutput.CodecMute1OnFeedback.BoolValue)); - VolumeLevelFeedback = new IntFeedback(new Func(() => programOutput.Codec1LevelFeedback.UShortValue)); - MuteOnAction = new Action(programOutput.Codec1MuteOn); - MuteOffAction = new Action(programOutput.Codec1MuteOff); - VolumeUpAction = new Action((b) => programOutput.Codec1LevelUp.BoolValue = b); - VolumeDownAction = new Action((b) => programOutput.Codec1LevelDown.BoolValue = b); - } - else if (output.Card is Card.Dmps3Aux2Output) - { - var auxOutput = output.Card as Card.Dmps3Aux2Output; - Level = auxOutput.Codec1Level; - MuteFeedback = new BoolFeedback(new Func(() => auxOutput.CodecMute1OnFeedback.BoolValue)); - VolumeLevelFeedback = new IntFeedback(new Func(() => auxOutput.Codec1LevelFeedback.UShortValue)); - MuteOnAction = new Action(auxOutput.Codec1MuteOn); - MuteOffAction = new Action(auxOutput.Codec1MuteOff); - VolumeUpAction = new Action((b) => auxOutput.Codec1LevelUp.BoolValue = b); - VolumeDownAction = new Action((b) => auxOutput.Codec1LevelDown.BoolValue = b); - } - break; - } - case eDmpsLevelType.Codec2: - { - if (output.Card is Card.Dmps3ProgramOutput) - { - var programOutput = output.Card as Card.Dmps3ProgramOutput; - Level = programOutput.Codec2Level; - MuteFeedback = new BoolFeedback(new Func(() => programOutput.CodecMute1OnFeedback.BoolValue)); - VolumeLevelFeedback = new IntFeedback(new Func(() => programOutput.Codec2LevelFeedback.UShortValue)); - MuteOnAction = new Action(programOutput.Codec2MuteOn); - MuteOffAction = new Action(programOutput.Codec2MuteOff); - VolumeUpAction = new Action((b) => programOutput.Codec2LevelUp.BoolValue = b); - VolumeDownAction = new Action((b) => programOutput.Codec2LevelDown.BoolValue = b); - } - else if (output.Card is Card.Dmps3Aux1Output) - { - var auxOutput = output.Card as Card.Dmps3Aux1Output; - - Level = auxOutput.Codec2Level; - MuteFeedback = new BoolFeedback(new Func(() => auxOutput.CodecMute2OnFeedback.BoolValue)); - VolumeLevelFeedback = new IntFeedback(new Func(() => auxOutput.Codec2LevelFeedback.UShortValue)); - MuteOnAction = new Action(auxOutput.Codec2MuteOn); - MuteOffAction = new Action(auxOutput.Codec2MuteOff); - VolumeUpAction = new Action((b) => auxOutput.Codec2LevelUp.BoolValue = b); - VolumeDownAction = new Action((b) => auxOutput.Codec2LevelDown.BoolValue = b); - } - break; - } - } - if (VolumeLevelFeedback != null) - { - VolumeLevelScaledFeedback = new IntFeedback(new Func(() => ScaleVolumeFeedback(VolumeLevelFeedback.UShortValue))); - VolumeLevelFeedback.FireUpdate(); - VolumeLevelScaledFeedback.FireUpdate(); - } - } - - public void SetVolumeScaled(ushort level) - { - if (ushort.MaxValue + MinLevel != 0) - { - VolumeLevelInput = (ushort)(level * (MaxLevel - MinLevel) / ushort.MaxValue + MinLevel); - if (EnableVolumeSend == true) - { - Level.UShortValue = VolumeLevelInput; - } - } - } - - public ushort ScaleVolumeFeedback(ushort level) - { - short signedLevel = (short)level; - - if (MaxLevel - MinLevel != 0) - { - return (ushort)((signedLevel - MinLevel) * ushort.MaxValue / (MaxLevel - MinLevel)); - } - else - return (ushort)MinLevel; - } - - public void SendScaledVolume(bool pressRelease) - { - EnableVolumeSend = pressRelease; - if (pressRelease == false) - { - SetVolumeScaled(VolumeLevelInput); - } - } - - #region IBasicVolumeWithFeedback Members - - public void SetVolume(ushort level) - { - Level.UShortValue = level; - } - - public void MuteOn() - { - MuteOnAction(); - } - - public void MuteOff() - { - MuteOffAction(); - } - - #endregion - - #region IBasicVolumeControls Members - - public void VolumeUp(bool pressRelease) - { - VolumeUpAction(pressRelease); - } - - public void VolumeDown(bool pressRelease) - { - VolumeDownAction(pressRelease); - } - - public void MuteToggle() - { - if (MuteFeedback.BoolValue) - MuteOff(); - else - MuteOn(); - } - - #endregion - } - - public class Dmps3AudioOutputWithMixerBase : Dmps3AudioOutputBase - { - public UShortOutputSig MinVolumeFeedback { get; private set; } - public UShortOutputSig MaxVolumeFeedback { get; private set; } - public UShortInputSig StartupVolume { get; private set; } - public UShortOutputSig StartupVolumeFeedback { get; private set; } - public UShortInputSig PresetNumber { get; private set; } - - public Action RecallPreset { get; private set; } - - public Dmps3AudioOutputWithMixerBase(Card.Dmps3OutputBase card, CrestronControlSystem.Dmps3OutputMixer mixer) - : base(card) - { - MinVolumeFeedback = mixer.MinVolumeFeedback; - MaxVolumeFeedback = mixer.MaxVolumeFeedback; - StartupVolume = mixer.StartupVolume; - StartupVolumeFeedback = mixer.StartupVolumeFeedback; - PresetNumber = mixer.PresetNumber; - - RecallPreset = new Action(mixer.RecallPreset); - } - - public Dmps3AudioOutputWithMixerBase(Card.Dmps3OutputBase card, CrestronControlSystem.Dmps3AttachableOutputMixer mixer) - : base(card) - { - MinVolumeFeedback = mixer.MinVolumeFeedback; - MaxVolumeFeedback = mixer.MaxVolumeFeedback; - StartupVolume = mixer.StartupVolume; - StartupVolumeFeedback = mixer.StartupVolumeFeedback; - PresetNumber = mixer.PresetNumber; - - RecallPreset = new Action(mixer.RecallPreset); - } - - public Dmps3AudioOutputWithMixerBase(Card.Dmps3DmHdmiAudioOutput.Dmps3AudioOutputStream stream) - : base(stream) - { - var mixer = stream.OutputMixer; - MinVolumeFeedback = mixer.MinVolumeFeedback; - MaxVolumeFeedback = mixer.MaxVolumeFeedback; - StartupVolume = mixer.StartupVolume; - StartupVolumeFeedback = mixer.StartupVolumeFeedback; - PresetNumber = stream.PresetNumber; - RecallPreset = new Action(stream.RecallPreset); - } - - public Dmps3AudioOutputWithMixerBase(Card.Dmps3DmHdmiAudioOutput.Dmps3DmHdmiOutputStream stream) - : base(stream) - { - var mixer = stream.OutputMixer; - MinVolumeFeedback = mixer.MinVolumeFeedback; - MaxVolumeFeedback = mixer.MaxVolumeFeedback; - StartupVolume = mixer.StartupVolume; - StartupVolumeFeedback = mixer.StartupVolumeFeedback; - PresetNumber = stream.PresetNumber; - RecallPreset = new Action(stream.RecallPreset); - } - } - public class Dmps3AudioOutputBase - { - public DMOutput Card { get; private set; } - public BoolOutputSig MasterMuteOffFeedBack { get; private set; } - public BoolOutputSig MasterMuteOnFeedBack { get; private set; } - public UShortInputSig MasterVolume { get; private set; } - public UShortOutputSig MasterVolumeFeedBack { get; private set; } - public BoolInputSig MasterVolumeUp { get; private set; } - public BoolInputSig MasterVolumeDown { get; private set; } - public BoolOutputSig SourceMuteOffFeedBack { get; private set; } - public BoolOutputSig SourceMuteOnFeedBack { get; private set; } - public UShortInputSig SourceLevel { get; private set; } - public UShortOutputSig SourceLevelFeedBack { get; private set; } - public BoolInputSig SourceLevelUp { get; private set; } - public BoolInputSig SourceLevelDown { get; private set; } - - public Action MasterMuteOff { get; private set; } - public Action MasterMuteOn { get; private set; } - public Action SourceMuteOff { get; private set; } - public Action SourceMuteOn { get; private set; } - - public Dmps3AudioOutputBase(Card.Dmps3OutputBase card) - { - Card = card; - MasterMuteOffFeedBack = card.MasterMuteOffFeedBack; - MasterMuteOnFeedBack = card.MasterMuteOnFeedBack; - MasterVolume = card.MasterVolume; - MasterVolumeFeedBack = card.MasterVolumeFeedBack; - MasterVolumeUp = card.MasterVolumeUp; - MasterVolumeDown = card.MasterVolumeDown; - SourceMuteOffFeedBack = card.SourceMuteOffFeedBack; - SourceMuteOnFeedBack = card.SourceMuteOnFeedBack; - SourceLevel = card.SourceLevel; - SourceLevelFeedBack = card.SourceLevelFeedBack; - SourceLevelUp = card.SourceLevelUp; - SourceLevelDown = card.SourceLevelDown; - - MasterMuteOff = new Action(card.MasterMuteOff); - MasterMuteOn = new Action(card.MasterMuteOn); - SourceMuteOff = new Action(card.SourceMuteOff); - SourceMuteOn = new Action(card.SourceMuteOn); - } - - public Dmps3AudioOutputBase(Card.Dmps3DmHdmiAudioOutput.Dmps3AudioOutputStream stream) - { - MasterMuteOffFeedBack = stream.MasterMuteOffFeedBack; - MasterMuteOnFeedBack = stream.MasterMuteOnFeedBack; - MasterVolume = stream.MasterVolume; - MasterVolumeFeedBack = stream.MasterVolumeFeedBack; - MasterVolumeUp = stream.MasterVolumeUp; - MasterVolumeDown = stream.MasterVolumeDown; - SourceMuteOffFeedBack = stream.SourceMuteOffFeedBack; - SourceMuteOnFeedBack = stream.SourceMuteOnFeedBack; - SourceLevel = stream.SourceLevel; - SourceLevelFeedBack = stream.SourceLevelFeedBack; - SourceLevelUp = stream.SourceLevelUp; - SourceLevelDown = stream.SourceLevelDown; - - MasterMuteOff = new Action(stream.MasterMuteOff); - MasterMuteOn = new Action(stream.MasterMuteOn); - SourceMuteOff = new Action(stream.SourceMuteOff); - SourceMuteOn = new Action(stream.SourceMuteOn); - } - - public Dmps3AudioOutputBase(Card.Dmps3DmHdmiAudioOutput.Dmps3DmHdmiOutputStream stream) - { - MasterMuteOffFeedBack = stream.MasterMuteOffFeedBack; - MasterMuteOnFeedBack = stream.MasterMuteOnFeedBack; - MasterVolume = stream.MasterVolume; - MasterVolumeFeedBack = stream.MasterVolumeFeedBack; - MasterVolumeUp = stream.MasterVolumeUp; - MasterVolumeDown = stream.MasterVolumeDown; - SourceMuteOffFeedBack = stream.SourceMuteOffFeedBack; - SourceMuteOnFeedBack = stream.SourceMuteOnFeedBack; - SourceLevel = stream.SourceLevel; - SourceLevelFeedBack = stream.SourceLevelFeedBack; - SourceLevelUp = stream.SourceLevelUp; - SourceLevelDown = stream.SourceLevelDown; - - MasterMuteOff = new Action(stream.MasterMuteOff); - MasterMuteOn = new Action(stream.MasterMuteOn); - SourceMuteOff = new Action(stream.SourceMuteOff); - SourceMuteOn = new Action(stream.SourceMuteOn); - } - } - - public enum eDmpsLevelType - { - Master, - Source, - MicsMaster, - Codec1, - Codec2, - Mic - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Chassis/DmpsDigitalOutputController.cs b/src/PepperDash.Essentials.DM/Chassis/DmpsDigitalOutputController.cs deleted file mode 100644 index 70465783..00000000 --- a/src/PepperDash.Essentials.DM/Chassis/DmpsDigitalOutputController.cs +++ /dev/null @@ -1,165 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Cards; - -using PepperDash.Core; -using PepperDash.Essentials.Core; - - -namespace PepperDash.Essentials.DM -{ - /// - /// - /// - public class DmpsDigitalOutputController : Device, IRoutingNumeric, IHasFeedback - { - public Card.Dmps3OutputBase OutputCard { get; protected set; } - - public RoutingInputPort None { get; protected set; } - public RoutingInputPort DigitalMix1 { get; protected set; } - public RoutingInputPort DigitalMix2 { get; protected set; } - public RoutingInputPort AudioFollowsVideo { get; protected set; } - - public RoutingOutputPort DigitalAudioOut { get; protected set; } - - public IntFeedback AudioSourceNumericFeedback { get; protected set; } - - /// - /// Returns a list containing the Outputs that we want to expose. - /// - public FeedbackCollection Feedbacks { get; private set; } - - public virtual RoutingPortCollection InputPorts - { - get - { - return new RoutingPortCollection - { - None, - DigitalMix1, - DigitalMix2, - AudioFollowsVideo - }; - } - } - - public RoutingPortCollection OutputPorts - { - get - { - return new RoutingPortCollection { DigitalAudioOut }; - } - } - - public DmpsDigitalOutputController(string key, string name, Card.Dmps3OutputBase outputCard) - : base(key, name) - { - Feedbacks = new FeedbackCollection(); - OutputCard = outputCard; - - if (outputCard is Card.Dmps3DmOutputBackend) - { - AudioSourceNumericFeedback = new IntFeedback(() => - { - return (int)(outputCard as Card.Dmps3DmOutputBackend).AudioOutSourceDeviceFeedback; - }); - DigitalAudioOut = new RoutingOutputPort(DmPortName.DmOut + OutputCard.Number, eRoutingSignalType.Audio, eRoutingPortConnectionType.DmCat, null, this); - } - - else if (outputCard is Card.Dmps3HdmiOutputBackend) - { - AudioSourceNumericFeedback = new IntFeedback(() => - { - return (int)(outputCard as Card.Dmps3HdmiOutputBackend).AudioOutSourceDeviceFeedback; - }); - DigitalAudioOut = new RoutingOutputPort(DmPortName.HdmiOut + OutputCard.Number, eRoutingSignalType.Audio, eRoutingPortConnectionType.Hdmi, null, this); - } - else - { - return; - } - - None = new RoutingInputPort("None", eRoutingSignalType.Audio, eRoutingPortConnectionType.DigitalAudio, - eDmps34KAudioOutSourceDevice.NoRoute, this); - DigitalMix1 = new RoutingInputPort("DigitalMix1", eRoutingSignalType.Audio, eRoutingPortConnectionType.DigitalAudio, - eDmps34KAudioOutSourceDevice.DigitalMixer1, this); - DigitalMix2 = new RoutingInputPort("DigitalMix2", eRoutingSignalType.Audio, eRoutingPortConnectionType.DigitalAudio, - eDmps34KAudioOutSourceDevice.DigitalMixer2, this); - AudioFollowsVideo = new RoutingInputPort("AudioFollowsVideo", eRoutingSignalType.Audio, eRoutingPortConnectionType.DigitalAudio, - eDmps34KAudioOutSourceDevice.AudioFollowsVideo, this); - - AddToFeedbackList(AudioSourceNumericFeedback); - } - - /// - /// Adds feedback(s) to the list - /// - /// - public void AddToFeedbackList(params Feedback[] newFbs) - { - foreach (var f in newFbs) - { - if (f != null) - { - if (!Feedbacks.Contains(f)) - { - Feedbacks.Add(f); - } - } - } - } - - public virtual void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) - { - Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); - - switch (input) - { - case 0: - { - ExecuteSwitch(None.Selector, null, type); - break; - } - case 1: - { - ExecuteSwitch(DigitalMix1.Selector, null, type); - break; - } - case 2: - { - ExecuteSwitch(DigitalMix2.Selector, null, type); - break; - } - case 3: - { - ExecuteSwitch(AudioFollowsVideo.Selector, null, type); - break; - } - } - - } - - #region IRouting Members - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) - { - if (OutputCard is Card.Dmps3DmOutputBackend) - { - (OutputCard as Card.Dmps3DmOutputBackend).AudioOutSourceDevice = (eDmps34KAudioOutSourceDevice)inputSelector; - } - else if (OutputCard is Card.Dmps3HdmiOutputBackend) - { - (OutputCard as Card.Dmps3HdmiOutputBackend).AudioOutSourceDevice = (eDmps34KAudioOutSourceDevice)inputSelector; - } - } - } - - #endregion - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Chassis/DmpsInternalVirtualDmTxController.cs b/src/PepperDash.Essentials.DM/Chassis/DmpsInternalVirtualDmTxController.cs deleted file mode 100644 index c9c2f261..00000000 --- a/src/PepperDash.Essentials.DM/Chassis/DmpsInternalVirtualDmTxController.cs +++ /dev/null @@ -1,458 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Cards; - -using PepperDash.Core; -using PepperDash.Essentials.Core; - - -namespace PepperDash.Essentials.DM -{ - /// - /// - /// - public class DmpsInternalVirtualHdmiVgaInputController : Device, ITxRouting, IHasFeedback - { - public Card.Dmps3HdmiVgaInput InputCard { get; protected set; } - - public eHdcpCapabilityType HdcpSupportCapability { get; protected set; } - public StringFeedback ActiveVideoInputFeedback { get; protected set; } - - public RoutingInputPortWithVideoStatuses HdmiIn { get; protected set; } - public RoutingInputPortWithVideoStatuses VgaIn { get; protected set; } - public RoutingInputPort AudioIn { get; protected set; } - public RoutingInputPortWithVideoStatuses AnyVideoInput { get; protected set; } - - public RoutingOutputPort VirtualDmOut { get; protected set; } - - public IntFeedback VideoSourceNumericFeedback { get; protected set; } - public IntFeedback AudioSourceNumericFeedback { get; protected set; } - public IntFeedback HdmiInHdcpCapabilityFeedback { get; protected set; } - - /// - /// Returns a list containing the Outputs that we want to expose. - /// - public FeedbackCollection Feedbacks { get; private set; } - - public void SetPortHdcpCapability(eHdcpCapabilityType hdcpMode, uint port) { } - - /// - /// Helps get the "real" inputs, including when in Auto - /// - public eDmps3InputVideoSource ActualVideoInput - { - get - { - try - { - if (InputCard.VideoSourceFeedback != eDmps3InputVideoSource.Auto) - return InputCard.VideoSourceFeedback; - else // auto - { - if (InputCard.HdmiInputPort.SyncDetectedFeedback.BoolValue) - return eDmps3InputVideoSource.Hdmi; - else if (InputCard.VgaInputPort.SyncDetectedFeedback.BoolValue) - return eDmps3InputVideoSource.Vga; - else - return eDmps3InputVideoSource.Bnc; - } - } - catch - { - return eDmps3InputVideoSource.Bnc; - } - } - } - - public virtual RoutingPortCollection InputPorts - { - get - { - return new RoutingPortCollection - { - HdmiIn, - VgaIn, - AudioIn, - AnyVideoInput - }; - } - } - - public RoutingPortCollection OutputPorts - { - get - { - return new RoutingPortCollection { VirtualDmOut }; - } - } - - public DmpsInternalVirtualHdmiVgaInputController(string key, string name, DMInput inputCard) - : base(key, name) - { - Feedbacks = new FeedbackCollection(); - - if (inputCard is Card.Dmps3HdmiVgaInput) - { - InputCard = inputCard as Card.Dmps3HdmiVgaInput; - - HdmiIn = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, - eDmps3InputVideoSource.Hdmi, this, VideoStatusHelper.GetHdmiInputStatusFuncs(InputCard.HdmiInputPort)); - VgaIn = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn, - eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, eDmps3InputVideoSource.Vga, this, - VideoStatusHelper.GetVgaInputStatusFuncs(InputCard.VgaInputPort)); - AudioIn = new RoutingInputPort(DmPortName.AudioIn, eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio, - eDmps3InputAudioSource.Analog, this); - - if (InputCard.HdmiInputPort.HdcpSupportedLevelFeedback == eHdcpSupportedLevel.Hdcp2xSupport) - HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support; - else if (InputCard.HdmiInputPort.HdcpSupportedLevelFeedback == eHdcpSupportedLevel.Hdcp1xSupport) - HdcpSupportCapability = eHdcpCapabilityType.Hdcp1xSupport; - - var combinedFuncs = new VideoStatusFuncsWrapper - { - HdcpActiveFeedbackFunc = () => - (ActualVideoInput == eDmps3InputVideoSource.Hdmi - && InputCard.HdmiInputPort.VideoAttributes.HdcpActiveFeedback.BoolValue), - - HdcpStateFeedbackFunc = () => - { - if (ActualVideoInput == eDmps3InputVideoSource.Hdmi) - return InputCard.HdmiInputPort.VideoAttributes.HdcpStateFeedback.ToString(); - return ""; - }, - - VideoResolutionFeedbackFunc = () => - { - if (ActualVideoInput == eDmps3InputVideoSource.Hdmi) - return InputCard.HdmiInputPort.VideoAttributes.GetVideoResolutionString(); - if (ActualVideoInput == eDmps3InputVideoSource.Vga) - return InputCard.VgaInputPort.VideoAttributes.GetVideoResolutionString(); - return ""; - }, - VideoSyncFeedbackFunc = () => - (ActualVideoInput == eDmps3InputVideoSource.Hdmi - && InputCard.HdmiInputPort.SyncDetectedFeedback.BoolValue) - || (ActualVideoInput == eDmps3InputVideoSource.Vga - && InputCard.VgaInputPort.SyncDetectedFeedback.BoolValue), - - HasVideoStatusFunc = () => - (ActualVideoInput == eDmps3InputVideoSource.Hdmi - && HdmiIn.VideoStatus.HasVideoStatusFeedback.BoolValue) - || (ActualVideoInput == eDmps3InputVideoSource.Vga - && VgaIn.VideoStatus.HasVideoStatusFeedback.BoolValue) - }; - - AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, eDmps3InputVideoSource.Auto, this, combinedFuncs); - - ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", () => ActualVideoInput.ToString()); - - VideoSourceNumericFeedback = new IntFeedback(() => - { - return (int)InputCard.VideoSourceFeedback; - }); - AudioSourceNumericFeedback = new IntFeedback(() => - { - return (int)InputCard.AudioSourceFeedback; - }); - - HdmiInHdcpCapabilityFeedback = new IntFeedback("HdmiInHdcpCapability", () => - { - if (InputCard.HdmiInputPort.HdcpSupportOnFeedback.BoolValue) - return 1; - else - return 0; - }); - - // Set Ports for CEC - HdmiIn.Port = InputCard.HdmiInputPort; - - VirtualDmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.None, null, this); - - AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, - AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, - AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, - AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiInHdcpCapabilityFeedback); - - //AddPostActivationAction(() => - //{ - // Link up all of these damned events to the various RoutingPorts via a helper handler - InputCard.HdmiInputPort.InputOutput.BaseDevice.BaseEvent += (o, a) => FowardInputStreamChange(HdmiIn, a.EventId); - InputCard.HdmiInputPort.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn, a.EventId); - - InputCard.VgaInputPort.InputOutput.BaseDevice.BaseEvent += (o, a) => FowardInputStreamChange(VgaIn, a.EventId); - InputCard.VgaInputPort.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(VgaIn, a.EventId); - //}); - - } - - } - - /// - /// Relays the input stream change to the appropriate RoutingInputPort. - /// - protected void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - if (eventId == Crestron.SimplSharpPro.DM.DMInputEventIds.SourceSyncEventId) - { - inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); - } - } - - /// - /// Relays the VideoAttributes change to a RoutingInputPort - /// - protected void ForwardVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - switch (eventId) - { - case VideoAttributeEventIds.HdcpActiveFeedbackEventId: - inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HdcpStateFeedbackEventId: - inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: - case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - } - } - - /// - /// Adds feedback(s) to the list - /// - /// - public void AddToFeedbackList(params Feedback[] newFbs) - { - foreach (var f in newFbs) - { - if (f != null) - { - if (!Feedbacks.Contains(f)) - { - Feedbacks.Add(f); - } - } - } - } - - #region ITxRouting Members - - - public virtual void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) - { - Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); - - switch (input) - { - case 0: - { - ExecuteSwitch(eDmps3InputVideoSource.Auto, null, type); - break; - } - case 1: - { - ExecuteSwitch(HdmiIn.Selector, null, type); - break; - } - case 2: - { - ExecuteSwitch(VgaIn.Selector, null, type); - break; - } - } - - } - - #endregion - - #region IRouting Members - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - if ((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video) - InputCard.VideoSource = (eDmps3InputVideoSource)inputSelector; - if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) - InputCard.AudioSource = (eDmps3InputAudioSource)inputSelector; - } - - #endregion - } - - /// - /// - /// - public class DmpsInternalVirtualHdmiVgaBncInputController : DmpsInternalVirtualHdmiVgaInputController - { - public new Card.Dmps3HdmiVgaBncInput InputCard { get; private set; } - - public RoutingInputPortWithVideoStatuses BncIn { get; private set; } - public RoutingInputPort SpdifIn { get; private set; } - - public override RoutingPortCollection InputPorts - { - get - { - return new RoutingPortCollection - { - HdmiIn, - VgaIn, - BncIn, - SpdifIn, - AnyVideoInput - }; - } - } - - public DmpsInternalVirtualHdmiVgaBncInputController(string key, string name, Card.Dmps3HdmiVgaBncInput inputCard) - : base(key, name, inputCard) - { - InputCard = inputCard; - - HdmiIn = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, - eDmps3InputVideoSource.Hdmi, this, VideoStatusHelper.GetHdmiInputStatusFuncs(InputCard.HdmiInputPort)); - VgaIn = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn, - eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, eDmps3InputVideoSource.Vga, this, - VideoStatusHelper.GetVgaInputStatusFuncs(InputCard.VgaInputPort)); - BncIn = new RoutingInputPortWithVideoStatuses(DmPortName.BncIn, eRoutingSignalType.Video, eRoutingPortConnectionType.Component, - eDmps3InputVideoSource.Bnc, this, VideoStatusHelper.GetBncInputStatusFuncs(InputCard.BncInputPort)); - SpdifIn = new RoutingInputPort(DmPortName.SpdifIn, eRoutingSignalType.Audio, eRoutingPortConnectionType.DigitalAudio, - eDmps3InputAudioSource.Spdif, this); - - if (InputCard.HdmiInputPort.HdcpSupportedLevelFeedback == eHdcpSupportedLevel.Hdcp2xSupport) - HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support; - else if (InputCard.HdmiInputPort.HdcpSupportedLevelFeedback == eHdcpSupportedLevel.Hdcp1xSupport) - HdcpSupportCapability = eHdcpCapabilityType.Hdcp1xSupport; - - var combinedFuncs = new VideoStatusFuncsWrapper - { - HdcpActiveFeedbackFunc = () => - (ActualVideoInput == eDmps3InputVideoSource.Hdmi - && InputCard.HdmiInputPort.VideoAttributes.HdcpActiveFeedback.BoolValue), - - HdcpStateFeedbackFunc = () => - { - if (ActualVideoInput == eDmps3InputVideoSource.Hdmi) - return InputCard.HdmiInputPort.VideoAttributes.HdcpStateFeedback.ToString(); - return ""; - }, - - VideoResolutionFeedbackFunc = () => - { - if (ActualVideoInput == eDmps3InputVideoSource.Hdmi) - return InputCard.HdmiInputPort.VideoAttributes.GetVideoResolutionString(); - if (ActualVideoInput == eDmps3InputVideoSource.Vga) - return InputCard.VgaInputPort.VideoAttributes.GetVideoResolutionString(); - if (ActualVideoInput == eDmps3InputVideoSource.Bnc) - return InputCard.BncInputPort.VideoAttributes.GetVideoResolutionString(); - return ""; - }, - VideoSyncFeedbackFunc = () => - (ActualVideoInput == eDmps3InputVideoSource.Hdmi - && InputCard.HdmiInputPort.SyncDetectedFeedback.BoolValue) - || (ActualVideoInput == eDmps3InputVideoSource.Vga - && InputCard.VgaInputPort.SyncDetectedFeedback.BoolValue) - || (ActualVideoInput == eDmps3InputVideoSource.Bnc - && InputCard.BncInputPort.VideoDetectedFeedback.BoolValue), - - HasVideoStatusFunc = () => - (ActualVideoInput == eDmps3InputVideoSource.Hdmi - && HdmiIn.VideoStatus.HasVideoStatusFeedback.BoolValue) - || (ActualVideoInput == eDmps3InputVideoSource.Vga - && VgaIn.VideoStatus.HasVideoStatusFeedback.BoolValue) - || (ActualVideoInput == eDmps3InputVideoSource.Bnc - &&BncIn.VideoStatus.HasVideoStatusFeedback.BoolValue) - }; - - AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs); - - ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", () => ActualVideoInput.ToString()); - - VideoSourceNumericFeedback = new IntFeedback(() => - { - return (int)InputCard.VideoSourceFeedback; - }); - AudioSourceNumericFeedback = new IntFeedback(() => - { - return (int)InputCard.AudioSourceFeedback; - }); - - HdmiInHdcpCapabilityFeedback = new IntFeedback("HdmiInHdcpCapability", () => - { - if (InputCard.HdmiInputPort.HdcpSupportOnFeedback.BoolValue) - return 1; - else - return 0; - }); - - // Set Ports for CEC - HdmiIn.Port = InputCard.HdmiInputPort; - - VirtualDmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.None, null, this); - - AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, - AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, - AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, - AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiInHdcpCapabilityFeedback); - - //AddPostActivationAction(() => - //{ - // Link up all of these damned events to the various RoutingPorts via a helper handler - InputCard.HdmiInputPort.InputOutput.BaseDevice.BaseEvent += (o, a) => FowardInputStreamChange(HdmiIn, a.EventId); - InputCard.HdmiInputPort.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn, a.EventId); - - InputCard.VgaInputPort.InputOutput.BaseDevice.BaseEvent += (o, a) => FowardInputStreamChange(VgaIn, a.EventId); - InputCard.VgaInputPort.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(VgaIn, a.EventId); - - InputCard.BncInputPort.InputOutput.BaseDevice.BaseEvent += (o, a) => FowardInputStreamChange(HdmiIn, a.EventId); - InputCard.BncInputPort.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn, a.EventId); - //}); - - } - - public override void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) - { - Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); - - switch (input) - { - case 0: - { - ExecuteSwitch(eDmps3InputVideoSource.Auto, null, type); - break; - } - case 1: - { - ExecuteSwitch(HdmiIn.Selector, null, type); - break; - } - case 2: - { - ExecuteSwitch(VgaIn.Selector, null, type); - break; - } - case 3: - { - ExecuteSwitch(BncIn.Selector, null, type); - break; - } - } - } - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Chassis/DmpsMicrophoneController.cs b/src/PepperDash.Essentials.DM/Chassis/DmpsMicrophoneController.cs deleted file mode 100644 index 29dc0693..00000000 --- a/src/PepperDash.Essentials.DM/Chassis/DmpsMicrophoneController.cs +++ /dev/null @@ -1,195 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; - - -namespace PepperDash.Essentials.DM -{ - /// - /// Exposes the volume levels for microphones DMPS3 chassis - /// - public class DmpsMicrophoneController - { - private Dictionary Mics; - - public DmpsMicrophoneController(CrestronControlSystem dmps) - { - Debug.Console(2, "Creating Dmps Microphone Controller"); - Mics = new Dictionary(); - - foreach (var mic in dmps.Microphones) - { - Debug.Console(0, "Dmps Microphone Controller Adding Mic: {0} Name: {1}", mic.ID, mic.Name); - var dmpsMic = new DmpsMicrophone("processor-microphone" + mic.ID, mic.Name, mic); - - DeviceManager.AddDevice(dmpsMic); - Mics.Add(mic.ID, dmpsMic); - } - - dmps.MicrophoneChange += new MicrophoneChangeEventHandler(Dmps_MicrophoneChange); - } - - void Dmps_MicrophoneChange(MicrophoneBase mic, GenericEventArgs args) - { - if (args.EventId == MicrophoneEventIds.VuFeedBackEventId) - return; - - Debug.Console(2, "Dmps Microphone Controller Index: {0} EventId: {1}", mic.ID, args.EventId.ToString()); - - if(Mics.ContainsKey(mic.ID)) - { - Mics[mic.ID].Event(args.EventId); - } - } - } - - public class DmpsMicrophone : EssentialsBridgeableDevice, IBasicVolumeWithFeedback - { - MicrophoneBase Mic; - - private bool EnableVolumeSend; - private ushort VolumeLevelInput; - protected short MinLevel { get; set; } - protected short MaxLevel { get; set; } - - public BoolFeedback MuteFeedback { get; private set; } - public IntFeedback VolumeLevelFeedback { get; private set; } - public IntFeedback VolumeLevelScaledFeedback { get; private set; } - public StringFeedback NameFeedback { get; private set; } - - Action MuteOnAction; - Action MuteOffAction; - - public DmpsMicrophone(string key, string name, MicrophoneBase mic) : base(key, name) - { - Mic = mic; - VolumeLevelInput = 0; - EnableVolumeSend = false; - MinLevel = 0; - MaxLevel = 600; - - MuteFeedback = new BoolFeedback(new Func(() => Mic.MuteOnFeedBack.BoolValue)); - VolumeLevelFeedback = new IntFeedback(new Func(() => Mic.GainFeedBack.UShortValue)); - VolumeLevelScaledFeedback = new IntFeedback(new Func(() => ScaleVolumeFeedback(VolumeLevelFeedback.UShortValue))); - NameFeedback = new StringFeedback(new Func(() => "Microphone " + Mic.ID)); - MuteOnAction = new Action(Mic.MuteOn); - MuteOffAction = new Action(Mic.MuteOff); - - VolumeLevelFeedback.FireUpdate(); - VolumeLevelScaledFeedback.FireUpdate(); - NameFeedback.FireUpdate(); - MuteFeedback.FireUpdate(); - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new DmpsMicrophoneControllerJoinMap(joinStart); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - - Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - - VolumeLevelFeedback.LinkInputSig(trilist.UShortInput[joinMap.MicGain.JoinNumber]); - VolumeLevelScaledFeedback.LinkInputSig(trilist.UShortInput[joinMap.MicGainScaled.JoinNumber ]); - MuteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.MicMuteOn.JoinNumber]); - MuteFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.MicMuteOff.JoinNumber]); - NameFeedback.LinkInputSig(trilist.StringInput[joinMap.MicName.JoinNumber]); - - trilist.SetUShortSigAction(joinMap.MicGain.JoinNumber, SetVolume); - trilist.SetUShortSigAction(joinMap.MicGainScaled.JoinNumber, SetVolumeScaled); - trilist.SetBoolSigAction(joinMap.MicGainScaledSend.JoinNumber, SendScaledVolume); - trilist.SetSigTrueAction(joinMap.MicMuteOn.JoinNumber, MuteOnAction); - trilist.SetSigTrueAction(joinMap.MicMuteOff.JoinNumber, MuteOffAction); - } - - public void Event(int id) - { - if (id == MicrophoneEventIds.MuteOnFeedBackEventId) - { - MuteFeedback.FireUpdate(); - } - else if (id == MicrophoneEventIds.GainFeedBackEventId) - { - VolumeLevelFeedback.FireUpdate(); - VolumeLevelScaledFeedback.FireUpdate(); - } - } - - public void SetVolumeScaled(ushort level) - { - VolumeLevelInput = (ushort)(level * (MaxLevel - MinLevel) / ushort.MaxValue + MinLevel); - if (EnableVolumeSend == true) - { - Mic.Gain.UShortValue = VolumeLevelInput; - } - } - - public ushort ScaleVolumeFeedback(ushort level) - { - short signedLevel = (short)level; - return (ushort)((signedLevel - MinLevel) * ushort.MaxValue / (MaxLevel - MinLevel)); - } - - public void SendScaledVolume(bool pressRelease) - { - EnableVolumeSend = pressRelease; - if (pressRelease == false) - { - SetVolumeScaled(VolumeLevelInput); - } - } - - #region IBasicVolumeWithFeedback Members - - public void SetVolume(ushort level) - { - Mic.Gain.UShortValue = level; - } - - public void MuteOn() - { - MuteOnAction(); - } - - public void MuteOff() - { - MuteOffAction(); - } - - #endregion - - #region IBasicVolumeControls Members - - public void VolumeUp(bool pressRelease) - { - } - - public void VolumeDown(bool pressRelease) - { - } - - public void MuteToggle() - { - if (MuteFeedback.BoolValue) - MuteOff(); - else - MuteOn(); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Chassis/DmpsRoutingController.cs b/src/PepperDash.Essentials.DM/Chassis/DmpsRoutingController.cs deleted file mode 100644 index f3fd66d5..00000000 --- a/src/PepperDash.Essentials.DM/Chassis/DmpsRoutingController.cs +++ /dev/null @@ -1,1371 +0,0 @@ -extern alias Full; - -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.Cards; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Receivers; -using Full.Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.DM.Config; - -using Feedback = PepperDash.Essentials.Core.Feedback; - -namespace PepperDash.Essentials.DM -{ - public class DmpsRoutingController : EssentialsBridgeableDevice, IRoutingNumericWithFeedback, IHasFeedback - { - private const string NonePortKey = "none"; - - public CrestronControlSystem Dmps { get; set; } - public ISystemControl SystemControl { get; private set; } - public bool? EnableRouting { get; private set; } - - //IroutingNumericEvent - public event EventHandler NumericSwitchChange; - - //Feedback for DMPS System Control - public BoolFeedback SystemPowerOnFeedback { get; private set; } - public BoolFeedback SystemPowerOffFeedback { get; private set; } - public BoolFeedback FrontPanelLockOnFeedback { get; private set; } - public BoolFeedback FrontPanelLockOffFeedback { get; private set; } - - // Feedbacks for EssentialDM - public Dictionary VideoOutputFeedbacks { get; private set; } - public Dictionary AudioOutputFeedbacks { get; private set; } - public Dictionary VideoInputSyncFeedbacks { get; private set; } - public Dictionary InputEndpointOnlineFeedbacks { get; private set; } - public Dictionary OutputEndpointOnlineFeedbacks { get; private set; } - public Dictionary InputNameFeedbacks { get; private set; } - public Dictionary OutputNameFeedbacks { get; private set; } - public Dictionary OutputVideoRouteNameFeedbacks { get; private set; } - public Dictionary OutputAudioRouteNameFeedbacks { get; private set; } - - public FeedbackCollection Feedbacks { get; private set; } - - // Need a couple Lists of generic Backplane ports - public RoutingPortCollection InputPorts { get; private set; } - public RoutingPortCollection OutputPorts { get; private set; } - - public Dictionary TxDictionary { get; set; } - public Dictionary RxDictionary { get; set; } - - public Dictionary InputNames { get; set; } - public Dictionary OutputNames { get; set; } - public Dictionary VolumeControls { get; private set; } - public Dictionary DigitalAudioOutputs { get; private set; } - public DmpsMicrophoneController Microphones { get; private set; } - - public const int RouteOffTime = 500; - Dictionary RouteOffTimers = new Dictionary(); - - /// - /// Text that represents when an output has no source routed to it - /// - public string NoRouteText = ""; - - /// - /// Raise an event when the status of a switch object changes. - /// - /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType - private void OnSwitchChange(RoutingNumericEventArgs e) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, e); - } - - - public static DmpsRoutingController GetDmpsRoutingController(string key, string name, - DmpsRoutingPropertiesConfig properties) - { - try - { - var systemControl = Global.ControlSystem.SystemControl; - - if (systemControl == null) - { - return null; - } - - var controller = new DmpsRoutingController(key, name, systemControl) - { - InputNames = properties.InputNames, - OutputNames = properties.OutputNames - }; - - if (!string.IsNullOrEmpty(properties.NoRouteText)) - controller.NoRouteText = properties.NoRouteText; - - return controller; - - } - catch (Exception e) - { - Debug.Console(0, "Error getting DMPS Controller:\r\n{0}", e); - } - return null; - } - - - /// - /// - /// - /// - /// - /// - public DmpsRoutingController(string key, string name, ISystemControl systemControl) - : base(key, name) - { - Dmps = Global.ControlSystem; - - switch (systemControl.SystemControlType) - { - case eSystemControlType.Dmps34K150CSystemControl: - SystemControl = systemControl as Dmps34K150CSystemControl; - SystemPowerOnFeedback = new BoolFeedback(() => { return true; }); - SystemPowerOffFeedback = new BoolFeedback(() => { return false; }); - break; - case eSystemControlType.Dmps34K200CSystemControl: - case eSystemControlType.Dmps34K250CSystemControl: - case eSystemControlType.Dmps34K300CSystemControl: - case eSystemControlType.Dmps34K350CSystemControl: - SystemControl = systemControl as Dmps34K300CSystemControl; - SystemPowerOnFeedback = new BoolFeedback(() => { return true; }); - SystemPowerOffFeedback = new BoolFeedback(() => { return false; }); - break; - default: - SystemControl = systemControl as Dmps3SystemControl; - SystemPowerOnFeedback = new BoolFeedback(() => - { - return ((Dmps3SystemControl)SystemControl).SystemPowerOnFeedBack.BoolValue; - }); - SystemPowerOffFeedback = new BoolFeedback(() => - { - return ((Dmps3SystemControl)SystemControl).SystemPowerOffFeedBack.BoolValue; - }); - break; - } - Debug.Console(1, this, "DMPS Type = {0}, 4K Type = {1}", systemControl.SystemControlType, Global.ControlSystemIsDmps4kType); - - InputPorts = new RoutingPortCollection(); - OutputPorts = new RoutingPortCollection(); - VolumeControls = new Dictionary(); - DigitalAudioOutputs = new Dictionary(); - TxDictionary = new Dictionary(); - RxDictionary = new Dictionary(); - - FrontPanelLockOnFeedback = new BoolFeedback(() => - { - return SystemControl.FrontPanelLockOnFeedback.BoolValue; - }); - FrontPanelLockOffFeedback = new BoolFeedback(() => - { - return SystemControl.FrontPanelLockOffFeedback.BoolValue; - }); - - VideoOutputFeedbacks = new Dictionary(); - AudioOutputFeedbacks = new Dictionary(); - VideoInputSyncFeedbacks = new Dictionary(); - InputNameFeedbacks = new Dictionary(); - OutputNameFeedbacks = new Dictionary(); - OutputVideoRouteNameFeedbacks = new Dictionary(); - OutputAudioRouteNameFeedbacks = new Dictionary(); - InputEndpointOnlineFeedbacks = new Dictionary(); - OutputEndpointOnlineFeedbacks = new Dictionary(); - - Debug.Console(1, this, "{0} Switcher Inputs Present.", Dmps.SwitcherInputs.Count); - Debug.Console(1, this, "{0} Switcher Outputs Present.", Dmps.SwitcherOutputs.Count); - - Debug.Console(1, this, "{0} Inputs in ControlSystem", Dmps.NumberOfSwitcherInputs); - Debug.Console(1, this, "{0} Outputs in ControlSystem", Dmps.NumberOfSwitcherOutputs); - - SetupOutputCards(); - - SetupInputCards(); - - Microphones = new DmpsMicrophoneController(Dmps); - } - - public override bool CustomActivate() - { - // Set input and output names from config - SetInputNames(); - - SetOutputNames(); - - // Subscribe to events - Dmps.DMInputChange += Dmps_DMInputChange; - Dmps.DMOutputChange += Dmps_DMOutputChange; - Dmps.DMSystemChange += Dmps_DMSystemChange; - - foreach (var x in VideoOutputFeedbacks) - { - x.Value.FireUpdate(); - } - foreach (var x in AudioOutputFeedbacks) - { - x.Value.FireUpdate(); - } - foreach (var x in VideoInputSyncFeedbacks) - { - x.Value.FireUpdate(); - } - foreach (var x in InputEndpointOnlineFeedbacks) - { - x.Value.FireUpdate(); - } - foreach (var x in InputNameFeedbacks) - { - x.Value.FireUpdate(); - } - foreach (var x in OutputNameFeedbacks) - { - x.Value.FireUpdate(); - } - foreach (var x in OutputEndpointOnlineFeedbacks) - { - x.Value.FireUpdate(); - } - - SystemPowerOnFeedback.FireUpdate(); - SystemPowerOffFeedback.FireUpdate(); - - FrontPanelLockOnFeedback.FireUpdate(); - FrontPanelLockOffFeedback.FireUpdate(); - - return base.CustomActivate(); - } - - private void SetOutputNames() - { - if (OutputNames == null) - { - return; - } - foreach (var kvp in OutputNames) - { - var output = (Dmps.SwitcherOutputs[kvp.Key] as DMOutput); - if (output != null) - { - if (output.Name.Supported && kvp.Value.Length > 0) - { - output.Name.StringValue = kvp.Value; - } - } - } - } - - private void SetInputNames() - { - if (InputNames == null) - { - return; - } - foreach (var kvp in InputNames) - { - var input = (Dmps.SwitcherInputs[kvp.Key] as DMInput); - if (input != null) - { - if (input.Name.Supported && kvp.Value.Length > 0) - { - input.Name.StringValue = kvp.Value; - } - } - } - } - - public void SetRoutingEnable(bool enable) - { - CrestronEnvironment.Sleep(1000); - EnableRouting = enable; - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new DmpsRoutingControllerJoinMap(joinStart); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - - Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - - //Link up system power only for non-4k DMPS3 - if (SystemControl is Dmps3SystemControl) - { - trilist.SetBoolSigAction(joinMap.SystemPowerOn.JoinNumber, a => { if (a) { ((Dmps3SystemControl)SystemControl).SystemPowerOn(); } }); - trilist.SetBoolSigAction(joinMap.SystemPowerOff.JoinNumber, a => { if (a) { ((Dmps3SystemControl)SystemControl).SystemPowerOff(); } }); - } - - SystemPowerOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.SystemPowerOn.JoinNumber]); - SystemPowerOffFeedback.LinkInputSig(trilist.BooleanInput[joinMap.SystemPowerOff.JoinNumber]); - - trilist.SetBoolSigAction(joinMap.FrontPanelLockOn.JoinNumber, a => { if (a) {SystemControl.FrontPanelLockOn();}}); - trilist.SetBoolSigAction(joinMap.FrontPanelLockOff.JoinNumber, a => { if (a) {SystemControl.FrontPanelLockOff();}}); - - FrontPanelLockOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.FrontPanelLockOn.JoinNumber]); - FrontPanelLockOffFeedback.LinkInputSig(trilist.BooleanInput[joinMap.FrontPanelLockOff.JoinNumber]); - - trilist.SetBoolSigAction(joinMap.EnableRouting.JoinNumber, SetRoutingEnable); - - // Link up outputs - LinkInputsToApi(trilist, joinMap); - LinkOutputsToApi(trilist, joinMap); - } - - private void LinkOutputsToApi(BasicTriList trilist, DmpsRoutingControllerJoinMap joinMap) - { - for (uint i = 1; i <= Dmps.SwitcherOutputs.Count; i++) - { - Debug.Console(2, this, "Linking Output Card {0}", i); - - var ioSlot = i; - var ioSlotJoin = ioSlot - 1; - - // Control - trilist.SetUShortSigAction(joinMap.OutputVideo.JoinNumber + ioSlotJoin, - o => ExecuteNumericSwitch(o, (ushort) ioSlot, eRoutingSignalType.Video)); - trilist.SetUShortSigAction(joinMap.OutputAudio.JoinNumber + ioSlotJoin, - o => ExecuteNumericSwitch(o, (ushort) ioSlot, eRoutingSignalType.Audio)); - - trilist.SetStringSigAction(joinMap.OutputNames.JoinNumber + ioSlotJoin, s => - { - var outputCard = Dmps.SwitcherOutputs[ioSlot] as DMOutput; - - //Debug.Console(2, dmpsRouter, "Output Name String Sig Action for Output Card {0}", ioSlot); - - if (outputCard == null) - { - return; - } - //Debug.Console(2, dmpsRouter, "Card Type: {0}", outputCard.CardInputOutputType); - - if (outputCard is Card.Dmps3CodecOutput || outputCard.NameFeedback == null) - { - return; - } - if (string.IsNullOrEmpty(outputCard.NameFeedback.StringValue)) - { - return; - } - //Debug.Console(2, dmpsRouter, "NameFeedabck: {0}", outputCard.NameFeedback.StringValue); - - if (outputCard.NameFeedback.StringValue != s && outputCard.Name != null) - { - outputCard.Name.StringValue = s; - } - }); - - // Feedback - if (VideoOutputFeedbacks[ioSlot] != null) - { - VideoOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputVideo.JoinNumber + ioSlotJoin]); - } - if (AudioOutputFeedbacks[ioSlot] != null) - { - AudioOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputAudio.JoinNumber + ioSlotJoin]); - } - if (OutputNameFeedbacks[ioSlot] != null) - { - if (Dmps.SwitcherOutputs[ioSlot].CardInputOutputType == eCardInputOutputType.Dmps3DmOutput || - Dmps.SwitcherOutputs[ioSlot].CardInputOutputType == eCardInputOutputType.Dmps3DmOutputBackend || - Dmps.SwitcherOutputs[ioSlot].CardInputOutputType == eCardInputOutputType.Dmps3HdmiOutput || - Dmps.SwitcherOutputs[ioSlot].CardInputOutputType == eCardInputOutputType.Dmps3HdmiOutputBackend || - Dmps.SwitcherOutputs[ioSlot].CardInputOutputType == eCardInputOutputType.Dmps3DmHdmiAudioOutput) - { - OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputVideoNames.JoinNumber + ioSlotJoin]); - OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputNames.JoinNumber + ioSlotJoin]); - OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputAudioNames.JoinNumber + ioSlotJoin]); - } - else - { - OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputNames.JoinNumber + ioSlotJoin]); - OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputAudioNames.JoinNumber + ioSlotJoin]); - } - } - if (OutputVideoRouteNameFeedbacks[ioSlot] != null) - { - OutputVideoRouteNameFeedbacks[ioSlot].LinkInputSig( - trilist.StringInput[joinMap.OutputCurrentVideoInputNames.JoinNumber + ioSlotJoin]); - } - if (OutputAudioRouteNameFeedbacks[ioSlot] != null) - { - OutputAudioRouteNameFeedbacks[ioSlot].LinkInputSig( - trilist.StringInput[joinMap.OutputCurrentAudioInputNames.JoinNumber + ioSlotJoin]); - } - if (OutputEndpointOnlineFeedbacks[ioSlot] != null) - { - OutputEndpointOnlineFeedbacks[ioSlot].LinkInputSig( - trilist.BooleanInput[joinMap.OutputEndpointOnline.JoinNumber + ioSlotJoin]); - } - } - } - - private void LinkInputsToApi(BasicTriList trilist, DmpsRoutingControllerJoinMap joinMap) - { - if (Global.ControlSystemIsDmps4k3xxType) - { - //Add DMPS-4K mixer input names to end of inputs - trilist.StringInput[joinMap.InputAudioNames.JoinNumber + (uint)Dmps.SwitcherInputs.Count + 4].StringValue = "Digital Mixer 1"; - trilist.StringInput[joinMap.InputAudioNames.JoinNumber + (uint)Dmps.SwitcherInputs.Count + 5].StringValue = "Digital Mixer 2"; - } - for (uint i = 1; i <= Dmps.SwitcherInputs.Count; i++) - { - Debug.Console(2, this, "Linking Input Card {0}", i); - - var ioSlot = i; - var ioSlotJoin = ioSlot - 1; - - if (VideoInputSyncFeedbacks.ContainsKey(ioSlot) && VideoInputSyncFeedbacks[ioSlot] != null) - { - VideoInputSyncFeedbacks[ioSlot].LinkInputSig( - trilist.BooleanInput[joinMap.VideoSyncStatus.JoinNumber + ioSlotJoin]); - } - - if (InputNameFeedbacks.ContainsKey(ioSlot) && InputNameFeedbacks[ioSlot] != null) - { - if (Dmps.SwitcherInputs[ioSlot] is Card.Dmps3AnalogAudioInput) - { - for (uint j = ioSlot; j < ioSlot + 5; j++) - { - InputNameFeedbacks[j].LinkInputSig(trilist.StringInput[joinMap.InputAudioNames.JoinNumber + j - 1]); - } - } - else - { - InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputNames.JoinNumber + ioSlotJoin]); - InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputVideoNames.JoinNumber + ioSlotJoin]); - InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputAudioNames.JoinNumber + ioSlotJoin]); - } - } - - trilist.SetStringSigAction(joinMap.InputNames.JoinNumber + ioSlotJoin, s => - { - var inputCard = Dmps.SwitcherInputs[ioSlot] as DMInput; - - if (inputCard == null) - { - return; - } - - if (inputCard.NameFeedback == null || string.IsNullOrEmpty(inputCard.NameFeedback.StringValue) || - inputCard.NameFeedback.StringValue == s) - { - return; - } - - if (inputCard.Name != null) - { - inputCard.Name.StringValue = s; - } - }); - - - if (InputEndpointOnlineFeedbacks.ContainsKey(ioSlot) && InputEndpointOnlineFeedbacks[ioSlot] != null) - { - InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig( - trilist.BooleanInput[joinMap.InputEndpointOnline.JoinNumber + ioSlotJoin]); - } - } - } - - - /// - /// Iterate the SwitcherOutputs collection to setup feedbacks and add routing ports - /// - void SetupOutputCards() - { - foreach (var card in Dmps.SwitcherOutputs) - { - try - { - Debug.Console(1, this, "Output Card Type: {0}", card.CardInputOutputType); - - var outputCard = card as DMOutput; - - if (outputCard == null) - { - Debug.Console(1, this, "Output card {0} is not a DMOutput", card.CardInputOutputType); - continue; - } - - Debug.Console(1, this, "Adding Output Card Number {0} Type: {1}", outputCard.Number, outputCard.CardInputOutputType.ToString()); - VideoOutputFeedbacks[outputCard.Number] = new IntFeedback(() => - { - if (outputCard.VideoOutFeedback != null) { return (ushort)outputCard.VideoOutFeedback.Number; } - return 0; - ; - }); - AudioOutputFeedbacks[outputCard.Number] = new IntFeedback(() => - { - if (!Global.ControlSystemIsDmps4k3xxType) - { - if (outputCard.AudioOutFeedback != null) - { - return (ushort)outputCard.AudioOutFeedback.Number; - } - return 0; - } - else - { - - if (outputCard is Card.Dmps3DmOutputBackend || outputCard is Card.Dmps3HdmiOutputBackend) - { - //Special cases for DMPS-4K digital audio output - if (DigitalAudioOutputs[outputCard.Number].AudioSourceNumericFeedback.UShortValue == 0) - return 0; - else if (DigitalAudioOutputs[outputCard.Number].AudioSourceNumericFeedback.UShortValue == 1) - return (ushort)Dmps.SwitcherInputs.Count + 5; - else if (DigitalAudioOutputs[outputCard.Number].AudioSourceNumericFeedback.UShortValue == 2) - return (ushort)Dmps.SwitcherInputs.Count + 6; - else if (DigitalAudioOutputs[outputCard.Number].AudioSourceNumericFeedback.UShortValue == 3) - return (ushort)outputCard.VideoOutFeedback.Number; - else - return 0; - } - else if (outputCard.AudioOutSourceFeedback == eDmps34KAudioOutSource.NoRoute) - { - //Fixes for weird audio indexing on DMPS3-4K - return 0; - } - else if (outputCard.AudioOutSourceFeedback == eDmps34KAudioOutSource.AirMedia8) - { - //Fixes for weird audio indexing on DMPS3-4K - return 8; - } - else if (outputCard.AudioOutSourceFeedback == eDmps34KAudioOutSource.AirMedia9) - { - //Fixes for weird audio indexing on DMPS3-4K - return 9; - } - else if ((ushort)outputCard.AudioOutSourceFeedback <= 5) - { - //Move analog inputs to after regular dm cards - return (ushort)outputCard.AudioOutSourceFeedback + (ushort)Dmps.SwitcherInputs.Count - 1; - } - else - { - //Fixes for weird audio indexing on DMPS3-4K - return (ushort)outputCard.AudioOutSourceFeedback - 5; - } - } - }); - - OutputNameFeedbacks[outputCard.Number] = new StringFeedback(() => - { - if(OutputNames.ContainsKey(outputCard.Number)) - { - return OutputNames[outputCard.Number]; - } - else if (outputCard.NameFeedback != null && outputCard.NameFeedback != CrestronControlSystem.NullStringOutputSig && !string.IsNullOrEmpty(outputCard.NameFeedback.StringValue)) - { - Debug.Console(2, this, "Output Card {0} Name: {1}", outputCard.Number, outputCard.NameFeedback.StringValue); - return outputCard.NameFeedback.StringValue; - } - return ""; - }); - - OutputVideoRouteNameFeedbacks[outputCard.Number] = new StringFeedback(() => - { - if (outputCard.VideoOutFeedback != null && outputCard.VideoOutFeedback.NameFeedback != null) - { - return outputCard.VideoOutFeedback.NameFeedback.StringValue; - } - return NoRouteText; - }); - OutputAudioRouteNameFeedbacks[outputCard.Number] = new StringFeedback(() => - { - if (!Global.ControlSystemIsDmps4k3xxType) - { - if (outputCard.AudioOutFeedback != null && outputCard.AudioOutFeedback.NameFeedback != null) - { - return outputCard.AudioOutFeedback.NameFeedback.StringValue; - } - } - else - { - if (outputCard is Card.Dmps3DmOutputBackend || outputCard is Card.Dmps3HdmiOutputBackend) - { - //Special cases for DMPS-4K digital audio output - if (DigitalAudioOutputs[outputCard.Number].AudioSourceNumericFeedback.UShortValue == 0) - return NoRouteText; - else if (DigitalAudioOutputs[outputCard.Number].AudioSourceNumericFeedback.UShortValue == 1) - return "Digital Mix 1"; - else if (DigitalAudioOutputs[outputCard.Number].AudioSourceNumericFeedback.UShortValue == 2) - return "Digital Mix 2"; - else if (DigitalAudioOutputs[outputCard.Number].AudioSourceNumericFeedback.UShortValue == 3) - return outputCard.VideoOutFeedback.NameFeedback.StringValue; - else - return NoRouteText; - } - else - { - return outputCard.AudioOutSourceFeedback.ToString(); - } - } - return NoRouteText; - }); - - OutputEndpointOnlineFeedbacks[outputCard.Number] = new BoolFeedback(() => outputCard.EndpointOnlineFeedback); - - AddOutputCard(outputCard.Number, outputCard); - } - catch (Exception ex) - { - Debug.LogError(Debug.ErrorLogLevel.Error, string.Format("DMPS Controller exception creating output card: {0}", ex)); - } - } - } - - /// - /// Iterate the SwitcherInputs collection to setup feedbacks and add routing ports - /// - void SetupInputCards() - { - foreach (var card in Dmps.SwitcherInputs) - { - var inputCard = card as DMInput; - - if (inputCard != null) - { - Debug.Console(1, this, "Adding Input Card Number {0} Type: {1}", inputCard.Number, inputCard.CardInputOutputType.ToString()); - - InputEndpointOnlineFeedbacks[inputCard.Number] = new BoolFeedback(() => inputCard.EndpointOnlineFeedback); - - if (inputCard.VideoDetectedFeedback != null && inputCard.VideoDetectedFeedback.Supported) - { - VideoInputSyncFeedbacks[inputCard.Number] = new BoolFeedback(() => inputCard.VideoDetectedFeedback.BoolValue); - } - - InputNameFeedbacks[inputCard.Number] = new StringFeedback(() => - { - if (InputNames.ContainsKey(inputCard.Number)) - { - return InputNames[inputCard.Number]; - } - else if (inputCard.NameFeedback != null && inputCard.NameFeedback != CrestronControlSystem.NullStringOutputSig && !string.IsNullOrEmpty(inputCard.NameFeedback.StringValue)) - { - Debug.Console(2, this, "Input Card {0} Name: {1}", inputCard.Number, inputCard.NameFeedback.StringValue); - return inputCard.NameFeedback.StringValue; - } - return ""; - }); - - AddInputCard(inputCard.Number, inputCard); - } - else - { - Debug.Console(2, this, "***********Input Card of type {0} is cannot be cast as DMInput*************", card.CardInputOutputType); - } - } - - InputPorts.Add(new RoutingInputPort(NonePortKey, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.None, null, this)); - } - - /// - /// Builds the appropriate ports aand callst the appropreate add port method - /// - /// - /// - public void AddInputCard(uint number, DMInput inputCard) - { - if (inputCard is Card.Dmps3HdmiInputWithoutAnalogAudio) - { - var hdmiInputCard = inputCard as Card.Dmps3HdmiInputWithoutAnalogAudio; - - var cecPort = hdmiInputCard.HdmiInputPort; - - AddInputPortWithDebug(number, string.Format("HdmiIn{0}", number), eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, cecPort); - } - else if (inputCard is Card.Dmps3HdmiInput) - { - var hdmiInputCard = inputCard as Card.Dmps3HdmiInput; - var cecPort = hdmiInputCard.HdmiInputPort; - - AddInputPortWithDebug(number, string.Format("HdmiIn{0}", number), eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, cecPort); - AddInputPortWithDebug(number, string.Format("HudioIn{1}", number), eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio); - } - else if (inputCard is Card.Dmps3HdmiVgaInput) - { - var hdmiVgaInputCard = inputCard as Card.Dmps3HdmiVgaInput; - - DmpsInternalVirtualHdmiVgaInputController inputCardController = new DmpsInternalVirtualHdmiVgaInputController(Key + - string.Format("-HdmiVgaIn{0}", number), string.Format("InternalInputController-{0}", number), hdmiVgaInputCard); - - DeviceManager.AddDevice(inputCardController); - - AddInputPortWithDebug(number, string.Format("HdmiVgaIn{0}", number), eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.BackplaneOnly); - } - else if (inputCard is Card.Dmps3HdmiVgaBncInput) - { - var hdmiVgaBncInputCard = inputCard as Card.Dmps3HdmiVgaBncInput; - - DmpsInternalVirtualHdmiVgaBncInputController inputCardController = new DmpsInternalVirtualHdmiVgaBncInputController(Key + - string.Format("-HdmiVgaBncIn{0}", number), string.Format("InternalInputController-{0}", number), hdmiVgaBncInputCard); - - DeviceManager.AddDevice(inputCardController); - - AddInputPortWithDebug(number, string.Format("HdmiVgaBncIn{0}", number), eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.BackplaneOnly); - - } - else if (inputCard is Card.Dmps3DmInput) - { - var hdmiInputCard = inputCard as Card.Dmps3DmInput; - var cecPort = hdmiInputCard.DmInputPort; - - AddInputPortWithDebug(number, string.Format("DmIn{0}", number), eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat, cecPort); - } - else if (inputCard is Card.Dmps3VgaInput) - { - AddInputPortWithDebug(number, string.Format("VgaIn{0}", number), eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Vga); - } - else if (inputCard is Card.Dmps3AirMediaInput) - { - AddInputPortWithDebug(number, string.Format("AirMediaIn{0}", number), eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Streaming); - } - else if (inputCard is Card.Dmps3AnalogAudioInput) - { - for (uint i = 0; i <= 4; i++) - { - uint j = i + 1; - uint input = i + number; - InputNameFeedbacks[input] = new StringFeedback(() => - { - if (InputNames.ContainsKey(input)) - { - return InputNames[input]; - } - else - { - return String.Format("Aux Input {0}", j); - } - }); - } - } - } - - - /// - /// Adds InputPort - /// - private void AddInputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, - eRoutingPortConnectionType portType) - { - AddInputPortWithDebug(cardNum, portName, sigType, portType, null); - } - - /// - /// Adds InputPort and sets Port as ICec object - /// - void AddInputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, ICec cecPort) - { - var portKey = string.Format("inputCard{0}--{1}", cardNum, portName); - Debug.Console(2, this, "Adding input port '{0}'", portKey); - var inputPort = new RoutingInputPort(portKey, sigType, portType, Dmps.SwitcherInputs[cardNum], this) - { - FeedbackMatchObject = Dmps.SwitcherInputs[cardNum] - }; - - if (cecPort != null) - inputPort.Port = cecPort; - - InputPorts.Add(inputPort); - } - - - /// - /// Builds the appropriate ports and calls the appropriate add port method - /// - /// - /// - public void AddOutputCard(uint number, DMOutput outputCard) - { - if (outputCard is Card.Dmps3HdmiOutput) - { - var hdmiOutputCard = outputCard as Card.Dmps3HdmiOutput; - - var cecPort = hdmiOutputCard.HdmiOutputPort; - - AddHdmiOutputPort(number, cecPort); - - var audioOutput = new DmpsAudioOutputController(string.Format("processor-digitalAudioOutput{0}", number), string.Format("Hdmi Audio Output {0}", number), outputCard as Card.Dmps3HdmiOutput); - DeviceManager.AddDevice(audioOutput); - } - else if (outputCard is Card.Dmps3HdmiOutputBackend) - { - var hdmiOutputCard = outputCard as Card.Dmps3HdmiOutputBackend; - var cecPort = hdmiOutputCard.HdmiOutputPort; - AddHdmiOutputPort(number, cecPort); - var audioOutput = new DmpsDigitalOutputController(string.Format("processor-avRouting-HdmiAudioOut{0}", number), string.Format("Hdmi Audio Output {0} Router", number), hdmiOutputCard); - DigitalAudioOutputs.Add(number, audioOutput); - DeviceManager.AddDevice(audioOutput); - } - else if (outputCard is Card.Dmps3DmOutput) - { - AddDmOutputPort(number); - var audioOutput = new DmpsAudioOutputController(string.Format("processor-digitalAudioOutput{0}", number), string.Format("Dm Audio Output {0}", number), outputCard as Card.Dmps3DmOutput); - DeviceManager.AddDevice(audioOutput); - } - else if (outputCard is Card.Dmps3DmOutputBackend) - { - AddDmOutputPort(number); - var audioOutput = new DmpsDigitalOutputController(string.Format("processor-avRouting-DmAudioOut{0}", number), string.Format("Dm Audio Output {0} Router", number), outputCard as Card.Dmps3DmOutputBackend); - DigitalAudioOutputs.Add(number, audioOutput); - DeviceManager.AddDevice(audioOutput); - } - else if (outputCard is Card.Dmps3DmHdmiAudioOutput) - { - var hdmiOutputCard = outputCard as Card.Dmps3DmHdmiAudioOutput; - var cecPort = hdmiOutputCard.HdmiOutputPort; - AddHdmiOutputPort(number, cecPort); - AddDmOutputPort(number); - AddAudioOnlyOutputPort(number, "Program"); - - var audioOutput = new DmpsAudioOutputController(string.Format("processor-programAudioOutput", number), string.Format("Program Audio Output {0}", number), hdmiOutputCard, hdmiOutputCard.AudioOutputStream); - DeviceManager.AddDevice(audioOutput); - var digitalAudioOutput = new DmpsAudioOutputController(string.Format("processor-digitalAudioOutput{0}", number), string.Format("Hdmi Audio Output {0}", number), hdmiOutputCard, hdmiOutputCard.DmHdmiOutputStream); - DeviceManager.AddDevice(digitalAudioOutput); - } - else if (outputCard is Card.Dmps3ProgramOutput) - { - AddAudioOnlyOutputPort(number, "Program"); - - var programOutput = new DmpsAudioOutputController(string.Format("processor-programAudioOutput"), "Program Audio Output", outputCard as Card.Dmps3ProgramOutput); - - DeviceManager.AddDevice(programOutput); - } - else if (outputCard is Card.Dmps3AuxOutput) - { - switch (outputCard.CardInputOutputType) - { - case eCardInputOutputType.Dmps3Aux1Output: - { - AddAudioOnlyOutputPort(number, "Aux1"); - - var aux1Output = new DmpsAudioOutputController(string.Format("processor-aux1AudioOutput"), "Aux1 Audio Output", outputCard as Card.Dmps3Aux1Output); - - DeviceManager.AddDevice(aux1Output); - } - break; - case eCardInputOutputType.Dmps3Aux2Output: - { - AddAudioOnlyOutputPort(number, "Aux2"); - - var aux2Output = new DmpsAudioOutputController(string.Format("processor-aux2AudioOutput"), "Aux2 Audio Output", outputCard as Card.Dmps3Aux2Output); - - DeviceManager.AddDevice(aux2Output); - } - break; - } - } - else if (outputCard is Card.Dmps3CodecOutput) - { - switch (number) - { - case (uint)CrestronControlSystem.eDmps34K350COutputs.Codec1: - case (uint)CrestronControlSystem.eDmps34K250COutputs.Codec1: - case (uint)CrestronControlSystem.eDmps3300cAecOutputs.Codec1: - AddAudioOnlyOutputPort(number, CrestronControlSystem.eDmps300cOutputs.Codec1.ToString()); - break; - case (uint)CrestronControlSystem.eDmps34K350COutputs.Codec2: - case (uint)CrestronControlSystem.eDmps34K250COutputs.Codec2: - case (uint)CrestronControlSystem.eDmps3300cAecOutputs.Codec2: - AddAudioOnlyOutputPort(number, CrestronControlSystem.eDmps300cOutputs.Codec2.ToString()); - break; - } - } - else if (outputCard is Card.Dmps3DialerOutput) - { - AddAudioOnlyOutputPort(number, "Dialer"); - } - else if (outputCard is Card.Dmps3AecOutput) - { - AddAudioOnlyOutputPort(number, "Aec"); - } - else if (outputCard is Card.Dmps3DigitalMixOutput) - { - if (number == (uint)CrestronControlSystem.eDmps34K250COutputs.Mix1 - || number == (uint)CrestronControlSystem.eDmps34K300COutputs.Mix1 - || number == (uint)CrestronControlSystem.eDmps34K350COutputs.Mix1) - AddAudioOnlyOutputPort(number, CrestronControlSystem.eDmps34K250COutputs.Mix1.ToString()); - if (number == (uint)CrestronControlSystem.eDmps34K250COutputs.Mix2 - || number == (uint)CrestronControlSystem.eDmps34K300COutputs.Mix2 - || number == (uint)CrestronControlSystem.eDmps34K350COutputs.Mix2) - AddAudioOnlyOutputPort(number, CrestronControlSystem.eDmps34K250COutputs.Mix2.ToString()); - - var audioOutput = new DmpsAudioOutputController(string.Format("processor-digitalAudioOutput{0}", number % 2 + 1), string.Format("Digital Audio Mix {0}", number % 2 + 1), outputCard as Card.Dmps3DigitalMixOutput); - DeviceManager.AddDevice(audioOutput); - } - else - { - Debug.Console(1, this, "Output Card is of a type not currently handled:", outputCard.CardInputOutputType.ToString()); - } - } - - /// - /// Adds an Audio only output port - /// - /// - void AddAudioOnlyOutputPort(uint number, string portName) - { - AddOutputPortWithDebug(number, portName, eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio, Dmps.SwitcherOutputs[number]); - } - - /// - /// Adds an HDMI output port - /// - /// - /// - void AddHdmiOutputPort(uint number, ICec cecPort) - { - AddOutputPortWithDebug(number, string.Format("hdmiOut{0}", number), eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, Dmps.SwitcherOutputs[number], cecPort); - } - - /// - /// Adds a DM output port - /// - /// - void AddDmOutputPort(uint number) - { - AddOutputPortWithDebug(number, string.Format("dmOut{0}", number), eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat, Dmps.SwitcherOutputs[number]); - } - - /// - /// Adds OutputPort - /// - void AddOutputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, object selector) - { - AddOutputPortWithDebug(cardNum, portName, sigType, portType, selector, null); - } - - /// - /// Adds OutputPort and sets Port as ICec object - /// - void AddOutputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, object selector, ICec cecPort) - { - var portKey = string.Format("outputCard{0}--{1}", cardNum, portName); - Debug.Console(2, this, "Adding output port '{0}'", portKey); - var outputPort = new RoutingOutputPort(portKey, sigType, portType, selector, this) - { - FeedbackMatchObject = Dmps.SwitcherOutputs[cardNum] - }; - - if (cecPort != null) - outputPort.Port = cecPort; - - OutputPorts.Add(outputPort); - } - - /// - /// - /// - void AddVolumeControl(uint number, Audio.Output audio) - { - VolumeControls.Add(number, new DmCardAudioOutputController(audio)); - } - - void Dmps_DMInputChange(Switch device, DMInputEventArgs args) - { - Debug.Console(2, this, "DMInputChange Input: {0} EventId: {1}", args.Number, args.EventId.ToString()); - try - { - switch (args.EventId) - { - case (DMInputEventIds.OnlineFeedbackEventId): - { - Debug.Console(2, this, "DM Input OnlineFeedbackEventId for input: {0}. State: {1}", args.Number, device.Inputs[args.Number].EndpointOnlineFeedback); - InputEndpointOnlineFeedbacks[args.Number].FireUpdate(); - break; - } - case (DMInputEventIds.EndpointOnlineEventId): - { - Debug.Console(2, this, "DM Input EndpointOnlineEventId for input: {0}. State: {1}", args.Number, device.Inputs[args.Number].EndpointOnlineFeedback); - InputEndpointOnlineFeedbacks[args.Number].FireUpdate(); - break; - } - case (DMInputEventIds.VideoDetectedEventId): - { - Debug.Console(2, this, "DM Input {0} VideoDetectedEventId", args.Number); - VideoInputSyncFeedbacks[args.Number].FireUpdate(); - break; - } - case (DMInputEventIds.InputNameEventId): - { - Debug.Console(2, this, "DM Input {0} NameFeedbackEventId", args.Number); - if(InputNameFeedbacks.ContainsKey(args.Number)) - { - InputNameFeedbacks[args.Number].FireUpdate(); - } - break; - } - } - } - catch (Exception e) - { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "DMSwitch Input Change:{0} Input:{1} Event:{2}\rException: {3}", this.Name, args.Number, args.EventId.ToString(), e.ToString()); - } - } - void Dmps_DMOutputChange(Switch device, DMOutputEventArgs args) - { - if (args.EventId == DMOutputEventIds.OutputVuFeedBackEventId) - { - //Frequently called event that isn't needed - return; - } - - Debug.Console(2, this, "DMOutputChange Output: {0} EventId: {1}", args.Number, args.EventId.ToString()); - var output = args.Number; - - DMOutput outputCard = Dmps.SwitcherOutputs[output] as DMOutput; - - if (args.EventId == DMOutputEventIds.VolumeEventId && VolumeControls.ContainsKey(output)) - { - VolumeControls[args.Number].VolumeEventFromChassis(); - } - else if (args.EventId == DMOutputEventIds.OnlineFeedbackEventId - && OutputEndpointOnlineFeedbacks.ContainsKey(output)) - { - OutputEndpointOnlineFeedbacks[output].FireUpdate(); - } - else if (args.EventId == DMOutputEventIds.EndpointOnlineEventId - && OutputEndpointOnlineFeedbacks.ContainsKey(output)) - { - OutputEndpointOnlineFeedbacks[output].FireUpdate(); - } - else if (args.EventId == DMOutputEventIds.VideoOutEventId) - { - if (outputCard != null && outputCard.VideoOutFeedback != null) - { - Debug.Console(2, this, "DMSwitchVideo:{0} Routed Input:{1} Output:{2}'", this.Name, outputCard.VideoOutFeedback.Number, output); - } - if (VideoOutputFeedbacks.ContainsKey(output)) - { - VideoOutputFeedbacks[output].FireUpdate(); - } - if (OutputVideoRouteNameFeedbacks.ContainsKey(output)) - { - OutputVideoRouteNameFeedbacks[output].FireUpdate(); - } - if (outputCard is Card.Dmps3DmOutputBackend || outputCard is Card.Dmps3HdmiOutputBackend) - { - if (AudioOutputFeedbacks.ContainsKey(output)) - { - AudioOutputFeedbacks[output].FireUpdate(); - } - if (OutputAudioRouteNameFeedbacks.ContainsKey(output)) - { - OutputAudioRouteNameFeedbacks[output].FireUpdate(); - } - } - } - else if (args.EventId == DMOutputEventIds.AudioOutEventId) - { - if (!Global.ControlSystemIsDmps4k3xxType) - { - if (outputCard != null && outputCard.AudioOutFeedback != null) - { - Debug.Console(2, this, "DMSwitchAudio:{0} Routed Input:{1} Output:{2}'", this.Name, - outputCard.AudioOutFeedback.Number, output); - } - } - else - { - if (outputCard != null) - { - if (outputCard is Card.Dmps3DmOutputBackend || outputCard is Card.Dmps3HdmiOutputBackend) - { - DigitalAudioOutputs[output].AudioSourceNumericFeedback.FireUpdate(); - } - else - { - Debug.Console(2, this, "DMSwitchAudio:{0} Routed Input:{1} Output:{2}'", Name, - outputCard.AudioOutSourceFeedback, output); - } - } - } - if (AudioOutputFeedbacks.ContainsKey(output)) - { - AudioOutputFeedbacks[output].FireUpdate(); - } - if (OutputAudioRouteNameFeedbacks.ContainsKey(output)) - { - OutputAudioRouteNameFeedbacks[output].FireUpdate(); - } - } - else if (args.EventId == DMOutputEventIds.OutputNameEventId - && OutputNameFeedbacks.ContainsKey(output)) - { - OutputNameFeedbacks[output].FireUpdate(); - } - else if (args.EventId == DMOutputEventIds.DigitalMixerAudioSourceFeedBackEventId) - { - if (AudioOutputFeedbacks.ContainsKey(output)) - { - AudioOutputFeedbacks[output].FireUpdate(); - } - if (OutputAudioRouteNameFeedbacks.ContainsKey(output)) - { - OutputAudioRouteNameFeedbacks[output].FireUpdate(); - } - } - } - - void Dmps_DMSystemChange(Switch device, DMSystemEventArgs args) - { - switch (args.EventId) - { - case DMSystemEventIds.SystemPowerOnEventId: - case DMSystemEventIds.SystemPowerOffEventId: - { - SystemPowerOnFeedback.FireUpdate(); - SystemPowerOffFeedback.FireUpdate(); - break; - } - case DMSystemEventIds.FrontPanelLockOnEventId: - case DMSystemEventIds.FrontPanelLockOffEventId: - { - FrontPanelLockOnFeedback.FireUpdate(); - FrontPanelLockOffFeedback.FireUpdate(); - break; - } - } - } - - /// - /// - /// - /// - void StartOffTimer(PortNumberType pnt) - { - if (RouteOffTimers.ContainsKey(pnt)) - return; - RouteOffTimers[pnt] = new CTimer(o => ExecuteSwitch(null, pnt.Selector, pnt.Type), RouteOffTime); - } - - #region IRouting Members - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType sigType) - { - try - { - if (EnableRouting == false) - { - return; - } - - Debug.Console(2, this, "Attempting a DM route from input {0} to output {1} {2}", inputSelector, outputSelector, sigType); - - var input = inputSelector as DMInput; - var output = outputSelector as DMOutput; - - if (output == null) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Warning, - "Unable to execute switch for inputSelector {0} to outputSelector {1}", inputSelector, - outputSelector); - return; - } - - var sigTypeIsUsbOrVideo = ((sigType & eRoutingSignalType.Video) == eRoutingSignalType.Video) || - ((sigType & eRoutingSignalType.UsbInput) == eRoutingSignalType.UsbInput) || - ((sigType & eRoutingSignalType.UsbOutput) == eRoutingSignalType.UsbOutput); - - if (input == null || (input.Number <= Dmps.NumberOfSwitcherInputs && output.Number <= Dmps.NumberOfSwitcherOutputs && - sigTypeIsUsbOrVideo) || - (input.Number <= (Dmps.NumberOfSwitcherInputs) && output.Number <= Dmps.NumberOfSwitcherOutputs && - (sigType & eRoutingSignalType.Audio) == eRoutingSignalType.Audio)) - { - // Check to see if there's an off timer waiting on this and if so, cancel - var key = new PortNumberType(output, sigType); - if (input == null) - { - StartOffTimer(key); - } - else if (key.Number > 0) - { - if (RouteOffTimers.ContainsKey(key)) - { - Debug.Console(2, this, "{0} cancelling route off due to new source", output); - RouteOffTimers[key].Stop(); - RouteOffTimers.Remove(key); - } - } - - // NOTE THAT BITWISE COMPARISONS - TO CATCH ALL ROUTING TYPES - if ((sigType & eRoutingSignalType.Video) == eRoutingSignalType.Video) - { - output.VideoOut = input; - } - - if ((sigType & eRoutingSignalType.Audio) == eRoutingSignalType.Audio) - { - if (!Global.ControlSystemIsDmps4k3xxType) - { - output.AudioOut = input; - } - else - { - if (input == null) - { - output.AudioOutSource = eDmps34KAudioOutSource.NoRoute; - } - else if (input.CardInputOutputType == eCardInputOutputType.Dmps3AirMediaInput || input.CardInputOutputType == eCardInputOutputType.Dmps3AirMediaNoStreamingInput) - { - //Special case for weird AirMedia indexing - if (Dmps.SystemControl.SystemControlType == eSystemControlType.Dmps34K250CSystemControl) - output.AudioOutSource = eDmps34KAudioOutSource.AirMedia8; - else if (Dmps.SystemControl.SystemControlType == eSystemControlType.Dmps34K350CSystemControl) - output.AudioOutSource = eDmps34KAudioOutSource.AirMedia9; - } - else if (input.Number < Dmps.SwitcherInputs.Count) - { - //Shift video inputs by 5 for weird DMPS3-4K indexing - output.AudioOutSource = (eDmps34KAudioOutSource)(input.Number + 5); - } - else - { - //Shift analog inputs back to inputs 1-5 - output.AudioOutSource = (eDmps34KAudioOutSource)(input.Number - Dmps.SwitcherInputs.Count + 1); - } - } - } - - if ((sigType & eRoutingSignalType.UsbOutput) == eRoutingSignalType.UsbOutput) - { - output.USBRoutedTo = input; - } - - if ((sigType & eRoutingSignalType.UsbInput) != eRoutingSignalType.UsbInput) - { - return; - } - if (input != null) - input.USBRoutedTo = output; - } - else - { - Debug.Console(1, this, "Unable to execute route from input {0} to output {1}", inputSelector, - outputSelector); - } - } - catch (Exception e) - { - Debug.Console(1, this, "Error executing switch: {0}", e); - } - } - - #endregion - - #region IRoutingNumeric Members - - public void ExecuteNumericSwitch(ushort inputSelector, ushort outputSelector, eRoutingSignalType sigType) - { - if (EnableRouting == false) - { - return; - } - - Debug.Console(1, this, "Attempting a numeric switch from input {0} to output {1} {2}", inputSelector, outputSelector, sigType); - - if((sigType & eRoutingSignalType.Video) == eRoutingSignalType.Video) - { - if (inputSelector <= Dmps.SwitcherInputs.Count && outputSelector <= Dmps.SwitcherOutputs.Count) - { - var input = inputSelector == 0 ? null : Dmps.SwitcherInputs[inputSelector]; - var output = Dmps.SwitcherOutputs[outputSelector]; - - ExecuteSwitch(input, output, sigType); - } - } - else if ((sigType & eRoutingSignalType.Audio) == eRoutingSignalType.Audio) - { - //Special case for DMPS-4K digital audio output - if (Global.ControlSystemIsDmps4k3xxType) - { - if (DigitalAudioOutputs.ContainsKey(outputSelector)) - { - if (inputSelector == 0) //Clear action - { - DigitalAudioOutputs[outputSelector].ExecuteNumericSwitch(0, 0, eRoutingSignalType.Audio); - } - else if (inputSelector < Dmps.SwitcherInputs.Count) //DMPS-4K video inputs, set to audio follows video - { - DigitalAudioOutputs[outputSelector].ExecuteNumericSwitch(3, 0, eRoutingSignalType.Audio); - //Force video route since it is now set so audio follows video - ExecuteNumericSwitch(inputSelector, outputSelector, eRoutingSignalType.Video); - } - else if (inputSelector == Dmps.SwitcherInputs.Count + 5) - { - //Set to mix 1 - DigitalAudioOutputs[outputSelector].ExecuteNumericSwitch(1, 0, eRoutingSignalType.Audio); - } - else if (inputSelector == Dmps.SwitcherInputs.Count + 6) - { - //Set to mix 2 - DigitalAudioOutputs[outputSelector].ExecuteNumericSwitch(2, 0, eRoutingSignalType.Audio); - } - } - else if (inputSelector <= (Dmps.SwitcherInputs.Count + 4) && outputSelector <= Dmps.SwitcherOutputs.Count) - { - var output = Dmps.SwitcherOutputs[outputSelector] as DMOutput; - if (inputSelector == 0) - { - output.AudioOutSource = eDmps34KAudioOutSource.NoRoute; - } - else if(inputSelector >= (Dmps.SwitcherInputs.Count)) - { - //Shift analog inputs back to inputs 1-5 - Debug.Console(1, this, "Attempting analog route input {0} to output {1}", inputSelector - Dmps.SwitcherInputs.Count + 1, outputSelector); - output.AudioOutSource = (eDmps34KAudioOutSource)(inputSelector - Dmps.SwitcherInputs.Count + 1); - } - else if (inputSelector < Dmps.SwitcherInputs.Count) - { - var input = Dmps.SwitcherInputs[inputSelector] as DMInput; - if (input.CardInputOutputType == eCardInputOutputType.Dmps3AirMediaInput || input.CardInputOutputType == eCardInputOutputType.Dmps3AirMediaNoStreamingInput) - { - //Special case for weird AirMedia indexing - if (Dmps.SystemControl.SystemControlType == eSystemControlType.Dmps34K250CSystemControl) - output.AudioOutSource = eDmps34KAudioOutSource.AirMedia8; - else if (Dmps.SystemControl.SystemControlType == eSystemControlType.Dmps34K350CSystemControl) - output.AudioOutSource = eDmps34KAudioOutSource.AirMedia9; - } - else - { - //Shift video inputs by 5 for weird DMPS3-4K indexing - output.AudioOutSource = (eDmps34KAudioOutSource)(inputSelector + 5); - } - } - } - } - - else if (inputSelector <= Dmps.SwitcherInputs.Count && outputSelector <= Dmps.SwitcherOutputs.Count) - { - var output = Dmps.SwitcherOutputs[outputSelector] as DMOutput; - var input = inputSelector == 0 ? null : Dmps.SwitcherInputs[inputSelector] as DMInput; - output.AudioOut = input; - } - } - } - - #endregion - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Chassis/HdMd8xNController.cs b/src/PepperDash.Essentials.DM/Chassis/HdMd8xNController.cs deleted file mode 100644 index 958f71cc..00000000 --- a/src/PepperDash.Essentials.DM/Chassis/HdMd8xNController.cs +++ /dev/null @@ -1,518 +0,0 @@ -extern alias Full; - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using Full.Newtonsoft.Json; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.DM.Config; -using Crestron.SimplSharpPro.DM.Cards; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Config; - - -namespace PepperDash.Essentials.DM.Chassis -{ - [Description("Wrapper class for all HdMd8xN switchers")] - public class HdMd8xNController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback, IHasFeedback - { - private HdMd8xN _Chassis; - - public event EventHandler NumericSwitchChange; - - public Dictionary InputNames { get; set; } - public Dictionary OutputNames { get; set; } - - public RoutingPortCollection InputPorts { get; private set; } - public RoutingPortCollection OutputPorts { get; private set; } - - public FeedbackCollection VideoInputSyncFeedbacks { get; private set; } - public FeedbackCollection VideoOutputRouteFeedbacks { get; private set; } - public FeedbackCollection AudioOutputRouteFeedbacks { get; private set; } - public FeedbackCollection InputNameFeedbacks { get; private set; } - public FeedbackCollection OutputNameFeedbacks { get; private set; } - public FeedbackCollection OutputVideoRouteNameFeedbacks { get; private set; } - public FeedbackCollection OutputAudioRouteNameFeedbacks { get; private set; } - public StringFeedback DeviceNameFeedback { get; private set; } - - #region Constructor - - public HdMd8xNController(string key, string name, HdMd8xN chassis, - DMChassisPropertiesConfig props) - : base(key, name, chassis) - { - _Chassis = chassis; - Name = name; - _Chassis.EnableAudioBreakaway.BoolValue = true; - - if (props == null) - { - Debug.Console(1, this, "HdMd8xNController properties are null, failed to build the device"); - return; - } - - InputNames = new Dictionary(); - if (props.InputNames != null) - { - InputNames = props.InputNames; - } - OutputNames = new Dictionary(); - if (props.OutputNames != null) - { - OutputNames = props.OutputNames; - } - - DeviceNameFeedback = new StringFeedback(()=> Name); - - VideoInputSyncFeedbacks = new FeedbackCollection(); - VideoOutputRouteFeedbacks = new FeedbackCollection(); - AudioOutputRouteFeedbacks = new FeedbackCollection(); - InputNameFeedbacks = new FeedbackCollection(); - OutputNameFeedbacks = new FeedbackCollection(); - OutputVideoRouteNameFeedbacks = new FeedbackCollection(); - OutputAudioRouteNameFeedbacks = new FeedbackCollection(); - - InputPorts = new RoutingPortCollection(); - OutputPorts = new RoutingPortCollection(); - - //Inputs - should always be 8 audio/video inputs - for (uint i = 1; i <= _Chassis.NumberOfInputs; i++) - { - try - { - var index = i; - if (!InputNames.ContainsKey(index)) - { - InputNames.Add(index, string.Format("Input{0}", index)); - } - string inputName = InputNames[index]; - _Chassis.Inputs[index].Name.StringValue = inputName; - - - InputPorts.Add(new RoutingInputPort(inputName, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.Hdmi, _Chassis.Inputs[index], this) - { - FeedbackMatchObject = _Chassis.Inputs[index] - }); - - VideoInputSyncFeedbacks.Add(new BoolFeedback(inputName, () => _Chassis.Inputs[index].VideoDetectedFeedback.BoolValue)); - InputNameFeedbacks.Add(new StringFeedback(inputName, () => _Chassis.Inputs[index].NameFeedback.StringValue)); - } - catch (Exception ex) - { - ErrorLog.Error("Exception creating input {0} on HD-MD8xN Chassis: {1}", i, ex); - } - } - - //Outputs. Either 2 outputs (1 audio, 1 audio/video) for HD-MD8x1 or 4 outputs (2 audio, 2 audio/video) for HD-MD8x2 - for (uint i = 1; i <= _Chassis.NumberOfOutputs; i++) - { - try - { - var index = i; - if (!OutputNames.ContainsKey(index)) - { - OutputNames.Add(index, string.Format("Output{0}", index)); - } - string outputName = OutputNames[index]; - _Chassis.Outputs[index].Name.StringValue = outputName; - - OutputPorts.Add(new RoutingOutputPort(outputName, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.Hdmi, _Chassis.Outputs[index], this) - { - FeedbackMatchObject = _Chassis.Outputs[index] - }); - - OutputNameFeedbacks.Add(new StringFeedback(outputName, () => _Chassis.Outputs[index].NameFeedback.StringValue)); - VideoOutputRouteFeedbacks.Add(new IntFeedback(outputName, () => _Chassis.Outputs[index].VideoOutFeedback == null ? 0 : (int)_Chassis.Outputs[index].VideoOutFeedback.Number)); - AudioOutputRouteFeedbacks.Add(new IntFeedback(outputName, () => _Chassis.Outputs[index].AudioOutFeedback == null ? 0 : (int)_Chassis.Outputs[index].AudioOutFeedback.Number)); - OutputVideoRouteNameFeedbacks.Add(new StringFeedback(outputName, () => _Chassis.Outputs[index].VideoOutFeedback == null ? "None" : _Chassis.Outputs[index].VideoOutFeedback.NameFeedback.StringValue)); - OutputAudioRouteNameFeedbacks.Add(new StringFeedback(outputName, () => _Chassis.Outputs[index].AudioOutFeedback == null ? "None" : _Chassis.Outputs[index].VideoOutFeedback.NameFeedback.StringValue)); - } - catch (Exception ex) - { - ErrorLog.Error("Exception creating output {0} on HD-MD8xN Chassis: {1}", i, ex); - } - } - - _Chassis.DMInputChange += Chassis_DMInputChange; - _Chassis.DMOutputChange += Chassis_DMOutputChange; - - AddPostActivationAction(AddFeedbackCollections); - } - #endregion - - #region Methods - - /// - /// Raise an event when the status of a switch object changes. - /// - /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType - private void OnSwitchChange(RoutingNumericEventArgs e) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, e); - } - - #region PostActivate - - public void AddFeedbackCollections() - { - AddFeedbackToList(DeviceNameFeedback); - AddCollectionsToList(VideoInputSyncFeedbacks); - AddCollectionsToList(VideoOutputRouteFeedbacks, AudioOutputRouteFeedbacks); - AddCollectionsToList(InputNameFeedbacks, OutputNameFeedbacks, OutputVideoRouteNameFeedbacks, OutputAudioRouteNameFeedbacks); - } - - #endregion - - #region FeedbackCollection Methods - - //Add arrays of collections - public void AddCollectionsToList(params FeedbackCollection[] newFbs) - { - foreach (FeedbackCollection fbCollection in newFbs) - { - foreach (var item in newFbs) - { - AddCollectionToList(item); - } - } - } - public void AddCollectionsToList(params FeedbackCollection[] newFbs) - { - foreach (FeedbackCollection fbCollection in newFbs) - { - foreach (var item in newFbs) - { - AddCollectionToList(item); - } - } - } - - public void AddCollectionsToList(params FeedbackCollection[] newFbs) - { - foreach (FeedbackCollection fbCollection in newFbs) - { - foreach (var item in newFbs) - { - AddCollectionToList(item); - } - } - } - - //Add Collections - public void AddCollectionToList(FeedbackCollection newFbs) - { - foreach (var f in newFbs) - { - if (f == null) continue; - - AddFeedbackToList(f); - } - } - - public void AddCollectionToList(FeedbackCollection newFbs) - { - foreach (var f in newFbs) - { - if (f == null) continue; - - AddFeedbackToList(f); - } - } - - public void AddCollectionToList(FeedbackCollection newFbs) - { - foreach (var f in newFbs) - { - if (f == null) continue; - - AddFeedbackToList(f); - } - } - - //Add Individual Feedbacks - public void AddFeedbackToList(PepperDash.Essentials.Core.Feedback newFb) - { - if (newFb == null) return; - - if (!Feedbacks.Contains(newFb)) - { - Feedbacks.Add(newFb); - } - } - - #endregion - - #region IRouting Members - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType sigType) - { - var input = inputSelector as DMInput; - var output = outputSelector as DMOutput; - Debug.Console(2, this, "ExecuteSwitch: input={0} output={1} sigType={2}", input, output, sigType.ToString()); - - if (output == null) - { - Debug.Console(0, this, "Unable to make switch. Output selector is not DMOutput"); - return; - } - - if ((sigType & eRoutingSignalType.Video) == eRoutingSignalType.Video) - { - _Chassis.VideoEnter.BoolValue = true; - if (output != null) - { - output.VideoOut = input; - } - } - - if ((sigType & eRoutingSignalType.Audio) == eRoutingSignalType.Audio) - { - _Chassis.AudioEnter.BoolValue = true; - if (output != null) - { - output.AudioOut = input; - } - } - } - - #endregion - - #region IRoutingNumeric Members - - public void ExecuteNumericSwitch(ushort inputSelector, ushort outputSelector, eRoutingSignalType signalType) - { - - var input = inputSelector == 0 ? null : _Chassis.Inputs[inputSelector]; - var output = _Chassis.Outputs[outputSelector]; - - Debug.Console(2, this, "ExecuteNumericSwitch: input={0} output={1}", input, output); - - ExecuteSwitch(input, output, signalType); - } - - #endregion - - #endregion - - #region Bridge Linking - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new DmChassisControllerJoinMap(joinStart); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - - IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - - trilist.StringInput[joinMap.Name.JoinNumber].StringValue = this.Name; - - for (uint i = 1; i <= _Chassis.NumberOfInputs; i++) - { - var joinIndex = i - 1; - var input = i; - //Digital - VideoInputSyncFeedbacks[InputNames[input]].LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus.JoinNumber + joinIndex]); - - //Serial - InputNameFeedbacks[InputNames[input]].LinkInputSig(trilist.StringInput[joinMap.InputNames.JoinNumber + joinIndex]); - } - - for (uint i = 1; i <= _Chassis.NumberOfOutputs; i++) - { - var joinIndex = i - 1; - var output = i; - //Analog - VideoOutputRouteFeedbacks[OutputNames[output]].LinkInputSig(trilist.UShortInput[joinMap.OutputVideo.JoinNumber + joinIndex]); - trilist.SetUShortSigAction(joinMap.OutputVideo.JoinNumber + joinIndex, (a) => ExecuteNumericSwitch(a, (ushort)output, eRoutingSignalType.Video)); - AudioOutputRouteFeedbacks[OutputNames[output]].LinkInputSig(trilist.UShortInput[joinMap.OutputAudio.JoinNumber + joinIndex]); - trilist.SetUShortSigAction(joinMap.OutputAudio.JoinNumber + joinIndex, (a) => ExecuteNumericSwitch(a, (ushort)output, eRoutingSignalType.Audio)); - - //Serial - OutputNameFeedbacks[OutputNames[output]].LinkInputSig(trilist.StringInput[joinMap.OutputNames.JoinNumber + joinIndex]); - OutputVideoRouteNameFeedbacks[OutputNames[output]].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentVideoInputNames.JoinNumber + joinIndex]); - OutputAudioRouteNameFeedbacks[OutputNames[output]].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentAudioInputNames.JoinNumber + joinIndex]); - } - - _Chassis.OnlineStatusChange += Chassis_OnlineStatusChange; - - trilist.OnlineStatusChange += (d, args) => - { - if (!args.DeviceOnLine) return; - }; - } - - - #endregion - - #region Events - - void Chassis_OnlineStatusChange(Crestron.SimplSharpPro.GenericBase currentDevice, Crestron.SimplSharpPro.OnlineOfflineEventArgs args) - { - IsOnline.FireUpdate(); - - if (!args.DeviceOnLine) return; - - foreach (var feedback in Feedbacks) - { - feedback.FireUpdate(); - } - } - - void Chassis_DMOutputChange(Switch device, DMOutputEventArgs args) - { - switch (args.EventId) - { - case DMOutputEventIds.VideoOutEventId: - { - var output = args.Number; - var inputNumber = _Chassis.Outputs[output].VideoOutFeedback == null ? 0 : _Chassis.Outputs[output].VideoOutFeedback.Number; - - var outputName = OutputNames[output]; - - var feedback = VideoOutputRouteFeedbacks[outputName]; - - if (feedback == null) - { - return; - } - var inPort = InputPorts.FirstOrDefault(p => p.FeedbackMatchObject == _Chassis.Outputs[output].VideoOutFeedback); - var outPort = OutputPorts.FirstOrDefault(p => p.FeedbackMatchObject == _Chassis.Outputs[output]); - - feedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(output, inputNumber, outPort, inPort, eRoutingSignalType.Video)); - break; - } - case DMOutputEventIds.AudioOutEventId: - { - var output = args.Number; - var inputNumber = _Chassis.Outputs[output].AudioOutFeedback == null ? 0 : _Chassis.Outputs[output].AudioOutFeedback.Number; - - var outputName = OutputNames[output]; - - var feedback = AudioOutputRouteFeedbacks[outputName]; - - if (feedback == null) - { - return; - } - var inPort = InputPorts.FirstOrDefault(p => p.FeedbackMatchObject == _Chassis.Outputs[output].AudioOutFeedback); - var outPort = OutputPorts.FirstOrDefault(p => p.FeedbackMatchObject == _Chassis.Outputs[output]); - - feedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(output, inputNumber, outPort, inPort, eRoutingSignalType.Audio)); - break; - } - case DMOutputEventIds.OutputNameEventId: - case DMOutputEventIds.NameFeedbackEventId: - { - Debug.Console(1, this, "Event ID {0}: Updating name feedbacks.", args.EventId); - Debug.Console(1, this, "Output {0} Name {1}", args.Number, - _Chassis.Outputs[args.Number].NameFeedback.StringValue); - foreach (var item in OutputNameFeedbacks) - { - item.FireUpdate(); - } - break; - } - default: - { - Debug.Console(1, this, "Unhandled DM Output Event ID {0}", args.EventId); - break; - } - } - } - - void Chassis_DMInputChange(Switch device, DMInputEventArgs args) - { - switch (args.EventId) - { - case DMInputEventIds.VideoDetectedEventId: - { - Debug.Console(1, this, "Event ID {0}: Updating VideoInputSyncFeedbacks", args.EventId); - foreach (var item in VideoInputSyncFeedbacks) - { - item.FireUpdate(); - } - break; - } - case DMInputEventIds.InputNameFeedbackEventId: - case DMInputEventIds.InputNameEventId: - case DMInputEventIds.NameFeedbackEventId: - { - Debug.Console(1, this, "Event ID {0}: Updating name feedbacks.", args.EventId); - Debug.Console(1, this, "Input {0} Name {1}", args.Number, - _Chassis.Inputs[args.Number].NameFeedback.StringValue); - foreach (var item in InputNameFeedbacks) - { - item.FireUpdate(); - } - break; - } - default: - { - Debug.Console(1, this, "Unhandled DM Input Event ID {0}", args.EventId); - break; - } - } - } - - #endregion - - #region Factory - - public class HdMd8xNControllerFactory : EssentialsDeviceFactory - { - public HdMd8xNControllerFactory() - { - TypeNames = new List() { "hdmd8x2", "hdmd8x1" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new HD-MD-8xN Device"); - - var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); - - var type = dc.Type.ToLower(); - var control = props.Control; - var ipid = control.IpIdInt; - - switch (type) - { - case ("hdmd8x2"): - return new HdMd8xNController(dc.Key, dc.Name, new HdMd8x2(ipid, Global.ControlSystem), props); - case ("hdmd8x1"): - return new HdMd8xNController(dc.Key, dc.Name, new HdMd8x1(ipid, Global.ControlSystem), props); - default: - return null; - } - } - } - - #endregion - - - - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Chassis/HdMdNxM4kEBridgeableController.cs b/src/PepperDash.Essentials.DM/Chassis/HdMdNxM4kEBridgeableController.cs deleted file mode 100644 index a2265497..00000000 --- a/src/PepperDash.Essentials.DM/Chassis/HdMdNxM4kEBridgeableController.cs +++ /dev/null @@ -1,506 +0,0 @@ -extern alias Full; - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using Full.Newtonsoft.Json; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.DM.Config; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Config; - -namespace PepperDash.Essentials.DM.Chassis -{ - [Description("Wrapper class for all HdMdNxM4E switchers")] - public class HdMdNxM4kEBridgeableController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback, IHasFeedback - { - private HdMdNxM _Chassis; - private HdMd4x14kE _Chassis4x1; - - //IroutingNumericEvent - public event EventHandler NumericSwitchChange; - - public Dictionary InputNames { get; set; } - public Dictionary OutputNames { get; set; } - - public RoutingPortCollection InputPorts { get; private set; } - public RoutingPortCollection OutputPorts { get; private set; } - - public FeedbackCollection VideoInputSyncFeedbacks { get; private set; } - public FeedbackCollection VideoOutputRouteFeedbacks { get; private set; } - public FeedbackCollection InputNameFeedbacks { get; private set; } - public FeedbackCollection OutputNameFeedbacks { get; private set; } - public FeedbackCollection OutputRouteNameFeedbacks { get; private set; } - public FeedbackCollection InputHdcpEnableFeedback { get; private set; } - public StringFeedback DeviceNameFeedback { get; private set; } - public BoolFeedback AutoRouteFeedback { get; private set; } - - #region Constructor - - public HdMdNxM4kEBridgeableController(string key, string name, HdMdNxM chassis, - HdMdNxM4kEBridgeablePropertiesConfig props) - : base(key, name, chassis) - { - _Chassis = chassis; - Name = name; - - if (props == null) - { - Debug.Console(1, this, "HdMdNx4keBridgeableController properties are null, failed to build the device"); - return; - } - - - if (props.Inputs != null) - { - foreach (var kvp in props.Inputs) - { - Debug.Console(1, this, "props.Inputs: {0}-{1}", kvp.Key, kvp.Value); - } - InputNames = props.Inputs; - } - if (props.Outputs != null) - { - foreach (var kvp in props.Outputs) - { - Debug.Console(1, this, "props.Outputs: {0}-{1}", kvp.Key, kvp.Value); - } - OutputNames = props.Outputs; - } - - DeviceNameFeedback = new StringFeedback(()=>Name); - - VideoInputSyncFeedbacks = new FeedbackCollection(); - VideoOutputRouteFeedbacks = new FeedbackCollection(); - InputNameFeedbacks = new FeedbackCollection(); - OutputNameFeedbacks = new FeedbackCollection(); - OutputRouteNameFeedbacks = new FeedbackCollection(); - InputHdcpEnableFeedback = new FeedbackCollection(); - - InputPorts = new RoutingPortCollection(); - OutputPorts = new RoutingPortCollection(); - - if (_Chassis.NumberOfInputs == 1) - { - _Chassis4x1 = _Chassis as HdMd4x14kE; - AutoRouteFeedback = new BoolFeedback(() => _Chassis4x1.AutoModeOnFeedback.BoolValue); - } - - for (uint i = 1; i <= _Chassis.NumberOfInputs; i++) - { - var index = i; - var inputName = InputNames[index]; - //_Chassis.Inputs[index].Name.StringValue = inputName; - _Chassis.HdmiInputs[index].Name.StringValue = inputName; - - InputPorts.Add(new RoutingInputPort(inputName, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.Hdmi, _Chassis.HdmiInputs[index], this) - { - FeedbackMatchObject = _Chassis.HdmiInputs[index] - }); - VideoInputSyncFeedbacks.Add(new BoolFeedback(inputName, () => _Chassis.Inputs[index].VideoDetectedFeedback.BoolValue)); - //InputNameFeedbacks.Add(new StringFeedback(inputName, () => _Chassis.Inputs[index].NameFeedback.StringValue)); - InputNameFeedbacks.Add(new StringFeedback(inputName, () => InputNames[index])); - InputHdcpEnableFeedback.Add(new BoolFeedback(inputName, () => _Chassis.HdmiInputs[index].HdmiInputPort.HdcpSupportOnFeedback.BoolValue)); - } - - for (uint i = 1; i <= _Chassis.NumberOfOutputs; i++) - { - var index = i; - var outputName = OutputNames[index]; - //_Chassis.Outputs[index].Name.StringValue = outputName; - //_Chassis.HdmiOutputs[index].Name.StringValue = outputName; - - OutputPorts.Add(new RoutingOutputPort(outputName, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.Hdmi, _Chassis.HdmiOutputs[index], this) - { - FeedbackMatchObject = _Chassis.HdmiOutputs[index] - }); - VideoOutputRouteFeedbacks.Add(new IntFeedback(outputName, () => _Chassis.Outputs[index].VideoOutFeedback == null ? 0 : (int)_Chassis.Outputs[index].VideoOutFeedback.Number)); - OutputNameFeedbacks.Add(new StringFeedback(outputName, () => OutputNames[index])); - OutputRouteNameFeedbacks.Add(new StringFeedback(outputName, () => _Chassis.Outputs[index].VideoOutFeedback.NameFeedback.StringValue)); - } - - _Chassis.DMInputChange += Chassis_DMInputChange; - _Chassis.DMOutputChange += Chassis_DMOutputChange; - - AddPostActivationAction(AddFeedbackCollections); - } - - #endregion - - #region Methods - - /// - /// Raise an event when the status of a switch object changes. - /// - /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType - private void OnSwitchChange(RoutingNumericEventArgs e) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, e); - } - - public void EnableHdcp(uint port) - { - if (port > _Chassis.NumberOfInputs) return; - if (port <= 0) return; - - _Chassis.HdmiInputs[port].HdmiInputPort.HdcpSupportOn(); - InputHdcpEnableFeedback[InputNames[port]].FireUpdate(); - } - - public void DisableHdcp(uint port) - { - if (port > _Chassis.NumberOfInputs) return; - if (port <= 0) return; - - _Chassis.HdmiInputs[port].HdmiInputPort.HdcpSupportOff(); - InputHdcpEnableFeedback[InputNames[port]].FireUpdate(); - } - - public void EnableAutoRoute() - { - if (_Chassis.NumberOfInputs != 1) return; - - if (_Chassis4x1 == null) return; - - _Chassis4x1.AutoModeOn(); - } - - public void DisableAutoRoute() - { - if (_Chassis.NumberOfInputs != 1) return; - - if (_Chassis4x1 == null) return; - - _Chassis4x1.AutoModeOff(); - } - - #region PostActivate - - public void AddFeedbackCollections() - { - AddFeedbackToList(DeviceNameFeedback); - AddCollectionsToList(VideoInputSyncFeedbacks, InputHdcpEnableFeedback); - AddCollectionsToList(VideoOutputRouteFeedbacks); - AddCollectionsToList(InputNameFeedbacks, OutputNameFeedbacks, OutputRouteNameFeedbacks); - } - - #endregion - - #region FeedbackCollection Methods - - //Add arrays of collections - public void AddCollectionsToList(params FeedbackCollection[] newFbs) - { - foreach (FeedbackCollection fbCollection in newFbs) - { - foreach (var item in newFbs) - { - AddCollectionToList(item); - } - } - } - public void AddCollectionsToList(params FeedbackCollection[] newFbs) - { - foreach (FeedbackCollection fbCollection in newFbs) - { - foreach (var item in newFbs) - { - AddCollectionToList(item); - } - } - } - - public void AddCollectionsToList(params FeedbackCollection[] newFbs) - { - foreach (FeedbackCollection fbCollection in newFbs) - { - foreach (var item in newFbs) - { - AddCollectionToList(item); - } - } - } - - //Add Collections - public void AddCollectionToList(FeedbackCollection newFbs) - { - foreach (var f in newFbs) - { - if (f == null) continue; - - AddFeedbackToList(f); - } - } - - public void AddCollectionToList(FeedbackCollection newFbs) - { - foreach (var f in newFbs) - { - if (f == null) continue; - - AddFeedbackToList(f); - } - } - - public void AddCollectionToList(FeedbackCollection newFbs) - { - foreach (var f in newFbs) - { - if (f == null) continue; - - AddFeedbackToList(f); - } - } - - //Add Individual Feedbacks - public void AddFeedbackToList(PepperDash.Essentials.Core.Feedback newFb) - { - if (newFb == null) return; - - if (!Feedbacks.Contains(newFb)) - { - Feedbacks.Add(newFb); - } - } - - #endregion - - #region IRouting Members - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - var input = inputSelector as HdMdNxMHdmiInput; //changed from HdMdNxM4kzEHdmiInput; - var output = outputSelector as HdMdNxMHdmiOutput; - Debug.Console(2, this, "ExecuteSwitch: input={0} output={1}", input, output); - - if (output == null) - { - Debug.Console(0, this, "Unable to make switch. output selector is not HdMdNxMHdmiOutput"); - return; - } - - // Try to make switch only when necessary. The unit appears to toggle when already selected. - var current = output.VideoOut; - if (current != input) - output.VideoOut = input; - } - - #endregion - - #region IRoutingNumeric Members - - public void ExecuteNumericSwitch(ushort inputSelector, ushort outputSelector, eRoutingSignalType signalType) - { - var input = inputSelector == 0 ? null : _Chassis.HdmiInputs[inputSelector]; - var output = _Chassis.HdmiOutputs[outputSelector]; - - Debug.Console(2, this, "ExecuteNumericSwitch: input={0} output={1}", input, output); - - ExecuteSwitch(input, output, signalType); - } - - #endregion - - #endregion - - #region Bridge Linking - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new HdMdNxM4kEControllerJoinMap(joinStart); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - - IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - DeviceNameFeedback.LinkInputSig(trilist.StringInput[joinMap.Name.JoinNumber]); - - if (_Chassis4x1 != null) - { - trilist.SetSigTrueAction(joinMap.EnableAutoRoute.JoinNumber, () => _Chassis4x1.AutoModeOn()); - trilist.SetSigFalseAction(joinMap.EnableAutoRoute.JoinNumber, () => _Chassis4x1.AutoModeOff()); - AutoRouteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableAutoRoute.JoinNumber]); - } - - for (uint i = 1; i <= _Chassis.NumberOfInputs; i++) - { - var joinIndex = i - 1; - var input = i; - //Digital - VideoInputSyncFeedbacks[InputNames[input]].LinkInputSig(trilist.BooleanInput[joinMap.InputSync.JoinNumber + joinIndex]); - InputHdcpEnableFeedback[InputNames[input]].LinkInputSig(trilist.BooleanInput[joinMap.EnableInputHdcp.JoinNumber + joinIndex]); - InputHdcpEnableFeedback[InputNames[input]].LinkComplementInputSig(trilist.BooleanInput[joinMap.DisableInputHdcp.JoinNumber + joinIndex]); - trilist.SetSigTrueAction(joinMap.EnableInputHdcp.JoinNumber + joinIndex, () => EnableHdcp(input)); - trilist.SetSigTrueAction(joinMap.DisableInputHdcp.JoinNumber + joinIndex, () => DisableHdcp(input)); - - //Serial - InputNameFeedbacks[InputNames[input]].LinkInputSig(trilist.StringInput[joinMap.InputName.JoinNumber + joinIndex]); - } - - for (uint i = 1; i <= _Chassis.NumberOfOutputs; i++) - { - var joinIndex = i - 1; - var output = i; - //Analog - VideoOutputRouteFeedbacks[OutputNames[output]].LinkInputSig(trilist.UShortInput[joinMap.OutputRoute.JoinNumber + joinIndex]); - trilist.SetUShortSigAction(joinMap.OutputRoute.JoinNumber + joinIndex, (a) => ExecuteNumericSwitch(a, (ushort) output, eRoutingSignalType.AudioVideo)); - - //Serial - OutputNameFeedbacks[OutputNames[output]].LinkInputSig(trilist.StringInput[joinMap.OutputName.JoinNumber + joinIndex]); - OutputRouteNameFeedbacks[OutputNames[output]].LinkInputSig(trilist.StringInput[joinMap.OutputRoutedName.JoinNumber + joinIndex]); - } - - _Chassis.OnlineStatusChange += Chassis_OnlineStatusChange; - - trilist.OnlineStatusChange += (d, args) => - { - if (!args.DeviceOnLine) return; - - // feedback updates was moved to the Chassis_OnlineStatusChange - // due to the amount of time it takes for the device to come online - }; - } - - - #endregion - - #region Events - - void Chassis_OnlineStatusChange(Crestron.SimplSharpPro.GenericBase currentDevice, Crestron.SimplSharpPro.OnlineOfflineEventArgs args) - { - IsOnline.FireUpdate(); - - if (!args.DeviceOnLine) return; - - foreach (var feedback in Feedbacks) - { - feedback.FireUpdate(); - } - - if (_Chassis4x1 != null) - AutoRouteFeedback.FireUpdate(); - } - - void Chassis_DMOutputChange(Switch device, DMOutputEventArgs args) - { - if (args.EventId != DMOutputEventIds.VideoOutEventId) return; - - var output = args.Number; - - var inputNumber = _Chassis.HdmiOutputs[output].VideoOutFeedback == null - ? 0 - : _Chassis.HdmiOutputs[output].VideoOutFeedback.Number; - - var outputName = OutputNames[output]; - - var feedback = VideoOutputRouteFeedbacks[outputName]; - - if (feedback == null) - { - return; - } - var inPort = - InputPorts.FirstOrDefault(p => p.FeedbackMatchObject == _Chassis.HdmiOutputs[output].VideoOutFeedback); - var outPort = OutputPorts.FirstOrDefault(p => p.FeedbackMatchObject == _Chassis.HdmiOutputs[output]); - - feedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(output, inputNumber, outPort, inPort, eRoutingSignalType.AudioVideo)); - } - - void Chassis_DMInputChange(Switch device, DMInputEventArgs args) - { - switch (args.EventId) - { - case DMInputEventIds.VideoDetectedEventId: - { - Debug.Console(1, this, "Event ID {0}: Updating VideoInputSyncFeedbacks", args.EventId); - foreach (var item in VideoInputSyncFeedbacks) - { - item.FireUpdate(); - } - break; - } - case DMInputEventIds.InputNameFeedbackEventId: - case DMInputEventIds.InputNameEventId: - case DMInputEventIds.NameFeedbackEventId: - { - Debug.Console(1, this, "Event ID {0}: Updating name feedbacks.", args.EventId); - Debug.Console(1, this, "Input {0} Name {1}", args.Number, - _Chassis.HdmiInputs[args.Number].NameFeedback.StringValue); - foreach (var item in InputNameFeedbacks) - { - item.FireUpdate(); - } - break; - } - default: - { - Debug.Console(1, this, "Unhandled DM Input Event ID {0}", args.EventId); - break; - } - } - } - - #endregion - - #region Factory - - public class HdMdNxM4kEControllerFactory : EssentialsDeviceFactory - { - public HdMdNxM4kEControllerFactory() - { - TypeNames = new List() { "hdmd4x14ke-bridgeable", "hdmd4x24ke", "hdmd6x24ke" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new HD-MD-NxM-4K-E Device"); - - var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); - - var type = dc.Type.ToLower(); - var control = props.Control; - var ipid = control.IpIdInt; - var address = control.TcpSshProperties.Address; - - switch (type) - { - case ("hdmd4x14ke-bridgeable"): - return new HdMdNxM4kEBridgeableController(dc.Key, dc.Name, new HdMd4x14kE(ipid, address, Global.ControlSystem), props); - case ("hdmd4x24ke"): - return new HdMdNxM4kEBridgeableController(dc.Key, dc.Name, new HdMd4x24kE(ipid, address, Global.ControlSystem), props); - case ("hdmd6x24ke"): - return new HdMdNxM4kEBridgeableController(dc.Key, dc.Name, new HdMd6x24kE(ipid, address, Global.ControlSystem), props); - default: - return null; - } - } - } - - #endregion - - - - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Chassis/HdMdNxM4kEController.cs b/src/PepperDash.Essentials.DM/Chassis/HdMdNxM4kEController.cs deleted file mode 100644 index 90186587..00000000 --- a/src/PepperDash.Essentials.DM/Chassis/HdMdNxM4kEController.cs +++ /dev/null @@ -1,171 +0,0 @@ -extern alias Full; - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.DM; -using Full.Newtonsoft.Json; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; -using PepperDash.Essentials.DM.Config; - -namespace PepperDash.Essentials.DM.Chassis -{ - [Obsolete("Please use HdMdNxM4kEBridgeable Controller")] - public class HdMdNxM4kEController : CrestronGenericBaseDevice, IRoutingInputsOutputs, IRouting - { - public HdMdNxM Chassis { get; private set; } - - public RoutingPortCollection InputPorts { get; private set; } - public RoutingPortCollection OutputPorts { get; private set; } - - - /// - /// - /// - /// - /// - /// - public HdMdNxM4kEController(string key, string name, HdMdNxM chassis, - HdMdNxM4kEPropertiesConfig props) - : base(key, name, chassis) - { - Debug.Console(0, this, "Type hdmd4x14ke is obsolete. Please use hdmd4x14ke-bridgeable"); - Chassis = chassis; - - // logical ports - InputPorts = new RoutingPortCollection(); - for (uint i = 1; i <= 4; i++) - { - InputPorts.Add(new RoutingInputPort("hdmiIn" + i, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, i, this)); - } - OutputPorts = new RoutingPortCollection(); - OutputPorts.Add(new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, null, this)); - - // physical settings - if (props != null && props.Inputs != null) - { - var inputRegex = new Regex(@"(?\d)", RegexOptions.IgnoreCase); - foreach (var kvp in props.Inputs) - { - // get numnbers from key and convert to int - //var inputNum = Convert.ToUInt32(kvp.Key.Substring(6)); - var inputMatch = inputRegex.Match(kvp.Key); - if (inputMatch == null) continue; - - var inputNum = Convert.ToUInt32(inputMatch.Groups["InputNum"].Value); - - var port = chassis.HdmiInputs[inputNum].HdmiInputPort; - // set hdcp disables - if (kvp.Value.DisableHdcp) - { - Debug.Console(0, this, "Configuration disables HDCP support on {0}", kvp.Key); - port.HdcpSupportOff(); - } - else - port.HdcpSupportOn(); - } - } - } - - public override bool CustomActivate() - { - var result = Chassis.Register(); - if (result != Crestron.SimplSharpPro.eDeviceRegistrationUnRegistrationResponse.Success) - { - Debug.Console(0, this, "Device registration failed: {0}", result); - return false; - } - - return base.CustomActivate(); - } - - - - #region IRouting Members - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - // Try to make switch only when necessary. The unit appears to toggle when already selected. - var current = Chassis.HdmiOutputs[1].VideoOut; - if (current != Chassis.HdmiInputs[(uint)inputSelector]) - Chassis.HdmiOutputs[1].VideoOut = Chassis.HdmiInputs[(uint)inputSelector]; - } - - #endregion - - ///////////////////////////////////////////////////// - - /// - /// - /// - /// - /// - /// - /// - /// - /// /* - /* - public static HdMdNxM4kEController GetController(string key, string name, - string type, HdMdNxM4kEPropertiesConfig properties) - { - try - { - var ipid = properties.Control.IpIdInt; - var address = properties.Control.TcpSshProperties.Address; - - type = type.ToLower(); - if (type == "hdmd4x14ke") - { - Debug.Console(0, @"The 'hdmd4x14ke' device is not an Essentials Bridgeable device. - If an essentials Bridgeable Device is required, use the 'hdmd4x14ke-bridgeable' type"); - - var chassis = new HdMd4x14kE(ipid, address, Global.ControlSystem); - return new HdMdNxM4kEController(key, name, chassis, properties); - } - return null; - } - catch (Exception e) - { - Debug.Console(0, "ERROR Creating device key {0}: \r{1}", key, e); - return null; - } - }*/ - - #region Factory - - public class HdMdNxM4kEFactory : EssentialsDeviceFactory - { - public HdMdNxM4kEFactory() - { - TypeNames = new List() {"hdmd4x14ke"}; - } - - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new HD-MD-NxM-4K-E Device"); - - var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); - - var type = dc.Type.ToLower(); - var control = props.Control; - var ipid = control.IpIdInt; - var address = control.TcpSshProperties.Address; - - return new HdMdNxM4kEController(dc.Key, dc.Name, new HdMd4x14kE(ipid, address, Global.ControlSystem), props); - - } - } - - #endregion - - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Config/DMChassisConfig.cs b/src/PepperDash.Essentials.DM/Config/DMChassisConfig.cs deleted file mode 100644 index 21604140..00000000 --- a/src/PepperDash.Essentials.DM/Config/DMChassisConfig.cs +++ /dev/null @@ -1,59 +0,0 @@ -extern alias Full; - -using System; -using System.Collections.Generic; -using Crestron.SimplSharpPro.DM; -using Full.Newtonsoft.Json; -using Full.Newtonsoft.Json.Converters; -using PepperDash.Core; -using PepperDash.Essentials.Core; - -namespace PepperDash.Essentials.DM.Config -{ - /// - /// Represents the "properties" property of a DM device config - /// - public class DMChassisPropertiesConfig - { - [JsonProperty("control")] - public ControlPropertiesConfig Control { get; set; } - - [JsonProperty("volumeControls")] - public Dictionary VolumeControls { get; set; } - - [JsonProperty("inputSlots")] - public Dictionary InputSlots { get; set; } - - [JsonProperty("outputSlots")] - public Dictionary OutputSlots { get; set; } - - [JsonProperty("inputNames")] - public Dictionary InputNames { get; set; } - - [JsonProperty("outputNames")] - public Dictionary OutputNames { get; set; } - - [JsonProperty("noRouteText")] - public string NoRouteText { get; set; } - - [JsonProperty("inputSlotSupportsHdcp2")] - public Dictionary InputSlotSupportsHdcp2 { get; set; } - - public DMChassisPropertiesConfig() - { - InputSlotSupportsHdcp2 = new Dictionary(); - } - } - - /// - /// - /// - public class DmCardAudioPropertiesConfig - { - [JsonProperty("outLevel")] - public int OutLevel { get; set; } - - [JsonProperty("isVolumeControlPoint")] - public bool IsVolumeControlPoint { get; set; } - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Config/DeviceFactory.cs b/src/PepperDash.Essentials.DM/Config/DeviceFactory.cs deleted file mode 100644 index 0cd08ec2..00000000 --- a/src/PepperDash.Essentials.DM/Config/DeviceFactory.cs +++ /dev/null @@ -1,53 +0,0 @@ -extern alias Full; - -using System; -using System.Linq; -using System.Collections.Generic; -using Crestron.SimplSharp; -using Crestron.SimplSharp.CrestronIO; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.AirMedia; -using Crestron.SimplSharpPro.UI; -using Crestron.SimplSharp.Reflection; - -using Full.Newtonsoft.Json; -using Full.Newtonsoft.Json.Linq; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; -using PepperDash.Essentials.DM.AirMedia; -using PepperDash.Essentials.DM.Endpoints.DGEs; - -namespace PepperDash.Essentials.DM -{ - /// - /// Responsible for loading the type factories for this library - /// - public class DeviceFactory - { - public DeviceFactory() - { - var assy = Assembly.GetExecutingAssembly(); - PluginLoader.SetEssentialsAssembly(assy.GetName().Name, assy); - - var types = assy.GetTypes().Where(ct => typeof(IDeviceFactory).IsAssignableFrom(ct) && !ct.IsInterface && !ct.IsAbstract); - - if (types != null) - { - foreach (var type in types) - { - try - { - var factory = (IDeviceFactory)Crestron.SimplSharp.Reflection.Activator.CreateInstance(type); - factory.LoadTypeFactories(); - } - catch (Exception e) - { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to load type: '{1}' DeviceFactory: {0}", e, type.Name); - } - } - } - } - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Config/DmRmcConfig.cs b/src/PepperDash.Essentials.DM/Config/DmRmcConfig.cs deleted file mode 100644 index 32d88bd5..00000000 --- a/src/PepperDash.Essentials.DM/Config/DmRmcConfig.cs +++ /dev/null @@ -1,26 +0,0 @@ -extern alias Full; - -using System; -using System.Collections.Generic; -using Crestron.SimplSharpPro.DM; -using Full.Newtonsoft.Json; -using Full.Newtonsoft.Json.Converters; -using PepperDash.Core; - -namespace PepperDash.Essentials.DM.Config -{ - /// - /// Represents the "properties" property of a DM TX device config - /// - public class DmRmcPropertiesConfig - { - [JsonProperty("control")] - public ControlPropertiesConfig Control { get; set; } - - [JsonProperty("parentDeviceKey")] - public string ParentDeviceKey { get; set; } - - [JsonProperty("parentOutputNumber")] - public uint ParentOutputNumber { get; set; } - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Config/DmTxConfig.cs b/src/PepperDash.Essentials.DM/Config/DmTxConfig.cs deleted file mode 100644 index c5c80b24..00000000 --- a/src/PepperDash.Essentials.DM/Config/DmTxConfig.cs +++ /dev/null @@ -1,29 +0,0 @@ -extern alias Full; - -using System; -using System.Collections.Generic; -using Crestron.SimplSharpPro.DM; -using Full.Newtonsoft.Json; -using Full.Newtonsoft.Json.Converters; -using PepperDash.Core; - -namespace PepperDash.Essentials.DM.Config -{ - /// - /// Represents the "properties" property of a DM TX device config - /// - public class DmTxPropertiesConfig - { - [JsonProperty("control")] - public ControlPropertiesConfig Control { get; set; } - - [JsonProperty("parentDeviceKey")] - public string ParentDeviceKey { get; set; } - - [JsonProperty("parentInputNumber")] - public uint ParentInputNumber { get; set; } - - [JsonProperty("autoSwitching")] - public bool AutoSwitching { get; set; } - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Config/DmpsRoutingConfig.cs b/src/PepperDash.Essentials.DM/Config/DmpsRoutingConfig.cs deleted file mode 100644 index 202455d0..00000000 --- a/src/PepperDash.Essentials.DM/Config/DmpsRoutingConfig.cs +++ /dev/null @@ -1,35 +0,0 @@ -extern alias Full; - -using System; -using System.Collections.Generic; -using Crestron.SimplSharpPro.DM; -using Full.Newtonsoft.Json; -using Full.Newtonsoft.Json.Converters; -using PepperDash.Core; -using PepperDash.Essentials.Core; - -namespace PepperDash.Essentials.DM.Config -{ - /// - /// Represents the "properties" property of a DM device config - /// - public class DmpsRoutingPropertiesConfig - { - [JsonProperty("inputNames")] - public Dictionary InputNames { get; set; } - - [JsonProperty("outputNames")] - public Dictionary OutputNames { get; set; } - - [JsonProperty("noRouteText")] - public string NoRouteText { get; set; } - - public DmpsRoutingPropertiesConfig() - { - InputNames = new Dictionary(); - OutputNames = new Dictionary(); - } - } - - -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Config/HdMdNxM4kEPropertiesConfig.cs b/src/PepperDash.Essentials.DM/Config/HdMdNxM4kEPropertiesConfig.cs deleted file mode 100644 index 4b28df12..00000000 --- a/src/PepperDash.Essentials.DM/Config/HdMdNxM4kEPropertiesConfig.cs +++ /dev/null @@ -1,37 +0,0 @@ -extern alias Full; - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Full.Newtonsoft.Json; - -using PepperDash.Core; - -namespace PepperDash.Essentials.DM.Config -{ - /// - /// Defines the properties section of HdMdNxM boxes - /// - public class HdMdNxM4kEPropertiesConfig - { - [JsonProperty("control")] - public ControlPropertiesConfig Control { get; set; } - - [JsonProperty("inputs")] - public Dictionary Inputs { get; set; } - } - - public class HdMdNxM4kEBridgeablePropertiesConfig - { - [JsonProperty("control")] - public ControlPropertiesConfig Control { get; set; } - - [JsonProperty("inputs")] - public Dictionary Inputs { get; set; } - - [JsonProperty("outputs")] - public Dictionary Outputs { get; set; } - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Config/InputPropertiesConfig.cs b/src/PepperDash.Essentials.DM/Config/InputPropertiesConfig.cs deleted file mode 100644 index 54fe978e..00000000 --- a/src/PepperDash.Essentials.DM/Config/InputPropertiesConfig.cs +++ /dev/null @@ -1,16 +0,0 @@ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; - -namespace PepperDash.Essentials.DM.Config -{ - public class InputPropertiesConfig - { - public string Name { get; set; } - - public bool DisableHdcp { get; set; } - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/DmLite/HdMdxxxCEController.cs b/src/PepperDash.Essentials.DM/DmLite/HdMdxxxCEController.cs deleted file mode 100644 index f7dd6fca..00000000 --- a/src/PepperDash.Essentials.DM/DmLite/HdMdxxxCEController.cs +++ /dev/null @@ -1,319 +0,0 @@ -extern alias Full; - -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 Full.Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Config; - -namespace PepperDash.Essentials.DM -{ - /// - /// Represent both a transmitter and receiver pair of the HD-MD-400-C-E / HD-MD-300-C-E / HD-MD-200-C-E kits - /// - [Description("Wrapper class for all HD-MD variants")] - public class HdMdxxxCEController : CrestronGenericBridgeableBaseDevice, IRouting//, IComPorts - { - /// - ///// DmLite Ports - ///// - //public RoutingOutputPort ToRx { get; private set; } - //public RoutingInputPort FromTx { get; private set; } - - public RoutingOutputPort HdmiOut { get; private set; } - - public HdMdxxxCE TxRxPair { get; private set; } - - public RoutingPortCollection InputPorts { get; private set; } - - /// - /// The value of the current video source for the HDMI output on the receiver - /// - public IntFeedback VideoSourceFeedback { get; private set; } - - /// - /// Indicates if Auto Route is on on the transmitter - /// - public BoolFeedback AutoRouteOnFeedback { get; private set; } - - /// - /// Indicates if Priority Routing is on on the transmitter - /// - public BoolFeedback PriorityRoutingOnFeedback { get; private set; } - - /// - /// INdicates if the On Screen Display is enabled - /// - public BoolFeedback InputOnScreenDisplayEnabledFeedback { get; private set; } - - /// - /// Indicates if video sync is detected on each of the inputs - /// - public Dictionary SyncDetectedFeedbacks { get; private set; } - - /// - /// Indicates if the remote end device is detected - /// - public BoolFeedback RemoteEndDetectedFeedback { get; private set; } - - public RoutingPortCollection OutputPorts - { - get { return new RoutingPortCollection { HdmiOut }; } - } - - public HdMdxxxCEController(string key, string name, HdMdxxxCE txRxPair) - :base(key, name, txRxPair) - { - - TxRxPair = txRxPair; - - RemoteEndDetectedFeedback = new BoolFeedback(() => TxRxPair.RemoteEndDetectedOnFeedback.BoolValue); - - AutoRouteOnFeedback = new BoolFeedback(() => TxRxPair.TransmitterAutoModeOnFeedback.BoolValue); - - PriorityRoutingOnFeedback = new BoolFeedback(() => TxRxPair.PriorityRoutingOnFeedback.BoolValue); - - InputOnScreenDisplayEnabledFeedback = new BoolFeedback(() => TxRxPair.OnScreenDisplayEnabledFeedback.BoolValue); - - InputPorts = new RoutingPortCollection(); - - SyncDetectedFeedbacks = new Dictionary(); - - // Add the HDMI input port on the receiver - InputPorts.Add(new RoutingInputPort(DmPortName.Hdmi, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, 1, this)); - - SyncDetectedFeedbacks.Add(1, new BoolFeedback( () => TxRxPair.HdmiInputs[1].VideoDetectedFeedback.BoolValue)); - - if(txRxPair is HdMd400CE) - { - InputPorts.Add(new RoutingInputPort(DmPortName.HdmiIn1, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, 2, this)); - SyncDetectedFeedbacks.Add(2, new BoolFeedback(() => TxRxPair.HdmiInputs[2].VideoDetectedFeedback.BoolValue)); - - InputPorts.Add(new RoutingInputPort(DmPortName.HdmiIn2, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, 3, this)); - SyncDetectedFeedbacks.Add(3, new BoolFeedback(() => TxRxPair.HdmiInputs[3].VideoDetectedFeedback.BoolValue)); - - InputPorts.Add(new RoutingInputPort(DmPortName.VgaIn, eRoutingSignalType.Video | eRoutingSignalType.Audio, - eRoutingPortConnectionType.Vga, 4, this)); - SyncDetectedFeedbacks.Add(4, new BoolFeedback(() => TxRxPair.VgaInputs[1].VideoDetectedFeedback.BoolValue)); - - // Set Ports for CEC - InputPorts[DmPortName.HdmiIn1].Port = TxRxPair.HdmiInputs[1]; - InputPorts[DmPortName.HdmiIn2].Port = TxRxPair.HdmiInputs[2]; - } - else if (txRxPair is HdMd300CE) - { - InputPorts.Add(new RoutingInputPort(DmPortName.HdmiIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, 2, this)); - SyncDetectedFeedbacks.Add(2, new BoolFeedback(() => TxRxPair.HdmiInputs[2].VideoDetectedFeedback.BoolValue)); - - InputPorts.Add(new RoutingInputPort(DmPortName.VgaIn, eRoutingSignalType.Video | eRoutingSignalType.Audio, - eRoutingPortConnectionType.Vga, 3, this)); - SyncDetectedFeedbacks.Add(3, new BoolFeedback(() => TxRxPair.VgaInputs[1].VideoDetectedFeedback.BoolValue)); - - // Set Ports for CEC - InputPorts[DmPortName.HdmiIn].Port = TxRxPair.HdmiInputs[1]; - } - else if (txRxPair is HdMd200CE || txRxPair is HdMd200C1GE) - { - InputPorts.Add(new RoutingInputPort(DmPortName.HdmiIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, 2, this)); - SyncDetectedFeedbacks.Add(2, new BoolFeedback(() => TxRxPair.HdmiInputs[2].VideoDetectedFeedback.BoolValue)); - - // Set Ports for CEC - InputPorts[DmPortName.HdmiIn].Port = TxRxPair.HdmiInputs[1]; - } - - //ToRx = new RoutingOutputPort(DmPortName.ToTx, eRoutingSignalType.Audio | eRoutingSignalType.Video, - // eRoutingPortConnectionType.DmCat, null, this); - - //FromTx = new RoutingInputPort(DmPortName.FromTx, eRoutingSignalType.Audio | eRoutingSignalType.Video, - // eRoutingPortConnectionType.DmCat, null, this); - - HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, null, this); - - OutputPorts[DmPortName.HdmiOut].Port = TxRxPair.HdmiOutputs[1]; - - TxRxPair.DMInputChange += new DMInputEventHandler(TxRxPair_DMInputChange); - TxRxPair.DMOutputChange += new DMOutputEventHandler(TxRxPair_DMOutputChange); - TxRxPair.DMSystemChange += new DMSystemEventHandler(TxRxPair_DMSystemChange); - - VideoSourceFeedback = new IntFeedback(() => (int)TxRxPair.HdmiOutputs[1].VideoOutFeedback.Number); - } - - void TxRxPair_DMSystemChange(Switch device, DMSystemEventArgs args) - { - if (args.EventId == DMSystemEventIds.RemoteEndDetectedEventId) - RemoteEndDetectedFeedback.FireUpdate(); - else if (args.EventId == DMSystemEventIds.TransmitterAutoModeOnEventId) - AutoRouteOnFeedback.FireUpdate(); - else if (args.EventId == DMSystemEventIds.PriorityRoutingOnEventId) - PriorityRoutingOnFeedback.FireUpdate(); - else if (args.EventId == DMSystemEventIds.OnScreenDisplayEnabledEventId) - InputOnScreenDisplayEnabledFeedback.FireUpdate(); - } - - void TxRxPair_DMOutputChange(Switch device, DMOutputEventArgs args) - { - if (args.EventId == DMOutputEventIds.VideoOutEventId) - VideoSourceFeedback.FireUpdate(); - } - - void TxRxPair_DMInputChange(Switch device, DMInputEventArgs args) - { - if (args.EventId == DMInputEventIds.VideoDetectedEventId) - SyncDetectedFeedbacks[args.Number].FireUpdate(); - } - - public void AutoRouteOn() - { - TxRxPair.TransmitterAutoModeOn(); - } - - public void AutoRouteOff() - { - TxRxPair.TransmitterAutoModeOff(); - } - - public void PriorityRouteOn() - { - TxRxPair.PriorityRoutingOn(); - } - - public void PriorityRouteOff() - { - TxRxPair.PriorityRoutingOff(); - } - - public void OnScreenDisplayEnable() - { - TxRxPair.OnScreenDisplayEnabled(); - } - - public void OnScreenDisplayDisable() - { - TxRxPair.OnScreenDisplayDisabled(); - } - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - var number = Convert.ToUInt32(inputSelector); // Cast can sometimes fail - - var input = number == 0 ? null : TxRxPair.Inputs[number]; - - TxRxPair.HdmiOutputs[1].VideoOut = input; - } - - // This device has a different class for com ports which will make it hard to implement IComPorts.... - - //#region IComPorts Members - //public CrestronCollection ComPorts { get { return TxRxPair.ComPorts as CrestronCollection; } } - //public int NumberOfComPorts { get { return 1; } } - //#endregion - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new HdMdxxxCEControllerJoinMap(joinStart); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - - Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - - IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - RemoteEndDetectedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RemoteEndDetected.JoinNumber]); - - trilist.SetSigTrueAction(joinMap.AutoRouteOn.JoinNumber, AutoRouteOn); - AutoRouteOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.AutoRouteOn.JoinNumber]); - trilist.SetSigTrueAction(joinMap.AutoRouteOff.JoinNumber, AutoRouteOff); - AutoRouteOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.AutoRouteOff.JoinNumber]); - - trilist.SetSigTrueAction(joinMap.PriorityRoutingOn.JoinNumber, PriorityRouteOn); - PriorityRoutingOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PriorityRoutingOn.JoinNumber]); - trilist.SetSigTrueAction(joinMap.PriorityRoutingOff.JoinNumber, PriorityRouteOff); - PriorityRoutingOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PriorityRoutingOff.JoinNumber]); - - trilist.SetSigTrueAction(joinMap.InputOnScreenDisplayEnabled.JoinNumber, OnScreenDisplayEnable); - InputOnScreenDisplayEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.InputOnScreenDisplayEnabled.JoinNumber]); - trilist.SetSigTrueAction(joinMap.AutoRouteOff.JoinNumber, OnScreenDisplayDisable); - InputOnScreenDisplayEnabledFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.InputOnScreenDisplayDisabled.JoinNumber]); - - trilist.SetUShortSigAction(joinMap.VideoSource.JoinNumber, (i) => ExecuteSwitch(i, null, eRoutingSignalType.Video | eRoutingSignalType.Audio)); - VideoSourceFeedback.LinkInputSig(trilist.UShortInput[joinMap.VideoSource.JoinNumber]); - - trilist.UShortInput[joinMap.SourceCount.JoinNumber].UShortValue = (ushort)InputPorts.Count; - - foreach (var input in InputPorts) - { - var number = Convert.ToUInt16(input.Selector); - var numberJoin = (UInt16)(number - 1); - SyncDetectedFeedbacks[number].LinkInputSig(trilist.BooleanInput[joinMap.SyncDetected.JoinNumber + numberJoin]); - trilist.StringInput[joinMap.SourceNames.JoinNumber + numberJoin].StringValue = input.Key; - } - } - } - - public class HdMdxxxCEPropertiesConfig - { - public ControlPropertiesConfig Control { get; set; } - } - - public class HdMdxxxCEControllerFactory : EssentialsDeviceFactory - { - public HdMdxxxCEControllerFactory() - { - TypeNames = new List() { "hdmd400ce", "hdmd300ce", "hdmd200ce", "hdmd200c1ge"}; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - var typeName = dc.Type.ToLower(); - var key = dc.Key; - var name = dc.Name; - - Debug.Console(1, "Factory Attempting to create new HD-MD Device"); - - var props = JsonConvert.DeserializeObject - (dc.Properties.ToString()); - - if (typeName.Equals("hdmd400ce")) - return new PepperDash.Essentials.DM.HdMdxxxCEController(key, name, - new HdMd400CE(props.Control.IpIdInt, props.Control.TcpSshProperties.Address, Global.ControlSystem)); - else if (typeName.Equals("hdmd300ce")) - return new PepperDash.Essentials.DM.HdMdxxxCEController(key, name, - new HdMd300CE(props.Control.IpIdInt, props.Control.TcpSshProperties.Address, Global.ControlSystem)); - else if (typeName.Equals("hdmd200ce")) - return new PepperDash.Essentials.DM.HdMdxxxCEController(key, name, - new HdMd200CE(props.Control.IpIdInt, props.Control.TcpSshProperties.Address, Global.ControlSystem)); - else if (typeName.Equals("hdmd200c1ge")) - return new PepperDash.Essentials.DM.HdMdxxxCEController(key, name, - new HdMd200C1GE(props.Control.IpIdInt, props.Control.TcpSshProperties.Address, Global.ControlSystem)); - else - return null; - } - } - -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/DmPortName.cs b/src/PepperDash.Essentials.DM/DmPortName.cs deleted file mode 100644 index 4ce4d34d..00000000 --- a/src/PepperDash.Essentials.DM/DmPortName.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; - -namespace PepperDash.Essentials.DM -{ - /// - /// Constants for consistent port naming - /// - public class DmPortName - { - public const string AirBoardIn = "AirBoardIn"; - public const string AirMediaIn = "AirMediaIn"; - public const string AnyVideoIn = "AnyVideoIn"; - public const string AudioIn = "AudioIn"; - public const string AudioLoopOut = "AudioLoopOut"; - public const string BalancedAudioOut = "BalancedAudioOut"; - public const string BalancedAudioOut1 = "BalancedAudioOut1"; - public const string BalancedAudioOut2 = "BalancedAudioOut2"; - public const string BncIn = "BncIn"; - public const string CompositeIn = "CompositeIn"; - public const string DisplayPortIn = "DisplayPortIn"; - public const string DmIn = "DmIn"; - public const string DmOut = "DmOut"; - public const string DmOut1 = "DmOut1"; - public const string DmOut2 = "DmOut2"; - public const string FromTx = "FromTx"; - public const string Hdmi = "Hdmi"; - public const string HdmiIn = "HdmiIn"; - public const string HdmiIn1 = "HdmiIn1"; - public const string HdmiIn2 = "HdmiIn2"; - public const string HdmiOut1 = "HdmiOut1"; - public const string HdmiOut2 = "HdmiOut2"; - public const string HdmiLoopOut = "HdmiLoopOut"; - public const string HdmiOut = "HdmiOut"; - public const string Osd = "Osd"; - public const string SpdifIn = "SpdifIn"; - public const string ToTx = "ToTx"; - public const string VgaIn = "VgaIn"; - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Endpoints/DGEs/Dge100Controller.cs b/src/PepperDash.Essentials.DM/Endpoints/DGEs/Dge100Controller.cs deleted file mode 100644 index 912f1498..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/DGEs/Dge100Controller.cs +++ /dev/null @@ -1,225 +0,0 @@ -extern alias Full; - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.UI; - -using Crestron.SimplSharpPro.DM; - - -using Full.Newtonsoft.Json; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; -using Crestron.SimplSharpPro.DeviceSupport; -using PepperDash.Essentials.Core.DeviceInfo; - -namespace PepperDash.Essentials.DM.Endpoints.DGEs -{ - [Description("Wrapper class for DGE-100")] - public class Dge100Controller : CrestronGenericBaseDevice, IComPorts, IIROutputPorts, IHasBasicTriListWithSmartObject, ICec, IDeviceInfoProvider - { - private const int CtpPort = 41795; - private readonly Dge100 _dge; - - private readonly TsxCcsUcCodec100EthernetReservedSigs _dgeEthernetInfo; - - public BasicTriListWithSmartObject Panel { get { return _dge; } } - - private DeviceConfig _dc; - - CrestronTouchpanelPropertiesConfig PropertiesConfig; - - public Dge100Controller(string key, string name, Dge100 device, DeviceConfig dc, CrestronTouchpanelPropertiesConfig props) - :base(key, name, device) - { - _dge = device; - _dgeEthernetInfo = _dge.ExtenderEthernetReservedSigs; - //_dgeEthernetInfo.DeviceExtenderSigChange += (extender, args) => UpdateDeviceInfo(); - _dgeEthernetInfo.Use(); - - DeviceInfo = new DeviceInfo(); - - _dge.OnlineStatusChange += (currentDevice, args) => { if (args.DeviceOnLine) UpdateDeviceInfo(); }; - - _dc = dc; - - PropertiesConfig = props; - } - - #region IComPorts Members - - public CrestronCollection ComPorts - { - get { return _dge.ComPorts; } - } - - public int NumberOfComPorts - { - get { return _dge.NumberOfComPorts; } - } - - #endregion - - #region IIROutputPorts Members - - public CrestronCollection IROutputPorts - { - get { return _dge.IROutputPorts; } - } - - public int NumberOfIROutputPorts - { - get { return _dge.NumberOfIROutputPorts; } - } - - #endregion - - #region ICec Members - public Cec StreamCec { get { return _dge.HdmiOut.StreamCec; } } - #endregion - - #region Implementation of IDeviceInfoProvider - - public DeviceInfo DeviceInfo { get; private set; } - - public event DeviceInfoChangeHandler DeviceInfoChanged; - - public void UpdateDeviceInfo() - { - DeviceInfo.IpAddress = _dgeEthernetInfo.IpAddressFeedback.StringValue; - DeviceInfo.MacAddress = _dgeEthernetInfo.MacAddressFeedback.StringValue; - - GetFirmwareAndSerialInfo(); - - OnDeviceInfoChange(); - } - - private void GetFirmwareAndSerialInfo() - { - if (String.IsNullOrEmpty(_dgeEthernetInfo.IpAddressFeedback.StringValue)) - { - Debug.Console(1, this, "IP Address information not yet received. No device is online"); - return; - } - - var tcpClient = new GenericTcpIpClient("", _dgeEthernetInfo.IpAddressFeedback.StringValue, CtpPort, 1024){AutoReconnect = false}; - - var gather = new CommunicationGather(tcpClient, "\r\n\r\n"); - - tcpClient.ConnectionChange += (sender, args) => - { - if (!args.Client.IsConnected) - { - return; - } - - args.Client.SendText("ver\r\n"); - }; - - gather.LineReceived += (sender, args) => - { - try - { - Debug.Console(1, this, "{0}", args.Text); - - if (args.Text.ToLower().Contains("host")) - { - DeviceInfo.HostName = args.Text.Split(':')[1].Trim(); - - Debug.Console(1, this, "hostname: {0}", DeviceInfo.HostName); - tcpClient.Disconnect(); - return; - } - - //ignore console prompt - /*if (args.Text.ToLower().Contains(">")) - { - Debug.Console(1, this, "Ignoring console"); - return; - } - - if (args.Text.ToLower().Contains("dge")) - { - Debug.Console(1, this, "Ignoring DGE"); - return; - }*/ - - if (!args.Text.Contains('[')) - { - return; - } - var splitResponse = args.Text.Split('['); - - foreach (string t in splitResponse) - { - Debug.Console(1, this, "{0}", t); - } - - DeviceInfo.SerialNumber = splitResponse[1].Split(' ')[4].Replace("#", ""); - DeviceInfo.FirmwareVersion = splitResponse[1].Split(' ')[0]; - - Debug.Console(1, this, "Firmware: {0} SerialNumber: {1}", DeviceInfo.FirmwareVersion, - DeviceInfo.SerialNumber); - - tcpClient.SendText("host\r\n"); - } - catch (Exception ex) - { - Debug.Console(0, this, "Exception getting data: {0}", ex.Message); - Debug.Console(0, this, "response: {0}", args.Text); - } - }; - - tcpClient.Connect(); - } - - private void OnDeviceInfoChange() - { - var handler = DeviceInfoChanged; - - if (handler == null) return; - - handler(this, new DeviceInfoEventArgs(DeviceInfo)); - } - - #endregion - } - - public class Dge100ControllerFactory : EssentialsDeviceFactory - { - public Dge100ControllerFactory() - { - TypeNames = new List() { "dge100" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - var typeName = dc.Type.ToLower(); - var comm = CommFactory.GetControlPropertiesConfig(dc); - var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); - - Debug.Console(1, "Factory Attempting to create new DgeController Device"); - - Dge100 dgeDevice = null; - if (typeName == "dge100") - dgeDevice = new Dge100(comm.IpIdInt, Global.ControlSystem); - - if (dgeDevice == null) - { - Debug.Console(1, "Unable to create DGE device"); - return null; - } - - var dgeController = new Dge100Controller(dc.Key, dc.Name, dgeDevice, dc, props); - - return dgeController; - } - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Endpoints/DGEs/DgePropertiesConfig.cs b/src/PepperDash.Essentials.DM/Endpoints/DGEs/DgePropertiesConfig.cs deleted file mode 100644 index e468161f..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/DGEs/DgePropertiesConfig.cs +++ /dev/null @@ -1,20 +0,0 @@ -extern alias Full; - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; - -using PepperDash.Core; - -using Full.Newtonsoft.Json; - -namespace PepperDash.Essentials.DM.Endpoints.DGEs -{ - public class DgePropertiesConfig - { - [JsonProperty("control")] - public ControlPropertiesConfig Control { get; set; } - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Endpoints/DGEs/DmDge200CController.cs b/src/PepperDash.Essentials.DM/Endpoints/DGEs/DmDge200CController.cs deleted file mode 100644 index 57131d60..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/DGEs/DmDge200CController.cs +++ /dev/null @@ -1,96 +0,0 @@ -extern alias Full; - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.UI; - -using Full.Newtonsoft.Json; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; -using Crestron.SimplSharpPro.DeviceSupport; - -using Crestron.SimplSharpPro.DM; - -namespace PepperDash.Essentials.DM.Endpoints.DGEs -{ - /// - /// Wrapper class for DGE-100 and DM-DGE-200-C - /// - [Description("Wrapper class for DM-DGE-200-C")] - public class DmDge200CController : Dge100Controller, IRoutingInputsOutputs - { - private readonly DmDge200C _dge; - - public RoutingInputPort DmIn { get; private set; } - public RoutingOutputPort HdmiOut { get; private set; } - - public RoutingPortCollection InputPorts - { - get; - private set; - } - - public RoutingPortCollection OutputPorts - { - get; - private set; - } - - public DmDge200CController(string key, string name, DmDge200C device, DeviceConfig dc, CrestronTouchpanelPropertiesConfig props) - : base(key, name, device, dc, props) - { - _dge = device; - - DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.DmCat, 0, this); - HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.Hdmi, null, this); - - - InputPorts = new RoutingPortCollection { DmIn }; - OutputPorts = new RoutingPortCollection { HdmiOut }; - - // Set Ports for CEC - HdmiOut.Port = _dge.HdmiOut; ; - - } - - public class DmDge200CControllerFactory : EssentialsDeviceFactory - { - public DmDge200CControllerFactory() - { - TypeNames = new List() { "dmdge200c" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - var typeName = dc.Type.ToLower(); - var comm = CommFactory.GetControlPropertiesConfig(dc); - var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); - - Debug.Console(1, "Factory Attempting to create new DgeController Device"); - - DmDge200C dgeDevice = null; - - if (typeName == "dmdge200c") - dgeDevice = new DmDge200C(comm.IpIdInt, Global.ControlSystem); - - if (dgeDevice == null) - { - Debug.Console(1, "Unable to create DGE device"); - return null; - } - - var dgeController = new DmDge200CController(dc.Key , dc.Name, dgeDevice, dc, props); - - return dgeController; - } - } - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmHdBaseTEndpointController.cs b/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmHdBaseTEndpointController.cs deleted file mode 100644 index 4a4ac67d..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmHdBaseTEndpointController.cs +++ /dev/null @@ -1,64 +0,0 @@ -extern alias Full; - -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DM.Endpoints.Receivers; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core; -using PepperDash.Core; -using Full.Newtonsoft.Json; - -namespace PepperDash.Essentials.DM -{ - public class HDBaseTRxController : DmHdBaseTControllerBase, IRoutingInputsOutputs, - IComPorts - { - public RoutingInputPort DmIn { get; private set; } - public RoutingOutputPort HDBaseTSink { get; private set; } - - public RoutingPortCollection InputPorts { get; private set; } - - public RoutingPortCollection OutputPorts { get; private set; } - - public HDBaseTRxController(string key, string name, HDRx3CB rmc) - : base(key, name, rmc) - { - DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.DmCat, 0, this); - HDBaseTSink = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.Hdmi, null, this) {Port = Rmc}; - - InputPorts = new RoutingPortCollection {DmIn}; - OutputPorts = new RoutingPortCollection {HDBaseTSink}; - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new DmRmcControllerJoinMap(joinStart); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - - Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - - IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - trilist.StringInput[joinMap.Name.JoinNumber].StringValue = this.Name; - } - - #region IComPorts Members - public CrestronCollection ComPorts { get { return Rmc.ComPorts; } } - public int NumberOfComPorts { get { return Rmc.NumberOfComPorts; } } - #endregion - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc100SController.cs b/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc100SController.cs deleted file mode 100644 index 90f6b3fb..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc100SController.cs +++ /dev/null @@ -1,64 +0,0 @@ -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints.Receivers; - -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.DM -{ - /// - /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions - /// - /// - [Description("Wrapper Class for DM-RMC-100-S")] - public class DmRmc100SController : DmRmcControllerBase, IRoutingInputsOutputs, - IIROutputPorts, IComPorts, ICec - { - private readonly DmRmc100S _rmc; - - public RoutingInputPort DmIn { get; private set; } - public RoutingOutputPort HdmiOut { get; private set; } - - public RoutingPortCollection InputPorts { get; private set; } - - public RoutingPortCollection OutputPorts { get; private set; } - - /// - /// Make a Crestron RMC and put it in here - /// - public DmRmc100SController(string key, string name, DmRmc100S rmc) - : base(key, name, rmc) - { - _rmc = rmc; - - DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.DmCat, 0, this); - HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.Hdmi, null, this) {Port = _rmc}; - - InputPorts = new RoutingPortCollection {DmIn}; - OutputPorts = new RoutingPortCollection {HdmiOut}; - } - - 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 - public Cec StreamCec { get { return _rmc.HdmiOutput.StreamCec; } } - #endregion - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc150SController.cs b/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc150SController.cs deleted file mode 100644 index 39d1fd83..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc150SController.cs +++ /dev/null @@ -1,99 +0,0 @@ -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints.Receivers; - -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.DM -{ - /// - /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions - /// - /// - [Description("Wrapper Class for DM-RMC-150-S")] - public class DmRmc150SController : DmRmcControllerBase, IRoutingInputsOutputs, - IIROutputPorts, IComPorts, ICec - { - private readonly DmRmc150S _rmc; - - public RoutingInputPort DmIn { get; private set; } - public RoutingOutputPort HdmiOut { get; private set; } - - public RoutingPortCollection InputPorts - { - get; private set; - } - - public RoutingPortCollection OutputPorts - { - get; - private set ; - } - - /// - /// Make a Crestron RMC and put it in here - /// - public DmRmc150SController(string key, string name, DmRmc150S rmc) - : base(key, name, rmc) - { - _rmc = rmc; - DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.DmCat, 0, this); - HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, - 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); - - InputPorts = new RoutingPortCollection {DmIn}; - OutputPorts = new RoutingPortCollection {HdmiOut}; - - _rmc.HdmiOutput.ConnectedDevice.DeviceInformationChange += ConnectedDevice_DeviceInformationChange; - - // Set Ports for CEC - HdmiOut.Port = _rmc.HdmiOutput; - } - - void ConnectedDevice_DeviceInformationChange(ConnectedDeviceInformation connectedDevice, ConnectedDeviceEventArgs args) - { - switch (args.EventId) - { - case ConnectedDeviceEventIds.ManufacturerEventId: - EdidManufacturerFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.NameEventId: - EdidNameFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.PreferredTimingEventId: - EdidPreferredTimingFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.SerialNumberEventId: - EdidSerialNumberFeedback.FireUpdate(); - break; - } - } - - 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 - public Cec StreamCec { get { return _rmc.HdmiOutput.StreamCec; } } - #endregion - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc200CController.cs b/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc200CController.cs deleted file mode 100644 index e7699e85..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc200CController.cs +++ /dev/null @@ -1,111 +0,0 @@ -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 -{ - /// - /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions - /// - /// - [Description("Wrapper Class for DM-RMC-200-C")] - public class DmRmc200CController : DmRmcControllerBase, IRoutingInputsOutputs, - IIROutputPorts, IComPorts, ICec - { - private readonly DmRmc200C _rmc; - - public RoutingInputPort DmIn { get; private set; } - public RoutingOutputPort HdmiOut { get; private set; } - - public RoutingPortCollection InputPorts - { - get; private set; - } - - public RoutingPortCollection OutputPorts - { - get; private set; - } - - /// - /// Make a Crestron RMC and put it in here - /// - public DmRmc200CController(string key, string name, DmRmc200C rmc) - : base(key, name, rmc) - { - _rmc = rmc; - DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.DmCat, 0, this); - HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, - 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; - - InputPorts = new RoutingPortCollection {DmIn}; - OutputPorts = new RoutingPortCollection {HdmiOut}; - - // Set Ports for CEC - HdmiOut.Port = _rmc.HdmiOutput; - } - - 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) - { - switch (args.EventId) - { - case ConnectedDeviceEventIds.ManufacturerEventId: - EdidManufacturerFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.NameEventId: - EdidNameFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.PreferredTimingEventId: - EdidPreferredTimingFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.SerialNumberEventId: - EdidSerialNumberFeedback.FireUpdate(); - break; - } - } - - 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 - public Cec StreamCec { get { return _rmc.HdmiOutput.StreamCec; } } - #endregion - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc200S2Controller.cs b/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc200S2Controller.cs deleted file mode 100644 index e329784f..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc200S2Controller.cs +++ /dev/null @@ -1,105 +0,0 @@ -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 -{ - /// - /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions - /// - /// - [Description("Wrapper Class for DM-RMC-200-S2")] - public class DmRmc200S2Controller : DmRmcControllerBase, IRoutingInputsOutputs, - IIROutputPorts, IComPorts, ICec - { - private readonly DmRmc200S2 _rmc; - - public RoutingInputPort DmIn { get; private set; } - public RoutingOutputPort HdmiOut { get; private set; } - - public RoutingPortCollection InputPorts { get; private set; } - - public RoutingPortCollection OutputPorts { get; private set; } - - /// - /// Make a Crestron RMC and put it in here - /// - public DmRmc200S2Controller(string key, string name, DmRmc200S2 rmc) - : base(key, name, rmc) - { - _rmc = rmc; - DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.DmCat, 0, this); - HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, - 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; - - InputPorts = new RoutingPortCollection {DmIn}; - OutputPorts = new RoutingPortCollection {HdmiOut}; - - // Set Ports for CEC - HdmiOut.Port = _rmc.HdmiOutput; - } - - 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) - { - switch (args.EventId) - { - case ConnectedDeviceEventIds.ManufacturerEventId: - EdidManufacturerFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.NameEventId: - EdidNameFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.PreferredTimingEventId: - EdidPreferredTimingFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.SerialNumberEventId: - EdidSerialNumberFeedback.FireUpdate(); - break; - } - } - - 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 - public Cec StreamCec { get { return _rmc.HdmiOutput.StreamCec; } } - #endregion - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc200SController.cs b/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc200SController.cs deleted file mode 100644 index 86e937c7..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc200SController.cs +++ /dev/null @@ -1,108 +0,0 @@ -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 -{ - /// - /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions - /// - /// - [Description("Wrapper Class for DM-RMC-200-S")] - public class DmRmc200SController : DmRmcControllerBase, IRoutingInputsOutputs, - IIROutputPorts, IComPorts, ICec - { - private readonly DmRmc200S _rmc; - - public RoutingInputPort DmIn { get; private set; } - public RoutingOutputPort HdmiOut { get; private set; } - - public RoutingPortCollection InputPorts { get; private set; } - - public RoutingPortCollection OutputPorts - { - get; private set; - } - - /// - /// Make a Crestron RMC and put it in here - /// - public DmRmc200SController(string key, string name, DmRmc200S rmc) - : base(key, name, rmc) - { - _rmc = rmc; - DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.DmCat, 0, this); - HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, - 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()); - - InputPorts = new RoutingPortCollection {DmIn}; - OutputPorts = new RoutingPortCollection {HdmiOut}; - - _rmc.HdmiOutput.OutputStreamChange += HdmiOutput_OutputStreamChange; - _rmc.HdmiOutput.ConnectedDevice.DeviceInformationChange += ConnectedDevice_DeviceInformationChange; - - // Set Ports for CEC - HdmiOut.Port = _rmc.HdmiOutput; - } - - 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) - { - switch (args.EventId) - { - case ConnectedDeviceEventIds.ManufacturerEventId: - EdidManufacturerFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.NameEventId: - EdidNameFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.PreferredTimingEventId: - EdidPreferredTimingFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.SerialNumberEventId: - EdidSerialNumberFeedback.FireUpdate(); - break; - } - } - - 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 - public Cec StreamCec { get { return _rmc.HdmiOutput.StreamCec; } } - #endregion - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc4KScalerCController.cs b/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc4KScalerCController.cs deleted file mode 100644 index 8d4abadd..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc4KScalerCController.cs +++ /dev/null @@ -1,196 +0,0 @@ -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Receivers; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.DM -{ - /// - /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions - /// - /// - [Description("Wrapper Class for DM-RMC-4K-SCALER-C")] - public class DmRmc4kScalerCController : DmRmcControllerBase, IRoutingInputsOutputs, IBasicVolumeWithFeedback, - IIROutputPorts, IComPorts, ICec, IRelayPorts - { - private readonly DmRmc4kScalerC _rmc; - - public RoutingInputPort DmIn { get; private set; } - public RoutingOutputPort HdmiOut { get; private set; } - public RoutingOutputPort BalancedAudioOut { get; private set; } - - public RoutingPortCollection InputPorts { get; private set; } - - public RoutingPortCollection OutputPorts { get; private set; } - - /// - /// Make a Crestron RMC and put it in here - /// - public DmRmc4kScalerCController(string key, string name, DmRmc4kScalerC rmc) - : base(key, name, rmc) - { - _rmc = rmc; - - DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.DmCat, 0, this); - HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.Hdmi, null, this); - BalancedAudioOut = new RoutingOutputPort(DmPortName.BalancedAudioOut, eRoutingSignalType.Audio, - eRoutingPortConnectionType.LineAudio, null, this); - - MuteFeedback = new BoolFeedback(() => false); - - VolumeLevelFeedback = new IntFeedback("MainVolumeLevelFeedback", () => - rmc.AudioOutput.VolumeFeedback.UShortValue); - - 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); - - InputPorts = new RoutingPortCollection {DmIn}; - OutputPorts = new RoutingPortCollection {HdmiOut, BalancedAudioOut}; - - 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; - } - - 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) - { - switch (args.EventId) - { - case ConnectedDeviceEventIds.ManufacturerEventId: - EdidManufacturerFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.NameEventId: - EdidNameFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.PreferredTimingEventId: - EdidPreferredTimingFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.SerialNumberEventId: - EdidSerialNumberFeedback.FireUpdate(); - break; - } - } - - 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 IRelayPorts Members - - public int NumberOfRelayPorts - { - get { return _rmc.NumberOfRelayPorts; } - } - - public CrestronCollection RelayPorts - { - get { return _rmc.RelayPorts; } - } - - #endregion - - #region IBasicVolumeWithFeedback Members - - public BoolFeedback MuteFeedback - { - get; - private set; - } - - /// - /// Not implemented - /// - public void MuteOff() - { - Debug.Console(2, this, "DM Endpoint {0} does not have a mute function", Key); - } - - /// - /// Not implemented - /// - public void MuteOn() - { - Debug.Console(2, this, "DM Endpoint {0} does not have a mute function", Key); - } - - public void SetVolume(ushort level) - { - _rmc.AudioOutput.Volume.UShortValue = level; - } - - public IntFeedback VolumeLevelFeedback - { - get; - private set; - } - - #endregion - - #region IBasicVolumeControls Members - - /// - /// Not implemented - /// - public void MuteToggle() - { - Debug.Console(2, this, "DM Endpoint {0} does not have a mute function", Key); - } - - public void VolumeDown(bool pressRelease) - { - if (pressRelease) - SigHelper.RampTimeScaled(_rmc.AudioOutput.Volume, 0, 4000); - else - _rmc.AudioOutput.Volume.StopRamp(); - } - - public void VolumeUp(bool pressRelease) - { - if (pressRelease) - SigHelper.RampTimeScaled(_rmc.AudioOutput.Volume, 65535, 4000); - else - _rmc.AudioOutput.Volume.StopRamp(); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc4k100C1GController.cs b/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc4k100C1GController.cs deleted file mode 100644 index 0664818d..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc4k100C1GController.cs +++ /dev/null @@ -1,78 +0,0 @@ -extern alias Full; - -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints.Receivers; -using Crestron.SimplSharpPro.DeviceSupport; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core; -using PepperDash.Core; -using Full.Newtonsoft.Json; - -namespace PepperDash.Essentials.DM -{ - - [Description("Wrapper Class for DM-RMC-4K-100-C-1G")] - public class DmRmc4k100C1GController : DmHdBaseTControllerBase, IRoutingInputsOutputs, - IIROutputPorts, IComPorts, ICec - { - private readonly DmRmc4K100C1G _rmc; - public RoutingInputPort DmIn { get; private set; } - public RoutingOutputPort HdmiOut { get; private set; } - - public RoutingPortCollection InputPorts { get; private set; } - - public RoutingPortCollection OutputPorts { get; private set; } - - public DmRmc4k100C1GController(string key, string name, DmRmc4K100C1G rmc) - : base(key, name, rmc) - { - _rmc = rmc; - DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.DmCat, 0, this); - HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.Hdmi, null, this) {Port = _rmc}; - - InputPorts = new RoutingPortCollection {DmIn}; - OutputPorts = new RoutingPortCollection {HdmiOut}; - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new DmRmcControllerJoinMap(joinStart); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - - Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - - IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - trilist.StringInput[joinMap.Name.JoinNumber].StringValue = this.Name; - } - - #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 - public Cec StreamCec { get { return _rmc.StreamCec; } } - #endregion - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc4kScalerCDspController.cs b/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc4kScalerCDspController.cs deleted file mode 100644 index 5c6db1aa..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc4kScalerCDspController.cs +++ /dev/null @@ -1,195 +0,0 @@ -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Receivers; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.DM -{ - /// - /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions - /// - /// - [Description("Wrapper Class for DM-RMC-4K-SCALER-C-DSP")] - public class DmRmc4kScalerCDspController : DmRmcControllerBase, IRoutingInputsOutputs, IBasicVolumeWithFeedback, - IIROutputPorts, IComPorts, ICec, IRelayPorts - { - private readonly DmRmc4kScalerCDsp _rmc; - - public RoutingInputPort DmIn { get; private set; } - public RoutingOutputPort HdmiOut { get; private set; } - public RoutingOutputPort BalancedAudioOut { get; private set; } - - public RoutingPortCollection InputPorts { get; private set; } - - public RoutingPortCollection OutputPorts { get; private set; } - - /// - /// Make a Crestron RMC and put it in here - /// - public DmRmc4kScalerCDspController(string key, string name, DmRmc4kScalerCDsp rmc) - : base(key, name, rmc) - { - _rmc = rmc; - - DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.DmCat, 0, this); - HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.Hdmi, null, this); - BalancedAudioOut = new RoutingOutputPort(DmPortName.BalancedAudioOut, eRoutingSignalType.Audio, - eRoutingPortConnectionType.LineAudio, null, this); - - MuteFeedback = new BoolFeedback(() => false); - VolumeLevelFeedback = new IntFeedback("MainVolumeLevelFeedback", () => - rmc.AudioOutput.VolumeFeedback.UShortValue); - - 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()); - - InputPorts = new RoutingPortCollection {DmIn}; - OutputPorts = new RoutingPortCollection {HdmiOut, BalancedAudioOut}; - - _rmc.HdmiOutput.OutputStreamChange += HdmiOutput_OutputStreamChange; - _rmc.HdmiOutput.ConnectedDevice.DeviceInformationChange += ConnectedDevice_DeviceInformationChange; - - // Set Ports for CEC - HdmiOut.Port = _rmc.HdmiOutput; - } - - 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) - { - switch (args.EventId) - { - case ConnectedDeviceEventIds.ManufacturerEventId: - EdidManufacturerFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.NameEventId: - EdidNameFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.PreferredTimingEventId: - EdidPreferredTimingFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.SerialNumberEventId: - EdidSerialNumberFeedback.FireUpdate(); - break; - } - } - - 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 IRelayPorts Members - - public int NumberOfRelayPorts - { - get { return _rmc.NumberOfRelayPorts; } - } - - public CrestronCollection RelayPorts - { - get { return _rmc.RelayPorts; } - } - - #endregion - - #region IBasicVolumeWithFeedback Members - - public BoolFeedback MuteFeedback - { - get; - private set; - } - - /// - /// Not implemented - /// - public void MuteOff() - { - Debug.Console(2, this, "DM Endpoint {0} does not have a mute function", Key); - } - - /// - /// Not implemented - /// - public void MuteOn() - { - Debug.Console(2, this, "DM Endpoint {0} does not have a mute function", Key); - } - - public void SetVolume(ushort level) - { - _rmc.AudioOutput.Volume.UShortValue = level; - } - - public IntFeedback VolumeLevelFeedback - { - get; - private set; - } - - #endregion - - #region IBasicVolumeControls Members - - /// - /// Not implemented - /// - public void MuteToggle() - { - Debug.Console(2, this, "DM Endpoint {0} does not have a mute function", Key); - } - - public void VolumeDown(bool pressRelease) - { - if (pressRelease) - SigHelper.RampTimeScaled(_rmc.AudioOutput.Volume, 0, 4000); - else - _rmc.AudioOutput.Volume.StopRamp(); - } - - public void VolumeUp(bool pressRelease) - { - if (pressRelease) - SigHelper.RampTimeScaled(_rmc.AudioOutput.Volume, 65535, 4000); - else - _rmc.AudioOutput.Volume.StopRamp(); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc4kZ100CController.cs b/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc4kZ100CController.cs deleted file mode 100644 index 3e3f56f9..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc4kZ100CController.cs +++ /dev/null @@ -1,76 +0,0 @@ -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 -{ - [Description("Wrapper Class for DM-RMC-4K-Z-100-C")] - public class DmRmc4kZ100CController : DmRmcX100CController - { - private readonly DmRmc4kz100C _rmc; - - public DmRmc4kZ100CController(string key, string name, DmRmc4kz100C rmc) - : base(key, name, rmc) - { - _rmc = rmc; - - 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; - - //removed to prevent NullReferenceException - //_rmc.HdmiOutput.ConnectedDevice.DeviceInformationChange += ConnectedDevice_DeviceInformationChange; - } - - void HdmiOutput_OutputStreamChange(EndpointOutputStream outputStream, EndpointOutputStreamEventArgs args) - { - switch (args.EventId) - { - case EndpointOutputStreamEventIds.FramesPerSecondFeedbackEventId: - case EndpointOutputStreamEventIds.VerticalResolutionFeedbackEventId: - case EndpointOutputStreamEventIds.HorizontalResolutionFeedbackEventId: - VideoOutputResolutionFeedback.FireUpdate(); - break; - case EndpointOutputStreamEventIds.HotplugDetectedEventId: - if (_rmc.HdmiOutput.ConnectedDevice == null) return; - EdidManufacturerFeedback.FireUpdate(); - EdidNameFeedback.FireUpdate(); - EdidPreferredTimingFeedback.FireUpdate(); - EdidSerialNumberFeedback.FireUpdate(); - break; - } - } - - /* - void ConnectedDevice_DeviceInformationChange(ConnectedDeviceInformation connectedDevice, ConnectedDeviceEventArgs args) - { - switch (args.EventId) - { - case ConnectedDeviceEventIds.ManufacturerEventId: - EdidManufacturerFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.NameEventId: - EdidNameFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.PreferredTimingEventId: - EdidPreferredTimingFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.SerialNumberEventId: - EdidSerialNumberFeedback.FireUpdate(); - break; - } - }*/ - - 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/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc4kZScalerCController.cs b/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc4kZScalerCController.cs deleted file mode 100644 index eef6ea16..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc4kZScalerCController.cs +++ /dev/null @@ -1,185 +0,0 @@ -using System; -using System.Linq; -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 -{ - [Description("Wrapper Class for DM-RMC-4K-Z-SCALER-C")] - public class DmRmc4kZScalerCController : DmRmcControllerBase, IRmcRoutingWithFeedback, - IIROutputPorts, IComPorts, ICec, IRelayPorts - { - private readonly DmRmc4kzScalerC _rmc; - - 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; private set; } - - public RoutingPortCollection OutputPorts { get; private set; } - - //IroutingNumericEvent - public event EventHandler NumericSwitchChange; - - /// - /// Raise an event when the status of a switch object changes. - /// - /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType - private void OnSwitchChange(RoutingNumericEventArgs e) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, e); - } - - - public DmRmc4kZScalerCController(string key, string name, DmRmc4kzScalerC rmc) - : base(key, name, rmc) - { - _rmc = rmc; - DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.DmCat, 0, this) - { - FeedbackMatchObject = 1 - }; - HdmiIn = new RoutingInputPort(DmPortName.HdmiIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.Hdmi, 0, this) - { - FeedbackMatchObject = 2 - }; - HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, - 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()); - - InputPorts = new RoutingPortCollection {DmIn, HdmiIn}; - OutputPorts = new RoutingPortCollection {HdmiOut}; - - _rmc.HdmiOutput.OutputStreamChange += HdmiOutput_OutputStreamChange; - _rmc.HdmiOutput.ConnectedDevice.DeviceInformationChange += ConnectedDevice_DeviceInformationChange; - - _rmc.OnlineStatusChange += _rmc_OnlineStatusChange; - - // Set Ports for CEC - HdmiOut.Port = _rmc.HdmiOutput; - - AudioVideoSourceNumericFeedback = new IntFeedback(() => (ushort)(_rmc.SelectedSourceFeedback)); - } - - private void _rmc_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) - { - AudioVideoSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioVideoSourceNumericFeedback.UShortValue, eRoutingSignalType.AudioVideo)); - } - - 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) - { - var localInputPort = - InputPorts.FirstOrDefault(p => (int)p.FeedbackMatchObject == AudioVideoSourceNumericFeedback.UShortValue); - - - AudioVideoSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioVideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputPort, eRoutingSignalType.AudioVideo)); - } - } - - void ConnectedDevice_DeviceInformationChange(ConnectedDeviceInformation connectedDevice, ConnectedDeviceEventArgs args) - { - switch (args.EventId) - { - case ConnectedDeviceEventIds.ManufacturerEventId: - EdidManufacturerFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.NameEventId: - EdidNameFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.PreferredTimingEventId: - EdidPreferredTimingFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.SerialNumberEventId: - EdidSerialNumberFeedback.FireUpdate(); - break; - } - } - - 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 - - #region Implementation of IRelayPorts - - public CrestronCollection RelayPorts - { - get { return _rmc.RelayPorts; } - } - - public int NumberOfRelayPorts - { - get { return _rmc.NumberOfRelayPorts; } - } - - #endregion - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmcHelper.cs b/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmcHelper.cs deleted file mode 100644 index 1d11db00..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmcHelper.cs +++ /dev/null @@ -1,531 +0,0 @@ -extern alias Full; - -using System; -using System.Collections.Generic; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Cards; -using Crestron.SimplSharpPro.DM.Endpoints.Receivers; -using Full.Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.DeviceInfo; -using PepperDash.Essentials.DM.Config; -using PepperDash.Essentials.Core.Config; - -namespace PepperDash.Essentials.DM -{ - [Description("Wrapper class for all DM-RMC variants")] - public abstract class DmRmcControllerBase : CrestronGenericBridgeableBaseDevice, IDeviceInfoProvider - { - private const int CtpPort = 41795; - private readonly EndpointReceiverBase _rmc; //kept here just in case. Only property or method on this class that's not device-specific is the DMOutput that it's attached to. - - public StringFeedback VideoOutputResolutionFeedback { get; protected set; } - public StringFeedback EdidManufacturerFeedback { get; protected set; } - public StringFeedback EdidNameFeedback { get; protected set; } - public StringFeedback EdidPreferredTimingFeedback { get; protected set; } - public StringFeedback EdidSerialNumberFeedback { get; protected set; } - - protected DmRmcControllerBase(string key, string name, EndpointReceiverBase device) - : base(key, name, device) - { - _rmc = device; - - // if wired to a chassis, skip registration step in base class - PreventRegistration = _rmc.DMOutput != null; - - AddToFeedbackList(VideoOutputResolutionFeedback, EdidManufacturerFeedback, EdidSerialNumberFeedback, EdidNameFeedback, EdidPreferredTimingFeedback); - - DeviceInfo = new DeviceInfo(); - - IsOnline.OutputChange += (currentDevice, args) => { if (args.BoolValue) UpdateDeviceInfo(); }; - } - - protected void LinkDmRmcToApi(DmRmcControllerBase rmc, BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new DmRmcControllerJoinMap(joinStart); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - - Debug.Console(1, rmc, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - - IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - trilist.StringInput[joinMap.Name.JoinNumber].StringValue = rmc.Name; - if (rmc.VideoOutputResolutionFeedback != null) - rmc.VideoOutputResolutionFeedback.LinkInputSig(trilist.StringInput[joinMap.CurrentOutputResolution.JoinNumber]); - if (rmc.EdidManufacturerFeedback != null) - rmc.EdidManufacturerFeedback.LinkInputSig(trilist.StringInput[joinMap.EdidManufacturer.JoinNumber]); - if (rmc.EdidNameFeedback != null) - rmc.EdidNameFeedback.LinkInputSig(trilist.StringInput[joinMap.EdidName.JoinNumber]); - if (rmc.EdidPreferredTimingFeedback != null) - rmc.EdidPreferredTimingFeedback.LinkInputSig(trilist.StringInput[joinMap.EdidPrefferedTiming.JoinNumber]); - if (rmc.EdidSerialNumberFeedback != null) - rmc.EdidSerialNumberFeedback.LinkInputSig(trilist.StringInput[joinMap.EdidSerialNumber.JoinNumber]); - - //If the device is an DM-RMC-4K-Z-SCALER-C - var routing = rmc as IRmcRouting; - - if (routing == null) - { - return; - } - - if (routing.AudioVideoSourceNumericFeedback != null) - routing.AudioVideoSourceNumericFeedback.LinkInputSig(trilist.UShortInput[joinMap.AudioVideoSource.JoinNumber]); - - trilist.SetUShortSigAction(joinMap.AudioVideoSource.JoinNumber, a => routing.ExecuteNumericSwitch(a, 1, eRoutingSignalType.AudioVideo)); - } - - #region Implementation of IDeviceInfoProvider - - public DeviceInfo DeviceInfo { get; private set; } - public event DeviceInfoChangeHandler DeviceInfoChanged; - - public void UpdateDeviceInfo() - { - Debug.Console(1, this, "Updating Device Info"); - - if (_rmc.ConnectedIpList.Count == 0) - { - Debug.Console(1, this, "IP Address information not yet received. No device is online"); - return; - } - - DeviceInfo.IpAddress = _rmc.ConnectedIpList[0].DeviceIpAddress; - - foreach (var ip in _rmc.ConnectedIpList) - { - Debug.Console(0, this, "Connected IP Address: {0}", ip.DeviceIpAddress); - } - - GetFirmwareAndSerialInfo(); - - OnDeviceInfoChange(); - } - - private void GetFirmwareAndSerialInfo() - { - var tcpClient = new GenericTcpIpClient(String.Format("{0}-devInfoSocket", Key), _rmc.ConnectedIpList[0].DeviceIpAddress, CtpPort, 1024) - { - AutoReconnect = false, - }; - - var gather = new CommunicationGather(tcpClient, "\r\n\r\n"); - - tcpClient.ConnectionChange += (sender, args) => - { - if (!args.Client.IsConnected) - { - OnDeviceInfoChange(); - return; - } - - args.Client.SendText("ver\r\n"); - }; - - gather.LineReceived += (sender, args) => - { - //ignore console prompt - if (args.Text.ToLower().Contains(">")) - { - return; - } - - - if (args.Text.ToLower().Contains("host")) - { - DeviceInfo.HostName = args.Text.Split(':')[1].Trim(); - - tcpClient.SendText("maca\r\n"); - - return; - } - - if (args.Text.ToLower().Contains("mac")) - { - DeviceInfo.MacAddress = args.Text.Split(':')[1].Trim().Replace(" ", ":"); - - tcpClient.Disconnect(); - - return; - } - - if (!args.Text.ToLower().Contains("rmc")) - { - return; - } - - DeviceInfo.SerialNumber = args.Text.Split('[')[1].Split(' ')[4].Replace("#", ""); - DeviceInfo.FirmwareVersion = args.Text.Split('[')[1].Split(' ')[1]; - - tcpClient.SendText("host\r\n"); - }; - - tcpClient.Connect(); - } - - private void OnDeviceInfoChange() - { - var handler = DeviceInfoChanged; - - if (handler == null) return; - - handler(this, new DeviceInfoEventArgs(DeviceInfo)); - } - - #endregion - } - - public abstract class DmHdBaseTControllerBase : CrestronGenericBridgeableBaseDevice - { - protected HDBaseTBase Rmc; - - /// - /// Make a Crestron RMC and put it in here - /// - protected DmHdBaseTControllerBase(string key, string name, HDBaseTBase rmc) - : base(key, name, rmc) - { - Rmc = rmc; - } - } - - public class DmRmcHelper - { - private static readonly Dictionary> ProcessorFactoryDict; - private static readonly Dictionary> ChassisCpu3Dict; - - private static readonly Dictionary> - ChassisDict; - - static DmRmcHelper() - { - ProcessorFactoryDict = new Dictionary> - { - {"dmrmc100c", (k, n, i) => new DmRmcX100CController(k, n, new DmRmc100C(i, Global.ControlSystem))}, - {"dmrmc100s", (k, n, i) => new DmRmc100SController(k, n, new DmRmc100S(i, Global.ControlSystem))}, - {"dmrmc4k100c", (k, n, i) => new DmRmcX100CController(k, n, new DmRmc4k100C(i, Global.ControlSystem))}, - {"dmrmc4kz100c", (k, n, i) => new DmRmc4kZ100CController(k, n, new DmRmc4kz100C(i, Global.ControlSystem))}, - {"dmrmc150s", (k, n, i) => new DmRmc150SController(k, n, new DmRmc150S(i, Global.ControlSystem))}, - {"dmrmc200c", (k, n, i) => new DmRmc200CController(k, n, new DmRmc200C(i, Global.ControlSystem))}, - {"dmrmc200s", (k, n, i) => new DmRmc200SController(k, n, new DmRmc200S(i, Global.ControlSystem))}, - {"dmrmc200s2", (k, n, i) => new DmRmc200S2Controller(k, n, new DmRmc200S2(i, Global.ControlSystem))}, - {"dmrmcscalerc", (k, n, i) => new DmRmcScalerCController(k, n, new DmRmcScalerC(i, Global.ControlSystem))}, - {"dmrmcscalers", (k, n, i) => new DmRmcScalerSController(k, n, new DmRmcScalerS(i, Global.ControlSystem))}, - { - "dmrmcscalers2", - (k, n, i) => new DmRmcScalerS2Controller(k, n, new DmRmcScalerS2(i, Global.ControlSystem)) - }, - { - "dmrmc4kscalerc", - (k, n, i) => new DmRmc4kScalerCController(k, n, new DmRmc4kScalerC(i, Global.ControlSystem)) - }, - { - "dmrmc4kscalercdsp", - (k, n, i) => new DmRmc4kScalerCDspController(k, n, new DmRmc4kScalerCDsp(i, Global.ControlSystem)) - }, - { - "dmrmc4kzscalerc", - (k, n, i) => new DmRmc4kZScalerCController(k, n, new DmRmc4kzScalerC(i, Global.ControlSystem)) - } - }; - - ChassisCpu3Dict = new Dictionary> - { - {"dmrmc100c", (k, n, d) => new DmRmcX100CController(k, n, new DmRmc100C(d))}, - {"dmrmc100s", (k, n, d) => new DmRmc100SController(k, n, new DmRmc100S(d))}, - {"dmrmc4k100c", (k, n, d) => new DmRmcX100CController(k, n, new DmRmc4k100C(d))}, - {"dmrmc4kz100c", (k, n, d) => new DmRmc4kZ100CController(k, n, new DmRmc4kz100C(d))}, - {"dmrmc150s", (k, n, d) => new DmRmc150SController(k, n, new DmRmc150S(d))}, - {"dmrmc200c", (k, n, d) => new DmRmc200CController(k, n, new DmRmc200C(d))}, - {"dmrmc200s", (k, n, d) => new DmRmc200SController(k, n, new DmRmc200S(d))}, - {"dmrmc200s2", (k, n, d) => new DmRmc200S2Controller(k, n, new DmRmc200S2(d))}, - {"dmrmcscalerc", (k, n, d) => new DmRmcScalerCController(k, n, new DmRmcScalerC(d))}, - {"dmrmcscalers", (k, n, d) => new DmRmcScalerSController(k, n, new DmRmcScalerS(d))}, - { - "dmrmcscalers2", - (k, n, d) => new DmRmcScalerS2Controller(k, n, new DmRmcScalerS2(d)) - }, - { - "dmrmc4kscalerc", - (k, n, d) => new DmRmc4kScalerCController(k, n, new DmRmc4kScalerC(d)) - }, - { - "dmrmc4kscalercdsp", - (k, n, d) => new DmRmc4kScalerCDspController(k, n, new DmRmc4kScalerCDsp(d)) - }, - { - "dmrmc4kzscalerc", - (k, n, d) => new DmRmc4kZScalerCController(k, n, new DmRmc4kzScalerC(d)) - }, - {"hdbasetrx", (k,n,d) => new HDBaseTRxController(k,n, new HDRx3CB(d))}, - {"dmrmc4k100c1g", (k,n,d) => new DmRmc4k100C1GController(k,n, new DmRmc4K100C1G(d))} - }; - - ChassisDict = new Dictionary> - { - {"dmrmc100c", (k, n, i, d) => new DmRmcX100CController(k, n, new DmRmc100C(i,d))}, - {"dmrmc100s", (k, n,i, d) => new DmRmc100SController(k, n, new DmRmc100S(i,d))}, - {"dmrmc4k100c", (k, n,i, d) => new DmRmcX100CController(k, n, new DmRmc4k100C(i,d))}, - {"dmrmc4kz100c", (k, n,i, d) => new DmRmc4kZ100CController(k, n, new DmRmc4kz100C(i,d))}, - {"dmrmc150s", (k, n,i, d) => new DmRmc150SController(k, n, new DmRmc150S(i,d))}, - {"dmrmc200c", (k, n,i, d) => new DmRmc200CController(k, n, new DmRmc200C(i,d))}, - {"dmrmc200s", (k, n,i, d) => new DmRmc200SController(k, n, new DmRmc200S(i,d))}, - {"dmrmc200s2", (k, n,i, d) => new DmRmc200S2Controller(k, n, new DmRmc200S2(i,d))}, - {"dmrmcscalerc", (k, n,i, d) => new DmRmcScalerCController(k, n, new DmRmcScalerC(i,d))}, - {"dmrmcscalers", (k, n,i, d) => new DmRmcScalerSController(k, n, new DmRmcScalerS(i,d))}, - { - "dmrmcscalers2", - (k, n,i, d) => new DmRmcScalerS2Controller(k, n, new DmRmcScalerS2(i, d)) - }, - { - "dmrmc4kscalerc", - (k, n,i, d) => new DmRmc4kScalerCController(k, n, new DmRmc4kScalerC(i, d)) - }, - { - "dmrmc4kscalercdsp", - (k, n,i, d) => new DmRmc4kScalerCDspController(k, n, new DmRmc4kScalerCDsp(i, d)) - }, - { - "dmrmc4kzscalerc", - (k, n,i, d) => new DmRmc4kZScalerCController(k, n, new DmRmc4kzScalerC(i, d)) - }, - {"hdbasetrx", (k,n,i,d) => new HDBaseTRxController(k,n, new HDRx3CB(i, d))}, - {"dmrmc4k100c1g", (k,n,i,d) => new DmRmc4k100C1GController(k,n, new DmRmc4K100C1G(i, d))} - }; - } - /// - /// A factory method for various DmRmcControllers - /// - /// device key. Used to uniquely identify device - /// device name - /// device type name. Used to retrived the correct device - /// Config from config file - /// - public static CrestronGenericBaseDevice GetDmRmcController(string key, string name, string typeName, DmRmcPropertiesConfig props) - { - typeName = typeName.ToLower(); - var ipid = props.Control.IpIdInt; - - var pKey = props.ParentDeviceKey.ToLower(); - - // Non-DM-chassis endpoints - return pKey == "processor" ? GetDmRmcControllerForProcessor(key, name, typeName, ipid) : GetDmRmcControllerForChassis(key, name, typeName, props, pKey, ipid); - } - - private static CrestronGenericBaseDevice GetDmRmcControllerForChassis(string key, string name, string typeName, - DmRmcPropertiesConfig props, string pKey, uint ipid) - { - var parentDev = DeviceManager.GetDeviceForKey(pKey); - if (parentDev is DmpsRoutingController) - { - var dmps = parentDev as DmpsRoutingController; - //Check that the input is within range of this chassis' possible inputs - var num = props.ParentOutputNumber; - Debug.Console(1, "Creating DMPS device '{0}'. Output number '{1}'.", key, num); - if (num <= 0 || num > dmps.Dmps.SwitcherOutputs.Count) - { - Debug.Console(0, "Cannot create DMPS device '{0}'. Output number '{1}' is out of range", - key, num); - return null; - } - // Must use different constructor for DMPS4K types. No IPID - if (Global.ControlSystemIsDmps4kType || typeName == "hdbasetrx" || typeName == "dmrmc4k100c1g") - { - var rmc = GetDmRmcControllerForDmps4k(key, name, typeName, dmps, props.ParentOutputNumber); - Debug.Console(0, "DM endpoint output {0} is for Dmps4k, changing online feedback to chassis", num); - rmc.IsOnline.SetValueFunc(() => dmps.OutputEndpointOnlineFeedbacks[num].BoolValue); - dmps.OutputEndpointOnlineFeedbacks[num].OutputChange += (o, a) => - { - foreach (var feedback in rmc.Feedbacks) - { - if (feedback != null) - feedback.FireUpdate(); - } - }; - return rmc; - } - return GetDmRmcControllerForDmps(key, name, typeName, ipid, dmps, props.ParentOutputNumber); - } - else if (parentDev is DmChassisController) - { - var controller = parentDev as DmChassisController; - var chassis = controller.Chassis; - var num = props.ParentOutputNumber; - Debug.Console(1, "Creating DM Chassis device '{0}'. Output number '{1}'.", key, num); - - if (num <= 0 || num > chassis.NumberOfOutputs) - { - Debug.Console(0, "Cannot create DM device '{0}'. Output number '{1}' is out of range", - key, num); - return null; - } - controller.RxDictionary.Add(num, key); - // Catch constructor failures, mainly dues to IPID - try - { - // Must use different constructor for CPU3 chassis types. No IPID - if (chassis is DmMd8x8Cpu3 || chassis is DmMd16x16Cpu3 || - chassis is DmMd32x32Cpu3 || chassis is DmMd8x8Cpu3rps || - chassis is DmMd16x16Cpu3rps || chassis is DmMd32x32Cpu3rps || - chassis is DmMd128x128 || chassis is DmMd64x64 - || typeName == "hdbasetrx" || typeName == "dmrmc4k100c1g") - { - var rmc = GetDmRmcControllerForCpu3Chassis(key, name, typeName, chassis, num, parentDev); - Debug.Console(0, "DM endpoint output {0} is for Cpu3, changing online feedback to chassis", num); - rmc.IsOnline.SetValueFunc(() => controller.OutputEndpointOnlineFeedbacks[num].BoolValue); - controller.OutputEndpointOnlineFeedbacks[num].OutputChange += (o, a) => - { - foreach (var feedback in rmc.Feedbacks) - { - if (feedback != null) - feedback.FireUpdate(); - } - }; - return rmc; - } - return GetDmRmcControllerForCpu2Chassis(key, name, typeName, ipid, chassis, num, parentDev); - } - catch (Exception e) - { - Debug.Console(0, "[{0}] WARNING: Cannot create DM-RMC device: {1}", key, e.Message); - return null; - } - } - else - { - Debug.Console(0, "Cannot create DM device '{0}'. '{1}' is not a DM Chassis or DMPS.", - key, pKey); - return null; - } - } - - private static CrestronGenericBaseDevice GetDmRmcControllerForCpu2Chassis(string key, string name, string typeName, - uint ipid, Switch chassis, uint num, IKeyed parentDev) - { - Func handler; - if (ChassisDict.TryGetValue(typeName.ToLower(), out handler)) - { - return handler(key, name, ipid, chassis.Outputs[num]); - } - Debug.Console(0, "Cannot create DM-RMC of type '{0}' with parent device {1}", typeName, parentDev.Key); - return null; - } - - private static CrestronGenericBaseDevice GetDmRmcControllerForCpu3Chassis(string key, string name, string typeName, - Switch chassis, uint num, IKeyed parentDev) - { - Func cpu3Handler; - if (ChassisCpu3Dict.TryGetValue(typeName.ToLower(), out cpu3Handler)) - { - return cpu3Handler(key, name, chassis.Outputs[num]); - } - Debug.Console(0, "Cannot create DM-RMC of type '{0}' with parent device {1}", typeName, parentDev.Key); - return null; - } - - private static CrestronGenericBaseDevice GetDmRmcControllerForDmps(string key, string name, string typeName, - uint ipid, DmpsRoutingController controller, uint num) - { - Func dmpsHandler; - if (ChassisDict.TryGetValue(typeName.ToLower(), out dmpsHandler)) - { - var output = controller.Dmps.SwitcherOutputs[num] as DMOutput; - - if (output != null) - { - return dmpsHandler(key, name, ipid, output); - } - Debug.Console(0, Debug.ErrorLogLevel.Error, - "Cannot attach DM-RMC of type '{0}' to output {1} on DMPS chassis. Output is not a DM Output.", - typeName, num); - return null; - } - - Debug.Console(0, Debug.ErrorLogLevel.Error, "Cannot create DM-RMC of type '{0}' to output {1} on DMPS chassis", typeName, num); - return null; - } - - private static CrestronGenericBaseDevice GetDmRmcControllerForDmps4k(string key, string name, string typeName, - DmpsRoutingController controller, uint num) - { - Func dmps4kHandler; - if (ChassisCpu3Dict.TryGetValue(typeName.ToLower(), out dmps4kHandler)) - { - var output = controller.Dmps.SwitcherOutputs[num] as DMOutput; - - if (output != null) - { - return dmps4kHandler(key, name, output); - } - Debug.Console(0, Debug.ErrorLogLevel.Error, - "Cannot attach DM-RMC of type '{0}' to output {1} on DMPS-4K chassis. Output is not a DM Output.", - typeName, num); - return null; - } - - Debug.Console(0, Debug.ErrorLogLevel.Error, "Cannot create DM-RMC of type '{0}' to output {1} on DMPS-4K chassis", typeName, num); - return null; - } - - private static CrestronGenericBaseDevice GetDmRmcControllerForProcessor(string key, string name, string typeName, uint ipid) - { - try - { - Func handler; - - if (ProcessorFactoryDict.TryGetValue(typeName.ToLower(), out handler)) - { - return handler(key, name, ipid); - } - Debug.Console(0, "Cannot create DM-RMC of type: '{0}'", typeName); - - return null; - } - catch (Exception e) - { - Debug.Console(0, "[{0}] WARNING: Cannot create DM-RMC device: {1}", key, e.Message); - return null; - } - } - - - } - - public class DmRmcControllerFactory : EssentialsDeviceFactory - { - public DmRmcControllerFactory() - { - TypeNames = new List - { "hdbasetrx", "dmrmc4k100c1g", "dmrmc100c", "dmrmc100s", "dmrmc4k100c", "dmrmc150s", - "dmrmc200c", "dmrmc200s", "dmrmc200s2", "dmrmcscalerc", "dmrmcscalers", "dmrmcscalers2", "dmrmc4kscalerc", "dmrmc4kscalercdsp", - "dmrmc4kz100c", "dmrmc4kzscalerc" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - var type = dc.Type.ToLower(); - - Debug.Console(1, "Factory Attempting to create new DM-RMC Device"); - - var props = JsonConvert.DeserializeObject - (dc.Properties.ToString()); - return DmRmcHelper.GetDmRmcController(dc.Key, dc.Name, type, props); - } - } - -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmcScalerCController.cs b/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmcScalerCController.cs deleted file mode 100644 index ec1493d8..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmcScalerCController.cs +++ /dev/null @@ -1,108 +0,0 @@ -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 -{ - /// - /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions - /// - /// - [Description("Wrapper Class for DM-RMC-SCALER-C")] - public class DmRmcScalerCController : DmRmcControllerBase, IRoutingInputsOutputs, - IIROutputPorts, IComPorts, ICec - { - private readonly DmRmcScalerC _rmc; - - public RoutingInputPort DmIn { get; private set; } - public RoutingOutputPort HdmiOut { get; private set; } - - public RoutingPortCollection InputPorts { get; private set; } - - public RoutingPortCollection OutputPorts { get; private set; } - - /// - /// Make a Crestron RMC and put it in here - /// - public DmRmcScalerCController(string key, string name, DmRmcScalerC rmc) - : base(key, name, rmc) - { - _rmc = rmc; - DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.DmCat, 0, this); - HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, - 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; - - InputPorts = new RoutingPortCollection {DmIn}; - OutputPorts = new RoutingPortCollection {HdmiOut}; - - // Set Ports for CEC - HdmiOut.Port = _rmc.HdmiOutput; - } - - 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) - { - switch (args.EventId) - { - case ConnectedDeviceEventIds.ManufacturerEventId: - EdidManufacturerFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.NameEventId: - EdidNameFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.PreferredTimingEventId: - EdidPreferredTimingFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.SerialNumberEventId: - EdidSerialNumberFeedback.FireUpdate(); - break; - } - } - - 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 - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmcScalerS2Controller.cs b/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmcScalerS2Controller.cs deleted file mode 100644 index 12e4e9d4..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmcScalerS2Controller.cs +++ /dev/null @@ -1,109 +0,0 @@ -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 -{ - /// - /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions - /// - /// - [Description("Wrapper Class for DM-RMC-SCALER-S2")] - public class DmRmcScalerS2Controller : DmRmcControllerBase, IRoutingInputsOutputs, - IIROutputPorts, IComPorts, ICec - { - private readonly DmRmcScalerS2 _rmc; - - public RoutingInputPort DmIn { get; private set; } - public RoutingOutputPort HdmiOut { get; private set; } - - public RoutingPortCollection InputPorts { get; private set; } - - public RoutingPortCollection OutputPorts { get; private set; } - - /// - /// Make a Crestron RMC and put it in here - /// - public DmRmcScalerS2Controller(string key, string name, DmRmcScalerS2 rmc) - : base(key, name, rmc) - { - _rmc = rmc; - DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.DmCat, 0, this); - HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, - 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; - - InputPorts = new RoutingPortCollection {DmIn}; - OutputPorts = new RoutingPortCollection {HdmiOut}; - - // Set Ports for CEC - HdmiOut.Port = _rmc.HdmiOutput; - } - - 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) - { - switch (args.EventId) - { - case ConnectedDeviceEventIds.ManufacturerEventId: - EdidManufacturerFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.NameEventId: - EdidNameFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.PreferredTimingEventId: - EdidPreferredTimingFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.SerialNumberEventId: - EdidSerialNumberFeedback.FireUpdate(); - break; - } - } - - - 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 - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmcScalerSController.cs b/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmcScalerSController.cs deleted file mode 100644 index ba509eac..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmcScalerSController.cs +++ /dev/null @@ -1,108 +0,0 @@ -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 -{ - /// - /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions - /// - /// - [Description("Wrapper Class for DM-RMC-SCALER-S")] - public class DmRmcScalerSController : DmRmcControllerBase, IRoutingInputsOutputs, - IIROutputPorts, IComPorts, ICec - { - private readonly DmRmcScalerS _rmc; - - public RoutingInputPort DmIn { get; private set; } - public RoutingOutputPort HdmiOut { get; private set; } - - public RoutingPortCollection InputPorts { get; private set; } - - public RoutingPortCollection OutputPorts { get; private set; } - - /// - /// Make a Crestron RMC and put it in here - /// - public DmRmcScalerSController(string key, string name, DmRmcScalerS rmc) - : base(key, name, rmc) - { - _rmc = rmc; - DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.DmCat, 0, this); - HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, - 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; - - InputPorts = new RoutingPortCollection {DmIn}; - OutputPorts = new RoutingPortCollection {HdmiOut}; - - // Set Ports for CEC - HdmiOut.Port = _rmc.HdmiOutput; - } - - 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) - { - switch (args.EventId) - { - case ConnectedDeviceEventIds.ManufacturerEventId: - EdidManufacturerFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.NameEventId: - EdidNameFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.PreferredTimingEventId: - EdidPreferredTimingFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.SerialNumberEventId: - EdidSerialNumberFeedback.FireUpdate(); - break; - } - } - - 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 - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmcX100CController.cs b/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmcX100CController.cs deleted file mode 100644 index 867069a8..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmcX100CController.cs +++ /dev/null @@ -1,63 +0,0 @@ -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints.Receivers; - -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.DM -{ - /// - /// Builds a controller for basic DM-RMCs (both 4K and non-4K) with Com and IR ports and no control functions - /// - /// - [Description("Wrapper Class for DM-RMC-4K-100-C & DM-RMC-100-C")] - public class DmRmcX100CController : DmRmcControllerBase, IRoutingInputsOutputs, - IIROutputPorts, IComPorts, ICec - { - private readonly DmRmc100C _rmc; - - public RoutingInputPort DmIn { get; protected set; } - public RoutingOutputPort HdmiOut { get; protected set; } - - public RoutingPortCollection InputPorts { get; protected set; } - - public RoutingPortCollection OutputPorts { get; protected set; } - - /// - /// Make a Crestron RMC and put it in here - /// - public DmRmcX100CController(string key, string name, DmRmc100C rmc) - : base(key, name, rmc) - { - _rmc = rmc; - DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.DmCat, 0, this); - HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.Hdmi, null, this) {Port = _rmc}; - - InputPorts = new RoutingPortCollection {DmIn}; - OutputPorts = new RoutingPortCollection {HdmiOut}; - } - - 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 - public Cec StreamCec { get { return _rmc.StreamCec; } } - #endregion - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx200Controller.cs b/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx200Controller.cs deleted file mode 100644 index 0caf6671..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx200Controller.cs +++ /dev/null @@ -1,415 +0,0 @@ -using System; -using System.Linq; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.DM -{ - // using eVst = Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType; - - /// - /// Controller class for all DM-TX-201C/S/F transmitters - /// - [Description("Wrapper class for DM-TX-200-C")] - public class DmTx200Controller : DmTxControllerBase, ITxRoutingWithFeedback, IHasFreeRun, IVgaBrightnessContrastControls - { - public DmTx200C2G Tx { get; private set; } - - public RoutingInputPortWithVideoStatuses HdmiInput { get; private set; } - public RoutingInputPortWithVideoStatuses VgaInput { get; private set; } - public RoutingOutputPort DmOutput { get; private set; } - - public override StringFeedback ActiveVideoInputFeedback { get; protected set; } - public IntFeedback VideoSourceNumericFeedback { get; protected set; } - public IntFeedback AudioSourceNumericFeedback { get; protected set; } - public IntFeedback HdmiInHdcpCapabilityFeedback { get; protected set; } //actually state - public BoolFeedback HdmiVideoSyncFeedback { get; protected set; } - public BoolFeedback VgaVideoSyncFeedback { get; protected set; } - - public BoolFeedback FreeRunEnabledFeedback { get; protected set; } - - public IntFeedback VgaBrightnessFeedback { get; protected set; } - public IntFeedback VgaContrastFeedback { get; protected set; } - - //IroutingNumericEvent - public event EventHandler NumericSwitchChange; - - /// - /// Raise an event when the status of a switch object changes. - /// - /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType - private void OnSwitchChange(RoutingNumericEventArgs e) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, e); - } - - - /// - /// Helps get the "real" inputs, including when in Auto - /// - public DmTx200Base.eSourceSelection ActualActiveVideoInput - { - get - { - if (Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Digital || - Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Analog || - Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Disable) - return Tx.VideoSourceFeedback; - if (Tx.HdmiInput.SyncDetectedFeedback.BoolValue) - return DmTx200Base.eSourceSelection.Digital; - - return Tx.VgaInput.SyncDetectedFeedback.BoolValue ? DmTx200Base.eSourceSelection.Analog : DmTx200Base.eSourceSelection.Disable; - } - } - - public RoutingPortCollection InputPorts - { - get - { - return new RoutingPortCollection - { - HdmiInput, - VgaInput, - AnyVideoInput - }; - } - } - - public RoutingPortCollection OutputPorts - { - get - { - return new RoutingPortCollection { DmOutput }; - } - } - - /// - /// - /// - /// - /// - /// - public DmTx200Controller(string key, string name, DmTx200C2G tx, bool preventRegistration) - : base(key, name, tx) - { - Tx = tx; - PreventRegistration = preventRegistration; - - HdmiInput = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, - DmTx200Base.eSourceSelection.Digital, this, - VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInput)) - { - FeedbackMatchObject = DmTx200Base.eSourceSelection.Digital - }; - - VgaInput = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn, - eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, DmTx200Base.eSourceSelection.Analog, this, - VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput)) - { - FeedbackMatchObject = DmTx200Base.eSourceSelection.Analog - }; - - ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", - () => ActualActiveVideoInput.ToString()); - - Tx.HdmiInput.InputStreamChange += InputStreamChangeEvent; - Tx.VgaInput.InputStreamChange += VgaInputOnInputStreamChange; - Tx.BaseEvent += Tx_BaseEvent; - Tx.OnlineStatusChange += Tx_OnlineStatusChange; - - VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); - AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.AudioSourceFeedback); - - HdmiInHdcpCapabilityFeedback = new IntFeedback("HdmiInHdcpCapability", () => tx.HdmiInput.HdcpSupportOnFeedback.BoolValue ? 1 : 0); - - //setting this on the base class so that we can get it easily on the chassis. - HdcpStateFeedback = HdmiInHdcpCapabilityFeedback; - - HdcpSupportCapability = eHdcpCapabilityType.HdcpAutoSupport; - - HdmiVideoSyncFeedback = new BoolFeedback(() => tx.HdmiInput.SyncDetectedFeedback.BoolValue); - - VgaVideoSyncFeedback = new BoolFeedback(() => tx.VgaInput.SyncDetectedFeedback.BoolValue); - - FreeRunEnabledFeedback = new BoolFeedback(() => tx.VgaInput.FreeRunFeedback == eDmFreeRunSetting.Enabled); - - VgaBrightnessFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.BrightnessFeedback.UShortValue); - VgaContrastFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.ContrastFeedback.UShortValue); - - tx.VgaInput.VideoControls.ControlChange += VideoControls_ControlChange; - - - var combinedFuncs = new VideoStatusFuncsWrapper - { - HdcpActiveFeedbackFunc = () => - (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital - && tx.HdmiInput.VideoAttributes.HdcpActiveFeedback.BoolValue), - - HdcpStateFeedbackFunc = () => ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital ? tx.HdmiInput.VideoAttributes.HdcpStateFeedback.ToString() : "", - - VideoResolutionFeedbackFunc = () => - { - if (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital) - return tx.HdmiInput.VideoAttributes.GetVideoResolutionString(); - return ActualActiveVideoInput == DmTx200Base.eSourceSelection.Analog ? tx.VgaInput.VideoAttributes.GetVideoResolutionString() : ""; - }, - VideoSyncFeedbackFunc = () => - (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital - && tx.HdmiInput.SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Analog - && tx.VgaInput.SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Auto - && (tx.VgaInput.SyncDetectedFeedback.BoolValue || tx.HdmiInput.SyncDetectedFeedback.BoolValue)) - - }; - - AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs); - - DmOutput = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmCat, null, this); - - AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, - AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, - AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, - AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiInHdcpCapabilityFeedback, HdmiVideoSyncFeedback, - VgaVideoSyncFeedback); - - // Set Ports for CEC - HdmiInput.Port = Tx.HdmiInput; - VgaInput.Port = Tx.VgaInput; - DmOutput.Port = Tx.DmOutput; - } - - private void VgaInputOnInputStreamChange(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - switch (args.EventId) - { - case EndpointInputStreamEventIds.FreeRunFeedbackEventId: - FreeRunEnabledFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - VgaVideoSyncFeedback.FireUpdate(); - break; - } - } - - void VideoControls_ControlChange(object sender, GenericEventArgs args) - { - var id = args.EventId; - Debug.Console(2, this, "EventId {0}", args.EventId); - - switch (id) - { - case VideoControlsEventIds.BrightnessFeedbackEventId: - VgaBrightnessFeedback.FireUpdate(); - break; - case VideoControlsEventIds.ContrastFeedbackEventId: - VgaContrastFeedback.FireUpdate(); - break; - } - } - - void Tx_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) - { - var localVideoInputPort = - InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection) p.Selector == Tx.VideoSourceFeedback); - var localAudioInputPort = - InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection) p.Selector == Tx.AudioSourceFeedback); - - - ActiveVideoInputFeedback.FireUpdate(); - VideoSourceNumericFeedback.FireUpdate(); - AudioSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localAudioInputPort, eRoutingSignalType.Audio)); - } - - public override bool CustomActivate() - { - - Tx.HdmiInput.InputStreamChange += (o, a) => FowardInputStreamChange(HdmiInput, a.EventId); - Tx.HdmiInput.VideoAttributes.AttributeChange += (o, a) => FireVideoAttributeChange(HdmiInput, a.EventId); - - Tx.VgaInput.InputStreamChange += (o, a) => FowardInputStreamChange(VgaInput, a.EventId); - Tx.VgaInput.VideoAttributes.AttributeChange += (o, a) => FireVideoAttributeChange(VgaInput, a.EventId); - - // Base does register and sets up comm monitoring. - return base.CustomActivate(); - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); - - if (HdmiVideoSyncFeedback != null) - { - HdmiVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); - } - if (VgaVideoSyncFeedback != null) - { - VgaVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); - } - - LinkDmTxToApi(this, trilist, joinMap, bridge); - } - - /// - /// Enables or disables free run - /// - /// - public void SetFreeRunEnabled(bool enable) - { - Tx.VgaInput.FreeRun = enable ? eDmFreeRunSetting.Enabled : eDmFreeRunSetting.Disabled; - } - - /// - /// Sets the VGA brightness level - /// - /// - public void SetVgaBrightness(ushort level) - { - Tx.VgaInput.VideoControls.Brightness.UShortValue = level; - } - - /// - /// Sets the VGA contrast level - /// - /// - public void SetVgaContrast(ushort level) - { - Tx.VgaInput.VideoControls.Contrast.UShortValue = level; - } - - public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) - { - Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); - - switch (input) - { - case 0: - { - ExecuteSwitch(DmTx200Base.eSourceSelection.Auto, null, type); - break; - } - case 1: - { - ExecuteSwitch(HdmiInput.Selector, null, type); - break; - } - case 2: - { - ExecuteSwitch(VgaInput.Selector, null, type); - break; - } - case 3: - { - ExecuteSwitch(DmTx200Base.eSourceSelection.Disable, null, type); - break; - } - } - } - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - if ((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video) - Tx.VideoSource = (DmTx200Base.eSourceSelection)inputSelector; - if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) - Tx.AudioSource = (DmTx200Base.eSourceSelection)inputSelector; - } - - void Tx_BaseEvent(GenericBase device, BaseEventArgs args) - { - var id = args.EventId; - Debug.Console(2, this, "EventId {0}", args.EventId); - - switch (id) - { - case EndpointTransmitterBase.VideoSourceFeedbackEventId: - var localVideoInputPort = InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.VideoSourceFeedback); - Debug.Console(2, this, " Video Source: {0}", Tx.VideoSourceFeedback); - VideoSourceNumericFeedback.FireUpdate(); - ActiveVideoInputFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - break; - case EndpointTransmitterBase.AudioSourceFeedbackEventId: - var localInputAudioPort = InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.AudioSourceFeedback); - Debug.Console(2, this, " Audio Source: {0}", Tx.AudioSourceFeedback); - AudioSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio)); - break; - } - } - - void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - Debug.Console(2, "{0} event {1} stream {2}", Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); - - switch (args.EventId) - { - case EndpointInputStreamEventIds.HdcpSupportOffFeedbackEventId: - HdmiInHdcpCapabilityFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.HdcpSupportOnFeedbackEventId: - HdmiInHdcpCapabilityFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - HdmiVideoSyncFeedback.FireUpdate(); - break; - } - } - - /// - /// Relays the input stream change to the appropriate RoutingInputPort. - /// - void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) - { - return; - } - inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); - } - - /// - /// Relays the VideoAttributes change to a RoutingInputPort - /// - void FireVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds - //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", - // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); - switch (eventId) - { - case VideoAttributeEventIds.HdcpActiveFeedbackEventId: - inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HdcpStateFeedbackEventId: - inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: - case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - } - } - - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx201CController.cs b/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx201CController.cs deleted file mode 100644 index 2e48f1e2..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx201CController.cs +++ /dev/null @@ -1,430 +0,0 @@ -using System; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; -using System.Linq; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.DM -{ - /// - /// Controller class for all DM-TX-201C/S/F transmitters - /// - [Description("Wrapper class for DM-TX-201-C")] - public class DmTx201CController : DmTxControllerBase, ITxRoutingWithFeedback, IHasFreeRun, IVgaBrightnessContrastControls - { - public DmTx201C Tx { get; private set; } - - public RoutingInputPortWithVideoStatuses HdmiInput { get; private set; } - public RoutingInputPortWithVideoStatuses VgaInput { get; private set; } - public RoutingOutputPort DmOutput { get; private set; } - public RoutingOutputPort HdmiLoopOut { get; private set; } - - public override StringFeedback ActiveVideoInputFeedback { get; protected set; } - public IntFeedback VideoSourceNumericFeedback { get; protected set; } - public IntFeedback AudioSourceNumericFeedback { get; protected set; } - public IntFeedback HdmiInHdcpCapabilityFeedback { get; protected set; } - public BoolFeedback HdmiVideoSyncFeedback { get; protected set; } - public BoolFeedback VgaVideoSyncFeedback { get; protected set; } - - public BoolFeedback FreeRunEnabledFeedback { get; protected set; } - - public IntFeedback VgaBrightnessFeedback { get; protected set; } - public IntFeedback VgaContrastFeedback { get; protected set; } - - //IroutingNumericEvent - public event EventHandler NumericSwitchChange; - - /// - /// Raise an event when the status of a switch object changes. - /// - /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType - private void OnSwitchChange(RoutingNumericEventArgs e) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, e); - } - - /// - /// Helps get the "real" inputs, including when in Auto - /// - public DmTx200Base.eSourceSelection ActualActiveVideoInput - { - get - { - if (Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Digital || - Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Analog || - Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Disable) - return Tx.VideoSourceFeedback; - else // auto - { - if (Tx.HdmiInput.SyncDetectedFeedback.BoolValue) - return DmTx200Base.eSourceSelection.Digital; - else if (Tx.VgaInput.SyncDetectedFeedback.BoolValue) - return DmTx200Base.eSourceSelection.Analog; - else - return DmTx200Base.eSourceSelection.Disable; - } - } - } - - public RoutingPortCollection InputPorts - { - get - { - return new RoutingPortCollection - { - HdmiInput, - VgaInput, - AnyVideoInput - }; - } - } - - public RoutingPortCollection OutputPorts - { - get - { - return new RoutingPortCollection { DmOutput, HdmiLoopOut }; - } - } - - /// - /// - /// - /// - /// - /// - public DmTx201CController(string key, string name, DmTx201C tx, bool preventRegistration) - : base(key, name, tx) - { - Tx = tx; - PreventRegistration = preventRegistration; - - HdmiInput = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, - DmTx200Base.eSourceSelection.Digital, this, - VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInput)) - { - FeedbackMatchObject = DmTx200Base.eSourceSelection.Digital - }; - - VgaInput = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn, - eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, DmTx200Base.eSourceSelection.Analog, this, - VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput)) - { - FeedbackMatchObject = DmTx200Base.eSourceSelection.Analog - }; - - ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", - () => ActualActiveVideoInput.ToString()); - - Tx.HdmiInput.InputStreamChange += InputStreamChangeEvent; - Tx.VgaInput.InputStreamChange += VgaInputOnInputStreamChange; - Tx.BaseEvent += Tx_BaseEvent; - Tx.OnlineStatusChange += new OnlineStatusChangeEventHandler(Tx_OnlineStatusChange); - - VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); - - AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.AudioSourceFeedback); - - HdmiInHdcpCapabilityFeedback = new IntFeedback("HdmiInHdcpCapability", () => - (tx.HdmiInput.HdcpSupportOnFeedback.BoolValue ? 1 : 0)); - - HdcpStateFeedback = HdmiInHdcpCapabilityFeedback; - - HdmiVideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInput.SyncDetectedFeedback.BoolValue); - - VgaVideoSyncFeedback = new BoolFeedback(() => (bool)tx.VgaInput.SyncDetectedFeedback.BoolValue); - - FreeRunEnabledFeedback = new BoolFeedback(() => tx.VgaInput.FreeRunFeedback == eDmFreeRunSetting.Enabled); - - VgaBrightnessFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.BrightnessFeedback.UShortValue); - - VgaContrastFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.ContrastFeedback.UShortValue); - - tx.VgaInput.VideoControls.ControlChange += VideoControls_ControlChange; - - HdcpSupportCapability = eHdcpCapabilityType.HdcpAutoSupport; - - var combinedFuncs = new VideoStatusFuncsWrapper - { - HdcpActiveFeedbackFunc = () => - (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital - && tx.HdmiInput.VideoAttributes.HdcpActiveFeedback.BoolValue), - - HdcpStateFeedbackFunc = () => ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital ? - tx.HdmiInput.VideoAttributes.HdcpStateFeedback.ToString() : "", - - VideoResolutionFeedbackFunc = () => - { - if (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital) - return tx.HdmiInput.VideoAttributes.GetVideoResolutionString(); - return ActualActiveVideoInput == DmTx200Base.eSourceSelection.Analog ? - tx.VgaInput.VideoAttributes.GetVideoResolutionString() : ""; - }, - - VideoSyncFeedbackFunc = () => - (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital - && tx.HdmiInput.SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Analog - && tx.VgaInput.SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Auto - && (tx.VgaInput.SyncDetectedFeedback.BoolValue || tx.HdmiInput.SyncDetectedFeedback.BoolValue)) - - }; - - AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs); - - DmOutput = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat, null, this); - HdmiLoopOut = new RoutingOutputPort(DmPortName.HdmiLoopOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, null, this); - - AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, - AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, - AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, - AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiInHdcpCapabilityFeedback, HdmiVideoSyncFeedback, - VgaVideoSyncFeedback); - - // Set Ports for CEC - HdmiInput.Port = Tx.HdmiInput; - VgaInput.Port = Tx.VgaInput; - HdmiLoopOut.Port = Tx.HdmiOutput; - DmOutput.Port = Tx.DmOutput; - } - - void VideoControls_ControlChange(object sender, Crestron.SimplSharpPro.DeviceSupport.GenericEventArgs args) - { - var id = args.EventId; - Debug.Console(2, this, "EventId {0}", args.EventId); - - switch (id) - { - case VideoControlsEventIds.BrightnessFeedbackEventId: - VgaBrightnessFeedback.FireUpdate(); - break; - case VideoControlsEventIds.ContrastFeedbackEventId: - VgaContrastFeedback.FireUpdate(); - break; - } - } - - void Tx_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) - { - var localVideoInputPort = - InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.VideoSourceFeedback); - var localAudioInputPort = - InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.AudioSourceFeedback); - - - ActiveVideoInputFeedback.FireUpdate(); - VideoSourceNumericFeedback.FireUpdate(); - AudioSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localAudioInputPort, eRoutingSignalType.Audio)); - } - - private void VgaInputOnInputStreamChange(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - switch (args.EventId) - { - case EndpointInputStreamEventIds.FreeRunFeedbackEventId: - FreeRunEnabledFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - VgaVideoSyncFeedback.FireUpdate(); - break; - } - } - - public override bool CustomActivate() - { - Tx.HdmiInput.InputStreamChange += (o, a) => FowardInputStreamChange(HdmiInput, a.EventId); - Tx.HdmiInput.VideoAttributes.AttributeChange += (o, a) => FireVideoAttributeChange(HdmiInput, a.EventId); - - Tx.VgaInput.InputStreamChange += (o, a) => FowardInputStreamChange(VgaInput, a.EventId); - Tx.VgaInput.VideoAttributes.AttributeChange += (o, a) => FireVideoAttributeChange(VgaInput, a.EventId); - - // Base does register and sets up comm monitoring. - return base.CustomActivate(); - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); - - if (HdmiVideoSyncFeedback != null) - { - HdmiVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); - } - if (VgaVideoSyncFeedback != null) - { - VgaVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); - } - - LinkDmTxToApi(this, trilist, joinMap, bridge); - } - - /// - /// Enables or disables free run - /// - /// - public void SetFreeRunEnabled(bool enable) - { - Tx.VgaInput.FreeRun = enable ? eDmFreeRunSetting.Enabled : eDmFreeRunSetting.Disabled; - } - - /// - /// Sets the VGA brightness level - /// - /// - public void SetVgaBrightness(ushort level) - { - Tx.VgaInput.VideoControls.Brightness.UShortValue = level; - } - - /// - /// Sets the VGA contrast level - /// - /// - public void SetVgaContrast(ushort level) - { - Tx.VgaInput.VideoControls.Contrast.UShortValue = level; - } - - /// - /// Switches the audio/video source based on the integer value (0-Auto, 1-HDMI, 2-VGA, 3-Disable) - /// - /// - /// - /// - public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) - { - Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); - - switch (input) - { - case 0: - { - ExecuteSwitch(DmTx200Base.eSourceSelection.Auto, null, type); - break; - } - case 1: - { - ExecuteSwitch(HdmiInput.Selector, null, type); - break; - } - case 2: - { - ExecuteSwitch(VgaInput.Selector, null, type); - break; - } - case 3: - { - ExecuteSwitch(DmTx200Base.eSourceSelection.Disable, null, type); - break; - } - } - } - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - if((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video) - Tx.VideoSource = (DmTx200Base.eSourceSelection)inputSelector; - if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) - Tx.AudioSource = (DmTx200Base.eSourceSelection)inputSelector; - } - - void Tx_BaseEvent(GenericBase device, BaseEventArgs args) - { - var id = args.EventId; - Debug.Console(2, this, "EventId {0}", args.EventId); - - switch (id) - { - case EndpointTransmitterBase.VideoSourceFeedbackEventId: - var localVideoInputPort = InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.VideoSourceFeedback); - Debug.Console(2, this, " Video Source: {0}", Tx.VideoSourceFeedback); - VideoSourceNumericFeedback.FireUpdate(); - ActiveVideoInputFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - break; - case EndpointTransmitterBase.AudioSourceFeedbackEventId: - var localInputAudioPort = InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.AudioSourceFeedback); - Debug.Console(2, this, " Audio Source: {0}", Tx.AudioSourceFeedback); - AudioSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio)); - break; - } - } - - void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - Debug.Console(2, "{0} event {1} stream {2}", Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); - - switch (args.EventId) - { - case EndpointInputStreamEventIds.HdcpSupportOffFeedbackEventId: - HdmiInHdcpCapabilityFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.HdcpSupportOnFeedbackEventId: - HdmiInHdcpCapabilityFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - HdmiVideoSyncFeedback.FireUpdate(); - break; - } - - } - - /// - /// Relays the input stream change to the appropriate RoutingInputPort. - /// - void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) - { - return; - } - inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); - } - - /// - /// Relays the VideoAttributes change to a RoutingInputPort - /// - void FireVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds - //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", - // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); - switch (eventId) - { - case VideoAttributeEventIds.HdcpActiveFeedbackEventId: - inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HdcpStateFeedbackEventId: - inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: - case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - } - } - - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx201SController.cs b/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx201SController.cs deleted file mode 100644 index 08d43b63..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx201SController.cs +++ /dev/null @@ -1,432 +0,0 @@ -using System; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; -using System.Linq; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.DM -{ - /// - /// Controller class for all DM-TX-201S/F transmitters - /// - [Description("Wrapper class for DM-TX-201-S/F")] - public class DmTx201SController : DmTxControllerBase, ITxRoutingWithFeedback, IHasFreeRun, IVgaBrightnessContrastControls - { - public DmTx201S Tx { get; private set; } - - public RoutingInputPortWithVideoStatuses HdmiInput { get; private set; } - public RoutingInputPortWithVideoStatuses VgaInput { get; private set; } - public RoutingOutputPort DmOutput { get; private set; } - public RoutingOutputPort HdmiLoopOut { get; private set; } - - public override StringFeedback ActiveVideoInputFeedback { get; protected set; } - public IntFeedback VideoSourceNumericFeedback { get; protected set; } - public IntFeedback AudioSourceNumericFeedback { get; protected set; } - public IntFeedback HdmiInHdcpCapabilityFeedback { get; protected set; } - public BoolFeedback HdmiVideoSyncFeedback { get; protected set; } - public BoolFeedback VgaVideoSyncFeedback { get; protected set; } - - public BoolFeedback FreeRunEnabledFeedback { get; protected set; } - - public IntFeedback VgaBrightnessFeedback { get; protected set; } - public IntFeedback VgaContrastFeedback { get; protected set; } - - //IroutingNumericEvent - public event EventHandler NumericSwitchChange; - - /// - /// - /// Raise an event when the status of a switch object changes. - /// - /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType - private void OnSwitchChange(RoutingNumericEventArgs e) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, e); - } - - - /// - /// Helps get the "real" inputs, including when in Auto - /// - public DmTx200Base.eSourceSelection ActualActiveVideoInput - { - get - { - if (Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Digital || - Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Analog || - Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Disable) - return Tx.VideoSourceFeedback; - else // auto - { - if (Tx.HdmiInput.SyncDetectedFeedback.BoolValue) - return DmTx200Base.eSourceSelection.Digital; - else if (Tx.VgaInput.SyncDetectedFeedback.BoolValue) - return DmTx200Base.eSourceSelection.Analog; - else - return DmTx200Base.eSourceSelection.Disable; - } - } - } - - public RoutingPortCollection InputPorts - { - get - { - return new RoutingPortCollection - { - HdmiInput, - VgaInput, - AnyVideoInput - }; - } - } - - public RoutingPortCollection OutputPorts - { - get - { - return new RoutingPortCollection { DmOutput, HdmiLoopOut }; - } - } - - /// - /// - /// - /// - /// - /// - public DmTx201SController(string key, string name, DmTx201S tx, bool preventRegistration) - : base(key, name, tx) - { - Tx = tx; - PreventRegistration = preventRegistration; - - HdmiInput = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, - DmTx200Base.eSourceSelection.Digital, this, - VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInput)) - { - FeedbackMatchObject = DmTx200Base.eSourceSelection.Digital - }; - - VgaInput = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn, - eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, DmTx200Base.eSourceSelection.Analog, this, - VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput)) - { - FeedbackMatchObject = DmTx200Base.eSourceSelection.Analog - }; - - ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", - () => ActualActiveVideoInput.ToString()); - - Tx.HdmiInput.InputStreamChange += InputStreamChangeEvent; - Tx.VgaInput.InputStreamChange += VgaInputOnInputStreamChange; - Tx.BaseEvent += Tx_BaseEvent; - Tx.OnlineStatusChange += new OnlineStatusChangeEventHandler(Tx_OnlineStatusChange); - - VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); - - AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.AudioSourceFeedback); - - HdmiInHdcpCapabilityFeedback = new IntFeedback("HdmiInHdcpCapability", () => - (tx.HdmiInput.HdcpSupportOnFeedback.BoolValue ? 1 : 0)); - - HdcpStateFeedback = HdmiInHdcpCapabilityFeedback; - - HdmiVideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInput.SyncDetectedFeedback.BoolValue); - - VgaVideoSyncFeedback = new BoolFeedback(() => (bool)tx.VgaInput.SyncDetectedFeedback.BoolValue); - - FreeRunEnabledFeedback = new BoolFeedback(() => tx.VgaInput.FreeRunFeedback == eDmFreeRunSetting.Enabled); - - VgaBrightnessFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.BrightnessFeedback.UShortValue); - - VgaContrastFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.ContrastFeedback.UShortValue); - - tx.VgaInput.VideoControls.ControlChange += VideoControls_ControlChange; - - HdcpSupportCapability = eHdcpCapabilityType.HdcpAutoSupport; - - var combinedFuncs = new VideoStatusFuncsWrapper - { - HdcpActiveFeedbackFunc = () => - (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital - && tx.HdmiInput.VideoAttributes.HdcpActiveFeedback.BoolValue), - - HdcpStateFeedbackFunc = () => ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital ? - tx.HdmiInput.VideoAttributes.HdcpStateFeedback.ToString() : "", - - VideoResolutionFeedbackFunc = () => - { - if (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital) - return tx.HdmiInput.VideoAttributes.GetVideoResolutionString(); - return ActualActiveVideoInput == DmTx200Base.eSourceSelection.Analog ? - tx.VgaInput.VideoAttributes.GetVideoResolutionString() : ""; - }, - - VideoSyncFeedbackFunc = () => - (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital - && tx.HdmiInput.SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Analog - && tx.VgaInput.SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Auto - && (tx.VgaInput.SyncDetectedFeedback.BoolValue || tx.HdmiInput.SyncDetectedFeedback.BoolValue)) - - }; - - AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs); - - DmOutput = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat, null, this); - HdmiLoopOut = new RoutingOutputPort(DmPortName.HdmiLoopOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, null, this); - - AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, - AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, - AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, - AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiInHdcpCapabilityFeedback, HdmiVideoSyncFeedback, - VgaVideoSyncFeedback); - - // Set Ports for CEC - HdmiInput.Port = Tx.HdmiInput; - VgaInput.Port = Tx.VgaInput; - HdmiLoopOut.Port = Tx.HdmiOutput; - DmOutput.Port = Tx.DmOutput; - } - - void VideoControls_ControlChange(object sender, Crestron.SimplSharpPro.DeviceSupport.GenericEventArgs args) - { - var id = args.EventId; - Debug.Console(2, this, "EventId {0}", args.EventId); - - switch (id) - { - case VideoControlsEventIds.BrightnessFeedbackEventId: - VgaBrightnessFeedback.FireUpdate(); - break; - case VideoControlsEventIds.ContrastFeedbackEventId: - VgaContrastFeedback.FireUpdate(); - break; - } - } - - void Tx_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) - { - var localVideoInputPort = - InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.VideoSourceFeedback); - var localAudioInputPort = - InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.AudioSourceFeedback); - - - ActiveVideoInputFeedback.FireUpdate(); - VideoSourceNumericFeedback.FireUpdate(); - AudioSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localAudioInputPort, eRoutingSignalType.Audio)); - } - - private void VgaInputOnInputStreamChange(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - switch (args.EventId) - { - case EndpointInputStreamEventIds.FreeRunFeedbackEventId: - FreeRunEnabledFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - VgaVideoSyncFeedback.FireUpdate(); - break; - } - } - - public override bool CustomActivate() - { - Tx.HdmiInput.InputStreamChange += (o, a) => FowardInputStreamChange(HdmiInput, a.EventId); - Tx.HdmiInput.VideoAttributes.AttributeChange += (o, a) => FireVideoAttributeChange(HdmiInput, a.EventId); - - Tx.VgaInput.InputStreamChange += (o, a) => FowardInputStreamChange(VgaInput, a.EventId); - Tx.VgaInput.VideoAttributes.AttributeChange += (o, a) => FireVideoAttributeChange(VgaInput, a.EventId); - - // Base does register and sets up comm monitoring. - return base.CustomActivate(); - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); - - if (HdmiVideoSyncFeedback != null) - { - HdmiVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); - } - if (VgaVideoSyncFeedback != null) - { - VgaVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); - } - - LinkDmTxToApi(this, trilist, joinMap, bridge); - } - - /// - /// Enables or disables free run - /// - /// - public void SetFreeRunEnabled(bool enable) - { - Tx.VgaInput.FreeRun = enable ? eDmFreeRunSetting.Enabled : eDmFreeRunSetting.Disabled; - } - - /// - /// Sets the VGA brightness level - /// - /// - public void SetVgaBrightness(ushort level) - { - Tx.VgaInput.VideoControls.Brightness.UShortValue = level; - } - - /// - /// Sets the VGA contrast level - /// - /// - public void SetVgaContrast(ushort level) - { - Tx.VgaInput.VideoControls.Contrast.UShortValue = level; - } - - /// - /// Switches the audio/video source based on the integer value (0-Auto, 1-HDMI, 2-VGA, 3-Disable) - /// - /// - /// - /// - public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) - { - Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); - - switch (input) - { - case 0: - { - ExecuteSwitch(DmTx200Base.eSourceSelection.Auto, null, type); - break; - } - case 1: - { - ExecuteSwitch(HdmiInput.Selector, null, type); - break; - } - case 2: - { - ExecuteSwitch(VgaInput.Selector, null, type); - break; - } - case 3: - { - ExecuteSwitch(DmTx200Base.eSourceSelection.Disable, null, type); - break; - } - } - } - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - if ((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video) - Tx.VideoSource = (DmTx200Base.eSourceSelection)inputSelector; - if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) - Tx.AudioSource = (DmTx200Base.eSourceSelection)inputSelector; - } - - void Tx_BaseEvent(GenericBase device, BaseEventArgs args) - { - var id = args.EventId; - Debug.Console(2, this, "EventId {0}", args.EventId); - - switch (id) - { - case EndpointTransmitterBase.VideoSourceFeedbackEventId: - var localVideoInputPort = InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.VideoSourceFeedback); - Debug.Console(2, this, " Video Source: {0}", Tx.VideoSourceFeedback); - VideoSourceNumericFeedback.FireUpdate(); - ActiveVideoInputFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - break; - case EndpointTransmitterBase.AudioSourceFeedbackEventId: - var localInputAudioPort = InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.AudioSourceFeedback); - Debug.Console(2, this, " Audio Source: {0}", Tx.AudioSourceFeedback); - AudioSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio)); - break; - } - } - - void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - Debug.Console(2, "{0} event {1} stream {2}", Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); - - switch (args.EventId) - { - case EndpointInputStreamEventIds.HdcpSupportOffFeedbackEventId: - HdmiInHdcpCapabilityFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.HdcpSupportOnFeedbackEventId: - HdmiInHdcpCapabilityFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - HdmiVideoSyncFeedback.FireUpdate(); - break; - } - - } - - /// - /// Relays the input stream change to the appropriate RoutingInputPort. - /// - void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) - { - return; - } - inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); - } - - /// - /// Relays the VideoAttributes change to a RoutingInputPort - /// - void FireVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds - //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", - // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); - switch (eventId) - { - case VideoAttributeEventIds.HdcpActiveFeedbackEventId: - inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HdcpStateFeedbackEventId: - inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: - case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - } - } - - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx401CController.cs b/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx401CController.cs deleted file mode 100644 index a165cd66..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx401CController.cs +++ /dev/null @@ -1,494 +0,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.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.DM.Config; - -namespace PepperDash.Essentials.DM -{ - using eVst = DmTx401C.eSourceSelection; - - [Description("Wrapper class for DM-TX-401-C")] - public class DmTx401CController : DmTxControllerBase, ITxRoutingWithFeedback, IIROutputPorts, IComPorts, IHasFreeRun, IVgaBrightnessContrastControls - { - public DmTx401C Tx { get; private set; } - - public RoutingInputPortWithVideoStatuses HdmiIn { get; private set; } - public RoutingInputPortWithVideoStatuses DisplayPortIn { get; private set; } - public RoutingInputPortWithVideoStatuses VgaIn { get; private set; } - public RoutingInputPortWithVideoStatuses CompositeIn { get; private set; } - public RoutingOutputPort DmOut { get; private set; } - - public override StringFeedback ActiveVideoInputFeedback { get; protected set; } - public IntFeedback VideoSourceNumericFeedback { get; protected set; } - public IntFeedback AudioSourceNumericFeedback { get; protected set; } - public IntFeedback HdmiInHdcpCapabilityFeedback { get; protected set; } - public BoolFeedback DisplayPortVideoSyncFeedback { get; protected set; } - public BoolFeedback HdmiVideoSyncFeedback { get; protected set; } - public BoolFeedback VgaVideoSyncFeedback { get; protected set; } - - public BoolFeedback FreeRunEnabledFeedback { get; protected set; } - - public IntFeedback VgaBrightnessFeedback { get; protected set; } - public IntFeedback VgaContrastFeedback { get; protected set; } - - //IroutingNumericEvent - public event EventHandler NumericSwitchChange; - - /// - /// Raise an event when the status of a switch object changes. - /// - /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType - private void OnSwitchChange(RoutingNumericEventArgs e) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, e); - } - - - /// - /// Helps get the "real" inputs, including when in Auto - /// - public BaseDmTx401.eSourceSelection ActualVideoInput - { - get - { - if (Tx.VideoSourceFeedback != BaseDmTx401.eSourceSelection.Auto) - return Tx.VideoSourceFeedback; - else // auto - { - if (Tx.HdmiInput.SyncDetectedFeedback.BoolValue) - return BaseDmTx401.eSourceSelection.HDMI; - else if (Tx.VgaInput.SyncDetectedFeedback.BoolValue) - return BaseDmTx401.eSourceSelection.VGA; - else if (Tx.DisplayPortInput.SyncDetectedFeedback.BoolValue) - return BaseDmTx401.eSourceSelection.DisplayPort; - else if (Tx.CvbsInput.SyncDetectedFeedback.BoolValue) - return BaseDmTx401.eSourceSelection.Composite; - else - return BaseDmTx401.eSourceSelection.Disabled; - } - } - } - - public RoutingPortCollection InputPorts - { - get - { - return new RoutingPortCollection - { - HdmiIn, - DisplayPortIn, - VgaIn, - CompositeIn, - AnyVideoInput - }; - } - } - - public RoutingPortCollection OutputPorts - { - get - { - return new RoutingPortCollection { DmOut }; - } - } - - /// - /// - /// - /// - /// - /// - public DmTx401CController(string key, string name, DmTx401C tx, bool preventRegistration) - : base(key, name, tx) - { - Tx = tx; - PreventRegistration = preventRegistration; - - HdmiIn = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.HDMI, this, - VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInput)) - { - FeedbackMatchObject = eVst.HDMI - }; - DisplayPortIn = new RoutingInputPortWithVideoStatuses(DmPortName.DisplayPortIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.DisplayPort, this, - VideoStatusHelper.GetDisplayPortInputStatusFuncs(tx.DisplayPortInput)) - { - FeedbackMatchObject = eVst.DisplayPort - }; - VgaIn = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn, - eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, eVst.VGA, this, - VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput)) - { - FeedbackMatchObject = eVst.VGA - }; - CompositeIn = new RoutingInputPortWithVideoStatuses(DmPortName.CompositeIn, - eRoutingSignalType.Video, eRoutingPortConnectionType.Composite, eVst.Composite, this, - VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput)) - { - FeedbackMatchObject = eVst.Composite - }; - - Tx.HdmiInput.InputStreamChange += HdmiInputStreamChangeEvent; - Tx.DisplayPortInput.InputStreamChange += DisplayPortInputStreamChangeEvent; - Tx.BaseEvent += Tx_BaseEvent; - Tx.OnlineStatusChange += Tx_OnlineStatusChange; - Tx.VgaInput.InputStreamChange += VgaInputOnInputStreamChange; - tx.VgaInput.VideoControls.ControlChange += VideoControls_ControlChange; - - - ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", - () => ActualVideoInput.ToString()); - - VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); - - AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.AudioSourceFeedback); - - HdmiInHdcpCapabilityFeedback = new IntFeedback("HdmiInHdcpCapability", () => tx.HdmiInput.HdcpSupportOnFeedback.BoolValue ? 1 : 0); - - HdcpStateFeedback = HdmiInHdcpCapabilityFeedback; - - HdcpSupportCapability = eHdcpCapabilityType.HdcpAutoSupport; - - DisplayPortVideoSyncFeedback = new BoolFeedback("DisplayPortVideoSync", () => (bool)tx.DisplayPortInput.SyncDetectedFeedback.BoolValue); - - HdmiVideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInput.SyncDetectedFeedback.BoolValue); - - VgaVideoSyncFeedback = new BoolFeedback(() => (bool)tx.VgaInput.SyncDetectedFeedback.BoolValue); - - FreeRunEnabledFeedback = new BoolFeedback(() => tx.VgaInput.FreeRunFeedback == eDmFreeRunSetting.Enabled); - - VgaBrightnessFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.BrightnessFeedback.UShortValue); - - VgaContrastFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.ContrastFeedback.UShortValue); - - - var combinedFuncs = new VideoStatusFuncsWrapper - { - HdcpActiveFeedbackFunc = () => - (ActualVideoInput == eVst.HDMI - && tx.HdmiInput.VideoAttributes.HdcpActiveFeedback.BoolValue) - || (ActualVideoInput == eVst.DisplayPort - && tx.DisplayPortInput.VideoAttributes.HdcpActiveFeedback.BoolValue), - - HdcpStateFeedbackFunc = () => - { - if (ActualVideoInput == eVst.HDMI) - return tx.HdmiInput.VideoAttributes.HdcpStateFeedback.ToString(); - if (ActualVideoInput == eVst.DisplayPort) - return tx.DisplayPortInput.VideoAttributes.HdcpStateFeedback.ToString(); - return ""; - }, - - VideoResolutionFeedbackFunc = () => - { - if (ActualVideoInput == eVst.HDMI) - return tx.HdmiInput.VideoAttributes.GetVideoResolutionString(); - if (ActualVideoInput == eVst.DisplayPort) - return tx.DisplayPortInput.VideoAttributes.GetVideoResolutionString(); - if (ActualVideoInput == eVst.VGA) - return tx.VgaInput.VideoAttributes.GetVideoResolutionString(); - if (ActualVideoInput == eVst.Composite) - return tx.CvbsInput.VideoAttributes.GetVideoResolutionString(); - return ""; - }, - VideoSyncFeedbackFunc = () => - (ActualVideoInput == eVst.HDMI - && tx.HdmiInput.SyncDetectedFeedback.BoolValue) - || (ActualVideoInput == eVst.DisplayPort - && tx.DisplayPortInput.SyncDetectedFeedback.BoolValue) - || (ActualVideoInput == eVst.VGA - && tx.VgaInput.SyncDetectedFeedback.BoolValue) - || (ActualVideoInput == eVst.Composite - && tx.CvbsInput.SyncDetectedFeedback.BoolValue) - }; - - AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs); - - DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmCat, null, this); - - AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, - AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, - AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, - AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiInHdcpCapabilityFeedback, DisplayPortVideoSyncFeedback, - HdmiVideoSyncFeedback, VgaVideoSyncFeedback); - - // Set Ports for CEC - DisplayPortIn.Port = Tx.DisplayPortInput; - HdmiIn.Port = Tx.HdmiInput; - DmOut.Port = Tx.DmOutput; - } - - public override bool CustomActivate() - { - // Link up all of these damned events to the various RoutingPorts via a helper handler - Tx.HdmiInput.InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn, a.EventId); - Tx.HdmiInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn, a.EventId); - - Tx.DisplayPortInput.InputStreamChange += (o, a) => FowardInputStreamChange(DisplayPortIn, a.EventId); - Tx.DisplayPortInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(DisplayPortIn, a.EventId); - - Tx.VgaInput.InputStreamChange += (o, a) => FowardInputStreamChange(VgaIn, a.EventId); - Tx.VgaInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(VgaIn, a.EventId); - - // Base does register and sets up comm monitoring. - return base.CustomActivate(); - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); - - if (HdmiVideoSyncFeedback != null) - { - HdmiVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); - } - if (VgaVideoSyncFeedback != null) - { - VgaVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); - } - - LinkDmTxToApi(this, trilist, joinMap, bridge); - } - - public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) - { - Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); - - switch (input) - { - case 0: - { - ExecuteSwitch(eVst.Auto, null, type); - break; - } - case 1: - { - ExecuteSwitch(DisplayPortIn.Selector, null, type); - break; - } - case 2: - { - ExecuteSwitch(HdmiIn.Selector, null, type); - break; - } - case 3: - { - ExecuteSwitch(VgaIn.Selector, null, type); - break; - } - case 4: - { - ExecuteSwitch(CompositeIn.Selector, null, type); - break; - } - case 5: - { - ExecuteSwitch(eVst.Disabled, null, type); - break; - } - } - - } - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - if ((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video) - Tx.VideoSource = (eVst)inputSelector; - if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) - Tx.AudioSource = (eVst)inputSelector; - } - - void Tx_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) - { - - var localVideoInputPort = - InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); - var localAudioInputPort = - InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.AudioSourceFeedback); - - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localAudioInputPort, eRoutingSignalType.Audio)); - - } - - void Tx_BaseEvent(GenericBase device, BaseEventArgs args) - { - var id = args.EventId; - Debug.Console(2, this, "EventId {0}", args.EventId); - - switch (id) - { - case EndpointTransmitterBase.VideoSourceFeedbackEventId: - var localVideoInputPort = InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); - Debug.Console(2, this, " Video Source: {0}", Tx.VideoSourceFeedback); - VideoSourceNumericFeedback.FireUpdate(); - ActiveVideoInputFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - break; - case EndpointTransmitterBase.AudioSourceFeedbackEventId: - var localInputAudioPort = InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.AudioSourceFeedback); - Debug.Console(2, this, " Audio Source: {0}", Tx.AudioSourceFeedback); - AudioSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio)); - break; - } - } - - void VideoControls_ControlChange(object sender, GenericEventArgs args) - { - var id = args.EventId; - Debug.Console(2, this, "EventId {0}", args.EventId); - - switch (id) - { - case VideoControlsEventIds.BrightnessFeedbackEventId: - VgaBrightnessFeedback.FireUpdate(); - break; - case VideoControlsEventIds.ContrastFeedbackEventId: - VgaContrastFeedback.FireUpdate(); - break; - } - } - - /// - /// Enables or disables free run - /// - /// - public void SetFreeRunEnabled(bool enable) - { - Tx.VgaInput.FreeRun = enable ? eDmFreeRunSetting.Enabled : eDmFreeRunSetting.Disabled; - } - - /// - /// Sets the VGA brightness level - /// - /// - public void SetVgaBrightness(ushort level) - { - Tx.VgaInput.VideoControls.Brightness.UShortValue = level; - } - - /// - /// Sets the VGA contrast level - /// - /// - public void SetVgaContrast(ushort level) - { - Tx.VgaInput.VideoControls.Contrast.UShortValue = level; - } - - /// - /// Relays the input stream change to the appropriate RoutingInputPort. - /// - void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) - { - return; - } - inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); - } - - /// - /// Relays the VideoAttributes change to a RoutingInputPort - /// - void ForwardVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds - //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", - // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); - switch (eventId) - { - case VideoAttributeEventIds.HdcpActiveFeedbackEventId: - inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HdcpStateFeedbackEventId: - inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: - case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - } - } - - void HdmiInputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - Debug.Console(2, "{0} event {1} stream {2}", Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); - - switch (args.EventId) - { - case EndpointInputStreamEventIds.HdcpSupportOffFeedbackEventId: - HdmiInHdcpCapabilityFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.HdcpSupportOnFeedbackEventId: - HdmiInHdcpCapabilityFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - HdmiVideoSyncFeedback.FireUpdate(); - break; - } - } - - void DisplayPortInputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - Debug.Console(2, "{0} event {1} stream {2}", Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); - - switch (args.EventId) - { - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - DisplayPortVideoSyncFeedback.FireUpdate(); - break; - } - } - - private void VgaInputOnInputStreamChange(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - switch (args.EventId) - { - case EndpointInputStreamEventIds.FreeRunFeedbackEventId: - FreeRunEnabledFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - VgaVideoSyncFeedback.FireUpdate(); - break; - } - } - - - - #region IIROutputPorts Members - public CrestronCollection IROutputPorts { get { return Tx.IROutputPorts; } } - public int NumberOfIROutputPorts { get { return Tx.NumberOfIROutputPorts; } } - #endregion - - #region IComPorts Members - public CrestronCollection ComPorts { get { return Tx.ComPorts; } } - public int NumberOfComPorts { get { return Tx.NumberOfComPorts; } } - #endregion - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx4k100Controller.cs b/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx4k100Controller.cs deleted file mode 100644 index d628110d..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx4k100Controller.cs +++ /dev/null @@ -1,112 +0,0 @@ -extern alias Full; - -using Crestron.SimplSharpPro; -//using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using Full.Newtonsoft.Json; - -namespace PepperDash.Essentials.DM -{ - using eVst = eX02VideoSourceType; - using eAst = eX02AudioSourceType; - - public class DmTx4k100Controller : BasicDmTxControllerBase, IRoutingInputsOutputs, - IIROutputPorts, IComPorts, ICec - { - public DmTx4K100C1G Tx { get; private set; } - - public RoutingInputPort HdmiIn { get; private set; } - public RoutingOutputPort DmOut { get; private set; } - - /// - /// Helps get the "real" inputs, including when in Auto - /// - public eX02VideoSourceType ActualActiveVideoInput - { - get - { - return eVst.Hdmi1; - } - } - public RoutingPortCollection InputPorts - { - get - { - return new RoutingPortCollection - { - HdmiIn - }; - } - } - public RoutingPortCollection OutputPorts - { - get - { - return new RoutingPortCollection { DmOut }; - } - } - public DmTx4k100Controller(string key, string name, DmTx4K100C1G tx) - : base(key, name, tx) - { - Tx = tx; - - HdmiIn = new RoutingInputPort(DmPortName.HdmiIn1, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi1, this); - - DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmCat, null, this); - - // Set Ports for CEC - HdmiIn.Port = Tx; - - PreventRegistration = true; - - var parentDev = DeviceManager.GetDeviceForKey(key); - var num = tx.DMInputOutput.Number; - if (parentDev is DmpsRoutingController) - { - var dmps = parentDev as DmpsRoutingController; - IsOnline.SetValueFunc(() => dmps.InputEndpointOnlineFeedbacks[num].BoolValue); - dmps.InputEndpointOnlineFeedbacks[num].OutputChange += (o, a) => IsOnline.FireUpdate(); - } - else if (parentDev is DmChassisController) - { - var controller = parentDev as DmChassisController; - IsOnline.SetValueFunc(() => controller.InputEndpointOnlineFeedbacks[num].BoolValue); - controller.InputEndpointOnlineFeedbacks[num].OutputChange += (o, a) => IsOnline.FireUpdate(); - } - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new HDBaseTTxControllerJoinMap(joinStart); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - this.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - trilist.StringInput[joinMap.Name.JoinNumber].StringValue = this.Name; - } - - #region IIROutputPorts Members - public CrestronCollection IROutputPorts { get { return Tx.IROutputPorts; } } - public int NumberOfIROutputPorts { get { return Tx.NumberOfIROutputPorts; } } - #endregion - - #region IComPorts Members - public CrestronCollection ComPorts { get { return Tx.ComPorts; } } - public int NumberOfComPorts { get { return Tx.NumberOfComPorts; } } - #endregion - - #region ICec Members - public Cec StreamCec { get { return Tx.StreamCec; } } - #endregion - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx4k202CController.cs b/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx4k202CController.cs deleted file mode 100644 index e39816d1..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx4k202CController.cs +++ /dev/null @@ -1,422 +0,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.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.DM.Config; - -namespace PepperDash.Essentials.DM -{ - using eVst = Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType; - using eAst = Crestron.SimplSharpPro.DeviceSupport.eX02AudioSourceType; - - [Description("Wrapper class for DM-TX-4K-202-C")] - public class DmTx4k202CController : DmTxControllerBase, ITxRoutingWithFeedback, IHasFeedback, - IIROutputPorts, IComPorts - { - public DmTx4k202C Tx { get; private set; } - - public RoutingInputPortWithVideoStatuses HdmiIn1 { get; private set; } - public RoutingInputPortWithVideoStatuses HdmiIn2 { get; private set; } - public RoutingOutputPort DmOut { get; private set; } - public RoutingOutputPort HdmiLoopOut { get; private set; } - - public override StringFeedback ActiveVideoInputFeedback { get; protected set; } - public IntFeedback VideoSourceNumericFeedback { get; protected set; } - public IntFeedback AudioSourceNumericFeedback { get; protected set; } - public IntFeedback HdmiIn1HdcpCapabilityFeedback { get; protected set; } - public IntFeedback HdmiIn2HdcpCapabilityFeedback { get; protected set; } - public BoolFeedback Hdmi1VideoSyncFeedback { get; protected set; } - public BoolFeedback Hdmi2VideoSyncFeedback { get; protected set; } - - //IroutingNumericEvent - public event EventHandler NumericSwitchChange; - - /// - /// Raise an event when the status of a switch object changes. - /// - /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType - private void OnSwitchChange(RoutingNumericEventArgs e) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, e); - } - - - //public override IntFeedback HdcpSupportAllFeedback { get; protected set; } - //public override ushort HdcpSupportCapability { get; protected set; } - - /// - /// Helps get the "real" inputs, including when in Auto - /// - public Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType ActualActiveVideoInput - { - get - { - if (Tx.VideoSourceFeedback != eVst.Auto) - return Tx.VideoSourceFeedback; - else // auto - { - if (Tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) - return eVst.Hdmi1; - else if (Tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) - return eVst.Hdmi2; - else - return eVst.AllDisabled; - } - } - } - public RoutingPortCollection InputPorts - { - get - { - return new RoutingPortCollection - { - HdmiIn1, - HdmiIn2, - AnyVideoInput - }; - } - } - public RoutingPortCollection OutputPorts - { - get - { - return new RoutingPortCollection { DmOut, HdmiLoopOut }; - } - } - - public DmTx4k202CController(string key, string name, DmTx4k202C tx, bool preventRegistration) - : base(key, name, tx) - { - Tx = tx; - PreventRegistration = preventRegistration; - - HdmiIn1 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn1, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi1, this, - VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[1])) - { - FeedbackMatchObject = eVst.Hdmi1 - }; - HdmiIn2 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn2, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi2, this, - VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[2])) - { - FeedbackMatchObject = eVst.Hdmi2 - }; - - ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", - () => ActualActiveVideoInput.ToString()); - - - - Tx.HdmiInputs[1].InputStreamChange += InputStreamChangeEvent; - Tx.HdmiInputs[2].InputStreamChange += InputStreamChangeEvent; - - Tx.BaseEvent += Tx_BaseEvent; - - Tx.OnlineStatusChange += Tx_OnlineStatusChange; - - VideoSourceNumericFeedback = new IntFeedback(() => (int) Tx.VideoSourceFeedback); - - AudioSourceNumericFeedback = new IntFeedback(() => (int) Tx.AudioSourceFeedback); - - HdmiIn1HdcpCapabilityFeedback = new IntFeedback("HdmiIn1HdcpCapability", - () => (int) tx.HdmiInputs[1].HdcpCapabilityFeedback); - - HdmiIn2HdcpCapabilityFeedback = new IntFeedback("HdmiIn2HdcpCapability", - () => (int) tx.HdmiInputs[2].HdcpCapabilityFeedback); - - HdcpStateFeedback = - new IntFeedback( - () => - tx.HdmiInputs[1].HdcpCapabilityFeedback > tx.HdmiInputs[2].HdcpCapabilityFeedback - ? (int) tx.HdmiInputs[1].HdcpCapabilityFeedback - : (int) tx.HdmiInputs[2].HdcpCapabilityFeedback); - - HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support; - - Hdmi1VideoSyncFeedback = new BoolFeedback(() => (bool) tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue); - - Hdmi2VideoSyncFeedback = new BoolFeedback(() => (bool) tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue); - - var combinedFuncs = new VideoStatusFuncsWrapper - { - HdcpActiveFeedbackFunc = () => - (ActualActiveVideoInput == eVst.Hdmi1 - && tx.HdmiInputs[1].VideoAttributes.HdcpActiveFeedback.BoolValue) - || (ActualActiveVideoInput == eVst.Hdmi2 - && tx.HdmiInputs[2].VideoAttributes.HdcpActiveFeedback.BoolValue), - - HdcpStateFeedbackFunc = () => - { - if (ActualActiveVideoInput == eVst.Hdmi1) - return tx.HdmiInputs[1].VideoAttributes.HdcpStateFeedback.ToString(); - if (ActualActiveVideoInput == eVst.Hdmi2) - return tx.HdmiInputs[2].VideoAttributes.HdcpStateFeedback.ToString(); - return ""; - }, - - VideoResolutionFeedbackFunc = () => - { - if (ActualActiveVideoInput == eVst.Hdmi1) - return tx.HdmiInputs[1].VideoAttributes.GetVideoResolutionString(); - if (ActualActiveVideoInput == eVst.Hdmi2) - return tx.HdmiInputs[2].VideoAttributes.GetVideoResolutionString(); - return ""; - }, - VideoSyncFeedbackFunc = () => - (ActualActiveVideoInput == eVst.Hdmi1 - && tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == eVst.Hdmi2 - && tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) - - }; - - AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, - combinedFuncs); - - DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmCat, null, this); - HdmiLoopOut = new RoutingOutputPort(DmPortName.HdmiLoopOut, - eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, null, this); - - - AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, - AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, - AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, - AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiIn1HdcpCapabilityFeedback, - HdmiIn2HdcpCapabilityFeedback, - Hdmi1VideoSyncFeedback, Hdmi2VideoSyncFeedback); - - // Set Ports for CEC - HdmiIn1.Port = Tx.HdmiInputs[1]; - HdmiIn2.Port = Tx.HdmiInputs[2]; - HdmiLoopOut.Port = Tx.HdmiOutput; - DmOut.Port = Tx.DmOutput; - } - - - - public override bool CustomActivate() - { - // Link up all of these damned events to the various RoutingPorts via a helper handler - Tx.HdmiInputs[1].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn1, a.EventId); - Tx.HdmiInputs[1].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn1, a.EventId); - - Tx.HdmiInputs[2].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn2, a.EventId); - Tx.HdmiInputs[2].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn2, a.EventId); - - // Base does register and sets up comm monitoring. - return base.CustomActivate(); - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); - - if (Hdmi1VideoSyncFeedback != null) - { - Hdmi1VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); - } - if (Hdmi2VideoSyncFeedback != null) - { - Hdmi2VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); - } - - LinkDmTxToApi(this, trilist, joinMap, bridge); - } - - public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) - { - Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); - - switch (type) - { - case eRoutingSignalType.Video: - switch (input) - { - case 0: - { - ExecuteSwitch(eVst.Auto, null, type); - break; - } - case 1: - { - ExecuteSwitch(HdmiIn1.Selector, null, type); - break; - } - case 2: - { - ExecuteSwitch(HdmiIn2.Selector, null, type); - break; - } - case 3: - { - ExecuteSwitch(eVst.AllDisabled, null, type); - break; - } - } - break; - case eRoutingSignalType.Audio: - switch (input) - { - case 0: - { - ExecuteSwitch(eAst.Auto, null, type); - break; - } - case 1: - { - ExecuteSwitch(eAst.Hdmi1, null, type); - break; - } - case 2: - { - ExecuteSwitch(eAst.Hdmi2, null, type); - break; - } - case 3: - { - ExecuteSwitch(eAst.AllDisabled, null, type); - break; - } - } - break; - } - } - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - if ((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video) - Tx.VideoSource = (eVst)inputSelector; - if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) - Tx.AudioSource = (eAst)inputSelector; - } - - void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - Debug.Console(2, "{0} event {1} stream {2}", this.Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); - - switch (args.EventId) - { - case EndpointInputStreamEventIds.HdcpSupportOffFeedbackEventId: - case EndpointInputStreamEventIds.HdcpSupportOnFeedbackEventId: - case EndpointInputStreamEventIds.HdcpCapabilityFeedbackEventId: - if (inputStream == Tx.HdmiInputs[1]) HdmiIn1HdcpCapabilityFeedback.FireUpdate(); - if (inputStream == Tx.HdmiInputs[2]) HdmiIn2HdcpCapabilityFeedback.FireUpdate(); - HdcpStateFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - if (inputStream == Tx.HdmiInputs[1]) Hdmi1VideoSyncFeedback.FireUpdate(); - if (inputStream == Tx.HdmiInputs[2]) Hdmi2VideoSyncFeedback.FireUpdate(); - break; - } - } - - void Tx_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) - { - var localVideoInputPort = - InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); - var localAudioInputPort = - InputPorts.FirstOrDefault(p => (eAst)p.Selector == Tx.AudioSourceFeedback); - - ActiveVideoInputFeedback.FireUpdate(); - VideoSourceNumericFeedback.FireUpdate(); - AudioSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localAudioInputPort, eRoutingSignalType.Audio)); - } - - void Tx_BaseEvent(GenericBase device, BaseEventArgs args) - { - var id = args.EventId; - Debug.Console(2, this, "EventId {0}", args.EventId); - - switch (id) - { - case EndpointTransmitterBase.VideoSourceFeedbackEventId: - var localVideoInputPort = InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); - Debug.Console(2, this, " Video Source: {0}", Tx.VideoSourceFeedback); - VideoSourceNumericFeedback.FireUpdate(); - ActiveVideoInputFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - break; - case EndpointTransmitterBase.AudioSourceFeedbackEventId: - var localInputAudioPort = InputPorts.FirstOrDefault(p => (eAst)p.Selector == Tx.AudioSourceFeedback); - Debug.Console(2, this, " Audio Source: {0}", Tx.AudioSourceFeedback); - AudioSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio)); - break; - } - } - - /// - /// Relays the input stream change to the appropriate RoutingInputPort. - /// - void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) - { - return; - } - inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); - } - - /// - /// Relays the VideoAttributes change to a RoutingInputPort - /// - void ForwardVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds - //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", - // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); - switch (eventId) - { - case VideoAttributeEventIds.HdcpActiveFeedbackEventId: - inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HdcpStateFeedbackEventId: - inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: - case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - } - } - - - - - #region IIROutputPorts Members - public CrestronCollection IROutputPorts { get { return Tx.IROutputPorts; } } - public int NumberOfIROutputPorts { get { return Tx.NumberOfIROutputPorts; } } - #endregion - - #region IComPorts Members - public CrestronCollection ComPorts { get { return Tx.ComPorts; } } - public int NumberOfComPorts { get { return Tx.NumberOfComPorts; } } - #endregion - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx4k302CController.cs b/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx4k302CController.cs deleted file mode 100644 index f8bbeb10..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx4k302CController.cs +++ /dev/null @@ -1,506 +0,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.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.DM.Config; - -namespace PepperDash.Essentials.DM -{ - using eVst = Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType; - using eAst = Crestron.SimplSharpPro.DeviceSupport.eX02AudioSourceType; - - [Description("Wrapper class for DM-TX-4K-302-C")] - public class DmTx4k302CController : DmTxControllerBase, ITxRoutingWithFeedback, IHasFeedback, - IIROutputPorts, IComPorts, IHasFreeRun, IVgaBrightnessContrastControls - { - public DmTx4k302C Tx { get; private set; } - - public RoutingInputPortWithVideoStatuses HdmiIn1 { get; private set; } - public RoutingInputPortWithVideoStatuses HdmiIn2 { get; private set; } - public RoutingInputPortWithVideoStatuses VgaIn { get; private set; } - public RoutingOutputPort DmOut { get; private set; } - public RoutingOutputPort HdmiLoopOut { get; private set; } - - public override StringFeedback ActiveVideoInputFeedback { get; protected set; } - public IntFeedback VideoSourceNumericFeedback { get; protected set; } - public IntFeedback AudioSourceNumericFeedback { get; protected set; } - public IntFeedback HdmiIn1HdcpCapabilityFeedback { get; protected set; } - public IntFeedback HdmiIn2HdcpCapabilityFeedback { get; protected set; } - public BoolFeedback Hdmi1VideoSyncFeedback { get; protected set; } - public BoolFeedback Hdmi2VideoSyncFeedback { get; protected set; } - public BoolFeedback VgaVideoSyncFeedback { get; protected set; } - - public BoolFeedback FreeRunEnabledFeedback { get; protected set; } - - public IntFeedback VgaBrightnessFeedback { get; protected set; } - public IntFeedback VgaContrastFeedback { get; protected set; } - - //IroutingNumericEvent - public event EventHandler NumericSwitchChange; - - /// - /// Raise an event when the status of a switch object changes. - /// - /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType - private void OnSwitchChange(RoutingNumericEventArgs e) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, e); - } - - - /// - /// Helps get the "real" inputs, including when in Auto - /// - public Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType ActualActiveVideoInput - { - get - { - if (Tx.VideoSourceFeedback != eVst.Auto) - return Tx.VideoSourceFeedback; - else // auto - { - if (Tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) - return eVst.Hdmi1; - else if (Tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) - return eVst.Hdmi2; - else if (Tx.VgaInput.SyncDetectedFeedback.BoolValue) - return eVst.Vga; - else - return eVst.AllDisabled; - } - } - } - public RoutingPortCollection InputPorts - { - get - { - return new RoutingPortCollection - { - HdmiIn1, - HdmiIn2, - VgaIn, - AnyVideoInput - }; - } - } - public RoutingPortCollection OutputPorts - { - get - { - return new RoutingPortCollection { DmOut, HdmiLoopOut }; - } - } - public DmTx4k302CController(string key, string name, DmTx4k302C tx, bool preventRegistration) - : base(key, name, tx) - { - Tx = tx; - PreventRegistration = preventRegistration; - - HdmiIn1 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn1, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi1, this, - VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[1])) - { - FeedbackMatchObject = eVst.Hdmi1 - }; - HdmiIn2 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn2, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi2, this, - VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[2])) - { - FeedbackMatchObject = eVst.Hdmi2 - }; - - VgaIn = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn, - eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, eVst.Vga, this, - VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput)) - { - FeedbackMatchObject = eVst.Vga - }; - - ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", - () => ActualActiveVideoInput.ToString()); - - Tx.HdmiInputs[1].InputStreamChange += InputStreamChangeEvent; - Tx.HdmiInputs[2].InputStreamChange += InputStreamChangeEvent; - Tx.VgaInput.InputStreamChange += VgaInputOnInputStreamChange; - Tx.BaseEvent += Tx_BaseEvent; - - Tx.OnlineStatusChange += Tx_OnlineStatusChange; - - VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); - AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.AudioSourceFeedback); - - HdmiIn1HdcpCapabilityFeedback = new IntFeedback("HdmiIn1HdcpCapability", () => (int)tx.HdmiInputs[1].HdcpCapabilityFeedback); - - HdmiIn2HdcpCapabilityFeedback = new IntFeedback("HdmiIn2HdcpCapability", () => (int)tx.HdmiInputs[2].HdcpCapabilityFeedback); - - HdcpStateFeedback = - new IntFeedback( - () => - tx.HdmiInputs[1].HdcpCapabilityFeedback > tx.HdmiInputs[2].HdcpCapabilityFeedback - ? (int)tx.HdmiInputs[1].HdcpCapabilityFeedback - : (int)tx.HdmiInputs[2].HdcpCapabilityFeedback); - - HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support; - - Hdmi1VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue); - - Hdmi2VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue); - - VgaVideoSyncFeedback = new BoolFeedback(() => (bool)tx.VgaInput.SyncDetectedFeedback.BoolValue); - - FreeRunEnabledFeedback = new BoolFeedback(() => tx.VgaInput.FreeRunFeedback == eDmFreeRunSetting.Enabled); - - VgaBrightnessFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.BrightnessFeedback.UShortValue); - VgaContrastFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.ContrastFeedback.UShortValue); - - tx.VgaInput.VideoControls.ControlChange += new Crestron.SimplSharpPro.DeviceSupport.GenericEventHandler(VideoControls_ControlChange); - - - var combinedFuncs = new VideoStatusFuncsWrapper - { - HdcpActiveFeedbackFunc = () => - (ActualActiveVideoInput == eVst.Hdmi1 - && tx.HdmiInputs[1].VideoAttributes.HdcpActiveFeedback.BoolValue) - || (ActualActiveVideoInput == eVst.Hdmi2 - && tx.HdmiInputs[2].VideoAttributes.HdcpActiveFeedback.BoolValue), - - HdcpStateFeedbackFunc = () => - { - if (ActualActiveVideoInput == eVst.Hdmi1) - return tx.HdmiInputs[1].VideoAttributes.HdcpStateFeedback.ToString(); - return ActualActiveVideoInput == eVst.Hdmi2 ? tx.HdmiInputs[2].VideoAttributes.HdcpStateFeedback.ToString() : ""; - }, - - VideoResolutionFeedbackFunc = () => - { - if (ActualActiveVideoInput == eVst.Hdmi1) - return tx.HdmiInputs[1].VideoAttributes.GetVideoResolutionString(); - if (ActualActiveVideoInput == eVst.Hdmi2) - return tx.HdmiInputs[2].VideoAttributes.GetVideoResolutionString(); - return ActualActiveVideoInput == eVst.Vga ? tx.VgaInput.VideoAttributes.GetVideoResolutionString() : ""; - }, - VideoSyncFeedbackFunc = () => - (ActualActiveVideoInput == eVst.Hdmi1 - && tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == eVst.Hdmi2 - && tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == eVst.Vga - && tx.VgaInput.SyncDetectedFeedback.BoolValue) - - }; - - AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs); - - DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmCat, null, this); - HdmiLoopOut = new RoutingOutputPort(DmPortName.HdmiLoopOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, null, this); - - - AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, - AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, - AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, - AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiIn1HdcpCapabilityFeedback, HdmiIn2HdcpCapabilityFeedback, - Hdmi1VideoSyncFeedback, Hdmi2VideoSyncFeedback, VgaVideoSyncFeedback); - - // Set Ports for CEC - HdmiIn1.Port = Tx.HdmiInputs[1]; - HdmiIn2.Port = Tx.HdmiInputs[2]; - HdmiLoopOut.Port = Tx.HdmiOutput; - DmOut.Port = Tx.DmOutput; - } - - void VgaInputOnInputStreamChange(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - switch (args.EventId) - { - case EndpointInputStreamEventIds.FreeRunFeedbackEventId: - FreeRunEnabledFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - VgaVideoSyncFeedback.FireUpdate(); - break; - } - } - - void VideoControls_ControlChange(object sender, Crestron.SimplSharpPro.DeviceSupport.GenericEventArgs args) - { - var id = args.EventId; - Debug.Console(2, this, "EventId {0}", args.EventId); - - switch (id) - { - case VideoControlsEventIds.BrightnessFeedbackEventId: - VgaBrightnessFeedback.FireUpdate(); - break; - case VideoControlsEventIds.ContrastFeedbackEventId: - VgaContrastFeedback.FireUpdate(); - break; - } - } - - - - public override bool CustomActivate() - { - // Link up all of these damned events to the various RoutingPorts via a helper handler - Tx.HdmiInputs[1].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn1, a.EventId); - Tx.HdmiInputs[1].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn1, a.EventId); - - Tx.HdmiInputs[2].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn2, a.EventId); - Tx.HdmiInputs[2].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn2, a.EventId); - - Tx.VgaInput.InputStreamChange += (o, a) => FowardInputStreamChange(VgaIn, a.EventId); - Tx.VgaInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(VgaIn, a.EventId); - - // Base does register and sets up comm monitoring. - return base.CustomActivate(); - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); - - if (Hdmi1VideoSyncFeedback != null) - { - Hdmi1VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); - } - if (Hdmi2VideoSyncFeedback != null) - { - Hdmi2VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); - } - if (VgaVideoSyncFeedback != null) - { - VgaVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input3VideoSyncStatus.JoinNumber]); - } - - LinkDmTxToApi(this, trilist, joinMap, bridge); - } - - /// - /// Enables or disables free run - /// - /// - public void SetFreeRunEnabled(bool enable) - { - Tx.VgaInput.FreeRun = enable ? eDmFreeRunSetting.Enabled : eDmFreeRunSetting.Disabled; - } - - /// - /// Sets the VGA brightness level - /// - /// - public void SetVgaBrightness(ushort level) - { - Tx.VgaInput.VideoControls.Brightness.UShortValue = level; - } - - /// - /// Sets the VGA contrast level - /// - /// - public void SetVgaContrast(ushort level) - { - Tx.VgaInput.VideoControls.Contrast.UShortValue = level; - } - - - - public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) - { - Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); - - switch (type) - { - case eRoutingSignalType.Video: - switch (input) - { - case 0: - { - ExecuteSwitch(eVst.Auto, null, type); - break; - } - case 1: - { - ExecuteSwitch(HdmiIn1.Selector, null, type); - break; - } - case 2: - { - ExecuteSwitch(HdmiIn2.Selector, null, type); - break; - } - case 3: - { - ExecuteSwitch(VgaIn.Selector, null, type); - break; - } - case 4: - { - ExecuteSwitch(eVst.AllDisabled, null, type); - break; - } - } - break; - case eRoutingSignalType.Audio: - switch (input) - { - case 0: - { - ExecuteSwitch(eAst.Auto, null, type); - break; - } - case 1: - { - ExecuteSwitch(eAst.Hdmi1, null, type); - break; - } - case 2: - { - ExecuteSwitch(eAst.Hdmi2, null, type); - break; - } - case 3: - { - ExecuteSwitch(eAst.AudioIn, null, type); - break; - } - case 4: - { - ExecuteSwitch(eAst.AllDisabled, null, type); - break; - } - } - break; - } - } - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - if ((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video) - Tx.VideoSource = (eVst)inputSelector; - if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) - Tx.AudioSource = (eAst)inputSelector; - } - - void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - Debug.Console(2, "{0} event {1} stream {2}", this.Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); - - switch (args.EventId) - { - case EndpointInputStreamEventIds.HdcpSupportOffFeedbackEventId: - case EndpointInputStreamEventIds.HdcpSupportOnFeedbackEventId: - case EndpointInputStreamEventIds.HdcpCapabilityFeedbackEventId: - if (inputStream == Tx.HdmiInputs[1]) HdmiIn1HdcpCapabilityFeedback.FireUpdate(); - if (inputStream == Tx.HdmiInputs[2]) HdmiIn2HdcpCapabilityFeedback.FireUpdate(); - HdcpStateFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - if (inputStream == Tx.HdmiInputs[1]) Hdmi1VideoSyncFeedback.FireUpdate(); - if (inputStream == Tx.HdmiInputs[2]) Hdmi2VideoSyncFeedback.FireUpdate(); - break; - } - } - void Tx_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) - { - var localVideoInputPort = - InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); - var localAudioInputPort = - InputPorts.FirstOrDefault(p => (eAst)p.Selector == Tx.AudioSourceFeedback); - - ActiveVideoInputFeedback.FireUpdate(); - VideoSourceNumericFeedback.FireUpdate(); - AudioSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localAudioInputPort, eRoutingSignalType.Audio)); - } - - void Tx_BaseEvent(GenericBase device, BaseEventArgs args) - { - var id = args.EventId; - Debug.Console(2, this, "EventId {0}", args.EventId); - - switch (id) - { - case EndpointTransmitterBase.VideoSourceFeedbackEventId: - var localVideoInputPort = InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); - Debug.Console(2, this, " Video Source: {0}", Tx.VideoSourceFeedback); - VideoSourceNumericFeedback.FireUpdate(); - ActiveVideoInputFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - break; - case EndpointTransmitterBase.AudioSourceFeedbackEventId: - var localInputAudioPort = InputPorts.FirstOrDefault(p => (eAst)p.Selector == Tx.AudioSourceFeedback); - Debug.Console(2, this, " Audio Source: {0}", Tx.AudioSourceFeedback); - AudioSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio)); - break; - } - } - - /// - /// Relays the input stream change to the appropriate RoutingInputPort. - /// - void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) return; - inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); - } - - /// - /// Relays the VideoAttributes change to a RoutingInputPort - /// - void ForwardVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds - //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", - // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); - switch (eventId) - { - case VideoAttributeEventIds.HdcpActiveFeedbackEventId: - inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HdcpStateFeedbackEventId: - inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: - case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - } - } - - - #region IIROutputPorts Members - public CrestronCollection IROutputPorts { get { return Tx.IROutputPorts; } } - public int NumberOfIROutputPorts { get { return Tx.NumberOfIROutputPorts; } } - #endregion - - #region IComPorts Members - public CrestronCollection ComPorts { get { return Tx.ComPorts; } } - public int NumberOfComPorts { get { return Tx.NumberOfComPorts; } } - #endregion - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx4kz100Controller.cs b/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx4kz100Controller.cs deleted file mode 100644 index 2778082d..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx4kz100Controller.cs +++ /dev/null @@ -1,96 +0,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 PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.DM.Config; - -namespace PepperDash.Essentials.DM -{ - // using eVst = Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType; - - /// - /// Controller class for all DM-TX-201C/S/F transmitters - /// - [Description("Wrapper class for DM-TX-4K-Z-100-C")] - public class DmTx4kz100Controller : BasicDmTxControllerBase, IRoutingInputsOutputs, IHasFeedback, - IIROutputPorts, IComPorts, ICec - { - public DmTx4kz100C1G Tx { get; private set; } - - public RoutingInputPort HdmiIn { get; private set; } - public RoutingOutputPort DmOut { get; private set; } - - /// - /// Helps get the "real" inputs, including when in Auto - /// - public eX02VideoSourceType ActualActiveVideoInput - { - get - { - return eX02VideoSourceType.Hdmi1; - } - } - public RoutingPortCollection InputPorts - { - get - { - return new RoutingPortCollection - { - HdmiIn - }; - } - } - public RoutingPortCollection OutputPorts - { - get - { - return new RoutingPortCollection { DmOut }; - } - } - public DmTx4kz100Controller(string key, string name, DmTx4kz100C1G tx) - : base(key, name, tx) - { - Tx = tx; - - HdmiIn = new RoutingInputPort(DmPortName.HdmiIn1, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eX02VideoSourceType.Hdmi1, this); - - DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmCat, null, this); - - // Set Ports for CEC - HdmiIn.Port = Tx; - - PreventRegistration = true; - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - Debug.Console(1, this, "No properties to link. Skipping device {0}", Name); - } - - #region IIROutputPorts Members - public CrestronCollection IROutputPorts { get { return Tx.IROutputPorts; } } - public int NumberOfIROutputPorts { get { return Tx.NumberOfIROutputPorts; } } - #endregion - - #region IComPorts Members - public CrestronCollection ComPorts { get { return Tx.ComPorts; } } - public int NumberOfComPorts { get { return Tx.NumberOfComPorts; } } - #endregion - - #region ICec Members - public Cec StreamCec { get { return Tx.HdmiInput.StreamCec; } } - #endregion - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx4kz202CController.cs b/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx4kz202CController.cs deleted file mode 100644 index c9a6c7f9..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx4kz202CController.cs +++ /dev/null @@ -1,406 +0,0 @@ -using Crestron.SimplSharpPro; -using System; -using System.Linq; -//using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.DM -{ - using eVst = eX02VideoSourceType; - using eAst = eX02AudioSourceType; - - public class DmTx4kz202CController : DmTxControllerBase, ITxRoutingWithFeedback, - IIROutputPorts, IComPorts - { - public DmTx4kz202C Tx { get; private set; } - - public RoutingInputPortWithVideoStatuses HdmiIn1 { get; private set; } - public RoutingInputPortWithVideoStatuses HdmiIn2 { get; private set; } - public RoutingOutputPort DmOut { get; private set; } - public RoutingOutputPort HdmiLoopOut { get; private set; } - - public override StringFeedback ActiveVideoInputFeedback { get; protected set; } - public IntFeedback VideoSourceNumericFeedback { get; protected set; } - public IntFeedback AudioSourceNumericFeedback { get; protected set; } - public IntFeedback HdmiIn1HdcpCapabilityFeedback { get; protected set; } - public IntFeedback HdmiIn2HdcpCapabilityFeedback { get; protected set; } - public BoolFeedback Hdmi1VideoSyncFeedback { get; protected set; } - public BoolFeedback Hdmi2VideoSyncFeedback { get; protected set; } - - //public override IntFeedback HdcpSupportAllFeedback { get; protected set; } - //public override ushort HdcpSupportCapability { get; protected set; } - //IroutingNumericEvent - public event EventHandler NumericSwitchChange; - - /// - /// Raise an event when the status of a switch object changes. - /// - /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType - private void OnSwitchChange(RoutingNumericEventArgs e) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, e); - } - - - - /// - /// Helps get the "real" inputs, including when in Auto - /// - public eX02VideoSourceType ActualActiveVideoInput - { - get - { - if (Tx.VideoSourceFeedback != eVst.Auto) - return Tx.VideoSourceFeedback; - - if (Tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) - return eVst.Hdmi1; - - return Tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue ? eVst.Hdmi2 : eVst.AllDisabled; - } - } - public RoutingPortCollection InputPorts - { - get - { - return new RoutingPortCollection - { - HdmiIn1, - HdmiIn2, - AnyVideoInput - }; - } - } - public RoutingPortCollection OutputPorts - { - get - { - return new RoutingPortCollection { DmOut, HdmiLoopOut }; - } - } - public DmTx4kz202CController(string key, string name, DmTx4kz202C tx, bool preventRegistration) - : base(key, name, tx) - { - Tx = tx; - PreventRegistration = preventRegistration; - - HdmiIn1 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn1, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi1, this, - VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[1])) - { - FeedbackMatchObject = eVst.Hdmi1 - }; - HdmiIn2 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn2, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi2, this, - VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[2])) - { - FeedbackMatchObject = eVst.Hdmi2 - }; - - ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", - () => ActualActiveVideoInput.ToString()); - - - - Tx.HdmiInputs[1].InputStreamChange += InputStreamChangeEvent; - Tx.HdmiInputs[2].InputStreamChange += InputStreamChangeEvent; - Tx.BaseEvent += Tx_BaseEvent; - Tx.OnlineStatusChange += Tx_OnlineStatusChange; - - VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); - - //Return VideoSourceFeedback here as DM-TX-4KZ-202-C does not support audio breakaway - AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); - - HdmiIn1HdcpCapabilityFeedback = new IntFeedback("HdmiIn1HdcpCapability", () => (int)tx.HdmiInputs[1].HdcpCapabilityFeedback); - - HdmiIn2HdcpCapabilityFeedback = new IntFeedback("HdmiIn2HdcpCapability", () => (int)tx.HdmiInputs[2].HdcpCapabilityFeedback); - - HdcpStateFeedback = - new IntFeedback( - () => - tx.HdmiInputs[1].HdcpCapabilityFeedback > tx.HdmiInputs[2].HdcpCapabilityFeedback - ? (int)tx.HdmiInputs[1].HdcpCapabilityFeedback - : (int)tx.HdmiInputs[2].HdcpCapabilityFeedback); - - HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support; - - Hdmi1VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue); - - Hdmi2VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue); - - var combinedFuncs = new VideoStatusFuncsWrapper - { - HdcpActiveFeedbackFunc = () => - (ActualActiveVideoInput == eVst.Hdmi1 - && tx.HdmiInputs[1].VideoAttributes.HdcpActiveFeedback.BoolValue) - || (ActualActiveVideoInput == eVst.Hdmi2 - && tx.HdmiInputs[2].VideoAttributes.HdcpActiveFeedback.BoolValue), - - HdcpStateFeedbackFunc = () => - { - if (ActualActiveVideoInput == eVst.Hdmi1) - return tx.HdmiInputs[1].VideoAttributes.HdcpStateFeedback.ToString(); - if (ActualActiveVideoInput == eVst.Hdmi2) - return tx.HdmiInputs[2].VideoAttributes.HdcpStateFeedback.ToString(); - return ""; - }, - - VideoResolutionFeedbackFunc = () => - { - if (ActualActiveVideoInput == eVst.Hdmi1) - return tx.HdmiInputs[1].VideoAttributes.GetVideoResolutionString(); - if (ActualActiveVideoInput == eVst.Hdmi2) - return tx.HdmiInputs[2].VideoAttributes.GetVideoResolutionString(); - return ""; - }, - VideoSyncFeedbackFunc = () => - (ActualActiveVideoInput == eVst.Hdmi1 - && tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == eVst.Hdmi2 - && tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) - - }; - - AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs); - - DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmCat, null, this); - HdmiLoopOut = new RoutingOutputPort(DmPortName.HdmiLoopOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, null, this); - - - AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, - AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, - AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, - AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiIn1HdcpCapabilityFeedback, HdmiIn2HdcpCapabilityFeedback, - Hdmi1VideoSyncFeedback, Hdmi2VideoSyncFeedback); - - // Set Ports for CEC - HdmiIn1.Port = Tx.HdmiInputs[1]; - HdmiIn2.Port = Tx.HdmiInputs[2]; - HdmiLoopOut.Port = Tx.HdmiOutput; - DmOut.Port = Tx.DmOutput; - } - - - - public override bool CustomActivate() - { - // Link up all of these damned events to the various RoutingPorts via a helper handler - Tx.HdmiInputs[1].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn1, a.EventId); - Tx.HdmiInputs[1].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn1, a.EventId); - - Tx.HdmiInputs[2].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn2, a.EventId); - Tx.HdmiInputs[2].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn2, a.EventId); - - // Base does register and sets up comm monitoring. - return base.CustomActivate(); - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); - - if (Hdmi1VideoSyncFeedback != null) - { - Hdmi1VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); - } - if (Hdmi2VideoSyncFeedback != null) - { - Hdmi2VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); - } - - LinkDmTxToApi(this, trilist, joinMap, bridge); - } - - public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) - { - Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); - - switch (type) - { - case eRoutingSignalType.Video: - switch (input) - { - case 0: - { - ExecuteSwitch(eVst.Auto, null, type); - break; - } - case 1: - { - ExecuteSwitch(HdmiIn1.Selector, null, type); - break; - } - case 2: - { - ExecuteSwitch(HdmiIn2.Selector, null, type); - break; - } - case 3: - { - ExecuteSwitch(eVst.AllDisabled, null, type); - break; - } - } - break; - case eRoutingSignalType.Audio: - switch (input) - { - case 0: - { - ExecuteSwitch(eAst.Auto, null, type); - break; - } - case 1: - { - ExecuteSwitch(eAst.Hdmi1, null, type); - break; - } - case 2: - { - ExecuteSwitch(eAst.Hdmi2, null, type); - break; - } - case 3: - { - ExecuteSwitch(eAst.AllDisabled, null, type); - break; - } - } - break; - } - } - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - if ((signalType & eRoutingSignalType.Video) == eRoutingSignalType.Video) - Tx.VideoSource = (eVst)inputSelector; - if(((signalType & eRoutingSignalType.Audio) == eRoutingSignalType.Audio)) - Debug.Console(2, this, "Unable to execute audio-only switch for tx {0}", Key); - } - - void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - Debug.Console(2, "{0} event {1} stream {2}", Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); - - switch (args.EventId) - { - case EndpointInputStreamEventIds.HdcpSupportOffFeedbackEventId: - case EndpointInputStreamEventIds.HdcpSupportOnFeedbackEventId: - case EndpointInputStreamEventIds.HdcpCapabilityFeedbackEventId: - if (inputStream == Tx.HdmiInputs[1]) HdmiIn1HdcpCapabilityFeedback.FireUpdate(); - if (inputStream == Tx.HdmiInputs[2]) HdmiIn2HdcpCapabilityFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - if (inputStream == Tx.HdmiInputs[1]) Hdmi1VideoSyncFeedback.FireUpdate(); - if (inputStream == Tx.HdmiInputs[2]) Hdmi2VideoSyncFeedback.FireUpdate(); - break; - } - } - - void Tx_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) - { - var localVideoInputPort = - InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); - var localAudioInputPort = - InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); - - ActiveVideoInputFeedback.FireUpdate(); - VideoSourceNumericFeedback.FireUpdate(); - AudioSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localAudioInputPort, eRoutingSignalType.Audio)); - } - - - void Tx_BaseEvent(GenericBase device, BaseEventArgs args) - { - var id = args.EventId; - Debug.Console(2, this, "EventId {0}", args.EventId); - - switch (id) - { - case EndpointTransmitterBase.VideoSourceFeedbackEventId: - var localVideoInputPort = InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); - Debug.Console(2, this, " Video Source: {0}", Tx.VideoSourceFeedback); - VideoSourceNumericFeedback.FireUpdate(); - ActiveVideoInputFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - break; - case EndpointTransmitterBase.AudioSourceFeedbackEventId: - var localInputAudioPort = InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); - Debug.Console(2, this, " Audio Source: {0}", Tx.VideoSourceFeedback); - AudioSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio)); - break; - } - } - - /// - /// Relays the input stream change to the appropriate RoutingInputPort. - /// - void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) - { - return; - } - inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); - } - - /// - /// Relays the VideoAttributes change to a RoutingInputPort - /// - void ForwardVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds - //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", - // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); - switch (eventId) - { - case VideoAttributeEventIds.HdcpActiveFeedbackEventId: - inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HdcpStateFeedbackEventId: - inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: - case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - } - } - - - - - #region IIROutputPorts Members - public CrestronCollection IROutputPorts { get { return Tx.IROutputPorts; } } - public int NumberOfIROutputPorts { get { return Tx.NumberOfIROutputPorts; } } - #endregion - - #region IComPorts Members - public CrestronCollection ComPorts { get { return Tx.ComPorts; } } - public int NumberOfComPorts { get { return Tx.NumberOfComPorts; } } - #endregion - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx4kz302CController.cs b/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx4kz302CController.cs deleted file mode 100644 index 90976a10..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx4kz302CController.cs +++ /dev/null @@ -1,427 +0,0 @@ -using Crestron.SimplSharpPro; -using System; -using System.Linq; -//using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.DM -{ - using eVst = eX02VideoSourceType; - using eAst = eX02AudioSourceType; - - - [Description("Wrapper class for DM-TX-4K-Z-302-C")] - public class DmTx4kz302CController : DmTxControllerBase, ITxRoutingWithFeedback, IHasFeedback, - IIROutputPorts, IComPorts - { - public DmTx4kz302C Tx { get; private set; } - - public RoutingInputPortWithVideoStatuses HdmiIn1 { get; private set; } - public RoutingInputPortWithVideoStatuses HdmiIn2 { get; private set; } - public RoutingInputPortWithVideoStatuses DisplayPortIn { get; private set; } - public RoutingOutputPort DmOut { get; private set; } - public RoutingOutputPort HdmiLoopOut { get; private set; } - - public override StringFeedback ActiveVideoInputFeedback { get; protected set; } - public IntFeedback VideoSourceNumericFeedback { get; protected set; } - public IntFeedback AudioSourceNumericFeedback { get; protected set; } - public IntFeedback HdmiIn1HdcpCapabilityFeedback { get; protected set; } - public IntFeedback HdmiIn2HdcpCapabilityFeedback { get; protected set; } - public BoolFeedback Hdmi1VideoSyncFeedback { get; protected set; } - public BoolFeedback Hdmi2VideoSyncFeedback { get; protected set; } - public BoolFeedback DisplayPortVideoSyncFeedback { get; protected set; } - - //public override IntFeedback HdcpSupportAllFeedback { get; protected set; } - //public override ushort HdcpSupportCapability { get; protected set; } - - //IroutingNumericEvent - public event EventHandler NumericSwitchChange; - - /// - /// Raise an event when the status of a switch object changes. - /// - /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType - private void OnSwitchChange(RoutingNumericEventArgs e) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, e); - } - - /// - /// Helps get the "real" inputs, including when in Auto - /// - public eX02VideoSourceType ActualActiveVideoInput - { - get - { - if (Tx.VideoSourceFeedback != eVst.Auto) - return Tx.VideoSourceFeedback; - if (Tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) - return eVst.Hdmi1; - if (Tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) - return eVst.Hdmi2; - - return Tx.DisplayPortInput.SyncDetectedFeedback.BoolValue ? eVst.Vga : eVst.AllDisabled; - } - } - public RoutingPortCollection InputPorts - { - get - { - return new RoutingPortCollection - { - HdmiIn1, - HdmiIn2, - DisplayPortIn, - AnyVideoInput - }; - } - } - public RoutingPortCollection OutputPorts - { - get - { - return new RoutingPortCollection { DmOut, HdmiLoopOut }; - } - } - public DmTx4kz302CController(string key, string name, DmTx4kz302C tx, bool preventRegistration) - : base(key, name, tx) - { - Tx = tx; - PreventRegistration = preventRegistration; - - HdmiIn1 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn1, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi1, this, - VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[1])) - { - FeedbackMatchObject = eVst.Hdmi1 - }; - HdmiIn2 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn2, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi2, this, - VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[2])) - { - FeedbackMatchObject = eVst.Hdmi2 - }; - DisplayPortIn = new RoutingInputPortWithVideoStatuses(DmPortName.DisplayPortIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DisplayPort, eVst.DisplayPort, this, - VideoStatusHelper.GetDisplayPortInputStatusFuncs(tx.DisplayPortInput)) - { - FeedbackMatchObject = eVst.DisplayPort - }; - ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", - () => ActualActiveVideoInput.ToString()); - - Tx.HdmiInputs[1].InputStreamChange += InputStreamChangeEvent; - Tx.HdmiInputs[2].InputStreamChange += InputStreamChangeEvent; - Tx.DisplayPortInput.InputStreamChange += DisplayPortInputStreamChange; - Tx.BaseEvent += Tx_BaseEvent; - Tx.OnlineStatusChange += Tx_OnlineStatusChange; - - VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); - AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); - - HdmiIn1HdcpCapabilityFeedback = new IntFeedback("HdmiIn1HdcpCapability", () => (int)tx.HdmiInputs[1].HdcpCapabilityFeedback); - - HdmiIn2HdcpCapabilityFeedback = new IntFeedback("HdmiIn2HdcpCapability", () => (int)tx.HdmiInputs[2].HdcpCapabilityFeedback); - - HdcpStateFeedback = - new IntFeedback( - () => - tx.HdmiInputs[1].HdcpCapabilityFeedback > tx.HdmiInputs[2].HdcpCapabilityFeedback - ? (int)tx.HdmiInputs[1].HdcpCapabilityFeedback - : (int)tx.HdmiInputs[2].HdcpCapabilityFeedback); - - HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support; - - Hdmi1VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue); - - Hdmi2VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue); - - DisplayPortVideoSyncFeedback = new BoolFeedback(() => (bool)tx.DisplayPortInput.SyncDetectedFeedback.BoolValue); - - - var combinedFuncs = new VideoStatusFuncsWrapper - { - HdcpActiveFeedbackFunc = () => - (ActualActiveVideoInput == eVst.Hdmi1 - && tx.HdmiInputs[1].VideoAttributes.HdcpActiveFeedback.BoolValue) - || (ActualActiveVideoInput == eVst.Hdmi2 - && tx.HdmiInputs[2].VideoAttributes.HdcpActiveFeedback.BoolValue), - - HdcpStateFeedbackFunc = () => - { - if (ActualActiveVideoInput == eVst.Hdmi1) - return tx.HdmiInputs[1].VideoAttributes.HdcpStateFeedback.ToString(); - return ActualActiveVideoInput == eVst.Hdmi2 ? tx.HdmiInputs[2].VideoAttributes.HdcpStateFeedback.ToString() : ""; - }, - - VideoResolutionFeedbackFunc = () => - { - if (ActualActiveVideoInput == eVst.Hdmi1) - return tx.HdmiInputs[1].VideoAttributes.GetVideoResolutionString(); - if (ActualActiveVideoInput == eVst.Hdmi2) - return tx.HdmiInputs[2].VideoAttributes.GetVideoResolutionString(); - return ActualActiveVideoInput == eVst.Vga ? tx.DisplayPortInput.VideoAttributes.GetVideoResolutionString() : ""; - }, - VideoSyncFeedbackFunc = () => - (ActualActiveVideoInput == eVst.Hdmi1 - && tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == eVst.Hdmi2 - && tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == eVst.Vga - && tx.DisplayPortInput.SyncDetectedFeedback.BoolValue) - - }; - - AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs); - - DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmCat, null, this); - HdmiLoopOut = new RoutingOutputPort(DmPortName.HdmiLoopOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, null, this); - - - AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, - AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, - AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, - AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiIn1HdcpCapabilityFeedback, HdmiIn2HdcpCapabilityFeedback, - Hdmi1VideoSyncFeedback, Hdmi2VideoSyncFeedback, DisplayPortVideoSyncFeedback); - - // Set Ports for CEC - HdmiIn1.Port = Tx.HdmiInputs[1]; - HdmiIn2.Port = Tx.HdmiInputs[2]; - HdmiLoopOut.Port = Tx.HdmiOutput; - DmOut.Port = Tx.DmOutput; - } - - void DisplayPortInputStreamChange(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - Debug.Console(2, "{0} event {1} stream {2}", Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); - - switch (args.EventId) - { - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - DisplayPortVideoSyncFeedback.FireUpdate(); - break; - } - } - - - - public override bool CustomActivate() - { - // Link up all of these damned events to the various RoutingPorts via a helper handler - Tx.HdmiInputs[1].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn1, a.EventId); - Tx.HdmiInputs[1].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn1, a.EventId); - - Tx.HdmiInputs[2].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn2, a.EventId); - Tx.HdmiInputs[2].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn2, a.EventId); - - Tx.DisplayPortInput.InputStreamChange += (o, a) => FowardInputStreamChange(DisplayPortIn, a.EventId); - Tx.DisplayPortInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(DisplayPortIn, a.EventId); - - // Base does register and sets up comm monitoring. - return base.CustomActivate(); - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); - - if (Hdmi1VideoSyncFeedback != null) - { - Hdmi1VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); - } - if (Hdmi2VideoSyncFeedback != null) - { - Hdmi2VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); - } - if (DisplayPortVideoSyncFeedback != null) - { - DisplayPortVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input3VideoSyncStatus.JoinNumber]); - } - - LinkDmTxToApi(this, trilist, joinMap, bridge); - } - - public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) - { - Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); - - switch (input) - { - case 0: - { - ExecuteSwitch(eVst.Auto, null, type); - break; - } - case 1: - { - ExecuteSwitch(HdmiIn1.Selector, null, type); - break; - } - case 2: - { - ExecuteSwitch(HdmiIn2.Selector, null, type); - break; - } - case 3: - { - ExecuteSwitch(DisplayPortIn.Selector, null, type); - break; - } - case 4: - { - ExecuteSwitch(eVst.AllDisabled, null, type); - break; - } - default: - { - Debug.Console(2, this, "Unable to execute numeric switch to input {0}", input); - break; - } - - } - - - } - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - try - { - Debug.Console(2, this, "Attempting to switch InputSelector {0}", ((eVst)inputSelector).ToString()); - if ((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video) - Tx.VideoSource = (eVst)inputSelector; - - // NOTE: It's possible that this particular TX model may not like the AudioSource property being set. - // The SIMPL definition only shows a single analog for AudioVideo Source - if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) - //it doesn't - Debug.Console(2, this, "Unable to execute audio-only switch for tx {0}", Key); - //Tx.AudioSource = (eAst)inputSelector; - } - catch (Exception e) - { - Debug.Console(2, this, "Exception in ExecuteSwitch: {0}", e); - } - } - - void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - Debug.Console(2, "{0} event {1} stream {2}", Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); - - switch (args.EventId) - { - case EndpointInputStreamEventIds.HdcpSupportOffFeedbackEventId: - case EndpointInputStreamEventIds.HdcpSupportOnFeedbackEventId: - case EndpointInputStreamEventIds.HdcpCapabilityFeedbackEventId: - if (inputStream == Tx.HdmiInputs[1]) HdmiIn1HdcpCapabilityFeedback.FireUpdate(); - if (inputStream == Tx.HdmiInputs[2]) HdmiIn2HdcpCapabilityFeedback.FireUpdate(); - HdcpStateFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - if (inputStream == Tx.HdmiInputs[1]) Hdmi1VideoSyncFeedback.FireUpdate(); - if (inputStream == Tx.HdmiInputs[2]) Hdmi2VideoSyncFeedback.FireUpdate(); - break; - } - } - - void Tx_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) - { - var localVideoInputPort = - InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); - var localAudioInputPort = - InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); - - ActiveVideoInputFeedback.FireUpdate(); - VideoSourceNumericFeedback.FireUpdate(); - AudioSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localAudioInputPort, eRoutingSignalType.Audio)); - } - - - void Tx_BaseEvent(GenericBase device, BaseEventArgs args) - { - var id = args.EventId; - Debug.Console(2, this, "EventId {0}", args.EventId); - - switch (id) - { - case EndpointTransmitterBase.VideoSourceFeedbackEventId: - var localVideoInputPort = InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); - Debug.Console(2, this, " Video Source: {0}", Tx.VideoSourceFeedback); - VideoSourceNumericFeedback.FireUpdate(); - ActiveVideoInputFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - break; - case EndpointTransmitterBase.AudioSourceFeedbackEventId: - var localInputAudioPort = InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); - Debug.Console(2, this, " Audio Source: {0}", Tx.VideoSourceFeedback); - AudioSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio)); - break; - } - } - - /// - /// Relays the input stream change to the appropriate RoutingInputPort. - /// - void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) return; - inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); - } - - /// - /// Relays the VideoAttributes change to a RoutingInputPort - /// - void ForwardVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds - //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", - // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); - switch (eventId) - { - case VideoAttributeEventIds.HdcpActiveFeedbackEventId: - inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HdcpStateFeedbackEventId: - inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: - case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - } - } - - - #region IIROutputPorts Members - public CrestronCollection IROutputPorts { get { return Tx.IROutputPorts; } } - public int NumberOfIROutputPorts { get { return Tx.NumberOfIROutputPorts; } } - #endregion - - #region IComPorts Members - public CrestronCollection ComPorts { get { return Tx.ComPorts; } } - public int NumberOfComPorts { get { return Tx.NumberOfComPorts; } } - #endregion - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTxHelpers.cs b/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTxHelpers.cs deleted file mode 100644 index 222fab39..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTxHelpers.cs +++ /dev/null @@ -1,452 +0,0 @@ -extern alias Full; - -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 Full.Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.DM.Config; -using PepperDash.Essentials.Core.Config; - - -namespace PepperDash.Essentials.DM -{ - public class DmTxHelper - { - - public static BasicDmTxControllerBase GetDmTxForChassisWithoutIpId(string key, string name, string typeName, DMInput dmInput) - { - if (typeName.StartsWith("dmtx200")) - return new DmTx200Controller(key, name, new DmTx200C2G(dmInput), true); - if (typeName.StartsWith("dmtx201c")) - return new DmTx201CController(key, name, new DmTx201C(dmInput), true); - if (typeName.StartsWith("dmtx201s")) - return new DmTx201SController(key, name, new DmTx201S(dmInput), true); - if (typeName.StartsWith("dmtx4k100")) - return new DmTx4k100Controller(key, name, new DmTx4K100C1G(dmInput)); - if (typeName.StartsWith("dmtx4kz100")) - return new DmTx4kz100Controller(key, name, new DmTx4kz100C1G(dmInput)); - if (typeName.StartsWith("dmtx4k202")) - return new DmTx4k202CController(key, name, new DmTx4k202C(dmInput), true); - if (typeName.StartsWith("dmtx4kz202")) - return new DmTx4kz202CController(key, name, new DmTx4kz202C(dmInput), true); - if (typeName.StartsWith("dmtx4k302")) - return new DmTx4k302CController(key, name, new DmTx4k302C(dmInput), true); - if (typeName.StartsWith("dmtx4kz302")) - return new DmTx4kz302CController(key, name, new DmTx4kz302C(dmInput), true); - if (typeName.StartsWith("dmtx401")) - return new DmTx401CController(key, name, new DmTx401C(dmInput), true); - if (typeName.StartsWith("hdbasettx")) - new HDBaseTTxController(key, name, new HDTx3CB(dmInput)); - - return null; - } - - public static BasicDmTxControllerBase GetDmTxForChassisWithIpId(string key, string name, string typeName, uint ipid, DMInput dmInput) - { - if (typeName.StartsWith("dmtx200")) - return new DmTx200Controller(key, name, new DmTx200C2G(ipid, dmInput), true); - if (typeName.StartsWith("dmtx201c")) - return new DmTx201CController(key, name, new DmTx201C(ipid, dmInput), true); - if (typeName.StartsWith("dmtx201s")) - return new DmTx201SController(key, name, new DmTx201S(ipid, dmInput), true); - if (typeName.StartsWith("dmtx4k100")) - return new DmTx4k100Controller(key, name, new DmTx4K100C1G(ipid, dmInput)); - if (typeName.StartsWith("dmtx4kz100")) - return new DmTx4kz100Controller(key, name, new DmTx4kz100C1G(ipid, dmInput)); - if (typeName.StartsWith("dmtx4k202")) - return new DmTx4k202CController(key, name, new DmTx4k202C(ipid, dmInput), true); - if (typeName.StartsWith("dmtx4kz202")) - return new DmTx4kz202CController(key, name, new DmTx4kz202C(ipid, dmInput), true); - if (typeName.StartsWith("dmtx4k302")) - return new DmTx4k302CController(key, name, new DmTx4k302C(ipid, dmInput), true); - if (typeName.StartsWith("dmtx4kz302")) - return new DmTx4kz302CController(key, name, new DmTx4kz302C(ipid, dmInput), true); - if (typeName.StartsWith("dmtx401")) - return new DmTx401CController(key, name, new DmTx401C(ipid, dmInput), true); - if (typeName.StartsWith("hdbasettx")) - return new HDBaseTTxController(key, name, new HDTx3CB(ipid, dmInput)); - - return null; - } - - /// - /// A factory method for various DmTxControllers - /// - /// - /// - /// - /// - public static BasicDmTxControllerBase GetDmTxController(string key, string name, string typeName, DmTxPropertiesConfig props) - { - // switch on type name... later... - - typeName = typeName.ToLower(); - //uint ipid = Convert.ToUInt16(props.Id, 16); - var ipid = props.Control.IpIdInt; - var pKey = props.ParentDeviceKey.ToLower(); - - if (pKey == "processor") - { - // Catch constructor failures, mainly dues to IPID - try - { - if(typeName.StartsWith("dmtx200")) - return new DmTx200Controller(key, name, new DmTx200C2G(ipid, Global.ControlSystem), false); - if (typeName.StartsWith("dmtx201c")) - return new DmTx201CController(key, name, new DmTx201C(ipid, Global.ControlSystem), false); - if (typeName.StartsWith("dmtx201s")) - return new DmTx201SController(key, name, new DmTx201S(ipid, Global.ControlSystem), false); - if (typeName.StartsWith("dmtx4k202")) - return new DmTx4k202CController(key, name, new DmTx4k202C(ipid, Global.ControlSystem), false); - if (typeName.StartsWith("dmtx4kz202")) - return new DmTx4kz202CController(key, name, new DmTx4kz202C(ipid, Global.ControlSystem), false); - if (typeName.StartsWith("dmtx4k302")) - return new DmTx4k302CController(key, name, new DmTx4k302C(ipid, Global.ControlSystem), false); - if (typeName.StartsWith("dmtx4kz302")) - return new DmTx4kz302CController(key, name, new DmTx4kz302C(ipid, Global.ControlSystem), false); - if (typeName.StartsWith("dmtx401")) - return new DmTx401CController(key, name, new DmTx401C(ipid, Global.ControlSystem), false); - Debug.Console(0, "{1} WARNING: Cannot create DM-TX of type: '{0}'", typeName, key); - } - catch (Exception e) - { - Debug.Console(0, "[{0}] WARNING: Cannot create DM-TX device: {1}", key, e); - } - return null; - } - - var parentDev = DeviceManager.GetDeviceForKey(pKey); - DMInput dmInput; - BasicDmTxControllerBase tx; - - if (parentDev is DmChassisController) - { - // Get the Crestron chassis and link stuff up - var switchDev = (parentDev as DmChassisController); - var chassis = switchDev.Chassis; - - //Check that the input is within range of this chassis' possible inputs - var num = props.ParentInputNumber; - if (num <= 0 || num > chassis.NumberOfInputs) - { - Debug.Console(0, "Cannot create DM device '{0}'. Input number '{1}' is out of range", - key, num); - return null; - } - - switchDev.TxDictionary.Add(num, key); - dmInput = chassis.Inputs[num]; - - - try - { - //Determine if IpId is needed for this chassis type - if (chassis is DmMd8x8Cpu3 || chassis is DmMd16x16Cpu3 || - chassis is DmMd32x32Cpu3 || chassis is DmMd8x8Cpu3rps || - chassis is DmMd16x16Cpu3rps || chassis is DmMd32x32Cpu3rps || - chassis is DmMd128x128 || chassis is DmMd64x64) - { - tx = GetDmTxForChassisWithoutIpId(key, name, typeName, dmInput); - Debug.Console(0, "DM endpoint output {0} is for Cpu3, changing online feedback to chassis", num); - tx.IsOnline.SetValueFunc(() => switchDev.InputEndpointOnlineFeedbacks[num].BoolValue); - switchDev.InputEndpointOnlineFeedbacks[num].OutputChange += (o, a) => tx.IsOnline.FireUpdate(); - return tx; - } - else - { - return GetDmTxForChassisWithIpId(key, name, typeName, ipid, dmInput); - } - } - catch (Exception e) - { - Debug.Console(0, "[{0}] WARNING: Cannot create DM-TX device for chassis: {1}", key, e); - return null; - } - } - else if(parentDev is DmpsRoutingController) - { - // Get the DMPS chassis and link stuff up - var dmpsDev = (parentDev as DmpsRoutingController); - var chassis = dmpsDev.Dmps; - - //Check that the input is within range of this chassis' possible inputs - var num = props.ParentInputNumber; - if (num <= 0 || num > chassis.SwitcherInputs.Count) - { - Debug.Console(0, "Cannot create DMPS device '{0}'. Input number '{1}' is out of range", - key, num); - return null; - } - - dmpsDev.TxDictionary.Add(num, key); - - try - { - dmInput = chassis.SwitcherInputs[num] as DMInput; - } - catch - { - Debug.Console(0, "Cannot create DMPS device '{0}'. Input number '{1}' is not a DM input", key, num); - return null; - } - - try - { - if(Global.ControlSystemIsDmps4kType) - { - tx = GetDmTxForChassisWithoutIpId(key, name, typeName, dmInput); - Debug.Console(0, "DM endpoint output {0} is for DMPS3-4K, changing online feedback to chassis", num); - tx.IsOnline.SetValueFunc(() => dmpsDev.InputEndpointOnlineFeedbacks[num].BoolValue); - dmpsDev.InputEndpointOnlineFeedbacks[num].OutputChange += (o, a) => tx.IsOnline.FireUpdate(); - return tx; - } - else - { - return GetDmTxForChassisWithIpId(key, name, typeName, ipid, dmInput); - } - } - catch (Exception e) - { - Debug.Console(0, "[{0}] WARNING: Cannot create DM-TX device for dmps: {1}", key, e); - return null; - } - } - - else - { - Debug.Console(0, "Cannot create DM device '{0}'. '{1}' is not a processor, DM Chassis or DMPS.", key, pKey); - return null; - } - } - } - - public abstract class BasicDmTxControllerBase : CrestronGenericBridgeableBaseDevice - { - protected BasicDmTxControllerBase(string key, string name, GenericBase hardware) - : base(key, name, hardware) - { - - } - } - - /// - /// - /// - [Description("Wrapper class for all DM-TX variants")] - public abstract class DmTxControllerBase : BasicDmTxControllerBase - { - public virtual void SetPortHdcpCapability(eHdcpCapabilityType hdcpMode, uint port) { } - public virtual eHdcpCapabilityType HdcpSupportCapability { get; protected set; } - public abstract StringFeedback ActiveVideoInputFeedback { get; protected set; } - public RoutingInputPortWithVideoStatuses AnyVideoInput { get; protected set; } - public IntFeedback HdcpStateFeedback { get; protected set; } - - protected DmTxControllerBase(string key, string name, EndpointTransmitterBase hardware) - : base(key, name, hardware) - { - AddToFeedbackList(ActiveVideoInputFeedback); - - IsOnline.OutputChange += (currentDevice, args) => - { - foreach (var feedback in Feedbacks) - { - if (feedback != null) - feedback.FireUpdate(); - } - }; - } - - protected DmTxControllerBase(string key, string name, DmHDBasedTEndPoint hardware) : base(key, name, hardware) - { - } - - protected DmTxControllerJoinMap GetDmTxJoinMap(uint joinStart, string joinMapKey) - { - var joinMap = new DmTxControllerJoinMap(joinStart); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - return joinMap; - } - - protected void LinkDmTxToApi(DmTxControllerBase tx, BasicTriList trilist, DmTxControllerJoinMap joinMap, EiscApiAdvanced bridge) - { - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - - Debug.Console(1, tx, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - - tx.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - tx.AnyVideoInput.VideoStatus.VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus.JoinNumber]); - tx.AnyVideoInput.VideoStatus.VideoResolutionFeedback.LinkInputSig(trilist.StringInput[joinMap.CurrentInputResolution.JoinNumber]); - trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber].UShortValue = (ushort)tx.HdcpSupportCapability; - trilist.StringInput[joinMap.Name.JoinNumber].StringValue = tx.Name; - - bool hdcpTypeSimple; - - if (tx.Hardware is DmTx4kX02CBase) - hdcpTypeSimple = false; - else - hdcpTypeSimple = true; - - if (tx is ITxRouting) - { - var txR = tx as ITxRouting; - - trilist.SetUShortSigAction(joinMap.VideoInput.JoinNumber, - i => txR.ExecuteNumericSwitch(i, 0, eRoutingSignalType.Video)); - trilist.SetUShortSigAction(joinMap.AudioInput.JoinNumber, - i => txR.ExecuteNumericSwitch(i, 0, eRoutingSignalType.Audio)); - - txR.VideoSourceNumericFeedback.LinkInputSig(trilist.UShortInput[joinMap.VideoInput.JoinNumber]); - txR.AudioSourceNumericFeedback.LinkInputSig(trilist.UShortInput[joinMap.AudioInput.JoinNumber]); - - trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber].UShortValue = (ushort)tx.HdcpSupportCapability; - - if (txR.InputPorts[DmPortName.HdmiIn] != null) - { - var inputPort = txR.InputPorts[DmPortName.HdmiIn]; - - if (tx.Feedbacks["HdmiInHdcpCapability"] != null) - { - var intFeedback = tx.Feedbacks["HdmiInHdcpCapability"] as IntFeedback; - if (intFeedback != null) - intFeedback.LinkInputSig(trilist.UShortInput[joinMap.Port1HdcpState.JoinNumber]); - } - - if (inputPort.ConnectionType == eRoutingPortConnectionType.Hdmi && inputPort.Port != null) - { - var port = inputPort.Port as EndpointHdmiInput; - - SetHdcpCapabilityAction(hdcpTypeSimple, port, joinMap.Port1HdcpState.JoinNumber, trilist); - } - } - - if (txR.InputPorts[DmPortName.HdmiIn1] != null) - { - var inputPort = txR.InputPorts[DmPortName.HdmiIn1]; - - if (tx.Feedbacks["HdmiIn1HdcpCapability"] != null) - { - var intFeedback = tx.Feedbacks["HdmiIn1HdcpCapability"] as IntFeedback; - if (intFeedback != null) - intFeedback.LinkInputSig(trilist.UShortInput[joinMap.Port1HdcpState.JoinNumber]); - } - - if (inputPort.ConnectionType == eRoutingPortConnectionType.Hdmi && inputPort.Port != null) - { - var port = inputPort.Port as EndpointHdmiInput; - - SetHdcpCapabilityAction(hdcpTypeSimple, port, joinMap.Port1HdcpState.JoinNumber, trilist); - } - } - - if (txR.InputPorts[DmPortName.HdmiIn2] != null) - { - var inputPort = txR.InputPorts[DmPortName.HdmiIn2]; - - if (tx.Feedbacks["HdmiIn2HdcpCapability"] != null) - { - var intFeedback = tx.Feedbacks["HdmiIn2HdcpCapability"] as IntFeedback; - if (intFeedback != null) - intFeedback.LinkInputSig(trilist.UShortInput[joinMap.Port1HdcpState.JoinNumber]); - } - - if (inputPort.ConnectionType == eRoutingPortConnectionType.Hdmi && inputPort.Port != null) - { - var port = inputPort.Port as EndpointHdmiInput; - - SetHdcpCapabilityAction(hdcpTypeSimple, port, joinMap.Port2HdcpState.JoinNumber, trilist); - } - } - - } - - var txFreeRun = tx as IHasFreeRun; - if (txFreeRun != null) - { - txFreeRun.FreeRunEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.FreeRunEnabled.JoinNumber]); - trilist.SetBoolSigAction(joinMap.FreeRunEnabled.JoinNumber, txFreeRun.SetFreeRunEnabled); - } - - var txVga = tx as IVgaBrightnessContrastControls; - { - if (txVga == null) return; - - txVga.VgaBrightnessFeedback.LinkInputSig(trilist.UShortInput[joinMap.VgaBrightness.JoinNumber]); - txVga.VgaContrastFeedback.LinkInputSig(trilist.UShortInput[joinMap.VgaContrast.JoinNumber]); - - trilist.SetUShortSigAction(joinMap.VgaBrightness.JoinNumber, txVga.SetVgaBrightness); - trilist.SetUShortSigAction(joinMap.VgaContrast.JoinNumber, txVga.SetVgaContrast); - } - } - - private void SetHdcpCapabilityAction(bool hdcpTypeSimple, EndpointHdmiInput port, uint join, BasicTriList trilist) - { - if (hdcpTypeSimple) - { - trilist.SetUShortSigAction(join, - s => - { - if (s == 0) - { - port.HdcpSupportOff(); - } - else if (s > 0) - { - port.HdcpSupportOn(); - } - }); - } - else - { - trilist.SetUShortSigAction(join, - s => - { - port.HdcpCapability = (eHdcpCapabilityType)s; - }); - } - } - } - - public class DmTxControllerFactory : EssentialsDeviceFactory - { - public DmTxControllerFactory() - { - TypeNames = new List() { "dmtx200c", "dmtx201c", "dmtx201s", "dmtx4k100c", "dmtx4k202c", "dmtx4kz202c", "dmtx4k302c", "dmtx4kz302c", - "dmtx401c", "dmtx401s", "dmtx4k100c1g", "dmtx4kz100c1g", "hdbasettx" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - var type = dc.Type.ToLower(); - - Debug.Console(1, "Factory Attempting to create new DM-TX Device"); - - var props = JsonConvert.DeserializeObject - (dc.Properties.ToString()); - return PepperDash.Essentials.DM.DmTxHelper.GetDmTxController(dc.Key, dc.Name, type, props); - } - } - -} - diff --git a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/HDBaseTTxController.cs b/src/PepperDash.Essentials.DM/Endpoints/Transmitters/HDBaseTTxController.cs deleted file mode 100644 index a90cb443..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/HDBaseTTxController.cs +++ /dev/null @@ -1,137 +0,0 @@ -extern alias Full; - -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.Endpoints.Transmitters; -using Crestron.SimplSharpPro.DM; -using Full.Newtonsoft.Json; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.DM -{ - /// - /// Controller class for suitable for HDBaseT transmitters - /// - [Description("Wrapper Class for HDBaseT devices based on HDTx3CB class")] - public class HDBaseTTxController : BasicDmTxControllerBase, IRoutingInputsOutputs, IComPorts - { - public RoutingInputPort HdmiIn { get; private set; } - public RoutingOutputPort DmOut { get; private set; } - - public HDBaseTTxController(string key, string name, HDTx3CB tx) - : base(key, name, tx) - { - PreventRegistration = true; - - HdmiIn = new RoutingInputPort(DmPortName.HdmiIn1, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, null, this) { Port = tx }; - - DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmCat, null, this); - - InputPorts = new RoutingPortCollection { HdmiIn }; - OutputPorts = new RoutingPortCollection { DmOut }; - - var parentDev = DeviceManager.GetDeviceForKey(key); - var num = tx.DMInputOutput.Number; - if (parentDev is DmpsRoutingController) - { - var dmps = parentDev as DmpsRoutingController; - IsOnline.SetValueFunc(() => dmps.InputEndpointOnlineFeedbacks[num].BoolValue); - dmps.InputEndpointOnlineFeedbacks[num].OutputChange += (o, a) => IsOnline.FireUpdate(); - } - else if (parentDev is DmChassisController) - { - var controller = parentDev as DmChassisController; - IsOnline.SetValueFunc(() => controller.InputEndpointOnlineFeedbacks[num].BoolValue); - controller.InputEndpointOnlineFeedbacks[num].OutputChange += (o, a) => IsOnline.FireUpdate(); - } - } - - #region IRoutingInputs Members - - public RoutingPortCollection InputPorts { get; private set; } - - #endregion - - #region IRoutingOutputs Members - - public RoutingPortCollection OutputPorts { get; private set; } - - #endregion - - #region IComPorts Members - - public CrestronCollection ComPorts { get { return (Hardware as HDTx3CB).ComPorts; } } - public int NumberOfComPorts { get { return (Hardware as HDTx3CB).NumberOfComPorts; } } - - #endregion - - #region CrestronBridgeableBaseDevice abstract overrides - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new HDBaseTTxControllerJoinMap(joinStart); - - var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } - - Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - - this.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - trilist.StringInput[joinMap.Name.JoinNumber].StringValue = this.Name; - } - - #endregion - } - - public class HDBaseTTxControllerJoinMap : JoinMapBaseAdvanced - { - [JoinName("IsOnline")] - public JoinDataComplete IsOnline = new JoinDataComplete( - new JoinData - { - JoinNumber = 1, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "HDBaseT device online feedback", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("Name")] - public JoinDataComplete Name = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, - new JoinMetadata { Description = "DM Tx Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - /// - /// Plugin device BridgeJoinMap constructor - /// - /// This will be the join it starts on the EISC bridge - public HDBaseTTxControllerJoinMap(uint joinStart) - : base(joinStart, typeof(HDBaseTTxControllerJoinMap)) - { - } - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/TxInterfaces.cs b/src/PepperDash.Essentials.DM/Endpoints/Transmitters/TxInterfaces.cs deleted file mode 100644 index 50955dda..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/TxInterfaces.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; - -using PepperDash.Essentials.Core; - -namespace PepperDash.Essentials.DM -{ - /// - /// Defines a device capable of setting the Free Run state of a VGA input and reporting feedback - /// - public interface IHasFreeRun - { - BoolFeedback FreeRunEnabledFeedback { get; } - - void SetFreeRunEnabled(bool enable); - } - - /// - /// Defines a device capable of adjusting VGA settings - /// - public interface IVgaBrightnessContrastControls - { - IntFeedback VgaBrightnessFeedback { get; } - IntFeedback VgaContrastFeedback { get; } - - void SetVgaBrightness(ushort level); - void SetVgaContrast(ushort level); - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/Extensions.cs b/src/PepperDash.Essentials.DM/Extensions.cs deleted file mode 100644 index c1ccfc5d..00000000 --- a/src/PepperDash.Essentials.DM/Extensions.cs +++ /dev/null @@ -1,43 +0,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.Cards; - -using PepperDash.Essentials.Core; - -namespace PepperDash.Essentials.DM -{ - public static class VideoAttributesBasicExtensions - { - public static string GetVideoResolutionString(this VideoAttributesBasic va) - { - ushort h = va.HorizontalResolutionFeedback.UShortValue; - ushort v = va.VerticalResolutionFeedback.UShortValue; - ushort r = va.FramesPerSecondFeedback.UShortValue; - if (h == 0 || v == 0) - return "n/a"; - else - return string.Format("{0}x{1}@{2}Hz", h, v, r); - } - } - - public static class AdvEndpointHdmiOutputExtensions - { - public static string GetVideoResolutionString(this AdvEndpointHdmiOutput va) - { - ushort h = va.HorizontalResolutionFeedback.UShortValue; - ushort v = va.VerticalResolutionFeedback.UShortValue; - ushort r = va.FramesPerSecondFeedback.UShortValue; - if (h == 0 || v == 0) - return "n/a"; - else - return string.Format("{0}x{1}@{2}Hz", h, v, r); - } - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/IDmHdmiInputExtensions.cs b/src/PepperDash.Essentials.DM/IDmHdmiInputExtensions.cs deleted file mode 100644 index a014e976..00000000 --- a/src/PepperDash.Essentials.DM/IDmHdmiInputExtensions.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.DM; - -using PepperDash.Essentials.Core; - -namespace PepperDash.Essentials.DM -{ - public static class IBasicDmInputExtensions - { - public static VideoStatusFuncsWrapper GetVideoStatusFuncsWrapper(this IBasicDMInput input) - { - var va = (input as IVideoAttributesEnhanced).VideoAttributes; - return new VideoStatusFuncsWrapper - { - HasVideoStatusFunc = () => true, - HdcpActiveFeedbackFunc = () => va.HdcpActiveFeedback.BoolValue, - HdcpStateFeedbackFunc = () => va.HdcpStateFeedback.ToString(), - VideoResolutionFeedbackFunc = () => - { - //var h = va.HorizontalResolutionFeedback.UShortValue; - //var v = va.VerticalResolutionFeedback.UShortValue; - //if (h == 0 || v == 0) - // return "---"; - return va.GetVideoResolutionString(); // h + "x" + v; - }, - VideoSyncFeedbackFunc = () => input.SyncDetectedFeedback.BoolValue - }; - } - } - - - public static class IEndpointHdmiInputExtensions - { - public static VideoStatusFuncsWrapper GetVideoStatusFuncsWrapper(this Crestron.SimplSharpPro.DM.Endpoints.EndpointHdmiInput input) - { - var va = (input as IVideoAttributesEnhanced).VideoAttributes; - return new VideoStatusFuncsWrapper - { - HasVideoStatusFunc = () => true, - HdcpActiveFeedbackFunc = () => va.HdcpActiveFeedback.BoolValue, - HdcpStateFeedbackFunc = () => va.HdcpStateFeedback.ToString(), - VideoResolutionFeedbackFunc = () => - { - //var h = va.HorizontalResolutionFeedback.UShortValue; - //var v = va.VerticalResolutionFeedback.UShortValue; - //if (h == 0 || v == 0) - // return "---"; - return va.GetVideoResolutionString(); // h + "x" + v; - }, - VideoSyncFeedbackFunc = () => input.SyncDetectedFeedback.BoolValue - }; - } - } - - -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/IDmSwitch.cs b/src/PepperDash.Essentials.DM/IDmSwitch.cs deleted file mode 100644 index ef50f2ce..00000000 --- a/src/PepperDash.Essentials.DM/IDmSwitch.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Cards; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Receivers; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -//using PepperDash.Essentials.DM.Cards; - -using PepperDash.Essentials.DM.Config; - -namespace PepperDash.Essentials.DM { - public interface IDmSwitch { - Switch Chassis { get; } - - Dictionary TxDictionary { get; } - Dictionary RxDictionary { get; } - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/PepperDash.Essentials.DM.csproj b/src/PepperDash.Essentials.DM/PepperDash.Essentials.DM.csproj deleted file mode 100644 index d346e5db..00000000 --- a/src/PepperDash.Essentials.DM/PepperDash.Essentials.DM.csproj +++ /dev/null @@ -1,43 +0,0 @@ - - - ProgramLibrary - - - PepperDash.Essentials.DM - net472 - PepperDash.Essentials.DM - PepperDash.Essentials.DM - bin\$(Configuration)\ - PepperDash Essentials DM - $(AssemblyName) - - - full - - - pdbonly - - - - - - - - - - - - - - - all - - - Full - - - - - - - \ No newline at end of file diff --git a/src/PepperDash.Essentials.DM/VideoStatusHelpers.cs b/src/PepperDash.Essentials.DM/VideoStatusHelpers.cs deleted file mode 100644 index 50107c37..00000000 --- a/src/PepperDash.Essentials.DM/VideoStatusHelpers.cs +++ /dev/null @@ -1,93 +0,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 PepperDash.Essentials.Core; - -namespace PepperDash.Essentials.DM -{ - /// - /// These methods will get the funcs that return values from various video port types... - /// - public class VideoStatusHelper - { - public static VideoStatusFuncsWrapper GetHdmiInputStatusFuncs(HdmiInputPort port) - { - return new VideoStatusFuncsWrapper - { - HdcpActiveFeedbackFunc = () => port.VideoAttributes.HdcpActiveFeedback.BoolValue, - HdcpStateFeedbackFunc = () => port.VideoAttributes.HdcpStateFeedback.ToString(), - VideoResolutionFeedbackFunc = () => port.VideoAttributes.GetVideoResolutionString(), - VideoSyncFeedbackFunc = () => port.SyncDetectedFeedback.BoolValue - }; - } - - public static VideoStatusFuncsWrapper GetHdmiInputStatusFuncs(EndpointHdmiInput port) - { - return new VideoStatusFuncsWrapper - { - VideoResolutionFeedbackFunc = () => port.VideoAttributes.GetVideoResolutionString(), - VideoSyncFeedbackFunc = () => port.SyncDetectedFeedback.BoolValue - }; - } - - public static VideoStatusFuncsWrapper GetVgaInputStatusFuncs(EndpointVgaInput port) - { - return new VideoStatusFuncsWrapper - { - HdcpActiveFeedbackFunc = () => port.VideoAttributes.HdcpActiveFeedback.BoolValue, - HdcpStateFeedbackFunc = () => port.VideoAttributes.HdcpStateFeedback.ToString(), - VideoResolutionFeedbackFunc = () => port.VideoAttributes.GetVideoResolutionString(), - VideoSyncFeedbackFunc = () => port.SyncDetectedFeedback.BoolValue - }; - } - - public static VideoStatusFuncsWrapper GetVgaInputStatusFuncs(VgaDviInputPort port) - { - return new VideoStatusFuncsWrapper - { - HdcpActiveFeedbackFunc = () => port.VideoAttributes.HdcpActiveFeedback.BoolValue, - HdcpStateFeedbackFunc = () => port.VideoAttributes.HdcpStateFeedback.ToString(), - VideoResolutionFeedbackFunc = () => port.VideoAttributes.GetVideoResolutionString(), - VideoSyncFeedbackFunc = () => port.SyncDetectedFeedback.BoolValue - }; - } - - public static VideoStatusFuncsWrapper GetBncInputStatusFuncs(Component port) - { - return new VideoStatusFuncsWrapper - { - VideoResolutionFeedbackFunc = () => port.VideoAttributes.GetVideoResolutionString(), - VideoSyncFeedbackFunc = () => port.VideoDetectedFeedback.BoolValue - }; - } - - public static VideoStatusFuncsWrapper GetDmInputStatusFuncs(DMInputPort port) - { - return new VideoStatusFuncsWrapper - { - HdcpActiveFeedbackFunc = () => port.VideoAttributes.HdcpActiveFeedback.BoolValue, - HdcpStateFeedbackFunc = () => port.VideoAttributes.HdcpStateFeedback.ToString(), - VideoResolutionFeedbackFunc = () => port.VideoAttributes.GetVideoResolutionString(), - VideoSyncFeedbackFunc = () => port.SyncDetectedFeedback.BoolValue - }; - } - - public static VideoStatusFuncsWrapper GetDisplayPortInputStatusFuncs(EndpointDisplayPortInput port) - { - return new VideoStatusFuncsWrapper - { - HdcpActiveFeedbackFunc = () => port.VideoAttributes.HdcpActiveFeedback.BoolValue, - HdcpStateFeedbackFunc = () => port.VideoAttributes.HdcpStateFeedback.ToString(), - VideoResolutionFeedbackFunc = () => port.VideoAttributes.GetVideoResolutionString(), - VideoSyncFeedbackFunc = () => port.SyncDetectedFeedback.BoolValue - }; - } - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/iHasScheduleAwareness.cs b/src/PepperDash.Essentials.Devices.Common/Codec/iHasScheduleAwareness.cs index 41140c34..6ddf10c2 100644 --- a/src/PepperDash.Essentials.Devices.Common/Codec/iHasScheduleAwareness.cs +++ b/src/PepperDash.Essentials.Devices.Common/Codec/iHasScheduleAwareness.cs @@ -218,6 +218,10 @@ namespace PepperDash.Essentials.Devices.Common.Codec return joinable; } } + + [JsonProperty("dialable")] + public bool Dialable { get; set; } + //public string ConferenceNumberToDial { get; set; } [JsonProperty("conferencePassword")] public string ConferencePassword { get; set; } diff --git a/src/PepperDash.Essentials.Devices.Common/PepperDash.Essentials.Devices.Common.csproj b/src/PepperDash.Essentials.Devices.Common/PepperDash.Essentials.Devices.Common.csproj index 0837b2df..96ef4e5d 100644 --- a/src/PepperDash.Essentials.Devices.Common/PepperDash.Essentials.Devices.Common.csproj +++ b/src/PepperDash.Essentials.Devices.Common/PepperDash.Essentials.Devices.Common.csproj @@ -27,7 +27,7 @@ - + Full diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/BookingsDataClasses.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/BookingsDataClasses.cs index 59823bb9..05456ad4 100644 --- a/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/BookingsDataClasses.cs +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/BookingsDataClasses.cs @@ -348,6 +348,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec if (b.DialInfo.ConnectMode.Value.ToLower() == "obtp" || b.DialInfo.ConnectMode.Value.ToLower() == "manual") meeting.IsOneButtonToPushMeeting = true; + meeting.Dialable = b.DialInfo.Calls.Call.Count > 0; + if (b.DialInfo.Calls.Call != null) { foreach (Call c in b.DialInfo.Calls.Call) diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/VideoCodecBase.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/VideoCodecBase.cs index 3dd85100..9d8fbce1 100644 --- a/src/PepperDash.Essentials.Devices.Common/VideoCodec/VideoCodecBase.cs +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/VideoCodecBase.cs @@ -940,7 +940,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec //digitals tokenArray[digitalIndex] = new XSigDigitalToken(digitalIndex + 1, meeting.Joinable); - tokenArray[digitalIndex + 1] = new XSigDigitalToken(digitalIndex + 2, meeting.Id != "0"); + tokenArray[digitalIndex + 1] = new XSigDigitalToken(digitalIndex + 2, meeting.Dialable); //serials tokenArray[stringIndex] = new XSigSerialToken(stringIndex + 1, meeting.Organizer); diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ResponseObjects.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ResponseObjects.cs index 5e49b15f..0ba684a8 100644 --- a/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ResponseObjects.cs +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ResponseObjects.cs @@ -1512,6 +1512,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom meeting.Privacy = b.IsPrivate ? eMeetingPrivacy.Private : eMeetingPrivacy.Public; + meeting.Dialable = meeting.Id != "0"; + // No meeting.Calls data exists for Zoom Rooms. Leaving out for now. var now = DateTime.Now; if (meeting.StartTime < now && meeting.EndTime < now) diff --git a/src/PepperDash.Essentials/Audio/EssentialsVolumeLevelConfig.cs b/src/PepperDash.Essentials/Audio/EssentialsVolumeLevelConfig.cs index 70fcd36f..c1b1cc2c 100644 --- a/src/PepperDash.Essentials/Audio/EssentialsVolumeLevelConfig.cs +++ b/src/PepperDash.Essentials/Audio/EssentialsVolumeLevelConfig.cs @@ -1,18 +1,8 @@ extern alias Full; - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using Crestron.SimplSharp; -using Full.Newtonsoft.Json; - -using PepperDash.Core; using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Devices.Common.DSP; -using PepperDash.Essentials.DM; +using System; +using System.Text.RegularExpressions; namespace PepperDash.Essentials { @@ -35,45 +25,5 @@ namespace PepperDash.Essentials public string DeviceKey { get; set; } public string Label { get; set; } public int Level { get; set; } - - /// - /// Helper to get the device associated with key - one timer. - /// - public IBasicVolumeWithFeedback GetDevice() - { - // DM output card format: deviceKey--output~number, dm8x8-1--output~4 - var match = Regex.Match(DeviceKey, @"([-_\w]+)--(\w+)~(\d+)"); - if (match.Success) - { - var devKey = match.Groups[1].Value; - var chassis = DeviceManager.GetDeviceForKey(devKey) as DmChassisController; - if (chassis != null) - { - var outputNum = Convert.ToUInt32(match.Groups[3].Value); - if (chassis.VolumeControls.ContainsKey(outputNum)) // should always... - return chassis.VolumeControls[outputNum]; - } - // No volume for some reason. We have failed as developers - return null; - } - - // DSP format: deviceKey--levelName, biampTesira-1--master - match = Regex.Match(DeviceKey, @"([-_\w]+)--(.+)"); - if (match.Success) - { - var devKey = match.Groups[1].Value; - var dsp = DeviceManager.GetDeviceForKey(devKey) as BiampTesiraForteDsp; - if (dsp != null) - { - var levelTag = match.Groups[2].Value; - if (dsp.LevelControlPoints.ContainsKey(levelTag)) // should always... - return dsp.LevelControlPoints[levelTag]; - } - // No volume for some reason. We have failed as developers - return null; - } - - return null; - } } } \ No newline at end of file diff --git a/src/PepperDash.Essentials/ControlSystem.cs b/src/PepperDash.Essentials/ControlSystem.cs index 077a2b1a..09c95323 100644 --- a/src/PepperDash.Essentials/ControlSystem.cs +++ b/src/PepperDash.Essentials/ControlSystem.cs @@ -1,28 +1,23 @@ extern alias Full; - -using System; -using System.Collections.Generic; -using System.Linq; using Crestron.SimplSharp; using Crestron.SimplSharp.CrestronIO; +using Crestron.SimplSharp.Reflection; using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.CrestronThread; using Crestron.SimplSharpPro.Diagnostics; -using Crestron.SimplSharp.Reflection; - +using Full.Newtonsoft.Json; using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Config; +using PepperDash.Essentials.Core.DeviceTypeInterfaces; using PepperDash.Essentials.Core.Fusion; -// using PepperDash.Essentials.Core.Web; using PepperDash.Essentials.Devices.Common; -using PepperDash.Essentials.DM; using PepperDash.Essentials.Fusion; using PepperDash.Essentials.Room.Config; - -using Full.Newtonsoft.Json; -using PepperDash.Essentials.Core.DeviceTypeInterfaces; +using System; +using System.Collections.Generic; +using System.Linq; namespace PepperDash.Essentials { @@ -49,28 +44,29 @@ namespace PepperDash.Essentials /// public override void InitializeSystem() { - _startTimer = new CTimer(StartSystem,StartupTime); - - // If the control system is a DMPS type, we need to wait to exit this method until all devices have had time to activate // to allow any HD-BaseT DM endpoints to register first. - if (Global.ControlSystemIsDmpsType) + bool preventInitializationComplete = Global.ControlSystemIsDmpsType; + if (preventInitializationComplete) { Debug.Console(1, "******************* InitializeSystem() Entering **********************"); - - _initializeEvent = new CEvent(); - + _startTimer = new CTimer(StartSystem, preventInitializationComplete, StartupTime); + _initializeEvent = new CEvent(true, false); DeviceManager.AllDevicesRegistered += (o, a) => { _initializeEvent.Set(); - Debug.Console(1, "******************* InitializeSystem() Exiting **********************"); }; - _initializeEvent.Wait(30000); + Debug.Console(1, "******************* InitializeSystem() Exiting **********************"); + SystemMonitor.ProgramInitialization.ProgramInitializationComplete = true; + } + else + { + _startTimer = new CTimer(StartSystem, preventInitializationComplete, StartupTime); } } - private void StartSystem(object obj) + private void StartSystem(object preventInitialization) { DeterminePlatform(); @@ -82,7 +78,7 @@ namespace PepperDash.Essentials CrestronConsole.AddNewConsoleCommand(PluginLoader.ReportAssemblyVersions, "reportversions", "Reports the versions of the loaded assemblies", ConsoleAccessLevelEnum.AccessOperator); - CrestronConsole.AddNewConsoleCommand(PepperDash.Essentials.Core.DeviceFactory.GetDeviceFactoryTypes, "gettypes", "Gets the device types that can be built. Accepts a filter string.", ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand(Core.DeviceFactory.GetDeviceFactoryTypes, "gettypes", "Gets the device types that can be built. Accepts a filter string.", ConsoleAccessLevelEnum.AccessOperator); CrestronConsole.AddNewConsoleCommand(BridgeHelper.PrintJoinMap, "getjoinmap", "map(s) for bridge or device on bridge [brKey [devKey]]", ConsoleAccessLevelEnum.AccessOperator); @@ -94,27 +90,28 @@ namespace PepperDash.Essentials CrestronConsole.AddNewConsoleCommand(s => { foreach (var tl in TieLineCollection.Default) - CrestronConsole.ConsoleCommandResponse(" {0}\r\n", tl); + CrestronConsole.ConsoleCommandResponse(" {0}{1}", tl, CrestronEnvironment.NewLine); }, "listtielines", "Prints out all tie lines", ConsoleAccessLevelEnum.AccessOperator); CrestronConsole.AddNewConsoleCommand(s => { CrestronConsole.ConsoleCommandResponse - ("Current running configuration. This is the merged system and template configuration"); + ("Current running configuration. This is the merged system and template configuration" + CrestronEnvironment.NewLine); CrestronConsole.ConsoleCommandResponse(Newtonsoft.Json.JsonConvert.SerializeObject (ConfigReader.ConfigObject, Newtonsoft.Json.Formatting.Indented)); }, "showconfig", "Shows the current running merged config", ConsoleAccessLevelEnum.AccessOperator); - CrestronConsole.AddNewConsoleCommand(s => + CrestronConsole.AddNewConsoleCommand(s => CrestronConsole.ConsoleCommandResponse( - "This system can be found at the following URLs:\r\n" + - "System URL: {0}\r\n" + - "Template URL: {1}", - ConfigReader.ConfigObject.SystemUrl, - ConfigReader.ConfigObject.TemplateUrl), - "portalinfo", - "Shows portal URLS from configuration", + "This system can be found at the following URLs:{2}" + + "System URL: {0}{2}" + + "Template URL: {1}{2}", + ConfigReader.ConfigObject.SystemUrl, + ConfigReader.ConfigObject.TemplateUrl, + CrestronEnvironment.NewLine), + "portalinfo", + "Shows portal URLS from configuration", ConsoleAccessLevelEnum.AccessOperator); @@ -127,7 +124,10 @@ namespace PepperDash.Essentials return; } - SystemMonitor.ProgramInitialization.ProgramInitializationComplete = true; + if (!(bool)preventInitialization) + { + SystemMonitor.ProgramInitialization.ProgramInitializationComplete = true; + } } /// @@ -231,9 +231,10 @@ namespace PepperDash.Essentials new Core.DeviceFactory(); new Devices.Common.DeviceFactory(); - new DM.DeviceFactory(); new DeviceFactory(); + new Core.ProcessorExtensionDeviceFactory(); + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials load from configuration"); var filesReady = SetupFilesystem(); @@ -334,13 +335,14 @@ namespace PepperDash.Essentials void Load() { LoadDevices(); - LoadTieLines(); LoadRooms(); LoadLogoServer(); DeviceManager.ActivateAll(); - var mobileControl = GetMobileControlDevice(); + LoadTieLines(); + + var mobileControl = GetMobileControlDevice(); if (mobileControl == null) return; @@ -367,6 +369,7 @@ namespace PepperDash.Essentials foreach (var devConf in ConfigReader.ConfigObject.Devices) { + IKeyed newDev = null; try { @@ -384,47 +387,55 @@ namespace PepperDash.Essentials "WARNING: Config file defines processor type as '{0}' but actual processor is '{1}'! Some ports may not be available", devConf.Type.ToUpper(), Global.ControlSystem.ControllerPrompt.ToUpper()); + //if (newDev == null) + // newDev = PepperDash.Essentials.Core.ProcessorExtensionDeviceFactory.GetExtensionDevice(devConf); + + //if (newDev != null) + //{ + // DeviceManager.AddDevice(newDev); + + // continue; + //} + // Check if the processor is a DMPS model - if (this.ControllerPrompt.IndexOf("dmps", StringComparison.OrdinalIgnoreCase) > -1) - { - Debug.Console(2, "Adding DmpsRoutingController for {0} to Device Manager.", this.ControllerPrompt); + //if (this.ControllerPrompt.IndexOf("dmps", StringComparison.OrdinalIgnoreCase) > -1) + //{ + // Debug.Console(2, "Adding DmpsRoutingController for {0} to Device Manager.", this.ControllerPrompt); - var propertiesConfig = JsonConvert.DeserializeObject(devConf.Properties.ToString()); + // var propertiesConfig = JsonConvert.DeserializeObject(devConf.Properties.ToString()); - if(propertiesConfig == null) - propertiesConfig = new DM.Config.DmpsRoutingPropertiesConfig(); + // if(propertiesConfig == null) + // propertiesConfig = new DM.Config.DmpsRoutingPropertiesConfig(); - DeviceManager.AddDevice(DmpsRoutingController.GetDmpsRoutingController("processor-avRouting", this.ControllerPrompt, propertiesConfig)); - } - else if (this.ControllerPrompt.IndexOf("mpc3", StringComparison.OrdinalIgnoreCase) > -1) - { - Debug.Console(2, "MPC3 processor type detected. Adding Mpc3TouchpanelController."); + // DeviceManager.AddDevice(DmpsRoutingController.GetDmpsRoutingController("processor-avRouting", this.ControllerPrompt, propertiesConfig)); + //} + //else - var butToken = devConf.Properties["buttons"]; - if (butToken != null) - { - var buttons = butToken.ToObject>(); - var tpController = new Essentials.Core.Touchpanels.Mpc3TouchpanelController(devConf.Key, devConf.Name, Global.ControlSystem, buttons); - DeviceManager.AddDevice(tpController); - } - else - { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: Unable to deserialize buttons collection for device: {0}", devConf.Key); - } + //if (this.ControllerPrompt.IndexOf("mpc3", StringComparison.OrdinalIgnoreCase) > -1) + //{ + // Debug.Console(2, "MPC3 processor type detected. Adding Mpc3TouchpanelController."); + + // var butToken = devConf.Properties["buttons"]; + // if (butToken != null) + // { + // var buttons = butToken.ToObject>(); + // var tpController = new Essentials.Core.Touchpanels.Mpc3TouchpanelController(devConf.Key, devConf.Name, Global.ControlSystem, buttons); + // DeviceManager.AddDevice(tpController); + // } + // else + // { + // Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: Unable to deserialize buttons collection for device: {0}", devConf.Key); + // } - } - else - { - Debug.Console(2, "************Processor is not DMPS type***************"); - } - - + //} + //else + //{ + // Debug.Console(2, "************Processor is not DMPS type***************"); + //} continue; } - // Try local factories first - IKeyed newDev = null; if (newDev == null) newDev = PepperDash.Essentials.Core.DeviceFactory.GetDevice(devConf); diff --git a/src/PepperDash.Essentials/PepperDash.Essentials.csproj b/src/PepperDash.Essentials/PepperDash.Essentials.csproj index 9d1cd4c2..bcc0e152 100644 --- a/src/PepperDash.Essentials/PepperDash.Essentials.csproj +++ b/src/PepperDash.Essentials/PepperDash.Essentials.csproj @@ -46,7 +46,7 @@ - + Full @@ -55,6 +55,5 @@ - \ No newline at end of file diff --git a/src/PepperDash.Essentials/Room/Types/EssentialsCombinedHuddleVtc1Room.cs b/src/PepperDash.Essentials/Room/Types/EssentialsCombinedHuddleVtc1Room.cs index 46d481ef..8be5508e 100644 --- a/src/PepperDash.Essentials/Room/Types/EssentialsCombinedHuddleVtc1Room.cs +++ b/src/PepperDash.Essentials/Room/Types/EssentialsCombinedHuddleVtc1Room.cs @@ -228,66 +228,66 @@ namespace PepperDash.Essentials } } - void Initialize() + public override void Initialize() { try { - if (DefaultAudioDevice is IBasicVolumeControls) - DefaultVolumeControls = DefaultAudioDevice as IBasicVolumeControls; - else if (DefaultAudioDevice is IHasVolumeDevice) - DefaultVolumeControls = (DefaultAudioDevice as IHasVolumeDevice).VolumeDevice; - CurrentVolumeControls = DefaultVolumeControls; + //if (DefaultAudioDevice is IBasicVolumeControls) + // DefaultVolumeControls = DefaultAudioDevice as IBasicVolumeControls; + //else if (DefaultAudioDevice is IHasVolumeDevice) + // DefaultVolumeControls = (DefaultAudioDevice as IHasVolumeDevice).VolumeDevice; + //CurrentVolumeControls = DefaultVolumeControls; - // Combines call feedback from both codecs if available - InCallFeedback = new BoolFeedback(() => - { - bool inAudioCall = false; - bool inVideoCall = false; + //// Combines call feedback from both codecs if available + //InCallFeedback = new BoolFeedback(() => + //{ + // bool inAudioCall = false; + // bool inVideoCall = false; - if (AudioCodec != null) - inAudioCall = AudioCodec.IsInCall; + // if (AudioCodec != null) + // inAudioCall = AudioCodec.IsInCall; - if (VideoCodec != null) - inVideoCall = VideoCodec.IsInCall; + // if (VideoCodec != null) + // inVideoCall = VideoCodec.IsInCall; - if (inAudioCall || inVideoCall) - return true; - else - return false; - }); + // if (inAudioCall || inVideoCall) + // return true; + // else + // return false; + //}); - SetupDisplays(); + //SetupDisplays(); - // Get Microphone Privacy object, if any MUST HAPPEN AFTER setting InCallFeedback - this.MicrophonePrivacy = EssentialsRoomConfigHelper.GetMicrophonePrivacy(PropertiesConfig, this); + //// Get Microphone Privacy object, if any MUST HAPPEN AFTER setting InCallFeedback + //this.MicrophonePrivacy = EssentialsRoomConfigHelper.GetMicrophonePrivacy(PropertiesConfig, this); - Debug.Console(2, this, "Microphone Privacy Config evaluated."); + //Debug.Console(2, this, "Microphone Privacy Config evaluated."); - // Get emergency object, if any - this.Emergency = EssentialsRoomConfigHelper.GetEmergency(PropertiesConfig, this); + //// Get emergency object, if any + //this.Emergency = EssentialsRoomConfigHelper.GetEmergency(PropertiesConfig, this); - Debug.Console(2, this, "Emergency Config evaluated."); + //Debug.Console(2, this, "Emergency Config evaluated."); - VideoCodec.CallStatusChange += (o, a) => this.InCallFeedback.FireUpdate(); - VideoCodec.IsReadyChange += (o, a) => { this.SetCodecExternalSources(); SetCodecBranding(); }; + //VideoCodec.CallStatusChange += (o, a) => this.InCallFeedback.FireUpdate(); + //VideoCodec.IsReadyChange += (o, a) => { this.SetCodecExternalSources(); SetCodecBranding(); }; - if (AudioCodec != null) - AudioCodec.CallStatusChange += (o, a) => this.InCallFeedback.FireUpdate(); + //if (AudioCodec != null) + // AudioCodec.CallStatusChange += (o, a) => this.InCallFeedback.FireUpdate(); - IsSharingFeedback = new BoolFeedback(() => VideoCodec.SharingContentIsOnFeedback.BoolValue); - VideoCodec.SharingContentIsOnFeedback.OutputChange += (o, a) => this.IsSharingFeedback.FireUpdate(); + //IsSharingFeedback = new BoolFeedback(() => VideoCodec.SharingContentIsOnFeedback.BoolValue); + //VideoCodec.SharingContentIsOnFeedback.OutputChange += (o, a) => this.IsSharingFeedback.FireUpdate(); - // link privacy to VC (for now?) - PrivacyModeIsOnFeedback = new BoolFeedback(() => VideoCodec.PrivacyModeIsOnFeedback.BoolValue); - VideoCodec.PrivacyModeIsOnFeedback.OutputChange += (o, a) => this.PrivacyModeIsOnFeedback.FireUpdate(); + //// link privacy to VC (for now?) + //PrivacyModeIsOnFeedback = new BoolFeedback(() => VideoCodec.PrivacyModeIsOnFeedback.BoolValue); + //VideoCodec.PrivacyModeIsOnFeedback.OutputChange += (o, a) => this.PrivacyModeIsOnFeedback.FireUpdate(); - CallTypeFeedback = new IntFeedback(() => 0); + //CallTypeFeedback = new IntFeedback(() => 0); SetSourceListKey(); - EnablePowerOnToLastSource = true; + //EnablePowerOnToLastSource = true; } catch (Exception e) { @@ -299,7 +299,9 @@ namespace PepperDash.Essentials { //DefaultDisplay = DeviceManager.GetDeviceForKey(PropertiesConfig.DefaultDisplayKey) as IRoutingSinkWithSwitching; - var destinationList = ConfigReader.ConfigObject.DestinationLists[PropertiesConfig.DestinationListKey]; + var destinationList = ConfigReader.ConfigObject.DestinationLists[PropertiesConfig.DestinationListKey]; + + Displays.Clear(); foreach (var destination in destinationList) { @@ -316,37 +318,54 @@ namespace PepperDash.Essentials // Link power, warming, cooling to display var dispTwoWay = display as IHasPowerControlWithFeedback; if (dispTwoWay != null) - { - dispTwoWay.PowerIsOnFeedback.OutputChange += (o, a) => - { - if (dispTwoWay.PowerIsOnFeedback.BoolValue != OnFeedback.BoolValue) - { - //if (!dispTwoWay.PowerIsOnFeedback.BoolValue) - // CurrentSourceInfo = null; - OnFeedback.FireUpdate(); - } - if (dispTwoWay.PowerIsOnFeedback.BoolValue) - { - SetDefaultLevels(); - } - }; - } - - display.IsWarmingUpFeedback.OutputChange += (o, a) => - { - IsWarmingUpFeedback.FireUpdate(); - if (!IsWarmingUpFeedback.BoolValue) - (CurrentVolumeControls as IBasicVolumeWithFeedback).SetVolume(DefaultVolume); - }; - display.IsCoolingDownFeedback.OutputChange += (o, a) => - { - IsCoolingDownFeedback.FireUpdate(); - }; + { + dispTwoWay.PowerIsOnFeedback.OutputChange -= PowerIsOnFeedback_OutputChange; + dispTwoWay.PowerIsOnFeedback.OutputChange += PowerIsOnFeedback_OutputChange; + + if (dispTwoWay.PowerIsOnFeedback.BoolValue) + { + SetDefaultLevels(); + } + } + + display.IsWarmingUpFeedback.OutputChange -= IsWarmingUpFeedback_OutputChange; + display.IsWarmingUpFeedback.OutputChange += IsWarmingUpFeedback_OutputChange; + + display.IsCoolingDownFeedback.OutputChange -= IsCoolingDownFeedback_OutputChange; + display.IsCoolingDownFeedback.OutputChange += IsCoolingDownFeedback_OutputChange; } } + } + + void IsCoolingDownFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + IsCoolingDownFeedback.FireUpdate(); + } + + void IsWarmingUpFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + IsWarmingUpFeedback.FireUpdate(); + if (!IsWarmingUpFeedback.BoolValue) + (CurrentVolumeControls as IBasicVolumeWithFeedback).SetVolume(DefaultVolume); + } + + void PowerIsOnFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + var dispTwoWay = sender as IHasPowerControlWithFeedback; + + if (dispTwoWay != null && dispTwoWay.PowerIsOnFeedback.BoolValue != OnFeedback.BoolValue) + { + //if (!dispTwoWay.PowerIsOnFeedback.BoolValue) + // CurrentSourceInfo = null; + OnFeedback.FireUpdate(); + } } + + + + private void SetSourceListKey() { if (!string.IsNullOrEmpty(PropertiesConfig.SourceListKey)) @@ -356,9 +375,9 @@ namespace PepperDash.Essentials else { SetSourceListKey(Key); - } - - SetCodecExternalSources(); + } + + SetUpVideoCodec(); } protected override void CustomSetConfig(DeviceConfig config) @@ -369,26 +388,150 @@ namespace PepperDash.Essentials PropertiesConfig = newPropertiesConfig; ConfigWriter.UpdateRoomConfig(config); + } + + public override bool Deactivate() + { + // Stop listining to this event when room deactivated + VideoCodec.IsReadyChange -= VideoCodec_IsReadyChange; + + // Clear occupancy + RoomOccupancy = null; + + Debug.Console(0, this, "Room '{0}' Deactivated", Name); + + return base.Deactivate(); } public override bool CustomActivate() - { - // Add Occupancy object from config - if (PropertiesConfig.Occupancy != null) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Setting Occupancy Provider for room"); - this.SetRoomOccupancy(DeviceManager.GetDeviceForKey(PropertiesConfig.Occupancy.DeviceKey) as - IOccupancyStatusProvider, PropertiesConfig.Occupancy.TimeoutMinutes); - } - - this.LogoUrlLightBkgnd = PropertiesConfig.LogoLight.GetLogoUrlLight(); - this.LogoUrlDarkBkgnd = PropertiesConfig.LogoDark.GetLogoUrlDark(); - - this.DefaultSourceItem = PropertiesConfig.DefaultSourceItem; - this.DefaultVolume = (ushort)(PropertiesConfig.Volumes.Master.Level * 65535 / 100); - + { + try + { + if (DefaultAudioDevice is IBasicVolumeControls) + DefaultVolumeControls = DefaultAudioDevice as IBasicVolumeControls; + else if (DefaultAudioDevice is IHasVolumeDevice) + DefaultVolumeControls = (DefaultAudioDevice as IHasVolumeDevice).VolumeDevice; + CurrentVolumeControls = DefaultVolumeControls; + + + // Combines call feedback from both codecs if available + InCallFeedback = new BoolFeedback(() => + { + bool inAudioCall = false; + bool inVideoCall = false; + + if (AudioCodec != null) + inAudioCall = AudioCodec.IsInCall; + + if (VideoCodec != null) + inVideoCall = VideoCodec.IsInCall; + + if (inAudioCall || inVideoCall) + return true; + else + return false; + }); + + SetupDisplays(); + + // Get Microphone Privacy object, if any MUST HAPPEN AFTER setting InCallFeedback + this.MicrophonePrivacy = EssentialsRoomConfigHelper.GetMicrophonePrivacy(PropertiesConfig, this); + + Debug.Console(2, this, "Microphone Privacy Config evaluated."); + + // Get emergency object, if any + this.Emergency = EssentialsRoomConfigHelper.GetEmergency(PropertiesConfig, this); + + Debug.Console(2, this, "Emergency Config evaluated."); + + if (AudioCodec != null) + { + AudioCodec.CallStatusChange -= AudioCodec_CallStatusChange; + AudioCodec.CallStatusChange += AudioCodec_CallStatusChange; + } + + VideoCodec.CallStatusChange -= VideoCodec_CallStatusChange; + VideoCodec.CallStatusChange += VideoCodec_CallStatusChange; + + VideoCodec.IsReadyChange -= VideoCodec_IsReadyChange; + VideoCodec.IsReadyChange += VideoCodec_IsReadyChange; + + VideoCodec.SharingContentIsOnFeedback.OutputChange -= SharingContentIsOnFeedback_OutputChange; + VideoCodec.SharingContentIsOnFeedback.OutputChange += SharingContentIsOnFeedback_OutputChange; + + + IsSharingFeedback = new BoolFeedback(() => VideoCodec.SharingContentIsOnFeedback.BoolValue); + + // link privacy to VC (for now?) + PrivacyModeIsOnFeedback = new BoolFeedback(() => VideoCodec.PrivacyModeIsOnFeedback.BoolValue); + + VideoCodec.PrivacyModeIsOnFeedback.OutputChange -= PrivacyModeIsOnFeedback_OutputChange; + VideoCodec.PrivacyModeIsOnFeedback.OutputChange += PrivacyModeIsOnFeedback_OutputChange; + + CallTypeFeedback = new IntFeedback(() => 0); + + SetSourceListKey(); + + EnablePowerOnToLastSource = true; + + + // Add Occupancy object from config + if (PropertiesConfig.Occupancy != null) + { + Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Setting Occupancy Provider for room"); + this.SetRoomOccupancy(DeviceManager.GetDeviceForKey(PropertiesConfig.Occupancy.DeviceKey) as + IOccupancyStatusProvider, PropertiesConfig.Occupancy.TimeoutMinutes); + } + + this.LogoUrlLightBkgnd = PropertiesConfig.LogoLight.GetLogoUrlLight(); + this.LogoUrlDarkBkgnd = PropertiesConfig.LogoDark.GetLogoUrlDark(); + + this.DefaultSourceItem = PropertiesConfig.DefaultSourceItem; + this.DefaultVolume = (ushort)(PropertiesConfig.Volumes.Master.Level * 65535 / 100); + + } + catch (Exception e) + { + Debug.Console(0, this, "Error Activiating Room: {0}", e); + } + + + Debug.Console(0, this, "Room '{0}' Activated", Name); return base.CustomActivate(); - } + } + + void AudioCodec_CallStatusChange(object sender, CodecCallStatusItemChangeEventArgs e) + { + InCallFeedback.FireUpdate(); + } + + void PrivacyModeIsOnFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + PrivacyModeIsOnFeedback.FireUpdate(); + } + + void VideoCodec_IsReadyChange(object sender, EventArgs e) + { + SetUpVideoCodec(); + } + + void SetUpVideoCodec() + { + SetCodecExternalSources(); + SetCodecBranding(); + } + + void VideoCodec_CallStatusChange(object sender, CodecCallStatusItemChangeEventArgs e) + { + InCallFeedback.FireUpdate(); + } + + void SharingContentIsOnFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + IsSharingFeedback.FireUpdate(); + } + + /// /// @@ -781,7 +924,9 @@ namespace PepperDash.Essentials videoCodecWithExternalSwitching.AddExternalSource(codecInputConnectorName, kvp.Key, srcConfig.PreferredName, PepperDash.Essentials.Devices.Common.VideoCodec.Cisco.eExternalSourceType.desktop); videoCodecWithExternalSwitching.SetExternalSourceState(kvp.Key, PepperDash.Essentials.Devices.Common.VideoCodec.Cisco.eExternalSourceMode.Ready); } - } + } + + Debug.Console(1, this, "Successfully set up codec external sources for room: {0}", Name); } catch (Exception e) { diff --git a/src/PepperDash.Essentials/Room/Types/EssentialsHuddleVtc1Room.cs b/src/PepperDash.Essentials/Room/Types/EssentialsHuddleVtc1Room.cs index c2942914..9c8c87e1 100644 --- a/src/PepperDash.Essentials/Room/Types/EssentialsHuddleVtc1Room.cs +++ b/src/PepperDash.Essentials/Room/Types/EssentialsHuddleVtc1Room.cs @@ -21,6 +21,8 @@ namespace PepperDash.Essentials { public class EssentialsHuddleVtc1Room : EssentialsRoomBase, IEssentialsHuddleVtc1Room { + private IEssentialsRoomCombiner _roomCombiner; + private bool _codecExternalSourceChange; public event EventHandler CurrentVolumeDeviceChange; public event SourceInfoChangeHandler CurrentSourceChange; @@ -236,7 +238,7 @@ namespace PepperDash.Essentials throw new ArgumentNullException("DefaultAudioDevice cannot be null"); } - InitializeRoom(); + Initialize(); } catch (Exception e) { @@ -244,8 +246,65 @@ namespace PepperDash.Essentials } } - void InitializeRoom() - { + + private void SetupEnvironmentalControlDevices() + { + if (PropertiesConfig.Environment != null) + { + if (PropertiesConfig.Environment.Enabled) + { + EnvironmentalControlDevices.Clear(); + + foreach (var d in PropertiesConfig.Environment.DeviceKeys) + { + var envDevice = DeviceManager.GetDeviceForKey(d) as EssentialsDevice; + EnvironmentalControlDevices.Add(envDevice); + } + } + } + } + + + private void SetSourceListKey() + { + if (!string.IsNullOrEmpty(PropertiesConfig.SourceListKey)) + { + SetSourceListKey(PropertiesConfig.SourceListKey); + } + else + { + SetSourceListKey(Key); + } + + SetUpVideoCodec(); + } + + protected override void CustomSetConfig(DeviceConfig config) + { + var newPropertiesConfig = JsonConvert.DeserializeObject(config.Properties.ToString()); + + if (newPropertiesConfig != null) + PropertiesConfig = newPropertiesConfig; + + ConfigWriter.UpdateRoomConfig(config); + } + + public override bool Deactivate() + { + + // Stop listining to this event when room deactivated + VideoCodec.IsReadyChange -= VideoCodec_IsReadyChange; + + // Clear occupancy + RoomOccupancy = null; + + Debug.Console(0, this, "Room '{0}' Deactivated", Name); + + return base.Deactivate(); + } + + public override bool CustomActivate() + { try { if (DefaultAudioDevice is IBasicVolumeControls) @@ -280,32 +339,15 @@ namespace PepperDash.Essentials var dispTwoWay = disp as IHasPowerControlWithFeedback; if (dispTwoWay != null) { - dispTwoWay.PowerIsOnFeedback.OutputChange += (o, a) => - { - if (dispTwoWay.PowerIsOnFeedback.BoolValue != OnFeedback.BoolValue) - { - if (!dispTwoWay.PowerIsOnFeedback.BoolValue) - CurrentSourceInfo = null; - OnFeedback.FireUpdate(); - } - if (dispTwoWay.PowerIsOnFeedback.BoolValue) - { - SetDefaultLevels(); - } - }; + dispTwoWay.PowerIsOnFeedback.OutputChange -= PowerIsOnFeedback_OutputChange; + dispTwoWay.PowerIsOnFeedback.OutputChange += PowerIsOnFeedback_OutputChange; } - disp.IsWarmingUpFeedback.OutputChange += (o, a) => - { - IsWarmingUpFeedback.FireUpdate(); - if (!IsWarmingUpFeedback.BoolValue) - (CurrentVolumeControls as IBasicVolumeWithFeedback).SetVolume(DefaultVolume); - }; - disp.IsCoolingDownFeedback.OutputChange += (o, a) => - { - IsCoolingDownFeedback.FireUpdate(); - }; + disp.IsWarmingUpFeedback.OutputChange -= IsWarmingUpFeedback_OutputChange; + disp.IsWarmingUpFeedback.OutputChange += IsWarmingUpFeedback_OutputChange; + disp.IsCoolingDownFeedback.OutputChange -= IsCoolingDownFeedback_OutputChange; + disp.IsCoolingDownFeedback.OutputChange += IsCoolingDownFeedback_OutputChange; } @@ -319,20 +361,30 @@ namespace PepperDash.Essentials this.Emergency = EssentialsRoomConfigHelper.GetEmergency(PropertiesConfig, this); Debug.Console(2, this, "Emergency Config evaluated."); - - - VideoCodec.CallStatusChange += (o, a) => this.InCallFeedback.FireUpdate(); - VideoCodec.IsReadyChange += (o, a) => { this.SetCodecExternalSources(); SetCodecBranding(); }; - + if (AudioCodec != null) - AudioCodec.CallStatusChange += (o, a) => this.InCallFeedback.FireUpdate(); + { + AudioCodec.CallStatusChange -= AudioCodec_CallStatusChange; + AudioCodec.CallStatusChange += AudioCodec_CallStatusChange; + } + + VideoCodec.CallStatusChange -= VideoCodec_CallStatusChange; + VideoCodec.CallStatusChange += VideoCodec_CallStatusChange; + + VideoCodec.IsReadyChange -= VideoCodec_IsReadyChange; + VideoCodec.IsReadyChange += VideoCodec_IsReadyChange; + + VideoCodec.SharingContentIsOnFeedback.OutputChange -= SharingContentIsOnFeedback_OutputChange; + VideoCodec.SharingContentIsOnFeedback.OutputChange += SharingContentIsOnFeedback_OutputChange; + IsSharingFeedback = new BoolFeedback(() => VideoCodec.SharingContentIsOnFeedback.BoolValue); - VideoCodec.SharingContentIsOnFeedback.OutputChange += (o, a) => this.IsSharingFeedback.FireUpdate(); // link privacy to VC (for now?) PrivacyModeIsOnFeedback = new BoolFeedback(() => VideoCodec.PrivacyModeIsOnFeedback.BoolValue); - VideoCodec.PrivacyModeIsOnFeedback.OutputChange += (o, a) => this.PrivacyModeIsOnFeedback.FireUpdate(); + + VideoCodec.PrivacyModeIsOnFeedback.OutputChange -= PrivacyModeIsOnFeedback_OutputChange; + VideoCodec.PrivacyModeIsOnFeedback.OutputChange += PrivacyModeIsOnFeedback_OutputChange; CallTypeFeedback = new IntFeedback(() => 0); @@ -341,72 +393,92 @@ namespace PepperDash.Essentials SetSourceListKey(); EnablePowerOnToLastSource = true; + + + // Add Occupancy object from config + if (PropertiesConfig.Occupancy != null) + { + Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Setting Occupancy Provider for room"); + this.SetRoomOccupancy(DeviceManager.GetDeviceForKey(PropertiesConfig.Occupancy.DeviceKey) as + IOccupancyStatusProvider, PropertiesConfig.Occupancy.TimeoutMinutes); + } + + this.LogoUrlLightBkgnd = PropertiesConfig.LogoLight.GetLogoUrlLight(); + this.LogoUrlDarkBkgnd = PropertiesConfig.LogoDark.GetLogoUrlDark(); + + this.DefaultSourceItem = PropertiesConfig.DefaultSourceItem; + this.DefaultVolume = (ushort)(PropertiesConfig.Volumes.Master.Level * 65535 / 100); } catch (Exception e) { - Debug.Console(0, this, "Error Initializing Room: {0}", e); - } - } - - private void SetupEnvironmentalControlDevices() - { - if (PropertiesConfig.Environment != null) - { - if (PropertiesConfig.Environment.Enabled) - { - foreach (var d in PropertiesConfig.Environment.DeviceKeys) - { - var envDevice = DeviceManager.GetDeviceForKey(d) as EssentialsDevice; - EnvironmentalControlDevices.Add(envDevice); - } - } - } - } - - - private void SetSourceListKey() - { - if (!string.IsNullOrEmpty(PropertiesConfig.SourceListKey)) - { - SetSourceListKey(PropertiesConfig.SourceListKey); - } - else - { - SetSourceListKey(Key); + Debug.Console(0, this, "Error Activiating Room: {0}", e); } - SetCodecExternalSources(); - } - - protected override void CustomSetConfig(DeviceConfig config) - { - var newPropertiesConfig = JsonConvert.DeserializeObject(config.Properties.ToString()); - - if (newPropertiesConfig != null) - PropertiesConfig = newPropertiesConfig; - - ConfigWriter.UpdateRoomConfig(config); - } - - public override bool CustomActivate() - { - // Add Occupancy object from config - if (PropertiesConfig.Occupancy != null) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Setting Occupancy Provider for room"); - this.SetRoomOccupancy(DeviceManager.GetDeviceForKey(PropertiesConfig.Occupancy.DeviceKey) as - IOccupancyStatusProvider, PropertiesConfig.Occupancy.TimeoutMinutes); - } - - this.LogoUrlLightBkgnd = PropertiesConfig.LogoLight.GetLogoUrlLight(); - this.LogoUrlDarkBkgnd = PropertiesConfig.LogoDark.GetLogoUrlDark(); - - this.DefaultSourceItem = PropertiesConfig.DefaultSourceItem; - this.DefaultVolume = (ushort)(PropertiesConfig.Volumes.Master.Level * 65535 / 100); - + Debug.Console(0, this, "Room '{0}' Activated", Name); return base.CustomActivate(); } + void PrivacyModeIsOnFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + PrivacyModeIsOnFeedback.FireUpdate(); + } + + void SharingContentIsOnFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + IsSharingFeedback.FireUpdate(); + } + + void AudioCodec_CallStatusChange(object sender, CodecCallStatusItemChangeEventArgs e) + { + InCallFeedback.FireUpdate(); + } + + void VideoCodec_IsReadyChange(object sender, EventArgs e) + { + SetUpVideoCodec(); + } + + void SetUpVideoCodec() + { + SetCodecExternalSources(); + SetCodecBranding(); + } + + void VideoCodec_CallStatusChange(object sender, CodecCallStatusItemChangeEventArgs e) + { + InCallFeedback.FireUpdate(); + } + + void IsCoolingDownFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + IsCoolingDownFeedback.FireUpdate(); + } + + void IsWarmingUpFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + IsWarmingUpFeedback.FireUpdate(); + if (!IsWarmingUpFeedback.BoolValue) + (CurrentVolumeControls as IBasicVolumeWithFeedback).SetVolume(DefaultVolume); + + } + + void PowerIsOnFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + var dispTwoWay = DefaultDisplay as IHasPowerControlWithFeedback; + + if (dispTwoWay.PowerIsOnFeedback.BoolValue != OnFeedback.BoolValue) + { + if (!dispTwoWay.PowerIsOnFeedback.BoolValue) + CurrentSourceInfo = null; + OnFeedback.FireUpdate(); + } + if (dispTwoWay.PowerIsOnFeedback.BoolValue) + { + SetDefaultLevels(); + } + + } + /// @@ -834,6 +906,8 @@ namespace PepperDash.Essentials videoCodecWithExternalSwitching.SetExternalSourceState(kvp.Key, PepperDash.Essentials.Devices.Common.VideoCodec.Cisco.eExternalSourceMode.Ready); } } + Debug.Console(1, this, "Successfully set up codec external sources for room: {0}", Name); + } catch (Exception e) { diff --git a/src/PepperDash.Essentials/Room/Types/Interfaces/IEssentialsHuddleSpaceRoom.cs b/src/PepperDash.Essentials/Room/Types/Interfaces/IEssentialsHuddleSpaceRoom.cs index 41616d96..dccae06a 100644 --- a/src/PepperDash.Essentials/Room/Types/Interfaces/IEssentialsHuddleSpaceRoom.cs +++ b/src/PepperDash.Essentials/Room/Types/Interfaces/IEssentialsHuddleSpaceRoom.cs @@ -7,7 +7,8 @@ using PepperDash.Essentials.Room.Config; namespace PepperDash.Essentials { - public interface IEssentialsHuddleSpaceRoom : IEssentialsRoom, IHasCurrentSourceInfoChange, IRunRouteAction, IRunDefaultPresentRoute, IHasDefaultDisplay, IHasCurrentVolumeControls + public interface IEssentialsHuddleSpaceRoom : IEssentialsRoom, IHasCurrentSourceInfoChange, IRunRouteAction, IRunDefaultPresentRoute, IHasDefaultDisplay, IHasCurrentVolumeControls, IRoomOccupancy, + IEmergency, IMicrophonePrivacy { bool ExcludeFromGlobalFunctions { get; } diff --git a/src/PepperDash.Essentials/Room/Types/Interfaces/IEssentialsHuddleVtc1Room.cs b/src/PepperDash.Essentials/Room/Types/Interfaces/IEssentialsHuddleVtc1Room.cs index 03f7340b..85937828 100644 --- a/src/PepperDash.Essentials/Room/Types/Interfaces/IEssentialsHuddleVtc1Room.cs +++ b/src/PepperDash.Essentials/Room/Types/Interfaces/IEssentialsHuddleVtc1Room.cs @@ -8,7 +8,8 @@ using PepperDash.Essentials.Devices.Common.AudioCodec; namespace PepperDash.Essentials { public interface IEssentialsHuddleVtc1Room : IEssentialsRoom, IHasCurrentSourceInfoChange, - IPrivacy, IHasCurrentVolumeControls, IRunRouteAction, IRunDefaultCallRoute, IHasVideoCodec, IHasAudioCodec, IHasDefaultDisplay, IHasInCallFeedback + IPrivacy, IHasCurrentVolumeControls, IRunRouteAction, IRunDefaultCallRoute, IHasVideoCodec, IHasAudioCodec, IHasDefaultDisplay, IHasInCallFeedback, + IRoomOccupancy, IEmergency, IMicrophonePrivacy { EssentialsHuddleVtc1PropertiesConfig PropertiesConfig { get; }