diff --git a/src/PepperDash.Essentials.Core/Routing/TieLine.cs b/src/PepperDash.Essentials.Core/Routing/TieLine.cs index 245194a9..0b271272 100644 --- a/src/PepperDash.Essentials.Core/Routing/TieLine.cs +++ b/src/PepperDash.Essentials.Core/Routing/TieLine.cs @@ -1,98 +1,91 @@ -using System; +using Newtonsoft.Json; +using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using Newtonsoft.Json; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DM; - -using PepperDash.Core; namespace PepperDash.Essentials.Core { - public class TieLine - { - public RoutingOutputPort SourcePort { get; private set; } - public RoutingInputPort DestinationPort { get; private set; } - //public int InUseCount { get { return DestinationUsingThis.Count; } } + public class TieLine + { + public RoutingOutputPort SourcePort { get; private set; } + public RoutingInputPort DestinationPort { get; private set; } + //public int InUseCount { get { return DestinationUsingThis.Count; } } - /// - /// Gets the type of this tie line. Will either be the type of the desination port - /// or the type of OverrideType when it is set. - /// - public eRoutingSignalType Type - { - get - { - if (OverrideType.HasValue) return OverrideType.Value; - return DestinationPort.Type; - } - } + /// + /// Gets the type of this tie line. Will either be the type of the desination port + /// or the type of OverrideType when it is set. + /// + public eRoutingSignalType Type + { + get + { + if (OverrideType.HasValue) return OverrideType.Value; + return DestinationPort.Type; + } + } - /// - /// Use this to override the Type property for the destination port. For example, - /// when the tie line is type AudioVideo, and the signal flow should be limited to - /// Audio-only or Video only, changing this type will alter the signal paths - /// available to the routing algorithm without affecting the actual Type - /// of the destination port. - /// - public eRoutingSignalType? OverrideType { get; set; } + /// + /// Use this to override the Type property for the destination port. For example, + /// when the tie line is type AudioVideo, and the signal flow should be limited to + /// Audio-only or Video only, changing this type will alter the signal paths + /// available to the routing algorithm without affecting the actual Type + /// of the destination port. + /// + public eRoutingSignalType? OverrideType { get; set; } - //List DestinationUsingThis = new List(); + //List DestinationUsingThis = new List(); - /// - /// For tie lines that represent internal links, like from cards to the matrix in a DM. - /// This property is true if SourcePort and DestinationPort IsInternal - /// property are both true - /// - public bool IsInternal { get { return SourcePort.IsInternal && DestinationPort.IsInternal; } } - public bool TypeMismatch { get { return SourcePort.Type != DestinationPort.Type; } } - public bool ConnectionTypeMismatch { get { return SourcePort.ConnectionType != DestinationPort.ConnectionType; } } - public string TypeMismatchNote { get; set; } + /// + /// For tie lines that represent internal links, like from cards to the matrix in a DM. + /// This property is true if SourcePort and DestinationPort IsInternal + /// property are both true + /// + public bool IsInternal { get { return SourcePort.IsInternal && DestinationPort.IsInternal; } } + public bool TypeMismatch { get { return SourcePort.Type != DestinationPort.Type; } } + public bool ConnectionTypeMismatch { get { return SourcePort.ConnectionType != DestinationPort.ConnectionType; } } + public string TypeMismatchNote { get; set; } - /// - /// - /// - /// - /// - public TieLine(RoutingOutputPort sourcePort, RoutingInputPort destinationPort) - { - if (sourcePort == null || destinationPort == null) - throw new ArgumentNullException("source or destination port"); - SourcePort = sourcePort; - DestinationPort = destinationPort; - } + /// + /// + /// + /// + /// + public TieLine(RoutingOutputPort sourcePort, RoutingInputPort destinationPort) + { + if (sourcePort == null || destinationPort == null) + throw new ArgumentNullException("source or destination port"); + SourcePort = sourcePort; + DestinationPort = destinationPort; + } - /// - /// Creates a tie line with an overriding Type. See help for OverrideType property for info - /// - /// The signal type to limit the link to. Overrides DestinationPort.Type - public TieLine(RoutingOutputPort sourcePort, RoutingInputPort destinationPort, eRoutingSignalType overrideType) : - this(sourcePort, destinationPort) - { - OverrideType = overrideType; - } + /// + /// Creates a tie line with an overriding Type. See help for OverrideType property for info + /// + /// The signal type to limit the link to. Overrides DestinationPort.Type + public TieLine(RoutingOutputPort sourcePort, RoutingInputPort destinationPort, eRoutingSignalType overrideType) : + this(sourcePort, destinationPort) + { + OverrideType = overrideType; + } - /// - /// Will link up video status from supporting inputs to connected outputs - /// - public void Activate() - { - // Now does nothing - } + /// + /// Will link up video status from supporting inputs to connected outputs + /// + public void Activate() + { + // Now does nothing + } - public void Deactivate() - { - // Now does nothing - } + public void Deactivate() + { + // Now does nothing + } - public override string ToString() - { - return string.Format("Tie line: {0}:{1} --> {2}:{3}", SourcePort.ParentDevice.Key, SourcePort.Key, - DestinationPort.ParentDevice.Key, DestinationPort.Key); - } - } + public override string ToString() + { + return string.Format("Tie line: {0}:{1} --> {2}:{3} {4}", SourcePort.ParentDevice.Key, SourcePort.Key, + DestinationPort.ParentDevice.Key, DestinationPort.Key, Type.ToString()); + } + } //******************************************************************************** @@ -109,6 +102,6 @@ namespace PepperDash.Essentials.Core } [JsonIgnore] - static TieLineCollection _Default; - } + private static TieLineCollection _Default; + } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Web/RequestHandlers/GetTieLinesRequestHandler.cs b/src/PepperDash.Essentials.Core/Web/RequestHandlers/GetTieLinesRequestHandler.cs index d5de5ad0..fb1db4e7 100644 --- a/src/PepperDash.Essentials.Core/Web/RequestHandlers/GetTieLinesRequestHandler.cs +++ b/src/PepperDash.Essentials.Core/Web/RequestHandlers/GetTieLinesRequestHandler.cs @@ -1,25 +1,24 @@ using Crestron.SimplSharp.WebScripting; using Newtonsoft.Json; using PepperDash.Core.Web.RequestHandlers; -using System; -using System.Collections.Generic; using System.Linq; using System.Text; -using System.Threading.Tasks; namespace PepperDash.Essentials.Core.Web.RequestHandlers { - public class GetTieLinesRequestHandler:WebApiBaseRequestHandler + public class GetTieLinesRequestHandler : WebApiBaseRequestHandler { public GetTieLinesRequestHandler() : base(true) { } protected override void HandleGet(HttpCwsContext context) { - var tieLineString = JsonConvert.SerializeObject(TieLineCollection.Default.Select((tl) => new { + var tieLineString = JsonConvert.SerializeObject(TieLineCollection.Default.Select((tl) => new + { sourceKey = tl.SourcePort.ParentDevice.Key, sourcePort = tl.SourcePort.Key, destinationKey = tl.DestinationPort.ParentDevice.Key, - destinationPort = tl.DestinationPort.Key + destinationPort = tl.DestinationPort.Key, + type = tl.Type.ToString(), })); context.Response.StatusCode = 200;