using System; using System.Collections.Generic; using PepperDash.Core; namespace PepperDash.Essentials.Core { /// /// Base class for RoutingInput and Output ports /// public abstract class RoutingPort : IKeyed { public string Key { get; private set; } public eRoutingSignalType Type { get; private set; } public eRoutingPortConnectionType ConnectionType { get; private set; } public readonly object Selector; public bool IsInternal { get; private set; } public object FeedbackMatchObject { get; set; } public RoutingPort(string key, eRoutingSignalType type, eRoutingPortConnectionType connType, object selector, bool isInternal) { Key = key; Type = type; ConnectionType = connType; Selector = selector; IsInternal = IsInternal; } } public enum eRoutingSignalType { Audio, Video, AudioVideo } public enum eRoutingPortConnectionType { None, BackplaneOnly, DisplayPort, Dvi, Hdmi, Rgb, Vga, LineAudio, DigitalAudio, Sdi, Composite, Component, DmCat, DmMmFiber, DmSmFiber, Speaker } /// /// Basic RoutingInput with no statuses. /// public class RoutingInputPort : RoutingPort { /// /// The IRoutingInputs object this lives on /// public IRoutingInputs ParentDevice { get; private set; } /// /// Constructor for a basic RoutingInputPort /// /// An object used to refer to this port in the IRouting device's ExecuteSwitch method. /// May be string, number, whatever /// The IRoutingInputs object this lives on public RoutingInputPort(string key, eRoutingSignalType type, eRoutingPortConnectionType connType, object selector, IRoutingInputs parent) : this (key, type, connType, selector, parent, false) { } /// /// 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 /// /// true for internal ports 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; } ///// ///// Static method to get a named port from a named device ///// ///// Returns null if device or port doesn't exist //public static RoutingInputPort GetDevicePort(string deviceKey, string portKey) //{ // var sourceDev = DeviceManager.GetDeviceForKey(deviceKey) as IRoutingInputs; // if (sourceDev == null) // return null; // return sourceDev.InputPorts[portKey]; //} ///// ///// Static method to get a named port from a card in a named ICardPortsDevice device ///// Uses ICardPortsDevice.GetChildInputPort ///// ///// 'input-N' ///// null if device, card or port doesn't exist //public static RoutingInputPort GetDeviceCardPort(string deviceKey, string cardKey, string portKey) //{ // var sourceDev = DeviceManager.GetDeviceForKey(deviceKey) as ICardPortsDevice; // if (sourceDev == null) // return null; // return sourceDev.GetChildInputPort(cardKey, portKey); //} } /// /// A RoutingInputPort for devices like DM-TX and DM input cards. /// Will provide video statistics on connected signals /// public class RoutingInputPortWithVideoStatuses : RoutingInputPort { /// /// Video statuses attached to this port /// public VideoStatusOutputs VideoStatus { get; private set; } /// /// Constructor /// /// An object used to refer to this port in the IRouting device's ExecuteSwitch method. /// May be string, number, whatever /// The IRoutingInputs object this lives on /// A VideoStatusFuncsWrapper used to assign the callback funcs that will get /// the values for the various stats 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 class RoutingOutputPort : RoutingPort { /// /// The IRoutingOutputs object this port lives on /// public IRoutingOutputs ParentDevice { get; private set; } public InUseTracking InUseTracker { get; private set; } /// /// /// An object used to refer to this port in the IRouting device's ExecuteSwitch method. /// May be string, number, whatever /// The IRoutingOutputs object this port lives on public RoutingOutputPort(string key, eRoutingSignalType type, eRoutingPortConnectionType connType, object selector, IRoutingOutputs parent) : this(key, type, connType, selector, parent, false) { } public RoutingOutputPort(string key, eRoutingSignalType type, eRoutingPortConnectionType connType, object selector, IRoutingOutputs parent, bool isInternal) : base(key, type, connType, selector, isInternal) { if (parent == null) throw new ArgumentNullException("parent"); ParentDevice = parent; InUseTracker = new InUseTracking(); } public override string ToString() { return ParentDevice.Key + ":" + Key; } ///// ///// Static method to get a named port from a named device ///// ///// Returns null if device or port doesn't exist //public static RoutingOutputPort GetDevicePort(string deviceKey, string portKey) //{ // var sourceDev = DeviceManager.GetDeviceForKey(deviceKey) as IRoutingOutputs; // if (sourceDev == null) // return null; // var port = sourceDev.OutputPorts[portKey]; // if (port == null) // Debug.Console(0, "WARNING: Device '{0}' does does not contain output port '{1}'", deviceKey, portKey); // return port; //} ///// ///// Static method to get a named port from a card in a named ICardPortsDevice device ///// Uses ICardPortsDevice.GetChildOutputPort on that device ///// ///// 'input-N' or 'output-N' ///// null if device, card or port doesn't exist //public static RoutingOutputPort GetDeviceCardPort(string deviceKey, string cardKey, string portKey) //{ // var sourceDev = DeviceManager.GetDeviceForKey(deviceKey) as ICardPortsDevice; // if (sourceDev == null) // return null; // var port = sourceDev.GetChildOutputPort(cardKey, portKey); //} } }