Adds new event to DeviceManager to indicate that all devices have been activated. Necessary for MicrophonePrivacyManager

#485
This commit is contained in:
Neil Dorin
2020-11-12 12:33:04 -07:00
parent 73addfefe7
commit 3d224496a8
3 changed files with 437 additions and 420 deletions

View File

@@ -41,12 +41,12 @@ namespace PepperDash.Essentials.Core.CrestronIO
{ {
InputPort = postActivationFunc(config); InputPort = postActivationFunc(config);
InputPort.Register();
InputPort.SetVersiportConfiguration(eVersiportConfiguration.DigitalInput); InputPort.SetVersiportConfiguration(eVersiportConfiguration.DigitalInput);
if (config.DisablePullUpResistor) if (config.DisablePullUpResistor)
InputPort.DisablePullUpResistor = true; InputPort.DisablePullUpResistor = true;
InputPort.Register();
InputPort.VersiportChange += InputPort_VersiportChange; InputPort.VersiportChange += InputPort_VersiportChange;

View File

@@ -13,6 +13,8 @@ namespace PepperDash.Essentials.Core
{ {
public static class DeviceManager public static class DeviceManager
{ {
public static event EventHandler<EventArgs> AllDevicesActivated;
private static readonly CCriticalSection DeviceCriticalSection = new CCriticalSection(); private static readonly CCriticalSection DeviceCriticalSection = new CCriticalSection();
private static readonly CEvent AllowAddDevicesCEvent = new CEvent(false, true); private static readonly CEvent AllowAddDevicesCEvent = new CEvent(false, true);
//public static List<Device> Devices { get { return _Devices; } } //public static List<Device> Devices { get { return _Devices; } }
@@ -98,6 +100,8 @@ namespace PepperDash.Essentials.Core
Debug.Console(0, d, "ERROR: Device PostActivation failure:\r{0}", e); Debug.Console(0, d, "ERROR: Device PostActivation failure:\r{0}", e);
} }
} }
OnAllDevicesActivated();
} }
finally finally
{ {
@@ -105,6 +109,15 @@ namespace PepperDash.Essentials.Core
} }
} }
private static void OnAllDevicesActivated()
{
var handler = AllDevicesActivated;
if (handler != null)
{
handler(null, new EventArgs());
}
}
/// <summary> /// <summary>
/// Calls activate on all Device class items /// Calls activate on all Device class items
/// </summary> /// </summary>

View File

@@ -88,8 +88,12 @@ namespace PepperDash.Essentials.Core.Privacy
else else
Debug.Console(0, this, "Unable to add Red LED device"); Debug.Console(0, this, "Unable to add Red LED device");
DeviceManager.AllDevicesActivated += (o, a) =>
{
CheckPrivacyMode();
};
AddPostActivationAction(() => { AddPostActivationAction(() => {
CheckPrivacyMode();
PrivacyDevice.PrivacyModeIsOnFeedback.OutputChange -= PrivacyModeIsOnFeedback_OutputChange; PrivacyDevice.PrivacyModeIsOnFeedback.OutputChange -= PrivacyModeIsOnFeedback_OutputChange;
PrivacyDevice.PrivacyModeIsOnFeedback.OutputChange += PrivacyModeIsOnFeedback_OutputChange; PrivacyDevice.PrivacyModeIsOnFeedback.OutputChange += PrivacyModeIsOnFeedback_OutputChange;
}); });