mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-14 20:24:57 +00:00
feat(essentials): Reworks logic in InitializeSystem() to be a bit cleaner using a CEvent and the existing AllDeviceActivated event
This commit is contained in:
@@ -28,6 +28,7 @@ namespace PepperDash.Essentials
|
|||||||
HttpLogoServer LogoServer;
|
HttpLogoServer LogoServer;
|
||||||
|
|
||||||
private CTimer _startTimer;
|
private CTimer _startTimer;
|
||||||
|
private CEvent _initializeEvent;
|
||||||
private const long StartupTime = 500;
|
private const long StartupTime = 500;
|
||||||
|
|
||||||
public ControlSystem()
|
public ControlSystem()
|
||||||
@@ -46,12 +47,20 @@ namespace PepperDash.Essentials
|
|||||||
public override void InitializeSystem()
|
public override void InitializeSystem()
|
||||||
{
|
{
|
||||||
_startTimer = new CTimer(StartSystem,StartupTime);
|
_startTimer = new CTimer(StartSystem,StartupTime);
|
||||||
ushort count = 0;
|
|
||||||
while (!DeviceManager.AllDevicesActivatedFb && count < 60)
|
|
||||||
|
// If the control system is a DMPS type, we need to wait to exit this method until all devices have had time to activate
|
||||||
|
// to allow any HD-BaseT DM endpoints to register first.
|
||||||
|
if (Global.ControlSystemIsDmpsType)
|
||||||
{
|
{
|
||||||
//Wait for devices to register before returning, as required by DMPS. Max wait is 60 seconds.
|
_initializeEvent = new CEvent();
|
||||||
CrestronEnvironment.Sleep(1000);
|
|
||||||
count++;
|
DeviceManager.AllDevicesActivated += (o, a) =>
|
||||||
|
{
|
||||||
|
_initializeEvent.Set();
|
||||||
|
};
|
||||||
|
|
||||||
|
_initializeEvent.Wait(20000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,11 +28,9 @@ namespace PepperDash.Essentials.Core
|
|||||||
public static List<IKeyed> AllDevices { get { return new List<IKeyed>(Devices.Values); } }
|
public static List<IKeyed> AllDevices { get { return new List<IKeyed>(Devices.Values); } }
|
||||||
|
|
||||||
public static bool AddDeviceEnabled;
|
public static bool AddDeviceEnabled;
|
||||||
public static bool AllDevicesActivatedFb;
|
|
||||||
|
|
||||||
public static void Initialize(CrestronControlSystem cs)
|
public static void Initialize(CrestronControlSystem cs)
|
||||||
{
|
{
|
||||||
AllDevicesActivatedFb = false;
|
|
||||||
AddDeviceEnabled = true;
|
AddDeviceEnabled = true;
|
||||||
CrestronConsole.AddNewConsoleCommand(ListDeviceCommStatuses, "devcommstatus", "Lists the communication status of all devices",
|
CrestronConsole.AddNewConsoleCommand(ListDeviceCommStatuses, "devcommstatus", "Lists the communication status of all devices",
|
||||||
ConsoleAccessLevelEnum.AccessOperator);
|
ConsoleAccessLevelEnum.AccessOperator);
|
||||||
@@ -124,7 +122,6 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
private static void OnAllDevicesActivated()
|
private static void OnAllDevicesActivated()
|
||||||
{
|
{
|
||||||
AllDevicesActivatedFb = true;
|
|
||||||
var handler = AllDevicesActivated;
|
var handler = AllDevicesActivated;
|
||||||
if (handler != null)
|
if (handler != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,6 +32,16 @@ namespace PepperDash.Essentials.Core
|
|||||||
// TODO: consider making this configurable later
|
// TODO: consider making this configurable later
|
||||||
public static IFormatProvider Culture = CultureInfo.CreateSpecificCulture("en-US");
|
public static IFormatProvider Culture = CultureInfo.CreateSpecificCulture("en-US");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// True when the processor type is a DMPS variant
|
||||||
|
/// </summary>
|
||||||
|
public static bool ControlSystemIsDmpsType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ControlSystem.ControllerPrompt.ToLower().IndexOf("dmps") > -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The file path prefix to the folder containing configuration files
|
/// The file path prefix to the folder containing configuration files
|
||||||
|
|||||||
Reference in New Issue
Block a user