Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature 2.0.0/tech password interface #1185

Merged
merged 6 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,11 @@ public interface IMobileControlAction
Action<string,string, JToken> Action { get; }
}

public interface IMobileControlTouchpanelController : IKeyed
{
string DefaultRoomKey { get; }
void SetAppUrl(string url);
bool UseDirectServer { get; }
bool ZoomRoomController { get; }
}
}
6 changes: 6 additions & 0 deletions src/PepperDash.Essentials.Core/Devices/DestinationListItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,11 @@ public string PreferredName

[JsonProperty("sinkType")]
public eRoutingSignalType SinkType { get; set; }

[JsonProperty("isCodecContentDestination")]
public bool isCodecContentDestination { get; set; }

[JsonProperty("isProgramAudioDestination")]
public bool isProgramAudioDestination { get; set; }
}
}
132 changes: 79 additions & 53 deletions src/PepperDash.Essentials.Core/Global/Scheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,31 @@ public static class 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(ListAllEventGroups, "ListAllEventGroups", "Lists all the event groups by key", ConsoleAccessLevelEnum.AccessOperator);

CrestronConsole.AddNewConsoleCommand(ListAllEventsForGroup, "ListEventsForGroup",
"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>
/// Clears (deletes) all events from a group
/// </summary>
Expand All @@ -40,7 +56,7 @@ static void ClearEventsFromGroup(string groupName)
if (!EventGroups.ContainsKey(groupName))
{
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);
return;
}
Expand All @@ -51,47 +67,47 @@ static void ClearEventsFromGroup(string groupName)
{
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
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);
}

static void ListAllEventGroups(string command)
{
Debug.LogMessage(LogEventLevel.Information, "Event Groups:");
CrestronConsole.ConsoleCommandResponse("Event Groups:");
foreach (var group in EventGroups)
{
Debug.LogMessage(LogEventLevel.Information, "{0}", group.Key);
CrestronConsole.ConsoleCommandResponse($"{group.Key}");
}
}

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;

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;
}

foreach (var evt in group.ScheduledEvents)
{
Debug.LogMessage(LogEventLevel.Information,
@"
****Event key {0}****
Event date/time: {1}
Persistent: {2}
Acknowlegable: {3}
Recurrence: {4}
Recurrence Days: {5}
********************", evt.Key, evt.Value.DateAndTime, evt.Value.Persistent, evt.Value.Acknowledgeable,
evt.Value.Recurrence.Recurrence, evt.Value.Recurrence.RecurrenceDays);
CrestronConsole.ConsoleCommandResponse(
$@"
****Event key {evt.Key}****
Event state: {evt.Value.EventState}
Event date/time: {evt.Value.DateAndTime}
Persistent: {evt.Value.Persistent}
Acknowlegable: {evt.Value.Acknowledgeable}
Recurrence: {evt.Value.Recurrence.Recurrence}
Recurrence Days: {evt.Value.Recurrence.RecurrenceDays}
********************");
}
}

Expand Down Expand Up @@ -138,10 +154,9 @@ public static bool CheckIfDayOfWeekMatchesRecurrenceDays(DateTime eventTime, Sch

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)
{
{
case DayOfWeek.Sunday:
{
if ((recurrence & ScheduledEventCommon.eWeekDays.Sunday) == ScheduledEventCommon.eWeekDays.Sunday)
Expand Down Expand Up @@ -203,53 +218,64 @@ public static bool CheckEventRecurrenceForMatch(ScheduledEvent evnt, ScheduledEv

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");
return;
}
var scheduledEvent = new ScheduledEvent(config.Key, group)
{
Acknowledgeable = config.Acknowledgeable,
Persistent = config.Persistent
};
if (group == null)
{
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.UserCallBack += handler;

scheduledEvent.DateAndTime.SetFirstDayOfWeek(ScheduledEventCommon.eFirstDayOfWeek.Sunday);
scheduledEvent.DateAndTime.SetFirstDayOfWeek(ScheduledEventCommon.eFirstDayOfWeek.Sunday);

var eventTime = DateTime.Parse(config.Time);
var eventTime = DateTime.Parse(config.Time);

if (DateTime.Now > eventTime)
{
eventTime = eventTime.AddDays(1);
}
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);
Debug.LogMessage(LogEventLevel.Verbose, "[Scheduler] Current Date day of week: {0} recurrence days: {1}", null, eventTime.DayOfWeek,
config.Days);

var dayOfWeekConverted = ConvertDayOfWeek(eventTime);
var dayOfWeekConverted = ConvertDayOfWeek(eventTime);

Debug.LogMessage(LogEventLevel.Debug, "[Scheduler] eventTime Day: {0}", dayOfWeekConverted);
Debug.LogMessage(LogEventLevel.Debug, "[Scheduler] eventTime Day: {0}", null, dayOfWeekConverted);

while (!dayOfWeekConverted.IsFlagSet(config.Days))
{
eventTime = eventTime.AddDays(1);
while (!dayOfWeekConverted.IsFlagSet(config.Days))
{
eventTime = eventTime.AddDays(1);

dayOfWeekConverted = ConvertDayOfWeek(eventTime);
}
dayOfWeekConverted = ConvertDayOfWeek(eventTime);
}

scheduledEvent.DateAndTime.SetAbsoluteEventTime(eventTime);
scheduledEvent.DateAndTime.SetAbsoluteEventTime(eventTime);

scheduledEvent.Recurrence.Weekly(config.Days);
scheduledEvent.Recurrence.Weekly(config.Days);

if (config.Enable)
{
scheduledEvent.Enable();
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();
}

}
else
catch (Exception e)
{
scheduledEvent.Disable();

Debug.LogMessage(LogEventLevel.Error, "Error creating scheduled event: {0}", null, e);
}
}

Expand Down
28 changes: 28 additions & 0 deletions src/PepperDash.Essentials.Core/Room/Interfaces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,34 @@ public interface IShutdownPromptTimer
SecondsCountdownTimer ShutdownPromptTimer { get; }

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>
Expand Down
5 changes: 5 additions & 0 deletions src/PepperDash.Essentials.Core/Timers/CountdownTimer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class SecondsCountdownTimer: IKeyed
public IntFeedback PercentFeedback { get; private set; }
public StringFeedback TimeRemainingFeedback { get; private set; }

public IntFeedback SecondsRemainingFeedback { get; private set; }

public bool CountsDown { get; set; }

/// <summary>
Expand Down Expand Up @@ -64,6 +66,8 @@ public SecondsCountdownTimer(string key)
: String.Format("{0:00}:{1:00}", timeSpan.Minutes, timeSpan.Seconds);
});

SecondsRemainingFeedback = new IntFeedback(() => (int)(FinishTime - DateTime.Now).TotalSeconds);

PercentFeedback =
new IntFeedback(
() =>
Expand Down Expand Up @@ -144,6 +148,7 @@ void SecondElapsedTimerCallback(object o)

PercentFeedback.FireUpdate();
TimeRemainingFeedback.FireUpdate();
SecondsRemainingFeedback.FireUpdate();
}
}
}
Loading