From 697b9109a37ba751f438b699bd13714d3be6dcd7 Mon Sep 17 00:00:00 2001 From: Heath Volmer Date: Fri, 17 May 2019 09:14:18 -0600 Subject: [PATCH] Modifications to plugin load and factories --- .../AppServer/CotijaSystemController.cs | 22 ++++++--- PepperDashEssentials/ControlSystem.cs | 45 +++++++++++-------- essentials-framework | 2 +- 3 files changed, 42 insertions(+), 27 deletions(-) diff --git a/PepperDashEssentials/AppServer/CotijaSystemController.cs b/PepperDashEssentials/AppServer/CotijaSystemController.cs index 5fd5e958..1f5fa0ff 100644 --- a/PepperDashEssentials/AppServer/CotijaSystemController.cs +++ b/PepperDashEssentials/AppServer/CotijaSystemController.cs @@ -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(); + DeviceJsonApi.DoDeviceAction(wrapper); + } else if (type == "close") { Debug.Console(1, this, "Received close message from server."); diff --git a/PepperDashEssentials/ControlSystem.cs b/PepperDashEssentials/ControlSystem.cs index 82d9d14b..ae2bdcd7 100644 --- a/PepperDashEssentials/ControlSystem.cs +++ b/PepperDashEssentials/ControlSystem.cs @@ -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"); - } - } + ///// + ///// + ///// + ///// + //public void EnablePortalSync(string s) + //{ + // if (s.ToLower() == "enable") + // { + // CrestronConsole.ConsoleCommandResponse("Portal Sync features enabled"); + // } + //} + /// + /// + /// 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 diff --git a/essentials-framework b/essentials-framework index 7de16a18..adc687ef 160000 --- a/essentials-framework +++ b/essentials-framework @@ -1 +1 @@ -Subproject commit 7de16a1826fa794d2c03361811033d4e38970a84 +Subproject commit adc687ef860c0f1d4a3e44c02cb76de12faaa5d3