Merge pull request #602 from PepperDash/hotfix/various-bugs

Hotfix/various bugs
This commit is contained in:
Andrew Welker
2021-02-08 16:33:21 -07:00
committed by GitHub
7 changed files with 491 additions and 366 deletions

View File

@@ -274,10 +274,23 @@ namespace PepperDash.Essentials
CallTypeFeedback = new IntFeedback(() => 0); CallTypeFeedback = new IntFeedback(() => 0);
SourceListKey = "default"; SetSourceListKey();
EnablePowerOnToLastSource = true; EnablePowerOnToLastSource = true;
} }
private void SetSourceListKey()
{
if (!string.IsNullOrEmpty(PropertiesConfig.SourceListKey))
{
SetSourceListKey(PropertiesConfig.SourceListKey);
}
else
{
SetSourceListKey(Key);
}
}
void InitializeDisplay(DisplayBase disp) void InitializeDisplay(DisplayBase disp)
{ {
if (disp != null) if (disp != null)
@@ -333,7 +346,6 @@ namespace PepperDash.Essentials
this.LogoUrlLightBkgnd = PropertiesConfig.LogoLight.GetLogoUrlLight(); this.LogoUrlLightBkgnd = PropertiesConfig.LogoLight.GetLogoUrlLight();
this.LogoUrlDarkBkgnd = PropertiesConfig.LogoDark.GetLogoUrlDark(); this.LogoUrlDarkBkgnd = PropertiesConfig.LogoDark.GetLogoUrlDark();
this.SourceListKey = PropertiesConfig.SourceListKey;
this.DefaultSourceItem = PropertiesConfig.DefaultSourceItem; this.DefaultSourceItem = PropertiesConfig.DefaultSourceItem;
this.DefaultVolume = (ushort)(PropertiesConfig.Volumes.Master.Level * 65535 / 100); this.DefaultVolume = (ushort)(PropertiesConfig.Volumes.Master.Level * 65535 / 100);

View File

@@ -201,11 +201,25 @@ namespace PepperDash.Essentials
IsCoolingDownFeedback.FireUpdate(); IsCoolingDownFeedback.FireUpdate();
}; };
} }
SetSourceListKey();
SourceListKey = "default";
EnablePowerOnToLastSource = true; EnablePowerOnToLastSource = true;
} }
private void SetSourceListKey()
{
if (!string.IsNullOrEmpty(PropertiesConfig.SourceListKey))
{
SetSourceListKey(PropertiesConfig.SourceListKey);
}
else
{
SetSourceListKey(Key);
}
}
protected override void CustomSetConfig(DeviceConfig config) protected override void CustomSetConfig(DeviceConfig config)
{ {
var newPropertiesConfig = JsonConvert.DeserializeObject<EssentialsHuddleRoomPropertiesConfig>(config.Properties.ToString()); var newPropertiesConfig = JsonConvert.DeserializeObject<EssentialsHuddleRoomPropertiesConfig>(config.Properties.ToString());
@@ -256,7 +270,6 @@ namespace PepperDash.Essentials
this.LogoUrlLightBkgnd = PropertiesConfig.LogoLight.GetLogoUrlLight(); this.LogoUrlLightBkgnd = PropertiesConfig.LogoLight.GetLogoUrlLight();
this.LogoUrlDarkBkgnd = PropertiesConfig.LogoDark.GetLogoUrlDark(); this.LogoUrlDarkBkgnd = PropertiesConfig.LogoDark.GetLogoUrlDark();
this.SourceListKey = PropertiesConfig.SourceListKey;
this.DefaultSourceItem = PropertiesConfig.DefaultSourceItem; this.DefaultSourceItem = PropertiesConfig.DefaultSourceItem;
this.DefaultVolume = (ushort)(PropertiesConfig.Volumes.Master.Level * 65535 / 100); this.DefaultVolume = (ushort)(PropertiesConfig.Volumes.Master.Level * 65535 / 100);

View File

@@ -51,20 +51,6 @@ namespace PepperDash.Essentials
//************************ //************************
public override string SourceListKey
{
get
{
return _SourceListKey;
}
set
{
_SourceListKey = value;
SetCodecExternalSources();
}
}
protected override Func<bool> OnFeedbackFunc protected override Func<bool> OnFeedbackFunc
{ {
get get
@@ -338,7 +324,8 @@ namespace PepperDash.Essentials
CallTypeFeedback = new IntFeedback(() => 0); CallTypeFeedback = new IntFeedback(() => 0);
SourceListKey = "default"; SetSourceListKey();
EnablePowerOnToLastSource = true; EnablePowerOnToLastSource = true;
} }
catch (Exception e) catch (Exception e)
@@ -347,6 +334,21 @@ namespace PepperDash.Essentials
} }
} }
private void SetSourceListKey()
{
if (!string.IsNullOrEmpty(PropertiesConfig.SourceListKey))
{
SetSourceListKey(PropertiesConfig.SourceListKey);
}
else
{
SetSourceListKey(Key);
}
SetCodecExternalSources();
}
protected override void CustomSetConfig(DeviceConfig config) protected override void CustomSetConfig(DeviceConfig config)
{ {
var newPropertiesConfig = JsonConvert.DeserializeObject<EssentialsHuddleVtc1PropertiesConfig>(config.Properties.ToString()); var newPropertiesConfig = JsonConvert.DeserializeObject<EssentialsHuddleVtc1PropertiesConfig>(config.Properties.ToString());
@@ -370,13 +372,14 @@ namespace PepperDash.Essentials
this.LogoUrlLightBkgnd = PropertiesConfig.LogoLight.GetLogoUrlLight(); this.LogoUrlLightBkgnd = PropertiesConfig.LogoLight.GetLogoUrlLight();
this.LogoUrlDarkBkgnd = PropertiesConfig.LogoDark.GetLogoUrlDark(); this.LogoUrlDarkBkgnd = PropertiesConfig.LogoDark.GetLogoUrlDark();
this.SourceListKey = PropertiesConfig.SourceListKey;
this.DefaultSourceItem = PropertiesConfig.DefaultSourceItem; this.DefaultSourceItem = PropertiesConfig.DefaultSourceItem;
this.DefaultVolume = (ushort)(PropertiesConfig.Volumes.Master.Level * 65535 / 100); this.DefaultVolume = (ushort)(PropertiesConfig.Volumes.Master.Level * 65535 / 100);
return base.CustomActivate(); return base.CustomActivate();
} }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>

View File

@@ -130,6 +130,12 @@ namespace PepperDash.Essentials.Core
void Hardware_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) void Hardware_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args)
{ {
Debug.Console(2, this, "OnlineStatusChange Event. Online = {0}", args.DeviceOnLine); Debug.Console(2, this, "OnlineStatusChange Event. Online = {0}", args.DeviceOnLine);
if (!Hardware.Registered)
{
return; // protects in cases where device has been unregistered and feedbacks would attempt to access null sigs.
}
foreach (var feedback in Feedbacks) foreach (var feedback in Feedbacks)
{ {
if (feedback != null) if (feedback != null)

View File

@@ -18,42 +18,52 @@ namespace PepperDash_Essentials_Core.Queues
private bool _delayEnabled; private bool _delayEnabled;
private int _delayTime; private int _delayTime;
private const Thread.eThreadPriority _defaultPriority = Thread.eThreadPriority.MediumPriority;
/// <summary> /// <summary>
/// If the instance has been disposed. /// If the instance has been disposed.
/// </summary> /// </summary>
public bool Disposed { get; private set; } public bool Disposed { get; private set; }
/// <summary>
/// Returns the capacity of the CrestronQueue (fixed Size property)
/// </summary>
public int QueueCapacity
{
get
{
return _queue.Size;
}
}
/// <summary>
/// Returns the number of elements currently in the CrestronQueue
/// </summary>
public int QueueCount
{
get
{
return _queue.Count;
}
}
/// <summary> /// <summary>
/// Constructor with no thread priority /// Constructor with no thread priority
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
public GenericQueue(string key) public GenericQueue(string key)
: this(key, Thread.eThreadPriority.MediumPriority) : this(key, _defaultPriority, 0, 0)
{ {
} }
/// <summary> /// <summary>
/// Constructor for generic queue with no pacing /// Constructor with queue size
/// </summary> /// </summary>
/// <param name="key">Key</param> /// <param name="key"></param>
/// <param name="priority"></param> /// <param name="capacity">Fixed size for the queue to hold</param>
public GenericQueue(string key, Thread.eThreadPriority priority) public GenericQueue(string key, int capacity)
: this(key, _defaultPriority, capacity, 0)
{ {
_key = key;
_queue = new CrestronQueue<IQueueMessage>(25);
_worker = new Thread(ProcessQueue, null, Thread.eThreadStartOptions.Running)
{
Priority = priority
};
CrestronEnvironment.ProgramStatusEventHandler += programEvent =>
{
if (programEvent != eProgramStatusEventType.Stopping)
return;
Dispose();
};
} }
/// <summary> /// <summary>
@@ -61,10 +71,20 @@ namespace PepperDash_Essentials_Core.Queues
/// </summary> /// </summary>
/// <param name="key">Key</param> /// <param name="key">Key</param>
/// <param name="pacing">Pacing in ms between actions</param> /// <param name="pacing">Pacing in ms between actions</param>
public GenericQueue(string key, int pacing) public GenericQueue(int pacing, string key)
: this(key) : this(key, _defaultPriority, 0, pacing)
{
}
/// <summary>
/// Constructor with pacing and capacity
/// </summary>
/// <param name="key"></param>
/// <param name="pacing"></param>
/// <param name="capacity"></param>
public GenericQueue(string key, int pacing, int capacity)
: this(key, _defaultPriority, capacity, pacing)
{ {
SetDelayValues(pacing);
} }
/// <summary> /// <summary>
@@ -74,8 +94,52 @@ namespace PepperDash_Essentials_Core.Queues
/// <param name="pacing"></param> /// <param name="pacing"></param>
/// <param name="priority"></param> /// <param name="priority"></param>
public GenericQueue(string key, int pacing, Thread.eThreadPriority priority) public GenericQueue(string key, int pacing, Thread.eThreadPriority priority)
: this(key, priority) : this(key, priority, 0, pacing)
{ {
}
/// <summary>
/// Constructor with pacing, priority and capacity
/// </summary>
/// <param name="key"></param>
/// <param name="priority"></param>
/// <param name="capacity"></param>
public GenericQueue(string key, Thread.eThreadPriority priority, int capacity)
: this(key, priority, capacity, 0)
{
}
/// <summary>
/// Constructor with pacing, priority and capacity
/// </summary>
/// <param name="key"></param>
/// <param name="pacing"></param>
/// <param name="priority"></param>
/// <param name="capacity"></param>
public GenericQueue(string key, int pacing, Thread.eThreadPriority priority, int capacity)
: this(key, priority, capacity, pacing)
{
}
/// <summary>
/// Constructor for generic queue with no pacing
/// </summary>
/// <param name="key">Key</param>
/// <param name="priority"></param>
private GenericQueue(string key, Thread.eThreadPriority priority, int capacity, int pacing)
{
_key = key;
int cap = 25; // sets default
if (capacity > 0)
{
cap = capacity; // overrides default
}
_queue = new CrestronQueue<IQueueMessage>(cap);
_worker = new Thread(ProcessQueue, null, Thread.eThreadStartOptions.Running)
{
Priority = priority
};
SetDelayValues(pacing); SetDelayValues(pacing);
} }
@@ -83,6 +147,14 @@ namespace PepperDash_Essentials_Core.Queues
{ {
_delayEnabled = pacing > 0; _delayEnabled = pacing > 0;
_delayTime = pacing; _delayTime = pacing;
CrestronEnvironment.ProgramStatusEventHandler += programEvent =>
{
if (programEvent != eProgramStatusEventType.Stopping)
return;
Dispose();
};
} }
/// <summary> /// <summary>

View File

@@ -53,18 +53,22 @@ namespace PepperDash.Essentials.Core
/// </summary> /// </summary>
/// ///
protected string _SourceListKey; protected string _SourceListKey;
public virtual string SourceListKey { public string SourceListKey {
get get
{ {
return _SourceListKey; return _SourceListKey;
} }
set private set
{ {
_SourceListKey = value; if (value != _SourceListKey)
{
_SourceListKey = value;
}
} }
} }
protected const string _defaultSourceListKey = "default";
/// <summary> /// <summary>
/// Timer used for informing the UIs of a shutdown /// Timer used for informing the UIs of a shutdown
/// </summary> /// </summary>
@@ -160,6 +164,22 @@ namespace PepperDash.Essentials.Core
return base.CustomActivate(); return base.CustomActivate();
} }
/// <summary>
/// Sets the SourceListKey property to the passed in value or the default if no value passed in
/// </summary>
/// <param name="sourceListKey"></param>
protected void SetSourceListKey(string sourceListKey)
{
if (!string.IsNullOrEmpty(sourceListKey))
{
SourceListKey = sourceListKey;
}
else
{
sourceListKey = _defaultSourceListKey;
}
}
/// <summary> /// <summary>
/// If mobile control is enabled, sets the appropriate properties /// If mobile control is enabled, sets the appropriate properties
/// </summary> /// </summary>

View File

@@ -1,46 +1,46 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
//using Crestron.SimplSharpPro.DeviceSupport; //using Crestron.SimplSharpPro.DeviceSupport;
using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DeviceSupport;
using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM;
using Crestron.SimplSharpPro.DM.Endpoints; using Crestron.SimplSharpPro.DM.Endpoints;
using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; using Crestron.SimplSharpPro.DM.Endpoints.Transmitters;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Bridges;
using PepperDash.Essentials.DM.Config; using PepperDash.Essentials.DM.Config;
namespace PepperDash.Essentials.DM namespace PepperDash.Essentials.DM
{ {
using eVst = DmTx401C.eSourceSelection; using eVst = DmTx401C.eSourceSelection;
[Description("Wrapper class for DM-TX-401-C")] [Description("Wrapper class for DM-TX-401-C")]
public class DmTx401CController : DmTxControllerBase, ITxRoutingWithFeedback, IIROutputPorts, IComPorts, IHasFreeRun, IVgaBrightnessContrastControls public class DmTx401CController : DmTxControllerBase, ITxRoutingWithFeedback, IIROutputPorts, IComPorts, IHasFreeRun, IVgaBrightnessContrastControls
{ {
public DmTx401C Tx { get; private set; } public DmTx401C Tx { get; private set; }
public RoutingInputPortWithVideoStatuses HdmiIn { get; private set; } public RoutingInputPortWithVideoStatuses HdmiIn { get; private set; }
public RoutingInputPortWithVideoStatuses DisplayPortIn { get; private set; } public RoutingInputPortWithVideoStatuses DisplayPortIn { get; private set; }
public RoutingInputPortWithVideoStatuses VgaIn { get; private set; } public RoutingInputPortWithVideoStatuses VgaIn { get; private set; }
public RoutingInputPortWithVideoStatuses CompositeIn { get; private set; } public RoutingInputPortWithVideoStatuses CompositeIn { get; private set; }
public RoutingOutputPort DmOut { get; private set; } public RoutingOutputPort DmOut { get; private set; }
public override StringFeedback ActiveVideoInputFeedback { get; protected set; } public override StringFeedback ActiveVideoInputFeedback { get; protected set; }
public IntFeedback VideoSourceNumericFeedback { get; protected set; } public IntFeedback VideoSourceNumericFeedback { get; protected set; }
public IntFeedback AudioSourceNumericFeedback { get; protected set; } public IntFeedback AudioSourceNumericFeedback { get; protected set; }
public IntFeedback HdmiInHdcpCapabilityFeedback { get; protected set; } public IntFeedback HdmiInHdcpCapabilityFeedback { get; protected set; }
public BoolFeedback DisplayPortVideoSyncFeedback { get; protected set; } public BoolFeedback DisplayPortVideoSyncFeedback { get; protected set; }
public BoolFeedback HdmiVideoSyncFeedback { get; protected set; } public BoolFeedback HdmiVideoSyncFeedback { get; protected set; }
public BoolFeedback VgaVideoSyncFeedback { get; protected set; } public BoolFeedback VgaVideoSyncFeedback { get; protected set; }
public BoolFeedback FreeRunEnabledFeedback { get; protected set; } public BoolFeedback FreeRunEnabledFeedback { get; protected set; }
public IntFeedback VgaBrightnessFeedback { get; protected set; } public IntFeedback VgaBrightnessFeedback { get; protected set; }
public IntFeedback VgaContrastFeedback { get; protected set; } public IntFeedback VgaContrastFeedback { get; protected set; }
//IroutingNumericEvent //IroutingNumericEvent
@@ -54,88 +54,88 @@ namespace PepperDash.Essentials.DM
{ {
var newEvent = NumericSwitchChange; var newEvent = NumericSwitchChange;
if (newEvent != null) newEvent(this, e); if (newEvent != null) newEvent(this, e);
} }
/// <summary> /// <summary>
/// Helps get the "real" inputs, including when in Auto /// Helps get the "real" inputs, including when in Auto
/// </summary> /// </summary>
public BaseDmTx401.eSourceSelection ActualVideoInput public BaseDmTx401.eSourceSelection ActualVideoInput
{ {
get get
{ {
if (Tx.VideoSourceFeedback != BaseDmTx401.eSourceSelection.Auto) if (Tx.VideoSourceFeedback != BaseDmTx401.eSourceSelection.Auto)
return Tx.VideoSourceFeedback; return Tx.VideoSourceFeedback;
else // auto else // auto
{ {
if (Tx.HdmiInput.SyncDetectedFeedback.BoolValue) if (Tx.HdmiInput.SyncDetectedFeedback.BoolValue)
return BaseDmTx401.eSourceSelection.HDMI; return BaseDmTx401.eSourceSelection.HDMI;
else if (Tx.VgaInput.SyncDetectedFeedback.BoolValue) else if (Tx.VgaInput.SyncDetectedFeedback.BoolValue)
return BaseDmTx401.eSourceSelection.VGA; return BaseDmTx401.eSourceSelection.VGA;
else if (Tx.DisplayPortInput.SyncDetectedFeedback.BoolValue) else if (Tx.DisplayPortInput.SyncDetectedFeedback.BoolValue)
return BaseDmTx401.eSourceSelection.DisplayPort; return BaseDmTx401.eSourceSelection.DisplayPort;
else if (Tx.CvbsInput.SyncDetectedFeedback.BoolValue) else if (Tx.CvbsInput.SyncDetectedFeedback.BoolValue)
return BaseDmTx401.eSourceSelection.Composite; return BaseDmTx401.eSourceSelection.Composite;
else else
return BaseDmTx401.eSourceSelection.Disabled; return BaseDmTx401.eSourceSelection.Disabled;
} }
} }
} }
public RoutingPortCollection<RoutingInputPort> InputPorts public RoutingPortCollection<RoutingInputPort> InputPorts
{ {
get get
{ {
return new RoutingPortCollection<RoutingInputPort> return new RoutingPortCollection<RoutingInputPort>
{ {
HdmiIn, HdmiIn,
DisplayPortIn, DisplayPortIn,
VgaIn, VgaIn,
CompositeIn, CompositeIn,
AnyVideoInput AnyVideoInput
}; };
} }
} }
public RoutingPortCollection<RoutingOutputPort> OutputPorts public RoutingPortCollection<RoutingOutputPort> OutputPorts
{ {
get get
{ {
return new RoutingPortCollection<RoutingOutputPort> { DmOut }; return new RoutingPortCollection<RoutingOutputPort> { DmOut };
} }
} }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
/// <param name="key"></param> /// <param name="key"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <param name="tx"></param> /// <param name="tx"></param>
public DmTx401CController(string key, string name, DmTx401C tx) public DmTx401CController(string key, string name, DmTx401C tx)
: base(key, name, tx) : base(key, name, tx)
{ {
Tx = tx; Tx = tx;
HdmiIn = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn, HdmiIn = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn,
eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.HDMI, this, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.HDMI, this,
VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInput)) VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInput))
{ {
FeedbackMatchObject = eVst.HDMI FeedbackMatchObject = eVst.HDMI
}; };
DisplayPortIn = new RoutingInputPortWithVideoStatuses(DmPortName.DisplayPortIn, DisplayPortIn = new RoutingInputPortWithVideoStatuses(DmPortName.DisplayPortIn,
eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.DisplayPort, this, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.DisplayPort, this,
VideoStatusHelper.GetDisplayPortInputStatusFuncs(tx.DisplayPortInput)) VideoStatusHelper.GetDisplayPortInputStatusFuncs(tx.DisplayPortInput))
{ {
FeedbackMatchObject = eVst.DisplayPort FeedbackMatchObject = eVst.DisplayPort
}; };
VgaIn = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn, VgaIn = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn,
eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, eVst.VGA, this, eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, eVst.VGA, this,
VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput)) VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput))
{ {
FeedbackMatchObject = eVst.VGA FeedbackMatchObject = eVst.VGA
}; };
CompositeIn = new RoutingInputPortWithVideoStatuses(DmPortName.CompositeIn, CompositeIn = new RoutingInputPortWithVideoStatuses(DmPortName.CompositeIn,
eRoutingSignalType.Video, eRoutingPortConnectionType.Composite, eVst.Composite, this, eRoutingSignalType.Video, eRoutingPortConnectionType.Composite, eVst.Composite, this,
VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput)) VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput))
{ {
FeedbackMatchObject = eVst.Composite FeedbackMatchObject = eVst.Composite
@@ -146,185 +146,184 @@ namespace PepperDash.Essentials.DM
Tx.BaseEvent += Tx_BaseEvent; Tx.BaseEvent += Tx_BaseEvent;
Tx.OnlineStatusChange += Tx_OnlineStatusChange; Tx.OnlineStatusChange += Tx_OnlineStatusChange;
Tx.VgaInput.InputStreamChange += VgaInputOnInputStreamChange; Tx.VgaInput.InputStreamChange += VgaInputOnInputStreamChange;
tx.VgaInput.VideoControls.ControlChange += VideoControls_ControlChange; tx.VgaInput.VideoControls.ControlChange += VideoControls_ControlChange;
ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput",
() => ActualVideoInput.ToString()); () => ActualVideoInput.ToString());
VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback);
AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.AudioSourceFeedback); AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.AudioSourceFeedback);
HdmiInHdcpCapabilityFeedback = new IntFeedback("HdmiInHdcpCapability", () => tx.HdmiInput.HdcpSupportOnFeedback.BoolValue ? 1 : 0); HdmiInHdcpCapabilityFeedback = new IntFeedback("HdmiInHdcpCapability", () => tx.HdmiInput.HdcpSupportOnFeedback.BoolValue ? 1 : 0);
HdcpStateFeedback = HdmiInHdcpCapabilityFeedback; HdcpStateFeedback = HdmiInHdcpCapabilityFeedback;
HdcpSupportCapability = eHdcpCapabilityType.HdcpAutoSupport; HdcpSupportCapability = eHdcpCapabilityType.HdcpAutoSupport;
DisplayPortVideoSyncFeedback = new BoolFeedback("DisplayPortVideoSync", () => (bool)tx.DisplayPortInput.SyncDetectedFeedback.BoolValue); DisplayPortVideoSyncFeedback = new BoolFeedback("DisplayPortVideoSync", () => (bool)tx.DisplayPortInput.SyncDetectedFeedback.BoolValue);
HdmiVideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInput.SyncDetectedFeedback.BoolValue); HdmiVideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInput.SyncDetectedFeedback.BoolValue);
VgaVideoSyncFeedback = new BoolFeedback(() => (bool)tx.VgaInput.SyncDetectedFeedback.BoolValue); VgaVideoSyncFeedback = new BoolFeedback(() => (bool)tx.VgaInput.SyncDetectedFeedback.BoolValue);
FreeRunEnabledFeedback = new BoolFeedback(() => tx.VgaInput.FreeRunFeedback == eDmFreeRunSetting.Enabled); FreeRunEnabledFeedback = new BoolFeedback(() => tx.VgaInput.FreeRunFeedback == eDmFreeRunSetting.Enabled);
VgaBrightnessFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.BrightnessFeedback.UShortValue); VgaBrightnessFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.BrightnessFeedback.UShortValue);
VgaContrastFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.ContrastFeedback.UShortValue); VgaContrastFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.ContrastFeedback.UShortValue);
var combinedFuncs = new VideoStatusFuncsWrapper var combinedFuncs = new VideoStatusFuncsWrapper
{ {
HdcpActiveFeedbackFunc = () => HdcpActiveFeedbackFunc = () =>
(ActualVideoInput == eVst.HDMI (ActualVideoInput == eVst.HDMI
&& tx.HdmiInput.VideoAttributes.HdcpActiveFeedback.BoolValue) && tx.HdmiInput.VideoAttributes.HdcpActiveFeedback.BoolValue)
|| (ActualVideoInput == eVst.DisplayPort || (ActualVideoInput == eVst.DisplayPort
&& tx.DisplayPortInput.VideoAttributes.HdcpActiveFeedback.BoolValue), && tx.DisplayPortInput.VideoAttributes.HdcpActiveFeedback.BoolValue),
HdcpStateFeedbackFunc = () => HdcpStateFeedbackFunc = () =>
{ {
if (ActualVideoInput == eVst.HDMI) if (ActualVideoInput == eVst.HDMI)
return tx.HdmiInput.VideoAttributes.HdcpStateFeedback.ToString(); return tx.HdmiInput.VideoAttributes.HdcpStateFeedback.ToString();
if (ActualVideoInput == eVst.DisplayPort) if (ActualVideoInput == eVst.DisplayPort)
return tx.DisplayPortInput.VideoAttributes.HdcpStateFeedback.ToString(); return tx.DisplayPortInput.VideoAttributes.HdcpStateFeedback.ToString();
return ""; return "";
}, },
VideoResolutionFeedbackFunc = () => VideoResolutionFeedbackFunc = () =>
{ {
if (ActualVideoInput == eVst.HDMI) if (ActualVideoInput == eVst.HDMI)
return tx.HdmiInput.VideoAttributes.GetVideoResolutionString(); return tx.HdmiInput.VideoAttributes.GetVideoResolutionString();
if (ActualVideoInput == eVst.DisplayPort) if (ActualVideoInput == eVst.DisplayPort)
return tx.DisplayPortInput.VideoAttributes.GetVideoResolutionString(); return tx.DisplayPortInput.VideoAttributes.GetVideoResolutionString();
if (ActualVideoInput == eVst.VGA) if (ActualVideoInput == eVst.VGA)
return tx.VgaInput.VideoAttributes.GetVideoResolutionString(); return tx.VgaInput.VideoAttributes.GetVideoResolutionString();
if (ActualVideoInput == eVst.Composite) if (ActualVideoInput == eVst.Composite)
return tx.CvbsInput.VideoAttributes.GetVideoResolutionString(); return tx.CvbsInput.VideoAttributes.GetVideoResolutionString();
return ""; return "";
}, },
VideoSyncFeedbackFunc = () => VideoSyncFeedbackFunc = () =>
(ActualVideoInput == eVst.HDMI (ActualVideoInput == eVst.HDMI
&& tx.HdmiInput.SyncDetectedFeedback.BoolValue) && tx.HdmiInput.SyncDetectedFeedback.BoolValue)
|| (ActualVideoInput == eVst.DisplayPort || (ActualVideoInput == eVst.DisplayPort
&& tx.DisplayPortInput.SyncDetectedFeedback.BoolValue) && tx.DisplayPortInput.SyncDetectedFeedback.BoolValue)
|| (ActualVideoInput == eVst.VGA || (ActualVideoInput == eVst.VGA
&& tx.VgaInput.SyncDetectedFeedback.BoolValue) && tx.VgaInput.SyncDetectedFeedback.BoolValue)
|| (ActualVideoInput == eVst.Composite || (ActualVideoInput == eVst.Composite
&& tx.CvbsInput.SyncDetectedFeedback.BoolValue) && tx.CvbsInput.SyncDetectedFeedback.BoolValue)
}; };
AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn,
eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs); eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs);
DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video,
eRoutingPortConnectionType.DmCat, null, this); eRoutingPortConnectionType.DmCat, null, this);
AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback,
AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback,
AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback,
AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiInHdcpCapabilityFeedback, DisplayPortVideoSyncFeedback, AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiInHdcpCapabilityFeedback, DisplayPortVideoSyncFeedback,
HdmiVideoSyncFeedback, VgaVideoSyncFeedback); HdmiVideoSyncFeedback, VgaVideoSyncFeedback);
// Set Ports for CEC // Set Ports for CEC
DisplayPortIn.Port = Tx.DisplayPortInput; DisplayPortIn.Port = Tx.DisplayPortInput;
HdmiIn.Port = Tx.HdmiInput; HdmiIn.Port = Tx.HdmiInput;
DmOut.Port = Tx.DmOutput; DmOut.Port = Tx.DmOutput;
} }
public override bool CustomActivate() public override bool CustomActivate()
{ {
// Link up all of these damned events to the various RoutingPorts via a helper handler // 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.InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn, a.EventId);
Tx.HdmiInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn, a.EventId); Tx.HdmiInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn, a.EventId);
Tx.DisplayPortInput.InputStreamChange += (o, a) => FowardInputStreamChange(DisplayPortIn, a.EventId); Tx.DisplayPortInput.InputStreamChange += (o, a) => FowardInputStreamChange(DisplayPortIn, a.EventId);
Tx.DisplayPortInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(DisplayPortIn, a.EventId); Tx.DisplayPortInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(DisplayPortIn, a.EventId);
Tx.VgaInput.InputStreamChange += (o, a) => FowardInputStreamChange(VgaIn, a.EventId); Tx.VgaInput.InputStreamChange += (o, a) => FowardInputStreamChange(VgaIn, a.EventId);
Tx.VgaInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(VgaIn, a.EventId); Tx.VgaInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(VgaIn, a.EventId);
// Base does register and sets up comm monitoring. // Base does register and sets up comm monitoring.
return base.CustomActivate(); return base.CustomActivate();
} }
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
{ {
var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); var joinMap = GetDmTxJoinMap(joinStart, joinMapKey);
if (HdmiVideoSyncFeedback != null) if (HdmiVideoSyncFeedback != null)
{
HdmiVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]);
}
if (VgaVideoSyncFeedback != null)
{ {
VgaVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); HdmiVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]);
} }
if (VgaVideoSyncFeedback != null)
LinkDmTxToApi(this, trilist, joinMap, bridge); {
} VgaVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]);
}
public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type)
{ LinkDmTxToApi(this, trilist, joinMap, bridge);
Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); }
switch (input) public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type)
{ {
case 0: Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input);
{
ExecuteSwitch(eVst.Auto, null, type); switch (input)
break; {
} case 0:
case 1: {
{ ExecuteSwitch(eVst.Auto, null, type);
ExecuteSwitch(DisplayPortIn.Selector, null, type); break;
break; }
} case 1:
case 2: {
{ ExecuteSwitch(DisplayPortIn.Selector, null, type);
ExecuteSwitch(HdmiIn.Selector, null, type); break;
break; }
} case 2:
case 3: {
{ ExecuteSwitch(HdmiIn.Selector, null, type);
ExecuteSwitch(VgaIn.Selector, null, type); break;
break; }
} case 3:
case 4: {
{ ExecuteSwitch(VgaIn.Selector, null, type);
ExecuteSwitch(CompositeIn.Selector, null, type); break;
break; }
} case 4:
case 5: {
{ ExecuteSwitch(CompositeIn.Selector, null, type);
ExecuteSwitch(eVst.Disabled, null, type); break;
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) public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType)
Tx.AudioSource = (eVst)inputSelector; {
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) void Tx_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args)
{ {
var localVideoInputPort = var localVideoInputPort =
InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback); InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback);
var localAudioInputPort = var localAudioInputPort =
InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.AudioSourceFeedback); InputPorts.FirstOrDefault(p => (eVst)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, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video));
OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localAudioInputPort, eRoutingSignalType.Audio)); OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localAudioInputPort, eRoutingSignalType.Audio));
} }
void Tx_BaseEvent(GenericBase device, BaseEventArgs args) void Tx_BaseEvent(GenericBase device, BaseEventArgs args)
@@ -348,7 +347,7 @@ namespace PepperDash.Essentials.DM
OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio)); OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio));
break; break;
} }
} }
void VideoControls_ControlChange(object sender, GenericEventArgs args) void VideoControls_ControlChange(object sender, GenericEventArgs args)
{ {
@@ -364,7 +363,7 @@ namespace PepperDash.Essentials.DM
VgaContrastFeedback.FireUpdate(); VgaContrastFeedback.FireUpdate();
break; break;
} }
} }
/// <summary> /// <summary>
/// Enables or disables free run /// Enables or disables free run
@@ -391,10 +390,10 @@ namespace PepperDash.Essentials.DM
public void SetVgaContrast(ushort level) public void SetVgaContrast(ushort level)
{ {
Tx.VgaInput.VideoControls.Contrast.UShortValue = level; Tx.VgaInput.VideoControls.Contrast.UShortValue = level;
} }
/// <summary> /// <summary>
/// Relays the input stream change to the appropriate RoutingInputPort. /// Relays the input stream change to the appropriate RoutingInputPort.
/// </summary> /// </summary>
void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId)
{ {
@@ -404,36 +403,36 @@ namespace PepperDash.Essentials.DM
} }
inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); inputPort.VideoStatus.VideoSyncFeedback.FireUpdate();
AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate();
} }
/// <summary> /// <summary>
/// Relays the VideoAttributes change to a RoutingInputPort /// Relays the VideoAttributes change to a RoutingInputPort
/// </summary> /// </summary>
void ForwardVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) void ForwardVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId)
{ {
//// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds
//Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}",
// args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType());
switch (eventId) switch (eventId)
{ {
case VideoAttributeEventIds.HdcpActiveFeedbackEventId: case VideoAttributeEventIds.HdcpActiveFeedbackEventId:
inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate();
AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate();
break; break;
case VideoAttributeEventIds.HdcpStateFeedbackEventId: case VideoAttributeEventIds.HdcpStateFeedbackEventId:
inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); inputPort.VideoStatus.HdcpStateFeedback.FireUpdate();
AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate();
break; break;
case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId:
case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: case VideoAttributeEventIds.VerticalResolutionFeedbackEventId:
inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate();
AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate();
break; break;
case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: case VideoAttributeEventIds.FramesPerSecondFeedbackEventId:
inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate();
AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate();
break; break;
} }
} }
void HdmiInputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) void HdmiInputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args)
@@ -477,18 +476,18 @@ namespace PepperDash.Essentials.DM
VgaVideoSyncFeedback.FireUpdate(); VgaVideoSyncFeedback.FireUpdate();
break; break;
} }
} }
#region IIROutputPorts Members #region IIROutputPorts Members
public CrestronCollection<IROutputPort> IROutputPorts { get { return Tx.IROutputPorts; } } public CrestronCollection<IROutputPort> IROutputPorts { get { return Tx.IROutputPorts; } }
public int NumberOfIROutputPorts { get { return Tx.NumberOfIROutputPorts; } } public int NumberOfIROutputPorts { get { return Tx.NumberOfIROutputPorts; } }
#endregion #endregion
#region IComPorts Members #region IComPorts Members
public CrestronCollection<ComPort> ComPorts { get { return Tx.ComPorts; } } public CrestronCollection<ComPort> ComPorts { get { return Tx.ComPorts; } }
public int NumberOfComPorts { get { return Tx.NumberOfComPorts; } } public int NumberOfComPorts { get { return Tx.NumberOfComPorts; } }
#endregion #endregion
} }
} }