Skip to content

Commit ad1e67c

Browse files
committed
Completed LightwaveRf implementation for Dimmers
1 parent bb2981d commit ad1e67c

37 files changed

+1001
-105
lines changed
+18-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<configSections>
44
<section name="hostContainer" type="SimpleConfig.Section, SimpleConfig" />
55
<section name="rabbitMq" type="SimpleConfig.Section, SimpleConfig" />
6-
<section name="wifiLink" type="SimpleConfig.Section, SimpleConfig"/>
6+
<section name="wifiLink" type="SimpleConfig.Section, SimpleConfig" />
77
</configSections>
88
<hostContainer>
99
<modulePatterns>
@@ -13,12 +13,26 @@
1313
</hostContainer>
1414
<rabbitMq HostName="devbox" UserName="HarmonizeClient" Password="P2ssw0rd" ExchangeName="Harmonize" QueueName="Host" />
1515
<wifiLink>
16-
<Settings ipAddress="192.168.1.59" commandPort="9760" queryPort="9761" />
16+
<Settings WifiLinkIpAddress="192.168.1.59" commandPort="9760" queryPort="9761" />
1717
<Devices>
18-
<Device Name="Roof Light" Description="Main light in middle of roof" Location="Living Room" Type="Dimmer" RoomNumber="1" DeviceNumber="1" />
18+
<Dimmers>
19+
<Dimmer Name="Roof Light" Description="Main light in middle of roof" Location="Living Room" Type="Dimmer" RoomNumber="1" DeviceNumber="1" />
20+
</Dimmers>
1921
</Devices>
2022
</wifiLink>
2123
<startup>
2224
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
2325
</startup>
26+
<runtime>
27+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
28+
<dependentAssembly>
29+
<assemblyIdentity name="System.Reactive.Interfaces" publicKeyToken="31bf3856ad364e35" culture="neutral" />
30+
<bindingRedirect oldVersion="0.0.0.0-2.2.5.0" newVersion="2.2.5.0" />
31+
</dependentAssembly>
32+
<dependentAssembly>
33+
<assemblyIdentity name="System.Reactive.Linq" publicKeyToken="31bf3856ad364e35" culture="neutral" />
34+
<bindingRedirect oldVersion="0.0.0.0-2.2.5.0" newVersion="2.2.5.0" />
35+
</dependentAssembly>
36+
</assemblyBinding>
37+
</runtime>
2438
</configuration>

Bebbs.Harmonize.With.LightwaveRf/Bebbs.Harmonize.With.LightwaveRf.csproj

+37-2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,21 @@
5555
</Reference>
5656
<Reference Include="System" />
5757
<Reference Include="System.Core" />
58+
<Reference Include="System.Reactive.Core, Version=2.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
59+
<SpecificVersion>False</SpecificVersion>
60+
<HintPath>..\packages\Rx-Core.2.2.5\lib\net45\System.Reactive.Core.dll</HintPath>
61+
</Reference>
62+
<Reference Include="System.Reactive.Interfaces, Version=2.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
63+
<SpecificVersion>False</SpecificVersion>
64+
<HintPath>..\packages\Rx-Interfaces.2.2.5\lib\net45\System.Reactive.Interfaces.dll</HintPath>
65+
</Reference>
66+
<Reference Include="System.Reactive.Linq, Version=2.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
67+
<SpecificVersion>False</SpecificVersion>
68+
<HintPath>..\packages\Rx-Linq.2.2.5\lib\net45\System.Reactive.Linq.dll</HintPath>
69+
</Reference>
70+
<Reference Include="System.Reactive.PlatformServices">
71+
<HintPath>..\packages\Rx-PlatformServices.2.2.5\lib\net45\System.Reactive.PlatformServices.dll</HintPath>
72+
</Reference>
5873
<Reference Include="System.Xml.Linq" />
5974
<Reference Include="System.Data.DataSetExtensions" />
6075
<Reference Include="Microsoft.CSharp" />
@@ -65,15 +80,35 @@
6580
</Reference>
6681
</ItemGroup>
6782
<ItemGroup>
68-
<Compile Include="Bootstrapper.cs" />
83+
<Compile Include="Configuration\Devices.cs" />
84+
<Compile Include="Service.cs" />
85+
<Compile Include="WifiLink\Bridge.cs" />
6986
<Compile Include="Configuration\Device.cs" />
7087
<Compile Include="Configuration\DeviceType.cs" />
71-
<Compile Include="Configuration\Extensions.cs" />
88+
<Compile Include="Configuration\Dimmer.cs" />
89+
<Compile Include="Configuration\DimmerType.cs" />
7290
<Compile Include="Configuration\Provider.cs" />
7391
<Compile Include="Configuration\Settings.cs" />
7492
<Compile Include="Configuration\WifiLink.cs" />
93+
<Compile Include="Constants.cs" />
94+
<Compile Include="Dimmer\Builder.cs" />
95+
<Compile Include="Dimmer\Constants.cs" />
96+
<Compile Include="Dimmer\Level.cs" />
97+
<Compile Include="Dimmer\Extensions.cs" />
98+
<Compile Include="Dimmer\Off.cs" />
99+
<Compile Include="Dimmer\On.cs" />
100+
<Compile Include="Dimmer\Percent.cs" />
101+
<Compile Include="Entity\Factory.cs" />
102+
<Compile Include="Dimmer\Entity.cs" />
103+
<Compile Include="Entity\IBuilder.cs" />
104+
<Compile Include="ILightwaveEntity.cs" />
105+
<Compile Include="Module.cs" />
75106
<Compile Include="Program.cs" />
76107
<Compile Include="Properties\AssemblyInfo.cs" />
108+
<Compile Include="WifiLink\CommandBuilder.cs" />
109+
<Compile Include="WifiLink\QueryEndpoint.cs" />
110+
<Compile Include="WifiLink\CommandEndpoint.cs" />
111+
<Compile Include="WifiLink\InstructionNumber.cs" />
77112
</ItemGroup>
78113
<ItemGroup>
79114
<None Include="App.config" />

Bebbs.Harmonize.With.LightwaveRf/Bootstrapper.cs

-50
This file was deleted.

Bebbs.Harmonize.With.LightwaveRf/Configuration/Device.cs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
using System.Xml.Serialization;
23
namespace Bebbs.Harmonize.With.LightwaveRf.Configuration
34
{
45
public interface IDevice
@@ -11,11 +12,12 @@ public interface IDevice
1112

1213
DeviceType Type { get; }
1314

14-
uint RoomNumber { get; }
15+
byte RoomNumber { get; }
1516

16-
uint DeviceNumber { get; }
17+
byte DeviceNumber { get; }
1718
}
1819

20+
[XmlInclude(typeof(Dimmer))]
1921
public class Device : IDevice
2022
{
2123
public string Name { get; set; }
@@ -26,8 +28,8 @@ public class Device : IDevice
2628

2729
public DeviceType Type { get; set; }
2830

29-
public uint RoomNumber { get; set; }
31+
public byte RoomNumber { get; set; }
3032

31-
public uint DeviceNumber { get; set; }
33+
public byte DeviceNumber { get; set; }
3234
}
3335
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Bebbs.Harmonize.With.LightwaveRf.Configuration
8+
{
9+
public interface IDevices
10+
{
11+
12+
}
13+
14+
public class Devices : IDevices
15+
{
16+
public IEnumerable<Dimmer> Dimmers { get; set; }
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+

2+
namespace Bebbs.Harmonize.With.LightwaveRf.Configuration
3+
{
4+
public class Dimmer : Device
5+
{
6+
public DimmerType DimmerType { get; set; }
7+
}
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+

2+
namespace Bebbs.Harmonize.With.LightwaveRf.Configuration
3+
{
4+
public enum DimmerType
5+
{
6+
OneGang,
7+
TwoGang,
8+
ThreeGang,
9+
FourGang
10+
}
11+
}

Bebbs.Harmonize.With.LightwaveRf/Configuration/Extensions.cs

-22
This file was deleted.

Bebbs.Harmonize.With.LightwaveRf/Configuration/Provider.cs

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
using Bebbs.Harmonize.With.Component;
2+
using EventSourceProxy;
23
using System;
34
using System.Collections.Generic;
45
using System.Linq;
56
using Config = SimpleConfig.Configuration;
67

78
namespace Bebbs.Harmonize.With.LightwaveRf.Configuration
89
{
10+
[EventSourceImplementation(Name = "Bebbs-Harmonize-With-LightwaveRf-Configuration-Provider")]
911
public interface IProvider
1012
{
1113
ISettings GetSettings();
@@ -24,12 +26,7 @@ public ISettings GetSettings()
2426

2527
public IEnumerable<IDevice> GetDevices()
2628
{
27-
return WifiLink.Value.Devices;
28-
}
29-
30-
public IEnumerable<IEntity> GetEntities()
31-
{
32-
return WifiLink.Value.Devices.Select(device => device.AsEntity());
29+
return WifiLink.Value.Devices.Dimmers;
3330
}
3431
}
3532
}

Bebbs.Harmonize.With.LightwaveRf/Configuration/Settings.cs

+10-6
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,23 @@ namespace Bebbs.Harmonize.With.LightwaveRf.Configuration
33
{
44
public interface ISettings
55
{
6-
string IpAddress { get; }
6+
string LocalIpAddress { get; }
7+
8+
string WifiLinkIpAddress { get; }
79

8-
uint CommandPort { get; }
10+
int CommandPort { get; }
911

10-
uint QueryPort { get; }
12+
int QueryPort { get; }
1113
}
1214

1315
public class Settings : ISettings
1416
{
15-
public string IpAddress { get; set; }
17+
public string LocalIpAddress { get; set; }
18+
19+
public string WifiLinkIpAddress { get; set; }
1620

17-
public uint CommandPort { get; set; }
21+
public int CommandPort { get; set; }
1822

19-
public uint QueryPort { get; set; }
23+
public int QueryPort { get; set; }
2024
}
2125
}

Bebbs.Harmonize.With.LightwaveRf/Configuration/WifiLink.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ public class WifiLink
66
{
77
public Settings Settings { get; set; }
88

9-
public IEnumerable<Device> Devices { get; set; }
9+
public Devices Devices { get; set; }
1010
}
1111
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using Bebbs.Harmonize.With.Component;
2+
3+
namespace Bebbs.Harmonize.With.LightwaveRf
4+
{
5+
public static class Constants
6+
{
7+
public static readonly string Manufacturer = "LightwaveRf";
8+
9+
public static readonly Identity Identity = new Identity("Bebbs.Harmonize.With.LightwaveRf");
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using EventSourceProxy;
2+
using System;
3+
4+
namespace Bebbs.Harmonize.With.LightwaveRf.Dimmer
5+
{
6+
[EventSourceImplementation(Name = "Bebbs-Harmonize-With-LightwaveRf-Dimmer-Builder")]
7+
public interface IBuilder : LightwaveRf.Entity.IBuilder { }
8+
9+
internal class Builder : IBuilder
10+
{
11+
public ILightwaveEntity Build(Configuration.IDevice device, WifiLink.IBridge bridge, With.Messaging.Client.IEndpoint clientEndpoint)
12+
{
13+
Configuration.Dimmer dimmer = device as Configuration.Dimmer;
14+
15+
if (dimmer != null)
16+
{
17+
return new Entity(dimmer, bridge, clientEndpoint);
18+
}
19+
else
20+
{
21+
throw new InvalidOperationException(string.Format("Could not create dimmer from device '{0}'", device));
22+
}
23+
}
24+
25+
public Configuration.DeviceType DeviceType
26+
{
27+
get { return Configuration.DeviceType.Dimmer; }
28+
}
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+

2+
namespace Bebbs.Harmonize.With.LightwaveRf.Dimmer
3+
{
4+
public static class Constants
5+
{
6+
public static readonly string Model = "Dimmer";
7+
8+
public static readonly string OneGang = "1 Gang Dimmer";
9+
10+
public static readonly string TwoGang = "2 Gang Dimmer";
11+
12+
public static readonly string ThreeGang = "3 Gang Dimmer";
13+
14+
public static readonly string FourGang = "4 Gang Dimmer";
15+
}
16+
}

0 commit comments

Comments
 (0)