/// <summary> /// Constructor /// </summary> /// <param name="selector">An object used to refer to this port in the IRouting device's ExecuteSwitch method. /// May be string, number, whatever</param> /// <param name="parent">The IRoutingInputs object this lives on</param> /// <param name="funcs">A VideoStatusFuncsWrapper used to assign the callback funcs that will get /// the values for the various stats</param> public RoutingInputPortWithVideoStatuses(string key, eRoutingSignalType type, eRoutingPortConnectionType connType, object selector, IRoutingInputs parent, VideoStatusFuncsWrapper funcs) : base(key, type, connType, selector, parent) { VideoStatus = new VideoStatusOutputs(funcs); }
public RouteDescriptor(IRoutingOutputs source, IRoutingInputs destination, eRoutingSignalType signalType) { Destination = destination; Source = source; SignalType = signalType; Routes = new List <RouteSwitchDescriptor>(); }
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 = Convert.ToUInt32(inputSelector); // Cast can sometimes fail var output = Convert.ToUInt32(outputSelector); // Check to see if there's an off timer waiting on this and if so, cancel var key = new PortNumberType(output, sigType); if (input == 0) { 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; Chassis.Outputs[output].VideoOut = inCard; } }
/// <summary> /// Adds OutputPort /// </summary> void AddOutputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, object selector) { var portKey = string.Format("outputCard{0}--{1}", cardNum, portName); Debug.Console(2, this, "Adding output port '{0}'", portKey); OutputPorts.Add(new RoutingOutputPort(portKey, sigType, portType, selector, this)); }
/// <summary> /// Switches the audio/video source based on the integer value (0-Auto, 1-HDMI, 2-VGA, 3-Disable) /// </summary> /// <param name="input"></param> /// <param name="output"></param> /// <param name="type"></param> 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 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; } } }
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 RoutingPort(string key, eRoutingSignalType type, eRoutingPortConnectionType connType, object selector, bool isInternal) { Key = key; Type = type; ConnectionType = connType; Selector = selector; IsInternal = IsInternal; }
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; }
/// <summary> /// Adds InputPort /// </summary> void AddInputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType) { 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, cardNum, this); InputPorts.Add(inputPort); }
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]; } }
/// <summary> /// Constructor for a virtual routing input port that lives inside a device. For example /// the ports that link a DM card to a DM matrix bus /// </summary> /// <param name="isInternal">true for internal ports</param> public RoutingInputPort(string key, eRoutingSignalType type, eRoutingPortConnectionType connType, object selector, IRoutingInputs parent, bool isInternal) : base(key, type, connType, selector, isInternal) { if (parent == null) { throw new ArgumentNullException("parent"); } ParentDevice = parent; }
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; } }
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; } }
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; } }
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); } }
/// <summary> /// Adds OutputPort and sets Port as ICec object /// </summary> 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); if (cecPort != null) { outputPort.Port = cecPort; } OutputPorts.Add(outputPort); }
public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) { 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) { Tx.AudioSource = (eAst)inputSelector; } }
public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) { 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; } }
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; } } }
/// <summary> /// Execute Switch with Essentials MagicRouting /// </summary> /// <param name="inputSelector">Input Object Data</param> /// <param name="outputSelector">Output Object Data</param> /// <param name="signalType">Signal Type to Route</param> public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) { if (signalType != eRoutingSignalType.Audio) { return; } if (Destination != 0) { return; } if (Type == "router") { SendFullCommand("set", "input", Convert.ToString(inputSelector), 1); SendFullCommand("get", "input", Index1.ToString(CultureInfo.InvariantCulture), 1); } else { SendFullCommand("set", "sourceSelection", Convert.ToString(inputSelector), 1); } }
/// <summary> /// Adds InputPort and sets Port as ICec object /// </summary> 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, cardNum, this); if (inputPort != null) { if (cecPort != null) { inputPort.Port = cecPort; } InputPorts.Add(inputPort); } else { Debug.Console(2, this, "inputPort is null"); } }
/// <summary> /// Creates a tie line with an overriding Type. See help for OverrideType property for info /// </summary> /// <param name="overrideType">The signal type to limit the link to. Overrides DestinationPort.Type</param> public TieLine(RoutingOutputPort sourcePort, RoutingInputPort destinationPort, eRoutingSignalType overrideType) : this(sourcePort, destinationPort) { OverrideType = overrideType; }
public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) { Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); if (type == 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; } } } else if (type == 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; } } } }
public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType sigType) { try { Debug.Console(2, this, "Attempting a DM route from input {0} to output {1} {2}", inputSelector, outputSelector, sigType); var input = Convert.ToUInt32(inputSelector); // Cast can sometimes fail var output = Convert.ToUInt32(outputSelector); if (input <= Dmps.NumberOfSwitcherInputs && output <= Dmps.NumberOfSwitcherOutputs) { // Check to see if there's an off timer waiting on this and if so, cancel var key = new PortNumberType(output, sigType); if (input == 0) { 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); } } DMInput inCard = input == 0 ? null : Dmps.SwitcherInputs[input] as DMInput; DMOutput outCard = output == 0 ? null : Dmps.SwitcherOutputs[output] as DMOutput; //if (inCard != null) //{ // NOTE THAT BITWISE COMPARISONS - TO CATCH ALL ROUTING TYPES if ((sigType | eRoutingSignalType.Video) == eRoutingSignalType.Video) { //SystemControl.VideoEnter.BoolValue = true; if (outCard != null) { outCard.VideoOut = inCard; } } if ((sigType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) { if (outCard != null) { outCard.AudioOut = inCard; } } if ((sigType | eRoutingSignalType.UsbOutput) == eRoutingSignalType.UsbOutput) { if (outCard != null) { outCard.USBRoutedTo = inCard; } } if ((sigType | eRoutingSignalType.UsbInput) == eRoutingSignalType.UsbInput) { if (inCard != null) { inCard.USBRoutedTo = outCard; } } //} //else //{ // Debug.Console(1, this, "Unable to execute route from input {0} to output {1}. Input card not available", inputSelector, outputSelector); //} } 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); } }
/// <summary> /// Constructor for a basic RoutingInputPort /// </summary> /// <param name="selector">An object used to refer to this port in the IRouting device's ExecuteSwitch method. /// May be string, number, whatever</param> /// <param name="parent">The IRoutingInputs object this lives on</param> public RoutingInputPort(string key, eRoutingSignalType type, eRoutingPortConnectionType connType, object selector, IRoutingInputs parent) : this(key, type, connType, selector, parent, false) { }
public PortNumberType(uint number, eRoutingSignalType type) : this() { Number = number; Type = type; }
/// <summary> /// Gets any existing route for a destination, clears it, and then /// </summary> public static void ReleaseAndMakeRoute(this IRoutingInputs destination, IRoutingOutputs source, eRoutingSignalType signalType) { var sw = new Stopwatch(); sw.Start(); destination.ReleaseRoute(); if (source == null) { return; } var newRoute = destination.GetRouteToSource(source, signalType); if (newRoute == null) { return; } RouteDescriptorCollection.DefaultCollection.AddRouteDescriptor(newRoute); Debug.Console(2, destination, "Executing new route"); newRoute.ExecuteRoutes(); sw.Stop(); Debug.Console(2, destination, "Route took {0} ms", sw.ElapsedMilliseconds); }
/// <summary> /// /// </summary> /// <param name="device"></param> /// <param name="targetSource"></param> /// <param name="signalType"></param> /// <returns></returns> public static RouteDescriptor GetRouteToSource(this IRoutingInputs destination, IRoutingOutputs source, eRoutingSignalType signalType) { var routeTable = new RouteDescriptor(source, destination, signalType); Debug.Console(0, destination, "Attempting to build source route from {0}***", source.Key); if (!destination.GetRouteToSource(source, null, null, signalType, 0, routeTable)) { routeTable = null; } Debug.Console(0, destination, "Route{0} discovered ***", routeTable == null ? " NOT" : ""); return(routeTable); }
/// <summary> /// The recursive part of this. Will stop on each device, search its inputs for the /// desired source and if not found, invoke this function for the each input port /// hoping to find the source. /// </summary> /// <param name="destination"></param> /// <param name="source"></param> /// <param name="onSuccessOutputPort"></param> /// <param name="alreadyCheckedDevices"></param> /// <param name="signalType"></param> /// <param name="cycle"></param> /// <param name="routeTable"></param> /// <returns>true if source is hit</returns> static bool GetRouteToSource(this IRoutingInputs destination, IRoutingOutputs source, RoutingOutputPort onSuccessOutputPort, List <IRoutingInputsOutputs> alreadyCheckedDevices, eRoutingSignalType signalType, int cycle, RouteDescriptor routeTable) { cycle++; Debug.Console(0, destination, "SelectInput-cycle {1}. Finding {2} route back to {0}", source.Key, cycle, signalType); var destDevInputTies = TieLineCollection.Default.Where(t => t.DestinationPort.ParentDevice == destination && (t.Type == signalType || t.Type == eRoutingSignalType.AudioVideo)); // find a direct tie var directTie = destDevInputTies.FirstOrDefault( t => !(t.SourcePort.ParentDevice is IRoutingInputsOutputs) && t.DestinationPort.ParentDevice == destination && t.SourcePort.ParentDevice == source); RoutingInputPort inputPort = null; if (directTie != null) // Found a tie directly to the source { Debug.Console(0, destination, "Found direct tie to {0}**", source.Key); inputPort = directTie.DestinationPort; } else // no direct-connect. Walk back devices. { Debug.Console(0, destination, "is not directly connected to {0}. Walking down tie lines", source.Key); // No direct tie? Run back out on the inputs' attached devices... // Only the ones that are routing devices var attachedMidpoints = destDevInputTies.Where(t => t.SourcePort.ParentDevice is IRoutingInputsOutputs); foreach (var inputTieToTry in attachedMidpoints) { Debug.Console(0, destination, "Trying to find route on {0}", inputTieToTry.SourcePort.ParentDevice.Key); var upstreamDeviceOutputPort = inputTieToTry.SourcePort; var upstreamRoutingDevice = upstreamDeviceOutputPort.ParentDevice as IRoutingInputsOutputs; // Check if this previous device has already been walked if (!(alreadyCheckedDevices != null && alreadyCheckedDevices.Contains(upstreamRoutingDevice))) { // haven't seen this device yet. Do it. Pass the output port to the next // level to enable switching on success var upstreamRoutingSuccess = upstreamRoutingDevice.GetRouteToSource(source, upstreamDeviceOutputPort, alreadyCheckedDevices, signalType, cycle, routeTable); if (upstreamRoutingSuccess) { Debug.Console(0, destination, "Upstream device route found"); inputPort = inputTieToTry.DestinationPort; break; // Stop looping the inputs in this cycle } } } } // we have a route on corresponding inputPort. *** Do the route *** if (inputPort != null) { Debug.Console(0, destination, "adding route:"); if (onSuccessOutputPort == null) { // it's a sink device routeTable.Routes.Add(new RouteSwitchDescriptor(inputPort)); } else if (destination is IRouting) { routeTable.Routes.Add(new RouteSwitchDescriptor(onSuccessOutputPort, inputPort)); } else // device is merely IRoutingInputOutputs { Debug.Console(0, destination, " No routing. Passthrough device"); } Debug.Console(0, destination, "Exiting cycle {0}", cycle); return(true); } if (alreadyCheckedDevices == null) { alreadyCheckedDevices = new List <IRoutingInputsOutputs>(); } alreadyCheckedDevices.Add(destination as IRoutingInputsOutputs); Debug.Console(0, destination, "No route found to {0}", source.Key); return(false); }