From fcc2a5db06746bdce691109d5425b483dd9c5c4e Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Wed, 1 Apr 2020 14:18:26 -0600 Subject: [PATCH 01/10] Updates to device factory methodology for use in plugins --- .../Config/Comm and IR/GenericComm.cs | 28 ++++++++----------- .../Devices/EssentialsDevice.cs | 26 ++++++++++++----- .../Factory/DeviceFactory.cs | 2 +- .../Factory/IDeviceFactory.cs | 3 ++ essentials-framework/pepperdashcore-builds | 2 +- 5 files changed, 36 insertions(+), 25 deletions(-) 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 0b0e4d82..dd3a835a 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,8 +13,6 @@ using PepperDash.Essentials.Core.Config; namespace PepperDash.Essentials.Core { - - /// /// Serves as a generic wrapper class for all styles of IBasicCommuncation ports /// @@ -62,21 +60,19 @@ namespace PepperDash.Essentials.Core ConfigWriter.UpdateDeviceConfig(config); } - public class Factory : Essentials.Core.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); - } - } } + public class GenericCommFactory : Essentials.Core.EssentialsDeviceFactory + { + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); + return new GenericComm(dc); + } + public GenericCommFactory() + { + TypeNames = new List() { "genericComm" }; + } + } } \ 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 index 88c62f48..c3fd2460 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsDevice.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsDevice.cs @@ -19,9 +19,18 @@ namespace PepperDash.Essentials.Core { } + + protected EssentialsDevice(string key, string name) + : base(key, name) + { + + } } - public abstract class Factory : IDeviceFactory + /// + /// Devices the basic needs for a Device Factory + /// + public abstract class EssentialsDeviceFactory : IDeviceFactory where T:EssentialsDevice { #region IDeviceFactory Members @@ -35,13 +44,16 @@ namespace PepperDash.Essentials.Core } } + public abstract EssentialsDevice BuildDevice(DeviceConfig dc); + #endregion + } - public abstract IKeyed BuildDevice(DeviceConfig dc); - - protected Factory() - { - TypeNames = new List(); - } + /// + /// Devices the basic needs for a Device Factory + /// + public abstract class EssentialsPluginDeviceFactory : EssentialsDeviceFactory, IPluginDeviceFactory where T : EssentialsDevice + { + public string MinimumEssentialsFrameworkVersion { get; protected set; } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs index 47947691..5b5af20b 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs @@ -96,7 +96,7 @@ namespace PepperDash.Essentials.Core { public CoreDeviceFactory() { - var genComm = new GenericComm.Factory() as IDeviceFactory; + var genComm = new GenericCommFactory() as IDeviceFactory; genComm.LoadTypeFactories(); } } diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/IDeviceFactory.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/IDeviceFactory.cs index 0781d647..ef792868 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/IDeviceFactory.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/IDeviceFactory.cs @@ -4,6 +4,9 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + namespace PepperDash.Essentials.Core { /// diff --git a/essentials-framework/pepperdashcore-builds b/essentials-framework/pepperdashcore-builds index 15206840..acebe6b4 160000 --- a/essentials-framework/pepperdashcore-builds +++ b/essentials-framework/pepperdashcore-builds @@ -1 +1 @@ -Subproject commit 15206840b3e6338f695e4ffba634a72e51ea1be5 +Subproject commit acebe6b43b28cc3a93f899e9714292a0cc1ab2cc From a231bb75a6fc3753c5718458e913cff0c3154500 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Wed, 1 Apr 2020 14:42:26 -0600 Subject: [PATCH 02/10] Adds back the correct PluginLoader version that supports loading with the new plugin methodology --- .../Config/Comm and IR/GenericComm.cs | 15 +- .../Devices/EssentialsDevice.cs | 2 +- .../Plugins/PluginLoader.cs | 137 ++++++++++++------ 3 files changed, 100 insertions(+), 54 deletions(-) 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 dd3a835a..45657e3e 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 @@ -18,7 +18,6 @@ namespace PepperDash.Essentials.Core /// public class GenericComm : ReconfigurableDevice { - EssentialsControlPropertiesConfig PropertiesConfig; public IBasicCommunication CommPort { get; private set; } @@ -30,7 +29,6 @@ namespace PepperDash.Essentials.Core CommPort = CommFactory.CreateCommForDevice(config); - } public static IKeyed BuildDevice(DeviceConfig dc) @@ -59,20 +57,19 @@ namespace PepperDash.Essentials.Core ConfigWriter.UpdateDeviceConfig(config); } - - } + } public class GenericCommFactory : Essentials.Core.EssentialsDeviceFactory { + public GenericCommFactory() + { + TypeNames = new List() { "genericComm" }; + } + public override EssentialsDevice BuildDevice(DeviceConfig dc) { Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); return new GenericComm(dc); } - - public GenericCommFactory() - { - TypeNames = new List() { "genericComm" }; - } } } \ 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 index c3fd2460..7bca06b9 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsDevice.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsDevice.cs @@ -36,7 +36,7 @@ namespace PepperDash.Essentials.Core public List TypeNames { get; protected set; } - public virtual void LoadTypeFactories() + public void LoadTypeFactories() { foreach (var typeName in TypeNames) { diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginLoader.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginLoader.cs index 3870159d..ca9c7b2f 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginLoader.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginLoader.cs @@ -8,6 +8,7 @@ using Crestron.SimplSharp.Reflection; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Plugins; namespace PepperDash.Essentials { @@ -69,6 +70,11 @@ namespace PepperDash.Essentials { version = Global.AssemblyVersion; assembly = Assembly.GetExecutingAssembly(); + break; + } + case ("PepperDashEssentialsBase.dll"): + { + break; } case ("PepperDash_Core.dll"): @@ -338,47 +344,19 @@ namespace PepperDash.Essentials { try { - var methods = type.GetMethods(BindingFlags.Public | BindingFlags.Static); - var loadPlugin = methods.FirstOrDefault(m => m.Name.Equals("LoadPlugin")); - if (loadPlugin != null) + if (typeof(IPluginDeviceFactory).IsAssignableFrom(type)) { - Debug.Console(2, "LoadPlugin method found in {0}", type.Name); - - var fields = type.GetFields(BindingFlags.Public | BindingFlags.Static); - - var minimumVersion = fields.FirstOrDefault(p => p.Name.Equals("MinimumEssentialsFrameworkVersion")); - if (minimumVersion != null) + var plugin = (IPluginDeviceFactory)Crestron.SimplSharp.Reflection.Activator.CreateInstance(type); + LoadCustomPlugin(plugin, loadedAssembly); + } + else + { + var methods = type.GetMethods(BindingFlags.Public | BindingFlags.Static); + var loadPlugin = methods.FirstOrDefault(m => m.Name.Equals("LoadPlugin")); + if (loadPlugin != null) { - Debug.Console(2, "MinimumEssentialsFrameworkVersion found"); - - var minimumVersionString = minimumVersion.GetValue(null) as string; - - if (!string.IsNullOrEmpty(minimumVersionString)) - { - var passed = Global.IsRunningMinimumVersionOrHigher(minimumVersionString); - - if (!passed) - { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Plugin indicates minimum Essentials version {0}. Dependency check failed. Skipping Plugin", minimumVersionString); - continue; - } - else - { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Passed plugin passed dependency check (required version {0})", minimumVersionString); - } - } - else - { - Debug.Console(0, Debug.ErrorLogLevel.Warning, "MinimumEssentialsFrameworkVersion found but not set. Loading plugin, but your mileage may vary."); - } + LoadCustomLegacyPlugin(type, loadPlugin, loadedAssembly); } - else - { - Debug.Console(0, Debug.ErrorLogLevel.Warning, "MinimumEssentialsFrameworkVersion not found. Loading plugin, but your mileage may vary."); - } - - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Adding plugin: {0}", loadedAssembly.Name); - loadPlugin.Invoke(null, null); } } catch (Exception e) @@ -400,6 +378,75 @@ namespace PepperDash.Essentials Debug.Console(0, "Done Loading Custom Plugin Types."); } + /// + /// Loads a + /// + /// + static void LoadCustomPlugin(IPluginDeviceFactory plugin, LoadedAssembly loadedAssembly) + { + var passed = Global.IsRunningMinimumVersionOrHigher(plugin.MinimumEssentialsFrameworkVersion); + + if (!passed) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, "Plugin indicates minimum Essentials version {0}. Dependency check failed. Skipping Plugin", plugin.MinimumEssentialsFrameworkVersion); + return; + } + else + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Passed plugin passed dependency check (required version {0})", plugin.MinimumEssentialsFrameworkVersion); + } + + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading plugin: {0}", loadedAssembly.Name); + plugin.LoadTypeFactories(); + } + + /// + /// Loads a a custom plugin via the legacy method + /// + /// + /// + static void LoadCustomLegacyPlugin(CType type, MethodInfo loadPlugin, LoadedAssembly loadedAssembly) + { + Debug.Console(2, "LoadPlugin method found in {0}", type.Name); + + var fields = type.GetFields(BindingFlags.Public | BindingFlags.Static); + + var minimumVersion = fields.FirstOrDefault(p => p.Name.Equals("MinimumEssentialsFrameworkVersion")); + if (minimumVersion != null) + { + Debug.Console(2, "MinimumEssentialsFrameworkVersion found"); + + var minimumVersionString = minimumVersion.GetValue(null) as string; + + if (!string.IsNullOrEmpty(minimumVersionString)) + { + var passed = Global.IsRunningMinimumVersionOrHigher(minimumVersionString); + + if (!passed) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, "Plugin indicates minimum Essentials version {0}. Dependency check failed. Skipping Plugin", minimumVersionString); + return; + } + else + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Passed plugin passed dependency check (required version {0})", minimumVersionString); + } + } + else + { + Debug.Console(0, Debug.ErrorLogLevel.Warning, "MinimumEssentialsFrameworkVersion found but not set. Loading plugin, but your mileage may vary."); + } + } + else + { + Debug.Console(0, Debug.ErrorLogLevel.Warning, "MinimumEssentialsFrameworkVersion not found. Loading plugin, but your mileage may vary."); + } + + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading legacy plugin: {0}", loadedAssembly.Name); + loadPlugin.Invoke(null, null); + + } + /// /// Loads plugins /// @@ -415,15 +462,17 @@ namespace PepperDash.Essentials // Deal with any .cplz files UnzipAndMoveCplzArchives(); - if(Directory.Exists(_loadedPluginsDirectoryPath)) { - // Load the assemblies from the loadedPlugins folder into the AppDomain - LoadPluginAssemblies(); + if (Directory.Exists(_loadedPluginsDirectoryPath)) + { + // Load the assemblies from the loadedPlugins folder into the AppDomain + LoadPluginAssemblies(); - // Load the types from any custom plugin assemblies - LoadCustomPluginTypes(); - } + // Load the types from any custom plugin assemblies + LoadCustomPluginTypes(); + } } } + } /// From 9828e796681afc00ca25809110ad85658a9a0c98 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Wed, 1 Apr 2020 15:08:24 -0600 Subject: [PATCH 03/10] Updates the name for Essentials_DM to PepperDash_Essentials_DM to ensure the .cplz name matches the .dll name --- PepperDashEssentials.sln | 8 +- .../PepperDashEssentials.csproj | 2 +- .../PepperDash_Essentials_Core.csproj | 2 +- ...csproj => PepperDash_Essentials_DM.csproj} | 316 +++++++++--------- .../Essentials_DM/Properties/AssemblyInfo.cs | 2 +- 5 files changed, 165 insertions(+), 165 deletions(-) rename essentials-framework/Essentials DM/Essentials_DM/{Essentials_DM.csproj => PepperDash_Essentials_DM.csproj} (97%) diff --git a/PepperDashEssentials.sln b/PepperDashEssentials.sln index a9a0e6d6..af0007ba 100644 --- a/PepperDashEssentials.sln +++ b/PepperDashEssentials.sln @@ -1,21 +1,21 @@  Microsoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PepperDashEssentials", ".\PepperDashEssentials\PepperDashEssentials.csproj", "{1BED5BA9-88C4-4365-9362-6F4B128071D3}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PepperDashEssentials", "PepperDashEssentials\PepperDashEssentials.csproj", "{1BED5BA9-88C4-4365-9362-6F4B128071D3}" ProjectSection(ProjectDependencies) = postProject {892B761C-E479-44CE-BD74-243E9214AF13} = {892B761C-E479-44CE-BD74-243E9214AF13} {9199CE8A-0C9F-4952-8672-3EED798B284F} = {9199CE8A-0C9F-4952-8672-3EED798B284F} {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} = {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PepperDash_Essentials_Core", ".\essentials-framework\Essentials Core\PepperDashEssentialsBase\PepperDash_Essentials_Core.csproj", "{A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PepperDash_Essentials_Core", "essentials-framework\Essentials Core\PepperDashEssentialsBase\PepperDash_Essentials_Core.csproj", "{A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Essentials Devices Common", ".\essentials-framework\Essentials Devices Common\Essentials Devices Common\Essentials Devices Common.csproj", "{892B761C-E479-44CE-BD74-243E9214AF13}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Essentials Devices Common", "essentials-framework\Essentials Devices Common\Essentials Devices Common\Essentials Devices Common.csproj", "{892B761C-E479-44CE-BD74-243E9214AF13}" ProjectSection(ProjectDependencies) = postProject {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} = {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Essentials_DM", ".\essentials-framework\Essentials DM\Essentials_DM\Essentials_DM.csproj", "{9199CE8A-0C9F-4952-8672-3EED798B284F}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PepperDash_Essentials_DM", "essentials-framework\Essentials DM\Essentials_DM\PepperDash_Essentials_DM.csproj", "{9199CE8A-0C9F-4952-8672-3EED798B284F}" ProjectSection(ProjectDependencies) = postProject {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} = {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} EndProjectSection diff --git a/PepperDashEssentials/PepperDashEssentials.csproj b/PepperDashEssentials/PepperDashEssentials.csproj index 3c4fd6b5..b2830e4e 100644 --- a/PepperDashEssentials/PepperDashEssentials.csproj +++ b/PepperDashEssentials/PepperDashEssentials.csproj @@ -7,7 +7,7 @@ {1BED5BA9-88C4-4365-9362-6F4B128071D3} Library Properties - PepperDash.Essentials + PepperDashEssentials PepperDashEssentials {0B4745B0-194B-4BB6-8E21-E9057CA92230};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} WindowsCE diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj index c3ea8202..5e255e82 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -7,7 +7,7 @@ {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} Library Properties - PepperDash.Essentials.Core + PepperDash_Essentials_Core PepperDash_Essentials_Core {0B4745B0-194B-4BB6-8E21-E9057CA92300};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} WindowsCE diff --git a/essentials-framework/Essentials DM/Essentials_DM/Essentials_DM.csproj b/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj similarity index 97% rename from essentials-framework/Essentials DM/Essentials_DM/Essentials_DM.csproj rename to essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj index 94154d6c..f8ea57a9 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Essentials_DM.csproj +++ b/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj @@ -1,159 +1,159 @@ - - - Release - AnyCPU - 9.0.30729 - 2.0 - {9199CE8A-0C9F-4952-8672-3EED798B284F} - Library - Properties - PepperDash.Essentials.DM - PepperDash_Essentials_DM - {0B4745B0-194B-4BB6-8E21-E9057CA92300};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - WindowsCE - E2BECB1F-8C8C-41ba-B736-9BE7D946A398 - 5.0 - SmartDeviceProject1 - v3.5 - Windows CE - - - - - .allowedReferenceRelatedFileExtensions - true - full - false - bin\ - DEBUG;TRACE; - prompt - 4 - 512 - true - true - off - - - .allowedReferenceRelatedFileExtensions - none - true - bin\ - prompt - 4 - 512 - true - true - off - - - - False - ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll - - - False - ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DM.dll - - - False - ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll - - - - False - ..\..\pepperdashcore-builds\PepperDash_Core.dll - - - False - ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll - False - - - False - ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll - False - - - False - ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpNewtonsoft.dll - - - False - ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe - False - - - False - ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpReflectionInterface.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} - PepperDash_Essentials_Core - - - - - - - - - rem S# Pro preparation will execute after these operations - + + + Release + AnyCPU + 9.0.30729 + 2.0 + {9199CE8A-0C9F-4952-8672-3EED798B284F} + Library + Properties + PepperDash_Essentials_DM + PepperDash_Essentials_DM + {0B4745B0-194B-4BB6-8E21-E9057CA92300};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + WindowsCE + E2BECB1F-8C8C-41ba-B736-9BE7D946A398 + 5.0 + SmartDeviceProject1 + v3.5 + Windows CE + + + + + .allowedReferenceRelatedFileExtensions + true + full + false + bin\ + DEBUG;TRACE; + prompt + 4 + 512 + true + true + off + + + .allowedReferenceRelatedFileExtensions + none + true + bin\ + prompt + 4 + 512 + true + true + off + + + + False + ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll + + + False + ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DM.dll + + + False + ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll + + + + False + ..\..\pepperdashcore-builds\PepperDash_Core.dll + + + False + ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll + False + + + False + ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll + False + + + False + ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpNewtonsoft.dll + + + False + ..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe + False + + + False + ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpReflectionInterface.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} + PepperDash_Essentials_Core + + + + + + + + + rem S# Pro preparation will execute after these operations + \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Properties/AssemblyInfo.cs b/essentials-framework/Essentials DM/Essentials_DM/Properties/AssemblyInfo.cs index 1f506f3a..c829e44a 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Properties/AssemblyInfo.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Properties/AssemblyInfo.cs @@ -1,7 +1,7 @@ using System.Reflection; using Crestron.SimplSharp.Reflection; -[assembly: System.Reflection.AssemblyTitle("Essentials_DM")] +[assembly: System.Reflection.AssemblyTitle("PepperDash_Essentials_DM")] [assembly: System.Reflection.AssemblyCompany("PepperDash Technology Corp")] [assembly: System.Reflection.AssemblyProduct("PepperDashEssentials")] [assembly: System.Reflection.AssemblyCopyright("Copyright © PepperDash Technology Corp 2020")] From bb3897160b4e30ad6feaf56cd4381675ba6b0d05 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Wed, 1 Apr 2020 15:57:51 -0600 Subject: [PATCH 04/10] Adds a method to print the typenames to console --- PepperDashEssentials/ControlSystem.cs | 4 ++- .../Factory/DeviceFactory.cs | 25 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/PepperDashEssentials/ControlSystem.cs b/PepperDashEssentials/ControlSystem.cs index 46ac77f2..f4046c85 100644 --- a/PepperDashEssentials/ControlSystem.cs +++ b/PepperDashEssentials/ControlSystem.cs @@ -47,7 +47,9 @@ namespace PepperDash.Essentials ConsoleAccessLevelEnum.AccessOperator); } - CrestronConsole.AddNewConsoleCommand(PluginLoader.ReportAssemblyVersions, "reportversions", "Reports the versions of the loaded assemblies", ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand(PluginLoader.ReportAssemblyVersions, "reportversions", "Reports the versions of the loaded assemblies", ConsoleAccessLevelEnum.AccessOperator); + + CrestronConsole.AddNewConsoleCommand(PepperDash.Essentials.Core.DeviceFactory.GetDeviceFactoryTypes, "gettypes", "Gets the device types that can be built. Accepts a filter string.", ConsoleAccessLevelEnum.AccessOperator); // CrestronConsole.AddNewConsoleCommand(S => { ConfigWriter.WriteConfigFile(null); }, "writeconfig", "writes the current config to a file", ConsoleAccessLevelEnum.AccessOperator); CrestronConsole.AddNewConsoleCommand(s => diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs index 5b5af20b..0fab13ae 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs @@ -86,6 +86,31 @@ namespace PepperDash.Essentials.Core return null; } + + /// + /// Prints the type names fromt the FactoryMethods collection. + /// + /// + public static void GetDeviceFactoryTypes(string filter) + { + List typeNames = new List(); + + if (!string.IsNullOrEmpty(filter)) + { + typeNames = FactoryMethods.Keys.Where(k => k.Contains(filter)).ToList(); + } + else + { + typeNames = FactoryMethods.Keys.ToList(); + } + + Debug.Console(0, "Device Types:"); + + foreach (var type in typeNames) + { + Debug.Console(0, "type: '{0}'", type); + } + } } From 703695e768eaadd0f6bfdc37b5b125a2596c312c Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Fri, 3 Apr 2020 09:25:48 -0600 Subject: [PATCH 05/10] Adds console method to print join maps at runtime. Adds overload of LinkToApi extension method for IBridge to allow passing the bridge in for JoinMapBaseAdvance applications --- PepperDashEssentials/Bridges/BridgeBase.cs | 70 +++++++++++++++++++ PepperDashEssentials/Bridges/IBridge.cs | 2 + PepperDashEssentials/ControlSystem.cs | 3 +- .../JoinMaps/JoinMapBase.cs | 9 ++- .../Touchpanels/Mpc3Touchpanel.cs | 7 +- 5 files changed, 83 insertions(+), 8 deletions(-) diff --git a/PepperDashEssentials/Bridges/BridgeBase.cs b/PepperDashEssentials/Bridges/BridgeBase.cs index 0c4e388b..de283e4e 100644 --- a/PepperDashEssentials/Bridges/BridgeBase.cs +++ b/PepperDashEssentials/Bridges/BridgeBase.cs @@ -20,6 +20,46 @@ using PepperDash.Essentials.DM; namespace PepperDash.Essentials.Bridges { + /// + /// Helper methods for bridges + /// + public static class BridgeHelper + { + public static void PrintJoinMap(string command) + { + string bridgeKey = ""; + string deviceKey = ""; + + var targets = command.Split(' '); + + bridgeKey = targets[0].Trim(); + + var bridge = DeviceManager.GetDeviceForKey(bridgeKey) as EiscApi; + + if (bridge == null) + { + Debug.Console(0, "Unable to find bridge with key: '{0}'", bridgeKey); + return; + } + + if (targets.Length > 1) + { + deviceKey = targets[1].Trim(); + + if (!string.IsNullOrEmpty(deviceKey)) + { + bridge.PrintJoinMapForDevice(deviceKey); + return; + } + } + else + { + bridge.PrintJoinMaps(); + } + } + } + + /// /// Base class for all bridge class variants /// @@ -206,6 +246,36 @@ namespace PepperDash.Essentials.Bridges } } + /// + /// Prints all the join maps on this bridge + /// + public void PrintJoinMaps() + { + Debug.Console(0, this, "Join Maps for EISC IPID: {0}", Eisc.ID.ToString("X")); + + foreach (var joinMap in JoinMaps) + { + joinMap.Value.PrintJoinMapInfo(); + } + } + + /// + /// Prints the join map for a device by key + /// + /// + public void PrintJoinMapForDevice(string deviceKey) + { + var joinMap = JoinMaps[deviceKey]; + + if (joinMap == null) + { + Debug.Console(0, this, "Unable to find joinMap for device with key: '{0}'", deviceKey); + return; + } + + joinMap.PrintJoinMapInfo(); + } + /// /// Used for debugging to trigger an action based on a join number and type /// diff --git a/PepperDashEssentials/Bridges/IBridge.cs b/PepperDashEssentials/Bridges/IBridge.cs index d86a1d1d..f95189a0 100644 --- a/PepperDashEssentials/Bridges/IBridge.cs +++ b/PepperDashEssentials/Bridges/IBridge.cs @@ -10,5 +10,7 @@ namespace PepperDash.Essentials.Bridges public interface IBridge { void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey); + + void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge); } } \ No newline at end of file diff --git a/PepperDashEssentials/ControlSystem.cs b/PepperDashEssentials/ControlSystem.cs index f4046c85..d1ca9b0d 100644 --- a/PepperDashEssentials/ControlSystem.cs +++ b/PepperDashEssentials/ControlSystem.cs @@ -51,7 +51,8 @@ namespace PepperDash.Essentials CrestronConsole.AddNewConsoleCommand(PepperDash.Essentials.Core.DeviceFactory.GetDeviceFactoryTypes, "gettypes", "Gets the device types that can be built. Accepts a filter string.", ConsoleAccessLevelEnum.AccessOperator); - // CrestronConsole.AddNewConsoleCommand(S => { ConfigWriter.WriteConfigFile(null); }, "writeconfig", "writes the current config to a file", ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand(PepperDash.Essentials.Bridges.BridgeHelper.PrintJoinMap, "getjoinmap", "gets map(s) for bridge or device on bridge [brKey [devKey]]", ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand(s => { Debug.Console(0, Debug.ErrorLogLevel.Notice, "CONSOLE MESSAGE: {0}", s); diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs index 8ea1cf7f..9e9538e1 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs @@ -48,16 +48,17 @@ namespace PepperDash.Essentials.Core if (joinMapSerialzed != null) { - var joinMap = JsonConvert.DeserializeObject>(joinMapSerialzed); + var joinMapData = JsonConvert.DeserializeObject>(joinMapSerialzed); - if (joinMap != null) - return joinMap; + if (joinMapData != null) + return joinMapData; else return null; } else return null; } + } /// @@ -255,6 +256,8 @@ namespace PepperDash.Essentials.Core Debug.Console(2, "No mathcing key found in join map for: '{0}'", customJoinData.Key); } } + + PrintJoinMapInfo(); } ///// diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs index 6c648a29..c9a5f605 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs @@ -28,7 +28,6 @@ namespace PepperDash.Essentials.Core.Touchpanels _Touchpanel.ButtonStateChange += new Crestron.SimplSharpPro.DeviceSupport.ButtonEventHandler(_Touchpanel_ButtonStateChange); - AddPostActivationAction(() => { // Link up the button feedbacks to the specified BoolFeedbacks @@ -40,7 +39,7 @@ namespace PepperDash.Essentials.Core.Touchpanels { var bKey = button.Key.ToLower(); - var feedback = device.GetFeedbackProperty(feedbackConfig.BoolFeedbackName); + var feedback = device.GetFeedbackProperty(feedbackConfig.FeedbackName); var bFeedback = feedback as BoolFeedback; var iFeedback = feedback as IntFeedback; @@ -72,7 +71,7 @@ namespace PepperDash.Essentials.Core.Touchpanels } else { - Debug.Console(1, this, "Unable to get BoolFeedback with name: {0} from device: {1}", feedbackConfig.BoolFeedbackName, device.Key); + Debug.Console(1, this, "Unable to get BoolFeedback with name: {0} from device: {1}", feedbackConfig.FeedbackName, device.Key); } } else @@ -140,6 +139,6 @@ namespace PepperDash.Essentials.Core.Touchpanels public class KeypadButtonFeedback { public string DeviceKey { get; set; } - public string BoolFeedbackName { get; set; } + public string FeedbackName { get; set; } } } \ No newline at end of file From 3a101d89ea5b83d48bf3ae4795be51f8e4c52990 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Fri, 3 Apr 2020 18:01:08 -0600 Subject: [PATCH 06/10] Adds some additional help --- .../Devices/EssentialsDevice.cs | 14 ++++++++++++++ .../PepperDash_Essentials_Core.csproj | 1 - .../Plugins/PluginEntrypointAttribute.cs | 19 ------------------- 3 files changed, 14 insertions(+), 20 deletions(-) delete mode 100644 essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginEntrypointAttribute.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsDevice.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsDevice.cs index 7bca06b9..18b187b7 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsDevice.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsDevice.cs @@ -34,8 +34,14 @@ namespace PepperDash.Essentials.Core { #region IDeviceFactory Members + /// + /// A list of strings that can be used in the type property of a DeviceConfig object to build an instance of this device + /// public List TypeNames { get; protected set; } + /// + /// Loads an item to the DeviceFactory.FactoryMethods dictionary for each entry in the TypeNames list + /// public void LoadTypeFactories() { foreach (var typeName in TypeNames) @@ -44,6 +50,11 @@ namespace PepperDash.Essentials.Core } } + /// + /// The method that will build the device + /// + /// The device config + /// An instance of the device public abstract EssentialsDevice BuildDevice(DeviceConfig dc); #endregion @@ -54,6 +65,9 @@ namespace PepperDash.Essentials.Core /// public abstract class EssentialsPluginDeviceFactory : EssentialsDeviceFactory, IPluginDeviceFactory where T : EssentialsDevice { + /// + /// Specifies the minimum version of Essentials required for a plugin to run. Must use the format Major.Minor.Build (ex. "1.4.33") + /// public string MinimumEssentialsFrameworkVersion { get; protected set; } } } \ 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 5e255e82..de778fc5 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -161,7 +161,6 @@ - diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginEntrypointAttribute.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginEntrypointAttribute.cs deleted file mode 100644 index f802211f..00000000 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginEntrypointAttribute.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; - -namespace PepperDash.Essentials.Core.Plugins -{ - [AttributeUsage(AttributeTargets.Class)] - public sealed class PluginEntryPointAttribute : Attribute - { - private readonly string _uniqueKey; - - public string UniqueKey { - get { return _uniqueKey; } - } - - public PluginEntryPointAttribute(string key) - { - _uniqueKey = key; - } - } -} \ No newline at end of file From 9d7f5af26e90361556416dd1c61e1a7b5fa99e9f Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Fri, 3 Apr 2020 18:21:17 -0600 Subject: [PATCH 07/10] Adds IBridgeAdvanced and updates to 1.0.35 of PepperDash.Core --- PepperDashEssentials/Bridges/BridgeBase.cs | 20 ++++++++++++------- PepperDashEssentials/Bridges/IBridge.cs | 10 ++++++++++ PepperDashEssentials/ControlSystem.cs | 2 +- .../Plugins/PluginLoader.cs | 1 - essentials-framework/pepperdashcore-builds | 2 +- 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/PepperDashEssentials/Bridges/BridgeBase.cs b/PepperDashEssentials/Bridges/BridgeBase.cs index de283e4e..c6b1e17a 100644 --- a/PepperDashEssentials/Bridges/BridgeBase.cs +++ b/PepperDashEssentials/Bridges/BridgeBase.cs @@ -124,6 +124,10 @@ namespace PepperDash.Essentials.Bridges (device as IBridge).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); continue; } + else if (device is IBridgeAdvanced) + { + (device as IBridgeAdvanced).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this); + } else if (device is PepperDash.Essentials.Core.Monitoring.SystemMonitorController) { (device as PepperDash.Essentials.Core.Monitoring.SystemMonitorController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); @@ -139,16 +143,18 @@ namespace PepperDash.Essentials.Bridges (device as CameraBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this); continue; } - else if (device is PepperDash.Essentials.Core.DisplayBase) - { - (device as DisplayBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - continue; - } - else if (device is DmChassisController) { + else if (device is PepperDash.Essentials.Core.DisplayBase) + { + (device as DisplayBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); + continue; + } + else if (device is DmChassisController) + { (device as DmChassisController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); continue; } - else if (device is DmBladeChassisController) { + else if (device is DmBladeChassisController) + { (device as DmBladeChassisController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); continue; } diff --git a/PepperDashEssentials/Bridges/IBridge.cs b/PepperDashEssentials/Bridges/IBridge.cs index f95189a0..f2b959ed 100644 --- a/PepperDashEssentials/Bridges/IBridge.cs +++ b/PepperDashEssentials/Bridges/IBridge.cs @@ -7,10 +7,20 @@ using Crestron.SimplSharpPro.DeviceSupport; namespace PepperDash.Essentials.Bridges { + /// + /// Defines a device that uses the legacy JoinMapBase for its join map + /// + [Obsolete("IBridgeAdvanced should be used going forward with JoinMapBaseAdvanced")] public interface IBridge { void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey); + } + /// + /// Defines a device that uses JoinMapBaseAdvanced for its join map + /// + public interface IBridgeAdvanced + { void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge); } } \ No newline at end of file diff --git a/PepperDashEssentials/ControlSystem.cs b/PepperDashEssentials/ControlSystem.cs index d1ca9b0d..ac33c7e7 100644 --- a/PepperDashEssentials/ControlSystem.cs +++ b/PepperDashEssentials/ControlSystem.cs @@ -51,7 +51,7 @@ namespace PepperDash.Essentials CrestronConsole.AddNewConsoleCommand(PepperDash.Essentials.Core.DeviceFactory.GetDeviceFactoryTypes, "gettypes", "Gets the device types that can be built. Accepts a filter string.", ConsoleAccessLevelEnum.AccessOperator); - CrestronConsole.AddNewConsoleCommand(PepperDash.Essentials.Bridges.BridgeHelper.PrintJoinMap, "getjoinmap", "gets map(s) for bridge or device on bridge [brKey [devKey]]", ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand(PepperDash.Essentials.Bridges.BridgeHelper.PrintJoinMap, "getjoinmap", "map(s) for bridge or device on bridge [brKey [devKey]]", ConsoleAccessLevelEnum.AccessOperator); CrestronConsole.AddNewConsoleCommand(s => { diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginLoader.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginLoader.cs index ca9c7b2f..c0d84714 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginLoader.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginLoader.cs @@ -8,7 +8,6 @@ using Crestron.SimplSharp.Reflection; using PepperDash.Core; using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Plugins; namespace PepperDash.Essentials { diff --git a/essentials-framework/pepperdashcore-builds b/essentials-framework/pepperdashcore-builds index acebe6b4..15206840 160000 --- a/essentials-framework/pepperdashcore-builds +++ b/essentials-framework/pepperdashcore-builds @@ -1 +1 @@ -Subproject commit acebe6b43b28cc3a93f899e9714292a0cc1ab2cc +Subproject commit 15206840b3e6338f695e4ffba634a72e51ea1be5 From 43e57ab6d181145ee50e324b86169a1605af0da5 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Fri, 3 Apr 2020 19:43:06 -0600 Subject: [PATCH 08/10] Adds some comments, initializes JoinMaps in EiscApi and moves GenericComm factory to new methodology --- PepperDashEssentials/Bridges/BridgeBase.cs | 6 ++++++ PepperDashEssentials/ControlSystem.cs | 7 ++++--- .../PepperDashEssentialsBase/Factory/DeviceFactory.cs | 11 +++++------ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/PepperDashEssentials/Bridges/BridgeBase.cs b/PepperDashEssentials/Bridges/BridgeBase.cs index c6b1e17a..3a8e6620 100644 --- a/PepperDashEssentials/Bridges/BridgeBase.cs +++ b/PepperDashEssentials/Bridges/BridgeBase.cs @@ -101,6 +101,8 @@ namespace PepperDash.Essentials.Bridges public EiscApi(DeviceConfig dc) : base(dc.Key) { + JoinMaps = new Dictionary(); + PropertiesConfig = JsonConvert.DeserializeObject(dc.Properties.ToString()); Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(PropertiesConfig.Control.IpIdInt, PropertiesConfig.Control.TcpSshProperties.Address, Global.ControlSystem); @@ -119,6 +121,9 @@ namespace PepperDash.Essentials.Bridges if (device != null) { + Debug.Console(1, this, "Linking Device: '{0}'", d.DeviceKey); + + if (device is IBridge) // Check for this first to allow bridges in plugins to override existing bridges that apply to the same type. { (device as IBridge).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); @@ -126,6 +131,7 @@ namespace PepperDash.Essentials.Bridges } else if (device is IBridgeAdvanced) { + Debug.Console(2, this, "'{0}' is IBridgeAdvanced"); (device as IBridgeAdvanced).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this); } else if (device is PepperDash.Essentials.Core.Monitoring.SystemMonitorController) diff --git a/PepperDashEssentials/ControlSystem.cs b/PepperDashEssentials/ControlSystem.cs index ac33c7e7..f158fc1f 100644 --- a/PepperDashEssentials/ControlSystem.cs +++ b/PepperDashEssentials/ControlSystem.cs @@ -290,12 +290,13 @@ namespace PepperDash.Essentials /// public void LoadDevices() { + // Instantiate the Device Factories + new CoreDeviceFactory(); + + // Build the processor wrapper class - DeviceManager.AddDevice(new PepperDash.Essentials.Core.Devices.CrestronProcessor("processor")); - - // Add global System Monitor device DeviceManager.AddDevice(new PepperDash.Essentials.Core.Monitoring.SystemMonitorController("systemMonitor")); diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs index 0fab13ae..201675d0 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs @@ -48,7 +48,6 @@ namespace PepperDash.Essentials.Core var typeName = dc.Type.ToLower(); - // Check for types that have been added by plugin dlls. if (FactoryMethods.ContainsKey(typeName)) { @@ -57,11 +56,11 @@ namespace PepperDash.Essentials.Core } // Check "core" types - if (typeName == "genericcomm") - { - Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); - return new GenericComm(dc); - } + //if (typeName == "genericcomm") + //{ + // Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); + // return new GenericComm(dc); + //} if (typeName == "ceniodigin104") { var control = CommFactory.GetControlPropertiesConfig(dc); From 6474bfa1366c6bee01f7350336172fad0d340179 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Fri, 3 Apr 2020 20:07:27 -0600 Subject: [PATCH 09/10] fixes format exception in debug statement --- PepperDashEssentials/Bridges/BridgeBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PepperDashEssentials/Bridges/BridgeBase.cs b/PepperDashEssentials/Bridges/BridgeBase.cs index 3a8e6620..32e550b2 100644 --- a/PepperDashEssentials/Bridges/BridgeBase.cs +++ b/PepperDashEssentials/Bridges/BridgeBase.cs @@ -121,7 +121,7 @@ namespace PepperDash.Essentials.Bridges if (device != null) { - Debug.Console(1, this, "Linking Device: '{0}'", d.DeviceKey); + Debug.Console(1, this, "Linking Device: '{0}'", device.Key); if (device is IBridge) // Check for this first to allow bridges in plugins to override existing bridges that apply to the same type. @@ -131,7 +131,7 @@ namespace PepperDash.Essentials.Bridges } else if (device is IBridgeAdvanced) { - Debug.Console(2, this, "'{0}' is IBridgeAdvanced"); + Debug.Console(2, this, "'{0}' is IBridgeAdvanced", device.Key); (device as IBridgeAdvanced).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this); } else if (device is PepperDash.Essentials.Core.Monitoring.SystemMonitorController) From 9363e9474944733a213ec44c4e49a9c43c07dbf0 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Sat, 4 Apr 2020 10:43:55 -0600 Subject: [PATCH 10/10] Updates to JoinMapBaseAdvanced constructor to properly add JoinDataComplete fields to Joins collection and to BridgeBase to implement console methods to print data at runtime. --- PepperDashEssentials/Bridges/BridgeBase.cs | 2 + .../JoinMaps/JoinMapBase.cs | 37 ++++++++++++++++--- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/PepperDashEssentials/Bridges/BridgeBase.cs b/PepperDashEssentials/Bridges/BridgeBase.cs index 32e550b2..b3f131c3 100644 --- a/PepperDashEssentials/Bridges/BridgeBase.cs +++ b/PepperDashEssentials/Bridges/BridgeBase.cs @@ -267,6 +267,7 @@ namespace PepperDash.Essentials.Bridges foreach (var joinMap in JoinMaps) { + Debug.Console(0, "Join map for device '{0}':", joinMap.Key); joinMap.Value.PrintJoinMapInfo(); } } @@ -285,6 +286,7 @@ namespace PepperDash.Essentials.Bridges return; } + Debug.Console(0, "Join map for device '{0}' on EISC '{1}':", deviceKey, this.Key); joinMap.PrintJoinMapInfo(); } diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs index 9e9538e1..fbbad609 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs @@ -88,14 +88,17 @@ namespace PepperDash.Essentials.Core // Get the joins of each type and print them Debug.Console(0, "Digitals:"); var digitals = Joins.Where(j => (j.Value.JoinType & eJoinType.Digital) == eJoinType.Digital).ToDictionary(j => j.Key, j => j.Value); + Debug.Console(2, "Found {0} Digital Joins", digitals.Count); PrintJoinList(GetSortedJoins(digitals)); Debug.Console(0, "Analogs:"); var analogs = Joins.Where(j => (j.Value.JoinType & eJoinType.Analog) == eJoinType.Analog).ToDictionary(j => j.Key, j => j.Value); + Debug.Console(2, "Found {0} Analog Joins", analogs.Count); PrintJoinList(GetSortedJoins(analogs)); Debug.Console(0, "Serials:"); var serials = Joins.Where(j => (j.Value.JoinType & eJoinType.Serial) == eJoinType.Serial).ToDictionary(j => j.Key, j => j.Value); + Debug.Console(2, "Found {0} Serial Joins", serials.Count); PrintJoinList(GetSortedJoins(serials)); } @@ -166,24 +169,43 @@ namespace PepperDash.Essentials.Core /// /// The collection of joins and associated metadata /// - public Dictionary Joins = new Dictionary(); + public Dictionary Joins { get; private set; } protected JoinMapBaseAdvanced(uint joinStart) { + Joins = new Dictionary(); + _joinOffset = joinStart - 1; // Add all the JoinDataComplete properties to the Joins Dictionary and pass in the offset - Joins = GetType() + Joins = this.GetType() .GetCType() - .GetProperties() - .Where(prop => prop.IsDefined(typeof(JoinNameAttribute), false)) - .Select(prop => (JoinDataComplete)prop.GetValue(this, null)) - .ToDictionary(join => join.GetNameAttribute(), join => + .GetFields(BindingFlags.Public | BindingFlags.Instance) + .Where(field => field.IsDefined(typeof(JoinNameAttribute), false)) + .Select(prop => (JoinDataComplete)prop.GetValue(this)) + .ToDictionary(join => join.GetNameAttribute(), join => { join.SetJoinOffset(_joinOffset); return join; }); + //var type = this.GetType(); + //var cType = type.GetCType(); + //var fields = cType.GetFields(BindingFlags.Public | BindingFlags.Instance); + //foreach (var field in fields) + //{ + // if (field.IsDefined(typeof(JoinNameAttribute), true)) + // { + // var value = field.GetValue(this) as JoinDataComplete; + + // if (value != null) + // { + // value.SetJoinOffset(_joinOffset); + // Joins.Add(value.GetNameAttribute(), value); + // } + // } + //} + PrintJoinMapInfo(); } @@ -197,14 +219,17 @@ namespace PepperDash.Essentials.Core // Get the joins of each type and print them Debug.Console(0, "Digitals:"); var digitals = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Digital) == eJoinType.Digital).ToDictionary(j => j.Key, j => j.Value); + Debug.Console(2, "Found {0} Digital Joins", digitals.Count); PrintJoinList(GetSortedJoins(digitals)); Debug.Console(0, "Analogs:"); var analogs = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Analog) == eJoinType.Analog).ToDictionary(j => j.Key, j => j.Value); + Debug.Console(2, "Found {0} Analog Joins", analogs.Count); PrintJoinList(GetSortedJoins(analogs)); Debug.Console(0, "Serials:"); var serials = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Serial) == eJoinType.Serial).ToDictionary(j => j.Key, j => j.Value); + Debug.Console(2, "Found {0} Serial Joins", serials.Count); PrintJoinList(GetSortedJoins(serials)); }