mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-15 04:34:56 +00:00
Working on adding shutdown timing to room, not UI
This commit is contained in:
Binary file not shown.
@@ -10,6 +10,8 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
public class SecondsCountdownTimer: IKeyed
|
public class SecondsCountdownTimer: IKeyed
|
||||||
{
|
{
|
||||||
|
public event EventHandler<EventArgs> WasCancelled;
|
||||||
|
|
||||||
public string Key { get; private set; }
|
public string Key { get; private set; }
|
||||||
|
|
||||||
public BoolFeedback IsRunningFeedback { get; private set; }
|
public BoolFeedback IsRunningFeedback { get; private set; }
|
||||||
@@ -21,13 +23,11 @@ namespace PepperDash.Essentials.Core
|
|||||||
public bool CountsDown { get; set; }
|
public bool CountsDown { get; set; }
|
||||||
public int SecondsToCount { get; set; }
|
public int SecondsToCount { get; set; }
|
||||||
|
|
||||||
public Action CompletionAction { get; set; }
|
|
||||||
public Action CancelAction { get; set; }
|
|
||||||
|
|
||||||
CTimer SecondTimer;
|
|
||||||
public DateTime StartTime { get; private set; }
|
public DateTime StartTime { get; private set; }
|
||||||
public DateTime FinishTime { get; private set; }
|
public DateTime FinishTime { get; private set; }
|
||||||
|
|
||||||
|
CTimer SecondTimer;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -78,10 +78,10 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
public void Cancel()
|
public void Cancel()
|
||||||
{
|
{
|
||||||
CleanUp();
|
Finish();
|
||||||
var a = CancelAction;
|
var a = WasCancelled;
|
||||||
if (a != null)
|
if (a != null)
|
||||||
a();
|
a(this, new EventArgs());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Reset()
|
public void Reset()
|
||||||
@@ -91,14 +91,6 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Finish()
|
public void Finish()
|
||||||
{
|
|
||||||
CleanUp();
|
|
||||||
var a = CompletionAction;
|
|
||||||
if (a != null)
|
|
||||||
a();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CleanUp()
|
|
||||||
{
|
{
|
||||||
if (SecondTimer != null)
|
if (SecondTimer != null)
|
||||||
SecondTimer.Stop();
|
SecondTimer.Stop();
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ namespace PepperDash.Essentials
|
|||||||
#warning Remove these test things:
|
#warning Remove these test things:
|
||||||
|
|
||||||
var cdt = new SecondsCountdownTimer("timer") { SecondsToCount = 20 };
|
var cdt = new SecondsCountdownTimer("timer") { SecondsToCount = 20 };
|
||||||
cdt.CompletionAction = () => Debug.Console(0, "TIMER DONE FOOLS!");
|
cdt.WasCancelled += (o,a) => Debug.Console(0, "TIMER CANCELLED FOOLS!");
|
||||||
cdt.IsRunningFeedback.OutputChange += (o, a) => Debug.Console(0, "TIMER Running={0}", cdt.IsRunningFeedback);
|
cdt.IsRunningFeedback.OutputChange += (o, a) => Debug.Console(0, "TIMER Running={0}", cdt.IsRunningFeedback);
|
||||||
cdt.PercentFeedback.OutputChange += (o, a) => Debug.Console(0, "TIMER {0}%", cdt.PercentFeedback);
|
cdt.PercentFeedback.OutputChange += (o, a) => Debug.Console(0, "TIMER {0}%", cdt.PercentFeedback);
|
||||||
cdt.TimeRemainingFeedback.OutputChange += (o,a) => Debug.Console(0, "TIMER time: {0}", cdt.TimeRemainingFeedback);
|
cdt.TimeRemainingFeedback.OutputChange += (o,a) => Debug.Console(0, "TIMER time: {0}", cdt.TimeRemainingFeedback);
|
||||||
|
|||||||
@@ -144,6 +144,18 @@ namespace PepperDash.Essentials
|
|||||||
EnablePowerOnToLastSource = true;
|
EnablePowerOnToLastSource = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public override void Shutdown()
|
||||||
|
{
|
||||||
|
RunRouteAction("roomoff");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="routeKey"></param>
|
||||||
public void RunRouteAction(string routeKey)
|
public void RunRouteAction(string routeKey)
|
||||||
{
|
{
|
||||||
RunRouteAction(routeKey, null);
|
RunRouteAction(routeKey, null);
|
||||||
|
|||||||
@@ -255,7 +255,18 @@ namespace PepperDash.Essentials
|
|||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public override void Shutdown()
|
||||||
|
{
|
||||||
|
RunRouteAction("roomoff");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="routeKey"></param>
|
||||||
public void RunRouteAction(string routeKey)
|
public void RunRouteAction(string routeKey)
|
||||||
{
|
{
|
||||||
RunRouteAction(routeKey, null);
|
RunRouteAction(routeKey, null);
|
||||||
|
|||||||
@@ -30,33 +30,79 @@ namespace PepperDash.Essentials
|
|||||||
public BoolFeedback IsWarmingFeedback { get; private set; }
|
public BoolFeedback IsWarmingFeedback { get; private set; }
|
||||||
public BoolFeedback IsCoolingFeedback { get; private set; }
|
public BoolFeedback IsCoolingFeedback { get; private set; }
|
||||||
|
|
||||||
public BoolFeedback PowerOffPendingFeedback { get; private set; }
|
//public BoolFeedback PowerOffPendingFeedback { get; private set; }
|
||||||
public IntFeedback PowerOffPendingTimerPercentFeedback { get; private set; }
|
//bool _PowerOffPending;
|
||||||
public StringFeedback PowerOffPendingTimeStringFeedback { get; private set; }
|
//public IntFeedback PowerOffPendingTimerPercentFeedback { get; private set; }
|
||||||
bool _PowerOffPending;
|
//public StringFeedback PowerOffPendingTimeStringFeedback { get; private set; }
|
||||||
public int PowerOffDelaySeconds { get; set; }
|
|
||||||
|
|
||||||
public BoolFeedback VacancyPowerDownFeedback { get; private set; }
|
/// <summary>
|
||||||
|
/// Timer used for informing the UIs of a shutdown
|
||||||
|
/// </summary>
|
||||||
|
public SecondsCountdownTimer ShutdownPromptTimer { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int ShutdownPromptSeconds { get; set; }
|
||||||
|
public int ShutdownVacancySeconds { get; set; }
|
||||||
|
public ShutdownType ShutdownType { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
protected abstract Func<bool> OnFeedbackFunc { get; }
|
protected abstract Func<bool> OnFeedbackFunc { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <param name="name"></param>
|
||||||
public EssentialsRoomBase(string key, string name) : base(key, name)
|
public EssentialsRoomBase(string key, string name) : base(key, name)
|
||||||
{
|
{
|
||||||
|
ShutdownPromptTimer = new SecondsCountdownTimer(Key + "-offTimer");
|
||||||
|
ShutdownPromptTimer.IsRunningFeedback.OutputChange += (o, a) =>
|
||||||
|
{
|
||||||
|
if (!ShutdownPromptTimer.IsRunningFeedback.BoolValue)
|
||||||
|
ShutdownType = ShutdownType.None;
|
||||||
|
};
|
||||||
|
|
||||||
|
ShutdownPromptSeconds = 60;
|
||||||
|
ShutdownVacancySeconds = 120;
|
||||||
|
|
||||||
OnFeedback = new BoolFeedback(OnFeedbackFunc);
|
OnFeedback = new BoolFeedback(OnFeedbackFunc);
|
||||||
PowerOffPendingFeedback = new BoolFeedback(() => _PowerOffPending);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Triggers the shutdown timer
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void StartShutdown()
|
/// <param name="type"></param>
|
||||||
|
public void StartShutdown(ShutdownType type)
|
||||||
{
|
{
|
||||||
if (!_PowerOffPending)
|
// Check for shutdowns running. Manual should override other shutdowns
|
||||||
{
|
|
||||||
_PowerOffPending = true;
|
if (type == ShutdownType.Manual)
|
||||||
PowerOffPendingFeedback.FireUpdate();
|
ShutdownPromptTimer.SecondsToCount = ShutdownPromptSeconds;
|
||||||
}
|
else if (type == ShutdownType.Vacancy)
|
||||||
|
ShutdownPromptTimer.SecondsToCount = ShutdownVacancySeconds;
|
||||||
|
ShutdownType = type;
|
||||||
|
ShutdownPromptTimer.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public abstract void Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// To describe the various ways a room may be shutting down
|
||||||
|
/// </summary>
|
||||||
|
public enum ShutdownType
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
External,
|
||||||
|
Manual,
|
||||||
|
Vacancy
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -63,8 +63,20 @@ namespace PepperDash.Essentials
|
|||||||
{
|
{
|
||||||
public string HelpMessage { get; set; }
|
public string HelpMessage { get; set; }
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
|
public int ShutdownVacancySeconds { get; set; }
|
||||||
|
public int ShutdownPromptSeconds { get; set; }
|
||||||
|
public EssentialsRoomOccSensorConfig OccupancySensors { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents occupancy sensor(s) setup for a room
|
||||||
|
/// </summary>
|
||||||
|
public class EssentialsRoomOccSensorConfig
|
||||||
|
{
|
||||||
|
public string Mode { get; set; }
|
||||||
|
public List<string> Types { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -473,25 +473,75 @@ namespace PepperDash.Essentials
|
|||||||
{
|
{
|
||||||
if (!CurrentRoom.OnFeedback.BoolValue)
|
if (!CurrentRoom.OnFeedback.BoolValue)
|
||||||
return;
|
return;
|
||||||
EndMeetingButtonSig.BoolValue = true;
|
|
||||||
ShareButtonSig.BoolValue = false;
|
//EndMeetingButtonSig.BoolValue = true;
|
||||||
// Timeout or button 1 press will shut down
|
//ShareButtonSig.BoolValue = false;
|
||||||
var modal = new ModalDialog(TriList);
|
|
||||||
uint time = 60000;
|
CurrentRoom.StartShutdown(ShutdownType.Manual);
|
||||||
uint seconds = time / 1000;
|
|
||||||
var message = string.Format("Meeting will end in {0} seconds", seconds);
|
//// Timeout or button 1 press will shut down
|
||||||
modal.PresentModalTimerDialog(2, "End Meeting", "Power", message,
|
//var modal = new ModalDialog(TriList);
|
||||||
"End Meeting Now", "Cancel", time, true,
|
//uint time = 60000;
|
||||||
but =>
|
//uint seconds = time / 1000;
|
||||||
{
|
//var message = string.Format("Meeting will end in {0} seconds", seconds);
|
||||||
if (but != 2)
|
//modal.PresentModalTimerDialog(2, "End Meeting", "Power", message,
|
||||||
CurrentRoom.RunRouteAction("roomOff");
|
// "End Meeting Now", "Cancel", time, true,
|
||||||
else
|
// but =>
|
||||||
ShareButtonSig.BoolValue = true; // restore Share fb
|
// {
|
||||||
EndMeetingButtonSig.BoolValue = false;
|
// if (but != 2)
|
||||||
});
|
// CurrentRoom.RunRouteAction("roomOff");
|
||||||
|
// else
|
||||||
|
// ShareButtonSig.BoolValue = true; // restore Share fb
|
||||||
|
// EndMeetingButtonSig.BoolValue = false;
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#warning WHAT I'M TRYING TO DO WITH SHUTDOWN PROMPTS. SEE COMMENT
|
||||||
|
// UI should ask room to shutdown
|
||||||
|
// UI should be attached to room's shutdown timer
|
||||||
|
// When timer starts, the UI should present a corresponding modal, with the right text
|
||||||
|
// the modal bar will decrement depending on the timer's percent
|
||||||
|
// If the user selects "end now"
|
||||||
|
// Cancel the modal
|
||||||
|
// Call shutdown on the room (which should cancel any timers)
|
||||||
|
// Room cancels timer
|
||||||
|
// Room fires Shutdown event?
|
||||||
|
// If the UI cancels shutdown
|
||||||
|
// Call cancel shutdown on room
|
||||||
|
// Timer will go low
|
||||||
|
// Fire shutdown cancelled event?
|
||||||
|
//
|
||||||
|
|
||||||
|
void Shutdown_IsRunningFeedback_OutputChange(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var timer = CurrentRoom.ShutdownPromptTimer;
|
||||||
|
if (timer.IsRunningFeedback.BoolValue)
|
||||||
|
{
|
||||||
|
EndMeetingButtonSig.BoolValue = true;
|
||||||
|
ShareButtonSig.BoolValue = false;
|
||||||
|
|
||||||
|
if (CurrentRoom.ShutdownType == ShutdownType.Manual)
|
||||||
|
{
|
||||||
|
var modal = new ModalDialog(TriList);
|
||||||
|
var message = string.Format("Meeting will end in {0} seconds", CurrentRoom.ShutdownPromptSeconds);
|
||||||
|
modal.PresentModalTimerDialog(2, "End Meeting", "Power", message,
|
||||||
|
"End Meeting Now", "Cancel", 0, true,
|
||||||
|
but =>
|
||||||
|
{
|
||||||
|
if (but != 2) // any button except for End cancels
|
||||||
|
timer.Cancel();
|
||||||
|
else
|
||||||
|
ShareButtonSig.BoolValue = true; // restore Share fb
|
||||||
|
EndMeetingButtonSig.BoolValue = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CancelPowerOffTimer()
|
void CancelPowerOffTimer()
|
||||||
{
|
{
|
||||||
if (PowerOffTimer != null)
|
if (PowerOffTimer != null)
|
||||||
@@ -615,6 +665,9 @@ namespace PepperDash.Essentials
|
|||||||
|
|
||||||
TriList.StringInput[UIStringJoin.CurrentRoomName].StringValue = _CurrentRoom.Name;
|
TriList.StringInput[UIStringJoin.CurrentRoomName].StringValue = _CurrentRoom.Name;
|
||||||
|
|
||||||
|
// Shutdown timer
|
||||||
|
_CurrentRoom.ShutdownPromptTimer.IsRunningFeedback.OutputChange += Shutdown_IsRunningFeedback_OutputChange;
|
||||||
|
|
||||||
// Link up all the change events from the room
|
// Link up all the change events from the room
|
||||||
_CurrentRoom.OnFeedback.OutputChange += _CurrentRoom_OnFeedback_OutputChange;
|
_CurrentRoom.OnFeedback.OutputChange += _CurrentRoom_OnFeedback_OutputChange;
|
||||||
_CurrentRoom.CurrentVolumeDeviceChange += _CurrentRoom_CurrentAudioDeviceChange;
|
_CurrentRoom.CurrentVolumeDeviceChange += _CurrentRoom_CurrentAudioDeviceChange;
|
||||||
|
|||||||
@@ -3,3 +3,7 @@ devjson:1 {"deviceKey":"display-1-comMonitor","methodName":"PrintStatus"}
|
|||||||
devjson:1 {"deviceKey":"display-1-com","methodName":"SimulateReceive", "params": ["\\x05\\x06taco\\xAA"]}
|
devjson:1 {"deviceKey":"display-1-com","methodName":"SimulateReceive", "params": ["\\x05\\x06taco\\xAA"]}
|
||||||
|
|
||||||
devjson:1 {"deviceKey":"timer","methodName":"Start" }
|
devjson:1 {"deviceKey":"timer","methodName":"Start" }
|
||||||
|
|
||||||
|
devjson:1 {"deviceKey":"timer","methodName":"Cancel" }
|
||||||
|
|
||||||
|
devjson:1 {"deviceKey":"timer","methodName":"Reset" }
|
||||||
Reference in New Issue
Block a user