diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/EssentialsPartitionController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/EssentialsPartitionController.cs
new file mode 100644
index 00000000..7066be0e
--- /dev/null
+++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/EssentialsPartitionController.cs
@@ -0,0 +1,149 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Crestron.SimplSharp;
+
+namespace PepperDash.Essentials.Core
+{
+ ///
+ /// Represents an abstract controller device for a partition dividing rooms that are combinable
+ ///
+ /// In Auto mode, it can use a partition sensor to automatically determine whether the partition is present.
+ ///
+ /// In Manual mode it accepts user input to tell it whether the partition is present.
+ ///
+ public class EssentialsPartitionController : IPartitionController
+ {
+ private IPartitionStateProvider _partitionSensor;
+
+ private bool isInAutoMode;
+
+ private bool partitionPresent;
+
+ public EssentialsPartitionController(string key, string name, IPartitionStateProvider sensor, bool defaultToManualMode, List adjacentRoomKeys)
+ {
+ Key = key;
+
+ Name = name;
+
+ AdjacentRoomKeys = adjacentRoomKeys;
+
+ if (sensor != null)
+ {
+ _partitionSensor = sensor;
+
+ if (!defaultToManualMode)
+ {
+ SetAutoMode();
+ }
+ else
+ {
+ SetManualMode();
+ }
+ }
+ else
+ {
+ SetManualMode();
+ }
+
+ PartitionPresentFeedback.FireUpdate();
+ }
+
+ void PartitionPresentFeedback_OutputChange(object sender, FeedbackEventArgs e)
+ {
+ if (isInAutoMode)
+ {
+ PartitionPresentFeedback.FireUpdate();
+ }
+ }
+
+ #region IPartitionController Members
+
+ public List AdjacentRoomKeys { get; private set; }
+
+ public void SetAutoMode()
+ {
+ isInAutoMode = true;
+ if (PartitionPresentFeedback != null)
+ {
+ PartitionPresentFeedback.SetValueFunc(() => _partitionSensor.PartitionPresentFeedback.BoolValue);
+ }
+ else
+ {
+ PartitionPresentFeedback = new BoolFeedback(() => _partitionSensor.PartitionPresentFeedback.BoolValue);
+ }
+
+ if (_partitionSensor != null)
+ {
+ _partitionSensor.PartitionPresentFeedback.OutputChange += PartitionPresentFeedback_OutputChange;
+ }
+ }
+
+ public void SetManualMode()
+ {
+ isInAutoMode = false;
+ if (PartitionPresentFeedback != null)
+ {
+ PartitionPresentFeedback.SetValueFunc(() => partitionPresent);
+ }
+ else
+ {
+ PartitionPresentFeedback = new BoolFeedback(() => partitionPresent);
+ }
+
+ if (_partitionSensor != null)
+ {
+ _partitionSensor.PartitionPresentFeedback.OutputChange -= PartitionPresentFeedback_OutputChange;
+ }
+ }
+
+
+ public void SetPartitionStatePresent()
+ {
+ if (!isInAutoMode)
+ {
+ partitionPresent = true;
+ PartitionPresentFeedback.FireUpdate();
+ }
+ }
+
+ public void SetPartitionStateNotPresent()
+ {
+ if (!isInAutoMode)
+ {
+ partitionPresent = false;
+ PartitionPresentFeedback.FireUpdate();
+ }
+ }
+
+ public void ToggglePartitionState()
+ {
+ if (!isInAutoMode)
+ {
+ partitionPresent = !partitionPresent;
+ PartitionPresentFeedback.FireUpdate();
+ }
+ }
+
+ #endregion
+
+ #region IPartitionStateProvider Members
+
+ public BoolFeedback PartitionPresentFeedback { get; private set; }
+
+ #endregion
+
+ #region IKeyName Members
+
+ public string Name { get; private set; }
+
+ #endregion
+
+ #region IKeyed Members
+
+ public string Key { get; private set; }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorController.cs
index 768e476b..752a7107 100644
--- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorController.cs
+++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorController.cs
@@ -19,7 +19,7 @@ namespace PepperDash.Essentials.Core
public StringFeedback NameFeedback { get; private set; }
public BoolFeedback EnableFeedback { get; private set; }
- public BoolFeedback PartitionSensedFeedback { get; private set; }
+ public BoolFeedback PartitionPresentFeedback { get; private set; }
public BoolFeedback PartitionNotSensedFeedback { get; private set; }
public IntFeedback SensitivityFeedback { get; private set; }
@@ -40,7 +40,7 @@ namespace PepperDash.Essentials.Core
NameFeedback = new StringFeedback(() => Name);
EnableFeedback = new BoolFeedback(() => _partitionSensor.EnableFeedback.BoolValue);
- PartitionSensedFeedback = new BoolFeedback(() => _partitionSensor.PartitionSensedFeedback.BoolValue);
+ PartitionPresentFeedback = new BoolFeedback(() => _partitionSensor.PartitionSensedFeedback.BoolValue);
PartitionNotSensedFeedback = new BoolFeedback(() => _partitionSensor.PartitionNotSensedFeedback.BoolValue);
SensitivityFeedback = new IntFeedback(() => _partitionSensor.SensitivityFeedback.UShortValue);
@@ -61,7 +61,7 @@ namespace PepperDash.Essentials.Core
}
case (GlsPartCn.PartitionSensedFeedbackEventId):
{
- PartitionSensedFeedback.FireUpdate();
+ PartitionPresentFeedback.FireUpdate();
break;
}
case (GlsPartCn.PartitionNotSensedFeedbackEventId):
@@ -186,7 +186,7 @@ namespace PepperDash.Essentials.Core
// link output to simpl
IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]);
EnableFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Enable.JoinNumber]);
- PartitionSensedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PartitionSensed.JoinNumber]);
+ PartitionPresentFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PartitionSensed.JoinNumber]);
PartitionNotSensedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PartitionNotSensed.JoinNumber]);
SensitivityFeedback.LinkInputSig(trilist.UShortInput[joinMap.Sensitivity.JoinNumber]);
@@ -216,7 +216,7 @@ namespace PepperDash.Essentials.Core
IsOnline.FireUpdate();
NameFeedback.FireUpdate();
EnableFeedback.FireUpdate();
- PartitionSensedFeedback.FireUpdate();
+ PartitionPresentFeedback.FireUpdate();
PartitionNotSensedFeedback.FireUpdate();
SensitivityFeedback.FireUpdate();
}
diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/IPartitionStateProvider.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/IPartitionStateProvider.cs
index 08b8012b..faf84015 100644
--- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/IPartitionStateProvider.cs
+++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/IPartitionStateProvider.cs
@@ -13,15 +13,24 @@ namespace PepperDash.Essentials.Core
///
public interface IPartitionStateProvider : IKeyName
{
- BoolFeedback PartitionSensedFeedback { get; }
+ BoolFeedback PartitionPresentFeedback { get; }
}
- public interface IManualPartitionSensor : IPartitionStateProvider
+ ///
+ /// Describes the functionality of a device that can provide partition state either manually via user input or optionally via a sensor state
+ ///
+ public interface IPartitionController : IPartitionStateProvider
{
+ List AdjacentRoomKeys { get; set; }
+
void SetPartitionStatePresent();
void SetPartitionStateNotPresent();
void ToggglePartitionState();
+
+ void SetManualMode();
+
+ void SetAutoMode();
}
}
\ No newline at end of file
diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj
index 38a532ba..53779a0d 100644
--- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj
+++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj
@@ -233,6 +233,7 @@
+
diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Combining/EssentialsRoomCombiner.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Combining/EssentialsRoomCombiner.cs
index 6e9a0afb..bb3040ff 100644
--- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Combining/EssentialsRoomCombiner.cs
+++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Combining/EssentialsRoomCombiner.cs
@@ -42,14 +42,19 @@ namespace PepperDash.Essentials.Core
void CreateScenarios()
{
+ RoomCombinationScenarios = new List();
+
foreach (var scenarioConfig in _propertiesConfig.Scenarios)
{
var scenario = new RoomCombinationScenario(scenarioConfig);
+ RoomCombinationScenarios.Add(scenario);
}
}
void SetRooms()
{
+ _rooms = new List();
+
foreach (var roomKey in _propertiesConfig.RoomKeys)
{
var room = DeviceManager.GetDeviceForKey(roomKey) as IEssentialsRoom;
@@ -62,7 +67,36 @@ namespace PepperDash.Essentials.Core
void SetupPartitionStateProviders()
{
+ foreach (var pConfig in _propertiesConfig.Partitions)
+ {
+ var sensor = DeviceManager.GetDeviceForKey(pConfig.DeviceKey) as IPartitionStateProvider;
+ var partition = new EssentialsPartitionController(pConfig.Key, pConfig.Name, sensor, _propertiesConfig.defaultToManualMode, pConfig.AdjacentRoomKeys);
+
+ partition.PartitionPresentFeedback.OutputChange += PartitionPresentFeedback_OutputChange;
+
+ Partitions.Add(partition);
+ }
+ }
+
+ void PartitionPresentFeedback_OutputChange(object sender, FeedbackEventArgs e)
+ {
+ DetermineRoomCombinationScenario();
+ }
+
+
+ ///
+ /// Determines the current room combination scenario based on the state of the partition sensors
+ ///
+ void DetermineRoomCombinationScenario()
+ {
+ //RoomCombinationScenarios.FirstOrDefault((s) =>
+ //{
+ // foreach (var partitionState in s.PartitionStates)
+ // {
+ // var partition = Partitions.FirstOrDefault(
+ // }
+ //});
}
#region IEssentialsRoomCombiner Members
@@ -111,11 +145,11 @@ namespace PepperDash.Essentials.Core
public List RoomCombinationScenarios { get; private set; }
- public List PartitionStateProviders { get; private set; }
+ public List Partitions { get; private set; }
public void TogglePartitionState(string partitionKey)
{
- var partition = PartitionStateProviders.FirstOrDefault((p) => p.Key.Equals(partitionKey)) as IManualPartitionSensor;
+ var partition = Partitions.FirstOrDefault((p) => p.Key.Equals(partitionKey)) as IPartitionController;
if (partition != null)
{
diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Combining/EssentialsRoomCombinerPropertiesConfig.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Combining/EssentialsRoomCombinerPropertiesConfig.cs
index 95b97c35..7fa215d5 100644
--- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Combining/EssentialsRoomCombinerPropertiesConfig.cs
+++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Combining/EssentialsRoomCombinerPropertiesConfig.cs
@@ -84,8 +84,8 @@ namespace PepperDash.Essentials.Core
[JsonProperty("partitionStates")]
public List PartitionStates { get; set; }
- [JsonProperty("roomMap")]
- public Dictionary RoomMap { get; set; }
+ [JsonProperty("uiMap")]
+ public Dictionary UiMap { get; set; }
[JsonProperty("activationActions")]
public List ActivationActions { 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 142e066c..c5fa0c50 100644
--- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Combining/IEssentialsRoomCombiner.cs
+++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Combining/IEssentialsRoomCombiner.cs
@@ -11,7 +11,7 @@ namespace PepperDash.Essentials.Core
///
/// Describes the functionality for an EssentailsRoomCombiner device
///
- public interface IEssentialsRoomCombiner
+ public interface IEssentialsRoomCombiner : IKeyed
{
///
/// Indicates that the room combination scenario has changed
@@ -51,7 +51,7 @@ namespace PepperDash.Essentials.Core
///
/// The partition
///
- List PartitionStateProviders { get; }
+ List Partitions { get; }
///
/// Toggles the state of a manual partition sensor
@@ -77,6 +77,16 @@ namespace PepperDash.Essentials.Core
/// Activates this room combination scenario
///
void Activate();
+
+ ///
+ /// The state of the partitions that would activate this scenario
+ ///
+ List PartitionStates { get; }
+
+ ///
+ /// The mapping of UIs by key to rooms by key
+ ///
+ Dictionary UiMap { get; set; }
}
}
\ No newline at end of file
diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Combining/RoomCombinationScenario.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Combining/RoomCombinationScenario.cs
index c1d75c3e..a5534edc 100644
--- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Combining/RoomCombinationScenario.cs
+++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Combining/RoomCombinationScenario.cs
@@ -21,7 +21,7 @@ namespace PepperDash.Essentials.Core
public List PartitionStates { get; private set; }
- public Dictionary EnabledRoomMap { get; set; }
+ public Dictionary UiMap { get; set; }
private bool _isActive;
@@ -39,7 +39,7 @@ namespace PepperDash.Essentials.Core
PartitionStates = config.PartitionStates;
- EnabledRoomMap = config.RoomMap;
+ UiMap = config.UiMap;
activationActions = config.ActivationActions;