mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-09 09:45:06 +00:00
Refining power off dialog; added helpers to TPController for console-signal debugging
This commit is contained in:
Binary file not shown.
@@ -14,6 +14,10 @@ namespace PepperDash.Essentials.Core
|
||||
/// Bool press 3992
|
||||
/// </summary>
|
||||
public const uint Button2Join = 3992;
|
||||
/// <summary>
|
||||
/// 3993
|
||||
/// </summary>
|
||||
public const uint CancelButtonJoin = 3993;
|
||||
/// <summary>
|
||||
///For visibility of single button. Bool feedback 3994
|
||||
/// </summary>
|
||||
@@ -34,7 +38,7 @@ namespace PepperDash.Essentials.Core
|
||||
/// <summary>
|
||||
/// The seconds value of the countdown timer. Ushort join 3991
|
||||
/// </summary>
|
||||
public const uint TimerSecondsJoin = 3991;
|
||||
//public const uint TimerSecondsJoin = 3991;
|
||||
/// <summary>
|
||||
/// The full ushort value of the countdown timer for a gauge. Ushort join 3992
|
||||
/// </summary>
|
||||
@@ -73,7 +77,7 @@ namespace PepperDash.Essentials.Core
|
||||
BasicTriList TriList;
|
||||
|
||||
Action<uint> ModalCompleteAction;
|
||||
CTimer Timer;
|
||||
//CTimer Timer;
|
||||
|
||||
static object CompleteActionLock = new object();
|
||||
|
||||
@@ -85,8 +89,9 @@ namespace PepperDash.Essentials.Core
|
||||
{
|
||||
TriList = triList;
|
||||
// Attach actions to buttons
|
||||
triList.SetSigFalseAction(Button1Join, () => OnModalComplete(1, true));
|
||||
triList.SetSigFalseAction(Button2Join, () => OnModalComplete(2, true));
|
||||
triList.SetSigFalseAction(Button1Join, () => OnModalComplete(1));
|
||||
triList.SetSigFalseAction(Button2Join, () => OnModalComplete(2));
|
||||
triList.SetSigFalseAction(CancelButtonJoin, () => CancelDialog());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -97,9 +102,9 @@ namespace PepperDash.Essentials.Core
|
||||
/// <param name="decreasingGauge">If the progress bar gauge needs to count down instead of up</param>
|
||||
/// <param name="completeAction">The action to run when the dialog is dismissed. Parameter will be 1 or 2 if button pressed, or 0 if dialog times out</param>
|
||||
/// <returns>True when modal is created.</returns>
|
||||
public bool PresentModalTimerDialog(uint numberOfButtons, string title, string iconName,
|
||||
public bool PresentModalDialog(uint numberOfButtons, string title, string iconName,
|
||||
string message, string button1Text,
|
||||
string button2Text, uint timeMs, bool decreasingGauge, Action<uint> completeAction)
|
||||
string button2Text, bool showGauge, Action<uint> completeAction)
|
||||
{
|
||||
//Debug.Console(0, "Present dialog");
|
||||
// Don't reset dialog if visible now
|
||||
@@ -131,66 +136,35 @@ namespace PepperDash.Essentials.Core
|
||||
TriList.StringInput[Button1TextJoin].StringValue = button1Text;
|
||||
TriList.StringInput[Button2TextJoin].StringValue = button2Text;
|
||||
}
|
||||
// Show/hide timer
|
||||
TriList.BooleanInput[TimerVisibleJoin].BoolValue = timeMs > 0;
|
||||
// Show/hide guage
|
||||
TriList.BooleanInput[TimerVisibleJoin].BoolValue = showGauge;
|
||||
|
||||
//Reveal and activate
|
||||
TriList.BooleanInput[ModalVisibleJoin].BoolValue = true;
|
||||
|
||||
// Start ramp timers if visible
|
||||
if (timeMs > 0)
|
||||
{
|
||||
TriList.UShortInput[TimerSecondsJoin].UShortValue = (ushort)(timeMs / 1000); // Seconds display
|
||||
TriList.UShortInput[TimerSecondsJoin].CreateRamp(0, (uint)(timeMs / 10));
|
||||
if (decreasingGauge)
|
||||
{
|
||||
// Gauge
|
||||
TriList.UShortInput[TimerGaugeJoin].UShortValue = ushort.MaxValue;
|
||||
// Text
|
||||
TriList.UShortInput[TimerGaugeJoin].CreateRamp(0, (uint)(timeMs / 10));
|
||||
}
|
||||
else
|
||||
{
|
||||
TriList.UShortInput[TimerGaugeJoin].UShortValue = 0; // Gauge
|
||||
TriList.UShortInput[TimerGaugeJoin].
|
||||
CreateRamp(ushort.MaxValue, (uint)(timeMs / 10));
|
||||
}
|
||||
Timer = new CTimer(o => OnModalComplete(0, false), timeMs);
|
||||
}
|
||||
|
||||
// Start a timer and fire action with no button on timeout.
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hide dialog from elsewhere, fires no actions^
|
||||
/// </summary>
|
||||
public void CancelDialog()
|
||||
{
|
||||
if (ModalIsVisible)
|
||||
{
|
||||
TriList.UShortInput[TimerSecondsJoin].StopRamp();
|
||||
TriList.UShortInput[TimerGaugeJoin].StopRamp();
|
||||
if (Timer != null) Timer.Stop();
|
||||
TriList.BooleanInput[ModalVisibleJoin].BoolValue = false;
|
||||
}
|
||||
OnModalComplete(0);
|
||||
}
|
||||
|
||||
// When the modal is cleared or times out, clean up the various bits
|
||||
void OnModalComplete(uint buttonNum, bool cancelled)
|
||||
void OnModalComplete(uint buttonNum)
|
||||
{
|
||||
//Debug.Console(2, "OnModalComplete {0}, {1}", buttonNum, cancelled);
|
||||
TriList.BooleanInput[ModalVisibleJoin].BoolValue = false;
|
||||
if (cancelled)
|
||||
{
|
||||
TriList.UShortInput[TimerSecondsJoin].StopRamp();
|
||||
TriList.UShortInput[TimerGaugeJoin].StopRamp();
|
||||
Timer.Stop();
|
||||
}
|
||||
if (ModalCompleteAction != null)
|
||||
|
||||
var action = ModalCompleteAction;
|
||||
if (action != null)
|
||||
{
|
||||
//Debug.Console(2, "Modal complete action");
|
||||
ModalCompleteAction(buttonNum);
|
||||
action(buttonNum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -149,7 +149,7 @@ namespace PepperDash.Essentials
|
||||
/// </summary>
|
||||
public override void Shutdown()
|
||||
{
|
||||
RunRouteAction("roomoff");
|
||||
RunRouteAction("roomOff");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -261,8 +261,6 @@ namespace PepperDash.Essentials
|
||||
if (successCallback != null)
|
||||
successCallback();
|
||||
|
||||
#warning Need to again handle special commands in here.
|
||||
|
||||
}, 0); // end of CTimer
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ namespace PepperDash.Essentials
|
||||
if (!ShutdownPromptTimer.IsRunningFeedback.BoolValue)
|
||||
ShutdownType = ShutdownType.None;
|
||||
};
|
||||
ShutdownPromptTimer.HasFinished += (o, a) => Shutdown(); // Shutdown is triggered
|
||||
|
||||
ShutdownPromptSeconds = 60;
|
||||
ShutdownVacancySeconds = 120;
|
||||
|
||||
@@ -476,74 +476,9 @@ namespace PepperDash.Essentials
|
||||
if (!room.OnFeedback.BoolValue || room.ShutdownPromptTimer.IsRunningFeedback.BoolValue)
|
||||
return;
|
||||
|
||||
//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 // Timer stopped.
|
||||
// {
|
||||
|
||||
// }
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
@@ -560,8 +495,7 @@ namespace PepperDash.Essentials
|
||||
{
|
||||
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,
|
||||
modal.PresentModalDialog(2, "End Meeting", "Power", message, "Cancel", "End Meeting Now", true,
|
||||
but =>
|
||||
{
|
||||
if (but != 2) // any button except for End cancels
|
||||
|
||||
@@ -654,8 +654,8 @@ namespace PepperDash.Essentials
|
||||
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,
|
||||
modal.PresentModalDialog(2, "End Meeting", "Power", message,
|
||||
"End Meeting Now", "Cancel", true,
|
||||
but =>
|
||||
{
|
||||
EndMeetingButtonSig.BoolValue = false;
|
||||
|
||||
@@ -175,6 +175,32 @@ namespace PepperDash.Essentials
|
||||
}
|
||||
}
|
||||
|
||||
public void PulseBool(uint join)
|
||||
{
|
||||
var act = Panel.BooleanInput[join].UserObject as Action<bool>;
|
||||
if (act != null)
|
||||
{
|
||||
act(true);
|
||||
act(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetBoolSig(uint join, bool value)
|
||||
{
|
||||
var act = Panel.BooleanInput[join].UserObject as Action<bool>;
|
||||
if (act != null)
|
||||
act(value);
|
||||
}
|
||||
|
||||
public void SetIntSig(uint join, ushort value)
|
||||
{
|
||||
var act = Panel.BooleanInput[join].UserObject as Action<ushort>;
|
||||
if (act != null)
|
||||
{
|
||||
act(value);
|
||||
}
|
||||
}
|
||||
|
||||
void Tsw_SigChange(object currentDevice, Crestron.SimplSharpPro.SigEventArgs args)
|
||||
{
|
||||
if (Debug.Level == 2)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user