mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-16 05:05:00 +00:00
fix: various updates for room combining from testing
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
|
using PepperDash.Core;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
@@ -17,7 +18,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
private IPartitionStateProvider _partitionSensor;
|
private IPartitionStateProvider _partitionSensor;
|
||||||
|
|
||||||
private bool isInAutoMode;
|
public bool IsInAutoMode { get; private set; }
|
||||||
|
|
||||||
private bool _partitionPresent;
|
private bool _partitionPresent;
|
||||||
|
|
||||||
@@ -74,7 +75,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
void PartitionPresentFeedback_OutputChange(object sender, FeedbackEventArgs e)
|
void PartitionPresentFeedback_OutputChange(object sender, FeedbackEventArgs e)
|
||||||
{
|
{
|
||||||
if (isInAutoMode)
|
if (IsInAutoMode)
|
||||||
{
|
{
|
||||||
PartitionPresentFeedback.FireUpdate();
|
PartitionPresentFeedback.FireUpdate();
|
||||||
}
|
}
|
||||||
@@ -86,7 +87,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
public void SetAutoMode()
|
public void SetAutoMode()
|
||||||
{
|
{
|
||||||
isInAutoMode = true;
|
IsInAutoMode = true;
|
||||||
if (PartitionPresentFeedback != null)
|
if (PartitionPresentFeedback != null)
|
||||||
{
|
{
|
||||||
PartitionPresentFeedback.SetValueFunc(() => _partitionSensor.PartitionPresentFeedback.BoolValue);
|
PartitionPresentFeedback.SetValueFunc(() => _partitionSensor.PartitionPresentFeedback.BoolValue);
|
||||||
@@ -98,13 +99,14 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
if (_partitionSensor != null)
|
if (_partitionSensor != null)
|
||||||
{
|
{
|
||||||
|
_partitionSensor.PartitionPresentFeedback.OutputChange -= PartitionPresentFeedback_OutputChange;
|
||||||
_partitionSensor.PartitionPresentFeedback.OutputChange += PartitionPresentFeedback_OutputChange;
|
_partitionSensor.PartitionPresentFeedback.OutputChange += PartitionPresentFeedback_OutputChange;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetManualMode()
|
public void SetManualMode()
|
||||||
{
|
{
|
||||||
isInAutoMode = false;
|
IsInAutoMode = false;
|
||||||
if (PartitionPresentFeedback != null)
|
if (PartitionPresentFeedback != null)
|
||||||
{
|
{
|
||||||
PartitionPresentFeedback.SetValueFunc(() => _partitionPresent);
|
PartitionPresentFeedback.SetValueFunc(() => _partitionPresent);
|
||||||
@@ -123,7 +125,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
public void SetPartitionStatePresent()
|
public void SetPartitionStatePresent()
|
||||||
{
|
{
|
||||||
if (!isInAutoMode)
|
if (!IsInAutoMode)
|
||||||
{
|
{
|
||||||
PartitionPresent = true;
|
PartitionPresent = true;
|
||||||
PartitionPresentFeedback.FireUpdate();
|
PartitionPresentFeedback.FireUpdate();
|
||||||
@@ -132,7 +134,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
public void SetPartitionStateNotPresent()
|
public void SetPartitionStateNotPresent()
|
||||||
{
|
{
|
||||||
if (!isInAutoMode)
|
if (!IsInAutoMode)
|
||||||
{
|
{
|
||||||
PartitionPresent = false;
|
PartitionPresent = false;
|
||||||
PartitionPresentFeedback.FireUpdate();
|
PartitionPresentFeedback.FireUpdate();
|
||||||
@@ -141,7 +143,10 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
public void ToggglePartitionState()
|
public void ToggglePartitionState()
|
||||||
{
|
{
|
||||||
if (!isInAutoMode)
|
Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, $"Toggling Partition State for {Key}", this);
|
||||||
|
Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, $"IsInAutoMode: {IsInAutoMode}", this);
|
||||||
|
|
||||||
|
if (!IsInAutoMode)
|
||||||
{
|
{
|
||||||
PartitionPresent = !PartitionPresent;
|
PartitionPresent = !PartitionPresent;
|
||||||
PartitionPresentFeedback.FireUpdate();
|
PartitionPresentFeedback.FireUpdate();
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ namespace PepperDash.Essentials.Core
|
|||||||
[JsonProperty("adjacentRoomKeys")]
|
[JsonProperty("adjacentRoomKeys")]
|
||||||
List<string> AdjacentRoomKeys { get; }
|
List<string> AdjacentRoomKeys { get; }
|
||||||
|
|
||||||
|
[JsonProperty("isInAutoMode")]
|
||||||
|
bool IsInAutoMode { get; }
|
||||||
|
|
||||||
void SetPartitionStatePresent();
|
void SetPartitionStatePresent();
|
||||||
|
|
||||||
void SetPartitionStateNotPresent();
|
void SetPartitionStateNotPresent();
|
||||||
|
|||||||
@@ -137,7 +137,11 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
void StartDebounceTimer()
|
void StartDebounceTimer()
|
||||||
{
|
{
|
||||||
var time = _scenarioChangeDebounceTimeSeconds * 1000;
|
// default to 500ms for manual mode
|
||||||
|
var time = 500;
|
||||||
|
|
||||||
|
// if in auto mode, debounce the scenario change
|
||||||
|
if(IsInAutoMode) time = _scenarioChangeDebounceTimeSeconds * 1000;
|
||||||
|
|
||||||
if (_scenarioChangeDebounceTimer == null)
|
if (_scenarioChangeDebounceTimer == null)
|
||||||
{
|
{
|
||||||
@@ -211,7 +215,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
_currentScenario.Activate();
|
_currentScenario.Activate();
|
||||||
|
|
||||||
Debug.LogMessage(LogEventLevel.Debug, this, "Current Scenario: {0}", _currentScenario.Name);
|
Debug.LogMessage(LogEventLevel.Debug, $"Current Scenario: {_currentScenario.Name}", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
var handler = RoomCombinationScenarioChanged;
|
var handler = RoomCombinationScenarioChanged;
|
||||||
@@ -246,7 +250,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
public void TogglePartitionState(string partitionKey)
|
public void TogglePartitionState(string partitionKey)
|
||||||
{
|
{
|
||||||
var partition = Partitions.FirstOrDefault((p) => p.Key.Equals(partitionKey)) as IPartitionController;
|
var partition = Partitions.FirstOrDefault((p) => p.Key.Equals(partitionKey));
|
||||||
|
|
||||||
if (partition != null)
|
if (partition != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -141,6 +141,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
if (!ShutdownPromptTimer.IsRunningFeedback.BoolValue)
|
if (!ShutdownPromptTimer.IsRunningFeedback.BoolValue)
|
||||||
ShutdownType = eShutdownType.None;
|
ShutdownType = eShutdownType.None;
|
||||||
};
|
};
|
||||||
|
|
||||||
ShutdownPromptTimer.HasFinished += (o, a) => Shutdown(); // Shutdown is triggered
|
ShutdownPromptTimer.HasFinished += (o, a) => Shutdown(); // Shutdown is triggered
|
||||||
|
|
||||||
ShutdownPromptSeconds = 60;
|
ShutdownPromptSeconds = 60;
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
var timeSpan = FinishTime - DateTime.Now;
|
var timeSpan = FinishTime - DateTime.Now;
|
||||||
|
|
||||||
Debug.LogMessage(LogEventLevel.Verbose, this,
|
Debug.LogMessage(LogEventLevel.Verbose,
|
||||||
"timeSpan.Minutes == {0}, timeSpan.Seconds == {1}, timeSpan.TotalSeconds == {2}",
|
"timeSpan.Minutes == {0}, timeSpan.Seconds == {1}, timeSpan.TotalSeconds == {2}", this,
|
||||||
timeSpan.Minutes, timeSpan.Seconds, timeSpan.TotalSeconds);
|
timeSpan.Minutes, timeSpan.Seconds, timeSpan.TotalSeconds);
|
||||||
|
|
||||||
if (Math.Floor(timeSpan.TotalSeconds) < 60 && Math.Floor(timeSpan.TotalSeconds) >= 0) //ignore milliseconds
|
if (Math.Floor(timeSpan.TotalSeconds) < 60 && Math.Floor(timeSpan.TotalSeconds) >= 0) //ignore milliseconds
|
||||||
@@ -103,6 +103,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
public void Reset()
|
public void Reset()
|
||||||
{
|
{
|
||||||
_isRunning = false;
|
_isRunning = false;
|
||||||
|
IsRunningFeedback.FireUpdate();
|
||||||
Start();
|
Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,7 +134,11 @@ namespace PepperDash.Essentials.Core
|
|||||||
void StopHelper()
|
void StopHelper()
|
||||||
{
|
{
|
||||||
if (_secondTimer != null)
|
if (_secondTimer != null)
|
||||||
|
{
|
||||||
_secondTimer.Stop();
|
_secondTimer.Stop();
|
||||||
|
_secondTimer = null;
|
||||||
|
}
|
||||||
|
|
||||||
_isRunning = false;
|
_isRunning = false;
|
||||||
IsRunningFeedback.FireUpdate();
|
IsRunningFeedback.FireUpdate();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user