mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-01-27 19:34:51 +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 event EventHandler<EventArgs> WasCancelled;
|
||||
|
||||
public string Key { get; private set; }
|
||||
|
||||
public BoolFeedback IsRunningFeedback { get; private set; }
|
||||
@@ -21,12 +23,10 @@ namespace PepperDash.Essentials.Core
|
||||
public bool CountsDown { 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 FinishTime { get; private set; }
|
||||
|
||||
CTimer SecondTimer;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -78,10 +78,10 @@ namespace PepperDash.Essentials.Core
|
||||
|
||||
public void Cancel()
|
||||
{
|
||||
CleanUp();
|
||||
var a = CancelAction;
|
||||
Finish();
|
||||
var a = WasCancelled;
|
||||
if (a != null)
|
||||
a();
|
||||
a(this, new EventArgs());
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
@@ -91,14 +91,6 @@ namespace PepperDash.Essentials.Core
|
||||
}
|
||||
|
||||
public void Finish()
|
||||
{
|
||||
CleanUp();
|
||||
var a = CompletionAction;
|
||||
if (a != null)
|
||||
a();
|
||||
}
|
||||
|
||||
void CleanUp()
|
||||
{
|
||||
if (SecondTimer != null)
|
||||
SecondTimer.Stop();
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace PepperDash.Essentials
|
||||
#warning Remove these test things:
|
||||
|
||||
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.PercentFeedback.OutputChange += (o, a) => Debug.Console(0, "TIMER {0}%", cdt.PercentFeedback);
|
||||
cdt.TimeRemainingFeedback.OutputChange += (o,a) => Debug.Console(0, "TIMER time: {0}", cdt.TimeRemainingFeedback);
|
||||
|
||||
@@ -144,6 +144,18 @@ namespace PepperDash.Essentials
|
||||
EnablePowerOnToLastSource = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public override void Shutdown()
|
||||
{
|
||||
RunRouteAction("roomoff");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="routeKey"></param>
|
||||
public void RunRouteAction(string routeKey)
|
||||
{
|
||||
RunRouteAction(routeKey, null);
|
||||
|
||||
@@ -255,7 +255,18 @@ namespace PepperDash.Essentials
|
||||
}, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public override void Shutdown()
|
||||
{
|
||||
RunRouteAction("roomoff");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="routeKey"></param>
|
||||
public void RunRouteAction(string routeKey)
|
||||
{
|
||||
RunRouteAction(routeKey, null);
|
||||
|
||||
@@ -30,33 +30,79 @@ namespace PepperDash.Essentials
|
||||
public BoolFeedback IsWarmingFeedback { get; private set; }
|
||||
public BoolFeedback IsCoolingFeedback { get; private set; }
|
||||
|
||||
public BoolFeedback PowerOffPendingFeedback { get; private set; }
|
||||
public IntFeedback PowerOffPendingTimerPercentFeedback { get; private set; }
|
||||
public StringFeedback PowerOffPendingTimeStringFeedback { get; private set; }
|
||||
bool _PowerOffPending;
|
||||
public int PowerOffDelaySeconds { get; set; }
|
||||
//public BoolFeedback PowerOffPendingFeedback { get; private set; }
|
||||
//bool _PowerOffPending;
|
||||
//public IntFeedback PowerOffPendingTimerPercentFeedback { get; private set; }
|
||||
//public StringFeedback PowerOffPendingTimeStringFeedback { get; private 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; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="name"></param>
|
||||
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);
|
||||
PowerOffPendingFeedback = new BoolFeedback(() => _PowerOffPending);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Triggers the shutdown timer
|
||||
///
|
||||
/// </summary>
|
||||
public void StartShutdown()
|
||||
/// <param name="type"></param>
|
||||
public void StartShutdown(ShutdownType type)
|
||||
{
|
||||
if (!_PowerOffPending)
|
||||
{
|
||||
_PowerOffPending = true;
|
||||
PowerOffPendingFeedback.FireUpdate();
|
||||
}
|
||||
// Check for shutdowns running. Manual should override other shutdowns
|
||||
|
||||
if (type == ShutdownType.Manual)
|
||||
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 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>
|
||||
|
||||
@@ -473,25 +473,75 @@ namespace PepperDash.Essentials
|
||||
{
|
||||
if (!CurrentRoom.OnFeedback.BoolValue)
|
||||
return;
|
||||
EndMeetingButtonSig.BoolValue = true;
|
||||
ShareButtonSig.BoolValue = false;
|
||||
// Timeout or button 1 press will shut down
|
||||
var modal = new ModalDialog(TriList);
|
||||
uint time = 60000;
|
||||
uint seconds = time / 1000;
|
||||
var message = string.Format("Meeting will end in {0} seconds", seconds);
|
||||
modal.PresentModalTimerDialog(2, "End Meeting", "Power", message,
|
||||
"End Meeting Now", "Cancel", time, true,
|
||||
but =>
|
||||
{
|
||||
if (but != 2)
|
||||
CurrentRoom.RunRouteAction("roomOff");
|
||||
else
|
||||
ShareButtonSig.BoolValue = true; // restore Share fb
|
||||
EndMeetingButtonSig.BoolValue = false;
|
||||
});
|
||||
|
||||
//EndMeetingButtonSig.BoolValue = true;
|
||||
//ShareButtonSig.BoolValue = false;
|
||||
|
||||
CurrentRoom.StartShutdown(ShutdownType.Manual);
|
||||
|
||||
//// Timeout or button 1 press will shut down
|
||||
//var modal = new ModalDialog(TriList);
|
||||
//uint time = 60000;
|
||||
//uint seconds = time / 1000;
|
||||
//var message = string.Format("Meeting will end in {0} seconds", seconds);
|
||||
//modal.PresentModalTimerDialog(2, "End Meeting", "Power", message,
|
||||
// "End Meeting Now", "Cancel", time, true,
|
||||
// but =>
|
||||
// {
|
||||
// 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()
|
||||
{
|
||||
if (PowerOffTimer != null)
|
||||
@@ -615,6 +665,9 @@ namespace PepperDash.Essentials
|
||||
|
||||
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
|
||||
_CurrentRoom.OnFeedback.OutputChange += _CurrentRoom_OnFeedback_OutputChange;
|
||||
_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":"timer","methodName":"Start" }
|
||||
|
||||
devjson:1 {"deviceKey":"timer","methodName":"Cancel" }
|
||||
|
||||
devjson:1 {"deviceKey":"timer","methodName":"Reset" }
|
||||
Reference in New Issue
Block a user