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

@@ -99,6 +99,8 @@ namespace PepperDash.Essentials
CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(CrestronEnvironment_EthernetEventHandler);
}
@@ -668,13 +670,14 @@ namespace PepperDash.Essentials
if(string.IsNullOrEmpty(message))
return;
if (!message.Contains("/system/heartbeat"))
Debug.Console(1, this, "Message RX: {0}", message);
else
{
LastAckMessage = DateTime.Now;
//Debug.Console(1, this, "RX message contains /system/heartbeat");
}
if (!message.Contains("/system/heartbeat"))
{
Debug.Console(1, this, "Message RX: {0}", message);
}
else
{
LastAckMessage = DateTime.Now;
}
try
{
@@ -691,6 +694,11 @@ namespace PepperDash.Essentials
{
HandleHeartBeat(messageObj["content"]);
}
else if (type == "raw")
{
var wrapper = messageObj["content"].ToObject<DeviceActionWrapper>();
DeviceJsonApi.DoDeviceAction(wrapper);
}
else if (type == "close")
{
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);
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 factory = Crestron.SimplSharp.Reflection.Activator.CreateInstance(type);
if (factory is PepperDash.Essentials.Core.Factory.IGetCrestronDevice)
@@ -215,7 +210,9 @@ namespace PepperDash.Essentials
}
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;
}
public void EnablePortalSync(string s)
{
if (s.ToLower() == "enable")
{
CrestronConsole.ConsoleCommandResponse("Portal Sync features enabled");
}
}
///// <summary>
/////
///// </summary>
///// <param name="s"></param>
//public void EnablePortalSync(string s)
//{
// if (s.ToLower() == "enable")
// {
// CrestronConsole.ConsoleCommandResponse("Portal Sync features enabled");
// }
//}
/// <summary>
///
/// </summary>
public void TearDown()
{
Debug.Console(0, "Tearing down existing system");
@@ -343,17 +347,20 @@ namespace PepperDash.Essentials
newDev = PepperDash.Essentials.Devices.Displays.DisplayDeviceFactory.GetDevice(devConf);
if (newDev == null)
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;
if (cresFactory != null)
// iterate plugin factories
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)
DeviceManager.AddDevice(newDev);
else