Renamed Config in Essentials room type classes to PropertiesConfig and modified EssentialsRoomBase to derive from ReconfigurableDevice

This commit is contained in:
Neil Dorin
2018-09-13 16:50:08 -06:00
parent 065075aabd
commit 8dabe732ec
14 changed files with 762 additions and 948 deletions

View File

@@ -87,9 +87,7 @@ namespace PepperDash.Essentials
else if (typeName == "roomonwhenoccupancydetectedfeature")
{
var props = JsonConvert.DeserializeObject<Room.Behaviours.RoomOnToDefaultSourceWhenOccupiedConfig>(properties.ToString());
return new Room.Behaviours.RoomOnToDefaultSourceWhenOccupied(key, props);
return new Room.Behaviours.RoomOnToDefaultSourceWhenOccupied(dc);
}
return null;

View File

@@ -49,12 +49,12 @@ namespace PepperDash.Essentials
avDriver.CurrentRoom = room as EssentialsHuddleSpaceRoom;
// Environment Driver
if (avDriver.CurrentRoom.Config.Environment != null && avDriver.CurrentRoom.Config.Environment.DeviceKeys.Count > 0)
if (avDriver.CurrentRoom.PropertiesConfig.Environment != null && avDriver.CurrentRoom.PropertiesConfig.Environment.DeviceKeys.Count > 0)
{
Debug.Console(0, panelController, "Adding environment driver");
mainDriver.EnvironmentDriver = new EssentialsEnvironmentDriver(mainDriver, props);
mainDriver.EnvironmentDriver.GetDevicesFromConfig(avDriver.CurrentRoom.Config.Environment);
mainDriver.EnvironmentDriver.GetDevicesFromConfig(avDriver.CurrentRoom.PropertiesConfig.Environment);
}
mainDriver.HeaderDriver.SetupHeaderButtons(avDriver, avDriver.CurrentRoom);
@@ -118,12 +118,12 @@ namespace PepperDash.Essentials
avDriver.CurrentRoom = room as EssentialsHuddleVtc1Room;
// Environment Driver
if (avDriver.CurrentRoom.Config.Environment != null && avDriver.CurrentRoom.Config.Environment.DeviceKeys.Count > 0)
if (avDriver.CurrentRoom.PropertiesConfig.Environment != null && avDriver.CurrentRoom.PropertiesConfig.Environment.DeviceKeys.Count > 0)
{
Debug.Console(0, panelController, "Adding environment driver");
mainDriver.EnvironmentDriver = new EssentialsEnvironmentDriver(mainDriver, props);
mainDriver.EnvironmentDriver.GetDevicesFromConfig(avDriver.CurrentRoom.Config.Environment);
mainDriver.EnvironmentDriver.GetDevicesFromConfig(avDriver.CurrentRoom.PropertiesConfig.Environment);
}
mainDriver.HeaderDriver.SetupHeaderButtons(avDriver, avDriver.CurrentRoom);

View File

@@ -774,7 +774,7 @@ namespace PepperDash.Essentials.Fusion
string roomConfigResponseArgs = args.Sig.StringValue.Replace("&", "and");
Debug.Console(1, this, "Fusion Response: \n {0}", roomConfigResponseArgs);
Debug.Console(2, this, "Fusion Response: \n {0}", roomConfigResponseArgs);
try
{

View File

@@ -3,10 +3,13 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.Devices;
using PepperDash.Essentials.Room.Behaviours;
namespace PepperDash.Essentials.Fusion
@@ -23,75 +26,79 @@ namespace PepperDash.Essentials.Fusion
/// <param name="roomInfo"></param>
public void EvaluateRoomInfo(string roomKey, RoomInformation roomInfo)
{
var runtimeConfigurableDevices = DeviceManager.AllDevices.Where(d => d is IRuntimeConfigurableDevice);
try
{
foreach (var device in runtimeConfigurableDevices)
var reconfigurableDevices = DeviceManager.AllDevices.Where(d => d is ReconfigurableDevice);
foreach (var device in reconfigurableDevices)
{
// Get the current device config so new values can be overwritten over existing
var deviceConfig = (device as IRuntimeConfigurableDevice).GetDeviceConfig();
var deviceConfig = (device as ReconfigurableDevice).Config;
if (device is RoomOnToDefaultSourceWhenOccupied)
{
var devConfig = (deviceConfig as RoomOnToDefaultSourceWhenOccupiedConfig);
var devProps = JsonConvert.DeserializeObject<RoomOnToDefaultSourceWhenOccupiedConfig>(deviceConfig.Properties.ToString());
var enableFeature = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupied"));
if (enableFeature != null)
devConfig.EnableRoomOnWhenOccupied = bool.Parse(enableFeature.CustomFieldValue);
devProps.EnableRoomOnWhenOccupied = bool.Parse(enableFeature.CustomFieldValue);
var enableTime = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("RoomOnWhenOccupiedStartTime"));
if (enableTime != null)
devConfig.OccupancyStartTime = enableTime.CustomFieldValue;
devProps.OccupancyStartTime = enableTime.CustomFieldValue;
var disableTime = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("RoomOnWhenOccupiedEndTime"));
if (disableTime != null)
devConfig.OccupancyEndTime = disableTime.CustomFieldValue;
devProps.OccupancyEndTime = disableTime.CustomFieldValue;
var enableSunday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedSun"));
if (enableSunday != null)
devConfig.EnableSunday = bool.Parse(enableSunday.CustomFieldValue);
devProps.EnableSunday = bool.Parse(enableSunday.CustomFieldValue);
var enableMonday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedMon"));
if (enableMonday != null)
devConfig.EnableMonday = bool.Parse(enableMonday.CustomFieldValue);
devProps.EnableMonday = bool.Parse(enableMonday.CustomFieldValue);
var enableTuesday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedTue"));
if (enableTuesday != null)
devConfig.EnableTuesday = bool.Parse(enableTuesday.CustomFieldValue);
devProps.EnableTuesday = bool.Parse(enableTuesday.CustomFieldValue);
var enableWednesday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedWed"));
if (enableWednesday != null)
devConfig.EnableWednesday = bool.Parse(enableWednesday.CustomFieldValue);
devProps.EnableWednesday = bool.Parse(enableWednesday.CustomFieldValue);
var enableThursday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedThu"));
if (enableThursday != null)
devConfig.EnableThursday = bool.Parse(enableThursday.CustomFieldValue);
devProps.EnableThursday = bool.Parse(enableThursday.CustomFieldValue);
var enableFriday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedFri"));
if (enableFriday != null)
devConfig.EnableFriday = bool.Parse(enableFriday.CustomFieldValue);
devProps.EnableFriday = bool.Parse(enableFriday.CustomFieldValue);
var enableSaturday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedSat"));
if (enableSaturday != null)
devConfig.EnableSaturday = bool.Parse(enableSaturday.CustomFieldValue);
devProps.EnableSaturday = bool.Parse(enableSaturday.CustomFieldValue);
deviceConfig = devConfig;
deviceConfig.Properties = JToken.FromObject(devProps);
}
else if (device is EssentialsRoomBase)
{
// Set the room name
deviceConfig.Name = roomInfo.Name;
// Set the help message
var helpMessage = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("RoomHelpMessage"));
if (helpMessage != null)
{
deviceConfig.Properties["Help"]["Message"].Value<string>(helpMessage.CustomFieldValue);
}
}
// Set the config on the device
(device as IRuntimeConfigurableDevice).SetDeviceConfig(deviceConfig);
(device as ReconfigurableDevice).SetConfig(deviceConfig);
}
//var roomConfig = ConfigReader.ConfigObject.Rooms.FirstOrDefault(r => r.Key.Equals(roomKey);
//if(roomConfig != null)
//{
// roomConfig.Name = roomInfo.Name;
// // Update HelpMessage in room properties
// roomConfig.Properties.
//}
}
catch (Exception e)
{

View File

@@ -11,6 +11,7 @@ using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.Devices;
using PepperDash.Essentials.Devices.Common.Occupancy;
namespace PepperDash.Essentials.Room.Behaviours
@@ -18,9 +19,9 @@ namespace PepperDash.Essentials.Room.Behaviours
/// <summary>
/// A device that when linked to a room can power the room on when enabled during scheduled hours.
/// </summary>
public class RoomOnToDefaultSourceWhenOccupied : Device, IRuntimeConfigurableDevice
public class RoomOnToDefaultSourceWhenOccupied : ReconfigurableDevice
{
RoomOnToDefaultSourceWhenOccupiedConfig Config;
RoomOnToDefaultSourceWhenOccupiedConfig PropertiesConfig;
public bool FeatureEnabled { get; private set; }
@@ -42,10 +43,10 @@ namespace PepperDash.Essentials.Room.Behaviours
private Fusion.EssentialsHuddleSpaceFusionSystemControllerBase FusionRoom;
public RoomOnToDefaultSourceWhenOccupied(string key, RoomOnToDefaultSourceWhenOccupiedConfig config)
: base(key)
public RoomOnToDefaultSourceWhenOccupied(DeviceConfig config) :
base (config)
{
Config = config;
PropertiesConfig = JsonConvert.DeserializeObject<RoomOnToDefaultSourceWhenOccupiedConfig>(config.Properties.ToString());
FeatureEventGroup = new ScheduledEventGroup(this.Key);
@@ -63,7 +64,7 @@ namespace PepperDash.Essentials.Room.Behaviours
else
Debug.Console(1, this, "Room has no RoomOccupancy object set");
var fusionRoomKey = Config.RoomKey + "-fusion";
var fusionRoomKey = PropertiesConfig.RoomKey + "-fusion";
FusionRoom = DeviceManager.GetDeviceForKey(fusionRoomKey) as Fusion.EssentialsHuddleSpaceFusionSystemControllerBase;
@@ -79,45 +80,48 @@ namespace PepperDash.Essentials.Room.Behaviours
return base.CustomActivate();
}
/// <summary>
/// Sets up device based on config values
/// </summary>
void SetUpDevice()
{
Room = DeviceManager.GetDeviceForKey(Config.RoomKey) as EssentialsRoomBase;
Room = DeviceManager.GetDeviceForKey(PropertiesConfig.RoomKey) as EssentialsRoomBase;
if (Room != null)
{
try
{
FeatureEnabledTime = DateTime.Parse(Config.OccupancyStartTime);
FeatureEnabledTime = DateTime.Parse(PropertiesConfig.OccupancyStartTime);
if (FeatureEnabledTime != null)
{
Debug.Console(1, this, "Enabled Time: {0}", FeatureEnabledTime.ToString());
}
else
Debug.Console(1, this, "Unable to parse {0} to DateTime", Config.OccupancyStartTime);
Debug.Console(1, this, "Unable to parse {0} to DateTime", PropertiesConfig.OccupancyStartTime);
}
catch (Exception e)
{
Debug.Console(1, this, "Unable to parse OccupancyStartTime property: {0} \n Error: {1}", Config.OccupancyStartTime, e);
Debug.Console(1, this, "Unable to parse OccupancyStartTime property: {0} \n Error: {1}", PropertiesConfig.OccupancyStartTime, e);
}
try
{
FeatureDisabledTime = DateTime.Parse(Config.OccupancyEndTime);
FeatureDisabledTime = DateTime.Parse(PropertiesConfig.OccupancyEndTime);
if (FeatureDisabledTime != null)
{
Debug.Console(1, this, "Disabled Time: {0}", FeatureDisabledTime.ToString());
}
else
Debug.Console(1, this, "Unable to parse {0} to DateTime", Config.OccupancyEndTime);
Debug.Console(1, this, "Unable to parse {0} to DateTime", PropertiesConfig.OccupancyEndTime);
}
catch (Exception e)
{
Debug.Console(1, this, "Unable to parse a DateTime config value \n Error: {1}", e);
}
if (!Config.EnableRoomOnWhenOccupied)
if (!PropertiesConfig.EnableRoomOnWhenOccupied)
FeatureEventGroup.ClearAllEvents();
else
{
@@ -133,30 +137,18 @@ namespace PepperDash.Essentials.Room.Behaviours
FeatureEnabled = CheckIfFeatureShouldBeEnabled();
}
else
Debug.Console(1, this, "Unable to get room from Device Manager with key: {0}", Config.RoomKey);
Debug.Console(1, this, "Unable to get room from Device Manager with key: {0}", PropertiesConfig.RoomKey);
}
/// <summary>
/// Returns a JObject of the device config properties as they currently exist at runtime
/// </summary>
/// <returns></returns>
public JToken GetLocalConfigProperties()
protected override void CustomSetConfig(DeviceConfig config)
{
return JToken.FromObject(Config);
}
var newPropertiesConfig = JsonConvert.DeserializeObject<RoomOnToDefaultSourceWhenOccupiedConfig>(config.Properties.ToString());
public object GetDeviceConfig()
{
return Config;
}
if(newPropertiesConfig != null)
PropertiesConfig = newPropertiesConfig;
public void SetDeviceConfig(object config)
{
var newConfig = config as RoomOnToDefaultSourceWhenOccupiedConfig;
Config = newConfig;
ConfigWriter.UpdateDeviceProperties(this.Key, GetLocalConfigProperties());
ConfigWriter.UpdateDeviceConfig(config);
SetUpDevice();
}
@@ -182,7 +174,7 @@ namespace PepperDash.Essentials.Room.Behaviours
{
if (SchEvent.Name == FeatureEnableEventName)
{
if (Config.EnableRoomOnWhenOccupied)
if (PropertiesConfig.EnableRoomOnWhenOccupied)
FeatureEnabled = true;
Debug.Console(1, this, "*****Feature Enabled by event.*****");
@@ -204,7 +196,7 @@ namespace PepperDash.Essentials.Room.Behaviours
{
bool enabled = false;
if(Config.EnableRoomOnWhenOccupied)
if(PropertiesConfig.EnableRoomOnWhenOccupied)
{
Debug.Console(1, this, "Current Time: {0} \n FeatureEnabledTime: {1} \n FeatureDisabledTime: {2}", DateTime.Now, FeatureEnabledTime, FeatureDisabledTime);
@@ -446,19 +438,19 @@ namespace PepperDash.Essentials.Room.Behaviours
{
ScheduledEventCommon.eWeekDays value = new ScheduledEventCommon.eWeekDays();
if (Config.EnableSunday)
if (PropertiesConfig.EnableSunday)
value = value | ScheduledEventCommon.eWeekDays.Sunday;
if (Config.EnableMonday)
if (PropertiesConfig.EnableMonday)
value = value | ScheduledEventCommon.eWeekDays.Monday;
if (Config.EnableTuesday)
if (PropertiesConfig.EnableTuesday)
value = value | ScheduledEventCommon.eWeekDays.Tuesday;
if (Config.EnableWednesday)
if (PropertiesConfig.EnableWednesday)
value = value | ScheduledEventCommon.eWeekDays.Wednesday;
if (Config.EnableThursday)
if (PropertiesConfig.EnableThursday)
value = value | ScheduledEventCommon.eWeekDays.Thursday;
if (Config.EnableFriday)
if (PropertiesConfig.EnableFriday)
value = value | ScheduledEventCommon.eWeekDays.Friday;
if (Config.EnableSaturday)
if (PropertiesConfig.EnableSaturday)
value = value | ScheduledEventCommon.eWeekDays.Saturday;
return value;
@@ -473,7 +465,7 @@ namespace PepperDash.Essentials.Room.Behaviours
{
if (type == ScheduledEventCommon.eCallbackReason.NormalExpiration)
{
if(Config.EnableRoomOnWhenOccupied)
if(PropertiesConfig.EnableRoomOnWhenOccupied)
FeatureEnabled = true;
Debug.Console(1, this, "RoomOnToDefaultSourceWhenOccupied Feature Enabled.");

View File

@@ -66,7 +66,7 @@ namespace PepperDash.Essentials
}
}
public EssentialsRoomPropertiesConfig Config { get; private set; }
public EssentialsRoomPropertiesConfig PropertiesConfig { get; private set; }
public IRoutingSinkWithSwitching DefaultDisplay { get; private set; }
public IRoutingSinkNoSwitching DefaultAudioDevice { get; private set; }
@@ -156,7 +156,7 @@ namespace PepperDash.Essentials
IRoutingSinkNoSwitching defaultAudio, EssentialsRoomPropertiesConfig config)
: base(key, name)
{
Config = config;
PropertiesConfig = config;
DefaultDisplay = defaultDisplay;
DefaultAudioDevice = defaultAudio;
if (defaultAudio is IBasicVolumeControls)

File diff suppressed because it is too large Load Diff

View File

@@ -7,6 +7,7 @@ using Crestron.SimplSharp.Scheduler;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Devices;
using PepperDash.Essentials.Devices.Common.Occupancy;
namespace PepperDash.Essentials
@@ -14,7 +15,7 @@ namespace PepperDash.Essentials
/// <summary>
///
/// </summary>
public abstract class EssentialsRoomBase : Device
public abstract class EssentialsRoomBase : ReconfigurableDevice
{
/// <summary>
///
@@ -80,12 +81,9 @@ namespace PepperDash.Essentials
/// </summary>
public bool ZeroVolumeWhenSwtichingVolumeDevices { get; private set; }
/// <summary>
///
/// </summary>
/// <param name="key"></param>
/// <param name="name"></param>
public EssentialsRoomBase(string key, string name) : base(key, name)
public EssentialsRoomBase(DeviceConfig config)
: base(config)
{
// Setup the ShutdownPromptTimer
ShutdownPromptTimer = new SecondsCountdownTimer(Key + "-offTimer");
@@ -124,6 +122,50 @@ namespace PepperDash.Essentials
});
}
///// <summary>
/////
///// </summary>
///// <param name="key"></param>
///// <param name="name"></param>
//public EssentialsRoomBase(string key, string name) : base(key, name)
//{
// // Setup the ShutdownPromptTimer
// ShutdownPromptTimer = new SecondsCountdownTimer(Key + "-offTimer");
// ShutdownPromptTimer.IsRunningFeedback.OutputChange += (o, a) =>
// {
// if (!ShutdownPromptTimer.IsRunningFeedback.BoolValue)
// ShutdownType = eShutdownType.None;
// };
// ShutdownPromptTimer.HasFinished += (o, a) => Shutdown(); // Shutdown is triggered
// ShutdownPromptSeconds = 60;
// ShutdownVacancySeconds = 120;
// ShutdownType = eShutdownType.None;
// RoomVacancyShutdownTimer = new SecondsCountdownTimer(Key + "-vacancyOffTimer");
// //RoomVacancyShutdownTimer.IsRunningFeedback.OutputChange += (o, a) =>
// //{
// // if (!RoomVacancyShutdownTimer.IsRunningFeedback.BoolValue)
// // ShutdownType = ShutdownType.Vacancy;
// //};
// RoomVacancyShutdownTimer.HasFinished += new EventHandler<EventArgs>(RoomVacancyShutdownPromptTimer_HasFinished); // Shutdown is triggered
// RoomVacancyShutdownPromptSeconds = 1500; // 25 min to prompt warning
// RoomVacancyShutdownSeconds = 240; // 4 min after prompt will trigger shutdown prompt
// VacancyMode = eVacancyMode.None;
// OnFeedback = new BoolFeedback(OnFeedbackFunc);
// IsWarmingUpFeedback = new BoolFeedback(IsWarmingFeedbackFunc);
// IsCoolingDownFeedback = new BoolFeedback(IsCoolingFeedbackFunc);
// AddPostActivationAction(() =>
// {
// if (RoomOccupancy != null)
// OnRoomOccupancyIsSet();
// });
//}
void RoomVacancyShutdownPromptTimer_HasFinished(object sender, EventArgs e)
{
switch (VacancyMode)

View File

@@ -76,7 +76,7 @@ namespace PepperDash.Essentials
avDriver.PopupInterlock.HideAndClear());
}
void SetUpHelpButton(EssentialsRoomPropertiesConfig roomConf)
public void SetUpHelpButton(EssentialsRoomPropertiesConfig roomConf)
{
// Help roomConf and popup
if (roomConf.Help != null)
@@ -107,7 +107,7 @@ namespace PepperDash.Essentials
var room = DeviceManager.GetDeviceForKey(Config.DefaultRoomKey)
as EssentialsHuddleSpaceRoom;
if (room != null)
message = room.Config.HelpMessage;
message = room.PropertiesConfig.HelpMessage;
else
message = "Sorry, no help message available. No room connected.";
//TriList.StringInput[UIStringJoin.HelpMessage].StringValue = message;
@@ -227,7 +227,7 @@ namespace PepperDash.Essentials
TriList.SetBool(UIBoolJoin.TopBarHabaneroDynamicVisible, true);
var roomConf = currentRoom.Config;
var roomConf = currentRoom.PropertiesConfig;
// Register for the PopupInterlock IsShowsFeedback event to tie the header carets subpage visiblity to it
Parent.AvDriver.PopupInterlock.StatusChanged -= PopupInterlock_StatusChanged;
@@ -289,7 +289,7 @@ namespace PepperDash.Essentials
TriList.SetBool(UIBoolJoin.TopBarHabaneroDynamicVisible, true);
var roomConf = currentRoom.Config;
var roomConf = currentRoom.PropertiesConfig;
// Register for the PopupInterlock IsShowsFeedback event to tie the header carets subpage visiblity to it
Parent.AvDriver.PopupInterlock.StatusChanged -= PopupInterlock_StatusChanged;

View File

@@ -164,7 +164,7 @@ namespace PepperDash.Essentials
get
{
if (_TechDriver == null)
_TechDriver = new PepperDash.Essentials.UIDrivers.EssentialsHuddleTechPageDriver(TriList, CurrentRoom.Config.Tech);
_TechDriver = new PepperDash.Essentials.UIDrivers.EssentialsHuddleTechPageDriver(TriList, CurrentRoom.PropertiesConfig.Tech);
return _TechDriver;
}
}
@@ -220,9 +220,7 @@ namespace PepperDash.Essentials
return;
}
var roomConf = CurrentRoom.Config;
TriList.SetString(UIStringJoin.CurrentRoomName, CurrentRoom.Name);
var roomConf = CurrentRoom.PropertiesConfig;
if (Config.HeaderStyle.ToLower() == CrestronTouchpanelPropertiesConfig.Habanero)
{
@@ -724,63 +722,58 @@ namespace PepperDash.Essentials
CurrentRoom.CurrentVolumeControls.VolumeDown(state);
}
/// <summary>
/// Helper for property setter. Sets the panel to the given room, latching up all functionality
/// </summary>
void SetCurrentRoom(EssentialsHuddleSpaceRoom room)
{
if (_CurrentRoom == room) return;
// Disconnect current (probably never called)
if (_CurrentRoom != null)
{
// Disconnect current room
_CurrentRoom.CurrentVolumeDeviceChange -= this.CurrentRoom_CurrentAudioDeviceChange;
ClearAudioDeviceConnections();
_CurrentRoom.CurrentSingleSourceChange -= this.CurrentRoom_SourceInfoChange;
DisconnectSource(_CurrentRoom.CurrentSourceInfo);
public void RefreshCurrentRoom(EssentialsHuddleSpaceRoom room)
{
if (_CurrentRoom != null)
{
// Disconnect current room
_CurrentRoom.CurrentVolumeDeviceChange -= this.CurrentRoom_CurrentAudioDeviceChange;
ClearAudioDeviceConnections();
_CurrentRoom.CurrentSingleSourceChange -= this.CurrentRoom_SourceInfoChange;
DisconnectSource(_CurrentRoom.CurrentSourceInfo);
_CurrentRoom.ShutdownPromptTimer.HasStarted -= ShutdownPromptTimer_HasStarted;
_CurrentRoom.ShutdownPromptTimer.HasFinished -= ShutdownPromptTimer_HasFinished;
_CurrentRoom.ShutdownPromptTimer.WasCancelled -= ShutdownPromptTimer_WasCancelled;
_CurrentRoom.OnFeedback.OutputChange += CurrentRoom_OnFeedback_OutputChange;
_CurrentRoom.OnFeedback.OutputChange -= CurrentRoom_OnFeedback_OutputChange;
_CurrentRoom.IsWarmingUpFeedback.OutputChange -= CurrentRoom_IsWarmingFeedback_OutputChange;
_CurrentRoom.IsCoolingDownFeedback.OutputChange -= IsCoolingDownFeedback_OutputChange;
}
_CurrentRoom = room;
_CurrentRoom = room;
if (_CurrentRoom != null)
{
// get the source list config and set up the source list
var config = ConfigReader.ConfigObject.SourceLists;
if (config.ContainsKey(_CurrentRoom.SourceListKey))
{
var srcList = config[_CurrentRoom.SourceListKey];
// Setup sources list
uint i = 1; // counter for UI list
foreach (var kvp in srcList)
{
var srcConfig = kvp.Value;
if (!srcConfig.IncludeInSourceList) // Skip sources marked this way
continue;
if (_CurrentRoom != null)
{
// get the source list config and set up the source list
var config = ConfigReader.ConfigObject.SourceLists;
if (config.ContainsKey(_CurrentRoom.SourceListKey))
{
var srcList = config[_CurrentRoom.SourceListKey];
// Setup sources list
uint i = 1; // counter for UI list
foreach (var kvp in srcList)
{
var srcConfig = kvp.Value;
if (!srcConfig.IncludeInSourceList) // Skip sources marked this way
continue;
var actualSource = DeviceManager.GetDeviceForKey(srcConfig.SourceKey) as Device;
if (actualSource == null)
{
Debug.Console(1, "Cannot assign missing source '{0}' to source UI list",
srcConfig.SourceKey);
continue;
}
var routeKey = kvp.Key;
var actualSource = DeviceManager.GetDeviceForKey(srcConfig.SourceKey) as Device;
if (actualSource == null)
{
Debug.Console(1, "Cannot assign missing source '{0}' to source UI list",
srcConfig.SourceKey);
continue;
}
var routeKey = kvp.Key;
var item = new SubpageReferenceListSourceItem(i++, SourcesSrl, srcConfig,
b => { if (!b) UiSelectSource(routeKey); });
SourcesSrl.AddItem(item); // add to the SRL
item.RegisterForSourceChange(_CurrentRoom);
}
}
SourcesSrl.Count = (ushort)(i - 1);
}
}
// Name and logo
TriList.StringInput[UIStringJoin.CurrentRoomName].StringValue = _CurrentRoom.Name;
TriList.StringInput[UIStringJoin.CurrentRoomName].StringValue = _CurrentRoom.Name;
if (_CurrentRoom.LogoUrl == null)
{
TriList.BooleanInput[UIBoolJoin.LogoDefaultVisible].BoolValue = true;
@@ -804,98 +797,31 @@ namespace PepperDash.Essentials
_CurrentRoom.IsWarmingUpFeedback.OutputChange += CurrentRoom_IsWarmingFeedback_OutputChange;
_CurrentRoom.IsCoolingDownFeedback.OutputChange += IsCoolingDownFeedback_OutputChange;
_CurrentRoom.CurrentVolumeDeviceChange += CurrentRoom_CurrentAudioDeviceChange;
RefreshAudioDeviceConnections();
_CurrentRoom.CurrentSingleSourceChange += CurrentRoom_SourceInfoChange;
RefreshSourceInfo();
_CurrentRoom.CurrentVolumeDeviceChange += CurrentRoom_CurrentAudioDeviceChange;
RefreshAudioDeviceConnections();
_CurrentRoom.CurrentSingleSourceChange += CurrentRoom_SourceInfoChange;
RefreshSourceInfo();
(Parent as EssentialsPanelMainInterfaceDriver).HeaderDriver.SetupHeaderButtons(this, CurrentRoom);
}
else
{
// Clear sigs that need to be
TriList.StringInput[UIStringJoin.CurrentRoomName].StringValue = "Select a room";
}
else
{
// Clear sigs that need to be
TriList.StringInput[UIStringJoin.CurrentRoomName].StringValue = "Select a room";
}
}
/// <summary>
/// Helper for property setter. Sets the panel to the given room, latching up all functionality
/// </summary>
void SetCurrentRoom(EssentialsHuddleSpaceRoom room)
{
if (_CurrentRoom == room) return;
// Disconnect current (probably never called)
RefreshCurrentRoom(room);
}
//void SetupHeaderButtons()
//{
// HeaderButtonsAreSetUp = false;
// TriList.SetBool(UIBoolJoin.TopBarHabaneroDynamicVisible, true);
// var roomConf = CurrentRoom.Config;
// // Gear
// TriList.SetString(UIStringJoin.HeaderButtonIcon5, "Gear");
// TriList.SetSigHeldAction(UIBoolJoin.HeaderIcon5Press, 2000,
// ShowTech,
// null,
// () =>
// {
// if (CurrentRoom.OnFeedback.BoolValue)
// PopupInterlock.ShowInterlockedWithToggle(UIBoolJoin.VolumesPageVisible);
// else
// PopupInterlock.ShowInterlockedWithToggle(UIBoolJoin.VolumesPagePowerOffVisible);
// });
// TriList.SetSigFalseAction(UIBoolJoin.TechExitButton, () =>
// PopupInterlock.HideAndClear());
// // Help button and popup
// if (CurrentRoom.Config.Help != null)
// {
// TriList.SetString(UIStringJoin.HelpMessage, roomConf.Help.Message);
// TriList.SetBool(UIBoolJoin.HelpPageShowCallButtonVisible, roomConf.Help.ShowCallButton);
// TriList.SetString(UIStringJoin.HelpPageCallButtonText, roomConf.Help.CallButtonText);
// if (roomConf.Help.ShowCallButton)
// TriList.SetSigFalseAction(UIBoolJoin.HelpPageShowCallButtonPress, () => { }); // ************ FILL IN
// else
// TriList.ClearBoolSigAction(UIBoolJoin.HelpPageShowCallButtonPress);
// }
// else // older config
// {
// TriList.SetString(UIStringJoin.HelpMessage, CurrentRoom.Config.HelpMessage);
// TriList.SetBool(UIBoolJoin.HelpPageShowCallButtonVisible, false);
// TriList.SetString(UIStringJoin.HelpPageCallButtonText, null);
// TriList.ClearBoolSigAction(UIBoolJoin.HelpPageShowCallButtonPress);
// }
// TriList.SetString(UIStringJoin.HeaderButtonIcon4, "Help");
// TriList.SetSigFalseAction(UIBoolJoin.HeaderIcon4Press, () =>
// {
// string message = null;
// var room = DeviceManager.GetDeviceForKey(Config.DefaultRoomKey)
// as EssentialsHuddleSpaceRoom;
// if (room != null)
// message = room.Config.HelpMessage;
// else
// message = "Sorry, no help message available. No room connected.";
// //TriList.StringInput[UIStringJoin.HelpMessage].StringValue = message;
// PopupInterlock.ShowInterlockedWithToggle(UIBoolJoin.HelpPageVisible);
// });
// uint nextJoin = 3953;
// //// Calendar button
// //if (_CurrentRoom.ScheduleSource != null)
// //{
// // TriList.SetString(nextJoin, "Calendar");
// // TriList.SetSigFalseAction(nextJoin, CalendarPress);
// // nextJoin--;
// //}
// //nextJoin--;
// // blank any that remain
// for (var i = nextJoin; i > 3950; i--)
// {
// TriList.SetString(i, "Blank");
// TriList.SetSigFalseAction(i, () => { });
// }
// HeaderButtonsAreSetUp = true;
//}
/// <summary>
/// For room on/off changes
/// </summary>

View File

@@ -155,7 +155,7 @@ namespace PepperDash.Essentials
get
{
if (_TechDriver == null)
_TechDriver = new PepperDash.Essentials.UIDrivers.EssentialsHuddleTechPageDriver(TriList, CurrentRoom.Config.Tech);
_TechDriver = new PepperDash.Essentials.UIDrivers.EssentialsHuddleTechPageDriver(TriList, CurrentRoom.PropertiesConfig.Tech);
return _TechDriver;
}
}
@@ -235,9 +235,7 @@ namespace PepperDash.Essentials
return;
}
var roomConf = CurrentRoom.Config;
TriList.SetString(UIStringJoin.CurrentRoomName, CurrentRoom.Name);
var roomConf = CurrentRoom.PropertiesConfig;
if (Config.HeaderStyle.ToLower() == CrestronTouchpanelPropertiesConfig.Habanero)
{
@@ -894,7 +892,7 @@ namespace PepperDash.Essentials
_CurrentRoom.ShutdownPromptTimer.HasFinished -= ShutdownPromptTimer_HasFinished;
_CurrentRoom.ShutdownPromptTimer.WasCancelled -= ShutdownPromptTimer_WasCancelled;
_CurrentRoom.OnFeedback.OutputChange += CurrentRoom_OnFeedback_OutputChange;
_CurrentRoom.OnFeedback.OutputChange -= CurrentRoom_OnFeedback_OutputChange;
_CurrentRoom.IsWarmingUpFeedback.OutputChange -= CurrentRoom_IsWarmingFeedback_OutputChange;
_CurrentRoom.IsCoolingDownFeedback.OutputChange -= CurrentRoom_IsCoolingDownFeedback_OutputChange;
_CurrentRoom.InCallFeedback.OutputChange -= CurrentRoom_InCallFeedback_OutputChange;
@@ -1066,155 +1064,6 @@ namespace PepperDash.Essentials
TriList.StringInput[UIStringJoin.CallSharedSourceNameText].StringValue = callListSharedSourceLabel;
}
///// <summary>
/////
///// </summary>
//void SetupHeaderButtons()
//{
// HeaderButtonsAreSetUp = false;
// TriList.SetBool(UIBoolJoin.TopBarHabaneroDynamicVisible, true);
// var roomConf = CurrentRoom.Config;
// // Gear
// TriList.SetString(UIStringJoin.HeaderButtonIcon5, "Gear");
// TriList.SetSigHeldAction(UIBoolJoin.HeaderIcon5Press, 2000,
// ShowTech,
// null,
// () =>
// {
// if (CurrentRoom.OnFeedback.BoolValue)
// PopupInterlock.ShowInterlockedWithToggle(UIBoolJoin.VolumesPageVisible);
// else
// PopupInterlock.ShowInterlockedWithToggle(UIBoolJoin.VolumesPagePowerOffVisible);
// });
// TriList.SetSigFalseAction(UIBoolJoin.TechExitButton, () =>
// PopupInterlock.HideAndClear());
// // Help button and popup
// if (CurrentRoom.Config.Help != null)
// {
// TriList.SetString(UIStringJoin.HelpMessage, roomConf.Help.Message);
// TriList.SetBool(UIBoolJoin.HelpPageShowCallButtonVisible, roomConf.Help.ShowCallButton);
// TriList.SetString(UIStringJoin.HelpPageCallButtonText, roomConf.Help.CallButtonText);
// if (roomConf.Help.ShowCallButton)
// TriList.SetSigFalseAction(UIBoolJoin.HelpPageShowCallButtonPress, () => { }); // ************ FILL IN
// else
// TriList.ClearBoolSigAction(UIBoolJoin.HelpPageShowCallButtonPress);
// }
// else // older config
// {
// TriList.SetString(UIStringJoin.HelpMessage, CurrentRoom.Config.HelpMessage);
// TriList.SetBool(UIBoolJoin.HelpPageShowCallButtonVisible, false);
// TriList.SetString(UIStringJoin.HelpPageCallButtonText, null);
// TriList.ClearBoolSigAction(UIBoolJoin.HelpPageShowCallButtonPress);
// }
// TriList.SetString(UIStringJoin.HeaderButtonIcon4, "Help");
// TriList.SetSigFalseAction(UIBoolJoin.HeaderIcon4Press, () =>
// {
// string message = null;
// var room = DeviceManager.GetDeviceForKey(Config.DefaultRoomKey)
// as EssentialsHuddleSpaceRoom;
// if (room != null)
// message = room.Config.HelpMessage;
// else
// message = "Sorry, no help message available. No room connected.";
// //TriList.StringInput[UIStringJoin.HelpMessage].StringValue = message;
// PopupInterlock.ShowInterlockedWithToggle(UIBoolJoin.HelpPageVisible);
// });
// uint nextJoin = 3953;
// // Calendar button
// if (_CurrentRoom.ScheduleSource != null)
// {
// TriList.SetString(nextJoin, "Calendar");
// TriList.SetSigFalseAction(nextJoin, CalendarPress);
// nextJoin--;
// }
// // Call button
// TriList.SetString(nextJoin, "DND");
// TriList.SetSigFalseAction(nextJoin, ShowActiveCallsList);
// HeaderCallButtonIconSig = TriList.StringInput[nextJoin];
// nextJoin--;
// // blank any that remain
// for (var i = nextJoin; i > 3950; i--)
// {
// TriList.SetString(i, "Blank");
// TriList.SetSigFalseAction(i, () => { });
// }
// TriList.SetSigFalseAction(UIBoolJoin.HeaderCallStatusLabelPress, ShowActiveCallsList);
// // Set Call Status Subpage Position
// if (nextJoin == 3951)
// {
// // Set to right position
// TriList.SetBool(UIBoolJoin.HeaderCallStatusLeftPositionVisible, false);
// TriList.SetBool(UIBoolJoin.HeaderCallStatusRightPositionVisible, true);
// }
// else if (nextJoin == 3950)
// {
// // Set to left position
// TriList.SetBool(UIBoolJoin.HeaderCallStatusLeftPositionVisible, true);
// TriList.SetBool(UIBoolJoin.HeaderCallStatusRightPositionVisible, false);
// }
// HeaderButtonsAreSetUp = true;
// ComputeHeaderCallStatus(CurrentRoom.VideoCodec);
//}
///// <summary>
///// Evaluates the call status and sets the icon mode and text label
///// </summary>
//public void ComputeHeaderCallStatus(VideoCodecBase codec)
//{
// if (codec == null)
// {
// Debug.Console(1, "ComputeHeaderCallStatus() cannot execute. codec is null");
// return;
// }
// if (HeaderCallButtonIconSig == null)
// {
// Debug.Console(1, "ComputeHeaderCallStatus() cannot execute. HeaderCallButtonIconSig is null");
// return;
// }
// // Set mode of header button
// if (!codec.IsInCall)
// {
// HeaderCallButtonIconSig.StringValue = "DND";
// //HeaderCallButton.SetIcon(HeaderListButton.OnHook);
// }
// else if (codec.ActiveCalls.Any(c => c.Type == eCodecCallType.Video))
// HeaderCallButtonIconSig.StringValue = "Misc-06_Dark";
// //HeaderCallButton.SetIcon(HeaderListButton.Camera);
// //TriList.SetUshort(UIUshortJoin.CallHeaderButtonMode, 2);
// else
// HeaderCallButtonIconSig.StringValue = "Misc-09_Dark";
// //HeaderCallButton.SetIcon(HeaderListButton.Phone);
// //TriList.SetUshort(UIUshortJoin.CallHeaderButtonMode, 1);
// // Set the call status text
// if (codec.ActiveCalls.Count > 0)
// {
// if (codec.ActiveCalls.Count == 1)
// TriList.SetString(UIStringJoin.HeaderCallStatusLabel, "1 Active Call");
// else if (codec.ActiveCalls.Count > 1)
// TriList.SetString(UIStringJoin.HeaderCallStatusLabel, string.Format("{0} Active Calls", codec.ActiveCalls.Count));
// }
// else
// TriList.SetString(UIStringJoin.HeaderCallStatusLabel, "No Active Calls");
//}
/// <summary>
///
/// </summary>