Moved generation of Mpc3TouchpanelController device from core device factory into ControlSystem LoadDevices() method.

This commit is contained in:
Neil Dorin
2020-03-12 12:46:21 -06:00
parent 7afcbaee61
commit 1b096de377
2 changed files with 19 additions and 15 deletions

View File

@@ -428,11 +428,30 @@ namespace PepperDash.Essentials
DeviceManager.AddDevice(dmpsRoutingController);
}
else if (this.ControllerPrompt.IndexOf("mpc3", StringComparison.OrdinalIgnoreCase) > -1)
{
Debug.Console(2, "MPC3 processor type detected. Adding Mpc3TouchpanelController.");
var butToken = devConf.Properties["buttons"];
if (butToken != null)
{
var buttons = butToken.ToObject<Dictionary<uint, Essentials.Core.Touchpanels.KeypadButton>>();
var tpController = new Essentials.Core.Touchpanels.Mpc3TouchpanelController(devConf.Key, devConf.Name, Global.ControlSystem, buttons);
DeviceManager.AddDevice(tpController);
}
else
{
Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: Unable to deserialize buttons collection for device: {0}", devConf.Key);
}
}
else
{
Debug.Console(2, "************Processor is not DMPS type***************");
}
continue;
}

View File

@@ -83,21 +83,6 @@ namespace PepperDash.Essentials.Core
return new C2nRthsController(key, name, new C2nRths(cresnetId, Global.ControlSystem));
}
if (typeName.StartsWith("mpc3"))
{
var butToken = dc.Properties["buttons"];
if (butToken != null)
{
var buttons = butToken.ToObject<Dictionary<uint, KeypadButton>>();
return new Mpc3TouchpanelController(key, name, Global.ControlSystem, buttons);
}
else
{
Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: Unable to deserialize buttons collection for device: {0}", key);
}
}
return null;
}