mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-01-31 05:14:51 +00:00
chore: miscellaeneous cleanup
This commit is contained in:
@@ -31,54 +31,4 @@ namespace PepperDash.Essentials
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class MobileControlSimplFactory : EssentialsDeviceFactory<MobileControlSIMPLRoomBridge>
|
||||
{
|
||||
public MobileControlSimplFactory()
|
||||
{
|
||||
TypeNames = new List<string> { "mobilecontrolbridge-ddvc01", "mobilecontrolbridge-simpl" };
|
||||
}
|
||||
|
||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||
{
|
||||
var comm = CommFactory.GetControlPropertiesConfig(dc);
|
||||
|
||||
var bridge = new MobileControlSIMPLRoomBridge(dc.Key, dc.Name, comm.IpIdInt);
|
||||
|
||||
bridge.AddPreActivationAction(() =>
|
||||
{
|
||||
var parent = GetMobileControlDevice();
|
||||
|
||||
if (parent == null)
|
||||
{
|
||||
bridge.LogInformation("ERROR: Cannot connect bridge. System controller not present");
|
||||
return;
|
||||
}
|
||||
bridge.LogInformation("Linking to parent controller");
|
||||
|
||||
parent.AddDeviceMessenger(bridge);
|
||||
});
|
||||
|
||||
return bridge;
|
||||
}
|
||||
|
||||
private static MobileControlSystemController GetMobileControlDevice()
|
||||
{
|
||||
var mobileControlList = DeviceManager.AllDevices.OfType<MobileControlSystemController>().ToList();
|
||||
|
||||
if (mobileControlList.Count > 1)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Warning, "Multiple instances of Mobile Control Server found.");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (mobileControlList.Count > 0)
|
||||
{
|
||||
return mobileControlList[0];
|
||||
}
|
||||
|
||||
Debug.LogMessage(LogEventLevel.Warning, "Mobile Control not enabled for this system");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user