Skip to content

Commit

Permalink
updated CM19Lib; integrated CM19Lib (as X10) namespace into automatio…
Browse files Browse the repository at this point in the history
…n programs; added 'Title' and 'Description' properties to ProgramHelper; fix dynamic module creation not working (UI);
  • Loading branch information
genemars committed Dec 23, 2018
1 parent 0673147 commit 1e2d086
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 12 deletions.
10 changes: 6 additions & 4 deletions BaseFiles/Common/html/js/app/homegenie.webapp.utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -324,4 +326,4 @@ HG.WebApp.Utility = HG.WebApp.Utility || new function(){ var $$ = this;
$$.SwitchPopup = HG.Ui.SwitchPopup;
$$.JScrollToElement = HG.Ui.ScrollTo;

};
};
19 changes: 16 additions & 3 deletions BaseFiles/Common/html/pages/events/_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -456,4 +469,4 @@
};

};
HG.Ui.CreatePage(HG.WebApp.Events, 'page_events');
HG.Ui.CreatePage(HG.WebApp.Events, 'page_events');
3 changes: 3 additions & 0 deletions HomeGenie/Automation/Engines/CSharpAppFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public static int ProgramCodeOffset
"HomeGenie.Automation",
"HomeGenie.Data",
"MIG",
"CM19Lib",
"X10 = CM19Lib.X10",
"Innovative.Geometry",
"Innovative.SolarCalculator",
"Raspberry",
Expand Down Expand Up @@ -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");

Expand Down
10 changes: 10 additions & 0 deletions HomeGenie/Automation/Scripting/ProgramHelperBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ public ProgramHelperBase(HomeGenieService hg)
homegenie = hg;
}

/// <summary>
/// Program title field (runtime variable)
/// </summary>
public string Title;

/// <summary>
/// Program description field (runtime variable)
/// </summary>
public string Description;

/// <summary>
/// Gets the logger object.
/// </summary>
Expand Down
6 changes: 3 additions & 3 deletions HomeGenie/HomeGenie.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="CM19Lib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>packages\CM19Lib.1.0.4\lib\CM19Lib.dll</HintPath>
<HintPath>packages\CM19Lib.1.1.2\lib\CM19Lib.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="CommonMark, Version=0.1.0.0, Culture=neutral, PublicKeyToken=001ef8810438905d">
Expand Down Expand Up @@ -126,8 +126,8 @@
<HintPath>packages\MIG.1.0.8\lib\MIG.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MIG.HomeAutomation, Version=1.0.6927.31715, Culture=neutral, PublicKeyToken=null">
<HintPath>packages\MIG.HomeAutomation.1.0.8\lib\MIG.HomeAutomation.dll</HintPath>
<Reference Include="MIG.HomeAutomation, Version=1.0.6931.37409, Culture=neutral, PublicKeyToken=null">
<HintPath>packages\MIG.HomeAutomation.1.0.9\lib\MIG.HomeAutomation.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MIG.Protocols, Version=1.0.6841.32282, Culture=neutral, PublicKeyToken=null">
Expand Down
4 changes: 2 additions & 2 deletions HomeGenie/packages.config
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CM19Lib" version="1.0.4" targetFramework="net45" />
<package id="CM19Lib" version="1.1.2" targetFramework="net45" />
<package id="CommonMark.NET" version="0.15.1" targetFramework="net45" />
<package id="DynamicLanguageRuntime" version="1.2.2" targetFramework="net45" />
<package id="IronPython" version="2.7.9" targetFramework="net45" />
<package id="Jint" version="2.11.58" targetFramework="net45" />
<package id="LibUsbDotNet" version="2.2.8" targetFramework="net45" />
<package id="M2Mqtt" version="4.3.0.0" targetFramework="net45" />
<package id="MIG" version="1.0.8" targetFramework="net45" />
<package id="MIG.HomeAutomation" version="1.0.8" targetFramework="net45" />
<package id="MIG.HomeAutomation" version="1.0.9" targetFramework="net45" />
<package id="MIG.Protocols" version="1.0.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net45" />
<package id="NLog" version="4.5.10" targetFramework="net45" />
Expand Down

0 comments on commit 1e2d086

Please sign in to comment.