feat: updates to Room combiner for use with mobile control

This commit is contained in:
Neil Dorin
2024-05-02 17:27:34 -06:00
parent 65369606a4
commit 2b6f79b68f
4 changed files with 39 additions and 13 deletions

View File

@@ -19,7 +19,29 @@ namespace PepperDash.Essentials.Core
private bool isInAutoMode;
private bool partitionPresent;
private bool _partitionPresent;
public bool PartitionPresent
{
get
{
return _partitionPresent;
}
set
{
if (_partitionPresent == value)
{
return;
}
_partitionPresent = value;
if (PartitionPresentFeedback != null)
{
PartitionPresentFeedback.FireUpdate();
}
}
}
public EssentialsPartitionController(string key, string name, IPartitionStateProvider sensor, bool defaultToManualMode, List<string> adjacentRoomKeys)
{
@@ -85,11 +107,11 @@ namespace PepperDash.Essentials.Core
isInAutoMode = false;
if (PartitionPresentFeedback != null)
{
PartitionPresentFeedback.SetValueFunc(() => partitionPresent);
PartitionPresentFeedback.SetValueFunc(() => _partitionPresent);
}
else
{
PartitionPresentFeedback = new BoolFeedback(() => partitionPresent);
PartitionPresentFeedback = new BoolFeedback(() => _partitionPresent);
}
if (_partitionSensor != null)
@@ -103,7 +125,7 @@ namespace PepperDash.Essentials.Core
{
if (!isInAutoMode)
{
partitionPresent = true;
PartitionPresent = true;
PartitionPresentFeedback.FireUpdate();
}
}
@@ -112,7 +134,7 @@ namespace PepperDash.Essentials.Core
{
if (!isInAutoMode)
{
partitionPresent = false;
PartitionPresent = false;
PartitionPresentFeedback.FireUpdate();
}
}
@@ -121,7 +143,7 @@ namespace PepperDash.Essentials.Core
{
if (!isInAutoMode)
{
partitionPresent = !partitionPresent;
PartitionPresent = !PartitionPresent;
PartitionPresentFeedback.FireUpdate();
}
}

View File

@@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using System.Collections.Generic;
using Newtonsoft.Json;
using PepperDash.Core;
namespace PepperDash.Essentials.Core
@@ -13,7 +9,11 @@ namespace PepperDash.Essentials.Core
/// </summary>
public interface IPartitionStateProvider : IKeyName
{
[JsonIgnore]
BoolFeedback PartitionPresentFeedback { get; }
[JsonProperty("partitionPresent")]
bool PartitionPresent { get; }
}
/// <summary>
@@ -21,6 +21,7 @@ namespace PepperDash.Essentials.Core
/// </summary>
public interface IPartitionController : IPartitionStateProvider
{
[JsonProperty("adjacentRoomKeys")]
List<string> AdjacentRoomKeys { get; }
void SetPartitionStatePresent();

View File

@@ -1,11 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
using Serilog.Events;
using Newtonsoft.Json;
namespace PepperDash.Essentials.Core
{

View File

@@ -30,6 +30,7 @@ namespace PepperDash.Essentials.Core
[JsonProperty("isInAutoMode")]
bool IsInAutoMode { get; }
[JsonProperty("rooms")]
List<IKeyName> Rooms { get; }
/// <summary>
@@ -77,6 +78,7 @@ namespace PepperDash.Essentials.Core
/// <summary>
/// When true, indicates that this room combination scenario is active
/// </summary>
[JsonIgnore]
BoolFeedback IsActiveFeedback { get; }
[JsonProperty("isActive")]
@@ -101,6 +103,7 @@ namespace PepperDash.Essentials.Core
/// <summary>
/// The mapping of UIs by key to rooms by key
/// </summary>
[JsonProperty("uiMap")]
Dictionary<string, string> UiMap { get; set; }
}