From a3887510dfabb16ebd05dcb8686617109f9ebe4c Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Wed, 24 Jul 2019 22:44:39 -0600 Subject: [PATCH] Additional progress after initial testing. Having issues iterating CrestronControlSystem.SwitcherInputs/Outputs collections. --- PepperDashEssentials/ControlSystem.cs | 16 +++++- .../Chassis/DmpsRoutingController.cs | 54 +++++++++++++------ .../Essentials_DM/Config/DmpsRoutingConfig.cs | 6 +++ 3 files changed, 60 insertions(+), 16 deletions(-) diff --git a/PepperDashEssentials/ControlSystem.cs b/PepperDashEssentials/ControlSystem.cs index 1325ea3e..795a4228 100644 --- a/PepperDashEssentials/ControlSystem.cs +++ b/PepperDashEssentials/ControlSystem.cs @@ -356,8 +356,22 @@ namespace PepperDash.Essentials public void LoadDevices() { // Build the processor wrapper class + DeviceManager.AddDevice(new PepperDash.Essentials.Core.Devices.CrestronProcessor("processor")); + // 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); + + var dmpsRoutingController = DmpsRoutingController.GetDmpsRoutingController("processor-avRouting", this.ControllerPrompt, new DM.Config.DmpsRoutingPropertiesConfig()); + DeviceManager.AddDevice(dmpsRoutingController); + } + else + { + Debug.Console(2, "************Processor is not DMPS type***************"); + } + // Add global System Monitor device DeviceManager.AddDevice(new PepperDash.Essentials.Core.Monitoring.SystemMonitorController("systemMonitor")); @@ -373,7 +387,7 @@ namespace PepperDash.Essentials if (devConf.Type.ToLower() != Global.ControlSystem.ControllerPrompt.ToLower()) Debug.Console(0, "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()); + devConf.Type.ToUpper(), Global.ControlSystem.ControllerPrompt.ToUpper()); continue; } diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs index 0811ee61..35c32fd7 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs @@ -49,14 +49,12 @@ namespace PepperDash.Essentials.DM Dictionary RouteOffTimers = new Dictionary(); public static DmpsRoutingController GetDmpsRoutingController(string key, string name, - string type, DmpsRoutingPropertiesConfig properties) + DmpsRoutingPropertiesConfig properties) { try { ISystemControl systemControl = null; - - type = type.ToLower(); - + systemControl = Global.ControlSystem.SystemControl as ISystemControl; if (systemControl == null) @@ -90,8 +88,8 @@ namespace PepperDash.Essentials.DM : base(key, name) { Dmps = Global.ControlSystem; - SystemControl = systemControl; + InputPorts = new RoutingPortCollection(); OutputPorts = new RoutingPortCollection(); VolumeControls = new Dictionary(); @@ -112,13 +110,27 @@ namespace PepperDash.Essentials.DM Dmps.DMOutputChange +=new DMOutputEventHandler(Dmps_DMOutputChange); // Default to EnableAudioBreakaway - SystemControl.EnableAudioBreakaway.BoolValue = true; + //SystemControl.EnableAudioBreakaway. = true; - for (uint x = 1; x <= Dmps.NumberOfSwitcherOutputs; x++) + Debug.Console(1, this, "{0} Switcher Inputs Present.", Dmps.NumberOfSwitcherInputs); + Debug.Console(1, this, "{0} Switcher Outputs Present.", Dmps.NumberOfSwitcherOutputs); + + + + uint tempX = 1; + + foreach (var card in Dmps.SwitcherOutputs) { - var tempX = x; + Debug.Console(1, this, "Output Card Type: {0}", card.CardInputOutputType); - Card.Dmps3OutputBase outputCard = Dmps.SwitcherOutputs[tempX] as Card.Dmps3OutputBase; + var outputCard = card as Card.Dmps3OutputBase; + //} + + //for (uint x = 1; x <= Dmps.NumberOfSwitcherOutputs; x++) + //{ + //var tempX = x; + + //Card.Dmps3OutputBase outputCard = Dmps.SwitcherOutputs[tempX] as Card.Dmps3OutputBase; if (outputCard != null) { @@ -170,15 +182,25 @@ namespace PepperDash.Essentials.DM OutputEndpointOnlineFeedbacks[tempX] = new BoolFeedback(() => { return outputCard.EndpointOnlineFeedback; }); - AddOutputCard(tempX, outputCard); + AddOutputCard(tempX, outputCard); + + tempX++; } } - for (uint x = 1; x <= Dmps.NumberOfSwitcherInputs; x++) - { - var tempX = x; + tempX = 1; - DMInput inputCard = Dmps.SwitcherInputs[tempX] as DMInput; + foreach (var card in Dmps.SwitcherInputs) + { + var inputCard = card as DMInput; + + Debug.Console(1, this, "Output Card Type: {0}", card.CardInputOutputType); + + //for (uint x = 1; x <= Dmps.NumberOfSwitcherInputs; x++) + //{ + // var tempX = x; + + // DMInput inputCard = Dmps.SwitcherInputs[tempX] as DMInput; if (inputCard != null) { @@ -200,6 +222,8 @@ namespace PepperDash.Essentials.DM } }); } + + AddInputCard(tempX, inputCard); } } @@ -388,7 +412,7 @@ namespace PepperDash.Essentials.DM { case (DMInputEventIds.OnlineFeedbackEventId): { - Debug.Console(2, this, "DMINput OnlineFeedbackEventId for input: {0}. State: {1}", args.Number, device.Inputs[args.Number].EndpointOnlineFeedback); + Debug.Console(2, this, "DM Input OnlineFeedbackEventId for input: {0}. State: {1}", args.Number, device.Inputs[args.Number].EndpointOnlineFeedback); InputEndpointOnlineFeedbacks[args.Number].FireUpdate(); break; } diff --git a/essentials-framework/Essentials DM/Essentials_DM/Config/DmpsRoutingConfig.cs b/essentials-framework/Essentials DM/Essentials_DM/Config/DmpsRoutingConfig.cs index b57018d8..57dd4a72 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Config/DmpsRoutingConfig.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Config/DmpsRoutingConfig.cs @@ -19,6 +19,12 @@ namespace PepperDash.Essentials.DM.Config [JsonProperty("outputNames")] public Dictionary OutputNames { get; set; } + + public DmpsRoutingPropertiesConfig() + { + InputNames = new Dictionary(); + OutputNames = new Dictionary(); + } }