update mobileControl retrieval method

remove commented out MC stuff
This commit is contained in:
Andrew Welker
2020-11-13 15:43:48 -07:00
parent ccdd8005d0
commit 1d1b4f0790

View File

@@ -290,33 +290,14 @@ namespace PepperDash.Essentials
DeviceManager.ActivateAll();
var mobileControl = DeviceManager.GetDeviceForKey("appServer") as IMobileControl;
var mobileControl = GetMobileControlDevice();
if (mobileControl == null) return;
mobileControl.LinkSystemMonitorToAppServer();
//LinkSystemMonitorToAppServer();
}
//void LinkSystemMonitorToAppServer()
//{
// var sysMon = DeviceManager.GetDeviceForKey("systemMonitor") as PepperDash.Essentials.Core.Monitoring.SystemMonitorController;
// var appServer = DeviceManager.GetDeviceForKey("appServer") as MobileControlSystemController;
// if (sysMon != null && appServer != null)
// {
// var key = sysMon.Key + "-" + appServer.Key;
// var messenger = new PepperDash.Essentials.AppServer.Messengers.SystemMonitorMessenger
// (key, sysMon, "/device/systemMonitor");
// messenger.RegisterWithAppServer(appServer);
// DeviceManager.AddDevice(messenger);
// }
//}
/// <summary>
/// Reads all devices from config and adds them to DeviceManager
/// </summary>
@@ -504,7 +485,7 @@ namespace PepperDash.Essentials
private static void CreateMobileControlBridge(EssentialsRoomBase room)
{
var mobileControl = DeviceManager.GetDeviceForKey("appServer") as IMobileControl;
var mobileControl = GetMobileControlDevice();
if (mobileControl == null) return;
@@ -513,6 +494,26 @@ namespace PepperDash.Essentials
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Mobile Control Bridge Added...");
}
private static IMobileControl GetMobileControlDevice()
{
var mobileControlList = DeviceManager.AllDevices.OfType<IMobileControl>().ToList();
if (mobileControlList.Count > 0)
{
Debug.Console(0, Debug.ErrorLogLevel.Notice,
"Multiple instances of Mobile Control Server found. Using instance with key {0}",
mobileControlList[0].Key);
}
if (mobileControlList.Count != 0)
{
return mobileControlList[0];
}
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Mobile Control not enabled for this system");
return null;
}
/// <summary>
/// Helps add the post activation steps that link bridges to main controller
/// </summary>