Compare commits

...

18 Commits

Author SHA1 Message Date
Neil Dorin
9148cfd819 Merge pull request #1249 from PepperDash/generic-comm-monitor-issues 2025-04-11 12:32:12 -06:00
Andrew Welker
60550caf99 fix: add lock for threadsafety
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-04-11 13:26:01 -05:00
Andrew Welker
59baa74dd7 fix: multiple messages no longer sent
Due to how the `BeginPolling` method was written and being called, there
were situations where multiple PollTimers were created, causing there to
be multiple messages sent to the end point for each poll cycle.
2025-04-11 12:13:26 -05:00
Neil Dorin
bf31bf9e93 Merge pull request #1247 from PepperDash/messenger-fixes
ISelectableItemsMessenger & logging updates
2025-04-09 12:33:04 -06:00
Andrew Welker
ee8776cfb1 chore: remove unnecessary constructor overload 2025-04-09 12:04:32 -05:00
Andrew Welker
0b59990532 fix: add IHasInputsMessenger
In order to match up with how existing front-end apps are expecting to
recieve data for devices that implement the `IHasInputs<T>` interface,
there is now an IHasInputsMessengers that is implemented for devices
that implement `IHasInputs<string>`, `IHasInputs<int>` or
`IHasInputs<byte>` interfaces.
2025-04-09 11:48:05 -05:00
Andrew Welker
8d3fd343f1 fix: remove extraneous param for message logging 2025-04-09 10:53:42 -05:00
Andrew Welker
372274d9fa fix: add constructor that takes IHasInputs<T>
In order to satisfy the requirements for the `MessengerBase` class, the
`ISelectableItemsMessenger` class needs to take an `IHasInputs<T>`, as that is
the device that implements `IKeyName`. We may want to consider adding a
`IHasInputsMessenger` specifically for those devices that implement that
interface vs the `ISelectableItemsMessenger`.
2025-04-09 10:49:31 -05:00
Neil Dorin
403c03491c Merge pull request #1245 from PepperDash/fix-add-client
Update `mobileadduiclient` command & `CrestronGenericBaseDevice.CustomActivate` method
2025-04-08 12:47:08 -06:00
Andrew Welker
3770c2a47d fix: call the EssentialsDevice custom activate
`CrestronGenericBaseDevice` was NOT calling `base.CustomActivate()` in
it's `CustomActivate` override, causing the
`CreateMobileControlMessengers` method to not be called as expected when
plugin devices were inheriting from `CrestronGenericBaseDevice` or
`CrestronGenericBridgeableBaseDevice`.
2025-04-08 13:35:58 -05:00
Andrew Welker
5f4a1f768e fix: check for grant code in mobileadduiclient
If the grant code was not provided, the `mobileadduiclient` console
command would fail silently. The command now checks that the correct
number of arguments was provided and prints an error to the console of
one is missing
2025-04-08 13:32:50 -05:00
Neil Dorin
7eed7866f1 Merge pull request #1243 from PepperDash/routing-fixes
Routing fixes
2025-04-04 09:50:27 -06:00
Andrew Welker
c5403f33c5 fix: add previous condition back to the flag check
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-04-04 10:49:04 -05:00
Andrew Welker
c9f10ecb90 build: delete clz files on build 2025-04-04 08:09:42 -05:00
Andrew Welker
ef2da21c2a chore: remove old InRoomPc class
class has moved to Devices.Common library
2025-04-04 08:09:32 -05:00
Andrew Welker
b0920746d1 feat: check base folder for cplz and ir files
In an effort to make things easier for devs and end users, the plugin loading logic will now find .cplz files that are in the `Global.FilePathPrefix` base folder (/user/program{programNumber}/` on an appliance, `/user/` on a server). The same applies for IR files. This should make it so that individual plugin cplzs can be loaded via the VC-4 web interface.
2025-04-04 08:09:24 -05:00
Andrew Welker
b531d724ff fix: add OverrideType property to TieLineConfig
The TielineConfig had no property for the `type` property from an Essentials configuration file to be deserialized into. This has been corrected so that the `type` property in a Tieline JSON configuration is now respected and used to build the tieline.
2025-04-04 00:04:53 -05:00
Andrew Welker
1b17d92ee0 fix: Essentials Routing now checks for SecondaryAudio if necessary
To support NVX Routing, checking for the SecondaryAudio routing type is necessary to find the correct path through the system for audio.
2025-04-04 00:03:21 -05:00
14 changed files with 334 additions and 208 deletions

View File

@@ -1,5 +1,9 @@
<Project>
<ItemGroup>
<ItemGroup>
<None Include="$(TargetDir)$(TargetName).$(Version).$(TargetFramework).clz" Condition="$(ProjectType) == 'Library'">
<Pack>true</Pack>
<PackagePath>build;</PackagePath>
</None>
<None Include="$(TargetDir)$(TargetName).$(Version).$(TargetFramework).cpz" Condition="$(ProjectType) == 'Program'">
<Pack>true</Pack>
<PackagePath>build;</PackagePath>
@@ -9,30 +13,41 @@
<PackagePath>build;</PackagePath>
</None>
</ItemGroup>
<PropertyGroup Condition="$(ProjectType) == 'Library'">
<FileName>$(TargetDir)$(TargetName).$(Version).$(TargetFramework).clz</FileName>
</PropertyGroup>
<PropertyGroup Condition="$(ProjectType) == 'ProgramLibrary'">
<FileName>$(TargetDir)$(TargetName).$(Version).$(TargetFramework).cplz</FileName>
</PropertyGroup>
<PropertyGroup Condition="$(ProjectType) == 'Program'">
<FileName>$(TargetDir)$(TargetName).$(Version).$(TargetFramework).cpz</FileName>
</PropertyGroup>
<Target Name="DeleteCPLZ" BeforeTargets="PreBuildEvent" Condition="$(ProjectType) == 'ProgramLibrary' And $(TargetDir) != '' And Exists($(FileName))">
<Delete Files="$(TargetDir)$(TargetName).$(Version).$(TargetFramework).cplz">
<Target Name="DeleteCLZ" BeforeTargets="PreBuildEvent" Condition="$(ProjectType) == 'Library' And $(TargetDir) != '' And Exists($(FileName))">
<Delete Files="$(TargetDir)$(TargetName).$(Version).$(TargetFramework).clz">
<Output TaskParameter="DeletedFiles" ItemName="DeletedList"/>
</Delete>
<Message Text="Deleted files: '@(DeletedList)'" />
</Target>
<Target Name="CreateCPLZ" AfterTargets="Build" Condition="$(ProjectType) == 'ProgramLibrary' And $(TargetDir) != ''" DependsOnTargets="DeleteCPLZ">
<Message Text="Creating CPLZ $(TargetDir)"></Message>
<MakeDir Directories="$(PackageOutputPath)" Condition="!Exists($(PackageOutputPath))" />
<ZipDirectory SourceDirectory="$(TargetDir)" DestinationFile="$(PackageOutputPath)\$(TargetName).$(Version).$(TargetFramework).cplz" Overwrite="true"/>
<Copy SourceFiles="$(PackageOutputPath)\$(TargetName).$(Version).$(TargetFramework).cplz" DestinationFiles="$(TargetDir)$(TargetName).$(Version).$(TargetFramework).cplz" />
</Target>
<Target Name="DeleteCPZ" BeforeTargets="PreBuildEvent" Condition="$(ProjectType) == 'Program' And $(TargetDir) != '' And Exists($(FileName))">
<Delete Files="$(TargetDir)$(TargetName).$(Version).$(TargetFramework).cpz">
<Output TaskParameter="DeletedFiles" ItemName="DeletedList"/>
</Delete>
<Message Text="Deleted files: '@(DeletedList)'" />
</Target>
<Target Name="DeleteCPLZ" BeforeTargets="PreBuildEvent" Condition="$(ProjectType) == 'ProgramLibrary' And $(TargetDir) != '' And Exists($(FileName))">
<Delete Files="$(TargetDir)$(TargetName).$(Version).$(TargetFramework).cplz">
<Output TaskParameter="DeletedFiles" ItemName="DeletedList"/>
</Delete>
<Message Text="Deleted files: '@(DeletedList)'" />
</Target>
<Target Name="CreateCPLZ" AfterTargets="Build" Condition="$(ProjectType) == 'ProgramLibrary' And $(TargetDir) != ''" DependsOnTargets="DeleteCPLZ">
<Message Text="Creating CPLZ $(TargetDir)"></Message>
<MakeDir Directories="$(PackageOutputPath)" Condition="!Exists($(PackageOutputPath))" />
<ZipDirectory SourceDirectory="$(TargetDir)" DestinationFile="$(PackageOutputPath)\$(TargetName).$(Version).$(TargetFramework).cplz" Overwrite="true"/>
<Copy SourceFiles="$(PackageOutputPath)\$(TargetName).$(Version).$(TargetFramework).cplz" DestinationFiles="$(TargetDir)$(TargetName).$(Version).$(TargetFramework).cplz" />
</Target>
<Target Name="Copy CLZ" AfterTargets="SimplSharpPostProcess" Condition="($(ProjectType) == 'Library')">
<Message Text="Copying CLZ"></Message>
<Move SourceFiles="$(TargetDir)\$(TargetName).clz" DestinationFiles="$(TargetDir)\$(TargetName).$(Version).$(TargetFramework).clz"/>

View File

@@ -104,7 +104,7 @@ namespace PepperDash.Essentials.Core
Hardware.OnlineStatusChange += Hardware_OnlineStatusChange;
CommunicationMonitor.Start();
return true;
return base.CustomActivate();
}
/// <summary>

View File

@@ -12,6 +12,8 @@ using PepperDash.Essentials.Core.Config;
using PepperDash.Core;
using Serilog.Events;
using System.IO;
using PepperDash.Core.Logging;
namespace PepperDash.Essentials.Core
{
@@ -69,7 +71,26 @@ namespace PepperDash.Essentials.Core
return;
}
var filePath = Global.FilePathPrefix + "ir" + Global.DirectorySeparator + config.Properties["control"]["irFile"].Value<string>();
// var filePath = Global.FilePathPrefix + "ir" + Global.DirectorySeparator + config.Properties["control"]["irFile"].Value<string>();
var fileName = config.Properties["control"]["irFile"].Value<string>();
var files = Directory.GetFiles(Global.FilePathPrefix, fileName, SearchOption.AllDirectories);
if(files.Length == 0)
{
this.LogError("IR file {fileName} not found in {path}", fileName, Global.FilePathPrefix);
return;
}
if(files.Length > 1)
{
this.LogError("IR file {fileName} found in multiple locations: {files}", fileName, files);
return;
}
var filePath = files[0];
Debug.LogMessage(LogEventLevel.Debug, "*************Attempting to load IR file: {0}***************", filePath);
LoadDriver(filePath);

View File

@@ -1,81 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Crestron.SimplSharpPro;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
using PepperDash.Core;
using Serilog.Events;
namespace PepperDash.Essentials.Core.Devices
{
[Obsolete("Please use PepperDash.Essentials.Devices.Common, this will be removed in 2.1")]
public class InRoomPc : EssentialsDevice, 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
}
[Obsolete("Please use PepperDash.Essentials.Devices.Common, this will be removed in 2.1")]
public class InRoomPcFactory : EssentialsDeviceFactory<InRoomPc>
{
public InRoomPcFactory()
{
TypeNames = new List<string>() { "inroompc" };
}
public override EssentialsDevice BuildDevice(DeviceConfig dc)
{
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new InRoomPc Device");
return new InRoomPc(dc.Key, dc.Name);
}
}
}

View File

@@ -1,16 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport;
using System.ComponentModel;
using PepperDash.Core;
using Serilog.Events;
using System.Threading;
using PepperDash.Core.Logging;
namespace PepperDash.Essentials.Core
{
@@ -31,35 +22,32 @@ namespace PepperDash.Essentials.Core
/// <summary>
/// Return true if the Client is ISocketStatus
/// </summary>
public bool IsSocket
{
get
{
return Client is ISocketStatus;
}
}
public bool IsSocket => Client is ISocketStatus;
long PollTime;
CTimer PollTimer;
string PollString;
Action PollAction;
/// <summary>
///
/// </summary>
/// <param name="client"></param>
/// <param name="pollTime">in MS, >= 5000</param>
/// <param name="warningTime">in MS, >= 5000</param>
/// <param name="errorTime">in MS, >= 5000</param>
/// <param name="pollString">String to send to comm</param>
public GenericCommunicationMonitor(IKeyed parent, IBasicCommunication client, long pollTime,
private readonly string PollString;
private readonly Action PollAction;
private readonly long PollTime;
private Timer PollTimer;
/// <summary>
/// GenericCommunicationMonitor constructor
///
/// Note: If the client is a socket, the connection status will be monitored and the PollTimer will be started automatically when the client is connected
/// </summary>
/// <param name="parent">Parent device</param>
/// <param name="client">Communications Client</param>
/// <param name="pollTime">Time in MS for polling</param>
/// <param name="warningTime">Warning time in MS. If a message is not received before this elapsed time the status will be Warning</param>
/// <param name="errorTime">Error time in MS. If a message is not received before this elapsed time the status will be Error</param>
/// <param name="pollString">string to send for polling</param>
/// <exception cref="ArgumentException">Poll time must be less than warning and error time</exception>
public GenericCommunicationMonitor(IKeyed parent, IBasicCommunication client, long pollTime,
long warningTime, long errorTime, string pollString) :
base(parent, warningTime, errorTime)
{
if (pollTime > warningTime || pollTime > errorTime)
throw new ArgumentException("pollTime must be less than warning or errorTime");
//if (pollTime < 5000)
// throw new ArgumentException("pollTime cannot be less than 5000 ms");
Client = client;
PollTime = pollTime;
@@ -67,26 +55,41 @@ namespace PepperDash.Essentials.Core
if (IsSocket)
{
(Client as ISocketStatus).ConnectionChange += new EventHandler<GenericSocketStatusChageEventArgs>(socket_ConnectionChange);
(Client as ISocketStatus).ConnectionChange += Socket_ConnectionChange;
}
}
/// <summary>
/// GenericCommunicationMonitor constructor with a bool to specify whether to monitor BytesReceived
///
/// Note: If the client is a socket, the connection status will be monitored and the PollTimer will be started automatically when the client is connected
/// </summary>
/// <param name="parent">Parent device</param>
/// <param name="client">Communications Client</param>
/// <param name="pollTime">Time in MS for polling</param>
/// <param name="warningTime">Warning time in MS. If a message is not received before this elapsed time the status will be Warning</param>
/// <param name="errorTime">Error time in MS. If a message is not received before this elapsed time the status will be Error</param>
/// <param name="pollString">string to send for polling</param>
/// <param name="monitorBytesReceived">Use bytesReceived event instead of textReceived when true</param>
public GenericCommunicationMonitor(IKeyed parent, IBasicCommunication client, long pollTime,
long warningTime, long errorTime, string pollString, bool monitorBytesReceived) :
this(parent, client, pollTime, warningTime, errorTime, pollString)
{
SetMonitorBytesReceived(monitorBytesReceived);
MonitorBytesReceived = monitorBytesReceived;
}
/// <summary>
/// Poll is a provided action instead of string
/// GenericCommunicationMonitor constructor with a poll action instead of a poll string
///
/// Note: If the client is a socket, the connection status will be monitored and the PollTimer will be started automatically when the client is connected
/// </summary>
/// <param name="parent"></param>
/// <param name="client"></param>
/// <param name="pollTime"></param>
/// <param name="warningTime"></param>
/// <param name="errorTime"></param>
/// <param name="pollBytes"></param>
/// <param name="parent">Parent device</param>
/// <param name="client">Communications Client</param>
/// <param name="pollTime">Time in MS for polling</param>
/// <param name="warningTime">Warning time in MS. If a message is not received before this elapsed time the status will be Warning</param>
/// <param name="errorTime">Error time in MS. If a message is not received before this elapsed time the status will be Error</param>
/// <param name="pollAction">Action to execute for polling</param>
/// <exception cref="ArgumentException">Poll time must be less than warning and error time</exception>
public GenericCommunicationMonitor(IKeyed parent, IBasicCommunication client, long pollTime,
long warningTime, long errorTime, Action pollAction) :
base(parent, warningTime, errorTime)
@@ -102,51 +105,67 @@ namespace PepperDash.Essentials.Core
if (IsSocket)
{
(Client as ISocketStatus).ConnectionChange += new EventHandler<GenericSocketStatusChageEventArgs>(socket_ConnectionChange);
(Client as ISocketStatus).ConnectionChange += Socket_ConnectionChange;
}
}
/// <summary>
/// GenericCommunicationMonitor constructor with a poll action instead of a poll string and a bool to specify whether to monitor BytesReceived
///
/// Note: If the client is a socket, the connection status will be monitored and the PollTimer will be started automatically when the client is connected
/// </summary>
/// <param name="parent">Parent device</param>
/// <param name="client">Communications Client</param>
/// <param name="pollTime">Time in MS for polling</param>
/// <param name="warningTime">Warning time in MS. If a message is not received before this elapsed time the status will be Warning</param>
/// <param name="errorTime">Error time in MS. If a message is not received before this elapsed time the status will be Error</param>
/// <param name="pollAction">Action to execute for polling</param>
/// <param name="monitorBytesReceived">Use bytesReceived event instead of textReceived when true</param>
public GenericCommunicationMonitor(IKeyed parent, IBasicCommunication client, long pollTime,
long warningTime, long errorTime, Action pollAction, bool monitorBytesReceived) :
this(parent, client, pollTime, warningTime, errorTime, pollAction)
{
SetMonitorBytesReceived(monitorBytesReceived);
MonitorBytesReceived = monitorBytesReceived;
}
/// <summary>
/// Build the monitor from a config object
/// </summary>
public GenericCommunicationMonitor(IKeyed parent, IBasicCommunication client,
/// <summary>
/// GenericCommunicationMonitor constructor with a config object
///
/// Note: If the client is a socket, the connection status will be monitored and the PollTimer will be started automatically when the client is connected
/// </summary>
/// <param name="parent">Parent Device</param>
/// <param name="client">Communications Client</param>
/// <param name="props"><see cref="CommunicationMonitorConfig">Communication Monitor Config</see> object</param>
public GenericCommunicationMonitor(IKeyed parent, IBasicCommunication client,
CommunicationMonitorConfig props) :
this(parent, client, props.PollInterval, props.TimeToWarning, props.TimeToError, props.PollString)
{
if (IsSocket)
{
(Client as ISocketStatus).ConnectionChange += new EventHandler<GenericSocketStatusChageEventArgs>(socket_ConnectionChange);
(Client as ISocketStatus).ConnectionChange += Socket_ConnectionChange;
}
}
/// <summary>
/// Builds the monitor from a config object and takes a bool to specify whether to monitor BytesReceived
/// Default is to monitor TextReceived
/// GenericCommunicationMonitor constructor with a config object and a bool to specify whether to monitor BytesReceived
///
/// Note: If the client is a socket, the connection status will be monitored and the PollTimer will be started automatically when the client is connected
/// </summary>
/// <param name="parent"></param>
/// <param name="client"></param>
/// <param name="props"></param>
/// <param name="monitorBytesReceived"></param>
/// <param name="parent">Parent Device</param>
/// <param name="client">Communications Client</param>
/// <param name="props"><see cref="CommunicationMonitorConfig">Communication Monitor Config</see> object</param>
/// <param name="monitorBytesReceived">Use bytesReceived event instead of textReceived when true</param>
public GenericCommunicationMonitor(IKeyed parent, IBasicCommunication client, CommunicationMonitorConfig props, bool monitorBytesReceived) :
this(parent, client, props.PollInterval, props.TimeToWarning, props.TimeToError, props.PollString)
{
SetMonitorBytesReceived(monitorBytesReceived);
}
void SetMonitorBytesReceived(bool monitorBytesReceived)
{
MonitorBytesReceived = monitorBytesReceived;
}
/// <summary>
/// Start the poll cycle
/// </summary>
public override void Start()
{
if (MonitorBytesReceived)
@@ -163,7 +182,7 @@ namespace PepperDash.Essentials.Core
BeginPolling();
}
void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e)
private void Socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e)
{
if (!e.Client.IsConnected)
{
@@ -176,58 +195,65 @@ namespace PepperDash.Essentials.Core
{
// Start polling and set status to unknow and let poll result update the status to IsOk when a response is received
Status = MonitorStatus.StatusUnknown;
Start();
BeginPolling();
Start();
}
}
void BeginPolling()
private void BeginPolling()
{
Poll();
PollTimer = new CTimer(o => Poll(), null, PollTime, PollTime);
lock (_pollTimerLock)
{
if (PollTimer != null)
{
return;
}
PollTimer = new Timer(o => Poll(), null, 0, PollTime);
}
}
/// <summary>
/// Stop the poll cycle
/// </summary>
public override void Stop()
{
if(MonitorBytesReceived)
{
Client.BytesReceived -= this.Client_BytesReceived;
Client.BytesReceived -= Client_BytesReceived;
}
else
{
Client.TextReceived -= Client_TextReceived;
}
if (PollTimer != null)
StopErrorTimers();
if (PollTimer == null)
{
PollTimer.Stop();
PollTimer = null;
StopErrorTimers();
return;
}
PollTimer.Dispose();
PollTimer = null;
}
void Client_TextReceived(object sender, GenericCommMethodReceiveTextArgs e)
private void Client_TextReceived(object sender, GenericCommMethodReceiveTextArgs e)
{
DataReceived();
}
/// <summary>
/// Upon any receipt of data, set everything to ok!
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void Client_BytesReceived(object sender, GenericCommMethodReceiveBytesArgs e)
private void Client_BytesReceived(object sender, GenericCommMethodReceiveBytesArgs e)
{
DataReceived();
}
void DataReceived()
private void DataReceived()
{
Status = MonitorStatus.IsOk;
ResetErrorTimers();
}
void Poll()
private void Poll()
{
StartErrorTimers();
if (Client.IsConnected)
@@ -240,12 +266,14 @@ namespace PepperDash.Essentials.Core
}
else
{
Debug.LogMessage(LogEventLevel.Verbose, this, "Comm not connected");
this.LogVerbose("Comm not connected");
}
}
}
/// <summary>
/// Communication Monitor Configuration from Essentials Configuration
/// </summary>
public class CommunicationMonitorConfig
{
public int PollInterval { get; set; }
@@ -253,6 +281,9 @@ namespace PepperDash.Essentials.Core
public int TimeToError { get; set; }
public string PollString { get; set; }
/// <summary>
/// Default constructor. Sets pollInterval to 30s, TimeToWarning to 120s, and TimeToError to 300s
/// </summary>
public CommunicationMonitorConfig()
{
PollInterval = 30000;

View File

@@ -2,13 +2,14 @@
using System.Collections.Generic;
using System.Linq;
using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO;
// using Crestron.SimplSharp.CrestronIO;
using System.Reflection;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using Serilog.Events;
using Newtonsoft.Json;
using System.IO;
namespace PepperDash.Essentials
{
@@ -283,11 +284,21 @@ namespace PepperDash.Essentials
/// </summary>
static void UnzipAndMoveCplzArchives()
{
Debug.LogMessage(LogEventLevel.Information, "Looking for .cplz archives from plugins folder...");
var di = new DirectoryInfo(_pluginDirectory);
var zFiles = di.GetFiles("*.cplz");
Debug.LogMessage(LogEventLevel.Information, "Looking for .cplz archives from user folder...");
//var di = new DirectoryInfo(_pluginDirectory);
//var zFiles = di.GetFiles("*.cplz");
if (zFiles.Length > 0)
//// Find cplz files at the root of the user folder. Makes development/testing easier for VC-4, and helps with mistakes by end users
//var userDi = new DirectoryInfo(Global.FilePathPrefix);
//var userZFiles = userDi.GetFiles("*.cplz");
Debug.LogInformation("Checking {folder} for .cplz files", Global.FilePathPrefix);
var cplzFiles = Directory.GetFiles(Global.FilePathPrefix, "*.cplz", SearchOption.AllDirectories)
.Select(f => new FileInfo(f))
.ToArray();
if (cplzFiles.Length > 0)
{
if (!Directory.Exists(_loadedPluginsDirectoryPath))
{
@@ -295,12 +306,12 @@ namespace PepperDash.Essentials
}
}
foreach (var zfi in zFiles)
foreach (var zfi in cplzFiles)
{
Directory.CreateDirectory(_tempDirectory);
var tempDi = new DirectoryInfo(_tempDirectory);
Debug.LogMessage(LogEventLevel.Information, "Found cplz: {0}. Unzipping into temp plugins directory", zfi.Name);
Debug.LogMessage(LogEventLevel.Information, "Found cplz: {0}. Unzipping into temp plugins directory", zfi.FullName);
var result = CrestronZIP.Unzip(zfi.FullName, tempDi.FullName);
Debug.LogMessage(LogEventLevel.Information, "UnZip Result: {0}", result.ToString());

View File

@@ -1,4 +1,5 @@
using PepperDash.Essentials.Core.Queues;
using Crestron.SimplSharpPro.Keypads;
using PepperDash.Essentials.Core.Queues;
using PepperDash.Essentials.Core.Routing;
using Serilog.Events;
using System;
@@ -88,9 +89,17 @@ namespace PepperDash.Essentials.Core
Debug.LogMessage(LogEventLevel.Debug, "Attempting to build source route from {sourceKey} of type {type}", destination, source.Key);
var audioRouteDescriptor = new RouteDescriptor(source, destination, destinationPort, eRoutingSignalType.Audio);
RouteDescriptor audioRouteDescriptor;
var audioSuccess = destination.GetRouteToSource(source, null, null, eRoutingSignalType.Audio, 0, audioRouteDescriptor, destinationPort, sourcePort);
if (signalType.HasFlag(eRoutingSignalType.SecondaryAudio))
{
audioRouteDescriptor = new RouteDescriptor(source, destination, destinationPort, eRoutingSignalType.SecondaryAudio);
} else
{
audioRouteDescriptor = new RouteDescriptor(source, destination, destinationPort, eRoutingSignalType.Audio);
}
var audioSuccess = destination.GetRouteToSource(source, null, null, signalType.HasFlag(eRoutingSignalType.SecondaryAudio) ? eRoutingSignalType.SecondaryAudio : eRoutingSignalType.Audio, 0, audioRouteDescriptor, destinationPort, sourcePort);
if (!audioSuccess)
Debug.LogMessage(LogEventLevel.Debug, "Cannot find audio route to {0}", destination, source.Key);
@@ -268,13 +277,12 @@ namespace PepperDash.Essentials.Core
if (destinationPort == null)
{
destinationTieLines = TieLineCollection.Default.Where(t =>
t.DestinationPort.ParentDevice.Key == destination.Key && (t.Type == signalType || t.Type.HasFlag(eRoutingSignalType.AudioVideo)));
t.DestinationPort.ParentDevice.Key == destination.Key && (t.Type.HasFlag(signalType) || signalType == eRoutingSignalType.AudioVideo));
}
else
{
destinationTieLines = TieLineCollection.Default.Where(t => t.DestinationPort.ParentDevice.Key == destination.Key && t.DestinationPort.Key == destinationPort.Key && (t.Type == signalType || t.Type.HasFlag(eRoutingSignalType.AudioVideo)));
destinationTieLines = TieLineCollection.Default.Where(t => t.DestinationPort.ParentDevice.Key == destination.Key && t.DestinationPort.Key == destinationPort.Key && (t.Type.HasFlag(signalType)));
}
// find the TieLine without a port

View File

@@ -57,6 +57,16 @@ namespace PepperDash.Essentials.Core
DestinationPort = destinationPort;
}
/// <summary>
/// Creates a tie line with an overriding Type. See help for OverrideType property for info
/// </summary>
/// <param name="overrideType">The signal type to limit the link to. Overrides DestinationPort.Type</param>
public TieLine(RoutingOutputPort sourcePort, RoutingInputPort destinationPort, eRoutingSignalType? overrideType) :
this(sourcePort, destinationPort)
{
OverrideType = overrideType;
}
/// <summary>
/// Creates a tie line with an overriding Type. See help for OverrideType property for info
/// </summary>

View File

@@ -7,6 +7,7 @@ using Crestron.SimplSharp.CrestronIO;
using Crestron.SimplSharpPro;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Essentials.Core;
@@ -23,6 +24,10 @@ namespace PepperDash.Essentials.Core.Config
public string DestinationCard { get; set; }
public string DestinationPort { get; set; }
[JsonProperty("type", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(StringEnumConverter))]
public eRoutingSignalType? OverrideType { get; set; }
/// <summary>
/// Returns the appropriate tie line for either a card-based device or
/// regular device with ports on-device.
@@ -65,7 +70,7 @@ namespace PepperDash.Essentials.Core.Config
return null;
}
return new TieLine(sourceOutputPort, destinationInputPort);
return new TieLine(sourceOutputPort, destinationInputPort, OverrideType);
}
void LogError(string msg)

View File

@@ -0,0 +1,101 @@
using Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Core.Logging;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using System;
using System.Collections.Generic;
namespace PepperDash.Essentials.AppServer.Messengers
{
public class IHasInputsMessenger<TKey> : MessengerBase
{
private readonly IHasInputs<TKey> itemDevice;
/// <summary>
/// Constructs a messenger for a device that implements IHasInputs<typeparamref name="TKey"/>
/// </summary>
/// <param name="key"></param>
/// <param name="messagePath"></param>
/// <param name="device"></param>
public IHasInputsMessenger(string key, string messagePath, IHasInputs<TKey> device) : base(key, messagePath, device)
{
itemDevice = device;
}
protected override void RegisterActions()
{
base.RegisterActions();
AddAction("/fullStatus", (id, context) =>
{
SendFullStatus();
});
itemDevice.Inputs.ItemsUpdated += (sender, args) =>
{
SendFullStatus();
};
itemDevice.Inputs.CurrentItemChanged += (sender, args) =>
{
SendFullStatus();
};
foreach (var input in itemDevice.Inputs.Items)
{
var key = input.Key;
var localItem = input.Value;
AddAction($"/{key}", (id, content) =>
{
localItem.Select();
});
localItem.ItemUpdated += (sender, args) =>
{
SendFullStatus();
};
}
}
private void SendFullStatus()
{
try
{
this.LogInformation("Sending full status");
var stateObject = new IHasInputsStateMessage<TKey>
{
Inputs = new Inputs<TKey>
{
Items = itemDevice.Inputs.Items,
CurrentItem = itemDevice.Inputs.CurrentItem
}
};
PostStatusMessage(stateObject);
}
catch (Exception e)
{
this.LogError("Error sending full status: {0}", e.Message);
}
}
}
public class IHasInputsStateMessage<TKey> : DeviceStateMessageBase
{
[JsonProperty("inputs")]
public Inputs<TKey> Inputs { get; set; }
}
public class Inputs<TKey>
{
[JsonProperty("items")]
public Dictionary<TKey, ISelectableItem> Items { get; set; }
[JsonProperty("currentItem")]
public TKey CurrentItem { get; set; }
}
}

View File

@@ -1,6 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Core.Logging;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
@@ -10,11 +8,18 @@ using System.Collections.Generic;
namespace PepperDash.Essentials.AppServer.Messengers
{
public class ISelectableItemsMessenger<TKey> : MessengerBase
{
private static readonly JsonSerializer serializer = new JsonSerializer { Converters = { new StringEnumConverter() } };
{
private readonly ISelectableItems<TKey> itemDevice;
private readonly string _propName;
/// <summary>
/// Constructs a messenger for a device that implements ISelectableItems<typeparamref name="TKey"/>
/// </summary>
/// <param name="key"></param>
/// <param name="messagePath"></param>
/// <param name="device"></param>
/// <param name="propName"></param>
public ISelectableItemsMessenger(string key, string messagePath, ISelectableItems<TKey> device, string propName) : base(key, messagePath, device as IKeyName)
{
itemDevice = device;

View File

@@ -763,11 +763,10 @@ namespace PepperDash.Essentials
{
this.LogVerbose("Adding InputsMessenger<string> for {deviceKey}", device.Key);
var messenger = new ISelectableItemsMessenger<string>(
var messenger = new IHasInputsMessenger<string>(
$"{device.Key}-inputs-{Key}",
$"/device/{device.Key}",
stringInputs.Inputs,
"inputs"
stringInputs
);
AddDefaultDeviceMessenger(messenger);
@@ -779,11 +778,10 @@ namespace PepperDash.Essentials
{
this.LogVerbose("Adding InputsMessenger for {deviceKey}", device.Key);
var messenger = new ISelectableItemsMessenger<byte>(
var messenger = new IHasInputsMessenger<byte>(
$"{device.Key}-inputs-{Key}",
$"/device/{device.Key}",
byteInputs.Inputs,
"inputs"
byteInputs
);
AddDefaultDeviceMessenger(messenger);
@@ -795,11 +793,10 @@ namespace PepperDash.Essentials
{
this.LogVerbose("Adding InputsMessenger for {deviceKey}", device.Key);
var messenger = new ISelectableItemsMessenger<int>(
var messenger = new IHasInputsMessenger<int>(
$"{device.Key}-inputs-{Key}",
$"/device/{device.Key}",
intInputs.Inputs,
"inputs"
intInputs
);
AddDefaultDeviceMessenger(messenger);

View File

@@ -113,10 +113,7 @@ namespace PepperDash.Essentials
_server.SendMessageToAllClients(message);
_server.LogVerbose("Message TX To all clients: {message}", null, message);
_server.LogVerbose("Message TX To all clients: {message}", message);
}
catch (ThreadAbortException)
{
@@ -126,8 +123,6 @@ namespace PepperDash.Essentials
{
Debug.LogMessage(ex, "Caught an exception in the Transmit Processor");
}
}
#endregion
}

View File

@@ -679,6 +679,14 @@ namespace PepperDash.Essentials.WebSocketServer
}
var values = s.Split(' ');
if(values.Length < 2)
{
CrestronConsole.ConsoleCommandResponse("Invalid number of arguments. Please provide a room key and a grant code");
return;
}
var roomKey = values[0];
var grantCode = values[1];