diff --git a/PepperDashEssentials/PluginLoading/PluginLoading.cs b/PepperDashEssentials/PluginLoading/PluginLoading.cs
index d12775c7..8c444622 100644
--- a/PepperDashEssentials/PluginLoading/PluginLoading.cs
+++ b/PepperDashEssentials/PluginLoading/PluginLoading.cs
@@ -70,6 +70,11 @@ namespace PepperDash.Essentials
{
version = Global.AssemblyVersion;
assembly = Assembly.GetExecutingAssembly();
+ break;
+ }
+ case ("PepperDashEssentialsBase.dll"):
+ {
+
break;
}
case ("PepperDash_Core.dll"):
@@ -339,9 +344,9 @@ namespace PepperDash.Essentials
{
try
{
- if (typeof(IPluginDeviceConfig).IsAssignableFrom(type))
+ if (typeof(IPluginDeviceFactory).IsAssignableFrom(type))
{
- var plugin = (IPluginDeviceConfig)Crestron.SimplSharp.Reflection.Activator.CreateInstance(type);
+ var plugin = (IPluginDeviceFactory)Crestron.SimplSharp.Reflection.Activator.CreateInstance(type);
LoadCustomPlugin(plugin, loadedAssembly);
}
else
@@ -377,7 +382,7 @@ namespace PepperDash.Essentials
/// Loads a
///
///
- static void LoadCustomPlugin(IPluginDeviceConfig plugin, LoadedAssembly loadedAssembly)
+ static void LoadCustomPlugin(IPluginDeviceFactory plugin, LoadedAssembly loadedAssembly)
{
var passed = Global.IsRunningMinimumVersionOrHigher(plugin.MinimumEssentialsFrameworkVersion);
@@ -392,7 +397,7 @@ namespace PepperDash.Essentials
}
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading plugin: {0}", loadedAssembly.Name);
- plugin.LoadPlugin();
+ plugin.LoadTypeFactories();
}
///
diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Comm and IR/GenericComm.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Comm and IR/GenericComm.cs
index 1998f62e..86faab64 100644
--- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Comm and IR/GenericComm.cs
+++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Comm and IR/GenericComm.cs
@@ -13,12 +13,14 @@ using PepperDash.Essentials.Core.Config;
namespace PepperDash.Essentials.Core
{
+
+
///
/// Serves as a generic wrapper class for all styles of IBasicCommuncation ports
///
- public class
- GenericComm : ReconfigurableDevice
+ public class GenericComm : ReconfigurableDevice
{
+
EssentialsControlPropertiesConfig PropertiesConfig;
public IBasicCommunication CommPort { get; private set; }
@@ -29,6 +31,14 @@ namespace PepperDash.Essentials.Core
PropertiesConfig = CommFactory.GetControlPropertiesConfig(config);
CommPort = CommFactory.CreateCommForDevice(config);
+
+
+ }
+
+ public static IKeyed BuildDevice(DeviceConfig dc)
+ {
+ Debug.Console(1, "Factory Attempting to create new Generic Comm Device");
+ return new GenericComm(dc);
}
public void SetPortConfig(string portConfig)
@@ -51,6 +61,22 @@ namespace PepperDash.Essentials.Core
ConfigWriter.UpdateDeviceConfig(config);
}
-
+
+ public class Factory : EssentialsDevice.Factory
+ {
+ #region IDeviceFactory Members
+
+ List TypeNames = new List() { "genericComm" };
+
+ #endregion
+
+ public override IKeyed BuildDevice(DeviceConfig dc)
+ {
+ Debug.Console(1, "Factory Attempting to create new Generic Comm Device");
+ return new GenericComm(dc);
+ }
+ }
}
+
+
}
\ No newline at end of file
diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsDevice.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsDevice.cs
new file mode 100644
index 00000000..00263f0f
--- /dev/null
+++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsDevice.cs
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Crestron.SimplSharp;
+
+using PepperDash.Core;
+using PepperDash.Essentials.Core.Config;
+
+namespace PepperDash.Essentials.Core
+{
+ ///
+ /// Defines the basic needs for an EssentialsDevice to enable it to be build by an IDeviceFactory class
+ ///
+ public abstract class EssentialsDevice : Device
+ {
+ public EssentialsDevice(string key)
+ : base(key)
+ {
+
+ }
+
+ public abstract class Factory : IDeviceFactory
+ {
+ #region IDeviceFactory Members
+
+ public List TypeNames { get; protected set; }
+
+ public virtual void LoadTypeFactories()
+ {
+ foreach (var typeName in TypeNames)
+ {
+ DeviceFactory.AddFactoryForType(typeName, BuildDevice);
+ }
+ }
+
+ #endregion
+
+ public abstract IKeyed BuildDevice(DeviceConfig dc);
+
+ public Factory()
+ {
+ TypeNames = new List();
+ }
+
+ }
+
+
+ }
+}
\ No newline at end of file
diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/ReconfigurableDevice.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/ReconfigurableDevice.cs
index 3acfcac0..b19b40b5 100644
--- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/ReconfigurableDevice.cs
+++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/ReconfigurableDevice.cs
@@ -12,7 +12,7 @@ namespace PepperDash.Essentials.Core.Devices
///
///
///
- public abstract class ReconfigurableDevice : Device
+ public abstract class ReconfigurableDevice : EssentialsDevice
{
public event EventHandler ConfigChanged;
diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs
index c07bc010..47947691 100644
--- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs
+++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs
@@ -87,4 +87,17 @@ namespace PepperDash.Essentials.Core
return null;
}
}
+
+
+ ///
+ /// Responsible for loading all of the device types
+ ///
+ public class CoreDeviceFactory
+ {
+ public CoreDeviceFactory()
+ {
+ var genComm = new GenericComm.Factory() as IDeviceFactory;
+ genComm.LoadTypeFactories();
+ }
+ }
}
\ No newline at end of file
diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj
index 70be9e8c..d728bbd0 100644
--- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj
+++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj
@@ -132,6 +132,7 @@
+
diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/IPluginDeviceConfig.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/IPluginDeviceConfig.cs
index 6808bf90..b8fa03a3 100644
--- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/IPluginDeviceConfig.cs
+++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/IPluginDeviceConfig.cs
@@ -1,15 +1,28 @@
using PepperDash.Core;
using PepperDash.Essentials.Core.Config;
-namespace PepperDash.Essentials.Core.Plugins
+namespace PepperDash.Essentials.Core
{
///
/// Defines a class that is capable of loading custom plugin device types
///
- public interface IPluginDeviceConfig
+ public interface IPluginDeviceFactory : IDeviceFactory
{
+ ///
+ /// Required to define the minimum version for Essentials in the format xx.yy.zz
+ ///
string MinimumEssentialsFrameworkVersion { get; }
- void LoadPlugin();
- IKeyed BuildDevice(DeviceConfig dc);
+
+ }
+
+ ///
+ /// Defines a class that is capable of loading device types
+ ///
+ public interface IDeviceFactory
+ {
+ ///
+ /// Will be called when the plugin is loaded by Essentials. Must add any new types to the DeviceFactory using DeviceFactory.AddFactoryForType() for each new type
+ ///
+ void LoadTypeFactories();
}
}
\ No newline at end of file