mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-17 05:35:03 +00:00
DID Not commit separately but also made bridge eisc uo actions use a threadpool thread. Fix the load plugin to load dlls before calling the load plugin method. Also added capability to place a cplz and unzip and load. The crestron dlls will throw exceptions so catching them and printing to console if debug is enabled to hide the messages from log and user as they can look like a problem when they are not. IMPORTANT we may need to add some logic to deal with multiple cplz's unzipping as the files will auto overwrite. See JIRA ticket ECS-1113
This commit is contained in:
@@ -130,11 +130,11 @@ public class BridgeApiEisc
|
|||||||
Debug.Console(1, "BridgeApiEisc change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue);
|
Debug.Console(1, "BridgeApiEisc change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue);
|
||||||
var uo = args.Sig.UserObject;
|
var uo = args.Sig.UserObject;
|
||||||
if (uo is Action<bool>)
|
if (uo is Action<bool>)
|
||||||
(uo as Action<bool>)(args.Sig.BoolValue);
|
CrestronInvoke.BeginInvoke(o => (uo as Action<bool>)((o as SigEventArgs).Sig.BoolValue), args);
|
||||||
else if (uo is Action<ushort>)
|
else if (uo is Action<ushort>)
|
||||||
(uo as Action<ushort>)(args.Sig.UShortValue);
|
CrestronInvoke.BeginInvoke(o => (uo as Action<ushort>)((o as SigEventArgs).Sig.UShortValue), args);
|
||||||
else if (uo is Action<string>)
|
else if (uo is Action<string>)
|
||||||
(uo as Action<string>)(args.Sig.StringValue);
|
CrestronInvoke.BeginInvoke(o => (uo as Action<string>)((o as SigEventArgs).Sig.StringValue), args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ namespace PepperDash.Essentials
|
|||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials v{0} on 3-series Appliance", versionString);
|
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials v{0} on 3-series Appliance", versionString);
|
||||||
|
|
||||||
// Check if User/ProgramX exists
|
// Check if User/ProgramX exists
|
||||||
if(Directory.Exists(directoryPrefix + dirSeparator + "User"
|
if (Directory.Exists(directoryPrefix + dirSeparator + "User"
|
||||||
+ dirSeparator + string.Format("program{0}", InitialParametersClass.ApplicationNumber)))
|
+ dirSeparator + string.Format("program{0}", InitialParametersClass.ApplicationNumber)))
|
||||||
{
|
{
|
||||||
Debug.Console(0, @"User/program{0} directory found", InitialParametersClass.ApplicationNumber);
|
Debug.Console(0, @"User/program{0} directory found", InitialParametersClass.ApplicationNumber);
|
||||||
@@ -197,37 +197,70 @@ namespace PepperDash.Essentials
|
|||||||
|
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Plugins directory found, checking for factory plugins");
|
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Plugins directory found, checking for factory plugins");
|
||||||
var di = new DirectoryInfo(dir);
|
var di = new DirectoryInfo(dir);
|
||||||
|
var zFiles = di.GetFiles("*.cplz");
|
||||||
|
foreach (var fi in zFiles)
|
||||||
|
{
|
||||||
|
Debug.Console(0, "Found cplz: {0}. Unzipping into plugins directory", fi.Name);
|
||||||
|
var result = CrestronZIP.Unzip(fi.FullName, di.FullName);
|
||||||
|
Debug.Console(0, "UnZip Result: {0}", result.ToString());
|
||||||
|
fi.Delete();
|
||||||
|
}
|
||||||
var files = di.GetFiles("*.dll");
|
var files = di.GetFiles("*.dll");
|
||||||
|
Dictionary<string, Assembly> assyList = new Dictionary<string, Assembly>();
|
||||||
foreach (FileInfo fi in files)
|
foreach (FileInfo fi in files)
|
||||||
{
|
{
|
||||||
// TODO COPY plugin to loadedPlugins folder
|
// TODO COPY plugin to loadedPlugins folder
|
||||||
|
|
||||||
// TODO LOAD that loadedPlugins dll file
|
// TODO LOAD that loadedPlugins dll file
|
||||||
|
try
|
||||||
|
{
|
||||||
var assy = Assembly.LoadFrom(fi.FullName);
|
var assy = Assembly.LoadFrom(fi.FullName);
|
||||||
var ver = assy.GetName().Version;
|
var ver = assy.GetName().Version;
|
||||||
var verStr = string.Format("{0}.{1}.{2}.{3}", ver.Major, ver.Minor, ver.Build, ver.Revision);
|
var verStr = string.Format("{0}.{1}.{2}.{3}", ver.Major, ver.Minor, ver.Build, ver.Revision);
|
||||||
|
assyList.Add(fi.FullName, assy);
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loaded plugin file '{0}', version {1}", fi.FullName, verStr);
|
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loaded plugin file '{0}', version {1}", fi.FullName, verStr);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Debug.Console(2, "Assembly {0} is not a custom assembly", fi.FullName);
|
||||||
|
continue; //catching any load issues and continuing. There will be exceptions loading Crestron .dlls from the cplz Probably should do something different here
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (var assy in assyList)
|
||||||
|
{
|
||||||
// iteratate this assembly's classes, looking for "LoadPlugin()" methods
|
// iteratate this assembly's classes, looking for "LoadPlugin()" methods
|
||||||
var types = assy.GetTypes();
|
try
|
||||||
|
{
|
||||||
|
var types = assy.Value.GetTypes();
|
||||||
foreach (var type in types)
|
foreach (var type in types)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var methods = type.GetMethods(BindingFlags.Public | BindingFlags.Static);
|
var methods = type.GetMethods(BindingFlags.Public | BindingFlags.Static);
|
||||||
var loadPlugin = methods.FirstOrDefault(m => m.Name.Equals("LoadPlugin"));
|
var loadPlugin = methods.FirstOrDefault(m => m.Name.Equals("LoadPlugin"));
|
||||||
if (loadPlugin != null)
|
if (loadPlugin != null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Adding type {0}", fi.FullName, type.FullName);
|
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Adding type {0}", assy.Key, type.FullName);
|
||||||
loadPlugin.Invoke(null, null);
|
loadPlugin.Invoke(null, null);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Debug.Console(2, "Load Plugin not found. {0} is not a plugin assembly", assy.Value.FullName);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Debug.Console(2, "Assembly {0} is not a custom assembly. Types cannot be loaded.", assy.Value.FullName);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
// plugin dll will be loaded. Any classes in plugin should have a static constructor
|
// plugin dll will be loaded. Any classes in plugin should have a static constructor
|
||||||
// that registers that class with the Core.DeviceFactory
|
// that registers that class with the Core.DeviceFactory
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Verifies filesystem is set up. IR, SGD, and programX folders
|
/// Verifies filesystem is set up. IR, SGD, and programX folders
|
||||||
|
|||||||
Reference in New Issue
Block a user