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

@@ -1,342 +1,355 @@
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 System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
using PepperDash.Core; using PepperDash.Core;
namespace PepperDash.Essentials.Core namespace PepperDash.Essentials.Core
{ {
public static class DeviceManager public static class DeviceManager
{ {
private static readonly CCriticalSection DeviceCriticalSection = new CCriticalSection(); public static event EventHandler<EventArgs> AllDevicesActivated;
private static readonly CEvent AllowAddDevicesCEvent = new CEvent(false, true);
//public static List<Device> Devices { get { return _Devices; } } private static readonly CCriticalSection DeviceCriticalSection = new CCriticalSection();
//static List<Device> _Devices = new List<Device>(); private static readonly CEvent AllowAddDevicesCEvent = new CEvent(false, true);
//public static List<Device> Devices { get { return _Devices; } }
static readonly Dictionary<string, IKeyed> Devices = new Dictionary<string, IKeyed>(StringComparer.OrdinalIgnoreCase); //static List<Device> _Devices = new List<Device>();
/// <summary> static readonly Dictionary<string, IKeyed> Devices = new Dictionary<string, IKeyed>(StringComparer.OrdinalIgnoreCase);
/// Returns a copy of all the devices in a list
/// </summary> /// <summary>
public static List<IKeyed> AllDevices { get { return new List<IKeyed>(Devices.Values); } } /// Returns a copy of all the devices in a list
/// </summary>
public static bool AddDeviceEnabled; public static List<IKeyed> AllDevices { get { return new List<IKeyed>(Devices.Values); } }
public static void Initialize(CrestronControlSystem cs) public static bool AddDeviceEnabled;
{
AddDeviceEnabled = true; public static void Initialize(CrestronControlSystem cs)
CrestronConsole.AddNewConsoleCommand(ListDeviceCommStatuses, "devcommstatus", "Lists the communication status of all devices", {
ConsoleAccessLevelEnum.AccessOperator); AddDeviceEnabled = true;
CrestronConsole.AddNewConsoleCommand(ListDeviceFeedbacks, "devfb", "Lists current feedbacks", CrestronConsole.AddNewConsoleCommand(ListDeviceCommStatuses, "devcommstatus", "Lists the communication status of all devices",
ConsoleAccessLevelEnum.AccessOperator); ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(ListDevices, "devlist", "Lists current managed devices", CrestronConsole.AddNewConsoleCommand(ListDeviceFeedbacks, "devfb", "Lists current feedbacks",
ConsoleAccessLevelEnum.AccessOperator); ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(DeviceJsonApi.DoDeviceActionWithJson, "devjson", "", CrestronConsole.AddNewConsoleCommand(ListDevices, "devlist", "Lists current managed devices",
ConsoleAccessLevelEnum.AccessOperator); ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s => CrestronConsole.ConsoleCommandResponse(DeviceJsonApi.GetProperties(s)), "devprops", "", ConsoleAccessLevelEnum.AccessOperator); CrestronConsole.AddNewConsoleCommand(DeviceJsonApi.DoDeviceActionWithJson, "devjson", "",
CrestronConsole.AddNewConsoleCommand(s => CrestronConsole.ConsoleCommandResponse(DeviceJsonApi.GetMethods(s)), "devmethods", "", ConsoleAccessLevelEnum.AccessOperator); ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s => CrestronConsole.ConsoleCommandResponse(DeviceJsonApi.GetApiMethods(s)), "apimethods", "", ConsoleAccessLevelEnum.AccessOperator); CrestronConsole.AddNewConsoleCommand(s => CrestronConsole.ConsoleCommandResponse(DeviceJsonApi.GetProperties(s)), "devprops", "", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(SimulateComReceiveOnDevice, "devsimreceive", CrestronConsole.AddNewConsoleCommand(s => CrestronConsole.ConsoleCommandResponse(DeviceJsonApi.GetMethods(s)), "devmethods", "", ConsoleAccessLevelEnum.AccessOperator);
"Simulates incoming data on a com device", ConsoleAccessLevelEnum.AccessOperator); CrestronConsole.AddNewConsoleCommand(s => CrestronConsole.ConsoleCommandResponse(DeviceJsonApi.GetApiMethods(s)), "apimethods", "", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(SimulateComReceiveOnDevice, "devsimreceive",
CrestronConsole.AddNewConsoleCommand(s => SetDeviceStreamDebugging(s), "setdevicestreamdebug", "set comm debug [deviceKey] [off/rx/tx/both] ([minutes])", ConsoleAccessLevelEnum.AccessOperator); "Simulates incoming data on a com device", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s => DisableAllDeviceStreamDebugging(), "disableallstreamdebug", "disables stream debugging on all devices", ConsoleAccessLevelEnum.AccessOperator);
} CrestronConsole.AddNewConsoleCommand(s => SetDeviceStreamDebugging(s), "setdevicestreamdebug", "set comm debug [deviceKey] [off/rx/tx/both] ([minutes])", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s => DisableAllDeviceStreamDebugging(), "disableallstreamdebug", "disables stream debugging on all devices", ConsoleAccessLevelEnum.AccessOperator);
/// <summary> }
/// Calls activate steps on all Device class items
/// </summary> /// <summary>
public static void ActivateAll() /// Calls activate steps on all Device class items
{ /// </summary>
try public static void ActivateAll()
{ {
DeviceCriticalSection.Enter(); try
AddDeviceEnabled = false; {
// PreActivate all devices DeviceCriticalSection.Enter();
foreach (var d in Devices.Values) AddDeviceEnabled = false;
{ // PreActivate all devices
try foreach (var d in Devices.Values)
{ {
if (d is Device) try
(d as Device).PreActivate(); {
} if (d is Device)
catch (Exception e) (d as Device).PreActivate();
{ }
Debug.Console(0, d, "ERROR: Device PreActivation failure:\r{0}", e); catch (Exception e)
} {
} Debug.Console(0, d, "ERROR: Device PreActivation failure:\r{0}", e);
}
// Activate all devices }
foreach (var d in Devices.Values)
{ // Activate all devices
try foreach (var d in Devices.Values)
{ {
if (d is Device) try
(d as Device).Activate(); {
} if (d is Device)
catch (Exception e) (d as Device).Activate();
{ }
Debug.Console(0, d, "ERROR: Device Activation failure:\r{0}", e); catch (Exception e)
} {
} Debug.Console(0, d, "ERROR: Device Activation failure:\r{0}", e);
}
// PostActivate all devices }
foreach (var d in Devices.Values)
{ // PostActivate all devices
try foreach (var d in Devices.Values)
{ {
if (d is Device) try
(d as Device).PostActivate(); {
} if (d is Device)
catch (Exception e) (d as Device).PostActivate();
{ }
Debug.Console(0, d, "ERROR: Device PostActivation failure:\r{0}", e); catch (Exception e)
} {
} Debug.Console(0, d, "ERROR: Device PostActivation failure:\r{0}", e);
} }
finally }
{
DeviceCriticalSection.Leave(); OnAllDevicesActivated();
} }
} finally
{
/// <summary> DeviceCriticalSection.Leave();
/// Calls activate on all Device class items }
/// </summary> }
public static void DeactivateAll()
{ private static void OnAllDevicesActivated()
try {
{ var handler = AllDevicesActivated;
DeviceCriticalSection.Enter(); if (handler != null)
foreach (var d in Devices.Values.OfType<Device>()) {
{ handler(null, new EventArgs());
d.Deactivate(); }
} }
}
finally /// <summary>
{ /// Calls activate on all Device class items
DeviceCriticalSection.Leave(); /// </summary>
} public static void DeactivateAll()
} {
try
//static void ListMethods(string devKey) {
//{ DeviceCriticalSection.Enter();
// var dev = GetDeviceForKey(devKey); foreach (var d in Devices.Values.OfType<Device>())
// if(dev != null) {
// { d.Deactivate();
// var type = dev.GetType().GetCType(); }
// var methods = type.GetMethods(BindingFlags.Public|BindingFlags.Instance); }
// var sb = new StringBuilder(); finally
// sb.AppendLine(string.Format("{2} methods on [{0}] ({1}):", dev.Key, type.Name, methods.Length)); {
// foreach (var m in methods) DeviceCriticalSection.Leave();
// { }
// sb.Append(string.Format("{0}(", m.Name)); }
// var pars = m.GetParameters();
// foreach (var p in pars) //static void ListMethods(string devKey)
// sb.Append(string.Format("({1}){0} ", p.Name, p.ParameterType.Name)); //{
// sb.AppendLine(")"); // var dev = GetDeviceForKey(devKey);
// } // if(dev != null)
// CrestronConsole.ConsoleCommandResponse(sb.ToString()); // {
// } // var type = dev.GetType().GetCType();
//} // var methods = type.GetMethods(BindingFlags.Public|BindingFlags.Instance);
// var sb = new StringBuilder();
private static void ListDevices(string s) // sb.AppendLine(string.Format("{2} methods on [{0}] ({1}):", dev.Key, type.Name, methods.Length));
{ // foreach (var m in methods)
Debug.Console(0, "{0} Devices registered with Device Manager:", Devices.Count); // {
var sorted = Devices.Values.ToList(); // sb.Append(string.Format("{0}(", m.Name));
sorted.Sort((a, b) => a.Key.CompareTo(b.Key)); // var pars = m.GetParameters();
// foreach (var p in pars)
foreach (var d in sorted) // sb.Append(string.Format("({1}){0} ", p.Name, p.ParameterType.Name));
{ // sb.AppendLine(")");
var name = d is IKeyName ? (d as IKeyName).Name : "---"; // }
Debug.Console(0, " [{0}] {1}", d.Key, name); // CrestronConsole.ConsoleCommandResponse(sb.ToString());
} // }
} //}
private static void ListDeviceFeedbacks(string devKey) private static void ListDevices(string s)
{ {
var dev = GetDeviceForKey(devKey); Debug.Console(0, "{0} Devices registered with Device Manager:", Devices.Count);
if (dev == null) var sorted = Devices.Values.ToList();
{ sorted.Sort((a, b) => a.Key.CompareTo(b.Key));
Debug.Console(0, "Device '{0}' not found", devKey);
return; foreach (var d in sorted)
} {
var statusDev = dev as IHasFeedback; var name = d is IKeyName ? (d as IKeyName).Name : "---";
if (statusDev == null) Debug.Console(0, " [{0}] {1}", d.Key, name);
{ }
Debug.Console(0, "Device '{0}' does not have visible feedbacks", devKey); }
return;
} private static void ListDeviceFeedbacks(string devKey)
statusDev.DumpFeedbacksToConsole(true); {
} var dev = GetDeviceForKey(devKey);
if (dev == null)
//static void ListDeviceCommands(string devKey) {
//{ Debug.Console(0, "Device '{0}' not found", devKey);
// var dev = GetDeviceForKey(devKey); return;
// if (dev == null) }
// { var statusDev = dev as IHasFeedback;
// Debug.Console(0, "Device '{0}' not found", devKey); if (statusDev == null)
// return; {
// } Debug.Console(0, "Device '{0}' does not have visible feedbacks", devKey);
// Debug.Console(0, "This needs to be reworked. Stay tuned.", devKey); return;
//} }
statusDev.DumpFeedbacksToConsole(true);
private static void ListDeviceCommStatuses(string input) }
{
var sb = new StringBuilder(); //static void ListDeviceCommands(string devKey)
foreach (var dev in Devices.Values.OfType<ICommunicationMonitor>()) //{
{ // var dev = GetDeviceForKey(devKey);
sb.Append(string.Format("{0}: {1}\r", dev, // if (dev == null)
dev.CommunicationMonitor.Status)); // {
} // Debug.Console(0, "Device '{0}' not found", devKey);
CrestronConsole.ConsoleCommandResponse(sb.ToString()); // return;
} // }
// Debug.Console(0, "This needs to be reworked. Stay tuned.", devKey);
//}
//static void DoDeviceCommand(string command)
//{ private static void ListDeviceCommStatuses(string input)
// Debug.Console(0, "Not yet implemented. Stay tuned"); {
//} var sb = new StringBuilder();
foreach (var dev in Devices.Values.OfType<ICommunicationMonitor>())
public static void AddDevice(IKeyed newDev) {
{ sb.Append(string.Format("{0}: {1}\r", dev,
try dev.CommunicationMonitor.Status));
{ }
if (!DeviceCriticalSection.TryEnter()) CrestronConsole.ConsoleCommandResponse(sb.ToString());
{ }
Debug.Console(0, Debug.ErrorLogLevel.Error, "Currently unable to add devices to Device Manager. Please try again");
return;
} //static void DoDeviceCommand(string command)
// Check for device with same key //{
//var existingDevice = _Devices.FirstOrDefault(d => d.Key.Equals(newDev.Key, StringComparison.OrdinalIgnoreCase)); // Debug.Console(0, "Not yet implemented. Stay tuned");
////// If it exists, remove or warn?? //}
//if (existingDevice != null)
public static void AddDevice(IKeyed newDev)
if (!AddDeviceEnabled) {
{ try
Debug.Console(0, Debug.ErrorLogLevel.Error, "All devices have been activated. Adding new devices is not allowed."); {
return; if (!DeviceCriticalSection.TryEnter())
} {
Debug.Console(0, Debug.ErrorLogLevel.Error, "Currently unable to add devices to Device Manager. Please try again");
if (Devices.ContainsKey(newDev.Key)) return;
{ }
Debug.Console(0, newDev, "WARNING: A device with this key already exists. Not added to manager"); // Check for device with same key
return; //var existingDevice = _Devices.FirstOrDefault(d => d.Key.Equals(newDev.Key, StringComparison.OrdinalIgnoreCase));
} ////// If it exists, remove or warn??
Devices.Add(newDev.Key, newDev); //if (existingDevice != null)
//if (!(_Devices.Contains(newDev)))
// _Devices.Add(newDev); if (!AddDeviceEnabled)
} {
finally Debug.Console(0, Debug.ErrorLogLevel.Error, "All devices have been activated. Adding new devices is not allowed.");
{ return;
DeviceCriticalSection.Leave(); }
}
} if (Devices.ContainsKey(newDev.Key))
{
public static void AddDevice(IEnumerable<IKeyed> devicesToAdd) Debug.Console(0, newDev, "WARNING: A device with this key already exists. Not added to manager");
{ return;
try }
{ Devices.Add(newDev.Key, newDev);
if (!DeviceCriticalSection.TryEnter()) //if (!(_Devices.Contains(newDev)))
{ // _Devices.Add(newDev);
Debug.Console(0, Debug.ErrorLogLevel.Error, }
"Currently unable to add devices to Device Manager. Please try again"); finally
return; {
} DeviceCriticalSection.Leave();
if (!AddDeviceEnabled) }
{ }
Debug.Console(0, Debug.ErrorLogLevel.Error,
"All devices have been activated. Adding new devices is not allowed."); public static void AddDevice(IEnumerable<IKeyed> devicesToAdd)
return; {
} try
{
foreach (var dev in devicesToAdd) if (!DeviceCriticalSection.TryEnter())
{ {
try Debug.Console(0, Debug.ErrorLogLevel.Error,
{ "Currently unable to add devices to Device Manager. Please try again");
Devices.Add(dev.Key, dev); return;
} }
catch (ArgumentException ex) if (!AddDeviceEnabled)
{ {
Debug.Console(0, "Error adding device with key {0} to Device Manager: {1}\r\nStack Trace: {2}", Debug.Console(0, Debug.ErrorLogLevel.Error,
dev.Key, ex.Message, ex.StackTrace); "All devices have been activated. Adding new devices is not allowed.");
} return;
} }
}
finally foreach (var dev in devicesToAdd)
{ {
DeviceCriticalSection.Leave(); try
} {
} Devices.Add(dev.Key, dev);
}
public static void RemoveDevice(IKeyed newDev) catch (ArgumentException ex)
{ {
try Debug.Console(0, "Error adding device with key {0} to Device Manager: {1}\r\nStack Trace: {2}",
{ dev.Key, ex.Message, ex.StackTrace);
DeviceCriticalSection.Enter(); }
if (newDev == null) }
return; }
if (Devices.ContainsKey(newDev.Key)) finally
Devices.Remove(newDev.Key); {
//if (_Devices.Contains(newDev)) DeviceCriticalSection.Leave();
// _Devices.Remove(newDev); }
else }
Debug.Console(0, "Device manager: Device '{0}' does not exist in manager. Cannot remove", newDev.Key);
} public static void RemoveDevice(IKeyed newDev)
finally {
{ try
DeviceCriticalSection.Leave(); {
} DeviceCriticalSection.Enter();
} if (newDev == null)
return;
public static IEnumerable<string> GetDeviceKeys() if (Devices.ContainsKey(newDev.Key))
{ Devices.Remove(newDev.Key);
//return _Devices.Select(d => d.Key).ToList(); //if (_Devices.Contains(newDev))
return Devices.Keys; // _Devices.Remove(newDev);
} else
Debug.Console(0, "Device manager: Device '{0}' does not exist in manager. Cannot remove", newDev.Key);
public static IEnumerable<IKeyed> GetDevices() }
{ finally
//return _Devices.Select(d => d.Key).ToList(); {
return Devices.Values; DeviceCriticalSection.Leave();
} }
}
public static IKeyed GetDeviceForKey(string key)
{ public static IEnumerable<string> GetDeviceKeys()
//return _Devices.FirstOrDefault(d => d.Key.Equals(key, StringComparison.OrdinalIgnoreCase)); {
if (key != null && Devices.ContainsKey(key)) //return _Devices.Select(d => d.Key).ToList();
return Devices[key]; return Devices.Keys;
}
return null;
} public static IEnumerable<IKeyed> GetDevices()
{
/// <summary> //return _Devices.Select(d => d.Key).ToList();
/// Console handler that simulates com port data receive return Devices.Values;
/// </summary> }
/// <param name="s"></param>
public static void SimulateComReceiveOnDevice(string s) public static IKeyed GetDeviceForKey(string key)
{ {
// devcomsim:1 xyzabc //return _Devices.FirstOrDefault(d => d.Key.Equals(key, StringComparison.OrdinalIgnoreCase));
var match = Regex.Match(s, @"(\S*)\s*(.*)"); if (key != null && Devices.ContainsKey(key))
if (match.Groups.Count < 3) return Devices[key];
{
CrestronConsole.ConsoleCommandResponse(" Format: devsimreceive:P <device key> <string to send>"); return null;
return; }
}
//Debug.Console(2, "**** {0} - {1} ****", match.Groups[1].Value, match.Groups[2].Value); /// <summary>
/// Console handler that simulates com port data receive
var com = GetDeviceForKey(match.Groups[1].Value) as ComPortController; /// </summary>
if (com == null) /// <param name="s"></param>
{ public static void SimulateComReceiveOnDevice(string s)
CrestronConsole.ConsoleCommandResponse("'{0}' is not a comm port device", match.Groups[1].Value); {
return; // devcomsim:1 xyzabc
} var match = Regex.Match(s, @"(\S*)\s*(.*)");
com.SimulateReceive(match.Groups[2].Value); if (match.Groups.Count < 3)
{
CrestronConsole.ConsoleCommandResponse(" Format: devsimreceive:P <device key> <string to send>");
return;
}
//Debug.Console(2, "**** {0} - {1} ****", match.Groups[1].Value, match.Groups[2].Value);
var com = GetDeviceForKey(match.Groups[1].Value) as ComPortController;
if (com == null)
{
CrestronConsole.ConsoleCommandResponse("'{0}' is not a comm port device", match.Groups[1].Value);
return;
}
com.SimulateReceive(match.Groups[2].Value);
} }
/// <summary> /// <summary>
@@ -366,82 +379,82 @@ namespace PepperDash.Essentials.Core
Debug.Console(0, "{0}", routingOutputPort.Key); Debug.Console(0, "{0}", routingOutputPort.Key);
} }
} }
} }
/// <summary> /// <summary>
/// Attempts to set the debug level of a device /// Attempts to set the debug level of a device
/// </summary> /// </summary>
/// <param name="s"></param> /// <param name="s"></param>
public static void SetDeviceStreamDebugging(string s) public static void SetDeviceStreamDebugging(string s)
{ {
var args = s.Split(' '); var args = s.Split(' ');
var deviceKey = args[0]; var deviceKey = args[0];
var setting = args[1]; var setting = args[1];
var timeout= String.Empty; var timeout= String.Empty;
if (args.Length >= 3) if (args.Length >= 3)
{ {
timeout = args[2]; timeout = args[2];
} }
var device = GetDeviceForKey(deviceKey) as IStreamDebugging; var device = GetDeviceForKey(deviceKey) as IStreamDebugging;
if (device == null) if (device == null)
{ {
Debug.Console(0, "Unable to get device with key: {0}", deviceKey); Debug.Console(0, "Unable to get device with key: {0}", deviceKey);
return; return;
} }
eStreamDebuggingSetting debugSetting; eStreamDebuggingSetting debugSetting;
try try
{ {
debugSetting = (eStreamDebuggingSetting)Enum.Parse(typeof(eStreamDebuggingSetting), setting, true); debugSetting = (eStreamDebuggingSetting)Enum.Parse(typeof(eStreamDebuggingSetting), setting, true);
} }
catch catch
{ {
Debug.Console(0, "Unable to convert setting value. Please use off/rx/tx/both"); Debug.Console(0, "Unable to convert setting value. Please use off/rx/tx/both");
return; return;
} }
if (!string.IsNullOrEmpty(timeout)) if (!string.IsNullOrEmpty(timeout))
{ {
try try
{ {
var min = Convert.ToUInt32(timeout); var min = Convert.ToUInt32(timeout);
device.StreamDebugging.SetDebuggingWithSpecificTimeout(debugSetting, min); device.StreamDebugging.SetDebuggingWithSpecificTimeout(debugSetting, min);
Debug.Console(0, "Device: '{0}' debug level set to {1) for {2} minutes", deviceKey, debugSetting, min); Debug.Console(0, "Device: '{0}' debug level set to {1) for {2} minutes", deviceKey, debugSetting, min);
} }
catch (Exception e) catch (Exception e)
{ {
Debug.Console(0, "Unable to convert minutes or settings value. Please use an integer value for minutes. Errro: {0}", e); Debug.Console(0, "Unable to convert minutes or settings value. Please use an integer value for minutes. Errro: {0}", e);
} }
} }
else else
{ {
device.StreamDebugging.SetDebuggingWithDefaultTimeout(debugSetting); device.StreamDebugging.SetDebuggingWithDefaultTimeout(debugSetting);
Debug.Console(0, "Device: '{0}' debug level set to {1) for default time (30 minutes)", deviceKey, debugSetting); Debug.Console(0, "Device: '{0}' debug level set to {1) for default time (30 minutes)", deviceKey, debugSetting);
} }
} }
/// <summary> /// <summary>
/// Sets stream debugging settings to off for all devices /// Sets stream debugging settings to off for all devices
/// </summary> /// </summary>
public static void DisableAllDeviceStreamDebugging() public static void DisableAllDeviceStreamDebugging()
{ {
foreach (var device in AllDevices) foreach (var device in AllDevices)
{ {
var streamDevice = device as IStreamDebugging; var streamDevice = device as IStreamDebugging;
if (streamDevice != null) if (streamDevice != null)
{ {
streamDevice.StreamDebugging.SetDebuggingWithDefaultTimeout(eStreamDebuggingSetting.Off); streamDevice.StreamDebugging.SetDebuggingWithDefaultTimeout(eStreamDebuggingSetting.Off);
} }
} }
} }
} }
} }

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;
}); });