Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
chkr1011 committed Apr 13, 2017
2 parents ff1f530 + 3ace71f commit 4dff331
Show file tree
Hide file tree
Showing 105 changed files with 1,268 additions and 1,188 deletions.
2 changes: 1 addition & 1 deletion App/HA4IoT.WebApp/Views/FanTemplate.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<span class="glyphicon glyphicon-arrow-down"></span>
</a>

<a href="#" class="btn btn-default" ng-repeat="i in getNumbers(component.Features.LevelStateFeature.MaxLevel)" ng-class="component.State.LevelState.Value===0 && i===0 ? 'btn-success' : component.State.LevelState.Value===i ? 'btn-danger' : 'btn-default'" ng-click="ctrl.componentService.setLevel(component, i)">
<a href="#" class="btn btn-default" ng-repeat="i in getNumbers(component.Features.LevelFeature.MaxLevel)" ng-class="component.State.LevelState.Value===0 && i===0 ? 'btn-success' : component.State.LevelState.Value===i ? 'btn-danger' : 'btn-default'" ng-click="ctrl.componentService.setLevel(component, i)">
<span>{{i}}</span>
</a>

Expand Down
2 changes: 1 addition & 1 deletion App/HA4IoT.WebApp/cache.manifest
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CACHE MANIFEST
# Version 1.17.169
# Version 1.17.170

CACHE:

Expand Down
1 change: 1 addition & 0 deletions App/LocalDeployInfo.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
192.168.1.15=
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using HA4IoT.Actuators;
using HA4IoT.Actuators.Connectors;
using HA4IoT.Actuators.Fans;
using HA4IoT.Actuators.Lamps;
using HA4IoT.Actuators.RollerShutters;
using HA4IoT.Adapters;
Expand Down Expand Up @@ -181,16 +180,16 @@ public void Apply()
.WithEnabledAtNight()
.WithSkipIfAnyIsAlreadyOn(area.GetLamp(Bedroom.LampBedLeft), area.GetLamp(Bedroom.LampBedRight));

area.RegisterComponent(new Fan($"{area.Id}.{Bedroom.Fan}", new BedroomFanAdapter(hsrel8)));
_actuatorFactory.RegisterFan(area, Bedroom.Fan, new BedroomFanAdapter(hsrel8));

area.GetButton(Bedroom.ButtonBedLeftInner).PressedShortTrigger.Attach(() => area.GetComponent(Bedroom.LampBedLeft).TryTogglePowerState());
area.GetButton(Bedroom.ButtonBedLeftInner).PressedLongTrigger.Attach(() => area.GetComponent(Bedroom.CombinedCeilingLights).TryTogglePowerState());
area.GetButton(Bedroom.ButtonBedLeftOuter).PressedShortTrigger.Attach(area.GetFan(Bedroom.Fan).SetNextLevelAction);
area.GetButton(Bedroom.ButtonBedLeftOuter).PressedShortTrigger.Attach(() => area.GetComponent(Bedroom.Fan).TryIncreaseLevel());
area.GetButton(Bedroom.ButtonBedLeftOuter).PressedLongTrigger.Attach(() => area.GetComponent(Bedroom.Fan).TryTurnOff());

area.GetButton(Bedroom.ButtonBedRightInner).PressedShortTrigger.Attach(() => area.GetComponent(Bedroom.LampBedRight).TryTogglePowerState());
area.GetButton(Bedroom.ButtonBedRightInner).PressedLongTrigger.Attach(() => area.GetComponent(Bedroom.CombinedCeilingLights).TryTogglePowerState());
area.GetButton(Bedroom.ButtonBedRightOuter).PressedShortTrigger.Attach(area.GetFan(Bedroom.Fan).SetNextLevelAction);
area.GetButton(Bedroom.ButtonBedRightOuter).PressedShortTrigger.Attach(() => area.GetComponent(Bedroom.Fan).TryIncreaseLevel());
area.GetButton(Bedroom.ButtonBedRightOuter).PressedLongTrigger.Attach(() => area.GetComponent(Bedroom.Fan).TryTurnOff());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace HA4IoT.Controller.Main.Main.Rooms
{
internal class KitchenConfiguration
{
private readonly ISystemEventsService _systemEventsService;
private readonly IAreaRegistryService _areaService;
private readonly IDeviceRegistryService _deviceService;
private readonly CCToolsDeviceService _ccToolsBoardService;
Expand Down Expand Up @@ -57,10 +58,14 @@ public enum Kitchen
SocketWall,
SocketKitchenette,

SocketCeiling1, // Über Hängeschrank
SocketCeiling2, // Bei Dunsabzug

Window
}

public KitchenConfiguration(
ISystemEventsService systemEventsService,
IAreaRegistryService areaService,
IDeviceRegistryService deviceService,
CCToolsDeviceService ccToolsDeviceService,
Expand All @@ -69,6 +74,7 @@ public KitchenConfiguration(
ActuatorFactory actuatorFactory,
SensorFactory sensorFactory)
{
_systemEventsService = systemEventsService ?? throw new ArgumentNullException(nameof(systemEventsService));
_areaService = areaService ?? throw new ArgumentNullException(nameof(areaService));
_deviceService = deviceService ?? throw new ArgumentNullException(nameof(deviceService));
_ccToolsBoardService = ccToolsDeviceService ?? throw new ArgumentNullException(nameof(ccToolsDeviceService));
Expand Down Expand Up @@ -102,18 +108,26 @@ public void Apply()

_sensorFactory.RegisterMotionDetector(area, Kitchen.MotionDetector, input1.GetInput(8));

var rgb = _outpostDeviceService.GetRgbAdapter("RGBSK1");
_actuatorFactory.RegisterLamp(area, Kitchen.LightCeilingMiddle, hsrel5[HSREL5Pin.GPIO0].WithInvertedState());
_actuatorFactory.RegisterLamp(area, Kitchen.LightCeilingWindow, hsrel5[HSREL5Pin.GPIO1].WithInvertedState());
_actuatorFactory.RegisterLamp(area, Kitchen.LightCeilingWall, hsrel5[HSREL5Pin.GPIO2].WithInvertedState());
_actuatorFactory.RegisterLamp(area, Kitchen.LightCeilingDoor, hspe8[HSPE8Pin.GPIO0].WithInvertedState());
_actuatorFactory.RegisterLamp(area, Kitchen.LightCeilingPassageInner, hspe8[HSPE8Pin.GPIO1].WithInvertedState());
_actuatorFactory.RegisterLamp(area, Kitchen.LightCeilingPassageOuter, hspe8[HSPE8Pin.GPIO2].WithInvertedState());
_actuatorFactory.RegisterLamp(area, Kitchen.LightKitchenette, _outpostDeviceService.GetRgbAdapter("RGBSK1"));

_actuatorFactory.RegisterSocket(area, Kitchen.SocketKitchenette, hsrel5[HSREL5Pin.Relay1]); // 0?
_actuatorFactory.RegisterSocket(area, Kitchen.SocketWall, hsrel5[HSREL5Pin.Relay2]);
_actuatorFactory.RegisterSocket(area, Kitchen.SocketCeiling1, hspe8[HSPE8Pin.GPIO3].WithInvertedState());
_actuatorFactory.RegisterSocket(area, Kitchen.SocketCeiling2, hspe8[HSPE8Pin.GPIO4].WithInvertedState());

_systemEventsService.StartupCompleted += (s, e) =>
{
area.GetComponent(Kitchen.SocketCeiling1).TryTurnOn();
};

_actuatorFactory.RegisterLamp(area, Kitchen.LightCeilingPassageOuter, hspe8.GetOutput(2).WithInvertedState());
_actuatorFactory.RegisterLamp(area, Kitchen.LightCeilingMiddle, hsrel5.GetOutput(5).WithInvertedState());
_actuatorFactory.RegisterLamp(area, Kitchen.LightCeilingWindow, hsrel5.GetOutput(6).WithInvertedState());
_actuatorFactory.RegisterLamp(area, Kitchen.LightCeilingWall, hsrel5.GetOutput(7).WithInvertedState());
_actuatorFactory.RegisterLamp(area, Kitchen.LightCeilingDoor, hspe8.GetOutput(0).WithInvertedState());
_actuatorFactory.RegisterLamp(area, Kitchen.LightCeilingPassageInner, hspe8.GetOutput(1).WithInvertedState());
_actuatorFactory.RegisterLamp(area, Kitchen.LightKitchenette, rgb);
_actuatorFactory.RegisterRollerShutter(area, Kitchen.RollerShutter, hsrel5[HSREL5Pin.Relay4], hsrel5[HSREL5Pin.Relay3]);

_actuatorFactory.RegisterSocket(area, Kitchen.SocketWall, hsrel5.GetOutput(2));
_actuatorFactory.RegisterRollerShutter(area, Kitchen.RollerShutter, hsrel5.GetOutput(4), hsrel5.GetOutput(3));
_sensorFactory.RegisterButton(area, Kitchen.ButtonKitchenette, input1.GetInput(11));
_sensorFactory.RegisterButton(area, Kitchen.ButtonPassage, input1.GetInput(9));
_sensorFactory.RegisterRollerShutterButtons(area, Kitchen.RollerShutterButtonUp, input2.GetInput(15),
Expand All @@ -128,7 +142,12 @@ public void Apply()
area.GetRollerShutter(Kitchen.RollerShutter).ConnectWith(
area.GetButton(Kitchen.RollerShutterButtonUp), area.GetButton(Kitchen.RollerShutterButtonDown));

area.GetButton(Kitchen.RollerShutterButtonUp).PressedLongTrigger.Attach(() => area.GetComponent(Kitchen.LightKitchenette).TryTogglePowerState());
area.GetButton(Kitchen.RollerShutterButtonUp).PressedLongTrigger.Attach(() =>
{
var light = area.GetComponent(Kitchen.LightKitchenette);
light.TryTogglePowerState();
light.TrySetColor(0D, 0D, 1D);
});

_actuatorFactory.RegisterLogicalComponent(area, Kitchen.CombinedAutomaticLights)
.WithComponent(area.GetLamp(Kitchen.LightCeilingWall))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ public void Apply()

var area = _areaService.RegisterArea(Room.UpperBathroom);

area.RegisterComponent(new Fan($"{area.Id}.{UpperBathroom.Fan}", new UpperBathroomFanAdapter(hsrel5)));

_sensorFactory.RegisterTemperatureSensor(area, UpperBathroom.TemperatureSensor,
i2CHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin));

Expand All @@ -87,6 +85,8 @@ public void Apply()

_sensorFactory.RegisterMotionDetector(area, UpperBathroom.MotionDetector, input5.GetInput(15));

_actuatorFactory.RegisterFan(area, UpperBathroom.Fan, new UpperBathroomFanAdapter(hsrel5));

_actuatorFactory.RegisterLamp(area, UpperBathroom.LightCeilingDoor, hsrel5.GetOutput(0));
_actuatorFactory.RegisterLamp(area, UpperBathroom.LightCeilingEdge, hsrel5.GetOutput(1));
_actuatorFactory.RegisterLamp(area, UpperBathroom.LightCeilingMirrorCabinet, hsrel5.GetOutput(2));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ public class UIMotionDetectorAdapter : IMotionDetectorAdapter

public UIMotionDetectorAdapter(CheckBox checkBox)
{
if (checkBox == null) throw new ArgumentNullException(nameof(checkBox));

_checkBox = checkBox;
_checkBox = checkBox ?? throw new ArgumentNullException(nameof(checkBox));
}

public event EventHandler MotionDetectionBegin;
public event EventHandler MotionDetectionEnd;

public void Refresh()
{
}

public void Connect()
{
_checkBox.Checked += (s, e) => OnMotionDetectionBegin();
Expand Down
2 changes: 0 additions & 2 deletions Core/HA4IoT.Contracts/Actuators/IFan.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using HA4IoT.Contracts.Components;
using HA4IoT.Contracts.Core;

namespace HA4IoT.Contracts.Actuators
{
public interface IFan : IComponent
{
IAction SetNextLevelAction { get; }
}
}
2 changes: 2 additions & 0 deletions Core/HA4IoT.Contracts/Adapters/IMotionDetectorAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ public interface IMotionDetectorAdapter
event EventHandler MotionDetectionBegin;

event EventHandler MotionDetectionEnd;

void Refresh();
}
}
2 changes: 1 addition & 1 deletion Core/HA4IoT.Contracts/Areas/IArea.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public interface IArea

IList<TComponent> GetComponents<TComponent>() where TComponent : IComponent;

void AddAutomation(IAutomation automation);
void RegisterAutomation(IAutomation automation);

IList<IAutomation> GetAutomations();
}
Expand Down
8 changes: 1 addition & 7 deletions Core/HA4IoT.Contracts/Components/Features/ButtonFeature.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
using Newtonsoft.Json.Linq;

namespace HA4IoT.Contracts.Components.Features
namespace HA4IoT.Contracts.Components.Features
{
public class ButtonFeature : IComponentFeature
{
public JToken Serialize()
{
return JObject.FromObject(this);
}
}
}
8 changes: 1 addition & 7 deletions Core/HA4IoT.Contracts/Components/Features/ColorFeature.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
using Newtonsoft.Json.Linq;

namespace HA4IoT.Contracts.Components.Features
namespace HA4IoT.Contracts.Components.Features
{
public class ColorFeature : IComponentFeature
{
public JToken Serialize()
{
return JObject.FromObject(this);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
using Newtonsoft.Json.Linq;

namespace HA4IoT.Contracts.Components.Features
namespace HA4IoT.Contracts.Components.Features
{
public class HumidityMeasurementFeature : IComponentFeature
{
public JToken Serialize()
{
return JToken.FromObject(this);
}
}
}
9 changes: 9 additions & 0 deletions Core/HA4IoT.Contracts/Components/Features/LevelFeature.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace HA4IoT.Contracts.Components.Features
{
public class LevelFeature : IComponentFeature
{
public int MaxLevel { get; set; }

public int DefaultActiveLevel { get; set; }
}
}
14 changes: 0 additions & 14 deletions Core/HA4IoT.Contracts/Components/Features/LevelStateFeature.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
using Newtonsoft.Json.Linq;

namespace HA4IoT.Contracts.Components.Features
namespace HA4IoT.Contracts.Components.Features
{
public class MotionDetectionFeature : IComponentFeature
{
public JToken Serialize()
{
return JObject.FromObject(this);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
using Newtonsoft.Json.Linq;

namespace HA4IoT.Contracts.Components.Features
namespace HA4IoT.Contracts.Components.Features
{
public class PositionTrackingFeature : IComponentFeature
{
public int MaxPosition { get; set; }

public JToken Serialize()
{
return JObject.FromObject(this);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
using Newtonsoft.Json.Linq;

namespace HA4IoT.Contracts.Components.Features
namespace HA4IoT.Contracts.Components.Features
{
public class PowerStateFeature : IComponentFeature
{
public JToken Serialize()
{
return JObject.FromObject(this);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
using System.Collections.Generic;
using Newtonsoft.Json.Linq;

namespace HA4IoT.Contracts.Components.Features
{
public class StateMachineFeature : IComponentFeature
{
public HashSet<string> SupportedStates { get; } = new HashSet<string>();

public JToken Serialize()
{
return JObject.FromObject(this);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
using Newtonsoft.Json.Linq;

namespace HA4IoT.Contracts.Components.Features
namespace HA4IoT.Contracts.Components.Features
{
public class TemperatureMeasurementFeature : IComponentFeature
{
public JToken Serialize()
{
return JObject.FromObject(this);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
using Newtonsoft.Json.Linq;

namespace HA4IoT.Contracts.Components.Features
namespace HA4IoT.Contracts.Components.Features
{
public class VerticalMovingFeature : IComponentFeature
{
public JToken Serialize()
{
return JObject.FromObject(this);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
using Newtonsoft.Json.Linq;

namespace HA4IoT.Contracts.Components.Features
namespace HA4IoT.Contracts.Components.Features
{
public class WindowStateFeature : IComponentFeature
{
public JToken Serialize()
{
return JObject.FromObject(this);
}
}
}
5 changes: 1 addition & 4 deletions Core/HA4IoT.Contracts/Components/IComponentFeature.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using Newtonsoft.Json.Linq;

namespace HA4IoT.Contracts.Components
namespace HA4IoT.Contracts.Components
{
public interface IComponentFeature
{
JToken Serialize();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ public interface IComponentFeatureCollection
{
TComponentFeature Extract<TComponentFeature>() where TComponentFeature : IComponentFeature;
bool Has(IComponentFeature state);
Dictionary<string, JToken> Serialize();
bool Supports<TComponentFeature>() where TComponentFeature : IComponentFeature;
IComponentFeatureCollection With(IComponentFeature feature);

Dictionary<string, JToken> Serialize();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ public interface IComponentFeatureStateCollection
{
TComponentFeatureState Extract<TComponentFeatureState>() where TComponentFeatureState : IComponentFeatureState;
bool Has(IComponentFeatureState state);
Dictionary<string, JToken> Serialize();
bool Supports<TComponentFeatureState>() where TComponentFeatureState : IComponentFeatureState;
IComponentFeatureStateCollection With(IComponentFeatureState state);

Dictionary<string, JToken> Serialize();
}
}
Loading

0 comments on commit 4dff331

Please sign in to comment.