diff --git a/src/PepperDash.Essentials.DM/AirMedia/AirMediaController.cs b/src/PepperDash.Essentials.DM/AirMedia/AirMediaController.cs deleted file mode 100644 index c26e8bc3..00000000 --- a/src/PepperDash.Essentials.DM/AirMedia/AirMediaController.cs +++ /dev/null @@ -1,410 +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 Am3x00 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, Am3x00 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(() => AirMedia.AirMedia.StatusFeedback.UShortValue == 0); - ErrorFeedback = new IntFeedback(() => AirMedia.AirMedia.ErrorFeedback.UShortValue); - NumberOfUsersConnectedFeedback = new IntFeedback(() => AirMedia.AirMedia.NumberOfUsersConnectedFeedback.UShortValue); - LoginCodeFeedback = new IntFeedback(() => AirMedia.AirMedia.LoginCodeFeedback.UShortValue); - ConnectionAddressFeedback = new StringFeedback(() => AirMedia.AirMedia.ConnectionAddressFeedback.StringValue); - HostnameFeedback = new StringFeedback(() => AirMedia.AirMedia.HostNameFeedback.StringValue); - - // TODO: Figure out if we can actually get the TSID/Serial - SerialNumberFeedback = new StringFeedback(() => "unknown"); - - AirMedia.DisplayControl.DisplayControlChange += DisplayControl_DisplayControlChange; - - VideoOutFeedback = new IntFeedback(() => Convert.ToInt16(AirMedia.DisplayControl.VideoOutFeedback)); - AutomaticInputRoutingEnabledFeedback = new BoolFeedback(() => AirMedia.DisplayControl.EnableAutomaticRoutingFeedback.BoolValue); - - // Not all AirMedia versions support HDMI In like the 3200 - if (AirMedia.HdmiIn != null) - { - AirMedia.HdmiIn.StreamChange += HdmiIn_StreamChange; - HdmiVideoSyncDetectedFeedback = new BoolFeedback(() => AirMedia.HdmiIn.SyncDetectedFeedback.BoolValue); - return; - } - - // Return false if the AirMedia device doesn't support HDMI Input - HdmiVideoSyncDetectedFeedback = new BoolFeedback(() => false); - } - - 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 handler = NumericSwitchChange; - - if (handler == null) return; - - handler(this, e); - } - - - void AirMedia_AirMediaChange(object sender, Crestron.SimplSharpPro.DeviceSupport.GenericEventArgs args) - { - switch (args.EventId) - { - case AirMediaInputSlot.AirMediaStatusFeedbackEventId: - { - IsInSessionFeedback.FireUpdate(); - break; - } - case AirMediaInputSlot.AirMediaErrorFeedbackEventId: - { - ErrorFeedback.FireUpdate(); - break; - } - case AirMediaInputSlot.AirMediaNumberOfUserConnectedEventId: - { - NumberOfUsersConnectedFeedback.FireUpdate(); - break; - } - case AirMediaInputSlot.AirMediaLoginCodeEventId: - { - LoginCodeFeedback.FireUpdate(); - break; - } - case AirMediaInputSlot.AirMediaConnectionAddressFeedbackEventId: - { - ConnectionAddressFeedback.FireUpdate(); - break; - } - case AirMediaInputSlot.AirMediaHostNameFeedbackEventId: - { - HostnameFeedback.FireUpdate(); - break; - } - } - } - - void DisplayControl_DisplayControlChange(object sender, Crestron.SimplSharpPro.DeviceSupport.GenericEventArgs args) - { - VideoOutFeedback.FireUpdate(); - - var localInputPort = - InputPorts.FirstOrDefault(p => (int) p.FeedbackMatchObject == VideoOutFeedback.UShortValue); - - OnSwitchChange(new RoutingNumericEventArgs(1, VideoOutFeedback.UShortValue, OutputPorts.First(), - localInputPort, eRoutingSignalType.AudioVideo)); - - 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", "am3200" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - var type = dc.Type.ToLower(); - - Debug.Console(1, "Factory Attempting to create new AirMedia Device"); - - var props = dc.Properties.ToObject(); - Am3x00 amDevice = null; - switch (type) - { - case "am200" : - { - amDevice = new Am200(props.Control.IpIdInt, Global.ControlSystem); - break; - } - case "am300" : - { - amDevice = new Am300(props.Control.IpIdInt, Global.ControlSystem); - break; - } - case "am3200" : - { - amDevice = new Am3200(props.Control.IpIdInt, Global.ControlSystem); - break; - } - } - - 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 3cdad1b8..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, IDmSwitchWithEndpointOnlineFeedback, 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 a00f6d80..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, IDmSwitchWithEndpointOnlineFeedback, 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/Chassis/HdPsXxxController.cs b/src/PepperDash.Essentials.DM/Chassis/HdPsXxxController.cs deleted file mode 100644 index 36e99bc6..00000000 --- a/src/PepperDash.Essentials.DM/Chassis/HdPsXxxController.cs +++ /dev/null @@ -1,589 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Config; -using PepperDash_Essentials_Core.Bridges; -using PepperDash_Essentials_DM.Config; - -namespace PepperDash_Essentials_DM.Chassis -{ - [Description("Wrapper class for all HdPsXxx switchers")] - public class HdPsXxxController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback, IRoutingHasVideoInputSyncFeedbacks - { - private readonly HdPsXxx _chassis; - - public RoutingPortCollection InputPorts { get; private set; } - public RoutingPortCollection OutputPorts { get; private set; } - - public Dictionary InputNames { get; set; } - public Dictionary OutputNames { get; set; } - - public FeedbackCollection InputNameFeedbacks { get; private set; } - public FeedbackCollection InputHdcpEnableFeedback { get; private set; } - - public FeedbackCollection OutputNameFeedbacks { get; private set; } - public FeedbackCollection OutputRouteNameFeedback { get; private set; } - - public FeedbackCollection VideoInputSyncFeedbacks { get; private set; } - public FeedbackCollection VideoOutputRouteFeedbacks { get; private set; } - - public StringFeedback DeviceNameFeedback { get; private set; } - public BoolFeedback AutoRouteFeedback { get; private set; } - - public event EventHandler NumericSwitchChange; - public event EventHandler DmInputChange; - - - /// - /// Constructor - /// - /// - /// - /// HdPs401 device instance - /// - public HdPsXxxController(string key, string name, HdPsXxx chassis, HdPsXxxPropertiesConfig props) - : base(key, name, chassis) - { - _chassis = chassis; - Name = name; - - if (props == null) - { - Debug.Console(1, this, "HdPsXxxController properties are null, failed to build device"); - return; - } - - InputPorts = new RoutingPortCollection(); - InputNameFeedbacks = new FeedbackCollection(); - InputHdcpEnableFeedback = new FeedbackCollection(); - InputNames = new Dictionary(); - - OutputPorts = new RoutingPortCollection(); - OutputNameFeedbacks = new FeedbackCollection(); - OutputRouteNameFeedback = new FeedbackCollection(); - OutputNames = new Dictionary(); - - VideoInputSyncFeedbacks = new FeedbackCollection(); - VideoOutputRouteFeedbacks = new FeedbackCollection(); - - if (_chassis.NumberOfOutputs == 1) - AutoRouteFeedback = new BoolFeedback(() => _chassis.PriorityRouteOnFeedback.BoolValue); - - InputNames = props.Inputs; - SetupInputs(InputNames); - - OutputNames = props.Outputs; - SetupOutputs(OutputNames); - } - - // get input priorities - private byte[] SetInputPriorities(HdPsXxxPropertiesConfig props) - { - throw new NotImplementedException(); - } - - // input setup - private void SetupInputs(Dictionary dict) - { - if (dict == null) - { - Debug.Console(1, this, "Failed to setup inputs, properties are null"); - return; - } - - // iterate through HDMI inputs - foreach (var item in _chassis.HdmiInputs) - { - var input = item; - var index = item.Number; - var key = string.Format("hdmiIn{0}", index); - var name = string.IsNullOrEmpty(InputNames[index]) - ? string.Format("HDMI Input {0}", index) - : InputNames[index]; - - input.Name.StringValue = name; - - InputNameFeedbacks.Add(new StringFeedback(index.ToString(CultureInfo.InvariantCulture), - () => InputNames[index])); - - var port = new RoutingInputPort(key, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, input, this) - { - FeedbackMatchObject = input - }; - Debug.Console(1, this, "Adding Input port: {0} - {1}", port.Key, name); - InputPorts.Add(port); - - InputHdcpEnableFeedback.Add(new BoolFeedback(index.ToString(CultureInfo.InvariantCulture), - () => input.InputPort.HdcpSupportOnFeedback.BoolValue)); - - VideoInputSyncFeedbacks.Add(new BoolFeedback(index.ToString(CultureInfo.InvariantCulture), - () => input.VideoDetectedFeedback.BoolValue)); - } - - // iterate through DM Lite inputs - foreach (var item in _chassis.DmLiteInputs) - { - var input = item; - var index = item.Number; - var key = string.Format("dmLiteIn{0}", index); - var name = string.IsNullOrEmpty(InputNames[index]) - ? string.Format("DM Input {0}", index) - : InputNames[index]; - - input.Name.StringValue = name; - - InputNameFeedbacks.Add(new StringFeedback(index.ToString(CultureInfo.InvariantCulture), - () => InputNames[index])); - - var port = new RoutingInputPort(key, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, input, this) - { - FeedbackMatchObject = input - }; - Debug.Console(0, this, "Adding Input port: {0} - {1}", port.Key, name); - InputPorts.Add(port); - - InputHdcpEnableFeedback.Add(new BoolFeedback(index.ToString(CultureInfo.InvariantCulture), - () => input.InputPort.HdcpSupportOnFeedback.BoolValue)); - - VideoInputSyncFeedbacks.Add(new BoolFeedback(index.ToString(CultureInfo.InvariantCulture), - () => input.VideoDetectedFeedback.BoolValue)); - } - - _chassis.DMInputChange += _chassis_InputChange; - } - - // output setup - private void SetupOutputs(Dictionary dict) - { - if (dict == null) - { - Debug.Console(1, this, "Failed to setup outputs, properties are null"); - return; - } - - foreach (var item in _chassis.HdmiDmLiteOutputs) - { - var output = item; - var index = item.Number; - var name = string.IsNullOrEmpty(OutputNames[index]) - ? string.Format("Output {0}", index) - : OutputNames[index]; - - output.Name.StringValue = name; - - var hdmiKey = string.Format("hdmiOut{0}", index); - var hdmiPort = new RoutingOutputPort(hdmiKey, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, output, this) - { - FeedbackMatchObject = output, - Port = output.HdmiOutput.HdmiOutputPort - }; - Debug.Console(1, this, "Adding Output port: {0} - {1}", hdmiPort.Key, name); - OutputPorts.Add(hdmiPort); - - var dmLiteKey = string.Format("dmLiteOut{0}", index); - var dmLitePort = new RoutingOutputPort(dmLiteKey, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.DmCat, output, this) - { - FeedbackMatchObject = output, - Port = output.DmLiteOutput.DmLiteOutputPort - }; - Debug.Console(1, this, "Adding Output port: {0} - {1}", dmLitePort.Key, name); - OutputPorts.Add(dmLitePort); - - OutputRouteNameFeedback.Add(new StringFeedback(index.ToString(CultureInfo.InvariantCulture), - () => output.VideoOutFeedback.NameFeedback.StringValue)); - - VideoOutputRouteFeedbacks.Add(new IntFeedback(index.ToString(CultureInfo.InvariantCulture), - () => output.VideoOutFeedback == null ? 0 : (int)output.VideoOutFeedback.Number)); - } - - _chassis.DMOutputChange += _chassis_OutputChange; - } - - - public void ListRoutingPorts() - { - try - { - foreach (var port in InputPorts) - { - Debug.Console(0, this, @"Input Port Key: {0} -Port: {1} -Type: {2} -ConnectionType: {3} -Selector: {4} -", port.Key, port.Port, port.Type, port.ConnectionType, port.Selector); - } - - foreach (var port in OutputPorts) - { - Debug.Console(0, this, @"Output Port Key: {0} -Port: {1} -Type: {2} -ConnectionType: {3} -Selector: {4} -", port.Key, port.Port, port.Type, port.ConnectionType, port.Selector); - } - } - catch (Exception ex) - { - Debug.Console(0, this, "ListRoutingPorts Exception Message: {0}", ex.Message); - Debug.Console(0, this, "ListRoutingPorts Exception StackTrace: {0}", ex.StackTrace); - if (ex.InnerException != null) Debug.Console(0, this, "ListRoutingPorts InnerException: {0}", ex.InnerException); - } - } - - #region BridgeLinking - - /// - /// Link device to API - /// - /// - /// - /// - /// - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new HdPsXxxControllerJoinMap(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"); - } - - IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - DeviceNameFeedback.LinkInputSig(trilist.StringInput[joinMap.Name.JoinNumber]); - - _chassis.OnlineStatusChange += _chassis_OnlineStatusChange; - - LinkChassisInputsToApi(trilist, joinMap); - LinkChassisOutputsToApi(trilist, joinMap); - - trilist.OnlineStatusChange += (sender, args) => - { - if (!args.DeviceOnLine) return; - }; - } - - - // links inputs to API - private void LinkChassisInputsToApi(BasicTriList trilist, HdPsXxxControllerJoinMap joinMap) - { - for (uint i = 1; i <= _chassis.NumberOfInputs; i++) - { - var input = i; - var inputName = InputNames[input]; - var indexWithOffset = input - 1; - - trilist.SetSigTrueAction(joinMap.EnableInputHdcp.JoinNumber + indexWithOffset, () => EnableHdcp(input)); - trilist.SetSigTrueAction(joinMap.DisableInputHdcp.JoinNumber + indexWithOffset, () => DisableHdcp(input)); - - InputHdcpEnableFeedback[inputName].LinkInputSig(trilist.BooleanInput[joinMap.EnableInputHdcp.JoinNumber + indexWithOffset]); - InputHdcpEnableFeedback[inputName].LinkComplementInputSig(trilist.BooleanInput[joinMap.EnableInputHdcp.JoinNumber + indexWithOffset]); - - VideoInputSyncFeedbacks[inputName].LinkInputSig(trilist.BooleanInput[joinMap.InputSync.JoinNumber + indexWithOffset]); - - InputNameFeedbacks[inputName].LinkInputSig(trilist.StringInput[joinMap.InputName.JoinNumber + indexWithOffset]); - } - } - - - // links outputs to API - private void LinkChassisOutputsToApi(BasicTriList trilist, HdPsXxxControllerJoinMap joinMap) - { - for (uint i = 1; i <= _chassis.NumberOfOutputs; i++) - { - var output = i; - var outputName = OutputNames[output]; - var indexWithOffset = output - 1; - - trilist.SetUShortSigAction(joinMap.OutputRoute.JoinNumber + indexWithOffset, (a) => - ExecuteNumericSwitch(a, (ushort)output, eRoutingSignalType.AudioVideo)); - - OutputNameFeedbacks[outputName].LinkInputSig(trilist.StringInput[joinMap.OutputName.JoinNumber + indexWithOffset]); - OutputRouteNameFeedback[outputName].LinkInputSig(trilist.StringInput[joinMap.OutputRoutedName.JoinNumber + indexWithOffset]); - - VideoOutputRouteFeedbacks[outputName].LinkInputSig(trilist.UShortInput[joinMap.OutputRoute.JoinNumber + indexWithOffset]); - } - - AutoRouteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableAutoRoute.JoinNumber]); - } - - #endregion - - - /// - /// Executes a device switch using objects - /// - /// - /// - /// - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - var input = inputSelector as HdPsXxxInput; - var output = outputSelector as HdPsXxxOutput; - - 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 HdPsXxxHdmiOutput"); - return; - } - - // TODO [ ] Validate if sending the same input toggles the switch - var current = output.VideoOut; - if (current != input) - output.VideoOut = input; - } - - - /// - /// Executes a device switch using numeric values - /// - /// - /// - /// - 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); - } - - - /// - /// Enables Hdcp on the provided port - /// - /// - public void EnableHdcp(uint port) - { - if (port <= 0 || port > _chassis.NumberOfInputs) return; - - _chassis.HdmiInputs[port].InputPort.HdcpSupportOn(); - InputHdcpEnableFeedback[InputNames[port]].FireUpdate(); - } - - - /// - /// Disables Hdcp on the provided port - /// - /// - public void DisableHdcp(uint port) - { - if (port <= 0 || port > _chassis.NumberOfInputs) return; - - _chassis.HdmiInputs[port].InputPort.HdcpSupportOff(); - InputHdcpEnableFeedback[InputNames[port]].FireUpdate(); - } - - - /// - /// Enables switcher auto route - /// - public void EnableAutoRoute() - { - if (_chassis.NumberOfInputs == 1) return; - - _chassis.AutoRouteOn(); - } - - - /// - /// Disables switcher auto route - /// - public void DisableAutoRoute() - { - if (_chassis.NumberOfInputs == 1) return; - - _chassis.AutoRouteOff(); - } - - #region Events - - - // _chassis online/offline event - private void _chassis_OnlineStatusChange(GenericBase currentDevice, - OnlineOfflineEventArgs args) - { - IsOnline.FireUpdate(); - - if (!args.DeviceOnLine) return; - - foreach (var feedback in Feedbacks) - { - feedback.FireUpdate(); - } - } - - - // _chassis input change event - private void _chassis_InputChange(Switch device, DMInputEventArgs args) - { - var eventId = args.EventId; - - switch (eventId) - { - case DMInputEventIds.VideoDetectedEventId: - { - Debug.Console(1, this, "Event ID {0}: Updating VideoInputSyncFeedbacks", 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", eventId); - - var input = args.Number; - var name = _chassis.HdmiInputs[input].NameFeedback.StringValue; - - Debug.Console(1, this, "Input {0} Name {1}", input, name); - break; - } - default: - { - Debug.Console(1, this, "Uhandled DM Input Event ID {0}", eventId); - break; - } - } - - OnDmInputChange(args); - } - - - // _chassis output change event - private void _chassis_OutputChange(Switch device, DMOutputEventArgs args) - { - if (args.EventId != DMOutputEventIds.VideoOutEventId) return; - - var output = args.Number; - - var input = _chassis.HdmiDmLiteOutputs[output].VideoOutFeedback == null - ? 0 - : _chassis.HdmiDmLiteOutputs[output].VideoOutFeedback.Number; - - var outputName = OutputNames[output]; - - var feedback = VideoOutputRouteFeedbacks[outputName]; - if (feedback == null) return; - - var inputPort = InputPorts.FirstOrDefault( - p => p.FeedbackMatchObject == _chassis.HdmiDmLiteOutputs[output].VideoOutFeedback); - - var outputPort = OutputPorts.FirstOrDefault( - p => p.FeedbackMatchObject == _chassis.HdmiDmLiteOutputs[output]); - - feedback.FireUpdate(); - - OnSwitchChange(new RoutingNumericEventArgs( - output, input, outputPort, inputPort, eRoutingSignalType.AudioVideo)); - } - - - // Raise an event when the status of a switch object changes. - private void OnSwitchChange(RoutingNumericEventArgs args) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, args); - } - - // Raise an event when the DM input changes. - private void OnDmInputChange(DMInputEventArgs args) - { - var newEvent = DmInputChange; - if (newEvent != null) newEvent(this, args); - } - - - #endregion - - - #region Factory - - - public class HdSp401ControllerFactory : EssentialsDeviceFactory - { - public HdSp401ControllerFactory() - { - TypeNames = new List() { "hdps401", "hdps402", "hdps621", "hdps622" }; - } - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - var key = dc.Key; - var name = dc.Name; - var type = dc.Type.ToLower(); - - Debug.Console(1, "Factory Attempting to create new {0} device", type); - - var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); - if (props == null) - { - Debug.Console(1, "Factory failed to create new HD-PSXxx device, properties config was null"); - return null; - } - - var ipid = props.Control.IpIdInt; - - switch (type) - { - case ("hdps401"): - { - return new HdPsXxxController(key, name, new HdPs401(ipid, Global.ControlSystem), props); - } - case ("hdps402"): - { - return new HdPsXxxController(key, name, new HdPs402(ipid, Global.ControlSystem), props); - } - case ("hdps621"): - { - return new HdPsXxxController(key, name, new HdPs621(ipid, Global.ControlSystem), props); - } - case ("hdps622"): - { - return new HdPsXxxController(key, name, new HdPs622(ipid, Global.ControlSystem), props); - } - default: - { - Debug.Console(1, "Factory failed to create new {0} device", type); - return null; - } - } - } - } - - - #endregion - } - - - public class StreamCecWrapper : IKeyed, ICec - { - public string Key { get; private set; } - public Cec StreamCec { get; private set; } - - public StreamCecWrapper(string key, Cec streamCec) - { - Key = key; - StreamCec = streamCec; - } - } -} \ 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/HdPsXxxPropertiesConfig.cs b/src/PepperDash.Essentials.DM/Config/HdPsXxxPropertiesConfig.cs deleted file mode 100644 index 576b74f0..00000000 --- a/src/PepperDash.Essentials.DM/Config/HdPsXxxPropertiesConfig.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Collections.Generic; -using Newtonsoft.Json; -using PepperDash.Core; - -namespace PepperDash_Essentials_DM.Config -{ - public class HdPsXxxPropertiesConfig - { - [JsonProperty("control")] - public ControlPropertiesConfig Control { get; set; } - - [JsonProperty("inputs")] - public Dictionary Inputs { get; set; } - - [JsonProperty("outputs")] - public Dictionary Outputs { get; set; } - - // "inputPriorities": "1,4,3,2" - [JsonProperty("inputPriorities")] - public string InputPriorities { get; set; } - - public HdPsXxxPropertiesConfig() - { - Inputs = new Dictionary(); - Outputs = new Dictionary(); - } - } -} \ 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 9c40fdc5..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/DGEs/Dge100Controller.cs +++ /dev/null @@ -1,298 +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; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.DM.Endpoints.DGEs -{ - [Description("Wrapper class for DGE-100")] - public class Dge100Controller : CrestronGenericBaseDevice, IComPorts, IIROutputPorts, IHasBasicTriListWithSmartObject, ICec, IDeviceInfoProvider, IBridgeAdvanced - { - private const int CtpPort = 41795; - private readonly Dge100 _dge; - - private readonly TsxCcsUcCodec100EthernetReservedSigs _dgeEthernetInfo; - - public BasicTriListWithSmartObject Panel { get { return _dge; } } - - private DeviceConfig _dc; - - public VideoStatusOutputs VideoStatusFeedbacks { get; private set; } - - 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; - - var videoStatusFuncs = new VideoStatusFuncsWrapper - { - HdcpActiveFeedbackFunc = () => _dge.HdmiIn.HdcpSupportOnFeedback.BoolValue, - VideoResolutionFeedbackFunc = () => _dge.HdmiIn.VideoAttributes.GetVideoResolutionString(), - VideoSyncFeedbackFunc = () => _dge.HdmiIn.SyncDetectedFeedback.BoolValue, - }; - - VideoStatusFeedbacks = new VideoStatusOutputs(videoStatusFuncs); - - _dge.HdmiIn.StreamChange += (s,a) => VideoStatusFeedbacks.FireAll(); - _dge.HdmiIn.VideoAttributes.AttributeChange += (o, a) => VideoStatusFeedbacks.FireAll(); - } - - #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 - - #region IBridgeAdvanced Members - - public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new DgeJoinMap(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")); - - //Presses - trilist.SetSigTrueAction(joinMap.HdmiInHdcpOn.JoinNumber, () => _dge.HdmiIn.HdcpSupportOn()); - trilist.SetSigTrueAction(joinMap.HdmiInHdcpOff.JoinNumber,() => _dge.HdmiIn.HdcpSupportOff()); - trilist.SetSigTrueAction(joinMap.HdmiInHdcpToggle.JoinNumber, () => { - if(_dge.HdmiIn.HdcpSupportOnFeedback.BoolValue) - { - _dge.HdmiIn.HdcpSupportOff(); - return; - } - - _dge.HdmiIn.HdcpSupportOn(); - }); - - - // Feedbacks - VideoStatusFeedbacks.HdcpActiveFeedback.LinkInputSig(trilist.BooleanInput[joinMap.HdmiInHdcpOn.JoinNumber]); - VideoStatusFeedbacks.HdcpActiveFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.HdmiInHdcpOff.JoinNumber]); - - VideoStatusFeedbacks.VideoResolutionFeedback.LinkInputSig(trilist.StringInput[joinMap.CurrentInputResolution.JoinNumber]); - VideoStatusFeedbacks.VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.SyncDetected.JoinNumber]); - - IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - - trilist.OnlineStatusChange += (o, a) => - { - if (!a.DeviceOnLine) return; - - VideoStatusFeedbacks.FireAll(); - }; - } - - - - #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/DgeJoinMap.cs b/src/PepperDash.Essentials.DM/Endpoints/DGEs/DgeJoinMap.cs deleted file mode 100644 index f53e9383..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/DGEs/DgeJoinMap.cs +++ /dev/null @@ -1,50 +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.Endpoints.DGEs -{ - public class DgeJoinMap : JoinMapBaseAdvanced - { - [JoinName("IsOnline")] - public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "DGE Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("CurrentInputResolution")] - public JoinDataComplete CurrentInputResolution = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "DGE Current Input Resolution", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); - - [JoinName("SyncDetected")] - public JoinDataComplete SyncDetected = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, - new JoinMetadata { Description = "DGE Sync Detected", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("HdmiHdcpOn")] - public JoinDataComplete HdmiInHdcpOn = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, - new JoinMetadata { Description = "DGE HDMI HDCP State On", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("HdmiHdcpOff")] - public JoinDataComplete HdmiInHdcpOff = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, - new JoinMetadata { Description = "DGE HDMI HDCP State Off", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("HdmiHdcpToggle")] - public JoinDataComplete HdmiInHdcpToggle = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, - new JoinMetadata { Description = "DGE HDMI HDCP State Toggle", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - public DgeJoinMap(uint joinStart) - : this(joinStart, typeof(DgeJoinMap)) - { - } - - /// - /// Constructor to use when extending this Join map - /// - /// Join this join map will start at - /// Type of the child join map - protected DgeJoinMap(uint joinStart, Type type) : base(joinStart, type) - { - } - } -} \ 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 6198cee5..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/EndpointInterfaces.cs b/src/PepperDash.Essentials.DM/Endpoints/EndpointInterfaces.cs deleted file mode 100644 index 085d379b..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/EndpointInterfaces.cs +++ /dev/null @@ -1,91 +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.Endpoints; -using PepperDash.Essentials.Core; - -namespace PepperDash_Essentials_DM -{ - public interface IHasDmInHdcpSet - { - void SetDmInHdcpState(eHdcpCapabilityType hdcpState); - } - - public interface IHasDmInHdcpGet - { - IntFeedback DmInHdcpStateFeedback { get; } - } - - public interface IHasDmInHdcp : IHasDmInHdcpGet, IHasDmInHdcpSet - { - eHdcpCapabilityType DmInHdcpCapability { get; } - } - - - public interface IHasHdmiInHdcpSet - { - void SetHdmiInHdcpState(eHdcpCapabilityType hdcpState); - } - - public interface IHasHdmiInHdcpGet - { - IntFeedback HdmiInHdcpStateFeedback { get; } - } - - public interface IHasHdmiInHdcp : IHasHdmiInHdcpGet, IHasHdmiInHdcpSet - { - eHdcpCapabilityType HdmiInHdcpCapability { get; } - } - - - public interface IHasHdmiIn1HdcpSet - { - void SetHdmiIn1HdcpState(eHdcpCapabilityType hdcpState); - } - - public interface IHasHdmiIn1HdcpGet - { - IntFeedback HdmiIn1HdcpStateFeedback { get; } - } - - public interface IHasHdmiIn1Hdcp : IHasHdmiIn1HdcpGet, IHasHdmiIn1HdcpSet - { - eHdcpCapabilityType HdmiIn1HdcpCapability { get; } - } - - - public interface IHasHdmiIn2HdcpSet - { - void SetHdmiIn2HdcpState(eHdcpCapabilityType hdcpState); - } - - public interface IHasHdmiIn2HdcpGet - { - IntFeedback HdmiInIn2HdcpStateFeedback { get; } - } - - public interface IHasHdmi2InHdcp : IHasHdmiIn2HdcpGet, IHasHdmiIn2HdcpSet - { - eHdcpCapabilityType Hdmi2InHdcpCapability { get; } - } - - - - public interface IHasDisplayPortInHdcpGet - { - IntFeedback DisplayPortInHdcpStateFeedback { get; } - } - - public interface IHasDisplayPortInHdcpSet - { - void SetDisplayPortInHdcpState(eHdcpCapabilityType hdcpState); - } - - public interface IHasDisplayPortInHdcp : IHasDisplayPortInHdcpGet, IHasDisplayPortInHdcpSet - { - eHdcpCapabilityType DisplayPortInHdcpCapability { get; } - } -} \ 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 aab7996d..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmHdBaseTEndpointController.cs +++ /dev/null @@ -1,66 +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}; - PreventRegistration = true; - rmc.Register(); - } - - 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 4496e64f..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc4KScalerCController.cs +++ /dev/null @@ -1,261 +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; -using PepperDash_Essentials_DM; -using System.Collections.Generic; - -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, IHasDmInHdcp, IBasicVideoMuteWithFeedback - { - 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; } - - public EndpointDmInputStreamWithCec DmInput { get; private set; } - - public IntFeedback DmInHdcpStateFeedback { 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()); - DmInHdcpStateFeedback = new IntFeedback("DmInHdcpCapability", - () => (int)_rmc.DmInput.HdcpCapabilityFeedback); - - AddToFeedbackList(DmInHdcpStateFeedback); - - VideoMuteIsOn = new BoolFeedback("HdmiOutputVideoMuteIsOn", () => _rmc.HdmiOutput.BlankEnabledFeedback.BoolValue); - - _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(); - } - else if (args.EventId == EndpointOutputStreamEventIds.BlankEnabledFeedbackEventId) - { - VideoMuteIsOn.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 - - public eHdcpCapabilityType DmInHdcpCapability - { - get { return eHdcpCapabilityType.Hdcp2_2Support; } - } - - public void SetDmInHdcpState(eHdcpCapabilityType hdcpState) - { - if (_rmc == null) return; - _rmc.DmInput.HdcpCapability = hdcpState; - } - - - #region IBasicVideoMuteWithFeedback Members - - public BoolFeedback VideoMuteIsOn - { - get; - private set; - } - - public void VideoMuteOn() - { - Debug.Console(2, this, "Video Mute On"); - _rmc.HdmiOutput.BlankEnabled(); - } - - public void VideoMuteOff() - { - Debug.Console(2, this, "Video Mute Off"); - _rmc.HdmiOutput.BlankDisabled(); - } - - #endregion - - #region IBasicVideoMute Members - - public void VideoMuteToggle() - { - Debug.Console(2, this, "Video Mute Toggle"); - if (_rmc.HdmiOutput.BlankEnabledFeedback.BoolValue == true) - VideoMuteOff(); - else - VideoMuteOn(); - } - - #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 51d2f202..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc4k100C1GController.cs +++ /dev/null @@ -1,80 +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}; - PreventRegistration = true; - rmc.Register(); - } - - 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 b83fd0e4..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc4kScalerCDspController.cs +++ /dev/null @@ -1,219 +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; -using PepperDash_Essentials_DM; - -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, IHasDmInHdcp - { - 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; } - - public EndpointDmInputStreamWithCec DmInput { get; private set; } - - public IntFeedback DmInHdcpStateFeedback { 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()); - - DmInHdcpStateFeedback = new IntFeedback("DmInHdcpCapability", - () => (int) _rmc.DmInput.HdcpCapabilityFeedback); - - AddToFeedbackList(DmInHdcpStateFeedback); - - - 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 - - public eHdcpCapabilityType DmInHdcpCapability - { - get { return eHdcpCapabilityType.Hdcp2_2Support; } - } - - public void SetDmInHdcpState(eHdcpCapabilityType hdcpState) - { - if (_rmc == null) return; - _rmc.DmInput.HdcpCapability = hdcpState; - } - - } -} \ 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 07b348e5..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmc4kZScalerCController.cs +++ /dev/null @@ -1,245 +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; -using PepperDash_Essentials_DM; - -namespace PepperDash.Essentials.DM -{ - [Description("Wrapper Class for DM-RMC-4K-Z-SCALER-C")] - public class DmRmc4kZScalerCController : DmRmcControllerBase, IRmcRoutingWithFeedback, - IIROutputPorts, IComPorts, ICec, IRelayPorts, IHasDmInHdcp, IHasHdmiInHdcp - { - private readonly DmRmc4kzScalerC _rmc; - - public RoutingInputPort DmIn { get; private set; } - public RoutingInputPort HdmiIn { get; private set; } - public RoutingOutputPort HdmiOut { get; private set; } - - public IntFeedback DmInHdcpStateFeedback { get; private set; } - public IntFeedback HdmiInHdcpStateFeedback { get; private set; } - - public BoolFeedback HdmiVideoSyncFeedback { 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); - - HdmiInHdcpStateFeedback = new IntFeedback("HdmiInHdcpCapability", - () => (int)_rmc.HdmiIn.HdcpCapabilityFeedback); - DmInHdcpStateFeedback = new IntFeedback("DmInHdcpCapability", - () => (int)_rmc.DmInput.HdcpCapabilityFeedback); - HdmiVideoSyncFeedback = new BoolFeedback("HdmiInVideoSync", - () => _rmc.HdmiIn.SyncDetectedFeedback.BoolValue); - - AddToFeedbackList(HdmiInHdcpStateFeedback, DmInHdcpStateFeedback, HdmiVideoSyncFeedback); - - - 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.HdmiIn.InputStreamChange += InputStreamChangeEvent; - _rmc.DmInput.InputStreamChange += InputStreamChangeEvent; - - _rmc.OnlineStatusChange += _rmc_OnlineStatusChange; - - // Set Ports for CEC - HdmiOut.Port = _rmc.HdmiOutput; - - AudioVideoSourceNumericFeedback = new IntFeedback(() => (ushort)(_rmc.SelectedSourceFeedback)); - } - - void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - switch (args.EventId) - { - case EndpointInputStreamEventIds.HdcpCapabilityFeedbackEventId: - if (inputStream == _rmc.HdmiIn) HdmiInHdcpStateFeedback.FireUpdate(); - if (inputStream == _rmc.DmInput) DmInHdcpStateFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - if (inputStream == _rmc.HdmiIn) HdmiVideoSyncFeedback.FireUpdate(); - break; - } - } - - 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 - - - public eHdcpCapabilityType DmInHdcpCapability - { - get { return eHdcpCapabilityType.Hdcp2_2Support; } - } - - public void SetDmInHdcpState(eHdcpCapabilityType hdcpState) - { - - if (_rmc == null) return; - _rmc.DmInput.HdcpCapability = hdcpState; - } - - - public eHdcpCapabilityType HdmiInHdcpCapability - { - get { return eHdcpCapabilityType.Hdcp2_2Support; } - } - - public void SetHdmiInHdcpState(eHdcpCapabilityType hdcpState) - { - if (_rmc == null) return; - _rmc.HdmiIn.HdcpCapability = hdcpState; - } - - } -} \ 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 31836a45..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Receivers/DmRmcHelper.cs +++ /dev/null @@ -1,634 +0,0 @@ -extern alias Full; - -using System; -using System.Collections.Generic; -using System.Linq; -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; -using PepperDash_Essentials_DM; - -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."); - } - - LinkDmRmcToApi(rmc, trilist, joinMap); - } - - protected void LinkDmRmcToApi(DmRmcControllerBase rmc, BasicTriList trilist, DmRmcControllerJoinMap joinMap) - { - 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 IRoutingInputsOutputs; - - trilist.UShortInput[joinMap.HdcpInputPortCount.JoinNumber].UShortValue = (ushort)(routing == null - ? 1 - : routing.InputPorts.Count); - - if (routing == null) - { - return; - } - var hdcpCapability = eHdcpCapabilityType.HdcpSupportOff; - if (routing.InputPorts[DmPortName.HdmiIn] != null) - { - var hdmiInHdcp = routing as IHasHdmiInHdcp; - if (hdmiInHdcp != null) - { - if (rmc.Feedbacks["HdmiInHdcpCapability"] != null) - { - var intFeedback = rmc.Feedbacks["HdmiInHdcpCapability"] as IntFeedback; - if (intFeedback != null) - intFeedback.LinkInputSig(trilist.UShortInput[joinMap.Port1HdcpState.JoinNumber]); - } - if (rmc.Feedbacks["HdmiInVideoSync"] != null) - { - var boolFeedback = rmc.Feedbacks["HdmiInVideoSync"] as BoolFeedback; - if (boolFeedback != null) - boolFeedback.LinkInputSig(trilist.BooleanInput[joinMap.HdmiInputSync.JoinNumber]); - } - hdcpCapability = hdmiInHdcp.HdmiInHdcpCapability > hdcpCapability - ? hdmiInHdcp.HdmiInHdcpCapability - : hdcpCapability; - - trilist.SetUShortSigAction(joinMap.Port1HdcpState.JoinNumber, a => hdmiInHdcp.SetHdmiInHdcpState((eHdcpCapabilityType)a)); - } - } - if (routing.InputPorts[DmPortName.DmIn] != null) - { - var dmInHdcp = rmc as IHasDmInHdcp; - - if (dmInHdcp != null) - { - if (rmc.Feedbacks["DmInHdcpCapability"] != null) - { - var intFeedback = rmc.Feedbacks["DmInHdcpCapability"] as IntFeedback; - if (intFeedback != null) - intFeedback.LinkInputSig(trilist.UShortInput[joinMap.Port2HdcpState.JoinNumber]); - } - - hdcpCapability = dmInHdcp.DmInHdcpCapability > hdcpCapability - ? dmInHdcp.DmInHdcpCapability - : hdcpCapability; - - - trilist.SetUShortSigAction(joinMap.Port2HdcpState.JoinNumber, a => dmInHdcp.SetDmInHdcpState((eHdcpCapabilityType)a)); - } - } - - trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber].UShortValue = (ushort)hdcpCapability; - - trilist.UShortInput[joinMap.HdcpInputPortCount.JoinNumber].UShortValue = (ushort)routing.InputPorts.Count; - - var dmRmcScalerCBasicVideoMuteWithFeedback = rmc as IBasicVideoMuteWithFeedback; - - if (dmRmcScalerCBasicVideoMuteWithFeedback != null) - { - Debug.Console(1, this, "Device is IBasicVideoMuteWithFeedback, linking video mute"); - trilist.SetSigTrueAction(joinMap.VideoMuteToggle.JoinNumber, () => dmRmcScalerCBasicVideoMuteWithFeedback.VideoMuteToggle()); - trilist.SetSigTrueAction(joinMap.VideoMuteOn.JoinNumber, () => dmRmcScalerCBasicVideoMuteWithFeedback.VideoMuteOn()); - trilist.SetSigTrueAction(joinMap.VideoMuteOff.JoinNumber, () => dmRmcScalerCBasicVideoMuteWithFeedback.VideoMuteOff()); - dmRmcScalerCBasicVideoMuteWithFeedback.VideoMuteIsOn.LinkInputSig(trilist.BooleanInput[joinMap.VideoMuteOn.JoinNumber]); - dmRmcScalerCBasicVideoMuteWithFeedback.VideoMuteIsOn.LinkComplementInputSig(trilist.BooleanInput[joinMap.VideoMuteOff.JoinNumber]); - } - - var routingWithFeedback = routing as IRmcRouting; - if (routingWithFeedback == null) return; - - if (routingWithFeedback.AudioVideoSourceNumericFeedback != null) - routingWithFeedback.AudioVideoSourceNumericFeedback.LinkInputSig( - trilist.UShortInput[joinMap.AudioVideoSource.JoinNumber]); - - - trilist.SetUShortSigAction(joinMap.AudioVideoSource.JoinNumber, - a => routingWithFeedback.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); - CrestronGenericBaseDevice rx; - bool useChassisForOfflineFeedback = false; - - 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) - { - rx = GetDmRmcControllerForDmps4k(key, name, typeName, dmps, props.ParentOutputNumber); - useChassisForOfflineFeedback = true; - } - else - { - rx = GetDmRmcControllerForDmps(key, name, typeName, ipid, dmps, props.ParentOutputNumber); - if (typeName == "hdbasetrx" || typeName == "dmrmc4k100c1g") - { - useChassisForOfflineFeedback = true; - } - } - if (useChassisForOfflineFeedback) - { - Debug.Console(0, "DM endpoint output {0} does not have direct online feedback, changing online feedback to chassis", num); - rx.IsOnline.SetValueFunc(() => dmps.OutputEndpointOnlineFeedbacks[num].BoolValue); - dmps.OutputEndpointOnlineFeedbacks[num].OutputChange += (o, a) => - { - foreach (var feedback in rx.Feedbacks) - { - if (feedback != null) - feedback.FireUpdate(); - } - }; - } - return rx; - } - else if (parentDev is IDmSwitchWithEndpointOnlineFeedback) - { - var controller = parentDev as IDmSwitchWithEndpointOnlineFeedback; - 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) - { - rx = GetDmRmcControllerForCpu3Chassis(key, name, typeName, chassis, num, parentDev); - useChassisForOfflineFeedback = true; - } - else - { - rx = GetDmRmcControllerForCpu2Chassis(key, name, typeName, ipid, chassis, num, parentDev); - if (typeName == "hdbasetrx" || typeName == "dmrmc4k100c1g") - { - useChassisForOfflineFeedback = true; - } - } - if (useChassisForOfflineFeedback) - { - Debug.Console(0, "DM endpoint output {0} does not have direct online feedback, changing online feedback to chassis", num); - rx.IsOnline.SetValueFunc(() => controller.OutputEndpointOnlineFeedbacks[num].BoolValue); - controller.OutputEndpointOnlineFeedbacks[num].OutputChange += (o, a) => - { - foreach (var feedback in rx.Feedbacks) - { - if (feedback != null) - feedback.FireUpdate(); - } - }; - } - return rx; - } - 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 06d65e6c..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx4k100Controller.cs +++ /dev/null @@ -1,114 +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(); - } - PreventRegistration = true; - tx.Register(); - } - - 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 8d13a80f..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx4k202CController.cs +++ /dev/null @@ -1,417 +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); - - HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support; - - HdcpStateFeedback = new IntFeedback(() => (int)HdcpSupportCapability); - - 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 fd3368ae..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx4k302CController.cs +++ /dev/null @@ -1,501 +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); - - HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support; - - HdcpStateFeedback = new IntFeedback(() => (int)HdcpSupportCapability); - - 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 c0ef7eba..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx4kz100Controller.cs +++ /dev/null @@ -1,97 +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; - tx.Register(); - } - - 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 8a212be9..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTx4kz302CController.cs +++ /dev/null @@ -1,446 +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, - 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 IntFeedback DisplayPortInHdcpCapabilityFeedback { 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 += InputStreamChangeEvent; - 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); - DisplayPortInHdcpCapabilityFeedback = new IntFeedback("DisplayPortInHdcpCapability", - () => (int)tx.DisplayPortInput.HdcpCapabilityFeedback); - - - /* - HdcpStateFeedback = - new IntFeedback( - () => - tx.HdmiInputs[1].HdcpCapabilityFeedback > tx.HdmiInputs[2].HdcpCapabilityFeedback - ? (int)tx.HdmiInputs[1].HdcpCapabilityFeedback - : (int)tx.HdmiInputs[2].HdcpCapabilityFeedback); - */ - - //yeah this is gross - but it's the quickest way to do this... - /* - HdcpStateFeedback = new IntFeedback(() => { - var states = new[] {(int) tx.DisplayPortInput.HdcpCapabilityFeedback, (int) tx.HdmiInputs[1].HdcpCapabilityFeedback, (int) tx.HdmiInputs[2].HdcpCapabilityFeedback}; - - return states.Max(); - }); - */ - - HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support; - // I feel like we have had this as a misnomer for so long, that it really needed to be fixed - // All we were doing was reporting the best of the current statuses - not the actual capability of the device. - HdcpStateFeedback = new IntFeedback(() => (int)HdcpSupportCapability); - - 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) - || (ActualActiveVideoInput == eVst.DisplayPort - && tx.DisplayPortInput.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 ActualActiveVideoInput == eVst.DisplayPort - ? tx.DisplayPortInput.VideoAttributes.HdcpStateFeedback.ToString() - : ""; - }, - - VideoResolutionFeedbackFunc = () => - { - if (ActualActiveVideoInput == eVst.Hdmi1) - return tx.HdmiInputs[1].VideoAttributes.GetVideoResolutionString(); - if (ActualActiveVideoInput == eVst.Hdmi2) - return tx.HdmiInputs[2].VideoAttributes.GetVideoResolutionString(); - if (ActualActiveVideoInput == eVst.DisplayPort) - return tx.DisplayPortInput.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.DisplayPort - && tx.DisplayPortInput.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, DisplayPortInHdcpCapabilityFeedback); - - HdmiIn1.Port = Tx.HdmiInputs[1]; - HdmiIn2.Port = Tx.HdmiInputs[2]; - DisplayPortIn.Port = Tx.DisplayPortInput; - 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); - - 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(); - if (inputStream == Tx.DisplayPortInput) DisplayPortInHdcpCapabilityFeedback.FireUpdate(); - - Debug.Console(2, this, "DisplayPortHDCP Mode Trigger = {0}", - DisplayPortInHdcpCapabilityFeedback.IntValue); - - HdcpStateFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - if (inputStream == Tx.HdmiInputs[1]) Hdmi1VideoSyncFeedback.FireUpdate(); - if (inputStream == Tx.HdmiInputs[2]) Hdmi2VideoSyncFeedback.FireUpdate(); - if (inputStream == Tx.DisplayPortInput) DisplayPortVideoSyncFeedback.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 4ba15c73..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/DmTxHelpers.cs +++ /dev/null @@ -1,525 +0,0 @@ -extern alias Full; - -using System; -using System.Collections.Generic; -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 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")) - return 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; - bool useChassisForOfflineFeedback = false; - - if (parentDev is IDmSwitchWithEndpointOnlineFeedback) - { - // Get the Crestron chassis and link stuff up - var switchDev = (parentDev as IDmSwitchWithEndpointOnlineFeedback); - 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); - useChassisForOfflineFeedback = true; - } - else - { - tx = GetDmTxForChassisWithIpId(key, name, typeName, ipid, dmInput); - if (typeName == "hdbasettx" || typeName == "dmtx4k100c1g") - { - useChassisForOfflineFeedback = true; - } - } - if (useChassisForOfflineFeedback) - { - Debug.Console(0, "DM endpoint output {0} does not have direct online feedback, changing online feedback to chassis", num); - tx.IsOnline.SetValueFunc(() => switchDev.InputEndpointOnlineFeedbacks[num].BoolValue); - switchDev.InputEndpointOnlineFeedbacks[num].OutputChange += (o, a) => tx.IsOnline.FireUpdate(); - } - return tx; - } - catch (Exception e) - { - Debug.Console(0, "[{0}] WARNING: Cannot create DM-TX device for chassis: {1}", key, e); - return null; - } - } - - 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); - useChassisForOfflineFeedback = true; - } - else - { - tx = GetDmTxForChassisWithIpId(key, name, typeName, ipid, dmInput); - if (typeName == "hdbasettx" || typeName == "dmtx4k100c1g") - { - useChassisForOfflineFeedback = true; - } - } - if (useChassisForOfflineFeedback) - { - Debug.Console(0, "DM endpoint output {0} does not have direct online feedback, changing online feedback to chassis", num); - tx.IsOnline.SetValueFunc(() => dmpsDev.InputEndpointOnlineFeedbacks[num].BoolValue); - dmpsDev.InputEndpointOnlineFeedbacks[num].OutputChange += (o, a) => tx.IsOnline.FireUpdate(); - } - return tx; - } - catch (Exception e) - { - Debug.Console(0, "[{0}] WARNING: Cannot create DM-TX device for dmps: {1}", key, e); - return null; - } - } - - 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]); - - 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.Port2HdcpState.JoinNumber]); - } - - if (inputPort.ConnectionType == eRoutingPortConnectionType.Hdmi && inputPort.Port != null) - { - var port = inputPort.Port as EndpointHdmiInput; - - SetHdcpCapabilityAction(hdcpTypeSimple, port, joinMap.Port2HdcpState.JoinNumber, trilist); - } - } - - if (txR.InputPorts[DmPortName.DisplayPortIn] != null) - { - var inputPort = txR.InputPorts[DmPortName.DisplayPortIn]; - - if (tx.Feedbacks["DisplayPortInHdcpCapability"] != null) - { - - var intFeedback = tx.Feedbacks["DisplayPortInHdcpCapability"] as IntFeedback; - if (intFeedback != null) - - intFeedback.LinkInputSig(trilist.UShortInput[joinMap.Port3HdcpState.JoinNumber]); - - if (inputPort.ConnectionType == eRoutingPortConnectionType.DisplayPort && inputPort.Port != null) - { - var port = inputPort.Port as EndpointDisplayPortInput; - SetHdcpCapabilityAction(port, joinMap.Port3HdcpState.JoinNumber, trilist); - } - } - } - - - var hdcpInputPortCount = - (ushort) - txR.InputPorts.Where( - x => (x.Type == eRoutingSignalType.Video) || (x.Type == eRoutingSignalType.AudioVideo)) - .Where( - x => - (x.ConnectionType == eRoutingPortConnectionType.DmCat) || - (x.ConnectionType == eRoutingPortConnectionType.Hdmi) || - (x.ConnectionType == eRoutingPortConnectionType.DisplayPort)) - .ToList().Count(); - - trilist.SetUshort(joinMap.HdcpInputPortCount.JoinNumber, hdcpInputPortCount); - - } - - 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; - }); - } - } - - private void SetHdcpCapabilityAction(EndpointDisplayPortInput port, uint join, - BasicTriList trilist) - { - trilist.SetUShortSigAction(join, - s => - { - Debug.Console(0, this, "Trying to set HDCP to {0} on port {1}", s, port.ToString()); - 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 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 b18598c1..00000000 --- a/src/PepperDash.Essentials.DM/Endpoints/Transmitters/HDBaseTTxController.cs +++ /dev/null @@ -1,140 +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(); - } - - PreventRegistration = true; - tx.Register(); - } - - #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 8f1af55e..00000000 --- a/src/PepperDash.Essentials.DM/IDmSwitch.cs +++ /dev/null @@ -1,32 +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; } - } - - public interface IDmSwitchWithEndpointOnlineFeedback : IDmSwitch - { - Dictionary InputEndpointOnlineFeedbacks { get; } - Dictionary OutputEndpointOnlineFeedbacks { 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