diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj
index b65cfd62..38a532ba 100644
--- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj
+++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj
@@ -288,6 +288,7 @@
+
diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Combining/EssentialsRoomCombiner.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Combining/EssentialsRoomCombiner.cs
new file mode 100644
index 00000000..6e9a0afb
--- /dev/null
+++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Combining/EssentialsRoomCombiner.cs
@@ -0,0 +1,133 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Crestron.SimplSharp;
+
+namespace PepperDash.Essentials.Core
+{
+ public class EssentialsRoomCombiner : EssentialsDevice, IEssentialsRoomCombiner
+ {
+ private EssentialsRoomCombinerPropertiesConfig _propertiesConfig;
+
+ private IRoomCombinationScenario _currentScenario;
+
+ private List _rooms;
+
+ private bool isInAutoMode;
+
+ public EssentialsRoomCombiner(string key, EssentialsRoomCombinerPropertiesConfig props)
+ : base(key)
+ {
+ _propertiesConfig = props;
+
+ IsInAutoModeFeedback = new BoolFeedback(() => isInAutoMode);
+
+ // default to auto mode
+ isInAutoMode = true;
+
+ if (_propertiesConfig.defaultToManualMode)
+ {
+ isInAutoMode = false;
+ }
+
+ IsInAutoModeFeedback.FireUpdate();
+
+ CreateScenarios();
+
+ SetupPartitionStateProviders();
+
+ SetRooms();
+ }
+
+ void CreateScenarios()
+ {
+ foreach (var scenarioConfig in _propertiesConfig.Scenarios)
+ {
+ var scenario = new RoomCombinationScenario(scenarioConfig);
+ }
+ }
+
+ void SetRooms()
+ {
+ foreach (var roomKey in _propertiesConfig.RoomKeys)
+ {
+ var room = DeviceManager.GetDeviceForKey(roomKey) as IEssentialsRoom;
+ if (room != null)
+ {
+ _rooms.Add(room);
+ }
+ }
+ }
+
+ void SetupPartitionStateProviders()
+ {
+
+ }
+
+ #region IEssentialsRoomCombiner Members
+
+ public event EventHandler RoomCombinationScenarioChanged;
+
+ public IRoomCombinationScenario CurrentScenario
+ {
+ get
+ {
+ return _currentScenario;
+ }
+ set
+ {
+ if (value != _currentScenario)
+ {
+ _currentScenario = value;
+ var handler = RoomCombinationScenarioChanged;
+ if (handler != null)
+ {
+ handler(this, new EventArgs());
+ }
+ }
+ }
+ }
+
+ public BoolFeedback IsInAutoModeFeedback { get; private set; }
+
+ public void SetAutoMode()
+ {
+ isInAutoMode = true;
+ IsInAutoModeFeedback.FireUpdate();
+ }
+
+ public void SetManualMode()
+ {
+ isInAutoMode = false;
+ IsInAutoModeFeedback.FireUpdate();
+ }
+
+ public void ToggleMode()
+ {
+ isInAutoMode = !isInAutoMode;
+ IsInAutoModeFeedback.FireUpdate();
+ }
+
+ public List RoomCombinationScenarios { get; private set; }
+
+ public List PartitionStateProviders { get; private set; }
+
+ public void TogglePartitionState(string partitionKey)
+ {
+ var partition = PartitionStateProviders.FirstOrDefault((p) => p.Key.Equals(partitionKey)) as IManualPartitionSensor;
+
+ if (partition != null)
+ {
+ partition.ToggglePartitionState();
+ }
+ }
+
+ public void SetRoomCombinationScenario(string scenarioKey)
+ {
+
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Combining/EssentialsRoomCombinerPropertiesConfig.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Combining/EssentialsRoomCombinerPropertiesConfig.cs
index 4576ac4d..95b97c35 100644
--- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Combining/EssentialsRoomCombinerPropertiesConfig.cs
+++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Combining/EssentialsRoomCombinerPropertiesConfig.cs
@@ -28,10 +28,22 @@ namespace PepperDash.Essentials.Core
public List Scenarios { get; set; }
///
- /// The list of rooms that can be combined
+ /// The list of rooms keys that can be combined
///
[JsonProperty("roomMap")]
- public Dictionary RoomMap {get; set;}
+ public List RoomKeys {get; set;}
+
+ ///
+ /// Set to true to default to manual mode
+ ///
+ [JsonProperty("defaultToManualMode")]
+ public bool defaultToManualMode { get; set; }
+
+ ///
+ /// The key of the scenario to default to at system startup if in manual mode
+ ///
+ [JsonProperty("defaultScenarioKey")]
+ public string defaultScenarioKey { get; set; }
}
///
@@ -54,8 +66,8 @@ namespace PepperDash.Essentials.Core
///
/// Keys of the rooms that this partion would be located between
///
- [JsonProperty("roomKeys")]
- public List RoomKeys { get; set; }
+ [JsonProperty("adjacentRoomKeys")]
+ public List AdjacentRoomKeys { get; set; }
}
///
@@ -72,11 +84,14 @@ namespace PepperDash.Essentials.Core
[JsonProperty("partitionStates")]
public List PartitionStates { get; set; }
- [JsonProperty("enabledRoomKeys")]
- public List EnabledRoomKeys { get; set; }
+ [JsonProperty("roomMap")]
+ public Dictionary RoomMap { get; set; }
- [JsonProperty("actions")]
- public List Actions { get; set; }
+ [JsonProperty("activationActions")]
+ public List ActivationActions { get; set; }
+
+ [JsonProperty("deactivationActions")]
+ public List DeactivationActions { get; set; }
}
///
diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Combining/IEssentialsRoomCombiner.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Combining/IEssentialsRoomCombiner.cs
index 894dd098..142e066c 100644
--- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Combining/IEssentialsRoomCombiner.cs
+++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Combining/IEssentialsRoomCombiner.cs
@@ -13,28 +13,69 @@ namespace PepperDash.Essentials.Core
///
public interface IEssentialsRoomCombiner
{
- // TODO: Update the EventArgs class as needed to specify scenario change
+ ///
+ /// Indicates that the room combination scenario has changed
+ ///
event EventHandler RoomCombinationScenarioChanged;
+ ///
+ /// The current room combination scenario
+ ///
+ IRoomCombinationScenario CurrentScenario { get; }
+
+ ///
+ /// When true, indicates the current mode is auto mode
+ ///
BoolFeedback IsInAutoModeFeedback {get;}
+ ///
+ /// Sets auto mode
+ ///
void SetAutoMode();
+ ///
+ /// Sets manual mode
+ ///
void SetManualMode();
+ ///
+ /// Toggles the current mode between auto and manual
+ ///
void ToggleMode();
- List Scenarios { get; }
+ ///
+ /// The available room combinatino scenarios
+ ///
+ List RoomCombinationScenarios { get; }
- List Partitions { get; }
+ ///
+ /// The partition
+ ///
+ List PartitionStateProviders { get; }
+ ///
+ /// Toggles the state of a manual partition sensor
+ ///
+ ///
void TogglePartitionState(string partitionKey);
+
+ ///
+ /// Sets the room combination scenario (if in manual mode)
+ ///
+ ///
+ void SetRoomCombinationScenario(string scenarioKey);
}
public interface IRoomCombinationScenario : IKeyName
{
- BoolFeedback IsActive { get; }
+ ///
+ /// When true, indicates that this room combination scenario is active
+ ///
+ BoolFeedback IsActiveFeedback { get; }
+ ///
+ /// Activates this room combination scenario
+ ///
void Activate();
}
diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Combining/RoomCombinationScenario.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Combining/RoomCombinationScenario.cs
index 94e2ed0a..c1d75c3e 100644
--- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Combining/RoomCombinationScenario.cs
+++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Combining/RoomCombinationScenario.cs
@@ -13,17 +13,69 @@ namespace PepperDash.Essentials.Core
///
public class RoomCombinationScenario: IRoomCombinationScenario
{
- [JsonProperty("key")]
+ private RoomCombinationScenarioConfig _config;
+
public string Key { get; set; }
- [JsonProperty("name")]
public string Name { get; set; }
- public BoolFeedback IsActive { get; private set; }
+ public List PartitionStates { get; private set; }
+
+ public Dictionary EnabledRoomMap { get; set; }
+
+ private bool _isActive;
+
+ public BoolFeedback IsActiveFeedback { get; private set; }
+
+ List activationActions;
+
+ List deactivationActions;
+
+ public RoomCombinationScenario(RoomCombinationScenarioConfig config)
+ {
+ Key = config.Key;
+
+ Name = config.Name;
+
+ PartitionStates = config.PartitionStates;
+
+ EnabledRoomMap = config.RoomMap;
+
+ activationActions = config.ActivationActions;
+
+ deactivationActions = config.DeactivationActions;
+
+ _config = config;
+
+ IsActiveFeedback = new BoolFeedback(() => _isActive);
+ }
public void Activate()
{
+ if (activationActions != null)
+ {
+ foreach (var action in activationActions)
+ {
+ DeviceJsonApi.DoDeviceAction(action);
+ }
+ }
+ _isActive = true;
+ IsActiveFeedback.FireUpdate();
+ }
+
+ public void Deactivate()
+ {
+ if (deactivationActions != null)
+ {
+ foreach (var action in deactivationActions)
+ {
+ DeviceJsonApi.DoDeviceAction(action);
+ }
+ }
+
+ _isActive = false;
+ IsActiveFeedback.FireUpdate();
}
}