Merge pull request #1185 from PepperDash/feature-2.0.0/tech-password-interface

Feature 2.0.0/tech password interface
This commit is contained in:
Neil Dorin
2024-05-02 09:55:41 -06:00
committed by GitHub
5 changed files with 136 additions and 64 deletions

View File

@@ -106,4 +106,11 @@ namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
Action<string,string, JToken> Action { get; } Action<string,string, JToken> Action { get; }
} }
public interface IMobileControlTouchpanelController : IKeyed
{
string DefaultRoomKey { get; }
void SetAppUrl(string url);
bool UseDirectServer { get; }
bool ZoomRoomController { get; }
}
} }

View File

@@ -52,5 +52,11 @@ namespace PepperDash.Essentials.Core
[JsonProperty("sinkType")] [JsonProperty("sinkType")]
public eRoutingSignalType SinkType { get; set; } public eRoutingSignalType SinkType { get; set; }
[JsonProperty("isCodecContentDestination")]
public bool isCodecContentDestination { get; set; }
[JsonProperty("isProgramAudioDestination")]
public bool isProgramAudioDestination { get; set; }
} }
} }

View File

@@ -22,15 +22,31 @@ namespace PepperDash.Essentials.Core
static Scheduler() static Scheduler()
{ {
CrestronConsole.AddNewConsoleCommand(DeleteEventGroup, "DeleteEventGroup", "Deletes the event group by key", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(ClearEventsFromGroup, "ClearAllEvents", "Clears all scheduled events for this group", ConsoleAccessLevelEnum.AccessOperator); CrestronConsole.AddNewConsoleCommand(ClearEventsFromGroup, "ClearAllEvents", "Clears all scheduled events for this group", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(ListAllEventGroups, "ListAllEventGroups", "Lists all the event groups by key", ConsoleAccessLevelEnum.AccessOperator); CrestronConsole.AddNewConsoleCommand(ListAllEventGroups, "ListAllEventGroups", "Lists all the event groups by key", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(ListAllEventsForGroup, "ListEventsForGroup", CrestronConsole.AddNewConsoleCommand(ListAllEventsForGroup, "ListEventsForGroup",
"Lists all events for the given group", ConsoleAccessLevelEnum.AccessOperator); "Lists all events for the given group", ConsoleAccessLevelEnum.AccessOperator);
} }
static void DeleteEventGroup(string groupName)
{
if (EventGroups.ContainsKey(groupName))
{
var group = EventGroups[groupName];
EventGroups.Remove(groupName);
group.Dispose();
group = null;
}
}
/// <summary> /// <summary>
/// Clears (deletes) all events from a group /// Clears (deletes) all events from a group
/// </summary> /// </summary>
@@ -40,7 +56,7 @@ namespace PepperDash.Essentials.Core
if (!EventGroups.ContainsKey(groupName)) if (!EventGroups.ContainsKey(groupName))
{ {
Debug.LogMessage(LogEventLevel.Information, Debug.LogMessage(LogEventLevel.Information,
"[Scheduler]: Unable to delete events from group '{0}'. Group not found in EventGroups dictionary.", "[Scheduler]: Unable to delete events from group '{0}'. Group not found in EventGroups dictionary.", null,
groupName); groupName);
return; return;
} }
@@ -51,47 +67,47 @@ namespace PepperDash.Essentials.Core
{ {
group.ClearAllEvents(); group.ClearAllEvents();
Debug.LogMessage(LogEventLevel.Information, "[Scheduler]: All events deleted from group '{0}'", groupName); Debug.LogMessage(LogEventLevel.Information, "[Scheduler]: All events deleted from group '{0}'", null, groupName);
} }
else else
Debug.LogMessage(LogEventLevel.Information, Debug.LogMessage(LogEventLevel.Information,
"[Scheduler]: Unable to delete events from group '{0}'. Group not found in EventGroups dictionary.", "[Scheduler]: Unable to delete events from group '{0}'. Group not found in EventGroups dictionary.", null,
groupName); groupName);
} }
static void ListAllEventGroups(string command) static void ListAllEventGroups(string command)
{ {
Debug.LogMessage(LogEventLevel.Information, "Event Groups:"); CrestronConsole.ConsoleCommandResponse("Event Groups:");
foreach (var group in EventGroups) foreach (var group in EventGroups)
{ {
Debug.LogMessage(LogEventLevel.Information, "{0}", group.Key); CrestronConsole.ConsoleCommandResponse($"{group.Key}");
} }
} }
static void ListAllEventsForGroup(string args) static void ListAllEventsForGroup(string args)
{ {
Debug.LogMessage(LogEventLevel.Information, "Getting events for group {0}...", args); Debug.LogMessage(LogEventLevel.Information, "Getting events for group {0}...", null, args);
ScheduledEventGroup group; ScheduledEventGroup group;
if (!EventGroups.TryGetValue(args, out group)) if (!EventGroups.TryGetValue(args, out group))
{ {
Debug.LogMessage(LogEventLevel.Information, "Unabled to get event group for key {0}", args); Debug.LogMessage(LogEventLevel.Information, "Unabled to get event group for key {0}", null, args);
return; return;
} }
foreach (var evt in group.ScheduledEvents) foreach (var evt in group.ScheduledEvents)
{ {
Debug.LogMessage(LogEventLevel.Information, CrestronConsole.ConsoleCommandResponse(
@" $@"
****Event key {0}**** ****Event key {evt.Key}****
Event date/time: {1} Event state: {evt.Value.EventState}
Persistent: {2} Event date/time: {evt.Value.DateAndTime}
Acknowlegable: {3} Persistent: {evt.Value.Persistent}
Recurrence: {4} Acknowlegable: {evt.Value.Acknowledgeable}
Recurrence Days: {5} Recurrence: {evt.Value.Recurrence.Recurrence}
********************", evt.Key, evt.Value.DateAndTime, evt.Value.Persistent, evt.Value.Acknowledgeable, Recurrence Days: {evt.Value.Recurrence.RecurrenceDays}
evt.Value.Recurrence.Recurrence, evt.Value.Recurrence.RecurrenceDays); ********************");
} }
} }
@@ -138,10 +154,9 @@ Recurrence Days: {5}
var dayOfWeek = eventTime.DayOfWeek; var dayOfWeek = eventTime.DayOfWeek;
Debug.LogMessage(LogEventLevel.Debug, "[Scheduler]: eventTime day of week is: {0}", dayOfWeek); Debug.LogMessage(LogEventLevel.Debug, "[Scheduler]: eventTime day of week is: {0}",null, dayOfWeek);
switch (dayOfWeek) switch (dayOfWeek)
{ {
case DayOfWeek.Sunday: case DayOfWeek.Sunday:
{ {
if ((recurrence & ScheduledEventCommon.eWeekDays.Sunday) == ScheduledEventCommon.eWeekDays.Sunday) if ((recurrence & ScheduledEventCommon.eWeekDays.Sunday) == ScheduledEventCommon.eWeekDays.Sunday)
@@ -203,53 +218,64 @@ Recurrence Days: {5}
public static void CreateEventFromConfig(ScheduledEventConfig config, ScheduledEventGroup group, ScheduledEvent.UserEventCallBack handler) public static void CreateEventFromConfig(ScheduledEventConfig config, ScheduledEventGroup group, ScheduledEvent.UserEventCallBack handler)
{ {
if (group == null) try
{ {
Debug.LogMessage(LogEventLevel.Information, "Unable to create event. Group is null"); if (group == null)
return; {
Debug.LogMessage(LogEventLevel.Information, "Unable to create event. Group is null", null, null);
return;
}
var scheduledEvent = new ScheduledEvent(config.Key, group)
{
Acknowledgeable = config.Acknowledgeable,
Persistent = config.Persistent
};
scheduledEvent.UserCallBack += handler;
scheduledEvent.DateAndTime.SetFirstDayOfWeek(ScheduledEventCommon.eFirstDayOfWeek.Sunday);
var eventTime = DateTime.Parse(config.Time);
if (DateTime.Now > eventTime)
{
eventTime = eventTime.AddDays(1);
}
Debug.LogMessage(LogEventLevel.Verbose, "[Scheduler] Current Date day of week: {0} recurrence days: {1}", null, eventTime.DayOfWeek,
config.Days);
var dayOfWeekConverted = ConvertDayOfWeek(eventTime);
Debug.LogMessage(LogEventLevel.Debug, "[Scheduler] eventTime Day: {0}", null, dayOfWeekConverted);
while (!dayOfWeekConverted.IsFlagSet(config.Days))
{
eventTime = eventTime.AddDays(1);
dayOfWeekConverted = ConvertDayOfWeek(eventTime);
}
scheduledEvent.DateAndTime.SetAbsoluteEventTime(eventTime);
scheduledEvent.Recurrence.Weekly(config.Days);
Debug.LogMessage(LogEventLevel.Verbose, $"[Scheduler] Event State: {scheduledEvent.EventState}", null, null);
if (config.Enable && scheduledEvent.EventState != ScheduledEventCommon.eEventState.Enabled)
{
scheduledEvent.Enable();
}
else if (!config.Enable && scheduledEvent.EventState != ScheduledEventCommon.eEventState.Disabled)
{
scheduledEvent.Disable();
}
} }
var scheduledEvent = new ScheduledEvent(config.Key, group) catch (Exception e)
{ {
Acknowledgeable = config.Acknowledgeable,
Persistent = config.Persistent
};
scheduledEvent.UserCallBack += handler; Debug.LogMessage(LogEventLevel.Error, "Error creating scheduled event: {0}", null, e);
scheduledEvent.DateAndTime.SetFirstDayOfWeek(ScheduledEventCommon.eFirstDayOfWeek.Sunday);
var eventTime = DateTime.Parse(config.Time);
if (DateTime.Now > eventTime)
{
eventTime = eventTime.AddDays(1);
}
Debug.LogMessage(LogEventLevel.Verbose, "[Scheduler] Current Date day of week: {0} recurrence days: {1}", eventTime.DayOfWeek,
config.Days);
var dayOfWeekConverted = ConvertDayOfWeek(eventTime);
Debug.LogMessage(LogEventLevel.Debug, "[Scheduler] eventTime Day: {0}", dayOfWeekConverted);
while (!dayOfWeekConverted.IsFlagSet(config.Days))
{
eventTime = eventTime.AddDays(1);
dayOfWeekConverted = ConvertDayOfWeek(eventTime);
}
scheduledEvent.DateAndTime.SetAbsoluteEventTime(eventTime);
scheduledEvent.Recurrence.Weekly(config.Days);
if (config.Enable)
{
scheduledEvent.Enable();
}
else
{
scheduledEvent.Disable();
} }
} }

View File

@@ -77,6 +77,34 @@ namespace PepperDash.Essentials.Core
SecondsCountdownTimer ShutdownPromptTimer { get; } SecondsCountdownTimer ShutdownPromptTimer { get; }
void SetShutdownPromptSeconds(int seconds); void SetShutdownPromptSeconds(int seconds);
void StartShutdown(eShutdownType type);
}
/// <summary""'""">
/// Describes a room with a tech password
/// </summary>
public interface ITechPassword
{
event EventHandler<TechPasswordEventArgs> TechPasswordValidateResult;
event EventHandler<EventArgs> TechPasswordChanged;
int TechPasswordLength { get; }
void ValidateTechPassword(string password);
void SetTechPassword(string oldPassword, string newPassword);
}
public class TechPasswordEventArgs : EventArgs
{
public bool IsValid { get; private set; }
public TechPasswordEventArgs(bool isValid)
{
IsValid = isValid;
}
} }
/// <summary> /// <summary>

View File

@@ -23,6 +23,8 @@ namespace PepperDash.Essentials.Core
public IntFeedback PercentFeedback { get; private set; } public IntFeedback PercentFeedback { get; private set; }
public StringFeedback TimeRemainingFeedback { get; private set; } public StringFeedback TimeRemainingFeedback { get; private set; }
public IntFeedback SecondsRemainingFeedback { get; private set; }
public bool CountsDown { get; set; } public bool CountsDown { get; set; }
/// <summary> /// <summary>
@@ -64,6 +66,8 @@ namespace PepperDash.Essentials.Core
: String.Format("{0:00}:{1:00}", timeSpan.Minutes, timeSpan.Seconds); : String.Format("{0:00}:{1:00}", timeSpan.Minutes, timeSpan.Seconds);
}); });
SecondsRemainingFeedback = new IntFeedback(() => (int)(FinishTime - DateTime.Now).TotalSeconds);
PercentFeedback = PercentFeedback =
new IntFeedback( new IntFeedback(
() => () =>
@@ -144,6 +148,7 @@ namespace PepperDash.Essentials.Core
PercentFeedback.FireUpdate(); PercentFeedback.FireUpdate();
TimeRemainingFeedback.FireUpdate(); TimeRemainingFeedback.FireUpdate();
SecondsRemainingFeedback.FireUpdate();
} }
} }
} }