From 1e2d0862024ae4daa9a40a3d8d59cbf4c2eeb1db Mon Sep 17 00:00:00 2001 From: Generoso Martello Date: Sun, 23 Dec 2018 23:08:03 +0100 Subject: [PATCH] updated CM19Lib; integrated CM19Lib (as X10) namespace into automation programs; added 'Title' and 'Description' properties to ProgramHelper; fix dynamic module creation not working (UI); --- .../html/js/app/homegenie.webapp.utility.js | 10 ++++++---- BaseFiles/Common/html/pages/events/_events.js | 19 ++++++++++++++++--- .../Automation/Engines/CSharpAppFactory.cs | 3 +++ .../Automation/Scripting/ProgramHelperBase.cs | 10 ++++++++++ HomeGenie/HomeGenie.csproj | 6 +++--- HomeGenie/packages.config | 4 ++-- 6 files changed, 40 insertions(+), 12 deletions(-) diff --git a/BaseFiles/Common/html/js/app/homegenie.webapp.utility.js b/BaseFiles/Common/html/js/app/homegenie.webapp.utility.js index a99e2908d..e0cbbd85f 100644 --- a/BaseFiles/Common/html/js/app/homegenie.webapp.utility.js +++ b/BaseFiles/Common/html/js/app/homegenie.webapp.utility.js @@ -135,8 +135,9 @@ HG.WebApp.Utility = HG.WebApp.Utility || new function(){ var $$ = this; { var module = null; for (var m = 0; m < HG.WebApp.Data.Modules.length; m++) { - if (HG.WebApp.Data.Modules[m].Domain == domain && HG.WebApp.Data.Modules[m].Address == address) { - module = HG.WebApp.Data.Modules[m]; + var cm = HG.WebApp.Data.Modules[m]; + if (cm != null && cm.Domain == domain && cm.Address == address) { + module = cm; break; } } @@ -147,7 +148,8 @@ HG.WebApp.Utility = HG.WebApp.Utility || new function(){ var $$ = this; { var moduleidx = -1; for (var m = 0; m < HG.WebApp.Data.Modules.length; m++) { - if (HG.WebApp.Data.Modules[m].Domain == domain && HG.WebApp.Data.Modules[m].Address == address) { + var cm = HG.WebApp.Data.Modules[m]; + if (cm != null && cm.Domain == domain && cm.Address == address) { moduleidx = m; break; } @@ -324,4 +326,4 @@ HG.WebApp.Utility = HG.WebApp.Utility || new function(){ var $$ = this; $$.SwitchPopup = HG.Ui.SwitchPopup; $$.JScrollToElement = HG.Ui.ScrollTo; -}; \ No newline at end of file +}; diff --git a/BaseFiles/Common/html/pages/events/_events.js b/BaseFiles/Common/html/pages/events/_events.js index 61fd89c17..f05f1ed62 100644 --- a/BaseFiles/Common/html/pages/events/_events.js +++ b/BaseFiles/Common/html/pages/events/_events.js @@ -87,9 +87,22 @@ if (module != null) { HG.WebApp.Utility.SetModulePropertyByName(module, event.Property, event.Value, event.Timestamp); HG.WebApp.Control.RefreshGroupIndicators(); + $$.SendEventToUi(module, event); + } else { + console.log("Adding module:", event.Domain, event.Source, "..."); + HG.Configure.Modules.Get(event.Domain, event.Source, function (data) { + try { + module = eval('[' + data + ']')[0]; + if (module != null) { + HG.WebApp.Data.Modules.push(module); + $$.SendEventToUi(module, event); + console.log("...done."); + } + } catch (e) { + console.log("...error!", e); + } + }); } - // send message to UI for updating UI elements related to this event (widgets, popup and such) - $$.SendEventToUi(module, event); } // if (event.Domain == 'MIGService.Interfaces') { @@ -456,4 +469,4 @@ }; }; -HG.Ui.CreatePage(HG.WebApp.Events, 'page_events'); \ No newline at end of file +HG.Ui.CreatePage(HG.WebApp.Events, 'page_events'); diff --git a/HomeGenie/Automation/Engines/CSharpAppFactory.cs b/HomeGenie/Automation/Engines/CSharpAppFactory.cs index 6ac6dee6a..bc9863255 100644 --- a/HomeGenie/Automation/Engines/CSharpAppFactory.cs +++ b/HomeGenie/Automation/Engines/CSharpAppFactory.cs @@ -59,6 +59,8 @@ public static int ProgramCodeOffset "HomeGenie.Automation", "HomeGenie.Data", "MIG", + "CM19Lib", + "X10 = CM19Lib.X10", "Innovative.Geometry", "Innovative.SolarCalculator", "Raspberry", @@ -222,6 +224,7 @@ private MethodRunResult Setup() compilerParams.ReferencedAssemblies.Add("HomeGenie.exe"); compilerParams.ReferencedAssemblies.Add("MIG.dll"); + compilerParams.ReferencedAssemblies.Add(Path.Combine("lib", "mig", "CM19Lib.dll")); compilerParams.ReferencedAssemblies.Add("NLog.dll"); compilerParams.ReferencedAssemblies.Add("Newtonsoft.Json.dll"); diff --git a/HomeGenie/Automation/Scripting/ProgramHelperBase.cs b/HomeGenie/Automation/Scripting/ProgramHelperBase.cs index 1e9bb2449..a8fe0197c 100644 --- a/HomeGenie/Automation/Scripting/ProgramHelperBase.cs +++ b/HomeGenie/Automation/Scripting/ProgramHelperBase.cs @@ -19,6 +19,16 @@ public ProgramHelperBase(HomeGenieService hg) homegenie = hg; } + /// + /// Program title field (runtime variable) + /// + public string Title; + + /// + /// Program description field (runtime variable) + /// + public string Description; + /// /// Gets the logger object. /// diff --git a/HomeGenie/HomeGenie.csproj b/HomeGenie/HomeGenie.csproj index 655578c55..1cb529b9a 100644 --- a/HomeGenie/HomeGenie.csproj +++ b/HomeGenie/HomeGenie.csproj @@ -70,7 +70,7 @@ - packages\CM19Lib.1.0.4\lib\CM19Lib.dll + packages\CM19Lib.1.1.2\lib\CM19Lib.dll True @@ -126,8 +126,8 @@ packages\MIG.1.0.8\lib\MIG.dll True - - packages\MIG.HomeAutomation.1.0.8\lib\MIG.HomeAutomation.dll + + packages\MIG.HomeAutomation.1.0.9\lib\MIG.HomeAutomation.dll True diff --git a/HomeGenie/packages.config b/HomeGenie/packages.config index 3c3d9a63a..8e1d08bba 100644 --- a/HomeGenie/packages.config +++ b/HomeGenie/packages.config @@ -1,6 +1,6 @@  - + @@ -8,7 +8,7 @@ - +