Skip to content

Commit

Permalink
Added support for CM19 Transceiver (X10)
Browse files Browse the repository at this point in the history
  • Loading branch information
genemars committed Dec 10, 2018
1 parent a24ddd5 commit 05075a3
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
HG.Configure.Interfaces.ServiceCall('Hardware.SerialPorts', function (ports) {
portSelect.empty().append('<option value="">' + HG.WebApp.Locales.GetLocaleString('systemsettings_selectport_placeholder') + '</option>');
portSelect.append('<option value="" data-ui-action="custom">(enter custom port)</option>');
portSelect.append('<option value="USB">CM15 Pro - USB</option>');
portSelect.append('<option value="USB">CM15 Pro (USB)</option>');
portSelect.append('<option value="CM19-USB">CM19 Transceiver (USB)</option>');
for (var p = 0; p < ports.length; p++) {
portSelect.append('<option value="' + ports[p] + '">CM11 - ' + ports[p] + '</option>');
}
Expand Down Expand Up @@ -301,4 +302,4 @@
}

};
</script>
</script>
10 changes: 7 additions & 3 deletions HomeGenie/HomeGenie.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="CM19Lib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>packages\CM19Lib.1.0.3\lib\CM19Lib.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="CommonMark, Version=0.1.0.0, Culture=neutral, PublicKeyToken=001ef8810438905d">
<HintPath>packages\CommonMark.NET.0.15.1\lib\net45\CommonMark.dll</HintPath>
<Private>True</Private>
Expand Down Expand Up @@ -130,8 +134,8 @@
<HintPath>packages\MIG.1.0.5\lib\MIG.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MIG.HomeAutomation, Version=1.0.6841.30386, Culture=neutral, PublicKeyToken=null">
<HintPath>packages\MIG.HomeAutomation.1.0.2\lib\MIG.HomeAutomation.dll</HintPath>
<Reference Include="MIG.HomeAutomation, Version=1.0.6917.42230, Culture=neutral, PublicKeyToken=null">
<HintPath>packages\MIG.HomeAutomation.1.0.3\lib\MIG.HomeAutomation.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MIG.Protocols, Version=1.0.6841.32282, Culture=neutral, PublicKeyToken=null">
Expand Down Expand Up @@ -226,7 +230,7 @@
<Private>False</Private>
</Reference>
<Reference Include="XTenLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>packages\XTenLib.1.0.10\lib\XTenLib.dll</HintPath>
<HintPath>packages\XTenLib.1.0.11\lib\XTenLib.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="ZWaveLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
Expand Down
1 change: 1 addition & 0 deletions HomeGenie/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ private static void PostInstallCheck()
"LibUsb.Common.dll",
"LibUsbDotNet.LibUsbDotNet.dll",
"XTenLib.dll",
"CM19Lib.dll",
"ZWaveLib.dll"
};
foreach (var f in migFiles)
Expand Down
40 changes: 27 additions & 13 deletions HomeGenie/Service/HomeGenieService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1193,26 +1193,40 @@ internal void modules_Sort()
{
module.Properties.Sort((ModuleParameter p1, ModuleParameter p2) =>
{
return p1.Name.CompareTo(p2.Name);
int c = -1;
try
{
c = p1.Name.CompareTo(p2.Name);
}
catch (Exception e)
{
}
return c;
});
}
//
// sort modules
//
systemModules.Sort((Module m1, Module m2) =>
{
System.Text.RegularExpressions.Regex re = new System.Text.RegularExpressions.Regex(@"([a-zA-Z]+)(\d+)");
System.Text.RegularExpressions.Match result1 = re.Match(m1.Address);
System.Text.RegularExpressions.Match result2 = re.Match(m2.Address);

string alphaPart1 = result1.Groups[1].Value.PadRight(8, '0');
string numberPart1 = (String.IsNullOrWhiteSpace(result1.Groups[2].Value) ? m1.Address.PadLeft(8, '0') : result1.Groups[2].Value.PadLeft(8, '0'));
string alphaPart2 = result2.Groups[1].Value.PadRight(8, '0');
string numberPart2 = (String.IsNullOrWhiteSpace(result2.Groups[2].Value) ? m2.Address.PadLeft(8, '0') : result2.Groups[2].Value.PadLeft(8, '0'));

string d1 = m1.Domain + "|" + alphaPart1 + numberPart1;
string d2 = m2.Domain + "|" + alphaPart2 + numberPart2;
return d1.CompareTo(d2);
int c = -1;
try
{
System.Text.RegularExpressions.Regex re = new System.Text.RegularExpressions.Regex(@"([a-zA-Z]+)(\d+)");
System.Text.RegularExpressions.Match result1 = re.Match(m1.Address);
System.Text.RegularExpressions.Match result2 = re.Match(m2.Address);

string alphaPart1 = result1.Groups[1].Value.PadRight(8, '0');
string numberPart1 = (String.IsNullOrWhiteSpace(result1.Groups[2].Value) ? m1.Address.PadLeft(8, '0') : result1.Groups[2].Value.PadLeft(8, '0'));
string alphaPart2 = result2.Groups[1].Value.PadRight(8, '0');
string numberPart2 = (String.IsNullOrWhiteSpace(result2.Groups[2].Value) ? m2.Address.PadLeft(8, '0') : result2.Groups[2].Value.PadLeft(8, '0'));

string d1 = m1.Domain + "|" + alphaPart1 + numberPart1;
string d2 = m2.Domain + "|" + alphaPart2 + numberPart2;

c = d1.CompareTo(d2);
} catch(Exception e) {}
return c;
});

}
Expand Down
5 changes: 3 additions & 2 deletions HomeGenie/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CM19Lib" version="1.0.3" targetFramework="net45" />
<package id="CommonMark.NET" version="0.15.1" targetFramework="net45" />
<package id="DynamicLanguageRuntime" version="1.2.1" targetFramework="net45" />
<package id="IronPython" version="2.7.8.1" targetFramework="net45" />
Expand All @@ -8,7 +9,7 @@
<package id="LibUsbDotNet" version="2.2.18" targetFramework="net45" />
<package id="M2Mqtt" version="4.3.0.0" targetFramework="net45" />
<package id="MIG" version="1.0.5" targetFramework="net45" />
<package id="MIG.HomeAutomation" version="1.0.2" targetFramework="net45" />
<package id="MIG.HomeAutomation" version="1.0.3" 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 All @@ -17,6 +18,6 @@
<package id="SharpZipLib" version="1.0.0" targetFramework="net45" />
<package id="UDE.CSharp" version="1.1.0" targetFramework="net45" />
<package id="WebSocketSharp-netstandard" version="1.0.1" targetFramework="net45" />
<package id="XTenLib" version="1.0.10" targetFramework="net45" />
<package id="XTenLib" version="1.0.11" targetFramework="net45" />
<package id="ZWaveLib" version="1.0.18" targetFramework="net45" />
</packages>

0 comments on commit 05075a3

Please sign in to comment.