-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds IMobileControlTouchpanelController to MobileControlTouchpa…
…nelController. Adds IShutdownPromptTimer
- Loading branch information
Showing
7 changed files
with
138 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,9 +26,6 @@ | |
using PepperDash.Essentials.Core.Shades; | ||
|
||
|
||
|
||
|
||
|
||
#if SERIES4 | ||
using PepperDash.Essentials.AppServer; | ||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
4-series/mobile-control-messengers/Messengers/IShutdownPromptTimerMessenger.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Newtonsoft.Json; | ||
using PepperDash.Core; | ||
using PepperDash.Essentials.Core; | ||
|
||
namespace PepperDash.Essentials.AppServer.Messengers | ||
{ | ||
public class IShutdownPromptTimerMessenger : MessengerBase | ||
{ | ||
private readonly IShutdownPromptTimer _room; | ||
|
||
public IShutdownPromptTimerMessenger(string key, string messagePath, IShutdownPromptTimer room) | ||
: base(key, messagePath, room as Device) | ||
{ | ||
_room = room; | ||
} | ||
|
||
protected override void RegisterActions() | ||
{ | ||
AddAction("/status", (id, content) => | ||
{ | ||
SendFullStatus(); | ||
}); | ||
|
||
AddAction("/setShutdownPromptSeconds", (id, content) => | ||
{ | ||
var response = content.ToObject<int>(); | ||
|
||
_room.SetShutdownPromptSeconds(response); | ||
}); | ||
|
||
_room.ShutdownPromptTimer.HasStarted += (sender, args) => | ||
{ | ||
var status = new IShutdownPromptTimerEventMessage | ||
{ | ||
TimerStarted = true | ||
}; | ||
|
||
PostEventMessage(status); | ||
}; | ||
|
||
_room.ShutdownPromptTimer.HasFinished += (sender, args) => | ||
{ | ||
var status = new IShutdownPromptTimerEventMessage | ||
{ | ||
TimerFinished = true | ||
}; | ||
|
||
PostEventMessage(status); | ||
}; | ||
|
||
_room.ShutdownPromptTimer.WasCancelled += (sender, args) => | ||
{ | ||
var status = new IShutdownPromptTimerEventMessage | ||
{ | ||
TimerCancelled = true | ||
}; | ||
|
||
PostEventMessage(status); | ||
}; | ||
|
||
_room.ShutdownPromptTimer.TimeRemainingFeedback.OutputChange += (sender, args) => | ||
{ | ||
var status = new | ||
{ | ||
timeRemaining = _room.ShutdownPromptTimer.TimeRemainingFeedback.StringValue | ||
}; | ||
}; | ||
} | ||
|
||
private void SendFullStatus() | ||
{ | ||
var status = new IShutdownPromptTimerStateMessage | ||
{ | ||
ShutdownPromptSeconds = _room.ShutdownPromptTimer.SecondsToCount, | ||
TimeRemaining = _room.ShutdownPromptTimer.TimeRemainingFeedback.StringValue, | ||
}; | ||
|
||
PostStatusMessage(status); | ||
} | ||
} | ||
|
||
|
||
public class IShutdownPromptTimerStateMessage : DeviceStateMessageBase | ||
{ | ||
[JsonProperty("secondsRemaining")] | ||
public string TimeRemaining { get; set; } | ||
|
||
[JsonProperty("shutdownPromptSeconds")] | ||
public int ShutdownPromptSeconds { get; set; } | ||
} | ||
|
||
public class IShutdownPromptTimerEventMessage : DeviceEventMessageBase | ||
{ | ||
[JsonProperty("timerFinished")] | ||
public bool TimerFinished { get; set; } | ||
|
||
[JsonProperty("timerStarted")] | ||
public bool TimerStarted { get; set; } | ||
|
||
[JsonProperty("timerCancelled")] | ||
public bool TimerCancelled { get; set; } | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters