diff --git a/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj b/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj index 08bd5c19..e02792ac 100644 --- a/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -175,6 +175,7 @@ + diff --git a/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.projectinfo b/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.projectinfo index 86124937..6abf2379 100644 Binary files a/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.projectinfo and b/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.projectinfo differ diff --git a/Essentials Core/PepperDashEssentialsBase/Timers/CountdownTimer.cs b/Essentials Core/PepperDashEssentialsBase/Timers/CountdownTimer.cs new file mode 100644 index 00000000..81d27f58 --- /dev/null +++ b/Essentials Core/PepperDashEssentialsBase/Timers/CountdownTimer.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +using PepperDash.Core; + +namespace PepperDash.Essentials.Core +{ + public class SecondsCountdownTimer: IKeyed + { + public string Key { get; private set; } + + public BoolFeedback IsRunningFeedback { get; private set; } + bool _IsRunning; + + public IntFeedback PercentFeedback { get; private set; } + public StringFeedback TimeRemainingFeedback { get; private set; } + + 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; } + + /// + /// + /// + /// + public SecondsCountdownTimer(string key) + { + Key = key; + IsRunningFeedback = new BoolFeedback(() => _IsRunning); + + TimeRemainingFeedback = new StringFeedback(() => + { + // Need to handle up and down here. + + if (StartTime == null || FinishTime == null) + return ""; + var timeSpan = FinishTime - DateTime.Now; + return Math.Round(timeSpan.TotalSeconds).ToString(); + }); + + PercentFeedback = new IntFeedback(() => + { + if (StartTime == null || FinishTime == null) + return 0; + double percent = (FinishTime - DateTime.Now).TotalSeconds + / (FinishTime - StartTime).TotalSeconds + * 100; + return (int)percent; + }); + } + + /// + /// + /// + public void Start() + { + if (_IsRunning) + return; + StartTime = DateTime.Now; + FinishTime = StartTime + TimeSpan.FromSeconds(SecondsToCount); + + if (SecondTimer != null) + SecondTimer.Stop(); + SecondTimer = new CTimer(SecondElapsedTimerCallback, null, 0, 1000); + _IsRunning = true; + IsRunningFeedback.FireUpdate(); + + } + + public void Cancel() + { + CleanUp(); + var a = CancelAction; + if (a != null) + a(); + } + + public void Reset() + { + _IsRunning = false; + Start(); + } + + public void Finish() + { + CleanUp(); + var a = CompletionAction; + if (a != null) + a(); + } + + void CleanUp() + { + if (SecondTimer != null) + SecondTimer.Stop(); + _IsRunning = false; + IsRunningFeedback.FireUpdate(); + } + + void SecondElapsedTimerCallback(object o) + { + PercentFeedback.FireUpdate(); + TimeRemainingFeedback.FireUpdate(); + + if (DateTime.Now >= FinishTime) + Finish(); + } + } +} \ No newline at end of file diff --git a/Essentials Core/PepperDashEssentialsBase/Touchpanels/ModalDialog.cs b/Essentials Core/PepperDashEssentialsBase/Touchpanels/ModalDialog.cs index 3a6f0b87..02c4de8c 100644 --- a/Essentials Core/PepperDashEssentialsBase/Touchpanels/ModalDialog.cs +++ b/Essentials Core/PepperDashEssentialsBase/Touchpanels/ModalDialog.cs @@ -162,8 +162,6 @@ namespace PepperDash.Essentials.Core return true; } - // Dialog is busy - //Debug.Console(2, "Modal is already visible"); return false; } diff --git a/Essentials DM/Essentials_DM/Essentials_DM.projectinfo b/Essentials DM/Essentials_DM/Essentials_DM.projectinfo index 64e201fb..ef7cb61f 100644 Binary files a/Essentials DM/Essentials_DM/Essentials_DM.projectinfo and b/Essentials DM/Essentials_DM/Essentials_DM.projectinfo differ diff --git a/Essentials Devices Common/Essentials Devices Common/Display/SamsungMDCDisplay.cs b/Essentials Devices Common/Essentials Devices Common/Display/SamsungMDCDisplay.cs index 4010b62b..1b50bc20 100644 --- a/Essentials Devices Common/Essentials Devices Common/Display/SamsungMDCDisplay.cs +++ b/Essentials Devices Common/Essentials Devices Common/Display/SamsungMDCDisplay.cs @@ -45,7 +45,6 @@ namespace PepperDash.Essentials.Devices.Displays : base(key, name) { Communication = comm; - //Communication.TextReceived += new EventHandler(Communication_TextReceived); Communication.BytesReceived += new EventHandler(Communication_BytesReceived); ID = id == null ? (byte)0x01 : Convert.ToByte(id, 16); // If id is null, set default value of 0x01, otherwise assign value passed in constructor @@ -59,7 +58,6 @@ namespace PepperDash.Essentials.Devices.Displays : base(key, name) { Communication = new GenericTcpIpClient(key + "-tcp", hostname, port, 5000); - //Communication.TextReceived += new EventHandler(Communication_TextReceived); ID = id == null ? (byte)0x01 : Convert.ToByte(id, 16); // If id is null, set default value of 0x01, otherwise assign value passed in constructor Init(); } @@ -186,7 +184,7 @@ namespace PepperDash.Essentials.Devices.Displays // Good length, grab the message var message = newBytes.Skip(4).Take(msgLen).ToArray(); - Debug.Console(0, this, "Parsing input: {0}", ComTextHelper.GetEscapedText(message)); + Debug.Console(2, this, "Parsing input: {0}", ComTextHelper.GetEscapedText(message)); // At this point, the ack/nak is the first byte if (message[0] == 0x41) @@ -194,7 +192,7 @@ namespace PepperDash.Essentials.Devices.Displays switch (message[1]) // type byte { case 0x00: // General status - UpdatePowerFB(message[2]); + UpdatePowerFBWithSource(message[2], message[3]); // "power" can be misrepresented when the display sleeps UpdateVolumeFB(message[3]); UpdateMuteFb(message[4]); UpdateInputFb(message[5]); @@ -233,12 +231,23 @@ namespace PepperDash.Essentials.Devices.Displays } /// + /// Checks power feedback AND that source >0x10 /// /// /// - void UpdatePowerFB(byte b) + void UpdatePowerFBWithSource(byte pb, byte ib) { - var newVal = b == 1; + var newVal = pb == 1 && ib > 0x10; + if (newVal != _PowerIsOn) + { + _PowerIsOn = newVal; + PowerIsOnFeedback.FireUpdate(); + } + } + + void UpdatePowerFB(byte pb) + { + var newVal = pb == 1; if (newVal != _PowerIsOn) { _PowerIsOn = newVal; @@ -419,10 +428,11 @@ namespace PepperDash.Essentials.Devices.Displays } public void InputGet() - { + { SendBytes(new byte[] { 0xAA, 0x14, 0x00, 0x00, 0x00 }); } + /// /// Executes a switch, turning on display if necessary. /// diff --git a/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.projectinfo b/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.projectinfo index 936dbfd7..d9acb686 100644 Binary files a/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.projectinfo and b/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.projectinfo differ diff --git a/Essentials/PepperDashEssentials/ControlSystem.cs b/Essentials/PepperDashEssentials/ControlSystem.cs index 6cba22e5..bdfbca8e 100644 --- a/Essentials/PepperDashEssentials/ControlSystem.cs +++ b/Essentials/PepperDashEssentials/ControlSystem.cs @@ -71,7 +71,19 @@ namespace PepperDash.Essentials DeviceManager.ActivateAll(); Debug.Console(0, "Essentials load complete\r" + "-------------------------------------------------------------"); - } + + //******************************************************************** +#warning Remove these test things: + + var cdt = new SecondsCountdownTimer("timer") { SecondsToCount = 20 }; + cdt.CompletionAction = () => Debug.Console(0, "TIMER DONE 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); + DeviceManager.AddDevice(cdt); + + //******************************************************************** + } catch (Exception e) { Debug.Console(0, "FATAL INITIALIZE ERROR. System is in an inconsistent state:\r{0}", e); diff --git a/Essentials/PepperDashEssentials/PepperDashEssentials.projectinfo b/Essentials/PepperDashEssentials/PepperDashEssentials.projectinfo index 4b4070d0..08391bf6 100644 Binary files a/Essentials/PepperDashEssentials/PepperDashEssentials.projectinfo and b/Essentials/PepperDashEssentials/PepperDashEssentials.projectinfo differ diff --git a/Essentials/PepperDashEssentials/Room/EssentialsRoomBase.cs b/Essentials/PepperDashEssentials/Room/EssentialsRoomBase.cs index 787df20f..6697bca6 100644 --- a/Essentials/PepperDashEssentials/Room/EssentialsRoomBase.cs +++ b/Essentials/PepperDashEssentials/Room/EssentialsRoomBase.cs @@ -29,14 +29,34 @@ namespace PepperDash.Essentials public BoolFeedback IsWarmingFeedback { get; private set; } public BoolFeedback IsCoolingFeedback { get; private set; } - public BoolFeedback ShutdownPendingFeedback { 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 VacancyPowerDownFeedback { get; private set; } protected abstract Func OnFeedbackFunc { get; } - public EssentialsRoomBase(string key, string name) : base(key, name) { OnFeedback = new BoolFeedback(OnFeedbackFunc); + PowerOffPendingFeedback = new BoolFeedback(() => _PowerOffPending); + } + + + /// + /// Triggers the shutdown timer + /// + public void StartShutdown() + { + if (!_PowerOffPending) + { + _PowerOffPending = true; + PowerOffPendingFeedback.FireUpdate(); + } } } } \ No newline at end of file diff --git a/Essentials/PepperDashEssentials/UI Drivers/EssentialsHuddlePanelAvFunctionsDriver.cs b/Essentials/PepperDashEssentials/UI Drivers/EssentialsHuddlePanelAvFunctionsDriver.cs index 488f38e4..d4c0a775 100644 --- a/Essentials/PepperDashEssentials/UI Drivers/EssentialsHuddlePanelAvFunctionsDriver.cs +++ b/Essentials/PepperDashEssentials/UI Drivers/EssentialsHuddlePanelAvFunctionsDriver.cs @@ -168,6 +168,8 @@ namespace PepperDash.Essentials TriList.StringInput[UIStringJoin.StartActivityText].StringValue = "Tap Share to begin"; + + TriList.BooleanInput[UIBoolJoin.LogoDefaultVisible].BoolValue = true; } /// diff --git a/Essentials/PepperDashEssentials/UI Drivers/UIBoolJoin.cs b/Essentials/PepperDashEssentials/UI Drivers/UIBoolJoin.cs index 86bcb20f..d9033fdd 100644 --- a/Essentials/PepperDashEssentials/UI Drivers/UIBoolJoin.cs +++ b/Essentials/PepperDashEssentials/UI Drivers/UIBoolJoin.cs @@ -319,19 +319,32 @@ namespace PepperDash.Essentials /// 15061 Reveals the dual-display subpage /// public const uint DualDisplayPageVisible = 15061; + /// /// 15062 Reveals the toggle switch for the sharing mode /// public const uint ToggleSharingModeVisible = 15062; + /// /// 15063 Press for the toggle mode switch /// public const uint ToggleSharingModePress = 15063; + /// + /// 15064 + /// + public const uint LogoDefaultVisible = 15064; + + /// + /// 15065 + /// + public const uint LogoUrlVisible = 15065; + /// /// 15085 Visibility join for help subpage /// public const uint HelpPageVisible = 15085; + /// /// 15086 Press for help header button /// diff --git a/Essentials/PepperDashEssentials/UI Drivers/UIStringlJoin.cs b/Essentials/PepperDashEssentials/UI Drivers/UIStringlJoin.cs index 59be1d58..28118f1e 100644 --- a/Essentials/PepperDashEssentials/UI Drivers/UIStringlJoin.cs +++ b/Essentials/PepperDashEssentials/UI Drivers/UIStringlJoin.cs @@ -72,6 +72,11 @@ namespace PepperDash.Essentials /// public const uint HelpMessage = 3922; + /// + /// 3923 + /// + public const uint LogoUrl = 3923; + /// /// 3961 Name of source on display 1 /// diff --git a/Release Package/PepperDashEssentials.cpz b/Release Package/PepperDashEssentials.cpz index ffd5460c..1dccc6fa 100644 Binary files a/Release Package/PepperDashEssentials.cpz and b/Release Package/PepperDashEssentials.cpz differ diff --git a/Release Package/PepperDashEssentials.dll b/Release Package/PepperDashEssentials.dll index fe634b9e..634960f1 100644 Binary files a/Release Package/PepperDashEssentials.dll and b/Release Package/PepperDashEssentials.dll differ diff --git a/devjson commands.json b/devjson commands.json index ed410606..0587439f 100644 --- a/devjson commands.json +++ b/devjson commands.json @@ -1,3 +1,5 @@ devjson:1 {"deviceKey":"display-1-comMonitor","methodName":"PrintStatus"} -devjson:1 {"deviceKey":"display-1-com","methodName":"SimulateReceive", "params": ["\\x05\\x06taco\\xAA"]} \ No newline at end of file +devjson:1 {"deviceKey":"display-1-com","methodName":"SimulateReceive", "params": ["\\x05\\x06taco\\xAA"]} + +devjson:1 {"deviceKey":"timer","methodName":"Start" }