Updated the factory device load snippet to include BridgeFactory

Neil Dorin
2020-02-11 16:00:17 -07:00
parent 0f7a5d5ce0
commit 223f5cef14

@@ -122,21 +122,21 @@ This ordering ensures that all devices are at least present before building tie
In each device/room step, a device factory process is called. We call subsequent device factory methods in the various libraries that make up Essentials until one of them returns a functional device. This allows us to break up the factory process into individual libraries, and not have a huge master list of types and build procedures. Here's part of the code: In each device/room step, a device factory process is called. We call subsequent device factory methods in the various libraries that make up Essentials until one of them returns a functional device. This allows us to break up the factory process into individual libraries, and not have a huge master list of types and build procedures. Here's part of the code:
``` ```
// Try local factory first // Try local factories first
var newDev = DeviceFactory.GetDevice(devConf); var newDev = DeviceFactory.GetDevice(devConf);
// Then associated library factories if (newDev == null)
if (newDev == null) newDev = BridgeFactory.GetDevice(devConf);
newDev = PepperDash.Essentials.Devices.Common.DeviceFactory.GetDevice(devConf);
if (newDev == null) // Then associated library factories
newDev = PepperDash.Essentials.DM.DeviceFactory.GetDevice(devConf); if (newDev == null)
if (newDev == null) newDev = PepperDash.Essentials.Core.DeviceFactory.GetDevice(devConf);
newDev = PepperDash.Essentials.Devices.Displays.DisplayDeviceFactory.GetDevice(devConf); if (newDev == null)
newDev = PepperDash.Essentials.Devices.Common.DeviceFactory.GetDevice(devConf);
if (newDev != null) if (newDev == null)
DeviceManager.AddDevice(newDev); newDev = PepperDash.Essentials.DM.DeviceFactory.GetDevice(devConf);
else if (newDev == null)
Debug.Console(0, "ERROR: Cannot load unknown device type '{0}', key '{1}'.", devConf.Type, devConf.Key); newDev = PepperDash.Essentials.Devices.Displays.DisplayDeviceFactory.GetDevice(devConf);
``` ```
In each respective factory, or device constructor, the config's properties object is either converted to a config object or read from using `JToken` methods. This builds the device which may be ready to go, or may require activation as described above. In each respective factory, or device constructor, the config's properties object is either converted to a config object or read from using `JToken` methods. This builds the device which may be ready to go, or may require activation as described above.