New device loading methodology working via reflection

This commit is contained in:
Neil Dorin
2020-04-23 14:59:54 -06:00
parent 911bd8daba
commit a93ded8c79
12 changed files with 121 additions and 268 deletions

View File

@@ -1,33 +0,0 @@
using System;
using System.Collections.Generic;
using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO;
using Crestron.SimplSharpPro;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
namespace PepperDash.Essentials.Devices.Displays
{
public class DisplayDeviceFactory
{
public DisplayDeviceFactory()
{
var necFactory = new NecPSXMDisplayFactory() as IDeviceFactory;
necFactory.LoadTypeFactories();
var panasonicThFactory = new PanasonicThDisplayFactory() as IDeviceFactory;
panasonicThFactory.LoadTypeFactories();
var samsungMdcFactory = new SamsungMDCFactory() as IDeviceFactory;
samsungMdcFactory.LoadTypeFactories();
var avocorFactory = new AvocorDisplayFactory() as IDeviceFactory;
avocorFactory.LoadTypeFactories();
}
}
}

View File

@@ -132,7 +132,6 @@
<Compile Include="Display\AvocorVTFDisplay.cs" />
<Compile Include="Display\InputInterfaces.cs" />
<Compile Include="Display\SamsungMDCDisplay.cs" />
<Compile Include="Display\DeviceFactory.cs" />
<Compile Include="Display\NecPaSeriesProjector.cs" />
<Compile Include="Display\NECPSXMDisplay.cs" />
<Compile Include="DSP\BiampTesira\BiampTesiraForteDspLevel.cs" />

View File

@@ -1,9 +1,11 @@
using System;
using System.Linq;
using System.Collections.Generic;
using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.GeneralIO;
using Crestron.SimplSharp.Reflection;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
@@ -20,96 +22,31 @@ using PepperDash.Essentials.Devices.Common.Environment;
namespace PepperDash.Essentials.Devices.Common
{
public class DeviceFactory
{
public class DeviceFactory
{
public DeviceFactory()
{
var appleTVFactory = new AppleTVFactory() as IDeviceFactory;
appleTVFactory.LoadTypeFactories();
var assy = Assembly.GetExecutingAssembly();
PluginLoader.SetEssentialsAssembly(assy.GetName().Name, assy);
var types = assy.GetTypes().Where(ct => typeof(IDeviceFactory).IsAssignableFrom(ct) && !ct.IsInterface && !ct.IsAbstract);
var analogWayLCFactory = new AnalogWayLiveCoreFactory() as IDeviceFactory;
analogWayLCFactory.LoadTypeFactories();
var basicIrDisplayFactory = new BasicIrDisplayFactory() as IDeviceFactory;
basicIrDisplayFactory.LoadTypeFactories();
var biampTesiraFactory = new BiampTesiraForteDspFactory() as IDeviceFactory;
biampTesiraFactory.LoadTypeFactories();
var cameraViscaFactory = new Cameras.CameraViscaFactory() as IDeviceFactory;
cameraViscaFactory.LoadTypeFactories();
var cenRfGwFactory = new CenRfgwControllerFactory() as IDeviceFactory;
cenRfGwFactory.LoadTypeFactories();
var irBlurayFactory = new IRBlurayBaseFactory() as IDeviceFactory;
irBlurayFactory.LoadTypeFactories();
var digitalLoggerFactory = new DigitalLoggerFactory() as IDeviceFactory;
digitalLoggerFactory.LoadTypeFactories();
var genericAudioOutFactory = new GenericAudioOutWithVolumeFactory() as IDeviceFactory;
genericAudioOutFactory.LoadTypeFactories();
var genericSourceFactory = new GenericSourceFactory() as IDeviceFactory;
genericSourceFactory.LoadTypeFactories();
var inRoomPcFactory = new Core.Devices.InRoomPcFactory() as IDeviceFactory;
inRoomPcFactory.LoadTypeFactories();
var laptopFactory = new Core.Devices.LaptopFactory() as IDeviceFactory;
laptopFactory.LoadTypeFactories();
var blueJeansPcFactory = new SoftCodec.BlueJeansPcFactory() as IDeviceFactory;
blueJeansPcFactory.LoadTypeFactories();
var mockAcFactory = new AudioCodec.MockACFactory() as IDeviceFactory;
mockAcFactory.LoadTypeFactories();
var mockVcFactory = new VideoCodec.MockVCFactory() as IDeviceFactory;
mockVcFactory.LoadTypeFactories();
var ciscoCodecFactory = new VideoCodec.Cisco.CiscoSparkCodecFactory() as IDeviceFactory;
ciscoCodecFactory.LoadTypeFactories();
var zoomRoomFactory = new VideoCodec.ZoomRoom.ZoomRoomFactory() as IDeviceFactory;
zoomRoomFactory.LoadTypeFactories();
var digitalInputFactory = new GenericDigitalInputDeviceFactory() as IDeviceFactory;
digitalInputFactory.LoadTypeFactories();
var relayFactory = new GenericRelayDeviceFactory() as IDeviceFactory;
relayFactory.LoadTypeFactories();
var micPrivacyFactory = new Core.Privacy.MicrophonePrivacyControllerFactory() as IDeviceFactory;
micPrivacyFactory.LoadTypeFactories();
var rokuFactory = new Roku2Factory() as IDeviceFactory;
rokuFactory.LoadTypeFactories();
var setTopBoxFactory = new IRSetTopBoxBaseFactory() as IDeviceFactory;
setTopBoxFactory.LoadTypeFactories();
var tvOneCorioFactory = new TVOneCorioFactory() as IDeviceFactory;
tvOneCorioFactory.LoadTypeFactories();
var glsOccSensorBaseFactory = new GlsOccupancySensorBaseControllerFactory() as IDeviceFactory;
glsOccSensorBaseFactory.LoadTypeFactories();
var glsOdtOccSensorFactory = new GlsOdtOccupancySensorControllerFactory() as IDeviceFactory;
glsOdtOccSensorFactory.LoadTypeFactories();
var lutronQuantumFactory = new Environment.Lutron.LutronQuantumAreaFactory() as IDeviceFactory;
lutronQuantumFactory.LoadTypeFactories();
var din8sw8ControllerFactory = new Environment.Lighting.Din8sw8ControllerFactory() as IDeviceFactory;
din8sw8ControllerFactory.LoadTypeFactories();
var shadeControllerFactory = new Core.Shades.ShadeControllerFactory() as IDeviceFactory;
shadeControllerFactory.LoadTypeFactories();
var relayControlledShadeFactory = new Environment.Somfy.RelayControlledShadeFactory() as IDeviceFactory;
relayControlledShadeFactory.LoadTypeFactories();
if (types != null)
{
foreach (var type in types)
{
try
{
var factory = (IDeviceFactory)Crestron.SimplSharp.Reflection.Activator.CreateInstance(type);
factory.LoadTypeFactories();
}
catch (Exception e)
{
Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to load type: '{1}' DeviceFactory: {0}", e, type.Name);
}
}
}
}
}
}
}