mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-14 20:24:57 +00:00
Implemented Device Usage feature for Fusion.
This commit is contained in:
@@ -13,7 +13,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A bridge class to cover the basic features of GenericBase hardware
|
/// A bridge class to cover the basic features of GenericBase hardware
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CrestronGenericBaseDevice : Device, IOnline, IHasFeedback, ICommunicationMonitor
|
public class CrestronGenericBaseDevice : Device, IOnline, IHasFeedback, ICommunicationMonitor, IUsageTracking
|
||||||
{
|
{
|
||||||
public virtual GenericBase Hardware { get; protected set; }
|
public virtual GenericBase Hardware { get; protected set; }
|
||||||
|
|
||||||
@@ -88,6 +88,12 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
public StatusMonitorBase CommunicationMonitor { get; private set; }
|
public StatusMonitorBase CommunicationMonitor { get; private set; }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region IUsageTracking Members
|
||||||
|
|
||||||
|
public UsageTracking UsageTracker { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
//***********************************************************************************
|
//***********************************************************************************
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Crestron.SimplSharp;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core
|
||||||
|
{
|
||||||
|
public interface IUsageTracking
|
||||||
|
{
|
||||||
|
UsageTracking UsageTracker { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
//public static class IUsageTrackingExtensions
|
||||||
|
//{
|
||||||
|
// public static void EnableUsageTracker(this IUsageTracking device)
|
||||||
|
// {
|
||||||
|
// device.UsageTracker = new UsageTracking();
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
public class UsageTracking
|
||||||
|
{
|
||||||
|
public event EventHandler<DeviceUsageEventArgs> DeviceUsageEnded;
|
||||||
|
|
||||||
|
public InUseTracking InUseTracker { get; protected set; }
|
||||||
|
|
||||||
|
public bool UsageIsTracked { get; set; }
|
||||||
|
public DateTime UsageStartTime { get; protected set; }
|
||||||
|
public DateTime UsageEndTime { get; protected set; }
|
||||||
|
|
||||||
|
public UsageTracking()
|
||||||
|
{
|
||||||
|
InUseTracker.InUseFeedback.OutputChange +=new EventHandler<EventArgs>(InUseFeedback_OutputChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InUseFeedback_OutputChange(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if(InUseTracker.InUseFeedback.BoolValue)
|
||||||
|
{
|
||||||
|
StartDeviceUsage();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EndDeviceUsage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stores the usage start time
|
||||||
|
/// </summary>
|
||||||
|
public void StartDeviceUsage()
|
||||||
|
{
|
||||||
|
UsageStartTime = DateTime.Now;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Calculates the difference between the usage start and end times, gets the total minutes used and fires an event to pass that info to a consumer
|
||||||
|
/// </summary>
|
||||||
|
public void EndDeviceUsage()
|
||||||
|
{
|
||||||
|
UsageEndTime = DateTime.Now;
|
||||||
|
|
||||||
|
var timeUsed = UsageEndTime - UsageStartTime;
|
||||||
|
|
||||||
|
var handler = DeviceUsageEnded;
|
||||||
|
|
||||||
|
if (handler != null)
|
||||||
|
{
|
||||||
|
handler(this, new DeviceUsageEventArgs() { UsageEndTime = UsageEndTime, MinutesUsed = timeUsed.Minutes });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DeviceUsageEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
public DateTime UsageEndTime { get; set; }
|
||||||
|
public int MinutesUsed { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,12 +16,14 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class DisplayBase : Device, IHasFeedback, IRoutingSinkWithSwitching, IPower, IWarmingCooling
|
public abstract class DisplayBase : Device, IHasFeedback, IRoutingSinkWithSwitching, IPower, IWarmingCooling, IUsageTracking
|
||||||
{
|
{
|
||||||
public BoolFeedback PowerIsOnFeedback { get; protected set; }
|
public BoolFeedback PowerIsOnFeedback { get; protected set; }
|
||||||
public BoolFeedback IsCoolingDownFeedback { get; protected set; }
|
public BoolFeedback IsCoolingDownFeedback { get; protected set; }
|
||||||
public BoolFeedback IsWarmingUpFeedback { get; private set; }
|
public BoolFeedback IsWarmingUpFeedback { get; private set; }
|
||||||
|
|
||||||
|
public UsageTracking UsageTracker { get; set; }
|
||||||
|
|
||||||
public uint WarmupTime { get; set; }
|
public uint WarmupTime { get; set; }
|
||||||
public uint CooldownTime { get; set; }
|
public uint CooldownTime { get; set; }
|
||||||
|
|
||||||
@@ -77,7 +79,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class TwoWayDisplayBase : DisplayBase
|
public abstract class TwoWayDisplayBase : DisplayBase
|
||||||
{
|
{
|
||||||
public StringFeedback CurrentInputFeedback { get; private set; }
|
public StringFeedback CurrentInputFeedback { get; private set; }
|
||||||
|
|
||||||
@@ -104,6 +106,8 @@ namespace PepperDash.Essentials.Core
|
|||||||
CooldownTime = 15000;
|
CooldownTime = 15000;
|
||||||
|
|
||||||
Feedbacks.Add(CurrentInputFeedback);
|
Feedbacks.Add(CurrentInputFeedback);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,6 +115,7 @@
|
|||||||
<Compile Include="Config\DeviceConfig.cs" />
|
<Compile Include="Config\DeviceConfig.cs" />
|
||||||
<Compile Include="Constants\CommonCues.cs" />
|
<Compile Include="Constants\CommonCues.cs" />
|
||||||
<Compile Include="Devices\DisplayUiConstants.cs" />
|
<Compile Include="Devices\DisplayUiConstants.cs" />
|
||||||
|
<Compile Include="Devices\IUsageTracking.cs" />
|
||||||
<Compile Include="Devices\REMOVE DeviceConfig.cs" />
|
<Compile Include="Devices\REMOVE DeviceConfig.cs" />
|
||||||
<Compile Include="Devices\DeviceJsonApi.cs" />
|
<Compile Include="Devices\DeviceJsonApi.cs" />
|
||||||
<Compile Include="Devices\SourceListItem.cs" />
|
<Compile Include="Devices\SourceListItem.cs" />
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -11,7 +11,7 @@ using PepperDash.Essentials.Core.Routing;
|
|||||||
|
|
||||||
namespace PepperDash.Essentials.Devices.Common
|
namespace PepperDash.Essentials.Devices.Common
|
||||||
{
|
{
|
||||||
public class IRBlurayBase : Device, IDiscPlayerControls, IUiDisplayInfo, IRoutingOutputs
|
public class IRBlurayBase : Device, IDiscPlayerControls, IUiDisplayInfo, IRoutingOutputs, IUsageTracking
|
||||||
{
|
{
|
||||||
public IrOutputPortController IrPort { get; private set; }
|
public IrOutputPortController IrPort { get; private set; }
|
||||||
|
|
||||||
@@ -304,5 +304,11 @@ namespace PepperDash.Essentials.Devices.Common
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
|
||||||
|
#region IUsageTracking Members
|
||||||
|
|
||||||
|
public UsageTracking UsageTracker { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Binary file not shown.
@@ -12,7 +12,7 @@ namespace PepperDash.Essentials.Devices.Common
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// This DVD class should cover most IR, one-way DVD and Bluray fuctions
|
/// This DVD class should cover most IR, one-way DVD and Bluray fuctions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class InRoomPc : Device, IHasFeedback, IRoutingOutputs, IAttachVideoStatus, IUiDisplayInfo
|
public class InRoomPc : Device, IHasFeedback, IRoutingOutputs, IAttachVideoStatus, IUiDisplayInfo, IUsageTracking
|
||||||
{
|
{
|
||||||
public uint DisplayUiType { get { return DisplayUiConstants.TypeLaptop; } }
|
public uint DisplayUiType { get { return DisplayUiConstants.TypeLaptop; } }
|
||||||
public string IconName { get; set; }
|
public string IconName { get; set; }
|
||||||
@@ -51,5 +51,11 @@ namespace PepperDash.Essentials.Devices.Common
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region IUsageTracking Members
|
||||||
|
|
||||||
|
public UsageTracking UsageTracker { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@ namespace PepperDash.Essentials.Devices.Common
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// This DVD class should cover most IR, one-way DVD and Bluray fuctions
|
/// This DVD class should cover most IR, one-way DVD and Bluray fuctions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Laptop : Device, IHasFeedback, IRoutingOutputs, IAttachVideoStatus, IUiDisplayInfo
|
public class Laptop : Device, IHasFeedback, IRoutingOutputs, IAttachVideoStatus, IUiDisplayInfo, IUsageTracking
|
||||||
{
|
{
|
||||||
public uint DisplayUiType { get { return DisplayUiConstants.TypeLaptop; } }
|
public uint DisplayUiType { get { return DisplayUiConstants.TypeLaptop; } }
|
||||||
public string IconName { get; set; }
|
public string IconName { get; set; }
|
||||||
@@ -51,5 +51,11 @@ namespace PepperDash.Essentials.Devices.Common
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region IUsageTracking Members
|
||||||
|
|
||||||
|
public UsageTracking UsageTracker { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@ using PepperDash.Essentials.Core.Routing;
|
|||||||
|
|
||||||
namespace PepperDash.Essentials.Devices.Common
|
namespace PepperDash.Essentials.Devices.Common
|
||||||
{
|
{
|
||||||
public class IRSetTopBoxBase : Device, ISetTopBoxControls, IUiDisplayInfo, IRoutingOutputs
|
public class IRSetTopBoxBase : Device, ISetTopBoxControls, IUiDisplayInfo, IRoutingOutputs, IUsageTracking
|
||||||
{
|
{
|
||||||
public IrOutputPortController IrPort { get; private set; }
|
public IrOutputPortController IrPort { get; private set; }
|
||||||
|
|
||||||
@@ -333,5 +333,11 @@ namespace PepperDash.Essentials.Devices.Common
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region IUsageTracking Members
|
||||||
|
|
||||||
|
public UsageTracking UsageTracker { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -175,8 +175,6 @@ namespace PepperDash.Essentials
|
|||||||
DeviceManager.AddDevice(room);
|
DeviceManager.AddDevice(room);
|
||||||
}
|
}
|
||||||
|
|
||||||
#warning Add Fusion connector to room factory?
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Debug.Console(0, "WARNING: Cannot create room from config, key '{0}'", roomConfig.Key);
|
Debug.Console(0, "WARNING: Cannot create room from config, key '{0}'", roomConfig.Key);
|
||||||
|
|||||||
@@ -14,10 +14,9 @@ using Crestron.SimplSharpPro.Fusion;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
using PepperDash.Essentials.Core;
|
|
||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials;
|
using PepperDash.Essentials;
|
||||||
|
using PepperDash.Essentials.Core;
|
||||||
using PepperDash.Essentials.Devices.Common;
|
using PepperDash.Essentials.Devices.Common;
|
||||||
|
|
||||||
|
|
||||||
@@ -314,6 +313,7 @@ namespace PepperDash.Essentials.Fusion
|
|||||||
NetMask1 = FusionRoom.CreateOffsetStringSig(63, "Info - Processor - Net Mask 1", eSigIoMask.InputSigOnly);
|
NetMask1 = FusionRoom.CreateOffsetStringSig(63, "Info - Processor - Net Mask 1", eSigIoMask.InputSigOnly);
|
||||||
NetMask2 = FusionRoom.CreateOffsetStringSig(64, "Info - Processor - Net Mask 2", eSigIoMask.InputSigOnly);
|
NetMask2 = FusionRoom.CreateOffsetStringSig(64, "Info - Processor - Net Mask 2", eSigIoMask.InputSigOnly);
|
||||||
|
|
||||||
|
SetProcessorEthernetValues();
|
||||||
|
|
||||||
CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(CrestronEnvironment_EthernetEventHandler);
|
CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(CrestronEnvironment_EthernetEventHandler);
|
||||||
}
|
}
|
||||||
@@ -816,6 +816,18 @@ namespace PepperDash.Essentials.Fusion
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var kvp in dict)
|
||||||
|
{
|
||||||
|
var usageDevice = kvp.Value.SourceDevice as IUsageTracking;
|
||||||
|
|
||||||
|
if (usageDevice != null)
|
||||||
|
{
|
||||||
|
usageDevice.UsageTracker = new UsageTracking();
|
||||||
|
|
||||||
|
usageDevice.UsageTracker.DeviceUsageEnded += new EventHandler<DeviceUsageEventArgs>(UsageTracker_SourceUsageEnded);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -824,6 +836,31 @@ namespace PepperDash.Essentials.Fusion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Collects usage data from source and sends to Fusion
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
void UsageTracker_SourceUsageEnded(object sender, DeviceUsageEventArgs e)
|
||||||
|
{
|
||||||
|
var device = sender as Device;
|
||||||
|
|
||||||
|
var configDevice = ConfigReader.ConfigObject.Devices.Where(d => d.Key.Equals(device.Key));
|
||||||
|
|
||||||
|
string group = "";
|
||||||
|
|
||||||
|
#warning Figure out how to get the group value from the device config
|
||||||
|
|
||||||
|
|
||||||
|
//Double check my time and date formatting in the ToString() methods
|
||||||
|
string deviceUsage = string.Format("USAGE||{0}||{1}||TIME||{2}||{3}||{4}||{5}||{6})", e.UsageEndTime.ToString("YYYY-MM-DD"), e.UsageEndTime.ToString("HH-mm-ss"),
|
||||||
|
group, device.Name, e.MinutesUsed, "asset_id", CurrentMeeting.MeetingID);
|
||||||
|
|
||||||
|
|
||||||
|
FusionRoom.DeviceUsage.InputSig.StringValue = deviceUsage;
|
||||||
|
}
|
||||||
|
|
||||||
void TryAddRouteActionSigs(string attrName, uint attrNum, string routeKey, Device pSrc)
|
void TryAddRouteActionSigs(string attrName, uint attrNum, string routeKey, Device pSrc)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "Creating attribute '{0}' with join {1} for source {2}",
|
Debug.Console(2, this, "Creating attribute '{0}' with join {1} for source {2}",
|
||||||
@@ -924,6 +961,10 @@ namespace PepperDash.Essentials.Fusion
|
|||||||
|
|
||||||
void SetUpDisplay()
|
void SetUpDisplay()
|
||||||
{
|
{
|
||||||
|
//Setup Display Usage Monitoring
|
||||||
|
|
||||||
|
#warning Somehow get list of room's displays and activate Usage tracking and subscribe to event
|
||||||
|
|
||||||
var display = Room.DefaultDisplay as DisplayBase;
|
var display = Room.DefaultDisplay as DisplayBase;
|
||||||
if (display == null)
|
if (display == null)
|
||||||
{
|
{
|
||||||
@@ -984,9 +1025,6 @@ namespace PepperDash.Essentials.Fusion
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Helper to get the number from the end of a device's key string
|
/// Helper to get the number from the end of a device's key string
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -83,7 +83,7 @@
|
|||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\..\pepperdash-simplsharp-core\Pepperdash Core\CLZ Builds\PepperDash_Core.dll</HintPath>
|
<HintPath>..\..\..\pepperdash-simplsharp-core\Pepperdash Core\CLZ Builds\PepperDash_Core.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="PepperDash_Essentials_Core, Version=1.0.0.12925, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="PepperDash_Essentials_Core, Version=1.0.0.18243, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\Essentials Core\PepperDashEssentialsBase\bin\PepperDash_Essentials_Core.dll</HintPath>
|
<HintPath>..\..\Essentials Core\PepperDashEssentialsBase\bin\PepperDash_Essentials_Core.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user