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

@@ -202,10 +202,24 @@ namespace PepperDash.Essentials
}; };
} }
SourceListKey = "default"; SetSourceListKey();
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

@@ -315,16 +315,15 @@ namespace PepperDash.Essentials.DM
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)