Modifications to plugin load and factories

This commit is contained in:
Heath Volmer
2019-05-17 09:14:18 -06:00
parent 727367c061
commit 697b9109a3
3 changed files with 42 additions and 27 deletions

View File

@@ -100,6 +100,8 @@ namespace PepperDash.Essentials
CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler); CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(CrestronEnvironment_EthernetEventHandler); CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(CrestronEnvironment_EthernetEventHandler);
} }
/// <summary> /// <summary>
@@ -668,13 +670,14 @@ namespace PepperDash.Essentials
if(string.IsNullOrEmpty(message)) if(string.IsNullOrEmpty(message))
return; return;
if (!message.Contains("/system/heartbeat")) if (!message.Contains("/system/heartbeat"))
Debug.Console(1, this, "Message RX: {0}", message); {
else Debug.Console(1, this, "Message RX: {0}", message);
{ }
LastAckMessage = DateTime.Now; else
//Debug.Console(1, this, "RX message contains /system/heartbeat"); {
} LastAckMessage = DateTime.Now;
}
try try
{ {
@@ -691,6 +694,11 @@ namespace PepperDash.Essentials
{ {
HandleHeartBeat(messageObj["content"]); HandleHeartBeat(messageObj["content"]);
} }
else if (type == "raw")
{
var wrapper = messageObj["content"].ToObject<DeviceActionWrapper>();
DeviceJsonApi.DoDeviceAction(wrapper);
}
else if (type == "close") else if (type == "close")
{ {
Debug.Console(1, this, "Received close message from server."); Debug.Console(1, this, "Received close message from server.");

View File

@@ -201,11 +201,6 @@ namespace PepperDash.Essentials
{ {
Debug.Console(0, "Checking file '{0}' for factory", fi.Name); Debug.Console(0, "Checking file '{0}' for factory", fi.Name);
var assy = Assembly.LoadFrom(fi.FullName); var assy = Assembly.LoadFrom(fi.FullName);
//var types = assy.GetTypes();
//foreach (var t in types)
//{
// Debug.Console(0, "{0}", t.FullName);
//}
var type = assy.GetType("PepperDash.Essentials.Plugin.Factory"); var type = assy.GetType("PepperDash.Essentials.Plugin.Factory");
var factory = Crestron.SimplSharp.Reflection.Activator.CreateInstance(type); var factory = Crestron.SimplSharp.Reflection.Activator.CreateInstance(type);
if (factory is PepperDash.Essentials.Core.Factory.IGetCrestronDevice) if (factory is PepperDash.Essentials.Core.Factory.IGetCrestronDevice)
@@ -215,7 +210,9 @@ namespace PepperDash.Essentials
} }
else else
{ {
Debug.Console(0, "Plugin '{0}' does not conform to any loadable types. Ignoring", fi.Name); Debug.Console(0, Debug.ErrorLogLevel.Warning,
"Plugin '{0}' does not conform to any loadable types. DLL should be removed from plugins folder. Ignoring",
fi.Name);
} }
} }
} }
@@ -243,14 +240,21 @@ namespace PepperDash.Essentials
return configExists; return configExists;
} }
public void EnablePortalSync(string s) ///// <summary>
{ /////
if (s.ToLower() == "enable") ///// </summary>
{ ///// <param name="s"></param>
CrestronConsole.ConsoleCommandResponse("Portal Sync features enabled"); //public void EnablePortalSync(string s)
} //{
} // if (s.ToLower() == "enable")
// {
// CrestronConsole.ConsoleCommandResponse("Portal Sync features enabled");
// }
//}
/// <summary>
///
/// </summary>
public void TearDown() public void TearDown()
{ {
Debug.Console(0, "Tearing down existing system"); Debug.Console(0, "Tearing down existing system");
@@ -343,17 +347,20 @@ namespace PepperDash.Essentials
newDev = PepperDash.Essentials.Devices.Displays.DisplayDeviceFactory.GetDevice(devConf); newDev = PepperDash.Essentials.Devices.Displays.DisplayDeviceFactory.GetDevice(devConf);
if (newDev == null) if (newDev == null)
newDev = PepperDash.Essentials.BridgeFactory.GetDevice(devConf); newDev = PepperDash.Essentials.BridgeFactory.GetDevice(devConf);
// iterate plugin factories
foreach (var f in FactoryObjects) if (newDev == null) // might want to consider the ability to override an essentials "type"
{ {
var cresFactory = f as IGetCrestronDevice; // iterate plugin factories
if (cresFactory != null) foreach (var f in FactoryObjects)
{ {
newDev = cresFactory.GetDevice(devConf, this); var cresFactory = f as IGetCrestronDevice;
if (cresFactory != null)
{
newDev = cresFactory.GetDevice(devConf, this);
}
} }
} }
if (newDev != null) if (newDev != null)
DeviceManager.AddDevice(newDev); DeviceManager.AddDevice(newDev);
else else