diff --git a/PepperDashEssentials/Config/ConfigWriter.cs b/PepperDashEssentials/Config/ConfigWriter.cs
new file mode 100644
index 00000000..243bafce
--- /dev/null
+++ b/PepperDashEssentials/Config/ConfigWriter.cs
@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Crestron.SimplSharp;
+using Crestron.SimplSharp.CrestronIO;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using PepperDash.Core;
+using PepperDash.Essentials.Core;
+using PepperDash.Essentials.Core.Config;
+
+namespace PepperDash.Essentials
+{
+ public class ConfigWriter
+ {
+
+ public static bool WriteConfig()
+ {
+ bool success = false;
+
+ Debug.Console(0, Debug.ErrorLogLevel.Notice, "Writing Configuration to file");
+
+ var fileLock = new CCriticalSection();
+
+
+ var filePath = Global.FilePathPrefix + "LocalConfig" + Global.DirectorySeparator + "configurationFile.json";
+
+ Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to write config file: '{0}'", filePath);
+
+ var configData = JsonConvert.SerializeObject(ConfigReader.ConfigObject);
+
+ try
+ {
+
+ if (fileLock.TryEnter())
+ {
+ using (StreamWriter sw = new StreamWriter(filePath))
+ {
+ sw.Write(configData);
+ sw.Flush();
+ }
+
+ success = true;
+ }
+ else
+ {
+ Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to enter FileLock");
+ success = false;
+ }
+ }
+ catch (Exception e)
+ {
+ Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: Config write failed: \r{0}", e);
+ success = false;
+ }
+ finally
+ {
+ if (fileLock != null && !fileLock.Disposed)
+ fileLock.Leave();
+
+ }
+
+ return success;
+ }
+ }
+}
\ No newline at end of file
diff --git a/PepperDashEssentials/ControlSystem.cs b/PepperDashEssentials/ControlSystem.cs
index d25711ed..ed07033d 100644
--- a/PepperDashEssentials/ControlSystem.cs
+++ b/PepperDashEssentials/ControlSystem.cs
@@ -35,6 +35,8 @@ namespace PepperDash.Essentials
//CrestronConsole.AddNewConsoleCommand(s => GoWithLoad(), "go", "Loads configuration file",
// ConsoleAccessLevelEnum.AccessOperator);
+ CrestronConsole.AddNewConsoleCommand(S => { ConfigWriter.WriteConfig(); }, "writeconfig", "writes the current config to a file", ConsoleAccessLevelEnum.AccessOperator);
+
CrestronConsole.AddNewConsoleCommand(s =>
{
foreach (var tl in TieLineCollection.Default)
diff --git a/PepperDashEssentials/PepperDashEssentials.csproj b/PepperDashEssentials/PepperDashEssentials.csproj
index 8d96ad67..e10ed1eb 100644
--- a/PepperDashEssentials/PepperDashEssentials.csproj
+++ b/PepperDashEssentials/PepperDashEssentials.csproj
@@ -127,6 +127,7 @@
+
diff --git a/PepperDashEssentials/Room/Behaviours/RoomOnToDefaultSourceWhenOccupied.cs b/PepperDashEssentials/Room/Behaviours/RoomOnToDefaultSourceWhenOccupied.cs
index 8501215e..e50309c2 100644
--- a/PepperDashEssentials/Room/Behaviours/RoomOnToDefaultSourceWhenOccupied.cs
+++ b/PepperDashEssentials/Room/Behaviours/RoomOnToDefaultSourceWhenOccupied.cs
@@ -273,8 +273,6 @@ namespace PepperDash.Essentials.Room.Behaviours
}
}
-
-
void CalculateAndSetAcknowledgeExpirationTimeout(ScheduledEvent schEvent, DateTime time1, DateTime time2)
{
Debug.Console(1, this, "time1.Hour = {0}", time1.Hour);
@@ -421,7 +419,7 @@ namespace PepperDash.Essentials.Room.Behaviours
}
///
- /// Callback for event that enables feature
+ /// Callback for event that enables feature. Enables feature if config property is true
///
///
///
@@ -437,7 +435,7 @@ namespace PepperDash.Essentials.Room.Behaviours
}
///
- /// Callback for event that enables feature
+ /// Callback for event that enables feature. Disables feature
///
///
///
diff --git a/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs b/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs
index ad3f5f61..15a81527 100644
--- a/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs
+++ b/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs
@@ -1,468 +1,468 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Crestron.SimplSharp;
-
-using PepperDash.Core;
-using PepperDash.Essentials.Core;
-using PepperDash.Essentials.Room.Config;
-
-namespace PepperDash.Essentials
-{
- public class EssentialsHuddleSpaceRoom : EssentialsRoomBase, IHasCurrentSourceInfoChange, IRunRouteAction, IRunDefaultPresentRoute
- {
- public event EventHandler CurrentVolumeDeviceChange;
- public event SourceInfoChangeHandler CurrentSingleSourceChange;
-
- protected override Func OnFeedbackFunc
- {
- get
- {
- return () =>
- {
- var disp = DefaultDisplay as DisplayBase;
- var val = CurrentSourceInfo != null
- && CurrentSourceInfo.Type == eSourceListItemType.Route
- && disp != null;
- //&& disp.PowerIsOnFeedback.BoolValue;
- return val;
- };
- }
- }
- ///
- ///
- ///
- protected override Func IsWarmingFeedbackFunc
- {
- get
- {
- return () =>
- {
- var disp = DefaultDisplay as DisplayBase;
- if (disp != null)
- return disp.IsWarmingUpFeedback.BoolValue;
- else
- return false;
- };
- }
- }
- ///
- ///
- ///
- protected override Func IsCoolingFeedbackFunc
- {
- get
- {
- return () =>
- {
- var disp = DefaultDisplay as DisplayBase;
- if (disp != null)
- return disp.IsCoolingDownFeedback.BoolValue;
- else
- return false;
- };
- }
- }
-
- public EssentialsRoomPropertiesConfig Config { get; private set; }
-
- public IRoutingSinkWithSwitching DefaultDisplay { get; private set; }
- public IRoutingSinkNoSwitching DefaultAudioDevice { get; private set; }
- public IBasicVolumeControls DefaultVolumeControls { get; private set; }
-
- public bool ExcludeFromGlobalFunctions { get; set; }
-
- ///
- /// The config name of the source list
- ///
- public string SourceListKey { get; set; }
-
- public string DefaultSourceItem { get; set; }
-
- public ushort DefaultVolume { get; set; }
-
- ///
- /// If room is off, enables power on to last source. Default true
- ///
- public bool EnablePowerOnToLastSource { get; set; }
- string LastSourceKey;
-
- ///
- ///
- ///
- public IBasicVolumeControls CurrentVolumeControls
- {
- get { return _CurrentAudioDevice; }
- set
- {
- if (value == _CurrentAudioDevice) return;
-
- var oldDev = _CurrentAudioDevice;
- // derigister this room from the device, if it can
- if (oldDev is IInUseTracking)
- (oldDev as IInUseTracking).InUseTracker.RemoveUser(this, "audio");
- var handler = CurrentVolumeDeviceChange;
- if (handler != null)
- CurrentVolumeDeviceChange(this, new VolumeDeviceChangeEventArgs(oldDev, value, ChangeType.WillChange));
- _CurrentAudioDevice = value;
- if (handler != null)
- CurrentVolumeDeviceChange(this, new VolumeDeviceChangeEventArgs(oldDev, value, ChangeType.DidChange));
- // register this room with new device, if it can
- if (_CurrentAudioDevice is IInUseTracking)
- (_CurrentAudioDevice as IInUseTracking).InUseTracker.AddUser(this, "audio");
- }
- }
- IBasicVolumeControls _CurrentAudioDevice;
-
- ///
- /// The SourceListItem last run - containing names and icons
- ///
- public SourceListItem CurrentSourceInfo
- {
- get { return _CurrentSourceInfo; }
- private set
- {
- if (value == _CurrentSourceInfo) return;
-
- var handler = CurrentSingleSourceChange;
- // remove from in-use tracker, if so equipped
- if(_CurrentSourceInfo != null && _CurrentSourceInfo.SourceDevice is IInUseTracking)
- (_CurrentSourceInfo.SourceDevice as IInUseTracking).InUseTracker.RemoveUser(this, "control");
-
- if (handler != null)
- handler(this, _CurrentSourceInfo, ChangeType.WillChange);
-
- _CurrentSourceInfo = value;
-
- // add to in-use tracking
- if (_CurrentSourceInfo != null && _CurrentSourceInfo.SourceDevice is IInUseTracking)
- (_CurrentSourceInfo.SourceDevice as IInUseTracking).InUseTracker.AddUser(this, "control");
- if (handler != null)
- handler(this, _CurrentSourceInfo, ChangeType.DidChange);
- }
- }
- SourceListItem _CurrentSourceInfo;
-
- public string CurrentSourceInfoKey { get; private set; }
-
- ///
- ///
- ///
- ///
- ///
- public EssentialsHuddleSpaceRoom(string key, string name, IRoutingSinkWithSwitching defaultDisplay,
- IRoutingSinkNoSwitching defaultAudio, EssentialsRoomPropertiesConfig config)
- : base(key, name)
- {
- Config = config;
- DefaultDisplay = defaultDisplay;
- DefaultAudioDevice = defaultAudio;
- if (defaultAudio is IBasicVolumeControls)
- DefaultVolumeControls = defaultAudio as IBasicVolumeControls;
- else if (defaultAudio is IHasVolumeDevice)
- DefaultVolumeControls = (defaultAudio as IHasVolumeDevice).VolumeDevice;
- CurrentVolumeControls = DefaultVolumeControls;
-
- var disp = DefaultDisplay as DisplayBase;
- if (disp != null)
- {
- // Link power, warming, cooling to display
- disp.PowerIsOnFeedback.OutputChange += (o, a) =>
- {
- if (disp.PowerIsOnFeedback.BoolValue != OnFeedback.BoolValue)
- {
- if (!disp.PowerIsOnFeedback.BoolValue)
- CurrentSourceInfo = null;
- OnFeedback.FireUpdate();
- }
- };
-
- disp.IsWarmingUpFeedback.OutputChange += (o, a) =>
- {
- IsWarmingUpFeedback.FireUpdate();
- if (!IsWarmingUpFeedback.BoolValue)
- (DefaultDisplay as IBasicVolumeWithFeedback).SetVolume(DefaultVolume);
- };
- disp.IsCoolingDownFeedback.OutputChange += (o, a) =>
- {
- IsCoolingDownFeedback.FireUpdate();
- };
- }
-
- SourceListKey = "default";
- EnablePowerOnToLastSource = true;
- }
-
-
- ///
- ///
- ///
- protected override void EndShutdown()
- {
- SetDefaultLevels();
-
- RunDefaultPresentRoute();
-
- CrestronEnvironment.Sleep(1000);
-
- RunRouteAction("roomOff");
- }
-
- ///
- /// Routes the default source item, if any
- ///
- public override bool RunDefaultPresentRoute()
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Crestron.SimplSharp;
+
+using PepperDash.Core;
+using PepperDash.Essentials.Core;
+using PepperDash.Essentials.Room.Config;
+
+namespace PepperDash.Essentials
+{
+ public class EssentialsHuddleSpaceRoom : EssentialsRoomBase, IHasCurrentSourceInfoChange, IRunRouteAction, IRunDefaultPresentRoute
+ {
+ public event EventHandler CurrentVolumeDeviceChange;
+ public event SourceInfoChangeHandler CurrentSingleSourceChange;
+
+ protected override Func OnFeedbackFunc
+ {
+ get
+ {
+ return () =>
+ {
+ var disp = DefaultDisplay as DisplayBase;
+ var val = CurrentSourceInfo != null
+ && CurrentSourceInfo.Type == eSourceListItemType.Route
+ && disp != null;
+ //&& disp.PowerIsOnFeedback.BoolValue;
+ return val;
+ };
+ }
+ }
+ ///
+ ///
+ ///
+ protected override Func IsWarmingFeedbackFunc
+ {
+ get
+ {
+ return () =>
+ {
+ var disp = DefaultDisplay as DisplayBase;
+ if (disp != null)
+ return disp.IsWarmingUpFeedback.BoolValue;
+ else
+ return false;
+ };
+ }
+ }
+ ///
+ ///
+ ///
+ protected override Func IsCoolingFeedbackFunc
+ {
+ get
+ {
+ return () =>
+ {
+ var disp = DefaultDisplay as DisplayBase;
+ if (disp != null)
+ return disp.IsCoolingDownFeedback.BoolValue;
+ else
+ return false;
+ };
+ }
+ }
+
+ public EssentialsRoomPropertiesConfig Config { get; private set; }
+
+ public IRoutingSinkWithSwitching DefaultDisplay { get; private set; }
+ public IRoutingSinkNoSwitching DefaultAudioDevice { get; private set; }
+ public IBasicVolumeControls DefaultVolumeControls { get; private set; }
+
+ public bool ExcludeFromGlobalFunctions { get; set; }
+
+ ///
+ /// The config name of the source list
+ ///
+ public string SourceListKey { get; set; }
+
+ public string DefaultSourceItem { get; set; }
+
+ public ushort DefaultVolume { get; set; }
+
+ ///
+ /// If room is off, enables power on to last source. Default true
+ ///
+ public bool EnablePowerOnToLastSource { get; set; }
+ string LastSourceKey;
+
+ ///
+ ///
+ ///
+ public IBasicVolumeControls CurrentVolumeControls
+ {
+ get { return _CurrentAudioDevice; }
+ set
+ {
+ if (value == _CurrentAudioDevice) return;
+
+ var oldDev = _CurrentAudioDevice;
+ // derigister this room from the device, if it can
+ if (oldDev is IInUseTracking)
+ (oldDev as IInUseTracking).InUseTracker.RemoveUser(this, "audio");
+ var handler = CurrentVolumeDeviceChange;
+ if (handler != null)
+ CurrentVolumeDeviceChange(this, new VolumeDeviceChangeEventArgs(oldDev, value, ChangeType.WillChange));
+ _CurrentAudioDevice = value;
+ if (handler != null)
+ CurrentVolumeDeviceChange(this, new VolumeDeviceChangeEventArgs(oldDev, value, ChangeType.DidChange));
+ // register this room with new device, if it can
+ if (_CurrentAudioDevice is IInUseTracking)
+ (_CurrentAudioDevice as IInUseTracking).InUseTracker.AddUser(this, "audio");
+ }
+ }
+ IBasicVolumeControls _CurrentAudioDevice;
+
+ ///
+ /// The SourceListItem last run - containing names and icons
+ ///
+ public SourceListItem CurrentSourceInfo
+ {
+ get { return _CurrentSourceInfo; }
+ private set
+ {
+ if (value == _CurrentSourceInfo) return;
+
+ var handler = CurrentSingleSourceChange;
+ // remove from in-use tracker, if so equipped
+ if(_CurrentSourceInfo != null && _CurrentSourceInfo.SourceDevice is IInUseTracking)
+ (_CurrentSourceInfo.SourceDevice as IInUseTracking).InUseTracker.RemoveUser(this, "control");
+
+ if (handler != null)
+ handler(this, _CurrentSourceInfo, ChangeType.WillChange);
+
+ _CurrentSourceInfo = value;
+
+ // add to in-use tracking
+ if (_CurrentSourceInfo != null && _CurrentSourceInfo.SourceDevice is IInUseTracking)
+ (_CurrentSourceInfo.SourceDevice as IInUseTracking).InUseTracker.AddUser(this, "control");
+ if (handler != null)
+ handler(this, _CurrentSourceInfo, ChangeType.DidChange);
+ }
+ }
+ SourceListItem _CurrentSourceInfo;
+
+ public string CurrentSourceInfoKey { get; private set; }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public EssentialsHuddleSpaceRoom(string key, string name, IRoutingSinkWithSwitching defaultDisplay,
+ IRoutingSinkNoSwitching defaultAudio, EssentialsRoomPropertiesConfig config)
+ : base(key, name)
+ {
+ Config = config;
+ DefaultDisplay = defaultDisplay;
+ DefaultAudioDevice = defaultAudio;
+ if (defaultAudio is IBasicVolumeControls)
+ DefaultVolumeControls = defaultAudio as IBasicVolumeControls;
+ else if (defaultAudio is IHasVolumeDevice)
+ DefaultVolumeControls = (defaultAudio as IHasVolumeDevice).VolumeDevice;
+ CurrentVolumeControls = DefaultVolumeControls;
+
+ var disp = DefaultDisplay as DisplayBase;
+ if (disp != null)
+ {
+ // Link power, warming, cooling to display
+ disp.PowerIsOnFeedback.OutputChange += (o, a) =>
+ {
+ if (disp.PowerIsOnFeedback.BoolValue != OnFeedback.BoolValue)
+ {
+ if (!disp.PowerIsOnFeedback.BoolValue)
+ CurrentSourceInfo = null;
+ OnFeedback.FireUpdate();
+ }
+ };
+
+ disp.IsWarmingUpFeedback.OutputChange += (o, a) =>
+ {
+ IsWarmingUpFeedback.FireUpdate();
+ if (!IsWarmingUpFeedback.BoolValue)
+ (DefaultDisplay as IBasicVolumeWithFeedback).SetVolume(DefaultVolume);
+ };
+ disp.IsCoolingDownFeedback.OutputChange += (o, a) =>
+ {
+ IsCoolingDownFeedback.FireUpdate();
+ };
+ }
+
+ SourceListKey = "default";
+ EnablePowerOnToLastSource = true;
+ }
+
+
+ ///
+ ///
+ ///
+ protected override void EndShutdown()
+ {
+ SetDefaultLevels();
+
+ RunDefaultPresentRoute();
+
+ CrestronEnvironment.Sleep(1000);
+
+ RunRouteAction("roomOff");
+ }
+
+ ///
+ /// Routes the default source item, if any
+ ///
+ public override bool RunDefaultPresentRoute()
{
if (DefaultSourceItem == null)
{
Debug.Console(0, this, "Unable to run default present route, DefaultSourceItem is null.");
return false;
- }
-
- RunRouteAction(DefaultSourceItem);
- return true;
- }
-
- ///
- ///
- ///
- ///
- public void RunRouteAction(string routeKey)
- {
- RunRouteAction(routeKey, null);
- }
-
- ///
- /// Gets a source from config list SourceListKey and dynamically build and executes the
- /// route or commands
- ///
- ///
- public void RunRouteAction(string routeKey, Action successCallback)
- {
- // Run this on a separate thread
- new CTimer(o =>
- {
- Debug.Console(1, this, "Run route action '{0}'", routeKey);
- var dict = ConfigReader.ConfigObject.GetSourceListForKey(SourceListKey);
- if(dict == null)
- {
- Debug.Console(1, this, "WARNING: Config source list '{0}' not found", SourceListKey);
- return;
- }
-
- // Try to get the list item by it's string key
- if (!dict.ContainsKey(routeKey))
- {
- Debug.Console(1, this, "WARNING: No item '{0}' found on config list '{1}'",
- routeKey, SourceListKey);
- return;
- }
-
- var item = dict[routeKey];
- //Debug.Console(2, this, "Action {0} has {1} steps",
- // item.SourceKey, item.RouteList.Count);
-
- // End usage timer on last source
- if (!string.IsNullOrEmpty(LastSourceKey))
- {
- var lastSource = dict[LastSourceKey].SourceDevice;
-
- try
- {
- if (lastSource != null && lastSource is IUsageTracking)
- (lastSource as IUsageTracking).UsageTracker.EndDeviceUsage();
- }
- catch (Exception e)
- {
- Debug.Console(1, this, "*#* EXCEPTION in end usage tracking (257):\r{0}", e);
- }
- }
-
- // Let's run it
- if (routeKey.ToLower() != "roomoff")
- {
- LastSourceKey = routeKey;
- }
- else
- {
- CurrentSourceInfoKey = null;
- }
-
- foreach (var route in item.RouteList)
- {
- // if there is a $defaultAll on route, run two separate
- if (route.DestinationKey.Equals("$defaultAll", StringComparison.OrdinalIgnoreCase))
- {
- // Going to assume a single-path route for now
- var tempVideo = new SourceRouteListItem
- {
- DestinationKey = "$defaultDisplay",
- SourceKey = route.SourceKey,
- Type = eRoutingSignalType.Video
- };
- DoRoute(tempVideo);
-
- //var tempAudio = new SourceRouteListItem
- //{
- // DestinationKey = "$defaultAudio",
- // SourceKey = route.SourceKey,
- // Type = eRoutingSignalType.Audio
- //};
- //DoRoute(tempAudio);
- //continue; -- not sure why this was here
- }
- else
- DoRoute(route);
- }
-
- // Start usage timer on routed source
- if (item.SourceDevice is IUsageTracking)
- {
- (item.SourceDevice as IUsageTracking).UsageTracker.StartDeviceUsage();
- }
-
-
-
-
- // Set volume control, using default if non provided
- IBasicVolumeControls volDev = null;
- // Handle special cases for volume control
- if (string.IsNullOrEmpty(item.VolumeControlKey)
- || item.VolumeControlKey.Equals("$defaultAudio", StringComparison.OrdinalIgnoreCase))
- volDev = DefaultVolumeControls;
- else if (item.VolumeControlKey.Equals("$defaultDisplay", StringComparison.OrdinalIgnoreCase))
- volDev = DefaultDisplay as IBasicVolumeControls;
- // Or a specific device, probably rarely used.
- else
- {
- var dev = DeviceManager.GetDeviceForKey(item.VolumeControlKey);
- if (dev is IBasicVolumeControls)
- volDev = dev as IBasicVolumeControls;
- else if (dev is IHasVolumeDevice)
- volDev = (dev as IHasVolumeDevice).VolumeDevice;
- }
-
- if (volDev != CurrentVolumeControls)
- {
- // zero the volume on the device we are leaving.
- // Set the volume to default on device we are entering
- if (ZeroVolumeWhenSwtichingVolumeDevices && CurrentVolumeControls is IBasicVolumeWithFeedback)
- {
- var vd = CurrentVolumeControls as IBasicVolumeWithFeedback;
- SavedVolumeLevels[vd] = (uint)vd.VolumeLevelFeedback.IntValue;
- vd.SetVolume(0);
- }
- CurrentVolumeControls = volDev;
- if (ZeroVolumeWhenSwtichingVolumeDevices && CurrentVolumeControls is IBasicVolumeWithFeedback)
- {
- var vd = CurrentVolumeControls as IBasicVolumeWithFeedback;
- ushort vol = (SavedVolumeLevels.ContainsKey(vd) ? (ushort)SavedVolumeLevels[vd] : DefaultVolume);
- vd.SetVolume(vol);
- }
- }
-
-
-
- // store the name and UI info for routes
- if (item.SourceKey == "$off")
- {
- CurrentSourceInfoKey = routeKey;
- CurrentSourceInfo = null;
- }
- else if (item.SourceKey != null)
- {
- CurrentSourceInfoKey = routeKey;
- CurrentSourceInfo = item;
- }
- // And finally, set the "control". This will trigger event
- //CurrentControlDevice = DeviceManager.GetDeviceForKey(item.SourceKey) as Device;
-
- OnFeedback.FireUpdate();
-
- // report back when done
- if (successCallback != null)
- successCallback();
-
- }, 0); // end of CTimer
- }
-
- ///
- /// Will power the room on with the last-used source
- ///
- public override void PowerOnToDefaultOrLastSource()
- {
- if (!EnablePowerOnToLastSource || LastSourceKey == null)
- return;
- RunRouteAction(LastSourceKey);
- }
-
- ///
- /// Does what it says
- ///
- public override void SetDefaultLevels()
- {
- Debug.Console(1, this, "Restoring default levels");
- var vc = CurrentVolumeControls as IBasicVolumeWithFeedback;
- if (vc != null)
- vc.SetVolume(DefaultVolume);
- }
-
- ///
- ///
- ///
- ///
- ///
- bool DoRoute(SourceRouteListItem route)
- {
- IRoutingSinkNoSwitching dest = null;
-
- if (route.DestinationKey.Equals("$defaultaudio", StringComparison.OrdinalIgnoreCase))
- dest = DefaultAudioDevice;
- else if (route.DestinationKey.Equals("$defaultDisplay", StringComparison.OrdinalIgnoreCase))
- dest = DefaultDisplay;
- else
- dest = DeviceManager.GetDeviceForKey(route.DestinationKey) as IRoutingSinkNoSwitching;
-
- if (dest == null)
- {
- Debug.Console(1, this, "Cannot route, unknown destination '{0}'", route.DestinationKey);
- return false;
- }
-
- if (route.SourceKey.Equals("$off", StringComparison.OrdinalIgnoreCase))
- {
- dest.ReleaseRoute();
- if (dest is IPower)
- (dest as IPower).PowerOff();
- }
- else
- {
- var source = DeviceManager.GetDeviceForKey(route.SourceKey) as IRoutingOutputs;
- if (source == null)
- {
- Debug.Console(1, this, "Cannot route unknown source '{0}' to {1}", route.SourceKey, route.DestinationKey);
- return false;
- }
- dest.ReleaseAndMakeRoute(source, route.Type);
- }
- return true;
- }
-
- public override void RoomVacatedForTimeoutPeriod(object o)
- {
- //Implement this
- }
-
- ///
- /// Runs "roomOff" action on all rooms not set to ExcludeFromGlobalFunctions
- ///
- public static void AllRoomsOff()
- {
- var allRooms = DeviceManager.AllDevices.Where(d =>
- d is EssentialsHuddleSpaceRoom && !(d as EssentialsHuddleSpaceRoom).ExcludeFromGlobalFunctions);
- foreach (var room in allRooms)
- (room as EssentialsHuddleSpaceRoom).RunRouteAction("roomOff");
- }
- }
+ }
+
+ RunRouteAction(DefaultSourceItem);
+ return true;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ public void RunRouteAction(string routeKey)
+ {
+ RunRouteAction(routeKey, null);
+ }
+
+ ///
+ /// Gets a source from config list SourceListKey and dynamically build and executes the
+ /// route or commands
+ ///
+ ///
+ public void RunRouteAction(string routeKey, Action successCallback)
+ {
+ // Run this on a separate thread
+ new CTimer(o =>
+ {
+ Debug.Console(1, this, "Run route action '{0}'", routeKey);
+ var dict = ConfigReader.ConfigObject.GetSourceListForKey(SourceListKey);
+ if(dict == null)
+ {
+ Debug.Console(1, this, "WARNING: Config source list '{0}' not found", SourceListKey);
+ return;
+ }
+
+ // Try to get the list item by it's string key
+ if (!dict.ContainsKey(routeKey))
+ {
+ Debug.Console(1, this, "WARNING: No item '{0}' found on config list '{1}'",
+ routeKey, SourceListKey);
+ return;
+ }
+
+ var item = dict[routeKey];
+ //Debug.Console(2, this, "Action {0} has {1} steps",
+ // item.SourceKey, item.RouteList.Count);
+
+ // End usage timer on last source
+ if (!string.IsNullOrEmpty(LastSourceKey))
+ {
+ var lastSource = dict[LastSourceKey].SourceDevice;
+
+ try
+ {
+ if (lastSource != null && lastSource is IUsageTracking)
+ (lastSource as IUsageTracking).UsageTracker.EndDeviceUsage();
+ }
+ catch (Exception e)
+ {
+ Debug.Console(1, this, "*#* EXCEPTION in end usage tracking (257):\r{0}", e);
+ }
+ }
+
+ // Let's run it
+ if (routeKey.ToLower() != "roomoff")
+ {
+ LastSourceKey = routeKey;
+ }
+ else
+ {
+ CurrentSourceInfoKey = null;
+ }
+
+ foreach (var route in item.RouteList)
+ {
+ // if there is a $defaultAll on route, run two separate
+ if (route.DestinationKey.Equals("$defaultAll", StringComparison.OrdinalIgnoreCase))
+ {
+ // Going to assume a single-path route for now
+ var tempVideo = new SourceRouteListItem
+ {
+ DestinationKey = "$defaultDisplay",
+ SourceKey = route.SourceKey,
+ Type = eRoutingSignalType.Video
+ };
+ DoRoute(tempVideo);
+
+ //var tempAudio = new SourceRouteListItem
+ //{
+ // DestinationKey = "$defaultAudio",
+ // SourceKey = route.SourceKey,
+ // Type = eRoutingSignalType.Audio
+ //};
+ //DoRoute(tempAudio);
+ //continue; -- not sure why this was here
+ }
+ else
+ DoRoute(route);
+ }
+
+ // Start usage timer on routed source
+ if (item.SourceDevice is IUsageTracking)
+ {
+ (item.SourceDevice as IUsageTracking).UsageTracker.StartDeviceUsage();
+ }
+
+
+
+
+ // Set volume control, using default if non provided
+ IBasicVolumeControls volDev = null;
+ // Handle special cases for volume control
+ if (string.IsNullOrEmpty(item.VolumeControlKey)
+ || item.VolumeControlKey.Equals("$defaultAudio", StringComparison.OrdinalIgnoreCase))
+ volDev = DefaultVolumeControls;
+ else if (item.VolumeControlKey.Equals("$defaultDisplay", StringComparison.OrdinalIgnoreCase))
+ volDev = DefaultDisplay as IBasicVolumeControls;
+ // Or a specific device, probably rarely used.
+ else
+ {
+ var dev = DeviceManager.GetDeviceForKey(item.VolumeControlKey);
+ if (dev is IBasicVolumeControls)
+ volDev = dev as IBasicVolumeControls;
+ else if (dev is IHasVolumeDevice)
+ volDev = (dev as IHasVolumeDevice).VolumeDevice;
+ }
+
+ if (volDev != CurrentVolumeControls)
+ {
+ // zero the volume on the device we are leaving.
+ // Set the volume to default on device we are entering
+ if (ZeroVolumeWhenSwtichingVolumeDevices && CurrentVolumeControls is IBasicVolumeWithFeedback)
+ {
+ var vd = CurrentVolumeControls as IBasicVolumeWithFeedback;
+ SavedVolumeLevels[vd] = (uint)vd.VolumeLevelFeedback.IntValue;
+ vd.SetVolume(0);
+ }
+ CurrentVolumeControls = volDev;
+ if (ZeroVolumeWhenSwtichingVolumeDevices && CurrentVolumeControls is IBasicVolumeWithFeedback)
+ {
+ var vd = CurrentVolumeControls as IBasicVolumeWithFeedback;
+ ushort vol = (SavedVolumeLevels.ContainsKey(vd) ? (ushort)SavedVolumeLevels[vd] : DefaultVolume);
+ vd.SetVolume(vol);
+ }
+ }
+
+
+
+ // store the name and UI info for routes
+ if (item.SourceKey == "$off")
+ {
+ CurrentSourceInfoKey = routeKey;
+ CurrentSourceInfo = null;
+ }
+ else if (item.SourceKey != null)
+ {
+ CurrentSourceInfoKey = routeKey;
+ CurrentSourceInfo = item;
+ }
+ // And finally, set the "control". This will trigger event
+ //CurrentControlDevice = DeviceManager.GetDeviceForKey(item.SourceKey) as Device;
+
+ OnFeedback.FireUpdate();
+
+ // report back when done
+ if (successCallback != null)
+ successCallback();
+
+ }, 0); // end of CTimer
+ }
+
+ ///
+ /// Will power the room on with the last-used source
+ ///
+ public override void PowerOnToDefaultOrLastSource()
+ {
+ if (!EnablePowerOnToLastSource || LastSourceKey == null)
+ return;
+ RunRouteAction(LastSourceKey);
+ }
+
+ ///
+ /// Does what it says
+ ///
+ public override void SetDefaultLevels()
+ {
+ Debug.Console(1, this, "Restoring default levels");
+ var vc = CurrentVolumeControls as IBasicVolumeWithFeedback;
+ if (vc != null)
+ vc.SetVolume(DefaultVolume);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ bool DoRoute(SourceRouteListItem route)
+ {
+ IRoutingSinkNoSwitching dest = null;
+
+ if (route.DestinationKey.Equals("$defaultaudio", StringComparison.OrdinalIgnoreCase))
+ dest = DefaultAudioDevice;
+ else if (route.DestinationKey.Equals("$defaultDisplay", StringComparison.OrdinalIgnoreCase))
+ dest = DefaultDisplay;
+ else
+ dest = DeviceManager.GetDeviceForKey(route.DestinationKey) as IRoutingSinkNoSwitching;
+
+ if (dest == null)
+ {
+ Debug.Console(1, this, "Cannot route, unknown destination '{0}'", route.DestinationKey);
+ return false;
+ }
+
+ if (route.SourceKey.Equals("$off", StringComparison.OrdinalIgnoreCase))
+ {
+ dest.ReleaseRoute();
+ if (dest is IPower)
+ (dest as IPower).PowerOff();
+ }
+ else
+ {
+ var source = DeviceManager.GetDeviceForKey(route.SourceKey) as IRoutingOutputs;
+ if (source == null)
+ {
+ Debug.Console(1, this, "Cannot route unknown source '{0}' to {1}", route.SourceKey, route.DestinationKey);
+ return false;
+ }
+ dest.ReleaseAndMakeRoute(source, route.Type);
+ }
+ return true;
+ }
+
+ public override void RoomVacatedForTimeoutPeriod(object o)
+ {
+ //Implement this
+ }
+
+ ///
+ /// Runs "roomOff" action on all rooms not set to ExcludeFromGlobalFunctions
+ ///
+ public static void AllRoomsOff()
+ {
+ var allRooms = DeviceManager.AllDevices.Where(d =>
+ d is EssentialsHuddleSpaceRoom && !(d as EssentialsHuddleSpaceRoom).ExcludeFromGlobalFunctions);
+ foreach (var room in allRooms)
+ (room as EssentialsHuddleSpaceRoom).RunRouteAction("roomOff");
+ }
+ }
}
\ No newline at end of file
diff --git a/PepperDashEssentials/UIDrivers/EssentialsHuddle/EssentialsHuddlePanelAvFunctionsDriver.cs b/PepperDashEssentials/UIDrivers/EssentialsHuddle/EssentialsHuddlePanelAvFunctionsDriver.cs
index dddcb326..523a2912 100644
--- a/PepperDashEssentials/UIDrivers/EssentialsHuddle/EssentialsHuddlePanelAvFunctionsDriver.cs
+++ b/PepperDashEssentials/UIDrivers/EssentialsHuddle/EssentialsHuddlePanelAvFunctionsDriver.cs
@@ -1,1135 +1,1135 @@
-using System;
-using System.Collections.Generic;
-using Crestron.SimplSharp;
-using Crestron.SimplSharpPro;
-using Crestron.SimplSharpPro.UI;
-
-using PepperDash.Core;
-using PepperDash.Essentials.Core;
-using PepperDash.Essentials.Core.SmartObjects;
-using PepperDash.Essentials.Core.PageManagers;
-
-namespace PepperDash.Essentials
-{
- ///
- ///
- ///
- public class EssentialsHuddlePanelAvFunctionsDriver : PanelDriverBase, IAVDriver
- {
- CrestronTouchpanelPropertiesConfig Config;
-
- public enum UiDisplayMode
- {
- PresentationMode, AudioSetup
- }
-
- ///
- /// Whether volume ramping from this panel will show the volume
- /// gauge popup.
- ///
- public bool ShowVolumeGauge { get; set; }
-
- ///
- /// The amount of time that the volume buttons stays on screen, in ms
- ///
- public uint VolumeButtonPopupTimeout
- {
- get { return VolumeButtonsPopupFeedback.TimeoutMs; }
- set { VolumeButtonsPopupFeedback.TimeoutMs = value; }
- }
-
- ///
- /// The amount of time that the volume gauge stays on screen, in ms
- ///
- public uint VolumeGaugePopupTimeout
- {
- get { return VolumeGaugeFeedback.TimeoutMs; }
- set { VolumeGaugeFeedback.TimeoutMs = value; }
- }
-
- ///
- ///
- ///
- public uint PowerOffTimeout { get; set; }
-
- ///
- ///
- ///
- public string DefaultRoomKey
- {
- get { return _DefaultRoomKey; }
- set
- {
- _DefaultRoomKey = value;
- //CurrentRoom = DeviceManager.GetDeviceForKey(value) as EssentialsHuddleSpaceRoom;
- }
- }
- string _DefaultRoomKey;
-
- ///
- /// Indicates that the SetHeaderButtons method has completed successfully
- ///
- public bool HeaderButtonsAreSetUp { get; private set; }
-
- ///
- ///
- ///
- public EssentialsHuddleSpaceRoom CurrentRoom
- {
- get { return _CurrentRoom; }
- set
- {
- SetCurrentRoom(value);
- }
- }
- EssentialsHuddleSpaceRoom _CurrentRoom;
-
- ///
- ///
- ///
- //uint CurrentInterlockedModalJoin;
-
- ///
- /// For hitting feedback
- ///
- BoolInputSig ShareButtonSig;
- BoolInputSig EndMeetingButtonSig;
-
- ///
- /// Controls the extended period that the volume gauge shows on-screen,
- /// as triggered by Volume up/down operations
- ///
- BoolFeedbackPulseExtender VolumeGaugeFeedback;
-
- ///
- /// Controls the period that the volume buttons show on non-hard-button
- /// interfaces
- ///
- BoolFeedbackPulseExtender VolumeButtonsPopupFeedback;
-
- ///
- /// The parent driver for this
- ///
- PanelDriverBase Parent;
-
- ///
- /// All children attached to this driver. For hiding and showing as a group.
- ///
- List ChildDrivers = new List();
-
- List CurrentDisplayModeSigsInUse = new List();
-
- //// Important smart objects
-
- ///
- /// Smart Object 3200
- ///
- SubpageReferenceList SourcesSrl;
-
- ///
- /// Smart Object 15022
- ///
- SubpageReferenceList ActivityFooterSrl;
-
- ///
- /// Tracks which audio page group the UI is in
- ///
- UiDisplayMode CurrentDisplayMode;
-
- ///
- /// The AV page mangagers that have been used, to keep them alive for later
- ///
- Dictionary