mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-15 12:44:58 +00:00
feat: updates to room combiner interfaces
This commit is contained in:
@@ -17,7 +17,33 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
private List<IEssentialsRoom> _rooms;
|
private List<IEssentialsRoom> _rooms;
|
||||||
|
|
||||||
private bool isInAutoMode;
|
public List<IKeyName> Rooms
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _rooms.Cast<IKeyName>().ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool _isInAutoMode;
|
||||||
|
|
||||||
|
public bool IsInAutoMode
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _isInAutoMode;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if(value == _isInAutoMode)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_isInAutoMode = value;
|
||||||
|
IsInAutoModeFeedback.FireUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private CTimer _scenarioChangeDebounceTimer;
|
private CTimer _scenarioChangeDebounceTimer;
|
||||||
|
|
||||||
@@ -36,14 +62,14 @@ namespace PepperDash.Essentials.Core
|
|||||||
_scenarioChangeDebounceTimeSeconds = _propertiesConfig.ScenarioChangeDebounceTimeSeconds;
|
_scenarioChangeDebounceTimeSeconds = _propertiesConfig.ScenarioChangeDebounceTimeSeconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
IsInAutoModeFeedback = new BoolFeedback(() => isInAutoMode);
|
IsInAutoModeFeedback = new BoolFeedback(() => _isInAutoMode);
|
||||||
|
|
||||||
// default to auto mode
|
// default to auto mode
|
||||||
isInAutoMode = true;
|
IsInAutoMode = true;
|
||||||
|
|
||||||
if (_propertiesConfig.defaultToManualMode)
|
if (_propertiesConfig.defaultToManualMode)
|
||||||
{
|
{
|
||||||
isInAutoMode = false;
|
IsInAutoMode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
IsInAutoModeFeedback.FireUpdate();
|
IsInAutoModeFeedback.FireUpdate();
|
||||||
@@ -56,7 +82,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
SetRooms();
|
SetRooms();
|
||||||
|
|
||||||
if (isInAutoMode)
|
if (IsInAutoMode)
|
||||||
{
|
{
|
||||||
DetermineRoomCombinationScenario();
|
DetermineRoomCombinationScenario();
|
||||||
}
|
}
|
||||||
@@ -201,20 +227,17 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
public void SetAutoMode()
|
public void SetAutoMode()
|
||||||
{
|
{
|
||||||
isInAutoMode = true;
|
IsInAutoMode = true;
|
||||||
IsInAutoModeFeedback.FireUpdate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetManualMode()
|
public void SetManualMode()
|
||||||
{
|
{
|
||||||
isInAutoMode = false;
|
IsInAutoMode = false;
|
||||||
IsInAutoModeFeedback.FireUpdate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ToggleMode()
|
public void ToggleMode()
|
||||||
{
|
{
|
||||||
isInAutoMode = !isInAutoMode;
|
IsInAutoMode = !IsInAutoMode;
|
||||||
IsInAutoModeFeedback.FireUpdate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<IRoomCombinationScenario> RoomCombinationScenarios { get; private set; }
|
public List<IRoomCombinationScenario> RoomCombinationScenarios { get; private set; }
|
||||||
@@ -233,7 +256,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
public void SetRoomCombinationScenario(string scenarioKey)
|
public void SetRoomCombinationScenario(string scenarioKey)
|
||||||
{
|
{
|
||||||
if (isInAutoMode)
|
if (IsInAutoMode)
|
||||||
{
|
{
|
||||||
Debug.LogMessage(LogEventLevel.Information, this, "Cannot set room combination scenario when in auto mode. Set to auto mode first.");
|
Debug.LogMessage(LogEventLevel.Information, this, "Cannot set room combination scenario when in auto mode. Set to auto mode first.");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using Newtonsoft.Json;
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
@@ -21,13 +18,20 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The current room combination scenario
|
/// The current room combination scenario
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[JsonProperty("currentScenario")]
|
||||||
IRoomCombinationScenario CurrentScenario { get; }
|
IRoomCombinationScenario CurrentScenario { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// When true, indicates the current mode is auto mode
|
/// When true, indicates the current mode is auto mode
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[JsonIgnore]
|
||||||
BoolFeedback IsInAutoModeFeedback {get;}
|
BoolFeedback IsInAutoModeFeedback {get;}
|
||||||
|
|
||||||
|
[JsonProperty("isInAutoMode")]
|
||||||
|
bool IsInAutoMode { get; }
|
||||||
|
|
||||||
|
List<IKeyName> Rooms { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets auto mode
|
/// Sets auto mode
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -46,11 +50,13 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The available room combinatino scenarios
|
/// The available room combinatino scenarios
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[JsonProperty("roomCombinationScenarios")]
|
||||||
List<IRoomCombinationScenario> RoomCombinationScenarios { get; }
|
List<IRoomCombinationScenario> RoomCombinationScenarios { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The partition
|
/// The partition
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[JsonProperty("partitions")]
|
||||||
List<IPartitionController> Partitions { get; }
|
List<IPartitionController> Partitions { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -73,6 +79,9 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
BoolFeedback IsActiveFeedback { get; }
|
BoolFeedback IsActiveFeedback { get; }
|
||||||
|
|
||||||
|
[JsonProperty("isActive")]
|
||||||
|
bool IsActive { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Activates this room combination scenario
|
/// Activates this room combination scenario
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -86,6 +95,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The state of the partitions that would activate this scenario
|
/// The state of the partitions that would activate this scenario
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[JsonProperty("partitionStates")]
|
||||||
List<PartitionState> PartitionStates { get; }
|
List<PartitionState> PartitionStates { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -16,20 +16,41 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a room combination scenario
|
/// Represents a room combination scenario
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class RoomCombinationScenario: IRoomCombinationScenario
|
public class RoomCombinationScenario: IRoomCombinationScenario, IKeyName
|
||||||
{
|
{
|
||||||
private RoomCombinationScenarioConfig _config;
|
private RoomCombinationScenarioConfig _config;
|
||||||
|
|
||||||
|
[JsonProperty("key")]
|
||||||
public string Key { get; set; }
|
public string Key { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("name")]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("partitionStates")]
|
||||||
public List<PartitionState> PartitionStates { get; private set; }
|
public List<PartitionState> PartitionStates { get; private set; }
|
||||||
|
|
||||||
|
[JsonProperty("uiMap")]
|
||||||
public Dictionary<string, string> UiMap { get; set; }
|
public Dictionary<string, string> UiMap { get; set; }
|
||||||
|
|
||||||
private bool _isActive;
|
private bool _isActive;
|
||||||
|
|
||||||
|
[JsonProperty("isActive")]
|
||||||
|
public bool IsActive
|
||||||
|
{
|
||||||
|
get { return _isActive; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if(value == _isActive)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_isActive = value;
|
||||||
|
IsActiveFeedback.FireUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public BoolFeedback IsActiveFeedback { get; private set; }
|
public BoolFeedback IsActiveFeedback { get; private set; }
|
||||||
|
|
||||||
private List<DeviceActionWrapper> activationActions;
|
private List<DeviceActionWrapper> activationActions;
|
||||||
@@ -67,8 +88,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_isActive = true;
|
IsActive = true;
|
||||||
IsActiveFeedback.FireUpdate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Deactivate()
|
public void Deactivate()
|
||||||
@@ -83,8 +103,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_isActive = false;
|
IsActive = false;
|
||||||
IsActiveFeedback.FireUpdate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user