mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-01-28 11:54:57 +00:00
Merge branch 'feature/ecs-1188' into bugfix/ecs-1192
# Conflicts: # PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs # essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingPort.cs
This commit is contained in:
@@ -21,8 +21,6 @@ namespace PepperDash.Essentials.Core.Config
|
||||
public string TemplateUrl { get; set; }
|
||||
|
||||
|
||||
//public CotijaConfig Cotija { get; private set; }
|
||||
|
||||
[JsonProperty("systemUuid")]
|
||||
public string SystemUuid
|
||||
{
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Crestron.SimplSharpPro;
|
||||
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Routing;
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core.Devices
|
||||
{
|
||||
/// <summary>
|
||||
/// This DVD class should cover most IR, one-way DVD and Bluray fuctions
|
||||
/// </summary>
|
||||
public class InRoomPc : Device, IHasFeedback, IRoutingOutputs, IAttachVideoStatus, IUiDisplayInfo, IUsageTracking
|
||||
{
|
||||
public uint DisplayUiType { get { return DisplayUiConstants.TypeLaptop; } }
|
||||
public string IconName { get; set; }
|
||||
public BoolFeedback HasPowerOnFeedback { get; private set; }
|
||||
|
||||
public RoutingOutputPort AnyVideoOut { get; private set; }
|
||||
|
||||
#region IRoutingOutputs Members
|
||||
|
||||
/// <summary>
|
||||
/// Options: hdmi
|
||||
/// </summary>
|
||||
public RoutingPortCollection<RoutingOutputPort> OutputPorts { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
public InRoomPc(string key, string name)
|
||||
: base(key, name)
|
||||
{
|
||||
IconName = "PC";
|
||||
HasPowerOnFeedback = new BoolFeedback("HasPowerFeedback",
|
||||
() => this.GetVideoStatuses() != VideoStatusOutputs.NoStatus);
|
||||
OutputPorts = new RoutingPortCollection<RoutingOutputPort>();
|
||||
OutputPorts.Add(AnyVideoOut = new RoutingOutputPort(RoutingPortNames.AnyVideoOut, eRoutingSignalType.Audio | eRoutingSignalType.Video,
|
||||
eRoutingPortConnectionType.None, 0, this));
|
||||
}
|
||||
|
||||
#region IHasFeedback Members
|
||||
|
||||
/// <summary>
|
||||
/// Passes through the VideoStatuses list
|
||||
/// </summary>
|
||||
public FeedbackCollection<Feedback> Feedbacks
|
||||
{
|
||||
get
|
||||
{
|
||||
var newList = new FeedbackCollection<Feedback>();
|
||||
newList.AddRange(this.GetVideoStatuses().ToList());
|
||||
return newList;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IUsageTracking Members
|
||||
|
||||
public UsageTracking UsageTracker { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Crestron.SimplSharpPro;
|
||||
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Routing;
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core.Devices
|
||||
{
|
||||
/// <summary>
|
||||
/// This DVD class should cover most IR, one-way DVD and Bluray fuctions
|
||||
/// </summary>
|
||||
public class Laptop : Device, IHasFeedback, IRoutingOutputs, IAttachVideoStatus, IUiDisplayInfo, IUsageTracking
|
||||
{
|
||||
public uint DisplayUiType { get { return DisplayUiConstants.TypeLaptop; } }
|
||||
public string IconName { get; set; }
|
||||
public BoolFeedback HasPowerOnFeedback { get; private set; }
|
||||
|
||||
public RoutingOutputPort AnyVideoOut { get; private set; }
|
||||
|
||||
#region IRoutingOutputs Members
|
||||
|
||||
/// <summary>
|
||||
/// Options: hdmi
|
||||
/// </summary>
|
||||
public RoutingPortCollection<RoutingOutputPort> OutputPorts { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
public Laptop(string key, string name)
|
||||
: base(key, name)
|
||||
{
|
||||
IconName = "Laptop";
|
||||
HasPowerOnFeedback = new BoolFeedback("HasPowerFeedback",
|
||||
() => this.GetVideoStatuses() != VideoStatusOutputs.NoStatus);
|
||||
OutputPorts = new RoutingPortCollection<RoutingOutputPort>();
|
||||
OutputPorts.Add(AnyVideoOut = new RoutingOutputPort(RoutingPortNames.AnyOut, eRoutingSignalType.Audio | eRoutingSignalType.Video,
|
||||
eRoutingPortConnectionType.None, 0, this));
|
||||
}
|
||||
|
||||
#region IHasFeedback Members
|
||||
|
||||
/// <summary>
|
||||
/// Passes through the VideoStatuses list
|
||||
/// </summary>
|
||||
public FeedbackCollection<Feedback> Feedbacks
|
||||
{
|
||||
get
|
||||
{
|
||||
var newList = new FeedbackCollection<Feedback>();
|
||||
newList.AddRange(this.GetVideoStatuses().ToList());
|
||||
return newList;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IUsageTracking Members
|
||||
|
||||
public UsageTracking UsageTracker { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -95,6 +95,9 @@ namespace PepperDash.Essentials.Core
|
||||
[JsonProperty("disableRoutedSharing")]
|
||||
public bool DisableRoutedSharing { get; set; }
|
||||
|
||||
[JsonProperty("destinations")]
|
||||
public List<eSourceListItemDestinationTypes> Destinations { get; set; }
|
||||
|
||||
public SourceListItem()
|
||||
{
|
||||
Icon = "Blank";
|
||||
@@ -112,4 +115,16 @@ namespace PepperDash.Essentials.Core
|
||||
[JsonProperty("type")]
|
||||
public eRoutingSignalType Type { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the valid destination types for SourceListItems in a room
|
||||
/// </summary>
|
||||
public enum eSourceListItemDestinationTypes
|
||||
{
|
||||
defaultDisplay,
|
||||
leftDisplay,
|
||||
rightDisplay,
|
||||
programAudio,
|
||||
codecContent
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ using PepperDash.Essentials.Core.Routing;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
public class BasicIrDisplay : DisplayBase, IBasicVolumeControls, IPower, IWarmingCooling, IRoutingSinkWithSwitching
|
||||
public class BasicIrDisplay : DisplayBase, IBasicVolumeControls, IPower, IWarmingCooling
|
||||
{
|
||||
public IrOutputPortController IrPort { get; private set; }
|
||||
public ushort IrPulseTime { get; set; }
|
||||
|
||||
@@ -18,6 +18,32 @@ namespace PepperDash.Essentials.Core
|
||||
/// </summary>
|
||||
public abstract class DisplayBase : Device, IHasFeedback, IRoutingSinkWithSwitching, IPower, IWarmingCooling, IUsageTracking
|
||||
{
|
||||
public event SourceInfoChangeHandler CurrentSourceChange;
|
||||
|
||||
public string CurrentSourceInfoKey { get; set; }
|
||||
public SourceListItem CurrentSourceInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
return _CurrentSourceInfo;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == _CurrentSourceInfo) return;
|
||||
|
||||
var handler = CurrentSourceChange;
|
||||
|
||||
if (handler != null)
|
||||
handler(_CurrentSourceInfo, ChangeType.WillChange);
|
||||
|
||||
_CurrentSourceInfo = value;
|
||||
|
||||
if (handler != null)
|
||||
handler(_CurrentSourceInfo, ChangeType.DidChange);
|
||||
}
|
||||
}
|
||||
SourceListItem _CurrentSourceInfo;
|
||||
|
||||
public BoolFeedback PowerIsOnFeedback { get; protected set; }
|
||||
public BoolFeedback IsCoolingDownFeedback { get; protected set; }
|
||||
public BoolFeedback IsWarmingUpFeedback { get; private set; }
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,118 @@
|
||||
using System;
|
||||
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;
|
||||
|
||||
namespace PepperDash.Essentials.Core.Fusion
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles mapping Fusion Custom Property values to system properties
|
||||
/// </summary>
|
||||
public class FusionCustomPropertiesBridge
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates the room info and custom properties from Fusion and updates the system properties aa needed
|
||||
/// </summary>
|
||||
/// <param name="roomInfo"></param>
|
||||
public void EvaluateRoomInfo(string roomKey, RoomInformation roomInfo)
|
||||
{
|
||||
try
|
||||
{
|
||||
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 ReconfigurableDevice).Config;
|
||||
|
||||
if (device is RoomOnToDefaultSourceWhenOccupied)
|
||||
{
|
||||
Debug.Console(1, "Mapping Room on via Occupancy values from Fusion");
|
||||
|
||||
var devProps = JsonConvert.DeserializeObject<RoomOnToDefaultSourceWhenOccupiedConfig>(deviceConfig.Properties.ToString());
|
||||
|
||||
var enableFeature = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupied"));
|
||||
if (enableFeature != null)
|
||||
devProps.EnableRoomOnWhenOccupied = bool.Parse(enableFeature.CustomFieldValue);
|
||||
|
||||
var enableTime = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("RoomOnWhenOccupiedStartTime"));
|
||||
if (enableTime != null)
|
||||
devProps.OccupancyStartTime = enableTime.CustomFieldValue;
|
||||
|
||||
var disableTime = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("RoomOnWhenOccupiedEndTime"));
|
||||
if (disableTime != null)
|
||||
devProps.OccupancyEndTime = disableTime.CustomFieldValue;
|
||||
|
||||
var enableSunday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedSun"));
|
||||
if (enableSunday != null)
|
||||
devProps.EnableSunday = bool.Parse(enableSunday.CustomFieldValue);
|
||||
|
||||
var enableMonday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedMon"));
|
||||
if (enableMonday != null)
|
||||
devProps.EnableMonday = bool.Parse(enableMonday.CustomFieldValue);
|
||||
|
||||
var enableTuesday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedTue"));
|
||||
if (enableTuesday != null)
|
||||
devProps.EnableTuesday = bool.Parse(enableTuesday.CustomFieldValue);
|
||||
|
||||
var enableWednesday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedWed"));
|
||||
if (enableWednesday != null)
|
||||
devProps.EnableWednesday = bool.Parse(enableWednesday.CustomFieldValue);
|
||||
|
||||
var enableThursday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedThu"));
|
||||
if (enableThursday != null)
|
||||
devProps.EnableThursday = bool.Parse(enableThursday.CustomFieldValue);
|
||||
|
||||
var enableFriday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedFri"));
|
||||
if (enableFriday != null)
|
||||
devProps.EnableFriday = bool.Parse(enableFriday.CustomFieldValue);
|
||||
|
||||
var enableSaturday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedSat"));
|
||||
if (enableSaturday != null)
|
||||
devProps.EnableSaturday = bool.Parse(enableSaturday.CustomFieldValue);
|
||||
|
||||
deviceConfig.Properties = JToken.FromObject(devProps);
|
||||
}
|
||||
else if (device is EssentialsRoomBase)
|
||||
{
|
||||
// Set the room name
|
||||
if (!string.IsNullOrEmpty(roomInfo.Name))
|
||||
{
|
||||
Debug.Console(1, "Current Room Name: {0}. New Room Name: {1}", deviceConfig.Name, roomInfo.Name);
|
||||
// Set the name in config
|
||||
deviceConfig.Name = roomInfo.Name;
|
||||
|
||||
Debug.Console(1, "Room Name Successfully Changed.");
|
||||
}
|
||||
|
||||
// Set the help message
|
||||
var helpMessage = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("RoomHelpMessage"));
|
||||
if (helpMessage != null)
|
||||
{
|
||||
//Debug.Console(1, "Current Help Message: {0}. New Help Message: {1}", deviceConfig.Properties["help"]["message"].Value<string>(ToString()), helpMessage.CustomFieldValue);
|
||||
deviceConfig.Properties["helpMessage"] = (string)helpMessage.CustomFieldValue;
|
||||
}
|
||||
}
|
||||
|
||||
// Set the config on the device
|
||||
(device as ReconfigurableDevice).SetConfig(deviceConfig);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(1, "FusionCustomPropetiesBridge: Error mapping properties: {0}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
namespace PepperDash.Essentials.Core.Fusion
|
||||
{
|
||||
public class ScheduleChangeEventArgs : EventArgs
|
||||
{
|
||||
public RoomSchedule Schedule { get; set; }
|
||||
}
|
||||
|
||||
public class MeetingChangeEventArgs : EventArgs
|
||||
{
|
||||
public Event Meeting { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core.Fusion
|
||||
{
|
||||
/// <summary>
|
||||
/// When created, runs progcomments on every slot and stores the program names in a list
|
||||
/// </summary>
|
||||
public class ProcessorProgReg
|
||||
{
|
||||
//public static Dictionary<int, ProcessorProgramItem> Programs { get; private set; }
|
||||
|
||||
public static Dictionary<int, ProcessorProgramItem> GetProcessorProgReg()
|
||||
{
|
||||
var programs = new Dictionary<int, ProcessorProgramItem>();
|
||||
for (int i = 1; i <= Global.ControlSystem.NumProgramsSupported; i++)
|
||||
{
|
||||
string response = null;
|
||||
var success = CrestronConsole.SendControlSystemCommand("progcomments:" + i, ref response);
|
||||
var item = new ProcessorProgramItem();
|
||||
if (!success)
|
||||
item.Name = "Error: PROGCOMMENTS failed";
|
||||
else
|
||||
{
|
||||
if (response.ToLower().Contains("bad or incomplete"))
|
||||
item.Name = "";
|
||||
else
|
||||
{
|
||||
var startPos = response.IndexOf("Program File");
|
||||
var colonPos = response.IndexOf(":", startPos) + 1;
|
||||
var endPos = response.IndexOf(CrestronEnvironment.NewLine, colonPos);
|
||||
item.Name = response.Substring(colonPos, endPos - colonPos).Trim();
|
||||
item.Exists = true;
|
||||
if (item.Name.Contains(".dll"))
|
||||
{
|
||||
startPos = response.IndexOf("Compiler Revision");
|
||||
colonPos = response.IndexOf(":", startPos) + 1;
|
||||
endPos = response.IndexOf(CrestronEnvironment.NewLine, colonPos);
|
||||
item.Name = item.Name + "_v" + response.Substring(colonPos, endPos - colonPos).Trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
programs[i] = item;
|
||||
Debug.Console(1, "Program {0}: {1}", i, item.Name);
|
||||
}
|
||||
return programs;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used in ProcessorProgReg
|
||||
/// </summary>
|
||||
public class ProcessorProgramItem
|
||||
{
|
||||
public bool Exists { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,499 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro.Fusion;
|
||||
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core.Fusion
|
||||
{
|
||||
// Helper Classes for GUIDs
|
||||
|
||||
/// <summary>
|
||||
/// Stores GUIDs to be written to a file in NVRAM
|
||||
/// </summary>
|
||||
public class FusionRoomGuids
|
||||
{
|
||||
public string RoomName { get; set; }
|
||||
public uint IpId { get; set; }
|
||||
public string RoomGuid { get; set; }
|
||||
public FusionOccupancySensorAsset OccupancyAsset { get; set; }
|
||||
public Dictionary<int, FusionAsset> StaticAssets { get; set; }
|
||||
|
||||
public FusionRoomGuids()
|
||||
{
|
||||
StaticAssets = new Dictionary<int, FusionAsset>();
|
||||
OccupancyAsset = new FusionOccupancySensorAsset();
|
||||
}
|
||||
|
||||
public FusionRoomGuids(string roomName, uint ipId, string roomGuid, Dictionary<int, FusionAsset> staticAssets)
|
||||
{
|
||||
RoomName = roomName;
|
||||
IpId = ipId;
|
||||
RoomGuid = roomGuid;
|
||||
|
||||
StaticAssets = staticAssets;
|
||||
OccupancyAsset = new FusionOccupancySensorAsset();
|
||||
}
|
||||
|
||||
public FusionRoomGuids(string roomName, uint ipId, string roomGuid, Dictionary<int, FusionAsset> staticAssets, FusionOccupancySensorAsset occAsset)
|
||||
{
|
||||
RoomName = roomName;
|
||||
IpId = ipId;
|
||||
RoomGuid = roomGuid;
|
||||
|
||||
StaticAssets = staticAssets;
|
||||
OccupancyAsset = occAsset;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a new room GUID prefixed by the program slot number and NIC MAC address
|
||||
/// </summary>
|
||||
/// <param name="progSlot"></param>
|
||||
/// <param name="mac"></param>
|
||||
public string GenerateNewRoomGuid(uint progSlot, string mac)
|
||||
{
|
||||
Guid roomGuid = Guid.NewGuid();
|
||||
|
||||
return string.Format("{0}-{1}-{2}", progSlot, mac, roomGuid.ToString());
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Adds an asset to the StaticAssets collection and returns the new asset
|
||||
/// </summary>
|
||||
/// <param name="room"></param>
|
||||
/// <param name="uid"></param>
|
||||
/// <param name="assetName"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="instanceId"></param>
|
||||
/// <returns></returns>
|
||||
public FusionAsset AddStaticAsset(FusionRoom room, int uid, string assetName, string type, string instanceId)
|
||||
{
|
||||
var slotNum = GetNextAvailableAssetNumber(room);
|
||||
|
||||
Debug.Console(2, "Adding Fusion Asset: {0} of Type: {1} at Slot Number: {2} with GUID: {3}", assetName, type, slotNum, instanceId);
|
||||
|
||||
var tempAsset = new FusionAsset(slotNum, assetName, type, instanceId);
|
||||
|
||||
StaticAssets.Add(uid, tempAsset);
|
||||
|
||||
return tempAsset;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the next available slot number in the Fusion UserConfigurableAssetDetails collection
|
||||
/// </summary>
|
||||
/// <param name="room"></param>
|
||||
/// <returns></returns>
|
||||
public static uint GetNextAvailableAssetNumber(FusionRoom room)
|
||||
{
|
||||
uint slotNum = 0;
|
||||
|
||||
foreach (var item in room.UserConfigurableAssetDetails)
|
||||
{
|
||||
if(item.Number > slotNum)
|
||||
slotNum = item.Number;
|
||||
}
|
||||
|
||||
if (slotNum < 5)
|
||||
{
|
||||
slotNum = 5;
|
||||
}
|
||||
else
|
||||
slotNum = slotNum + 1;
|
||||
|
||||
Debug.Console(2, "#Next available fusion asset number is: {0}", slotNum);
|
||||
|
||||
return slotNum;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class FusionOccupancySensorAsset
|
||||
{
|
||||
// SlotNumber fixed at 4
|
||||
|
||||
public uint SlotNumber { get { return 4; } }
|
||||
public string Name { get { return "Occupancy Sensor"; } }
|
||||
public eAssetType Type { get; set; }
|
||||
public string InstanceId { get; set; }
|
||||
|
||||
public FusionOccupancySensorAsset()
|
||||
{
|
||||
}
|
||||
|
||||
public FusionOccupancySensorAsset(eAssetType type)
|
||||
{
|
||||
Type = type;
|
||||
|
||||
InstanceId = Guid.NewGuid().ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public class FusionAsset
|
||||
{
|
||||
public uint SlotNumber { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string InstanceId { get;set; }
|
||||
|
||||
public FusionAsset()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public FusionAsset(uint slotNum, string assetName, string type, string instanceId)
|
||||
{
|
||||
SlotNumber = slotNum;
|
||||
Name = assetName;
|
||||
Type = type;
|
||||
if (string.IsNullOrEmpty(instanceId))
|
||||
{
|
||||
InstanceId = Guid.NewGuid().ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
InstanceId = instanceId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//***************************************************************************************************
|
||||
|
||||
public class RoomSchedule
|
||||
{
|
||||
public List<Event> Meetings { get; set; }
|
||||
|
||||
public RoomSchedule()
|
||||
{
|
||||
Meetings = new List<Event>();
|
||||
}
|
||||
}
|
||||
|
||||
//****************************************************************************************************
|
||||
// Helper Classes for XML API
|
||||
|
||||
/// <summary>
|
||||
/// Data needed to request the local time from the Fusion server
|
||||
/// </summary>
|
||||
public class LocalTimeRequest
|
||||
{
|
||||
public string RequestID { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// All the data needed for a full schedule request in a room
|
||||
/// </summary>
|
||||
/// //[XmlRoot(ElementName = "RequestSchedule")]
|
||||
public class RequestSchedule
|
||||
{
|
||||
//[XmlElement(ElementName = "RequestID")]
|
||||
public string RequestID { get; set; }
|
||||
//[XmlElement(ElementName = "RoomID")]
|
||||
public string RoomID { get; set; }
|
||||
//[XmlElement(ElementName = "Start")]
|
||||
public DateTime Start { get; set; }
|
||||
//[XmlElement(ElementName = "HourSpan")]
|
||||
public double HourSpan { get; set; }
|
||||
|
||||
public RequestSchedule(string requestID, string roomID)
|
||||
{
|
||||
RequestID = requestID;
|
||||
RoomID = roomID;
|
||||
Start = DateTime.Now;
|
||||
HourSpan = 24;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//[XmlRoot(ElementName = "RequestAction")]
|
||||
public class RequestAction
|
||||
{
|
||||
//[XmlElement(ElementName = "RequestID")]
|
||||
public string RequestID { get; set; }
|
||||
//[XmlElement(ElementName = "RoomID")]
|
||||
public string RoomID { get; set; }
|
||||
//[XmlElement(ElementName = "ActionID")]
|
||||
public string ActionID { get; set; }
|
||||
//[XmlElement(ElementName = "Parameters")]
|
||||
public List<Parameter> Parameters { get; set; }
|
||||
|
||||
public RequestAction(string roomID, string actionID, List<Parameter> parameters)
|
||||
{
|
||||
RoomID = roomID;
|
||||
ActionID = actionID;
|
||||
Parameters = parameters;
|
||||
}
|
||||
}
|
||||
|
||||
//[XmlRoot(ElementName = "ActionResponse")]
|
||||
public class ActionResponse
|
||||
{
|
||||
//[XmlElement(ElementName = "RequestID")]
|
||||
public string RequestID { get; set; }
|
||||
//[XmlElement(ElementName = "ActionID")]
|
||||
public string ActionID { get; set; }
|
||||
//[XmlElement(ElementName = "Parameters")]
|
||||
public List<Parameter> Parameters { get; set; }
|
||||
}
|
||||
|
||||
//[XmlRoot(ElementName = "Parameter")]
|
||||
public class Parameter
|
||||
{
|
||||
//[XmlAttribute(AttributeName = "ID")]
|
||||
public string ID { get; set; }
|
||||
//[XmlAttribute(AttributeName = "Value")]
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
////[XmlRoot(ElementName = "Parameters")]
|
||||
//public class Parameters
|
||||
//{
|
||||
// //[XmlElement(ElementName = "Parameter")]
|
||||
// public List<Parameter> Parameter { get; set; }
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Data structure for a ScheduleResponse from Fusion
|
||||
/// </summary>
|
||||
/// //[XmlRoot(ElementName = "ScheduleResponse")]
|
||||
public class ScheduleResponse
|
||||
{
|
||||
//[XmlElement(ElementName = "RequestID")]
|
||||
public string RequestID { get; set; }
|
||||
//[XmlElement(ElementName = "RoomID")]
|
||||
public string RoomID { get; set; }
|
||||
//[XmlElement(ElementName = "RoomName")]
|
||||
public string RoomName { get; set; }
|
||||
//[XmlElement("Event")]
|
||||
public List<Event> Events { get; set; }
|
||||
|
||||
public ScheduleResponse()
|
||||
{
|
||||
Events = new List<Event>();
|
||||
}
|
||||
}
|
||||
|
||||
//[XmlRoot(ElementName = "Event")]
|
||||
public class Event
|
||||
{
|
||||
//[XmlElement(ElementName = "MeetingID")]
|
||||
public string MeetingID { get; set; }
|
||||
//[XmlElement(ElementName = "RVMeetingID")]
|
||||
public string RVMeetingID { get; set; }
|
||||
//[XmlElement(ElementName = "Recurring")]
|
||||
public string Recurring { get; set; }
|
||||
//[XmlElement(ElementName = "InstanceID")]
|
||||
public string InstanceID { get; set; }
|
||||
//[XmlElement(ElementName = "dtStart")]
|
||||
public DateTime dtStart { get; set; }
|
||||
//[XmlElement(ElementName = "dtEnd")]
|
||||
public DateTime dtEnd { get; set; }
|
||||
//[XmlElement(ElementName = "Organizer")]
|
||||
public string Organizer { get; set; }
|
||||
//[XmlElement(ElementName = "Attendees")]
|
||||
public Attendees Attendees { get; set; }
|
||||
//[XmlElement(ElementName = "Resources")]
|
||||
public Resources Resources { get; set; }
|
||||
//[XmlElement(ElementName = "IsEvent")]
|
||||
public string IsEvent { get; set; }
|
||||
//[XmlElement(ElementName = "IsRoomViewMeeting")]
|
||||
public string IsRoomViewMeeting { get; set; }
|
||||
//[XmlElement(ElementName = "IsPrivate")]
|
||||
public string IsPrivate { get; set; }
|
||||
//[XmlElement(ElementName = "IsExchangePrivate")]
|
||||
public string IsExchangePrivate { get; set; }
|
||||
//[XmlElement(ElementName = "MeetingTypes")]
|
||||
public MeetingTypes MeetingTypes { get; set; }
|
||||
//[XmlElement(ElementName = "ParticipantCode")]
|
||||
public string ParticipantCode { get; set; }
|
||||
//[XmlElement(ElementName = "PhoneNo")]
|
||||
public string PhoneNo { get; set; }
|
||||
//[XmlElement(ElementName = "WelcomeMsg")]
|
||||
public string WelcomeMsg { get; set; }
|
||||
//[XmlElement(ElementName = "Subject")]
|
||||
public string Subject { get; set; }
|
||||
//[XmlElement(ElementName = "LiveMeeting")]
|
||||
public LiveMeeting LiveMeeting { get; set; }
|
||||
//[XmlElement(ElementName = "ShareDocPath")]
|
||||
public string ShareDocPath { get; set; }
|
||||
//[XmlElement(ElementName = "HaveAttendees")]
|
||||
public string HaveAttendees { get; set; }
|
||||
//[XmlElement(ElementName = "HaveResources")]
|
||||
public string HaveResources { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the duration of the meeting
|
||||
/// </summary>
|
||||
public string DurationInMinutes
|
||||
{
|
||||
get
|
||||
{
|
||||
string duration;
|
||||
|
||||
var timeSpan = dtEnd.Subtract(dtStart);
|
||||
int hours = timeSpan.Hours;
|
||||
double minutes = timeSpan.Minutes;
|
||||
double roundedMinutes = Math.Round(minutes);
|
||||
if (hours > 0)
|
||||
{
|
||||
duration = string.Format("{0} hours {1} minutes", hours, roundedMinutes);
|
||||
}
|
||||
else
|
||||
{
|
||||
duration = string.Format("{0} minutes", roundedMinutes);
|
||||
}
|
||||
|
||||
return duration;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the remaining time in the meeting. Returns null if the meeting is not currently in progress.
|
||||
/// </summary>
|
||||
public string RemainingTime
|
||||
{
|
||||
get
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
|
||||
string remainingTime;
|
||||
|
||||
if (GetInProgress())
|
||||
{
|
||||
var timeSpan = dtEnd.Subtract(now);
|
||||
int hours = timeSpan.Hours;
|
||||
double minutes = timeSpan.Minutes;
|
||||
double roundedMinutes = Math.Round(minutes);
|
||||
if (hours > 0)
|
||||
{
|
||||
remainingTime = string.Format("{0} hours {1} minutes", hours, roundedMinutes);
|
||||
}
|
||||
else
|
||||
{
|
||||
remainingTime = string.Format("{0} minutes", roundedMinutes);
|
||||
}
|
||||
|
||||
return remainingTime;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the meeting is in progress
|
||||
/// </summary>
|
||||
public bool isInProgress
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetInProgress();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the meeting is in progress
|
||||
/// </summary>
|
||||
/// <returns>Returns true if in progress</returns>
|
||||
bool GetInProgress()
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
|
||||
if (now > dtStart && now < dtEnd)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//[XmlRoot(ElementName = "Resources")]
|
||||
public class Resources
|
||||
{
|
||||
//[XmlElement(ElementName = "Rooms")]
|
||||
public Rooms Rooms { get; set; }
|
||||
}
|
||||
|
||||
//[XmlRoot(ElementName = "Rooms")]
|
||||
public class Rooms
|
||||
{
|
||||
//[XmlElement(ElementName = "Room")]
|
||||
public List<Room> Room { get; set; }
|
||||
}
|
||||
|
||||
//[XmlRoot(ElementName = "Room")]
|
||||
public class Room
|
||||
{
|
||||
//[XmlElement(ElementName = "Name")]
|
||||
public string Name { get; set; }
|
||||
//[XmlElement(ElementName = "ID")]
|
||||
public string ID { get; set; }
|
||||
//[XmlElement(ElementName = "MPType")]
|
||||
public string MPType { get; set; }
|
||||
}
|
||||
|
||||
//[XmlRoot(ElementName = "Attendees")]
|
||||
public class Attendees
|
||||
{
|
||||
//[XmlElement(ElementName = "Required")]
|
||||
public Required Required { get; set; }
|
||||
//[XmlElement(ElementName = "Optional")]
|
||||
public Optional Optional { get; set; }
|
||||
}
|
||||
|
||||
//[XmlRoot(ElementName = "Required")]
|
||||
public class Required
|
||||
{
|
||||
//[XmlElement(ElementName = "Attendee")]
|
||||
public List<string> Attendee { get; set; }
|
||||
}
|
||||
|
||||
//[XmlRoot(ElementName = "Optional")]
|
||||
public class Optional
|
||||
{
|
||||
//[XmlElement(ElementName = "Attendee")]
|
||||
public List<string> Attendee { get; set; }
|
||||
}
|
||||
|
||||
//[XmlRoot(ElementName = "MeetingType")]
|
||||
public class MeetingType
|
||||
{
|
||||
//[XmlAttribute(AttributeName = "ID")]
|
||||
public string ID { get; set; }
|
||||
//[XmlAttribute(AttributeName = "Value")]
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
//[XmlRoot(ElementName = "MeetingTypes")]
|
||||
public class MeetingTypes
|
||||
{
|
||||
//[XmlElement(ElementName = "MeetingType")]
|
||||
public List<MeetingType> MeetingType { get; set; }
|
||||
}
|
||||
|
||||
//[XmlRoot(ElementName = "LiveMeeting")]
|
||||
public class LiveMeeting
|
||||
{
|
||||
//[XmlElement(ElementName = "URL")]
|
||||
public string URL { get; set; }
|
||||
//[XmlElement(ElementName = "ID")]
|
||||
public string ID { get; set; }
|
||||
//[XmlElement(ElementName = "Key")]
|
||||
public string Key { get; set; }
|
||||
//[XmlElement(ElementName = "Subject")]
|
||||
public string Subject { get; set; }
|
||||
}
|
||||
|
||||
//[XmlRoot(ElementName = "LiveMeetingURL")]
|
||||
public class LiveMeetingURL
|
||||
{
|
||||
//[XmlElement(ElementName = "LiveMeeting")]
|
||||
public LiveMeeting LiveMeeting { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,377 +0,0 @@
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using System.Text;
|
||||
|
||||
//using Crestron.SimplSharp;
|
||||
//using Crestron.SimplSharpPro;
|
||||
//using Crestron.SimplSharpPro.DeviceSupport;
|
||||
|
||||
//using Crestron.SimplSharpPro.Fusion;
|
||||
//using PepperDash.Essentials.Core;
|
||||
|
||||
//using PepperDash.Core;
|
||||
|
||||
|
||||
//namespace PepperDash.Essentials.Core.Fusion
|
||||
//{
|
||||
// public class EssentialsHuddleSpaceFusionSystemController : Device
|
||||
// {
|
||||
// FusionRoom FusionRoom;
|
||||
// Room Room;
|
||||
// Dictionary<IPresentationSource, BoolInputSig> SourceToFeedbackSigs = new Dictionary<IPresentationSource, BoolInputSig>();
|
||||
|
||||
// StatusMonitorCollection ErrorMessageRollUp;
|
||||
|
||||
// public EssentialsHuddleSpaceFusionSystemController(HuddleSpaceRoom room, uint ipId)
|
||||
// : base(room.Key + "-fusion")
|
||||
// {
|
||||
// Room = room;
|
||||
|
||||
// FusionRoom = new FusionRoom(ipId, Global.ControlSystem, room.Name, "awesomeGuid-" + room.Key);
|
||||
// FusionRoom.Register();
|
||||
|
||||
// FusionRoom.FusionStateChange += new FusionStateEventHandler(FusionRoom_FusionStateChange);
|
||||
|
||||
// // Room to fusion room
|
||||
// room.RoomIsOn.LinkInputSig(FusionRoom.SystemPowerOn.InputSig);
|
||||
// var srcName = FusionRoom.CreateOffsetStringSig(50, "Source - Name", eSigIoMask.InputSigOnly);
|
||||
// room.CurrentSourceName.LinkInputSig(srcName.InputSig);
|
||||
|
||||
// FusionRoom.SystemPowerOn.OutputSig.UserObject = new Action<bool>(b => { if (b) room.RoomOn(null); });
|
||||
// FusionRoom.SystemPowerOff.OutputSig.UserObject = new Action<bool>(b => { if (b) room.RoomOff(); });
|
||||
// // NO!! room.RoomIsOn.LinkComplementInputSig(FusionRoom.SystemPowerOff.InputSig);
|
||||
// FusionRoom.ErrorMessage.InputSig.StringValue = "3: 7 Errors: This is a really long error message;This is a really long error message;This is a really long error message;This is a really long error message;This is a really long error message;This is a really long error message;This is a really long error message;";
|
||||
|
||||
// // Sources
|
||||
// foreach (var src in room.Sources)
|
||||
// {
|
||||
// var srcNum = src.Key;
|
||||
// var pSrc = src.Value as IPresentationSource;
|
||||
// var keyNum = ExtractNumberFromKey(pSrc.Key);
|
||||
// if (keyNum == -1)
|
||||
// {
|
||||
// Debug.Console(1, this, "WARNING: Cannot link source '{0}' to numbered Fusion attributes", pSrc.Key);
|
||||
// continue;
|
||||
// }
|
||||
// string attrName = null;
|
||||
// uint attrNum = Convert.ToUInt32(keyNum);
|
||||
// switch (pSrc.Type)
|
||||
// {
|
||||
// case PresentationSourceType.None:
|
||||
// break;
|
||||
// case PresentationSourceType.SetTopBox:
|
||||
// attrName = "Source - TV " + keyNum;
|
||||
// attrNum += 115; // TV starts at 116
|
||||
// break;
|
||||
// case PresentationSourceType.Dvd:
|
||||
// attrName = "Source - DVD " + keyNum;
|
||||
// attrNum += 120; // DVD starts at 121
|
||||
// break;
|
||||
// case PresentationSourceType.PC:
|
||||
// attrName = "Source - PC " + keyNum;
|
||||
// attrNum += 110; // PC starts at 111
|
||||
// break;
|
||||
// case PresentationSourceType.Laptop:
|
||||
// attrName = "Source - Laptop " + keyNum;
|
||||
// attrNum += 100; // Laptops start at 101
|
||||
// break;
|
||||
// case PresentationSourceType.VCR:
|
||||
// attrName = "Source - VCR " + keyNum;
|
||||
// attrNum += 125; // VCRs start at 126
|
||||
// break;
|
||||
// }
|
||||
// if (attrName == null)
|
||||
// {
|
||||
// Debug.Console(1, this, "Source type {0} does not have corresponsing Fusion attribute type, skipping", pSrc.Type);
|
||||
// continue;
|
||||
// }
|
||||
// Debug.Console(2, this, "Creating attribute '{0}' with join {1} for source {2}", attrName, attrNum, pSrc.Key);
|
||||
// var sigD = FusionRoom.CreateOffsetBoolSig(attrNum, attrName, eSigIoMask.InputOutputSig);
|
||||
// // Need feedback when this source is selected
|
||||
// // Event handler, added below, will compare source changes with this sig dict
|
||||
// SourceToFeedbackSigs.Add(pSrc, sigD.InputSig);
|
||||
|
||||
// // And respond to selection in Fusion
|
||||
// sigD.OutputSig.UserObject = new Action<bool>(b => { if(b) room.SelectSource(pSrc); });
|
||||
// }
|
||||
|
||||
// // Attach to all room's devices with monitors.
|
||||
// //foreach (var dev in DeviceManager.Devices)
|
||||
// foreach (var dev in DeviceManager.GetDevices())
|
||||
// {
|
||||
// if (!(dev is ICommunicationMonitor))
|
||||
// continue;
|
||||
|
||||
// var keyNum = ExtractNumberFromKey(dev.Key);
|
||||
// if (keyNum == -1)
|
||||
// {
|
||||
// Debug.Console(1, this, "WARNING: Cannot link device '{0}' to numbered Fusion monitoring attributes", dev.Key);
|
||||
// continue;
|
||||
// }
|
||||
// string attrName = null;
|
||||
// uint attrNum = Convert.ToUInt32(keyNum);
|
||||
|
||||
// //if (dev is SmartGraphicsTouchpanelControllerBase)
|
||||
// //{
|
||||
// // if (attrNum > 10)
|
||||
// // continue;
|
||||
// // attrName = "Device Ok - Touch Panel " + attrNum;
|
||||
// // attrNum += 200;
|
||||
// //}
|
||||
// //// add xpanel here
|
||||
|
||||
// //else
|
||||
// if (dev is DisplayBase)
|
||||
// {
|
||||
// if (attrNum > 10)
|
||||
// continue;
|
||||
// attrName = "Device Ok - Display " + attrNum;
|
||||
// attrNum += 240;
|
||||
// }
|
||||
// //else if (dev is DvdDeviceBase)
|
||||
// //{
|
||||
// // if (attrNum > 5)
|
||||
// // continue;
|
||||
// // attrName = "Device Ok - DVD " + attrNum;
|
||||
// // attrNum += 260;
|
||||
// //}
|
||||
// // add set top box
|
||||
|
||||
// // add Cresnet roll-up
|
||||
|
||||
// // add DM-devices roll-up
|
||||
|
||||
// if (attrName != null)
|
||||
// {
|
||||
// // Link comm status to sig and update
|
||||
// var sigD = FusionRoom.CreateOffsetBoolSig(attrNum, attrName, eSigIoMask.InputSigOnly);
|
||||
// var smd = dev as ICommunicationMonitor;
|
||||
// sigD.InputSig.BoolValue = smd.CommunicationMonitor.Status == MonitorStatus.IsOk;
|
||||
// smd.CommunicationMonitor.StatusChange += (o, a) => { sigD.InputSig.BoolValue = a.Status == MonitorStatus.IsOk; };
|
||||
// Debug.Console(0, this, "Linking '{0}' communication monitor to Fusion '{1}'", dev.Key, attrName);
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Don't think we need to get current status of this as nothing should be alive yet.
|
||||
// room.PresentationSourceChange += Room_PresentationSourceChange;
|
||||
|
||||
// // these get used in multiple places
|
||||
// var display = room.Display;
|
||||
// var dispPowerOnAction = new Action<bool>(b => { if (!b) display.PowerOn(); });
|
||||
// var dispPowerOffAction = new Action<bool>(b => { if (!b) display.PowerOff(); });
|
||||
|
||||
// // Display to fusion room sigs
|
||||
// FusionRoom.DisplayPowerOn.OutputSig.UserObject = dispPowerOnAction;
|
||||
// FusionRoom.DisplayPowerOff.OutputSig.UserObject = dispPowerOffAction;
|
||||
// display.PowerIsOnFeedback.LinkInputSig(FusionRoom.DisplayPowerOn.InputSig);
|
||||
// if (display is IDisplayUsage)
|
||||
// (display as IDisplayUsage).LampHours.LinkInputSig(FusionRoom.DisplayUsage.InputSig);
|
||||
|
||||
// // Roll up ALL device errors
|
||||
// ErrorMessageRollUp = new StatusMonitorCollection(this);
|
||||
// foreach (var dev in DeviceManager.GetDevices())
|
||||
// {
|
||||
// var md = dev as ICommunicationMonitor;
|
||||
// if (md != null)
|
||||
// {
|
||||
// ErrorMessageRollUp.AddMonitor(md.CommunicationMonitor);
|
||||
// Debug.Console(2, this, "Adding '{0}' to room's overall error monitor", md.CommunicationMonitor.Parent.Key);
|
||||
// }
|
||||
// }
|
||||
// ErrorMessageRollUp.Start();
|
||||
// FusionRoom.ErrorMessage.InputSig.StringValue = ErrorMessageRollUp.Message;
|
||||
// ErrorMessageRollUp.StatusChange += (o, a) => {
|
||||
// FusionRoom.ErrorMessage.InputSig.StringValue = ErrorMessageRollUp.Message; };
|
||||
|
||||
|
||||
// // static assets --------------- testing
|
||||
|
||||
// // test assets --- THESE ARE BOTH WIRED TO AssetUsage somewhere internally.
|
||||
// var ta1 = FusionRoom.CreateStaticAsset(1, "Test asset 1", "Awesome Asset", "Awesome123");
|
||||
// ta1.AssetError.InputSig.StringValue = "This should be error";
|
||||
|
||||
|
||||
// var ta2 = FusionRoom.CreateStaticAsset(2, "Test asset 2", "Awesome Asset", "Awesome1232");
|
||||
// ta2.AssetUsage.InputSig.StringValue = "This should be usage";
|
||||
|
||||
|
||||
// // Make a display asset
|
||||
// var dispAsset = FusionRoom.CreateStaticAsset(3, display.Name, "Display", "awesomeDisplayId" + room.Key);
|
||||
// dispAsset.PowerOn.OutputSig.UserObject = dispPowerOnAction;
|
||||
// dispAsset.PowerOff.OutputSig.UserObject = dispPowerOffAction;
|
||||
// display.PowerIsOnFeedback.LinkInputSig(dispAsset.PowerOn.InputSig);
|
||||
// // NO!! display.PowerIsOn.LinkComplementInputSig(dispAsset.PowerOff.InputSig);
|
||||
// // Use extension methods
|
||||
// dispAsset.TrySetMakeModel(display);
|
||||
// dispAsset.TryLinkAssetErrorToCommunication(display);
|
||||
|
||||
|
||||
// // Make it so!
|
||||
// FusionRVI.GenerateFileForAllFusionDevices();
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// Helper to get the number from the end of a device's key string
|
||||
// /// </summary>
|
||||
// /// <returns>-1 if no number matched</returns>
|
||||
// int ExtractNumberFromKey(string key)
|
||||
// {
|
||||
// var capture = System.Text.RegularExpressions.Regex.Match(key, @"\D+(\d+)");
|
||||
// if (!capture.Success)
|
||||
// return -1;
|
||||
// else return Convert.ToInt32(capture.Groups[1].Value);
|
||||
// }
|
||||
|
||||
// void Room_PresentationSourceChange(object sender, EssentialsRoomSourceChangeEventArgs e)
|
||||
// {
|
||||
// if (e.OldSource != null)
|
||||
// {
|
||||
// if (SourceToFeedbackSigs.ContainsKey(e.OldSource))
|
||||
// SourceToFeedbackSigs[e.OldSource].BoolValue = false;
|
||||
// }
|
||||
// if (e.NewSource != null)
|
||||
// {
|
||||
// if (SourceToFeedbackSigs.ContainsKey(e.NewSource))
|
||||
// SourceToFeedbackSigs[e.NewSource].BoolValue = true;
|
||||
// }
|
||||
// }
|
||||
|
||||
// void FusionRoom_FusionStateChange(FusionBase device, FusionStateEventArgs args)
|
||||
// {
|
||||
|
||||
// // The sig/UO method: Need separate handlers for fixed and user sigs, all flavors,
|
||||
// // even though they all contain sigs.
|
||||
|
||||
// var sigData = (args.UserConfiguredSigDetail as BooleanSigDataFixedName);
|
||||
// if (sigData != null)
|
||||
// {
|
||||
// var outSig = sigData.OutputSig;
|
||||
// if (outSig.UserObject is Action<bool>)
|
||||
// (outSig.UserObject as Action<bool>).Invoke(outSig.BoolValue);
|
||||
// else if (outSig.UserObject is Action<ushort>)
|
||||
// (outSig.UserObject as Action<ushort>).Invoke(outSig.UShortValue);
|
||||
// else if (outSig.UserObject is Action<string>)
|
||||
// (outSig.UserObject as Action<string>).Invoke(outSig.StringValue);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// var attrData = (args.UserConfiguredSigDetail as BooleanSigData);
|
||||
// if (attrData != null)
|
||||
// {
|
||||
// var outSig = attrData.OutputSig;
|
||||
// if (outSig.UserObject is Action<bool>)
|
||||
// (outSig.UserObject as Action<bool>).Invoke(outSig.BoolValue);
|
||||
// else if (outSig.UserObject is Action<ushort>)
|
||||
// (outSig.UserObject as Action<ushort>).Invoke(outSig.UShortValue);
|
||||
// else if (outSig.UserObject is Action<string>)
|
||||
// (outSig.UserObject as Action<string>).Invoke(outSig.StringValue);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// public static class FusionRoomExtensions
|
||||
// {
|
||||
// /// <summary>
|
||||
// /// Creates and returns a fusion attribute. The join number will match the established Simpl
|
||||
// /// standard of 50+, and will generate a 50+ join in the RVI. It calls
|
||||
// /// FusionRoom.AddSig with join number - 49
|
||||
// /// </summary>
|
||||
// /// <returns>The new attribute</returns>
|
||||
// public static BooleanSigData CreateOffsetBoolSig(this FusionRoom fr, uint number, string name, eSigIoMask mask)
|
||||
// {
|
||||
// if (number < 50) throw new ArgumentOutOfRangeException("number", "Cannot be less than 50");
|
||||
// number -= 49;
|
||||
// fr.AddSig(eSigType.Bool, number, name, mask);
|
||||
// return fr.UserDefinedBooleanSigDetails[number];
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// Creates and returns a fusion attribute. The join number will match the established Simpl
|
||||
// /// standard of 50+, and will generate a 50+ join in the RVI. It calls
|
||||
// /// FusionRoom.AddSig with join number - 49
|
||||
// /// </summary>
|
||||
// /// <returns>The new attribute</returns>
|
||||
// public static UShortSigData CreateOffsetUshortSig(this FusionRoom fr, uint number, string name, eSigIoMask mask)
|
||||
// {
|
||||
// if (number < 50) throw new ArgumentOutOfRangeException("number", "Cannot be less than 50");
|
||||
// number -= 49;
|
||||
// fr.AddSig(eSigType.UShort, number, name, mask);
|
||||
// return fr.UserDefinedUShortSigDetails[number];
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// Creates and returns a fusion attribute. The join number will match the established Simpl
|
||||
// /// standard of 50+, and will generate a 50+ join in the RVI. It calls
|
||||
// /// FusionRoom.AddSig with join number - 49
|
||||
// /// </summary>
|
||||
// /// <returns>The new attribute</returns>
|
||||
// public static StringSigData CreateOffsetStringSig(this FusionRoom fr, uint number, string name, eSigIoMask mask)
|
||||
// {
|
||||
// if (number < 50) throw new ArgumentOutOfRangeException("number", "Cannot be less than 50");
|
||||
// number -= 49;
|
||||
// fr.AddSig(eSigType.String, number, name, mask);
|
||||
// return fr.UserDefinedStringSigDetails[number];
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// Creates and returns a static asset
|
||||
// /// </summary>
|
||||
// /// <returns>the new asset</returns>
|
||||
// public static FusionStaticAsset CreateStaticAsset(this FusionRoom fr, uint number, string name, string type, string instanceId)
|
||||
// {
|
||||
// fr.AddAsset(eAssetType.StaticAsset, number, name, type, instanceId);
|
||||
// return fr.UserConfigurableAssetDetails[number].Asset as FusionStaticAsset;
|
||||
// }
|
||||
// }
|
||||
|
||||
// //************************************************************************************************
|
||||
// /// <summary>
|
||||
// /// Extensions to enhance Fusion room, asset and signal creation.
|
||||
// /// </summary>
|
||||
// public static class FusionStaticAssetExtensions
|
||||
// {
|
||||
// /// <summary>
|
||||
// /// Tries to set a Fusion asset with the make and model of a device.
|
||||
// /// If the provided Device is IMakeModel, will set the corresponding parameters on the fusion static asset.
|
||||
// /// Otherwise, does nothing.
|
||||
// /// </summary>
|
||||
// public static void TrySetMakeModel(this FusionStaticAsset asset, Device device)
|
||||
// {
|
||||
// var mm = device as IMakeModel;
|
||||
// if (mm != null)
|
||||
// {
|
||||
// asset.ParamMake.Value = mm.DeviceMake;
|
||||
// asset.ParamModel.Value = mm.DeviceModel;
|
||||
// }
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// Tries to attach the AssetError input on a Fusion asset to a Device's
|
||||
// /// CommunicationMonitor.StatusChange event. Does nothing if the device is not
|
||||
// /// IStatusMonitor
|
||||
// /// </summary>
|
||||
// /// <param name="asset"></param>
|
||||
// /// <param name="device"></param>
|
||||
// public static void TryLinkAssetErrorToCommunication(this FusionStaticAsset asset, Device device)
|
||||
// {
|
||||
// if (device is ICommunicationMonitor)
|
||||
// {
|
||||
// var monitor = (device as ICommunicationMonitor).CommunicationMonitor;
|
||||
// monitor.StatusChange += (o, a) =>
|
||||
// {
|
||||
// // Link connected and error inputs on asset
|
||||
// asset.Connected.InputSig.BoolValue = a.Status == MonitorStatus.IsOk;
|
||||
// asset.AssetError.InputSig.StringValue = a.Status.ToString();
|
||||
// };
|
||||
// // set current value
|
||||
// asset.Connected.InputSig.BoolValue = monitor.Status == MonitorStatus.IsOk;
|
||||
// asset.AssetError.InputSig.StringValue = monitor.Status.ToString();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
//}
|
||||
@@ -0,0 +1,228 @@
|
||||
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.Core.CrestronIO;
|
||||
|
||||
|
||||
namespace PepperDash.Essentials.Core.Privacy
|
||||
{
|
||||
/// <summary>
|
||||
/// Used for applications where one or more microphones with momentary contact closure outputs are used to
|
||||
/// toggle the privacy state of the room. Privacy state feedback is represented
|
||||
/// </summary>
|
||||
public class MicrophonePrivacyController : Device
|
||||
{
|
||||
MicrophonePrivacyControllerConfig Config;
|
||||
|
||||
bool initialized;
|
||||
|
||||
public bool EnableLeds
|
||||
{
|
||||
get
|
||||
{
|
||||
return _enableLeds;
|
||||
}
|
||||
set
|
||||
{
|
||||
_enableLeds = value;
|
||||
|
||||
if (initialized)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
CheckPrivacyMode();
|
||||
SetLedStates();
|
||||
}
|
||||
else
|
||||
TurnOffAllLeds();
|
||||
}
|
||||
}
|
||||
}
|
||||
bool _enableLeds;
|
||||
|
||||
public List<IDigitalInput> Inputs { get; private set; }
|
||||
|
||||
public GenericRelayDevice RedLedRelay { get; private set; }
|
||||
bool _redLedRelayState;
|
||||
|
||||
public GenericRelayDevice GreenLedRelay { get; private set; }
|
||||
bool _greenLedRelayState;
|
||||
|
||||
public IPrivacy PrivacyDevice { get; private set; }
|
||||
|
||||
public MicrophonePrivacyController(string key, MicrophonePrivacyControllerConfig config) :
|
||||
base(key)
|
||||
{
|
||||
Config = config;
|
||||
|
||||
Inputs = new List<IDigitalInput>();
|
||||
}
|
||||
|
||||
public override bool CustomActivate()
|
||||
{
|
||||
foreach (var i in Config.Inputs)
|
||||
{
|
||||
var input = DeviceManager.GetDeviceForKey(i.DeviceKey) as IDigitalInput;
|
||||
|
||||
if(input != null)
|
||||
AddInput(input);
|
||||
}
|
||||
|
||||
var greenLed = DeviceManager.GetDeviceForKey(Config.GreenLedRelay.DeviceKey) as GenericRelayDevice;
|
||||
|
||||
if (greenLed != null)
|
||||
GreenLedRelay = greenLed;
|
||||
else
|
||||
Debug.Console(0, this, "Unable to add Green LED device");
|
||||
|
||||
var redLed = DeviceManager.GetDeviceForKey(Config.RedLedRelay.DeviceKey) as GenericRelayDevice;
|
||||
|
||||
if (redLed != null)
|
||||
RedLedRelay = redLed;
|
||||
else
|
||||
Debug.Console(0, this, "Unable to add Red LED device");
|
||||
|
||||
AddPostActivationAction(() => {
|
||||
CheckPrivacyMode();
|
||||
PrivacyDevice.PrivacyModeIsOnFeedback.OutputChange -= PrivacyModeIsOnFeedback_OutputChange;
|
||||
PrivacyDevice.PrivacyModeIsOnFeedback.OutputChange += PrivacyModeIsOnFeedback_OutputChange;
|
||||
});
|
||||
|
||||
initialized = true;
|
||||
|
||||
return base.CustomActivate();
|
||||
}
|
||||
|
||||
public void SetPrivacyDevice(IPrivacy privacyDevice)
|
||||
{
|
||||
PrivacyDevice = privacyDevice;
|
||||
}
|
||||
|
||||
void PrivacyModeIsOnFeedback_OutputChange(object sender, EventArgs e)
|
||||
{
|
||||
Debug.Console(1, this, "Privacy mode change: {0}", sender as BoolFeedback);
|
||||
CheckPrivacyMode();
|
||||
}
|
||||
|
||||
void CheckPrivacyMode()
|
||||
{
|
||||
if (PrivacyDevice != null)
|
||||
{
|
||||
var privacyState = PrivacyDevice.PrivacyModeIsOnFeedback.BoolValue;
|
||||
|
||||
if (privacyState)
|
||||
TurnOnRedLeds();
|
||||
else
|
||||
TurnOnGreenLeds();
|
||||
}
|
||||
}
|
||||
|
||||
void AddInput(IDigitalInput input)
|
||||
{
|
||||
Inputs.Add(input);
|
||||
|
||||
input.InputStateFeedback.OutputChange += InputStateFeedback_OutputChange;
|
||||
}
|
||||
|
||||
void RemoveInput(IDigitalInput input)
|
||||
{
|
||||
var tempInput = Inputs.FirstOrDefault(i => i.Equals(input));
|
||||
|
||||
if (tempInput != null)
|
||||
tempInput.InputStateFeedback.OutputChange -= InputStateFeedback_OutputChange;
|
||||
|
||||
Inputs.Remove(input);
|
||||
}
|
||||
|
||||
void SetRedLedRelay(GenericRelayDevice relay)
|
||||
{
|
||||
RedLedRelay = relay;
|
||||
}
|
||||
|
||||
void SetGreenLedRelay(GenericRelayDevice relay)
|
||||
{
|
||||
GreenLedRelay = relay;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check the state of the input change and handle accordingly
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void InputStateFeedback_OutputChange(object sender, EventArgs e)
|
||||
{
|
||||
if ((sender as BoolFeedback).BoolValue == true)
|
||||
TogglePrivacyMute();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Toggles the state of the privacy mute
|
||||
/// </summary>
|
||||
public void TogglePrivacyMute()
|
||||
{
|
||||
PrivacyDevice.PrivacyModeToggle();
|
||||
}
|
||||
|
||||
void TurnOnRedLeds()
|
||||
{
|
||||
_greenLedRelayState = false;
|
||||
_redLedRelayState = true;
|
||||
SetLedStates();
|
||||
}
|
||||
|
||||
void TurnOnGreenLeds()
|
||||
{
|
||||
_redLedRelayState = false;
|
||||
_greenLedRelayState = true;
|
||||
SetLedStates();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If enabled, sets the actual state of the relays
|
||||
/// </summary>
|
||||
void SetLedStates()
|
||||
{
|
||||
if (_enableLeds)
|
||||
{
|
||||
SetRelayStates();
|
||||
}
|
||||
else
|
||||
TurnOffAllLeds();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Turns off all LEDs
|
||||
/// </summary>
|
||||
void TurnOffAllLeds()
|
||||
{
|
||||
_redLedRelayState = false;
|
||||
_greenLedRelayState = false;
|
||||
|
||||
SetRelayStates();
|
||||
}
|
||||
|
||||
void SetRelayStates()
|
||||
{
|
||||
if (RedLedRelay != null)
|
||||
{
|
||||
if (_redLedRelayState)
|
||||
RedLedRelay.CloseRelay();
|
||||
else
|
||||
RedLedRelay.OpenRelay();
|
||||
}
|
||||
|
||||
if(GreenLedRelay != null)
|
||||
{
|
||||
if (_greenLedRelayState)
|
||||
GreenLedRelay.CloseRelay();
|
||||
else
|
||||
GreenLedRelay.OpenRelay();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
using PepperDash.Essentials.Core.CrestronIO;
|
||||
|
||||
namespace PepperDash.Essentials.Core.Privacy
|
||||
{
|
||||
public class MicrophonePrivacyControllerConfig
|
||||
{
|
||||
public List<KeyedDevice> Inputs { get; set; }
|
||||
public KeyedDevice GreenLedRelay { get; set; }
|
||||
public KeyedDevice RedLedRelay { get; set; }
|
||||
}
|
||||
|
||||
public class KeyedDevice
|
||||
{
|
||||
public string DeviceKey { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -123,6 +123,8 @@
|
||||
<Compile Include="Devices\CodecInterfaces.cs" />
|
||||
<Compile Include="Devices\CrestronProcessor.cs" />
|
||||
<Compile Include="Devices\DeviceApiBase.cs" />
|
||||
<Compile Include="Devices\PC\InRoomPc.cs" />
|
||||
<Compile Include="Devices\PC\Laptop.cs" />
|
||||
<Compile Include="Devices\ReconfigurableDevice.cs" />
|
||||
<Compile Include="Devices\VolumeDeviceChangeEventArgs.cs" />
|
||||
<Compile Include="Factory\DeviceFactory.cs" />
|
||||
@@ -132,12 +134,19 @@
|
||||
<Compile Include="Feedbacks\IntFeedback.cs" />
|
||||
<Compile Include="Feedbacks\SerialFeedback.cs" />
|
||||
<Compile Include="Feedbacks\StringFeedback.cs" />
|
||||
<Compile Include="Fusion\EssentialsHuddleSpaceFusionSystemControllerBase.cs" />
|
||||
<Compile Include="Fusion\FusionCustomPropertiesBridge.cs" />
|
||||
<Compile Include="Fusion\FusionEventHandlers.cs" />
|
||||
<Compile Include="Fusion\FusionProcessorQueries.cs" />
|
||||
<Compile Include="Fusion\FusionRviDataClasses.cs" />
|
||||
<Compile Include="Global\JobTimer.cs" />
|
||||
<Compile Include="Global\Scheduler.cs" />
|
||||
<Compile Include="JoinMaps\JoinMapBase.cs" />
|
||||
<Compile Include="Lighting\Lighting Interfaces.cs" />
|
||||
<Compile Include="Lighting\LightingBase.cs" />
|
||||
<Compile Include="Monitoring\SystemMonitorController.cs" />
|
||||
<Compile Include="Microphone Privacy\MicrophonePrivacyController.cs" />
|
||||
<Compile Include="Microphone Privacy\MicrophonePrivacyControllerConfig.cs" />
|
||||
<Compile Include="Ramps and Increments\ActionIncrementer.cs" />
|
||||
<Compile Include="Comm and IR\CommFactory.cs" />
|
||||
<Compile Include="Comm and IR\CommunicationExtras.cs" />
|
||||
@@ -173,6 +182,10 @@
|
||||
<Compile Include="Feedbacks\BoolFeedbackOneShot.cs" />
|
||||
<Compile Include="Ramps and Increments\NumericalHelpers.cs" />
|
||||
<Compile Include="Ramps and Increments\UshortSigIncrementer.cs" />
|
||||
<Compile Include="Room\Behaviours\RoomOnToDefaultSourceWhenOccupied.cs" />
|
||||
<Compile Include="Room\EssentialsRoomBase.cs" />
|
||||
<Compile Include="Room\Interfaces.cs" />
|
||||
<Compile Include="Room\iOccupancyStatusProvider.cs" />
|
||||
<Compile Include="Routing\DummyRoutingInputsDevice.cs" />
|
||||
<Compile Include="Routing\ICardPortsDevice.cs" />
|
||||
<Compile Include="InUseTracking\IInUseTracking.cs" />
|
||||
@@ -191,7 +204,6 @@
|
||||
<Compile Include="Display\DELETE IRDisplayBase.cs" />
|
||||
<Compile Include="Display\MockDisplay.cs" />
|
||||
<Compile Include="Ethernet\EthernetStatistics.cs" />
|
||||
<Compile Include="Fusion\MOVED FusionSystemController.cs" />
|
||||
<Compile Include="Global\Global.cs" />
|
||||
<Compile Include="License\EssentialsLicenseManager.cs" />
|
||||
<Compile Include="Feedbacks\BoolOutputLogicals.cs" />
|
||||
@@ -217,6 +229,7 @@
|
||||
<Compile Include="Routing\TieLine.cs" />
|
||||
<Compile Include="Timers\CountdownTimer.cs" />
|
||||
<Compile Include="Touchpanels\CrestronTouchpanelPropertiesConfig.cs" />
|
||||
<Compile Include="Touchpanels\Interfaces.cs" />
|
||||
<Compile Include="Touchpanels\Keyboards\HabaneroKeyboardController.cs" />
|
||||
<Compile Include="Touchpanels\MOVED LargeTouchpanelControllerBase.cs" />
|
||||
<Compile Include="Touchpanels\TriListExtensions.cs" />
|
||||
@@ -238,7 +251,6 @@
|
||||
<Compile Include="Feedbacks\FeedbackBase.cs" />
|
||||
<Compile Include="Room\Room.cs" />
|
||||
<Compile Include="Room\RoomCues.cs" />
|
||||
<Compile Include="Room\MOVED RoomEventArgs.cs" />
|
||||
<Compile Include="SmartObjects\SubpageReferencList\SourceListSubpageReferenceList.cs" />
|
||||
<Compile Include="Touchpanels\ModalDialog.cs" />
|
||||
<Compile Include="Touchpanels\SmartGraphicsTouchpanelControllerBase.cs" />
|
||||
|
||||
@@ -0,0 +1,525 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharp.Scheduler;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using PepperDash.Essentials.Core.Devices;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// A device that when linked to a room can power the room on when enabled during scheduled hours.
|
||||
/// </summary>
|
||||
public class RoomOnToDefaultSourceWhenOccupied : ReconfigurableDevice
|
||||
{
|
||||
RoomOnToDefaultSourceWhenOccupiedConfig PropertiesConfig;
|
||||
|
||||
public bool FeatureEnabled { get; private set; }
|
||||
|
||||
public DateTime FeatureEnabledTime { get; private set; }
|
||||
|
||||
ScheduledEvent FeatureEnableEvent;
|
||||
|
||||
const string FeatureEnableEventName = "EnableRoomOnToDefaultSourceWhenOccupied";
|
||||
|
||||
public DateTime FeatureDisabledTime { get; private set; }
|
||||
|
||||
ScheduledEvent FeatureDisableEvent;
|
||||
|
||||
const string FeatureDisableEventName = "DisableRoomOnToDefaultSourceWhenOccupied";
|
||||
|
||||
ScheduledEventGroup FeatureEventGroup;
|
||||
|
||||
public EssentialsRoomBase Room { get; private set; }
|
||||
|
||||
private Fusion.EssentialsHuddleSpaceFusionSystemControllerBase FusionRoom;
|
||||
|
||||
public RoomOnToDefaultSourceWhenOccupied(DeviceConfig config) :
|
||||
base (config)
|
||||
{
|
||||
PropertiesConfig = JsonConvert.DeserializeObject<RoomOnToDefaultSourceWhenOccupiedConfig>(config.Properties.ToString());
|
||||
|
||||
FeatureEventGroup = new ScheduledEventGroup(this.Key);
|
||||
|
||||
FeatureEventGroup.RetrieveAllEvents();
|
||||
|
||||
// Add to the global class for tracking
|
||||
Scheduler.AddEventGroup(FeatureEventGroup);
|
||||
|
||||
AddPostActivationAction(() =>
|
||||
{
|
||||
// Subscribe to room event to know when RoomOccupancy is set and ready to be subscribed to
|
||||
if (Room != null)
|
||||
Room.RoomOccupancyIsSet += new EventHandler<EventArgs>(RoomOccupancyIsSet);
|
||||
|
||||
else
|
||||
Debug.Console(1, this, "Room has no RoomOccupancy object set");
|
||||
|
||||
var fusionRoomKey = PropertiesConfig.RoomKey + "-fusion";
|
||||
|
||||
FusionRoom = DeviceManager.GetDeviceForKey(fusionRoomKey) as Core.Fusion.EssentialsHuddleSpaceFusionSystemControllerBase;
|
||||
|
||||
if (FusionRoom == null)
|
||||
Debug.Console(1, this, "Unable to get Fusion Room from Device Manager with key: {0}", fusionRoomKey);
|
||||
});
|
||||
}
|
||||
|
||||
public override bool CustomActivate()
|
||||
{
|
||||
SetUpDevice();
|
||||
|
||||
return base.CustomActivate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets up device based on config values
|
||||
/// </summary>
|
||||
void SetUpDevice()
|
||||
{
|
||||
Room = DeviceManager.GetDeviceForKey(PropertiesConfig.RoomKey) as EssentialsRoomBase;
|
||||
|
||||
if (Room != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
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", PropertiesConfig.OccupancyStartTime);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(1, this, "Unable to parse OccupancyStartTime property: {0} \n Error: {1}", PropertiesConfig.OccupancyStartTime, e);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
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", PropertiesConfig.OccupancyEndTime);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(1, this, "Unable to parse a DateTime config value \n Error: {1}", e);
|
||||
}
|
||||
|
||||
if (!PropertiesConfig.EnableRoomOnWhenOccupied)
|
||||
FeatureEventGroup.ClearAllEvents();
|
||||
else
|
||||
{
|
||||
AddEnableEventToGroup();
|
||||
|
||||
AddDisableEventToGroup();
|
||||
|
||||
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}", PropertiesConfig.RoomKey);
|
||||
}
|
||||
|
||||
|
||||
protected override void CustomSetConfig(DeviceConfig config)
|
||||
{
|
||||
var newPropertiesConfig = JsonConvert.DeserializeObject<RoomOnToDefaultSourceWhenOccupiedConfig>(config.Properties.ToString());
|
||||
|
||||
if(newPropertiesConfig != null)
|
||||
PropertiesConfig = newPropertiesConfig;
|
||||
|
||||
ConfigWriter.UpdateDeviceConfig(config);
|
||||
|
||||
SetUpDevice();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Subscribe to feedback from RoomIsOccupiedFeedback on Room
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void RoomOccupancyIsSet(object sender, EventArgs e)
|
||||
{
|
||||
if (Room.RoomOccupancy != null)
|
||||
{
|
||||
Room.RoomOccupancy.RoomIsOccupiedFeedback.OutputChange -= RoomIsOccupiedFeedback_OutputChange;
|
||||
Room.RoomOccupancy.RoomIsOccupiedFeedback.OutputChange += new EventHandler<FeedbackEventArgs>(RoomIsOccupiedFeedback_OutputChange);
|
||||
Debug.Console(1, this, "Subscribed to RoomOccupancy status from: '{0}'", Room.Key);
|
||||
}
|
||||
}
|
||||
|
||||
void FeatureEventGroup_UserGroupCallBack(ScheduledEvent SchEvent, ScheduledEventCommon.eCallbackReason type)
|
||||
{
|
||||
if (type == ScheduledEventCommon.eCallbackReason.NormalExpiration)
|
||||
{
|
||||
if (SchEvent.Name == FeatureEnableEventName)
|
||||
{
|
||||
if (PropertiesConfig.EnableRoomOnWhenOccupied)
|
||||
FeatureEnabled = true;
|
||||
|
||||
Debug.Console(1, this, "*****Feature Enabled by event.*****");
|
||||
}
|
||||
else if (SchEvent.Name == FeatureDisableEventName)
|
||||
{
|
||||
FeatureEnabled = false;
|
||||
|
||||
Debug.Console(1, this, "*****Feature Disabled by event.*****");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the feature should be currently enabled. Used on startup if processor starts after start time but before end time
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool CheckIfFeatureShouldBeEnabled()
|
||||
{
|
||||
bool enabled = false;
|
||||
|
||||
if(PropertiesConfig.EnableRoomOnWhenOccupied)
|
||||
{
|
||||
Debug.Console(1, this, "Current Time: {0} \n FeatureEnabledTime: {1} \n FeatureDisabledTime: {2}", DateTime.Now, FeatureEnabledTime, FeatureDisabledTime);
|
||||
|
||||
if (DateTime.Now.TimeOfDay.CompareTo(FeatureEnabledTime.TimeOfDay) >= 0 && FeatureDisabledTime.TimeOfDay.CompareTo(DateTime.Now.TimeOfDay) > 0)
|
||||
{
|
||||
if (SchedulerUtilities.CheckIfDayOfWeekMatchesRecurrenceDays(DateTime.Now, CalculateDaysOfWeekRecurrence()))
|
||||
{
|
||||
enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(enabled)
|
||||
Debug.Console(1, this, "*****Feature Enabled*****");
|
||||
else
|
||||
Debug.Console(1, this, "*****Feature Disabled*****");
|
||||
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Respond to Occupancy status event
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void RoomIsOccupiedFeedback_OutputChange(object sender, FeedbackEventArgs e)
|
||||
{
|
||||
Debug.Console(1, this, "RoomIsOccupiedFeeback.OutputChange event fired. e.BoolValue: {0}", e.BoolValue);
|
||||
if(e.BoolValue)
|
||||
{
|
||||
// Occupancy detected
|
||||
|
||||
if (FeatureEnabled)
|
||||
{
|
||||
// Check room power state first
|
||||
if (!Room.OnFeedback.BoolValue)
|
||||
{
|
||||
Debug.Console(1, this, "Powering Room on to default source");
|
||||
Room.RunDefaultPresentRoute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CreateEvent(ScheduledEvent schEvent, string name)
|
||||
{
|
||||
Debug.Console(1, this, "Adding Event: '{0}'", name);
|
||||
// Create the event
|
||||
if (schEvent == null)
|
||||
schEvent = new ScheduledEvent(name, FeatureEventGroup);
|
||||
|
||||
// Set up its initial properties
|
||||
|
||||
if(!schEvent.Acknowledgeable)
|
||||
schEvent.Acknowledgeable = true;
|
||||
|
||||
if(!schEvent.Persistent)
|
||||
schEvent.Persistent = true;
|
||||
|
||||
schEvent.DateAndTime.SetFirstDayOfWeek(ScheduledEventCommon.eFirstDayOfWeek.Sunday);
|
||||
|
||||
// Set config driven properties
|
||||
|
||||
if (schEvent.Name == FeatureEnableEventName)
|
||||
{
|
||||
schEvent.Description = "Enables the RoomOnToDefaultSourceWhenOccupiedFeature";
|
||||
|
||||
var eventRecurrennce = CalculateDaysOfWeekRecurrence();
|
||||
|
||||
var eventTime = new DateTime();
|
||||
|
||||
// Check to make sure the date for this event is in the future
|
||||
if (DateTime.Now.CompareTo(FeatureEnabledTime) > 0)
|
||||
eventTime = FeatureEnabledTime.AddDays(1);
|
||||
else
|
||||
eventTime = FeatureEnabledTime;
|
||||
|
||||
Debug.Console(1, this, "eventTime (before recurrence check): {0}", eventTime);
|
||||
|
||||
// Check day of week against recurrence days and move date ahead as necessary to avoid throwing an exception by trying to set the event
|
||||
// start date on a day of the week that doesn't match teh recurrence values
|
||||
while(!SchedulerUtilities.CheckIfDayOfWeekMatchesRecurrenceDays(eventTime, eventRecurrennce))
|
||||
{
|
||||
eventTime = eventTime.AddDays(1);
|
||||
Debug.Console(1, this, "eventTime does not fall on a recurrence weekday. eventTime: {0}", eventTime);
|
||||
}
|
||||
|
||||
schEvent.DateAndTime.SetAbsoluteEventTime(eventTime);
|
||||
|
||||
Debug.Console(1, this, "Event '{0}' Absolute time set to {1}", schEvent.Name, schEvent.DateAndTime.ToString());
|
||||
|
||||
CalculateAndSetAcknowledgeExpirationTimeout(schEvent, FeatureEnabledTime, FeatureDisabledTime);
|
||||
|
||||
schEvent.Recurrence.Weekly(eventRecurrennce);
|
||||
|
||||
}
|
||||
else if (schEvent.Name == FeatureDisableEventName)
|
||||
{
|
||||
schEvent.Description = "Disables the RoomOnToDefaultSourceWhenOccupiedFeature";
|
||||
|
||||
// Check to make sure the date for this event is in the future
|
||||
if (DateTime.Now.CompareTo(FeatureDisabledTime) > 0)
|
||||
schEvent.DateAndTime.SetAbsoluteEventTime(FeatureDisabledTime.AddDays(1));
|
||||
else
|
||||
schEvent.DateAndTime.SetAbsoluteEventTime(FeatureDisabledTime);
|
||||
|
||||
Debug.Console(1, this, "Event '{0}' Absolute time set to {1}", schEvent.Name, schEvent.DateAndTime.ToString());
|
||||
|
||||
CalculateAndSetAcknowledgeExpirationTimeout(schEvent, FeatureDisabledTime, FeatureEnabledTime);
|
||||
|
||||
schEvent.Recurrence.Daily();
|
||||
}
|
||||
}
|
||||
|
||||
void CalculateAndSetAcknowledgeExpirationTimeout(ScheduledEvent schEvent, DateTime time1, DateTime time2)
|
||||
{
|
||||
Debug.Console(1, this, "time1.Hour = {0}", time1.Hour);
|
||||
Debug.Console(1, this, "time2.Hour = {0}", time2.Hour);
|
||||
Debug.Console(1, this, "time1.Minute = {0}", time1.Minute);
|
||||
Debug.Console(1, this, "time2.Minute = {0}", time2.Minute);
|
||||
|
||||
// Calculate the Acknowledge Expiration timer to be the time between the enable and dispable events, less one minute
|
||||
var ackHours = time2.Hour - time1.Hour;
|
||||
if(ackHours < 0)
|
||||
ackHours = ackHours + 24;
|
||||
var ackMinutes = time2.Minute - time1.Minute;
|
||||
|
||||
Debug.Console(1, this, "ackHours = {0}, ackMinutes = {1}", ackHours, ackMinutes);
|
||||
|
||||
var ackTotalMinutes = ((ackHours * 60) + ackMinutes) - 1;
|
||||
|
||||
var ackExpHour = ackTotalMinutes / 60;
|
||||
var ackExpMinutes = ackTotalMinutes % 60;
|
||||
|
||||
Debug.Console(1, this, "Acknowledge Expiration Timeout: {0} hours, {1} minutes", ackExpHour, ackExpMinutes);
|
||||
|
||||
schEvent.AcknowledgeExpirationTimeout.Hour = (ushort)(ackHours);
|
||||
schEvent.AcknowledgeExpirationTimeout.Minute = (ushort)(ackExpMinutes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks existing event to see if it matches the execution time
|
||||
/// </summary>
|
||||
/// <param name="existingEvent"></param>
|
||||
/// <returns></returns>
|
||||
bool CheckExistingEventTimeForMatch(ScheduledEvent existingEvent, DateTime newTime)
|
||||
{
|
||||
bool isMatch = true;
|
||||
|
||||
// Check to see if hour and minute match
|
||||
if (existingEvent.DateAndTime.Hour != newTime.Hour || existingEvent.DateAndTime.Minute != newTime.Minute)
|
||||
return false;
|
||||
|
||||
|
||||
return isMatch;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks existing event to see if it matches the recurrence days
|
||||
/// </summary>
|
||||
/// <param name="existingEvent"></param>
|
||||
/// <param name="eWeekdays"></param>
|
||||
/// <returns></returns>
|
||||
bool CheckExistingEventRecurrenceForMatch(ScheduledEvent existingEvent, ScheduledEventCommon.eWeekDays eWeekdays)
|
||||
{
|
||||
bool isMatch = true;
|
||||
|
||||
// Check to see if recurrence matches
|
||||
if (eWeekdays != existingEvent.Recurrence.RecurrenceDays)
|
||||
return false;
|
||||
|
||||
return isMatch;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the Enable event to the local event group and sets its properties based on config
|
||||
/// </summary>
|
||||
void AddEnableEventToGroup()
|
||||
{
|
||||
if (!FeatureEventGroup.ScheduledEvents.ContainsKey(FeatureEnableEventName))
|
||||
{
|
||||
CreateEvent(FeatureEnableEvent, FeatureEnableEventName);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check if existing event has same time and recurrence as config values
|
||||
|
||||
FeatureEnableEvent = FeatureEventGroup.ScheduledEvents[FeatureEnableEventName];
|
||||
Debug.Console(1, this, "Enable event already found in group");
|
||||
|
||||
// Check config times and days against DateAndTime of existing event. If different, delete existing event and create new event
|
||||
if(!CheckExistingEventTimeForMatch(FeatureEnableEvent, FeatureEnabledTime) || !CheckExistingEventRecurrenceForMatch(FeatureEnableEvent, CalculateDaysOfWeekRecurrence()))
|
||||
{
|
||||
Debug.Console(1, this, "Existing event does not match new config properties. Deleting exisiting event: '{0}'", FeatureEnableEvent.Name);
|
||||
FeatureEventGroup.DeleteEvent(FeatureEnableEvent);
|
||||
|
||||
FeatureEnableEvent = null;
|
||||
|
||||
CreateEvent(FeatureEnableEvent, FeatureEnableEventName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the Enable event to the local event group and sets its properties based on config
|
||||
/// </summary>
|
||||
void AddDisableEventToGroup()
|
||||
{
|
||||
if (!FeatureEventGroup.ScheduledEvents.ContainsKey(FeatureDisableEventName))
|
||||
{
|
||||
CreateEvent(FeatureDisableEvent, FeatureDisableEventName);
|
||||
}
|
||||
else
|
||||
{
|
||||
FeatureDisableEvent = FeatureEventGroup.ScheduledEvents[FeatureDisableEventName];
|
||||
Debug.Console(1, this, "Disable event already found in group");
|
||||
|
||||
// Check config times against DateAndTime of existing event. If different, delete existing event and create new event
|
||||
if(!CheckExistingEventTimeForMatch(FeatureDisableEvent, FeatureDisabledTime))
|
||||
{
|
||||
Debug.Console(1, this, "Existing event does not match new config properties. Deleting exisiting event: '{0}'", FeatureDisableEvent.Name);
|
||||
|
||||
FeatureEventGroup.DeleteEvent(FeatureDisableEvent);
|
||||
|
||||
FeatureDisableEvent = null;
|
||||
|
||||
CreateEvent(FeatureDisableEvent, FeatureDisableEventName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the correct bitfield enum value for the event recurrence based on the config values
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
ScheduledEventCommon.eWeekDays CalculateDaysOfWeekRecurrence()
|
||||
{
|
||||
ScheduledEventCommon.eWeekDays value = new ScheduledEventCommon.eWeekDays();
|
||||
|
||||
if (PropertiesConfig.EnableSunday)
|
||||
value = value | ScheduledEventCommon.eWeekDays.Sunday;
|
||||
if (PropertiesConfig.EnableMonday)
|
||||
value = value | ScheduledEventCommon.eWeekDays.Monday;
|
||||
if (PropertiesConfig.EnableTuesday)
|
||||
value = value | ScheduledEventCommon.eWeekDays.Tuesday;
|
||||
if (PropertiesConfig.EnableWednesday)
|
||||
value = value | ScheduledEventCommon.eWeekDays.Wednesday;
|
||||
if (PropertiesConfig.EnableThursday)
|
||||
value = value | ScheduledEventCommon.eWeekDays.Thursday;
|
||||
if (PropertiesConfig.EnableFriday)
|
||||
value = value | ScheduledEventCommon.eWeekDays.Friday;
|
||||
if (PropertiesConfig.EnableSaturday)
|
||||
value = value | ScheduledEventCommon.eWeekDays.Saturday;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Callback for event that enables feature. Enables feature if config property is true
|
||||
/// </summary>
|
||||
/// <param name="SchEvent"></param>
|
||||
/// <param name="type"></param>
|
||||
void FeatureEnableEvent_UserCallBack(ScheduledEvent SchEvent, ScheduledEventCommon.eCallbackReason type)
|
||||
{
|
||||
if (type == ScheduledEventCommon.eCallbackReason.NormalExpiration)
|
||||
{
|
||||
if(PropertiesConfig.EnableRoomOnWhenOccupied)
|
||||
FeatureEnabled = true;
|
||||
|
||||
Debug.Console(1, this, "RoomOnToDefaultSourceWhenOccupied Feature Enabled.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Callback for event that enables feature. Disables feature
|
||||
/// </summary>
|
||||
/// <param name="SchEvent"></param>
|
||||
/// <param name="type"></param>
|
||||
void FeatureDisableEvent_UserCallBack(ScheduledEvent SchEvent, ScheduledEventCommon.eCallbackReason type)
|
||||
{
|
||||
if (type == ScheduledEventCommon.eCallbackReason.NormalExpiration)
|
||||
{
|
||||
FeatureEnabled = false;
|
||||
|
||||
Debug.Console(1, this, "RoomOnToDefaultSourceWhenOccupied Feature Disabled.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class RoomOnToDefaultSourceWhenOccupiedConfig
|
||||
{
|
||||
[JsonProperty("roomKey")]
|
||||
public string RoomKey { get; set; }
|
||||
|
||||
[JsonProperty("enableRoomOnWhenOccupied")]
|
||||
public bool EnableRoomOnWhenOccupied { get; set; }
|
||||
|
||||
[JsonProperty("occupancyStartTime")]
|
||||
public string OccupancyStartTime { get; set; }
|
||||
|
||||
[JsonProperty("occupancyEndTime")]
|
||||
public string OccupancyEndTime { get; set; }
|
||||
|
||||
[JsonProperty("enableSunday")]
|
||||
public bool EnableSunday { get; set; }
|
||||
|
||||
[JsonProperty("enableMonday")]
|
||||
public bool EnableMonday { get; set; }
|
||||
|
||||
[JsonProperty("enableTuesday")]
|
||||
public bool EnableTuesday { get; set; }
|
||||
|
||||
[JsonProperty("enableWednesday")]
|
||||
public bool EnableWednesday { get; set; }
|
||||
|
||||
[JsonProperty("enableThursday")]
|
||||
public bool EnableThursday { get; set; }
|
||||
|
||||
[JsonProperty("enableFriday")]
|
||||
public bool EnableFriday { get; set; }
|
||||
|
||||
[JsonProperty("enableSaturday")]
|
||||
public bool EnableSaturday { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,311 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharp.Scheduler;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using PepperDash.Essentials.Core.Devices;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public abstract class EssentialsRoomBase : ReconfigurableDevice
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public BoolFeedback OnFeedback { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Fires when the RoomOccupancy object is set
|
||||
/// </summary>
|
||||
public event EventHandler<EventArgs> RoomOccupancyIsSet;
|
||||
|
||||
public BoolFeedback IsWarmingUpFeedback { get; private set; }
|
||||
public BoolFeedback IsCoolingDownFeedback { get; private set; }
|
||||
|
||||
public IOccupancyStatusProvider RoomOccupancy { get; private set; }
|
||||
|
||||
public bool OccupancyStatusProviderIsRemote { get; private set; }
|
||||
|
||||
protected abstract Func<bool> IsWarmingFeedbackFunc { get; }
|
||||
protected abstract Func<bool> IsCoolingFeedbackFunc { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The config name of the source list
|
||||
/// </summary>
|
||||
public string SourceListKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Timer used for informing the UIs of a shutdown
|
||||
/// </summary>
|
||||
public SecondsCountdownTimer ShutdownPromptTimer { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int ShutdownPromptSeconds { get; set; }
|
||||
public int ShutdownVacancySeconds { get; set; }
|
||||
public eShutdownType ShutdownType { get; private set; }
|
||||
|
||||
public EssentialsRoomEmergencyBase Emergency { get; set; }
|
||||
|
||||
public Core.Privacy.MicrophonePrivacyController MicrophonePrivacy { get; set; }
|
||||
|
||||
public string LogoUrl { get; set; }
|
||||
|
||||
protected SecondsCountdownTimer RoomVacancyShutdownTimer { get; private set; }
|
||||
|
||||
public eVacancyMode VacancyMode { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Seconds after vacancy prompt is displayed until shutdown
|
||||
/// </summary>
|
||||
protected int RoomVacancyShutdownSeconds;
|
||||
|
||||
/// <summary>
|
||||
/// Seconds after vacancy detected until prompt is displayed
|
||||
/// </summary>
|
||||
protected int RoomVacancyShutdownPromptSeconds;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
protected abstract Func<bool> OnFeedbackFunc { get; }
|
||||
|
||||
protected Dictionary<IBasicVolumeWithFeedback, uint> SavedVolumeLevels = new Dictionary<IBasicVolumeWithFeedback, uint>();
|
||||
|
||||
/// <summary>
|
||||
/// When volume control devices change, should we zero the one that we are leaving?
|
||||
/// </summary>
|
||||
public bool ZeroVolumeWhenSwtichingVolumeDevices { get; private set; }
|
||||
|
||||
|
||||
public EssentialsRoomBase(DeviceConfig config)
|
||||
: base(config)
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
case eVacancyMode.None:
|
||||
StartRoomVacancyTimer(eVacancyMode.InInitialVacancy);
|
||||
break;
|
||||
case eVacancyMode.InInitialVacancy:
|
||||
StartRoomVacancyTimer(eVacancyMode.InShutdownWarning);
|
||||
break;
|
||||
case eVacancyMode.InShutdownWarning:
|
||||
{
|
||||
StartShutdown(eShutdownType.Vacancy);
|
||||
Debug.Console(0, this, "Shutting Down due to vacancy.");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
public void StartShutdown(eShutdownType type)
|
||||
{
|
||||
// Check for shutdowns running. Manual should override other shutdowns
|
||||
|
||||
if (type == eShutdownType.Manual)
|
||||
ShutdownPromptTimer.SecondsToCount = ShutdownPromptSeconds;
|
||||
else if (type == eShutdownType.Vacancy)
|
||||
ShutdownPromptTimer.SecondsToCount = ShutdownVacancySeconds;
|
||||
ShutdownType = type;
|
||||
ShutdownPromptTimer.Start();
|
||||
|
||||
Debug.Console(0, this, "ShutdwonPromptTimer Started. Type: {0}. Seconds: {1}", ShutdownType, ShutdownPromptTimer.SecondsToCount);
|
||||
}
|
||||
|
||||
public void StartRoomVacancyTimer(eVacancyMode mode)
|
||||
{
|
||||
if (mode == eVacancyMode.None)
|
||||
RoomVacancyShutdownTimer.SecondsToCount = RoomVacancyShutdownPromptSeconds;
|
||||
else if (mode == eVacancyMode.InInitialVacancy)
|
||||
RoomVacancyShutdownTimer.SecondsToCount = RoomVacancyShutdownSeconds;
|
||||
VacancyMode = mode;
|
||||
RoomVacancyShutdownTimer.Start();
|
||||
|
||||
Debug.Console(0, this, "Vacancy Timer Started. Mode: {0}. Seconds: {1}", VacancyMode, RoomVacancyShutdownTimer.SecondsToCount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the vacancy mode and shutsdwon the room
|
||||
/// </summary>
|
||||
public void Shutdown()
|
||||
{
|
||||
VacancyMode = eVacancyMode.None;
|
||||
EndShutdown();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is for the derived class to define it's specific shutdown
|
||||
/// requirements but should not be called directly. It is called by Shutdown()
|
||||
/// </summary>
|
||||
protected abstract void EndShutdown();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Override this to implement a default volume level(s) method
|
||||
/// </summary>
|
||||
public abstract void SetDefaultLevels();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the object to be used as the IOccupancyStatusProvider for the room. Can be an Occupancy Aggregator or a specific device
|
||||
/// </summary>
|
||||
/// <param name="statusProvider"></param>
|
||||
public void SetRoomOccupancy(IOccupancyStatusProvider statusProvider, int timeoutMinutes)
|
||||
{
|
||||
if (statusProvider == null)
|
||||
{
|
||||
Debug.Console(0, this, "ERROR: Occupancy sensor device is null");
|
||||
return;
|
||||
}
|
||||
|
||||
// If status provider is fusion, set flag to remote
|
||||
if (statusProvider is Core.Fusion.EssentialsHuddleSpaceFusionSystemControllerBase)
|
||||
OccupancyStatusProviderIsRemote = true;
|
||||
|
||||
if(timeoutMinutes > 0)
|
||||
RoomVacancyShutdownSeconds = timeoutMinutes * 60;
|
||||
|
||||
Debug.Console(1, this, "RoomVacancyShutdownSeconds set to {0}", RoomVacancyShutdownSeconds);
|
||||
|
||||
RoomOccupancy = statusProvider;
|
||||
|
||||
OnRoomOccupancyIsSet();
|
||||
|
||||
RoomOccupancy.RoomIsOccupiedFeedback.OutputChange -= RoomIsOccupiedFeedback_OutputChange;
|
||||
RoomOccupancy.RoomIsOccupiedFeedback.OutputChange += RoomIsOccupiedFeedback_OutputChange;
|
||||
|
||||
Debug.Console(0, this, "Room Occupancy set to device: '{0}'", (statusProvider as Device).Key);
|
||||
}
|
||||
|
||||
void OnRoomOccupancyIsSet()
|
||||
{
|
||||
var handler = RoomOccupancyIsSet;
|
||||
if (handler != null)
|
||||
handler(this, new EventArgs());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// To allow base class to power room on to last source
|
||||
/// </summary>
|
||||
public abstract void PowerOnToDefaultOrLastSource();
|
||||
|
||||
/// <summary>
|
||||
/// To allow base class to power room on to default source
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public abstract bool RunDefaultPresentRoute();
|
||||
|
||||
void RoomIsOccupiedFeedback_OutputChange(object sender, EventArgs e)
|
||||
{
|
||||
if (RoomOccupancy.RoomIsOccupiedFeedback.BoolValue == false)
|
||||
{
|
||||
Debug.Console(1, this, "Notice: Vacancy Detected");
|
||||
// Trigger the timer when the room is vacant
|
||||
StartRoomVacancyTimer(eVacancyMode.InInitialVacancy);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Console(1, this, "Notice: Occupancy Detected");
|
||||
// Reset the timer when the room is occupied
|
||||
RoomVacancyShutdownTimer.Cancel();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes when RoomVacancyShutdownTimer expires. Used to trigger specific room actions as needed. Must nullify the timer object when executed
|
||||
/// </summary>
|
||||
/// <param name="o"></param>
|
||||
public abstract void RoomVacatedForTimeoutPeriod(object o);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// To describe the various ways a room may be shutting down
|
||||
/// </summary>
|
||||
public enum eShutdownType
|
||||
{
|
||||
None = 0,
|
||||
External,
|
||||
Manual,
|
||||
Vacancy
|
||||
}
|
||||
|
||||
public enum eVacancyMode
|
||||
{
|
||||
None = 0,
|
||||
InInitialVacancy,
|
||||
InShutdownWarning
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public enum eWarmingCoolingMode
|
||||
{
|
||||
None,
|
||||
Warming,
|
||||
Cooling
|
||||
}
|
||||
|
||||
public abstract class EssentialsRoomEmergencyBase : IKeyed
|
||||
{
|
||||
public string Key { get; private set; }
|
||||
|
||||
public EssentialsRoomEmergencyBase(string key)
|
||||
{
|
||||
Key = key;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// For rooms with in call feedback
|
||||
/// </summary>
|
||||
public interface IHasInCallFeedback
|
||||
{
|
||||
BoolFeedback InCallFeedback { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For rooms with a single display
|
||||
/// </summary>
|
||||
public interface IHasDefaultDisplay
|
||||
{
|
||||
IRoutingSinkWithSwitching DefaultDisplay { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For rooms with multiple displays
|
||||
/// </summary>
|
||||
public interface IHasMultipleDisplays
|
||||
{
|
||||
Dictionary<eSourceListItemDestinationTypes, IRoutingSinkWithSwitching> Displays { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For rooms with routing
|
||||
/// </summary>
|
||||
public interface IRunRouteAction
|
||||
{
|
||||
void RunRouteAction(string routeKey);
|
||||
|
||||
void RunRouteAction(string routeKey, Action successCallback);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For rooms that default presentation only routing
|
||||
/// </summary>
|
||||
public interface IRunDefaultPresentRoute
|
||||
{
|
||||
bool RunDefaultPresentRoute();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For rooms that have default presentation and calling routes
|
||||
/// </summary>
|
||||
public interface IRunDefaultCallRoute : IRunDefaultPresentRoute
|
||||
{
|
||||
bool RunDefaultCallRoute();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using System.Text;
|
||||
//using Crestron.SimplSharp;
|
||||
|
||||
//namespace PepperDash.Essentials.Core
|
||||
//{
|
||||
// public class EssentialsRoomSourceChangeEventArgs : EventArgs
|
||||
// {
|
||||
// public EssentialsRoom Room { get; private set; }
|
||||
// public IPresentationSource OldSource { get; private set; }
|
||||
// public IPresentationSource NewSource { get; private set; }
|
||||
|
||||
// public EssentialsRoomSourceChangeEventArgs(EssentialsRoom room,
|
||||
// IPresentationSource oldSource, IPresentationSource newSource)
|
||||
// {
|
||||
// Room = room;
|
||||
// OldSource = oldSource;
|
||||
// NewSource = newSource;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// public class EssentialsRoomAudioDeviceChangeEventArgs : EventArgs
|
||||
// {
|
||||
// public EssentialsRoom Room { get; private set; }
|
||||
// public IBasicVolumeControls OldDevice { get; private set; }
|
||||
// public IBasicVolumeControls NewDevice { get; private set; }
|
||||
|
||||
// public EssentialsRoomAudioDeviceChangeEventArgs(EssentialsRoom room,
|
||||
// IBasicVolumeControls oldDevice, IBasicVolumeControls newDevice)
|
||||
// {
|
||||
// Room = room;
|
||||
// OldDevice = oldDevice;
|
||||
// NewDevice = newDevice;
|
||||
// }
|
||||
// }
|
||||
|
||||
//}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
using PepperDash.Essentials.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
public interface IOccupancyStatusProvider
|
||||
{
|
||||
BoolFeedback RoomIsOccupiedFeedback { get; }
|
||||
}
|
||||
}
|
||||
@@ -11,9 +11,25 @@ using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// The handler type for a Room's SourceInfoChange
|
||||
/// </summary>
|
||||
public delegate void SourceInfoChangeHandler(/*EssentialsRoomBase room,*/ SourceListItem info, ChangeType type);
|
||||
|
||||
|
||||
//*******************************************************************************************
|
||||
// Interfaces
|
||||
|
||||
/// <summary>
|
||||
/// For rooms with a single presentation source, change event
|
||||
/// </summary>
|
||||
public interface IHasCurrentSourceInfoChange
|
||||
{
|
||||
string CurrentSourceInfoKey { get; set; }
|
||||
SourceListItem CurrentSourceInfo { get; set; }
|
||||
event SourceInfoChangeHandler CurrentSourceChange;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines a class that has a collection of RoutingInputPorts
|
||||
@@ -35,7 +51,7 @@ namespace PepperDash.Essentials.Core
|
||||
/// <summary>
|
||||
/// For fixed-source endpoint devices
|
||||
/// </summary>
|
||||
public interface IRoutingSinkNoSwitching : IRoutingInputs
|
||||
public interface IRoutingSinkNoSwitching : IRoutingInputs, IHasCurrentSourceInfoChange
|
||||
{
|
||||
|
||||
}
|
||||
@@ -43,7 +59,7 @@ namespace PepperDash.Essentials.Core
|
||||
/// <summary>
|
||||
/// Endpoint device like a display, that selects inputs
|
||||
/// </summary>
|
||||
public interface IRoutingSinkWithSwitching : IRoutingSinkNoSwitching
|
||||
public interface IRoutingSinkWithSwitching : IRoutingSinkNoSwitching, IHasCurrentSourceInfoChange
|
||||
{
|
||||
//void ClearRoute();
|
||||
void ExecuteSwitch(object inputSelector);
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
public interface IHasBasicTriListWithSmartObject
|
||||
{
|
||||
BasicTriListWithSmartObject Panel { get; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user