Moved config reader/writer classes to essentials core. refactored as a result

This commit is contained in:
Neil Dorin
2018-09-07 15:58:03 -06:00
parent 0487099ee4
commit 30506419df
19 changed files with 44 additions and 387 deletions

View File

@@ -6,6 +6,7 @@ using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharp.Scheduler;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Essentials.Core;
@@ -112,11 +113,11 @@ namespace PepperDash.Essentials.Room.Behaviours
AddDisableEventToGroup();
FeatureEnabled = CheckIfFeatureShouldBeEnabled();
FeatureEventGroup.UserGroupCallBack += new ScheduledEventGroup.UserEventGroupCallBack(FeatureEventGroup_UserGroupCallBack);
FeatureEventGroup.EnableAllEvents();
FeatureEnabled = CheckIfFeatureShouldBeEnabled();
}
else
Debug.Console(1, this, "Unable to get room from Device Manager with key: {0}", Config.RoomKey);
@@ -124,6 +125,15 @@ namespace PepperDash.Essentials.Room.Behaviours
return base.CustomActivate();
}
/// <summary>
/// Returns a JObject of the device config properties as they currently exist at runtime
/// </summary>
/// <returns></returns>
public JToken GetLocalConfigProperties()
{
return JToken.FromObject(Config);
}
/// <summary>
/// Subscribe to feedback from RoomIsOccupiedFeedback on Room
/// </summary>
@@ -173,7 +183,7 @@ namespace PepperDash.Essentials.Room.Behaviours
if (DateTime.Now.TimeOfDay.CompareTo(FeatureEnabledTime.TimeOfDay) >= 0 && FeatureDisabledTime.TimeOfDay.CompareTo(DateTime.Now.TimeOfDay) > 0)
{
if (SchedulerUtilities.CheckIfDayOfWeekMatchesRecurrenceDays(DateTime.Now, FeatureEnableEvent.Recurrence.RecurrenceDays))
if (SchedulerUtilities.CheckIfDayOfWeekMatchesRecurrenceDays(DateTime.Now, CalculateDaysOfWeekRecurrence()))
{
Debug.Console(1, this, "*****Feature Enabled by startup check.*****");
enabled = true;