mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-01-18 15:05:01 +00:00
Compare commits
83 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d93662b31 | ||
|
|
11b190e76f | ||
|
|
df03a71cbc | ||
|
|
72e67a1c4c | ||
|
|
f8728b6825 | ||
|
|
d9ef8a2289 | ||
|
|
278408a3bc | ||
|
|
5921b5dbb0 | ||
|
|
ba0de5128f | ||
|
|
258699fbcd | ||
|
|
738504e9fc | ||
|
|
cae1bbd6e6 | ||
|
|
dea4407e3e | ||
|
|
ab08a546f7 | ||
|
|
ef98d47792 | ||
|
|
c05976ee60 | ||
|
|
4ca1031bef | ||
|
|
6d61c4525e | ||
|
|
3db274ace5 | ||
|
|
f0f708294c | ||
|
|
a00d186c62 | ||
|
|
51da668dfd | ||
|
|
d2b7400039 | ||
|
|
2424838b7f | ||
|
|
9556edc064 | ||
|
|
f9088691fd | ||
|
|
e40b6a8b4c | ||
|
|
c3b39a87da | ||
|
|
06dc0e947e | ||
|
|
147997f460 | ||
|
|
49abec5eea | ||
|
|
6830efe42a | ||
|
|
d013068a0c | ||
|
|
52916d29f4 | ||
|
|
19e8489166 | ||
|
|
fe33443b25 | ||
|
|
8cf195b262 | ||
|
|
40406b797d | ||
|
|
65bc408ebf | ||
|
|
9d49fb8357 | ||
|
|
fb7797dac7 | ||
|
|
574f5f6dc9 | ||
|
|
e49c69a12f | ||
|
|
7889cba196 | ||
|
|
033aa1f3dd | ||
|
|
9b6c2d80ea | ||
|
|
a0fc731701 | ||
|
|
f2d0dca7b8 | ||
|
|
ab4e85d081 | ||
|
|
47017da527 | ||
|
|
4f0d464ba4 | ||
|
|
0107422507 | ||
|
|
1a366790e7 | ||
|
|
97448f4f0f | ||
|
|
cf3ece4237 | ||
|
|
bb4b2f88b6 | ||
|
|
808e8042a7 | ||
|
|
0bc4388bfd | ||
|
|
dbc132c0da | ||
|
|
5bb0ab2626 | ||
|
|
27bf36c58c | ||
|
|
ce886aea63 | ||
|
|
ef920bf54c | ||
|
|
a031424752 | ||
|
|
fd1ba345aa | ||
|
|
e03874a7a9 | ||
|
|
a41aba1904 | ||
|
|
b47f1d6b77 | ||
|
|
fda4a5a816 | ||
|
|
9f70e3c721 | ||
|
|
ec6aeb17f6 | ||
|
|
91dc655103 | ||
|
|
bf31fb10eb | ||
|
|
5e21bad596 | ||
|
|
2368f0c8cc | ||
|
|
be58a0bc29 | ||
|
|
8406f69e0d | ||
|
|
116d83394a | ||
|
|
9b8e452eb4 | ||
|
|
c9d86bd5dd | ||
|
|
b2b257020f | ||
|
|
6f58e18d14 | ||
|
|
60fc0298ec |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -395,3 +395,4 @@ essentials-framework/Essentials Interfaces/PepperDash_Essentials_Interfaces/Pepp
|
||||
_site/
|
||||
api/
|
||||
*.DS_Store
|
||||
/._PepperDash.Essentials.4Series.sln
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<Version>2.4.0-local</Version>
|
||||
<Version>2.15.1-local</Version>
|
||||
<InformationalVersion>$(Version)</InformationalVersion>
|
||||
<Authors>PepperDash Technology</Authors>
|
||||
<Company>PepperDash Technology</Company>
|
||||
|
||||
@@ -74,6 +74,10 @@ namespace PepperDash.Core
|
||||
/// <summary>
|
||||
/// Secure TCP/IP
|
||||
/// </summary>
|
||||
SecureTcpIp
|
||||
SecureTcpIp,
|
||||
/// <summary>
|
||||
/// Used when comms needs to be handled in SIMPL and bridged opposite the normal direction
|
||||
/// </summary>
|
||||
ComBridge
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using Crestron.SimplSharp;
|
||||
@@ -19,7 +20,6 @@ using Serilog.Templates;
|
||||
namespace PepperDash.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains debug commands for use in various situations
|
||||
/// </summary>
|
||||
public static class Debug
|
||||
{
|
||||
@@ -272,6 +272,9 @@ namespace PepperDash.Core
|
||||
if (result != CrestronDataStore.CDS_ERROR.CDS_SUCCESS)
|
||||
{
|
||||
CrestronConsole.Print($"Unable to retrieve stored log level for {levelStoreKey}.\r\nError: {result}.\r\nSetting level to {LogEventLevel.Information}\r\n");
|
||||
|
||||
CrestronDataStoreStatic.SetLocalIntValue(levelStoreKey, (int)LogEventLevel.Information);
|
||||
|
||||
return LogEventLevel.Information;
|
||||
}
|
||||
|
||||
@@ -346,13 +349,13 @@ namespace PepperDash.Core
|
||||
if (levelString.Trim() == "?")
|
||||
{
|
||||
CrestronConsole.ConsoleCommandResponse(
|
||||
$@"Used to set the minimum level of debug messages to be printed to the console:
|
||||
{_logLevels[0]} = 0
|
||||
{_logLevels[1]} = 1
|
||||
{_logLevels[2]} = 2
|
||||
{_logLevels[3]} = 3
|
||||
{_logLevels[4]} = 4
|
||||
{_logLevels[5]} = 5");
|
||||
"Used to set the minimum level of debug messages to be printed to the console:\r\n" +
|
||||
$"{_logLevels[0]} = 0\r\n" +
|
||||
$"{_logLevels[1]} = 1\r\n" +
|
||||
$"{_logLevels[2]} = 2\r\n" +
|
||||
$"{_logLevels[3]} = 3\r\n" +
|
||||
$"{_logLevels[4]} = 4\r\n" +
|
||||
$"{_logLevels[5]} = 5");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -373,7 +376,7 @@ namespace PepperDash.Core
|
||||
return;
|
||||
}
|
||||
|
||||
if (Enum.TryParse<LogEventLevel>(levelString, out var levelEnum))
|
||||
if (Enum.TryParse<LogEventLevel>(levelString, true, out var levelEnum))
|
||||
{
|
||||
SetDebugLevel(levelEnum);
|
||||
return;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Serilog.Events;
|
||||
using System;
|
||||
using System;
|
||||
using Serilog.Events;
|
||||
using Log = PepperDash.Core.Debug;
|
||||
|
||||
namespace PepperDash.Core.Logging
|
||||
@@ -11,7 +11,7 @@ namespace PepperDash.Core.Logging
|
||||
/// </summary>
|
||||
public static void LogException(this IKeyed device, Exception ex, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(ex, message, device, args);
|
||||
Log.LogMessage(ex, message, device: device, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -19,7 +19,7 @@ namespace PepperDash.Core.Logging
|
||||
/// </summary>
|
||||
public static void LogVerbose(this IKeyed device, Exception ex, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Verbose, ex, message, device, args);
|
||||
Log.LogVerbose(ex, device, message, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -27,7 +27,7 @@ namespace PepperDash.Core.Logging
|
||||
/// </summary>
|
||||
public static void LogVerbose(this IKeyed device, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Verbose, device, message, args);
|
||||
Log.LogVerbose(device, message, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -35,7 +35,7 @@ namespace PepperDash.Core.Logging
|
||||
/// </summary>
|
||||
public static void LogDebug(this IKeyed device, Exception ex, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Debug, ex, message, device, args);
|
||||
Log.LogDebug(ex, device, message, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -43,7 +43,7 @@ namespace PepperDash.Core.Logging
|
||||
/// </summary>
|
||||
public static void LogDebug(this IKeyed device, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Debug, device, message, args);
|
||||
Log.LogDebug(device, message, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -51,7 +51,7 @@ namespace PepperDash.Core.Logging
|
||||
/// </summary>
|
||||
public static void LogInformation(this IKeyed device, Exception ex, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Information, ex, message, device, args);
|
||||
Log.LogInformation(ex, device, message, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -59,7 +59,7 @@ namespace PepperDash.Core.Logging
|
||||
/// </summary>
|
||||
public static void LogInformation(this IKeyed device, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Information, device, message, args);
|
||||
Log.LogInformation(device, message, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -67,7 +67,7 @@ namespace PepperDash.Core.Logging
|
||||
/// </summary>
|
||||
public static void LogWarning(this IKeyed device, Exception ex, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Warning, ex, message, device, args);
|
||||
Log.LogWarning(ex, device, message, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -75,7 +75,7 @@ namespace PepperDash.Core.Logging
|
||||
/// </summary>
|
||||
public static void LogWarning(this IKeyed device, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Warning, device, message, args);
|
||||
Log.LogWarning(device, message, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -83,7 +83,7 @@ namespace PepperDash.Core.Logging
|
||||
/// </summary>
|
||||
public static void LogError(this IKeyed device, Exception ex, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Error, ex, message, device, args);
|
||||
Log.LogError(ex, device, message, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -91,7 +91,7 @@ namespace PepperDash.Core.Logging
|
||||
/// </summary>
|
||||
public static void LogError(this IKeyed device, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Error, device, message, args);
|
||||
Log.LogError(device, message, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -99,7 +99,7 @@ namespace PepperDash.Core.Logging
|
||||
/// </summary>
|
||||
public static void LogFatal(this IKeyed device, Exception ex, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Fatal, ex, message, device, args);
|
||||
Log.LogFatal(ex, device, message, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -107,7 +107,7 @@ namespace PepperDash.Core.Logging
|
||||
/// </summary>
|
||||
public static void LogFatal(this IKeyed device, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Fatal, device, message, args);
|
||||
Log.LogFatal(device, message, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,14 +2,12 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Crestron.SimplSharp;
|
||||
using System.Reflection;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
using Crestron.SimplSharpPro.EthernetCommunication;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using Serilog.Events;
|
||||
@@ -355,22 +353,22 @@ namespace PepperDash.Essentials.Core.Bridges
|
||||
/// </summary>
|
||||
public class EiscApiPropertiesConfig
|
||||
{
|
||||
[JsonProperty("control")]
|
||||
/// <summary>
|
||||
/// Gets or sets the Control
|
||||
/// </summary>
|
||||
[JsonProperty("control")]
|
||||
public EssentialsControlPropertiesConfig Control { get; set; }
|
||||
|
||||
[JsonProperty("devices")]
|
||||
/// <summary>
|
||||
/// Gets or sets the Devices
|
||||
/// </summary>
|
||||
[JsonProperty("devices")]
|
||||
public List<ApiDevicePropertiesConfig> Devices { get; set; }
|
||||
|
||||
[JsonProperty("rooms")]
|
||||
/// <summary>
|
||||
/// Gets or sets the Rooms
|
||||
/// </summary>
|
||||
[JsonProperty("rooms")]
|
||||
public List<ApiRoomPropertiesConfig> Rooms { get; set; }
|
||||
|
||||
|
||||
@@ -379,22 +377,22 @@ namespace PepperDash.Essentials.Core.Bridges
|
||||
/// </summary>
|
||||
public class ApiDevicePropertiesConfig
|
||||
{
|
||||
[JsonProperty("deviceKey")]
|
||||
/// <summary>
|
||||
/// Gets or sets the DeviceKey
|
||||
/// </summary>
|
||||
[JsonProperty("deviceKey")]
|
||||
public string DeviceKey { get; set; }
|
||||
|
||||
[JsonProperty("joinStart")]
|
||||
/// <summary>
|
||||
/// Gets or sets the JoinStart
|
||||
/// </summary>
|
||||
[JsonProperty("joinStart")]
|
||||
public uint JoinStart { get; set; }
|
||||
|
||||
[JsonProperty("joinMapKey")]
|
||||
/// <summary>
|
||||
/// Gets or sets the JoinMapKey
|
||||
/// </summary>
|
||||
[JsonProperty("joinMapKey")]
|
||||
public string JoinMapKey { get; set; }
|
||||
}
|
||||
|
||||
@@ -403,22 +401,22 @@ namespace PepperDash.Essentials.Core.Bridges
|
||||
/// </summary>
|
||||
public class ApiRoomPropertiesConfig
|
||||
{
|
||||
[JsonProperty("roomKey")]
|
||||
/// <summary>
|
||||
/// Gets or sets the RoomKey
|
||||
/// </summary>
|
||||
[JsonProperty("roomKey")]
|
||||
public string RoomKey { get; set; }
|
||||
|
||||
[JsonProperty("joinStart")]
|
||||
/// <summary>
|
||||
/// Gets or sets the JoinStart
|
||||
/// </summary>
|
||||
[JsonProperty("joinStart")]
|
||||
public uint JoinStart { get; set; }
|
||||
|
||||
[JsonProperty("joinMapKey")]
|
||||
/// <summary>
|
||||
/// Gets or sets the JoinMapKey
|
||||
/// </summary>
|
||||
[JsonProperty("joinMapKey")]
|
||||
public string JoinMapKey { get; set; }
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,13 @@ namespace PepperDash.Essentials.Core.Bridges
|
||||
/// </summary>
|
||||
public interface IBridgeAdvanced
|
||||
{
|
||||
/// <summary>
|
||||
/// Links the bridge to the API using the provided trilist, join start, join map key, and bridge.
|
||||
/// </summary>
|
||||
/// <param name="trilist">The trilist to link to.</param>
|
||||
/// <param name="joinStart">The starting join number.</param>
|
||||
/// <param name="joinMapKey">The key for the join map.</param>
|
||||
/// <param name="bridge">The EISC API bridge.</param>
|
||||
void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge);
|
||||
}
|
||||
}
|
||||
138
src/PepperDash.Essentials.Core/Comm and IR/CommBridge.cs
Normal file
138
src/PepperDash.Essentials.Core/Comm and IR/CommBridge.cs
Normal file
@@ -0,0 +1,138 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp.CrestronSockets;
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
using Newtonsoft.Json;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Core.Logging;
|
||||
using PepperDash.Essentials.Core.Bridges;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using PepperDash.Essentials.Core.Devices;
|
||||
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements IBasicCommunication and sends all communication through an EISC
|
||||
/// </summary>
|
||||
[Description("Generic communication wrapper class for any IBasicCommunication type")]
|
||||
public class CommBridge : EssentialsBridgeableDevice, IBasicCommunication
|
||||
{
|
||||
private EiscApiAdvanced eisc;
|
||||
|
||||
private IBasicCommunicationJoinMap joinMap;
|
||||
|
||||
/// <summary>
|
||||
/// Event triggered when text is received through the communication bridge.
|
||||
/// </summary>
|
||||
public event EventHandler<GenericCommMethodReceiveTextArgs> TextReceived;
|
||||
|
||||
/// <summary>
|
||||
/// Event triggered when bytes are received through the communication bridge.
|
||||
/// </summary>
|
||||
public event EventHandler<GenericCommMethodReceiveBytesArgs> BytesReceived;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the communication bridge is currently connected.
|
||||
/// </summary>
|
||||
public bool IsConnected { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CommBridge"/> class.
|
||||
/// </summary>
|
||||
/// <param name="key">The unique key for the communication bridge.</param>
|
||||
/// <param name="name">The display name for the communication bridge.</param>
|
||||
public CommBridge(string key, string name)
|
||||
: base(key, name)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a byte array through the communication bridge.
|
||||
/// </summary>
|
||||
/// <param name="bytes">The byte array to send.</param>
|
||||
public void SendBytes(byte[] bytes)
|
||||
{
|
||||
if (eisc == null)
|
||||
{
|
||||
this.LogWarning("EISC is null, cannot send bytes.");
|
||||
return;
|
||||
}
|
||||
eisc.Eisc.SetString(joinMap.SendText.JoinNumber, Encoding.ASCII.GetString(bytes, 0, bytes.Length));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a text string through the communication bridge.
|
||||
/// </summary>
|
||||
/// <param name="text">The text string to send.</param>
|
||||
public void SendText(string text)
|
||||
{
|
||||
if (eisc == null)
|
||||
{
|
||||
this.LogWarning("EISC is null, cannot send text.");
|
||||
return;
|
||||
}
|
||||
eisc.Eisc.SetString(joinMap.SendText.JoinNumber, text);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initiates a connection through the communication bridge.
|
||||
/// </summary>
|
||||
public void Connect()
|
||||
{
|
||||
if (eisc == null)
|
||||
{
|
||||
this.LogWarning("EISC is null, cannot connect.");
|
||||
return;
|
||||
}
|
||||
eisc.Eisc.SetBool(joinMap.Connect.JoinNumber, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Terminates the connection through the communication bridge.
|
||||
/// </summary>
|
||||
public void Disconnect()
|
||||
{
|
||||
if (eisc == null)
|
||||
{
|
||||
this.LogWarning("EISC is null, cannot disconnect.");
|
||||
return;
|
||||
}
|
||||
eisc.Eisc.SetBool(joinMap.Connect.JoinNumber, false);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
|
||||
{
|
||||
joinMap = new IBasicCommunicationJoinMap(joinStart);
|
||||
|
||||
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
|
||||
|
||||
if (!string.IsNullOrEmpty(joinMapSerialized))
|
||||
joinMap = JsonConvert.DeserializeObject<IBasicCommunicationJoinMap>(joinMapSerialized);
|
||||
|
||||
if (bridge != null)
|
||||
{
|
||||
bridge.AddJoinMap(Key, joinMap);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.LogWarning("Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
||||
}
|
||||
|
||||
this.LogDebug("Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
||||
|
||||
eisc = bridge;
|
||||
|
||||
trilist.SetBoolSigAction(joinMap.Connected.JoinNumber, (b) => IsConnected = b);
|
||||
|
||||
trilist.SetStringSigAction(joinMap.TextReceived.JoinNumber, (s) =>
|
||||
{
|
||||
TextReceived?.Invoke(this, new GenericCommMethodReceiveTextArgs(s));
|
||||
BytesReceived?.Invoke(this, new GenericCommMethodReceiveBytesArgs(Encoding.ASCII.GetBytes(s)));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
|
||||
|
||||
using System;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.DM;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using Serilog.Events;
|
||||
@@ -38,9 +36,9 @@ namespace PepperDash.Essentials.Core
|
||||
/// Returns a comm method of either com port, TCP, SSH, and puts this into the DeviceManager
|
||||
/// </summary>
|
||||
/// <param name="deviceConfig">The Device config object</param>
|
||||
/// <summary>
|
||||
/// CreateCommForDevice method
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// CreateCommForDevice method
|
||||
/// </summary>
|
||||
public static IBasicCommunication CreateCommForDevice(DeviceConfig deviceConfig)
|
||||
{
|
||||
EssentialsControlPropertiesConfig controlConfig = GetControlPropertiesConfig(deviceConfig);
|
||||
@@ -56,35 +54,38 @@ namespace PepperDash.Essentials.Core
|
||||
case eControlMethod.Com:
|
||||
comm = new ComPortController(deviceConfig.Key + "-com", GetComPort, controlConfig.ComParams.Value, controlConfig);
|
||||
break;
|
||||
case eControlMethod.Cec:
|
||||
comm = new CecPortController(deviceConfig.Key + "-cec", GetCecPort, controlConfig);
|
||||
break;
|
||||
case eControlMethod.ComBridge:
|
||||
comm = new CommBridge(deviceConfig.Key + "-simpl", deviceConfig.Name + " Simpl");
|
||||
break;
|
||||
case eControlMethod.Cec:
|
||||
comm = new CecPortController(deviceConfig.Key + "-cec", GetCecPort, controlConfig);
|
||||
break;
|
||||
case eControlMethod.IR:
|
||||
break;
|
||||
case eControlMethod.Ssh:
|
||||
{
|
||||
var ssh = new GenericSshClient(deviceConfig.Key + "-ssh", c.Address, c.Port, c.Username, c.Password);
|
||||
ssh.AutoReconnect = c.AutoReconnect;
|
||||
if(ssh.AutoReconnect)
|
||||
ssh.AutoReconnectIntervalMs = c.AutoReconnectIntervalMs;
|
||||
comm = ssh;
|
||||
break;
|
||||
}
|
||||
case eControlMethod.Tcpip:
|
||||
{
|
||||
var tcp = new GenericTcpIpClient(deviceConfig.Key + "-tcp", c.Address, c.Port, c.BufferSize);
|
||||
tcp.AutoReconnect = c.AutoReconnect;
|
||||
if (tcp.AutoReconnect)
|
||||
tcp.AutoReconnectIntervalMs = c.AutoReconnectIntervalMs;
|
||||
comm = tcp;
|
||||
break;
|
||||
}
|
||||
case eControlMethod.Udp:
|
||||
{
|
||||
var udp = new GenericUdpServer(deviceConfig.Key + "-udp", c.Address, c.Port, c.BufferSize);
|
||||
comm = udp;
|
||||
break;
|
||||
}
|
||||
case eControlMethod.Ssh:
|
||||
{
|
||||
var ssh = new GenericSshClient(deviceConfig.Key + "-ssh", c.Address, c.Port, c.Username, c.Password);
|
||||
ssh.AutoReconnect = c.AutoReconnect;
|
||||
if (ssh.AutoReconnect)
|
||||
ssh.AutoReconnectIntervalMs = c.AutoReconnectIntervalMs;
|
||||
comm = ssh;
|
||||
break;
|
||||
}
|
||||
case eControlMethod.Tcpip:
|
||||
{
|
||||
var tcp = new GenericTcpIpClient(deviceConfig.Key + "-tcp", c.Address, c.Port, c.BufferSize);
|
||||
tcp.AutoReconnect = c.AutoReconnect;
|
||||
if (tcp.AutoReconnect)
|
||||
tcp.AutoReconnectIntervalMs = c.AutoReconnectIntervalMs;
|
||||
comm = tcp;
|
||||
break;
|
||||
}
|
||||
case eControlMethod.Udp:
|
||||
{
|
||||
var udp = new GenericUdpServer(deviceConfig.Key + "-udp", c.Address, c.Port, c.BufferSize);
|
||||
comm = udp;
|
||||
break;
|
||||
}
|
||||
case eControlMethod.Telnet:
|
||||
break;
|
||||
case eControlMethod.SecureTcpIp:
|
||||
@@ -98,7 +99,7 @@ namespace PepperDash.Essentials.Core
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -107,15 +108,14 @@ namespace PepperDash.Essentials.Core
|
||||
}
|
||||
|
||||
// put it in the device manager if it's the right flavor
|
||||
var comDev = comm as Device;
|
||||
if (comDev != null)
|
||||
if (comm is Device comDev)
|
||||
DeviceManager.AddDevice(comDev);
|
||||
return comm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// GetComPort method
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// GetComPort method
|
||||
/// </summary>
|
||||
public static ComPort GetComPort(EssentialsControlPropertiesConfig config)
|
||||
{
|
||||
var comPar = config.ComParams;
|
||||
@@ -126,74 +126,74 @@ namespace PepperDash.Essentials.Core
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an ICec port from a RoutingInput or RoutingOutput on a device
|
||||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
/// <returns></returns>
|
||||
/// <summary>
|
||||
/// GetCecPort method
|
||||
/// </summary>
|
||||
public static ICec GetCecPort(ControlPropertiesConfig config)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dev = DeviceManager.GetDeviceForKey(config.ControlPortDevKey);
|
||||
/// <summary>
|
||||
/// Gets an ICec port from a RoutingInput or RoutingOutput on a device
|
||||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
/// <returns></returns>
|
||||
/// <summary>
|
||||
/// GetCecPort method
|
||||
/// </summary>
|
||||
public static ICec GetCecPort(ControlPropertiesConfig config)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dev = DeviceManager.GetDeviceForKey(config.ControlPortDevKey);
|
||||
|
||||
Debug.LogMessage(LogEventLevel.Information, "GetCecPort: device '{0}' {1}", config.ControlPortDevKey, dev == null
|
||||
? "is not valid, failed to get cec port"
|
||||
: "found in device manager, attempting to get cec port");
|
||||
Debug.LogMessage(LogEventLevel.Information, "GetCecPort: device '{0}' {1}", config.ControlPortDevKey, dev == null
|
||||
? "is not valid, failed to get cec port"
|
||||
: "found in device manager, attempting to get cec port");
|
||||
|
||||
if (dev == null)
|
||||
return null;
|
||||
if (dev == null)
|
||||
return null;
|
||||
|
||||
if (String.IsNullOrEmpty(config.ControlPortName))
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "GetCecPort: '{0}' - Configuration missing 'ControlPortName'", config.ControlPortDevKey);
|
||||
return null;
|
||||
}
|
||||
if (String.IsNullOrEmpty(config.ControlPortName))
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "GetCecPort: '{0}' - Configuration missing 'ControlPortName'", config.ControlPortDevKey);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
var inputsOutputs = dev as IRoutingInputsOutputs;
|
||||
if (inputsOutputs == null)
|
||||
{
|
||||
var inputsOutputs = dev as IRoutingInputsOutputs;
|
||||
if (inputsOutputs == null)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "GetCecPort: Device '{0}' does not support IRoutingInputsOutputs, failed to get CEC port called '{1}'",
|
||||
config.ControlPortDevKey, config.ControlPortName);
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
var inputPort = inputsOutputs.InputPorts[config.ControlPortName];
|
||||
if (inputPort != null && inputPort.Port is ICec)
|
||||
if (inputPort != null && inputPort.Port is ICec)
|
||||
return inputPort.Port as ICec;
|
||||
|
||||
|
||||
var outputPort = inputsOutputs.OutputPorts[config.ControlPortName];
|
||||
if (outputPort != null && outputPort.Port is ICec)
|
||||
return outputPort.Port as ICec;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, "GetCecPort Exception Message: {0}", ex.Message);
|
||||
Debug.LogMessage(LogEventLevel.Verbose, "GetCecPort Exception StackTrace: {0}", ex.StackTrace);
|
||||
if (ex.InnerException != null)
|
||||
Debug.LogMessage(LogEventLevel.Information, "GetCecPort Exception InnerException: {0}", ex.InnerException);
|
||||
}
|
||||
|
||||
var outputPort = inputsOutputs.OutputPorts[config.ControlPortName];
|
||||
if (outputPort != null && outputPort.Port is ICec)
|
||||
return outputPort.Port as ICec;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, "GetCecPort Exception Message: {0}", ex.Message);
|
||||
Debug.LogMessage(LogEventLevel.Verbose, "GetCecPort Exception StackTrace: {0}", ex.StackTrace);
|
||||
if (ex.InnerException != null)
|
||||
Debug.LogMessage(LogEventLevel.Information, "GetCecPort Exception InnerException: {0}", ex.InnerException);
|
||||
}
|
||||
|
||||
Debug.LogMessage(LogEventLevel.Information, "GetCecPort: Device '{0}' does not have a CEC port called '{1}'",
|
||||
config.ControlPortDevKey, config.ControlPortName);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper to grab the IComPorts device for this PortDeviceKey. Key "controlSystem" will
|
||||
/// return the ControlSystem object from the Global class.
|
||||
/// </summary>
|
||||
/// <returns>IComPorts device or null if the device is not found or does not implement IComPorts</returns>
|
||||
/// <summary>
|
||||
/// GetIComPortsDeviceFromManagedDevice method
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// GetIComPortsDeviceFromManagedDevice method
|
||||
/// </summary>
|
||||
public static IComPorts GetIComPortsDeviceFromManagedDevice(string ComPortDevKey)
|
||||
{
|
||||
if ((ComPortDevKey.Equals("controlSystem", System.StringComparison.OrdinalIgnoreCase)
|
||||
@@ -210,81 +210,81 @@ namespace PepperDash.Essentials.Core
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a EssentialsControlPropertiesConfig
|
||||
/// </summary>
|
||||
public class EssentialsControlPropertiesConfig :
|
||||
ControlPropertiesConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a EssentialsControlPropertiesConfig
|
||||
/// </summary>
|
||||
public class EssentialsControlPropertiesConfig :
|
||||
ControlPropertiesConfig
|
||||
{
|
||||
|
||||
[JsonProperty("comParams", NullValueHandling = NullValueHandling.Ignore)]
|
||||
[JsonConverter(typeof(ComSpecJsonConverter))]
|
||||
public ComPort.ComPortSpec? ComParams { get; set; }
|
||||
[JsonProperty("comParams", NullValueHandling = NullValueHandling.Ignore)]
|
||||
[JsonConverter(typeof(ComSpecJsonConverter))]
|
||||
public ComPort.ComPortSpec? ComParams { get; set; }
|
||||
|
||||
[JsonProperty("cresnetId", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public string CresnetId { get; set; }
|
||||
[JsonProperty("cresnetId", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public string CresnetId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to provide uint conversion of string CresnetId
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public uint CresnetIdInt
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
return Convert.ToUInt32(CresnetId, 16);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new FormatException(string.Format("ERROR:Unable to convert Cresnet ID: {0} to hex. Error:\n{1}", CresnetId));
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Attempts to provide uint conversion of string CresnetId
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public uint CresnetIdInt
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
return Convert.ToUInt32(CresnetId, 16);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new FormatException(string.Format("ERROR:Unable to convert Cresnet ID: {0} to hex. Error:\n{1}", CresnetId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[JsonProperty("infinetId", NullValueHandling = NullValueHandling.Ignore)]
|
||||
/// <summary>
|
||||
/// Gets or sets the InfinetId
|
||||
/// </summary>
|
||||
public string InfinetId { get; set; }
|
||||
[JsonProperty("infinetId", NullValueHandling = NullValueHandling.Ignore)]
|
||||
/// <summary>
|
||||
/// Gets or sets the InfinetId
|
||||
/// </summary>
|
||||
public string InfinetId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Attepmts to provide uiont conversion of string InifinetId
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public uint InfinetIdInt
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
return Convert.ToUInt32(InfinetId, 16);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new FormatException(string.Format("ERROR:Unable to conver Infinet ID: {0} to hex. Error:\n{1}", InfinetId));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Attepmts to provide uiont conversion of string InifinetId
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public uint InfinetIdInt
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
return Convert.ToUInt32(InfinetId, 16);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new FormatException(string.Format("ERROR:Unable to conver Infinet ID: {0} to hex. Error:\n{1}", InfinetId));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a IrControlSpec
|
||||
/// </summary>
|
||||
public class IrControlSpec
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the PortDeviceKey
|
||||
/// </summary>
|
||||
public string PortDeviceKey { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the PortNumber
|
||||
/// </summary>
|
||||
public uint PortNumber { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the File
|
||||
/// </summary>
|
||||
public string File { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Represents a IrControlSpec
|
||||
/// </summary>
|
||||
public class IrControlSpec
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the PortDeviceKey
|
||||
/// </summary>
|
||||
public string PortDeviceKey { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the PortNumber
|
||||
/// </summary>
|
||||
public uint PortNumber { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the File
|
||||
/// </summary>
|
||||
public string File { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace PepperDash.Essentials.Core.Config
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the base properties for a streaming device.
|
||||
/// </summary>
|
||||
public class BaseStreamingDeviceProperties
|
||||
{
|
||||
/// <summary>
|
||||
/// The multicast video address for the streaming device.
|
||||
/// </summary>
|
||||
[JsonProperty("multicastVideoAddress", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public string MulticastVideoAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The multicast audio address for the streaming device.
|
||||
/// </summary>
|
||||
[JsonProperty("multicastAudioAddress", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public string MulticastAudioAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The URL for the streaming device's media stream.
|
||||
/// </summary>
|
||||
[JsonProperty("streamUrl", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public string StreamUrl { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -18,41 +18,41 @@ namespace PepperDash.Essentials.Core.Config
|
||||
/// </summary>
|
||||
public class DeviceConfig
|
||||
{
|
||||
[JsonProperty("key")]
|
||||
/// <summary>
|
||||
/// Gets or sets the Key
|
||||
/// </summary>
|
||||
[JsonProperty("key")]
|
||||
public string Key { get; set; }
|
||||
|
||||
[JsonProperty("uid")]
|
||||
/// <summary>
|
||||
/// Gets or sets the Uid
|
||||
/// </summary>
|
||||
[JsonProperty("uid")]
|
||||
public int Uid { get; set; }
|
||||
|
||||
[JsonProperty("name")]
|
||||
/// <summary>
|
||||
/// Gets or sets the Name
|
||||
/// </summary>
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonProperty("group")]
|
||||
/// <summary>
|
||||
/// Gets or sets the Group
|
||||
/// </summary>
|
||||
[JsonProperty("group")]
|
||||
public string Group { get; set; }
|
||||
|
||||
[JsonProperty("type")]
|
||||
/// <summary>
|
||||
/// Gets or sets the Type
|
||||
/// </summary>
|
||||
[JsonProperty("type")]
|
||||
public string Type { get; set; }
|
||||
|
||||
[JsonProperty("properties")]
|
||||
[JsonConverter(typeof(DevicePropertiesConverter))]
|
||||
/// <summary>
|
||||
/// Gets or sets the Properties
|
||||
/// </summary>
|
||||
[JsonProperty("properties")]
|
||||
[JsonConverter(typeof(DevicePropertiesConverter))]
|
||||
public JToken Properties { get; set; }
|
||||
|
||||
public DeviceConfig(DeviceConfig dc)
|
||||
@@ -68,7 +68,7 @@ namespace PepperDash.Essentials.Core.Config
|
||||
//Properties = JToken.FromObject(dc.Properties);
|
||||
}
|
||||
|
||||
public DeviceConfig() {}
|
||||
public DeviceConfig() { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -2,59 +2,54 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
using Newtonsoft.Json;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Core.Logging;
|
||||
using PepperDash.Essentials.Core.Bridges;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using Serilog.Events;
|
||||
|
||||
|
||||
namespace PepperDash.Essentials.Core.CrestronIO
|
||||
{
|
||||
[Description("Wrapper class for Digital Input")]
|
||||
|
||||
/// <summary>
|
||||
/// Represents a GenericDigitalInputDevice
|
||||
/// </summary>
|
||||
public class GenericDigitalInputDevice : EssentialsBridgeableDevice, IDigitalInput
|
||||
/// [Description("Wrapper class for Digital Input")]
|
||||
public class GenericDigitalInputDevice : EssentialsBridgeableDevice, IDigitalInput, IHasFeedback
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the InputPort
|
||||
/// </summary>
|
||||
public DigitalInput InputPort { get; private set; }
|
||||
private DigitalInput inputPort;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the InputStateFeedback
|
||||
/// </summary>
|
||||
public BoolFeedback InputStateFeedback { get; private set; }
|
||||
|
||||
Func<bool> InputStateFeedbackFunc
|
||||
{
|
||||
get
|
||||
{
|
||||
return () => InputPort.State;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public FeedbackCollection<Feedback> Feedbacks { get; private set; } = new FeedbackCollection<Feedback>();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GenericDigitalInputDevice"/> class.
|
||||
/// </summary>
|
||||
/// <param name="key">key for device</param>
|
||||
/// <param name="name">name for device</param>
|
||||
/// <param name="postActivationFunc">function to call after activation. Should return the DigitalInput</param>
|
||||
/// <param name="config">config for device</param>
|
||||
public GenericDigitalInputDevice(string key, string name, Func<IOPortConfig, DigitalInput> postActivationFunc,
|
||||
IOPortConfig config)
|
||||
: base(key, name)
|
||||
{
|
||||
InputStateFeedback = new BoolFeedback(InputStateFeedbackFunc);
|
||||
InputStateFeedback = new BoolFeedback("inputState", () => inputPort.State);
|
||||
|
||||
AddPostActivationAction(() =>
|
||||
{
|
||||
InputPort = postActivationFunc(config);
|
||||
inputPort = postActivationFunc(config);
|
||||
|
||||
InputPort.Register();
|
||||
|
||||
InputPort.StateChange += InputPort_StateChange;
|
||||
inputPort.Register();
|
||||
|
||||
inputPort.StateChange += InputPort_StateChange;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -71,41 +66,31 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
||||
|
||||
private static DigitalInput GetDigitalInput(IOPortConfig dc)
|
||||
{
|
||||
IDigitalInputPorts ioPortDevice;
|
||||
|
||||
if (dc.PortDeviceKey.Equals("processor"))
|
||||
{
|
||||
if (!Global.ControlSystem.SupportsDigitalInput)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "GetDigitalInput: Processor does not support Digital Inputs");
|
||||
Debug.LogError("GetDigitalInput: Processor does not support Digital Inputs");
|
||||
return null;
|
||||
}
|
||||
ioPortDevice = Global.ControlSystem;
|
||||
|
||||
return Global.ControlSystem.DigitalInputPorts[dc.PortNumber];
|
||||
}
|
||||
else
|
||||
|
||||
if (!(DeviceManager.GetDeviceForKey(dc.PortDeviceKey) is IDigitalInputPorts ioPortDevice))
|
||||
{
|
||||
var ioPortDev = DeviceManager.GetDeviceForKey(dc.PortDeviceKey) as IDigitalInputPorts;
|
||||
if (ioPortDev == null)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "GetDigitalInput: Device {0} is not a valid device", dc.PortDeviceKey);
|
||||
return null;
|
||||
}
|
||||
ioPortDevice = ioPortDev;
|
||||
}
|
||||
if (ioPortDevice == null)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "GetDigitalInput: Device '0' is not a valid IDigitalInputPorts Device", dc.PortDeviceKey);
|
||||
Debug.LogError("GetDigitalInput: Device {key} is not a valid device", dc.PortDeviceKey);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (dc.PortNumber > ioPortDevice.NumberOfDigitalInputPorts)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "GetDigitalInput: Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber);
|
||||
Debug.LogError("GetDigitalInput: Device {key} does not contain a digital input port {port}", dc.PortDeviceKey, dc.PortNumber);
|
||||
return null;
|
||||
}
|
||||
|
||||
return ioPortDevice.DigitalInputPorts[dc.PortNumber];
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -131,20 +116,20 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
||||
this.LogWarning("Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
||||
this.LogDebug("Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
||||
|
||||
// Link feedback for input state
|
||||
InputStateFeedback.LinkInputSig(trilist.BooleanInput[joinMap.InputState.JoinNumber]);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, "Unable to link device '{0}'. Input is null", Key);
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, "Error: {0}", e);
|
||||
this.LogError("Unable to link device {key}. {message}", Key, e.Message);
|
||||
this.LogDebug(e, "Stack Trace: ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,22 +138,22 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
||||
#region Factory
|
||||
|
||||
/// <summary>
|
||||
/// Represents a GenericDigitalInputDeviceFactory
|
||||
/// Factory for creating GenericDigitalInputDevice devices
|
||||
/// </summary>
|
||||
public class GenericDigitalInputDeviceFactory : EssentialsDeviceFactory<GenericDigitalInputDevice>
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor for GenericDigitalInputDeviceFactory
|
||||
/// </summary>
|
||||
public GenericDigitalInputDeviceFactory()
|
||||
{
|
||||
TypeNames = new List<string>() { "digitalinput" };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// BuildDevice method
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic Digital Input Device");
|
||||
Debug.LogDebug("Factory Attempting to create new Generic Digital Input Device");
|
||||
|
||||
var props = JsonConvert.DeserializeObject<IOPortConfig>(dc.Properties.ToString());
|
||||
|
||||
|
||||
@@ -2,66 +2,64 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using PepperDash.Essentials.Core.Bridges;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Serilog.Events;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Core.Logging;
|
||||
using PepperDash.Essentials.Core.Bridges;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
|
||||
namespace PepperDash.Essentials.Core.CrestronIO
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a generic digital input deviced tied to a versiport
|
||||
/// </summary>
|
||||
public class GenericVersiportAnalogInputDevice : EssentialsBridgeableDevice, IAnalogInput
|
||||
public class GenericVersiportAnalogInputDevice : EssentialsBridgeableDevice, IAnalogInput, IHasFeedback
|
||||
{
|
||||
public Versiport InputPort { get; private set; }
|
||||
private Versiport inputPort;
|
||||
|
||||
/// <inheritdoc />
|
||||
public IntFeedback InputValueFeedback { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Get the InputMinimumChangeFeedback
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Updates when the analog input minimum change value changes
|
||||
/// </remarks>
|
||||
public IntFeedback InputMinimumChangeFeedback { get; private set; }
|
||||
|
||||
Func<int> InputValueFeedbackFunc
|
||||
{
|
||||
get
|
||||
{
|
||||
return () => InputPort.AnalogIn;
|
||||
}
|
||||
}
|
||||
|
||||
Func<int> InputMinimumChangeFeedbackFunc
|
||||
{
|
||||
get { return () => InputPort.AnalogMinChange; }
|
||||
}
|
||||
/// <inheritdoc />
|
||||
public FeedbackCollection<Feedback> Feedbacks { get; private set; } = new FeedbackCollection<Feedback>();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GenericVersiportAnalogInputDevice"/> class.
|
||||
/// </summary>
|
||||
/// <param name="key">key for the device</param>
|
||||
/// <param name="name">name for the device</param>
|
||||
/// <param name="postActivationFunc">function to call after activation</param>
|
||||
/// <param name="config">IO port configuration</param>
|
||||
public GenericVersiportAnalogInputDevice(string key, string name, Func<IOPortConfig, Versiport> postActivationFunc, IOPortConfig config) :
|
||||
base(key, name)
|
||||
{
|
||||
InputValueFeedback = new IntFeedback(InputValueFeedbackFunc);
|
||||
InputMinimumChangeFeedback = new IntFeedback(InputMinimumChangeFeedbackFunc);
|
||||
InputValueFeedback = new IntFeedback("inputValue", () => inputPort.AnalogIn);
|
||||
InputMinimumChangeFeedback = new IntFeedback("inputMinimumChange", () => inputPort.AnalogMinChange);
|
||||
|
||||
AddPostActivationAction(() =>
|
||||
{
|
||||
InputPort = postActivationFunc(config);
|
||||
inputPort = postActivationFunc(config);
|
||||
|
||||
InputPort.Register();
|
||||
inputPort.Register();
|
||||
|
||||
InputPort.SetVersiportConfiguration(eVersiportConfiguration.AnalogInput);
|
||||
InputPort.AnalogMinChange = (ushort)(config.MinimumChange > 0 ? config.MinimumChange : 655);
|
||||
inputPort.SetVersiportConfiguration(eVersiportConfiguration.AnalogInput);
|
||||
inputPort.AnalogMinChange = (ushort)(config.MinimumChange > 0 ? config.MinimumChange : 655);
|
||||
if (config.DisablePullUpResistor)
|
||||
InputPort.DisablePullUpResistor = true;
|
||||
inputPort.DisablePullUpResistor = true;
|
||||
|
||||
InputPort.VersiportChange += InputPort_VersiportChange;
|
||||
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, "Created GenericVersiportAnalogInputDevice on port '{0}'. DisablePullUpResistor: '{1}'", config.PortNumber, InputPort.DisablePullUpResistor);
|
||||
inputPort.VersiportChange += InputPort_VersiportChange;
|
||||
|
||||
this.LogDebug("Created GenericVersiportAnalogInputDevice on port {port}. DisablePullUpResistor: {pullUpResistorDisabled}", config.PortNumber, inputPort.DisablePullUpResistor);
|
||||
});
|
||||
|
||||
}
|
||||
@@ -69,20 +67,17 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
||||
/// <summary>
|
||||
/// Set minimum voltage change for device to update voltage changed method
|
||||
/// </summary>
|
||||
/// <param name="value">valid values range from 0 - 65535, representing the full 100% range of the processor voltage source. Check processor documentation for details</param>
|
||||
/// <summary>
|
||||
/// SetMinimumChange method
|
||||
/// </summary>
|
||||
/// <param name="value">valid values range from 0 - 65535, representing the full 100% range of the processor voltage source. Check processor documentation for details</param>
|
||||
public void SetMinimumChange(ushort value)
|
||||
{
|
||||
InputPort.AnalogMinChange = value;
|
||||
inputPort.AnalogMinChange = value;
|
||||
}
|
||||
|
||||
void InputPort_VersiportChange(Versiport port, VersiportEventArgs args)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, "Versiport change: {0}", args.Event);
|
||||
this.LogDebug("Versiport change: {event}", args.Event);
|
||||
|
||||
if(args.Event == eVersiportEvent.AnalogInChange)
|
||||
if (args.Event == eVersiportEvent.AnalogInChange)
|
||||
InputValueFeedback.FireUpdate();
|
||||
if (args.Event == eVersiportEvent.AnalogMinChangeChange)
|
||||
InputMinimumChangeFeedback.FireUpdate();
|
||||
@@ -91,9 +86,6 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
||||
|
||||
#region Bridge Linking
|
||||
|
||||
/// <summary>
|
||||
/// LinkToApi method
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
|
||||
{
|
||||
@@ -110,12 +102,12 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
||||
this.LogWarning("Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
||||
this.LogDebug("Linking to Trilist '{trilistId}'", trilist.ID.ToString("X"));
|
||||
|
||||
// Link feedback for input state
|
||||
InputValueFeedback.LinkInputSig(trilist.UShortInput[joinMap.InputValue.JoinNumber]);
|
||||
@@ -125,8 +117,8 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, "Unable to link device '{0}'. Input is null", Key);
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, "Error: {0}", e);
|
||||
this.LogError("Unable to link device {key}: {message}", Key, e.Message);
|
||||
this.LogDebug(e, "Stack Trace: ");
|
||||
}
|
||||
|
||||
trilist.OnlineStatusChange += (d, args) =>
|
||||
@@ -138,11 +130,6 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
||||
|
||||
}
|
||||
|
||||
void trilist_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -151,70 +138,55 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
||||
/// </summary>
|
||||
public static Versiport GetVersiportDigitalInput(IOPortConfig dc)
|
||||
{
|
||||
|
||||
IIOPorts ioPortDevice;
|
||||
|
||||
if (dc.PortDeviceKey.Equals("processor"))
|
||||
{
|
||||
if (!Global.ControlSystem.SupportsVersiport)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "GetVersiportAnalogInput: Processor does not support Versiports");
|
||||
Debug.LogError("GetVersiportAnalogInput: Processor does not support Versiports");
|
||||
return null;
|
||||
}
|
||||
ioPortDevice = Global.ControlSystem;
|
||||
return Global.ControlSystem.VersiPorts[dc.PortNumber];
|
||||
}
|
||||
else
|
||||
|
||||
if (!(DeviceManager.GetDeviceForKey(dc.PortDeviceKey) is IIOPorts ioPortDevice))
|
||||
{
|
||||
var ioPortDev = DeviceManager.GetDeviceForKey(dc.PortDeviceKey) as IIOPorts;
|
||||
if (ioPortDev == null)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "GetVersiportAnalogInput: Device {0} is not a valid device", dc.PortDeviceKey);
|
||||
return null;
|
||||
}
|
||||
ioPortDevice = ioPortDev;
|
||||
}
|
||||
if (ioPortDevice == null)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "GetVersiportAnalogInput: Device '0' is not a valid IIOPorts Device", dc.PortDeviceKey);
|
||||
Debug.LogError("GetVersiportAnalogInput: Device {key} is not a valid device", dc.PortDeviceKey);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (dc.PortNumber > ioPortDevice.NumberOfVersiPorts)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "GetVersiportAnalogInput: Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber);
|
||||
Debug.LogError("GetVersiportAnalogInput: Device {key} does not contain a port {port}", dc.PortDeviceKey, dc.PortNumber);
|
||||
return null;
|
||||
}
|
||||
if(!ioPortDevice.VersiPorts[dc.PortNumber].SupportsAnalogInput)
|
||||
if (!ioPortDevice.VersiPorts[dc.PortNumber].SupportsAnalogInput)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "GetVersiportAnalogInput: Device {0} does not support AnalogInput on port {1}", dc.PortDeviceKey, dc.PortNumber);
|
||||
Debug.LogError("GetVersiportAnalogInput: Device {key} does not support AnalogInput on port {port}", dc.PortDeviceKey, dc.PortNumber);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return ioPortDevice.VersiPorts[dc.PortNumber];
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Represents a GenericVersiportAbalogInputDeviceFactory
|
||||
/// Factory for creating GenericVersiportAnalogInputDevice devices
|
||||
/// </summary>
|
||||
public class GenericVersiportAbalogInputDeviceFactory : EssentialsDeviceFactory<GenericVersiportAnalogInputDevice>
|
||||
public class GenericVersiportAnalogInputDeviceFactory : EssentialsDeviceFactory<GenericVersiportAnalogInputDevice>
|
||||
{
|
||||
public GenericVersiportAbalogInputDeviceFactory()
|
||||
/// <summary>
|
||||
/// Constructor for GenericVersiportAnalogInputDeviceFactory
|
||||
/// </summary>
|
||||
public GenericVersiportAnalogInputDeviceFactory()
|
||||
{
|
||||
TypeNames = new List<string>() { "versiportanaloginput" };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// BuildDevice method
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic Versiport Device");
|
||||
Debug.LogDebug("Factory Attempting to create new Generic Versiport Device");
|
||||
|
||||
var props = JsonConvert.DeserializeObject<IOPortConfig>(dc.Properties.ToString());
|
||||
|
||||
|
||||
@@ -2,78 +2,82 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using PepperDash.Essentials.Core.Bridges;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Serilog.Events;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Core.Logging;
|
||||
using PepperDash.Essentials.Core.Bridges;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
|
||||
namespace PepperDash.Essentials.Core.CrestronIO
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a generic digital input deviced tied to a versiport
|
||||
/// </summary>
|
||||
public class GenericVersiportDigitalInputDevice : EssentialsBridgeableDevice, IDigitalInput, IPartitionStateProvider
|
||||
public class GenericVersiportDigitalInputDevice : EssentialsBridgeableDevice, IDigitalInput, IPartitionStateProvider, IHasFeedback
|
||||
{
|
||||
public Versiport InputPort { get; private set; }
|
||||
private Versiport inputPort;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the InputStateFeedback
|
||||
/// </summary>
|
||||
public BoolFeedback InputStateFeedback { get; private set; }
|
||||
|
||||
Func<bool> InputStateFeedbackFunc
|
||||
{
|
||||
get
|
||||
{
|
||||
return () => InputPort.DigitalIn;
|
||||
}
|
||||
}
|
||||
/// <inheritdoc />
|
||||
public FeedbackCollection<Feedback> Feedbacks { get; private set; } = new FeedbackCollection<Feedback>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the PartitionPresentFeedback
|
||||
/// </summary>
|
||||
public BoolFeedback PartitionPresentFeedback { get; }
|
||||
|
||||
public bool PartitionPresent => !InputStateFeedbackFunc();
|
||||
/// <summary>
|
||||
/// Get partition state
|
||||
/// </summary>
|
||||
public bool PartitionPresent => !inputPort.DigitalIn;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GenericVersiportDigitalInputDevice"/> class.
|
||||
/// </summary>
|
||||
/// <param name="key">key for device</param>
|
||||
/// <param name="name">name for device</param>
|
||||
/// <param name="postActivationFunc">function to call after activation. Should return the Versiport</param>
|
||||
/// <param name="config">config for device</param>
|
||||
public GenericVersiportDigitalInputDevice(string key, string name, Func<IOPortConfig, Versiport> postActivationFunc, IOPortConfig config) :
|
||||
base(key, name)
|
||||
{
|
||||
InputStateFeedback = new BoolFeedback(InputStateFeedbackFunc);
|
||||
PartitionPresentFeedback = new BoolFeedback(() => !InputStateFeedbackFunc());
|
||||
InputStateFeedback = new BoolFeedback("inputState", () => inputPort.DigitalIn);
|
||||
PartitionPresentFeedback = new BoolFeedback("partitionPresent", () => !inputPort.DigitalIn);
|
||||
|
||||
AddPostActivationAction(() =>
|
||||
{
|
||||
InputPort = postActivationFunc(config);
|
||||
inputPort = postActivationFunc(config);
|
||||
|
||||
InputPort.Register();
|
||||
inputPort.Register();
|
||||
|
||||
InputPort.SetVersiportConfiguration(eVersiportConfiguration.DigitalInput);
|
||||
inputPort.SetVersiportConfiguration(eVersiportConfiguration.DigitalInput);
|
||||
if (config.DisablePullUpResistor)
|
||||
InputPort.DisablePullUpResistor = true;
|
||||
inputPort.DisablePullUpResistor = true;
|
||||
|
||||
InputPort.VersiportChange += InputPort_VersiportChange;
|
||||
inputPort.VersiportChange += InputPort_VersiportChange;
|
||||
|
||||
InputStateFeedback.FireUpdate();
|
||||
PartitionPresentFeedback.FireUpdate();
|
||||
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, "Created GenericVersiportDigitalInputDevice on port '{0}'. DisablePullUpResistor: '{1}'", config.PortNumber, InputPort.DisablePullUpResistor);
|
||||
this.LogDebug("Created GenericVersiportDigitalInputDevice for port {port}. DisablePullUpResistor: {pullUpResistorDisable}", config.PortNumber, inputPort.DisablePullUpResistor);
|
||||
|
||||
});
|
||||
|
||||
Feedbacks.Add(InputStateFeedback);
|
||||
Feedbacks.Add(PartitionPresentFeedback);
|
||||
}
|
||||
|
||||
void InputPort_VersiportChange(Versiport port, VersiportEventArgs args)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, "Versiport change: {0}", args.Event);
|
||||
this.LogDebug("Versiport change: {0}", args.Event);
|
||||
|
||||
if(args.Event == eVersiportEvent.DigitalInChange)
|
||||
if (args.Event == eVersiportEvent.DigitalInChange)
|
||||
{
|
||||
InputStateFeedback.FireUpdate();
|
||||
PartitionPresentFeedback.FireUpdate();
|
||||
@@ -102,20 +106,20 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
||||
this.LogWarning("Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
||||
this.LogDebug("Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
||||
|
||||
// Link feedback for input state
|
||||
InputStateFeedback.LinkInputSig(trilist.BooleanInput[joinMap.InputState.JoinNumber]);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, "Unable to link device '{0}'. Input is null", Key);
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, "Error: {0}", e);
|
||||
this.LogError("Unable to link device {key}. Input is null. {message}", Key, e.Message);
|
||||
this.LogDebug(e, "Stack Trace: ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,63 +131,50 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
||||
/// </summary>
|
||||
public static Versiport GetVersiportDigitalInput(IOPortConfig dc)
|
||||
{
|
||||
|
||||
IIOPorts ioPortDevice;
|
||||
|
||||
if (dc.PortDeviceKey.Equals("processor"))
|
||||
{
|
||||
if (!Global.ControlSystem.SupportsVersiport)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "GetVersiportDigitalInput: Processor does not support Versiports");
|
||||
Debug.LogError("GetVersiportDigitalInput: Processor does not support Versiports");
|
||||
return null;
|
||||
}
|
||||
ioPortDevice = Global.ControlSystem;
|
||||
return Global.ControlSystem.VersiPorts[dc.PortNumber];
|
||||
}
|
||||
else
|
||||
|
||||
if (!(DeviceManager.GetDeviceForKey(dc.PortDeviceKey) is IIOPorts ioPortDevice))
|
||||
{
|
||||
var ioPortDev = DeviceManager.GetDeviceForKey(dc.PortDeviceKey) as IIOPorts;
|
||||
if (ioPortDev == null)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "GetVersiportDigitalInput: Device {0} is not a valid device", dc.PortDeviceKey);
|
||||
return null;
|
||||
}
|
||||
ioPortDevice = ioPortDev;
|
||||
}
|
||||
if (ioPortDevice == null)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "GetVersiportDigitalInput: Device '0' is not a valid IIOPorts Device", dc.PortDeviceKey);
|
||||
Debug.LogError("GetVersiportDigitalInput: Device {key} is not a valid device", dc.PortDeviceKey);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (dc.PortNumber > ioPortDevice.NumberOfVersiPorts)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "GetVersiportDigitalInput: Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber);
|
||||
Debug.LogError("GetVersiportDigitalInput: Device {key} does not contain versiport {port}", dc.PortDeviceKey, dc.PortNumber);
|
||||
return null;
|
||||
}
|
||||
|
||||
return ioPortDevice.VersiPorts[dc.PortNumber];
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Represents a GenericVersiportDigitalInputDeviceFactory
|
||||
/// Factory class for GenericVersiportDigitalInputDevice
|
||||
/// </summary>
|
||||
public class GenericVersiportDigitalInputDeviceFactory : EssentialsDeviceFactory<GenericVersiportDigitalInputDevice>
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor for GenericVersiportDigitalInputDeviceFactory
|
||||
/// </summary>
|
||||
public GenericVersiportDigitalInputDeviceFactory()
|
||||
{
|
||||
TypeNames = new List<string>() { "versiportinput" };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// BuildDevice method
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic Versiport Device");
|
||||
Debug.LogDebug("Factory Attempting to create new Generic Versiport Device");
|
||||
|
||||
var props = JsonConvert.DeserializeObject<IOPortConfig>(dc.Properties.ToString());
|
||||
|
||||
|
||||
@@ -2,18 +2,13 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using PepperDash.Essentials.Core.Bridges;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Core.Logging;
|
||||
using PepperDash.Essentials.Core.Bridges;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using Serilog.Events;
|
||||
|
||||
namespace PepperDash.Essentials.Core.CrestronIO
|
||||
@@ -21,76 +16,68 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
||||
/// <summary>
|
||||
/// Represents a generic digital input deviced tied to a versiport
|
||||
/// </summary>
|
||||
public class GenericVersiportDigitalOutputDevice : EssentialsBridgeableDevice, IDigitalOutput
|
||||
public class GenericVersiportDigitalOutputDevice : EssentialsBridgeableDevice, IDigitalOutput, IHasFeedback
|
||||
{
|
||||
public Versiport OutputPort { get; private set; }
|
||||
private Versiport outputPort;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the OutputStateFeedback
|
||||
/// </summary>
|
||||
public BoolFeedback OutputStateFeedback { get; private set; }
|
||||
|
||||
Func<bool> OutputStateFeedbackFunc
|
||||
{
|
||||
get
|
||||
{
|
||||
return () => OutputPort.DigitalOut;
|
||||
}
|
||||
}
|
||||
/// <inheritdoc />
|
||||
public FeedbackCollection<Feedback> Feedbacks { get; private set; } = new FeedbackCollection<Feedback>();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GenericVersiportDigitalOutputDevice"/> class.
|
||||
/// </summary>
|
||||
public GenericVersiportDigitalOutputDevice(string key, string name, Func<IOPortConfig, Versiport> postActivationFunc, IOPortConfig config) :
|
||||
base(key, name)
|
||||
{
|
||||
OutputStateFeedback = new BoolFeedback(OutputStateFeedbackFunc);
|
||||
OutputStateFeedback = new BoolFeedback("outputState", () => outputPort.DigitalOut);
|
||||
|
||||
AddPostActivationAction(() =>
|
||||
{
|
||||
OutputPort = postActivationFunc(config);
|
||||
outputPort = postActivationFunc(config);
|
||||
|
||||
OutputPort.Register();
|
||||
outputPort.Register();
|
||||
|
||||
|
||||
if (!OutputPort.SupportsDigitalOutput)
|
||||
if (!outputPort.SupportsDigitalOutput)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, this, "Device does not support configuration as a Digital Output");
|
||||
this.LogError("Device does not support configuration as a Digital Output");
|
||||
return;
|
||||
}
|
||||
|
||||
OutputPort.SetVersiportConfiguration(eVersiportConfiguration.DigitalOutput);
|
||||
outputPort.SetVersiportConfiguration(eVersiportConfiguration.DigitalOutput);
|
||||
|
||||
|
||||
OutputPort.VersiportChange += OutputPort_VersiportChange;
|
||||
outputPort.VersiportChange += OutputPort_VersiportChange;
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
void OutputPort_VersiportChange(Versiport port, VersiportEventArgs args)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, "Versiport change: {0}", args.Event);
|
||||
this.LogDebug("Versiport change: {event}", args.Event);
|
||||
|
||||
if(args.Event == eVersiportEvent.DigitalOutChange)
|
||||
if (args.Event == eVersiportEvent.DigitalOutChange)
|
||||
OutputStateFeedback.FireUpdate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set value of the versiport digital output
|
||||
/// </summary>
|
||||
/// <param name="state">value to set the output to</param>
|
||||
/// <summary>
|
||||
/// SetOutput method
|
||||
/// </summary>
|
||||
/// <param name="state">value to set the output to</param>
|
||||
public void SetOutput(bool state)
|
||||
{
|
||||
if (OutputPort.SupportsDigitalOutput)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, this, "Passed the Check");
|
||||
|
||||
OutputPort.DigitalOut = state;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, this, "Versiport does not support Digital Output Mode");
|
||||
}
|
||||
if (!outputPort.SupportsDigitalOutput)
|
||||
{
|
||||
this.LogError("Versiport does not support Digital Output Mode");
|
||||
return;
|
||||
}
|
||||
|
||||
outputPort.DigitalOut = state;
|
||||
}
|
||||
|
||||
#region Bridge Linking
|
||||
@@ -114,12 +101,12 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
||||
this.LogWarning("Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
||||
this.LogDebug("Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
||||
|
||||
// Link feedback for input state
|
||||
OutputStateFeedback.LinkInputSig(trilist.BooleanInput[joinMap.OutputState.JoinNumber]);
|
||||
@@ -127,8 +114,8 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, "Unable to link device '{0}'. Input is null", Key);
|
||||
Debug.LogMessage(LogEventLevel.Debug, this, "Error: {0}", e);
|
||||
this.LogError("Unable to link device: {message}", e.Message);
|
||||
this.LogDebug(e, "Stack Trace: ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,41 +127,28 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
||||
/// </summary>
|
||||
public static Versiport GetVersiportDigitalOutput(IOPortConfig dc)
|
||||
{
|
||||
|
||||
IIOPorts ioPortDevice;
|
||||
|
||||
if (dc.PortDeviceKey.Equals("processor"))
|
||||
if (dc.PortDeviceKey.Equals("processor"))
|
||||
{
|
||||
if (!Global.ControlSystem.SupportsVersiport)
|
||||
{
|
||||
if (!Global.ControlSystem.SupportsVersiport)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "GetVersiportDigitalOuptut: Processor does not support Versiports");
|
||||
return null;
|
||||
}
|
||||
ioPortDevice = Global.ControlSystem;
|
||||
}
|
||||
else
|
||||
{
|
||||
var ioPortDev = DeviceManager.GetDeviceForKey(dc.PortDeviceKey) as IIOPorts;
|
||||
if (ioPortDev == null)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "GetVersiportDigitalOuptut: Device {0} is not a valid device", dc.PortDeviceKey);
|
||||
return null;
|
||||
}
|
||||
ioPortDevice = ioPortDev;
|
||||
}
|
||||
if (ioPortDevice == null)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "GetVersiportDigitalOuptut: Device '0' is not a valid IOPorts Device", dc.PortDeviceKey);
|
||||
Debug.LogError("GetVersiportDigitalOutput: Processor does not support Versiports");
|
||||
return null;
|
||||
}
|
||||
return Global.ControlSystem.VersiPorts[dc.PortNumber];
|
||||
}
|
||||
|
||||
if (dc.PortNumber > ioPortDevice.NumberOfVersiPorts)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "GetVersiportDigitalOuptut: Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber);
|
||||
}
|
||||
var port = ioPortDevice.VersiPorts[dc.PortNumber];
|
||||
return port;
|
||||
if (!(DeviceManager.GetDeviceForKey(dc.PortDeviceKey) is IIOPorts ioPortDevice))
|
||||
{
|
||||
Debug.LogError("GetVersiportDigitalOutput: Device {key} is not a valid device", dc.PortDeviceKey);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (dc.PortNumber > ioPortDevice.NumberOfVersiPorts)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "GetVersiportDigitalOutput: Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber);
|
||||
return null;
|
||||
}
|
||||
return ioPortDevice.VersiPorts[dc.PortNumber];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,18 +158,18 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
||||
/// </summary>
|
||||
public class GenericVersiportDigitalOutputDeviceFactory : EssentialsDeviceFactory<GenericVersiportDigitalInputDevice>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialize a new instance of the <see cref="GenericVersiportDigitalOutputDeviceFactory"/> class.
|
||||
/// </summary>
|
||||
public GenericVersiportDigitalOutputDeviceFactory()
|
||||
{
|
||||
TypeNames = new List<string>() { "versiportoutput" };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// BuildDevice method
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic Versiport Device");
|
||||
Debug.LogDebug("Factory Attempting to create new Generic Versiport Device");
|
||||
|
||||
var props = JsonConvert.DeserializeObject<IOPortConfig>(dc.Properties.ToString());
|
||||
|
||||
|
||||
@@ -12,6 +12,12 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
||||
/// </summary>
|
||||
public interface IAnalogInput
|
||||
{
|
||||
/// <summary>
|
||||
/// Get the InputValueFeedback.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Updates when the analog input value changes
|
||||
/// </remarks>
|
||||
IntFeedback InputValueFeedback { get; }
|
||||
}
|
||||
}
|
||||
@@ -14,25 +14,28 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
||||
/// </summary>
|
||||
public class IOPortConfig
|
||||
{
|
||||
[JsonProperty("portDeviceKey")]
|
||||
/// <summary>
|
||||
/// Gets or sets the PortDeviceKey
|
||||
/// </summary>
|
||||
[JsonProperty("portDeviceKey")]
|
||||
public string PortDeviceKey { get; set; }
|
||||
[JsonProperty("portNumber")]
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the PortNumber
|
||||
/// </summary>
|
||||
[JsonProperty("portNumber")]
|
||||
public uint PortNumber { get; set; }
|
||||
[JsonProperty("disablePullUpResistor")]
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the DisablePullUpResistor
|
||||
/// </summary>
|
||||
[JsonProperty("disablePullUpResistor")]
|
||||
public bool DisablePullUpResistor { get; set; }
|
||||
[JsonProperty("minimumChange")]
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the MinimumChange
|
||||
/// </summary>
|
||||
[JsonProperty("minimumChange")]
|
||||
public int MinimumChange { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using Crestron.SimplSharpPro.DM.Streaming;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Crestron.SimplSharpPro.DM.Streaming;
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
@@ -11,7 +12,7 @@ namespace PepperDash.Essentials.Core
|
||||
/// subscribers when the port information is updated. Implementations of this interface should ensure that the <see
|
||||
/// cref="PortInformationChanged"/> event is raised whenever the <see cref="NetworkPorts"/> collection
|
||||
/// changes.</remarks>
|
||||
public interface INvxNetworkPortInformation
|
||||
public interface INvxNetworkPortInformation : IKeyed
|
||||
{
|
||||
/// <summary>
|
||||
/// Occurs when the port information changes.
|
||||
|
||||
@@ -202,14 +202,15 @@ namespace PepperDash.Essentials.Core
|
||||
|
||||
private static void ListDevices(string s)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "{0} Devices registered with Device Manager:", Devices.Count);
|
||||
CrestronConsole.ConsoleCommandResponse($"{Devices.Count} Devices registered with Device Manager:\r\n");
|
||||
|
||||
var sorted = Devices.Values.ToList();
|
||||
sorted.Sort((a, b) => a.Key.CompareTo(b.Key));
|
||||
|
||||
foreach (var d in sorted)
|
||||
{
|
||||
var name = d is IKeyName ? (d as IKeyName).Name : "---";
|
||||
Debug.LogMessage(LogEventLevel.Information, " [{0}] {1}", d.Key, name);
|
||||
CrestronConsole.ConsoleCommandResponse($" [{d.Key}] {name}\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,28 +219,17 @@ namespace PepperDash.Essentials.Core
|
||||
var dev = GetDeviceForKey(devKey);
|
||||
if (dev == null)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "Device '{0}' not found", devKey);
|
||||
CrestronConsole.ConsoleCommandResponse($"Device '{devKey}' not found\r\n");
|
||||
return;
|
||||
}
|
||||
if (!(dev is IHasFeedback statusDev))
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "Device '{0}' does not have visible feedbacks", devKey);
|
||||
CrestronConsole.ConsoleCommandResponse($"Device '{devKey}' does not have visible feedbacks\r\n");
|
||||
return;
|
||||
}
|
||||
statusDev.DumpFeedbacksToConsole(true);
|
||||
}
|
||||
|
||||
//static void ListDeviceCommands(string devKey)
|
||||
//{
|
||||
// var dev = GetDeviceForKey(devKey);
|
||||
// if (dev == null)
|
||||
// {
|
||||
// Debug.LogMessage(LogEventLevel.Information, "Device '{0}' not found", devKey);
|
||||
// return;
|
||||
// }
|
||||
// Debug.LogMessage(LogEventLevel.Information, "This needs to be reworked. Stay tuned.", devKey);
|
||||
//}
|
||||
|
||||
private static void ListDeviceCommStatuses(string input)
|
||||
{
|
||||
|
||||
@@ -249,12 +239,6 @@ namespace PepperDash.Essentials.Core
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//static void DoDeviceCommand(string command)
|
||||
//{
|
||||
// Debug.LogMessage(LogEventLevel.Information, "Not yet implemented. Stay tuned");
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// AddDevice method
|
||||
/// </summary>
|
||||
@@ -475,9 +459,9 @@ namespace PepperDash.Essentials.Core
|
||||
if (String.IsNullOrEmpty(s) || s.Contains("?"))
|
||||
{
|
||||
CrestronConsole.ConsoleCommandResponse(
|
||||
@"SETDEVICESTREAMDEBUG [{deviceKey}] [OFF |TX | RX | BOTH] [timeOutInMinutes]
|
||||
{deviceKey} [OFF | TX | RX | BOTH] - Device to set stream debugging on, and which setting to use
|
||||
timeOutInMinutes - Set timeout for stream debugging. Default is 30 minutes");
|
||||
"SETDEVICESTREAMDEBUG [{deviceKey}] [OFF |TX | RX | BOTH] [timeOutInMinutes]\r\n" +
|
||||
" {deviceKey} [OFF | TX | RX | BOTH] - Device to set stream debugging on, and which setting to use\r\n" +
|
||||
" timeOutInMinutes - Set timeout for stream debugging. Default is 30 minutes");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,16 +3,29 @@ using PepperDash.Essentials.Core.Bridges;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
public abstract class EssentialsBridgeableDevice:EssentialsDevice, IBridgeAdvanced
|
||||
/// <summary>
|
||||
/// Base class for devices that can be bridged to an EISC API.
|
||||
/// </summary>
|
||||
public abstract class EssentialsBridgeableDevice : EssentialsDevice, IBridgeAdvanced
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="EssentialsBridgeableDevice"/> class with the specified key.
|
||||
/// </summary>
|
||||
/// <param name="key">The unique key for the device.</param>
|
||||
protected EssentialsBridgeableDevice(string key) : base(key)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="EssentialsBridgeableDevice"/> class with the specified key and name.
|
||||
/// </summary>
|
||||
/// <param name="key">The unique key for the device.</param>
|
||||
/// <param name="name">The display name for the device.</param>
|
||||
protected EssentialsBridgeableDevice(string key, string name) : base(key, name)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge);
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ namespace PepperDash.Essentials.Core
|
||||
public List<string> TypeNames { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// The method that will build the device
|
||||
/// Build the device using the configuration
|
||||
/// </summary>
|
||||
/// <param name="dc">The device config</param>
|
||||
/// <returns>An instance of the device</returns>
|
||||
|
||||
@@ -1,65 +1,90 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
using Crestron.SimplSharp;
|
||||
using PepperDash.Core;
|
||||
using Serilog.Events;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the contract for IHasFeedback
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Defines the contract for IHasFeedback
|
||||
/// </summary>
|
||||
public interface IHasFeedback : IKeyed
|
||||
{
|
||||
/// <summary>
|
||||
/// This method shall return a list of all Output objects on a device,
|
||||
/// This method returns a list of all Output objects on a device,
|
||||
/// including all "aggregate" devices.
|
||||
/// </summary>
|
||||
FeedbackCollection<Feedback> Feedbacks { get; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for IHasFeedback
|
||||
/// </summary>
|
||||
public static class IHasFeedbackExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the feedback type name for sorting purposes
|
||||
/// </summary>
|
||||
/// <param name="feedback">The feedback to get the type name for</param>
|
||||
/// <returns>A string representing the feedback type</returns>
|
||||
private static string GetFeedbackTypeName(Feedback feedback)
|
||||
{
|
||||
if (feedback is BoolFeedback)
|
||||
return "boolean";
|
||||
else if (feedback is IntFeedback)
|
||||
return "integer";
|
||||
else if (feedback is StringFeedback)
|
||||
return "string";
|
||||
else
|
||||
return feedback.GetType().Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dumps the feedbacks to the console
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="getCurrentStates"></param>
|
||||
public static void DumpFeedbacksToConsole(this IHasFeedback source, bool getCurrentStates)
|
||||
{
|
||||
Type t = source.GetType();
|
||||
// get the properties and set them into a new collection of NameType wrappers
|
||||
var props = t.GetProperties().Select(p => new PropertyNameType(p, t));
|
||||
|
||||
var feedbacks = source.Feedbacks;
|
||||
if (feedbacks != null)
|
||||
|
||||
if (feedbacks == null || feedbacks.Count == 0)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, source, "\n\nAvailable feedbacks:");
|
||||
foreach (var f in feedbacks)
|
||||
{
|
||||
string val = "";
|
||||
string type = "";
|
||||
if (getCurrentStates)
|
||||
{
|
||||
if (f is BoolFeedback)
|
||||
{
|
||||
val = f.BoolValue.ToString();
|
||||
type = "boolean";
|
||||
}
|
||||
else if (f is IntFeedback)
|
||||
{
|
||||
val = f.IntValue.ToString();
|
||||
type = "integer";
|
||||
}
|
||||
else if (f is StringFeedback)
|
||||
{
|
||||
val = f.StringValue;
|
||||
type = "string";
|
||||
}
|
||||
}
|
||||
Debug.LogMessage(LogEventLevel.Information, "{0,-12} {1, -25} {2}", type,
|
||||
(string.IsNullOrEmpty(f.Key) ? "-no key-" : f.Key), val);
|
||||
}
|
||||
CrestronConsole.ConsoleCommandResponse("No available feedbacks\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
CrestronConsole.ConsoleCommandResponse("Available feedbacks:\r\n");
|
||||
|
||||
// Sort feedbacks by type first, then by key
|
||||
var sortedFeedbacks = feedbacks.OrderBy(f => GetFeedbackTypeName(f)).ThenBy(f => string.IsNullOrEmpty(f.Key) ? "" : f.Key);
|
||||
|
||||
foreach (var feedback in sortedFeedbacks)
|
||||
{
|
||||
string value = "";
|
||||
string type = "";
|
||||
if (getCurrentStates)
|
||||
{
|
||||
if (feedback is BoolFeedback)
|
||||
{
|
||||
value = feedback.BoolValue.ToString();
|
||||
type = "boolean";
|
||||
}
|
||||
else if (feedback is IntFeedback)
|
||||
{
|
||||
value = feedback.IntValue.ToString();
|
||||
type = "integer";
|
||||
}
|
||||
else if (feedback is StringFeedback)
|
||||
{
|
||||
value = feedback.StringValue;
|
||||
type = "string";
|
||||
}
|
||||
}
|
||||
CrestronConsole.ConsoleCommandResponse($" {type,-12} {(string.IsNullOrEmpty(feedback.Key) ? "-no key-" : feedback.Key),-25} {value}\r\n");
|
||||
}
|
||||
else
|
||||
Debug.LogMessage(LogEventLevel.Information, source, "No available outputs:");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -244,6 +244,20 @@ namespace PepperDash.Essentials.Core
|
||||
/// </summary>
|
||||
[JsonProperty("type")]
|
||||
public eRoutingSignalType Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Key for a destination list item. If BOTH SourceListItemKey AND DestinationListItemKey are defined,
|
||||
/// then the direct route method should be used.
|
||||
/// </summary>
|
||||
[JsonProperty("destinationListItemKey", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public string DestinationListItemKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Key for a source list item. If BOTH SourceListItemKey AND DestinationListItemKey are defined,
|
||||
/// then the direct route method should be used.
|
||||
/// </summary>
|
||||
[JsonProperty("sourceListItemKey", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public string SourceListItemKey { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace PepperDash.Essentials.Core
|
||||
{
|
||||
if (FactoryMethods.ContainsKey(typeName))
|
||||
{
|
||||
Debug.LogInformation("Unable to add type: '{typeName}'. Already exists in DeviceFactory", typeName);
|
||||
Debug.LogInformation("Unable to add type: '{typeName}'. Already exists in DeviceFactory", typeName);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -217,7 +217,8 @@ namespace PepperDash.Essentials.Core
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError(ex, "Exception occurred while creating device {0}: {1}", null, dc.Key, ex.Message);
|
||||
Debug.LogError(ex, "Exception occurred while creating device {key}: {message}", dc.Key, ex.Message);
|
||||
Debug.LogDebug(ex, "Exception details: {stackTrace}", ex.StackTrace);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -249,9 +250,9 @@ namespace PepperDash.Essentials.Core
|
||||
}
|
||||
|
||||
CrestronConsole.ConsoleCommandResponse(
|
||||
@"Type: '{0}'
|
||||
Type: '{1}'
|
||||
Description: {2}{3}", type.Key, Type, description, CrestronEnvironment.NewLine);
|
||||
"Type: '{0}'\r\n" +
|
||||
" Type: '{1}'\r\n" +
|
||||
" Description: {2}{3}", type.Key, Type, description, CrestronEnvironment.NewLine);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -103,6 +103,12 @@ namespace PepperDash.Essentials.Core
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether to hide this scenario in the UI.
|
||||
/// </summary>
|
||||
[JsonProperty("hideInUi", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public bool HideInUi { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the collection of partition states.
|
||||
/// </summary>
|
||||
|
||||
@@ -109,6 +109,12 @@ namespace PepperDash.Essentials.Core
|
||||
[JsonProperty("isActive")]
|
||||
bool IsActive { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this scenario should be hidden in the UI.
|
||||
/// </summary>
|
||||
[JsonProperty("hideInUi")]
|
||||
bool HideInUi { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Activates this room combination scenario
|
||||
/// </summary>
|
||||
|
||||
@@ -14,18 +14,40 @@ namespace PepperDash.Essentials.Core
|
||||
{
|
||||
private RoomCombinationScenarioConfig _config;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the key associated with the object.
|
||||
/// </summary>
|
||||
[JsonProperty("key")]
|
||||
public string Key { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name associated with the object.
|
||||
/// </summary>
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonProperty("partitionStates")]
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether to hide this scenario in the UI.
|
||||
/// </summary>
|
||||
///
|
||||
[JsonProperty("hideInUi")]
|
||||
|
||||
public bool HideInUi
|
||||
{
|
||||
get { return _config.HideInUi; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the PartitionStates
|
||||
/// </summary>
|
||||
///
|
||||
[JsonProperty("partitionStates")]
|
||||
|
||||
public List<PartitionState> PartitionStates { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Determines which UI devices get mapped to which room in this scenario. The Key should be the key of the UI device and the Value should be the key of the room to map to
|
||||
/// </summary>
|
||||
[JsonProperty("uiMap")]
|
||||
public Dictionary<string, string> UiMap { get; set; }
|
||||
|
||||
|
||||
@@ -9,11 +9,11 @@ using Serilog.Events;
|
||||
|
||||
namespace PepperDash.Essentials.Room.Config
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a EssentialsRoomConfigHelper
|
||||
/// </summary>
|
||||
public class EssentialsRoomConfigHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a EssentialsRoomConfigHelper
|
||||
/// </summary>
|
||||
public class EssentialsRoomConfigHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// GetEmergency method
|
||||
/// </summary>
|
||||
@@ -31,100 +31,100 @@ namespace PepperDash.Essentials.Room.Config
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="props"></param>
|
||||
/// <param name="room"></param>
|
||||
/// <returns></returns>
|
||||
/// <summary>
|
||||
/// GetMicrophonePrivacy method
|
||||
/// </summary>
|
||||
public static MicrophonePrivacyController GetMicrophonePrivacy(
|
||||
EssentialsRoomPropertiesConfig props, IPrivacy room)
|
||||
{
|
||||
var microphonePrivacy = props.MicrophonePrivacy;
|
||||
if (microphonePrivacy == null)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "Cannot create microphone privacy with null properties");
|
||||
return null;
|
||||
}
|
||||
// Get the MicrophonePrivacy device from the device manager
|
||||
var mP = (DeviceManager.GetDeviceForKey(props.MicrophonePrivacy.DeviceKey) as MicrophonePrivacyController);
|
||||
// Set this room as the IPrivacy device
|
||||
if (mP == null)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "ERROR: Selected device {0} is not MicrophonePrivacyController", props.MicrophonePrivacy.DeviceKey);
|
||||
return null;
|
||||
}
|
||||
mP.SetPrivacyDevice(room);
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="props"></param>
|
||||
/// <param name="room"></param>
|
||||
/// <returns></returns>
|
||||
/// <summary>
|
||||
/// GetMicrophonePrivacy method
|
||||
/// </summary>
|
||||
public static MicrophonePrivacyController GetMicrophonePrivacy(
|
||||
EssentialsRoomPropertiesConfig props, IPrivacy room)
|
||||
{
|
||||
var microphonePrivacy = props.MicrophonePrivacy;
|
||||
if (microphonePrivacy == null)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "Cannot create microphone privacy with null properties");
|
||||
return null;
|
||||
}
|
||||
// Get the MicrophonePrivacy device from the device manager
|
||||
var mP = (DeviceManager.GetDeviceForKey(props.MicrophonePrivacy.DeviceKey) as MicrophonePrivacyController);
|
||||
// Set this room as the IPrivacy device
|
||||
if (mP == null)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "ERROR: Selected device {0} is not MicrophonePrivacyController", props.MicrophonePrivacy.DeviceKey);
|
||||
return null;
|
||||
}
|
||||
mP.SetPrivacyDevice(room);
|
||||
|
||||
var behaviour = props.MicrophonePrivacy.Behaviour.ToLower();
|
||||
var behaviour = props.MicrophonePrivacy.Behaviour.ToLower();
|
||||
|
||||
if (behaviour == null)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "WARNING: No behaviour defined for MicrophonePrivacyController");
|
||||
return null;
|
||||
}
|
||||
if (behaviour == "trackroomstate")
|
||||
{
|
||||
// Tie LED enable to room power state
|
||||
if (behaviour == null)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "WARNING: No behaviour defined for MicrophonePrivacyController");
|
||||
return null;
|
||||
}
|
||||
if (behaviour == "trackroomstate")
|
||||
{
|
||||
// Tie LED enable to room power state
|
||||
var essRoom = room as IEssentialsRoom;
|
||||
essRoom.OnFeedback.OutputChange += (o, a) =>
|
||||
{
|
||||
{
|
||||
if (essRoom.OnFeedback.BoolValue)
|
||||
mP.EnableLeds = true;
|
||||
else
|
||||
mP.EnableLeds = false;
|
||||
};
|
||||
mP.EnableLeds = true;
|
||||
else
|
||||
mP.EnableLeds = false;
|
||||
};
|
||||
|
||||
mP.EnableLeds = essRoom.OnFeedback.BoolValue;
|
||||
}
|
||||
else if (behaviour == "trackcallstate")
|
||||
{
|
||||
// Tie LED enable to room power state
|
||||
}
|
||||
else if (behaviour == "trackcallstate")
|
||||
{
|
||||
// Tie LED enable to room power state
|
||||
var inCallRoom = room as IHasInCallFeedback;
|
||||
inCallRoom.InCallFeedback.OutputChange += (o, a) =>
|
||||
{
|
||||
{
|
||||
if (inCallRoom.InCallFeedback.BoolValue)
|
||||
mP.EnableLeds = true;
|
||||
else
|
||||
mP.EnableLeds = false;
|
||||
};
|
||||
mP.EnableLeds = true;
|
||||
else
|
||||
mP.EnableLeds = false;
|
||||
};
|
||||
|
||||
mP.EnableLeds = inCallRoom.InCallFeedback.BoolValue;
|
||||
}
|
||||
}
|
||||
|
||||
return mP;
|
||||
}
|
||||
|
||||
}
|
||||
return mP;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a EssentialsRoomPropertiesConfig
|
||||
/// </summary>
|
||||
public class EssentialsRoomPropertiesConfig
|
||||
{
|
||||
[JsonProperty("addresses")]
|
||||
public EssentialsRoomAddressPropertiesConfig Addresses { get; set; }
|
||||
}
|
||||
|
||||
[JsonProperty("description")]
|
||||
public string Description { get; set; }
|
||||
/// <summary>
|
||||
/// Represents a EssentialsRoomPropertiesConfig
|
||||
/// </summary>
|
||||
public class EssentialsRoomPropertiesConfig
|
||||
{
|
||||
[JsonProperty("addresses")]
|
||||
public EssentialsRoomAddressPropertiesConfig Addresses { get; set; }
|
||||
|
||||
[JsonProperty("emergency")]
|
||||
public EssentialsRoomEmergencyConfig Emergency { get; set; }
|
||||
[JsonProperty("description")]
|
||||
public string Description { get; set; }
|
||||
|
||||
[JsonProperty("help")]
|
||||
/// <summary>
|
||||
/// Gets or sets the Help
|
||||
/// </summary>
|
||||
public EssentialsHelpPropertiesConfig Help { get; set; }
|
||||
[JsonProperty("emergency")]
|
||||
public EssentialsRoomEmergencyConfig Emergency { get; set; }
|
||||
|
||||
[JsonProperty("helpMessage")]
|
||||
/// <summary>
|
||||
/// Gets or sets the HelpMessage
|
||||
/// </summary>
|
||||
public string HelpMessage { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the Help
|
||||
/// </summary>
|
||||
[JsonProperty("help")]
|
||||
public EssentialsHelpPropertiesConfig Help { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the HelpMessage
|
||||
/// </summary>
|
||||
[JsonProperty("helpMessage")]
|
||||
public string HelpMessage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Read this value to get the help message. It checks for the old and new config format.
|
||||
@@ -133,94 +133,94 @@ namespace PepperDash.Essentials.Room.Config
|
||||
{
|
||||
get
|
||||
{
|
||||
if(Help != null && !string.IsNullOrEmpty(Help.Message))
|
||||
if (Help != null && !string.IsNullOrEmpty(Help.Message))
|
||||
{
|
||||
return Help.Message;
|
||||
}
|
||||
else
|
||||
{
|
||||
return HelpMessage;
|
||||
return HelpMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[JsonProperty("environment")]
|
||||
/// <summary>
|
||||
/// Gets or sets the Environment
|
||||
/// </summary>
|
||||
public EssentialsEnvironmentPropertiesConfig Environment { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the Environment
|
||||
/// </summary>
|
||||
[JsonProperty("environment")]
|
||||
public EssentialsEnvironmentPropertiesConfig Environment { get; set; }
|
||||
|
||||
[JsonProperty("logo")]
|
||||
/// <summary>
|
||||
/// Gets or sets the LogoLight
|
||||
/// </summary>
|
||||
public EssentialsLogoPropertiesConfig LogoLight { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the LogoLight
|
||||
/// </summary>
|
||||
[JsonProperty("logo")]
|
||||
public EssentialsLogoPropertiesConfig LogoLight { get; set; }
|
||||
|
||||
[JsonProperty("logoDark")]
|
||||
/// <summary>
|
||||
/// Gets or sets the LogoDark
|
||||
/// </summary>
|
||||
[JsonProperty("logoDark")]
|
||||
public EssentialsLogoPropertiesConfig LogoDark { get; set; }
|
||||
|
||||
[JsonProperty("microphonePrivacy")]
|
||||
/// <summary>
|
||||
/// Gets or sets the MicrophonePrivacy
|
||||
/// </summary>
|
||||
public EssentialsRoomMicrophonePrivacyConfig MicrophonePrivacy { get; set; }
|
||||
|
||||
[JsonProperty("occupancy")]
|
||||
/// <summary>
|
||||
/// Gets or sets the Occupancy
|
||||
/// </summary>
|
||||
public EssentialsRoomOccSensorConfig Occupancy { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the MicrophonePrivacy
|
||||
/// </summary>
|
||||
[JsonProperty("microphonePrivacy")]
|
||||
public EssentialsRoomMicrophonePrivacyConfig MicrophonePrivacy { get; set; }
|
||||
|
||||
[JsonProperty("oneButtonMeeting")]
|
||||
/// <summary>
|
||||
/// Gets or sets the OneButtonMeeting
|
||||
/// </summary>
|
||||
public EssentialsOneButtonMeetingPropertiesConfig OneButtonMeeting { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the Occupancy
|
||||
/// </summary>
|
||||
[JsonProperty("occupancy")]
|
||||
public EssentialsRoomOccSensorConfig Occupancy { get; set; }
|
||||
|
||||
[JsonProperty("shutdownVacancySeconds")]
|
||||
/// <summary>
|
||||
/// Gets or sets the ShutdownVacancySeconds
|
||||
/// </summary>
|
||||
public int ShutdownVacancySeconds { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the OneButtonMeeting
|
||||
/// </summary>
|
||||
[JsonProperty("oneButtonMeeting")]
|
||||
public EssentialsOneButtonMeetingPropertiesConfig OneButtonMeeting { get; set; }
|
||||
|
||||
[JsonProperty("shutdownPromptSeconds")]
|
||||
/// <summary>
|
||||
/// Gets or sets the ShutdownPromptSeconds
|
||||
/// </summary>
|
||||
public int ShutdownPromptSeconds { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the ShutdownVacancySeconds
|
||||
/// </summary>
|
||||
[JsonProperty("shutdownVacancySeconds")]
|
||||
public int ShutdownVacancySeconds { get; set; }
|
||||
|
||||
[JsonProperty("tech")]
|
||||
/// <summary>
|
||||
/// Gets or sets the Tech
|
||||
/// </summary>
|
||||
public EssentialsRoomTechConfig Tech { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the ShutdownPromptSeconds
|
||||
/// </summary>
|
||||
[JsonProperty("shutdownPromptSeconds")]
|
||||
public int ShutdownPromptSeconds { get; set; }
|
||||
|
||||
[JsonProperty("volumes")]
|
||||
/// <summary>
|
||||
/// Gets or sets the Volumes
|
||||
/// </summary>
|
||||
public EssentialsRoomVolumesConfig Volumes { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the Tech
|
||||
/// </summary>
|
||||
[JsonProperty("tech")]
|
||||
public EssentialsRoomTechConfig Tech { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Volumes
|
||||
/// </summary>
|
||||
[JsonProperty("volumes")]
|
||||
public EssentialsRoomVolumesConfig Volumes { get; set; }
|
||||
|
||||
[JsonProperty("fusion")]
|
||||
/// <summary>
|
||||
/// Gets or sets the Fusion
|
||||
/// </summary>
|
||||
[JsonProperty("fusion")]
|
||||
public EssentialsRoomFusionConfig Fusion { get; set; }
|
||||
|
||||
[JsonProperty("essentialsRoomUiBehaviorConfig", NullValueHandling=NullValueHandling.Ignore)]
|
||||
/// <summary>
|
||||
/// Gets or sets the UiBehavior
|
||||
/// </summary>
|
||||
[JsonProperty("essentialsRoomUiBehaviorConfig", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public EssentialsRoomUiBehaviorConfig UiBehavior { get; set; }
|
||||
|
||||
[JsonProperty("zeroVolumeWhenSwtichingVolumeDevices")]
|
||||
/// <summary>
|
||||
/// Gets or sets the ZeroVolumeWhenSwtichingVolumeDevices
|
||||
/// </summary>
|
||||
public bool ZeroVolumeWhenSwtichingVolumeDevices { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the ZeroVolumeWhenSwtichingVolumeDevices
|
||||
/// </summary>
|
||||
[JsonProperty("zeroVolumeWhenSwtichingVolumeDevices")]
|
||||
public bool ZeroVolumeWhenSwtichingVolumeDevices { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if this room represents a combination of other rooms
|
||||
@@ -236,7 +236,7 @@ namespace PepperDash.Essentials.Room.Config
|
||||
LogoLight = new EssentialsLogoPropertiesConfig();
|
||||
LogoDark = new EssentialsLogoPropertiesConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a EssentialsRoomUiBehaviorConfig
|
||||
@@ -327,15 +327,15 @@ namespace PepperDash.Essentials.Room.Config
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a EssentialsEnvironmentPropertiesConfig
|
||||
/// </summary>
|
||||
public class EssentialsEnvironmentPropertiesConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the Enabled
|
||||
/// </summary>
|
||||
public bool Enabled { get; set; }
|
||||
/// <summary>
|
||||
/// Represents a EssentialsEnvironmentPropertiesConfig
|
||||
/// </summary>
|
||||
public class EssentialsEnvironmentPropertiesConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the Enabled
|
||||
/// </summary>
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
[JsonProperty("deviceKeys")]
|
||||
/// <summary>
|
||||
@@ -348,7 +348,7 @@ namespace PepperDash.Essentials.Room.Config
|
||||
DeviceKeys = new List<string>();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a EssentialsRoomFusionConfig
|
||||
@@ -359,7 +359,7 @@ namespace PepperDash.Essentials.Room.Config
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
try
|
||||
{
|
||||
return Convert.ToUInt32(IpId, 16);
|
||||
}
|
||||
@@ -367,7 +367,7 @@ namespace PepperDash.Essentials.Room.Config
|
||||
{
|
||||
throw new FormatException(string.Format("ERROR:Unable to convert IP ID: {0} to hex. Error:\n{1}", IpId));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,17 +390,17 @@ namespace PepperDash.Essentials.Room.Config
|
||||
/// </summary>
|
||||
public class EssentialsRoomMicrophonePrivacyConfig
|
||||
{
|
||||
[JsonProperty("deviceKey")]
|
||||
/// <summary>
|
||||
/// Gets or sets the DeviceKey
|
||||
/// </summary>
|
||||
public string DeviceKey { get; set; }
|
||||
[JsonProperty("deviceKey")]
|
||||
/// <summary>
|
||||
/// Gets or sets the DeviceKey
|
||||
/// </summary>
|
||||
public string DeviceKey { get; set; }
|
||||
|
||||
[JsonProperty("behaviour")]
|
||||
/// <summary>
|
||||
/// Gets or sets the Behaviour
|
||||
/// </summary>
|
||||
public string Behaviour { get; set; }
|
||||
[JsonProperty("behaviour")]
|
||||
/// <summary>
|
||||
/// Gets or sets the Behaviour
|
||||
/// </summary>
|
||||
public string Behaviour { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -408,23 +408,23 @@ namespace PepperDash.Essentials.Room.Config
|
||||
/// </summary>
|
||||
public class EssentialsHelpPropertiesConfig
|
||||
{
|
||||
[JsonProperty("message")]
|
||||
/// <summary>
|
||||
/// Gets or sets the Message
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
[JsonProperty("message")]
|
||||
/// <summary>
|
||||
/// Gets or sets the Message
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
|
||||
[JsonProperty("showCallButton")]
|
||||
public bool ShowCallButton { get; set; }
|
||||
|
||||
/// <summary>
|
||||
[JsonProperty("showCallButton")]
|
||||
public bool ShowCallButton { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Defaults to "Call Help Desk"
|
||||
/// </summary>
|
||||
[JsonProperty("callButtonText")]
|
||||
/// <summary>
|
||||
/// Gets or sets the CallButtonText
|
||||
/// </summary>
|
||||
public string CallButtonText { get; set; }
|
||||
[JsonProperty("callButtonText")]
|
||||
/// <summary>
|
||||
/// Gets or sets the CallButtonText
|
||||
/// </summary>
|
||||
public string CallButtonText { get; set; }
|
||||
|
||||
public EssentialsHelpPropertiesConfig()
|
||||
{
|
||||
@@ -437,23 +437,23 @@ namespace PepperDash.Essentials.Room.Config
|
||||
/// </summary>
|
||||
public class EssentialsOneButtonMeetingPropertiesConfig
|
||||
{
|
||||
[JsonProperty("enable")]
|
||||
/// <summary>
|
||||
/// Gets or sets the Enable
|
||||
/// </summary>
|
||||
public bool Enable { get; set; }
|
||||
[JsonProperty("enable")]
|
||||
/// <summary>
|
||||
/// Gets or sets the Enable
|
||||
/// </summary>
|
||||
public bool Enable { get; set; }
|
||||
}
|
||||
|
||||
public class EssentialsRoomAddressPropertiesConfig
|
||||
{
|
||||
[JsonProperty("phoneNumber")]
|
||||
public string PhoneNumber { get; set; }
|
||||
[JsonProperty("phoneNumber")]
|
||||
public string PhoneNumber { get; set; }
|
||||
|
||||
[JsonProperty("sipAddress")]
|
||||
/// <summary>
|
||||
/// Gets or sets the SipAddress
|
||||
/// </summary>
|
||||
public string SipAddress { get; set; }
|
||||
[JsonProperty("sipAddress")]
|
||||
/// <summary>
|
||||
/// Gets or sets the SipAddress
|
||||
/// </summary>
|
||||
public string SipAddress { get; set; }
|
||||
}
|
||||
|
||||
|
||||
@@ -462,14 +462,14 @@ namespace PepperDash.Essentials.Room.Config
|
||||
/// </summary>
|
||||
public class EssentialsLogoPropertiesConfig
|
||||
{
|
||||
[JsonProperty("type")]
|
||||
/// <summary>
|
||||
/// Gets or sets the Type
|
||||
/// </summary>
|
||||
public string Type { get; set; }
|
||||
[JsonProperty("type")]
|
||||
/// <summary>
|
||||
/// Gets or sets the Type
|
||||
/// </summary>
|
||||
public string Type { get; set; }
|
||||
|
||||
[JsonProperty("url")]
|
||||
public string Url { get; set; }
|
||||
[JsonProperty("url")]
|
||||
public string Url { get; set; }
|
||||
/// <summary>
|
||||
/// GetLogoUrlLight method
|
||||
/// </summary>
|
||||
@@ -478,7 +478,7 @@ namespace PepperDash.Essentials.Room.Config
|
||||
if (Type == "url")
|
||||
return Url;
|
||||
if (Type == "system")
|
||||
return string.Format("http://{0}:8080/logo.png",
|
||||
return string.Format("http://{0}:8080/logo.png",
|
||||
CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0));
|
||||
return null;
|
||||
}
|
||||
@@ -502,22 +502,22 @@ namespace PepperDash.Essentials.Room.Config
|
||||
/// </summary>
|
||||
public class EssentialsRoomOccSensorConfig
|
||||
{
|
||||
[JsonProperty("deviceKey")]
|
||||
/// <summary>
|
||||
/// Gets or sets the DeviceKey
|
||||
/// </summary>
|
||||
public string DeviceKey { get; set; }
|
||||
[JsonProperty("deviceKey")]
|
||||
/// <summary>
|
||||
/// Gets or sets the DeviceKey
|
||||
/// </summary>
|
||||
public string DeviceKey { get; set; }
|
||||
|
||||
[JsonProperty("timeoutMinutes")]
|
||||
public int TimeoutMinutes { get; set; }
|
||||
[JsonProperty("timeoutMinutes")]
|
||||
public int TimeoutMinutes { get; set; }
|
||||
}
|
||||
|
||||
public class EssentialsRoomTechConfig
|
||||
{
|
||||
[JsonProperty("password")]
|
||||
/// <summary>
|
||||
/// Gets or sets the Password
|
||||
/// </summary>
|
||||
public string Password { get; set; }
|
||||
}
|
||||
public class EssentialsRoomTechConfig
|
||||
{
|
||||
[JsonProperty("password")]
|
||||
/// <summary>
|
||||
/// Gets or sets the Password
|
||||
/// </summary>
|
||||
public string Password { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using PepperDash.Essentials.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core.Routing
|
||||
{
|
||||
@@ -25,5 +25,19 @@ namespace PepperDash.Essentials.Core.Routing
|
||||
/// </summary>
|
||||
Dictionary<eRoutingSignalType, string> CurrentSourceKeys { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Event raised when the current sources change.
|
||||
/// </summary>
|
||||
event EventHandler CurrentSourcesChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the current source for a specific signal type.
|
||||
/// This method updates the current source for the specified signal type and notifies any subscribers of the change.
|
||||
/// </summary>
|
||||
/// <param name="signalType">The signal type to update.</param>
|
||||
/// <param name="sourceListKey">The key for the source list.</param>
|
||||
/// <param name="sourceListItem">The source list item to set as the current source.</param>
|
||||
void SetCurrentSource(eRoutingSignalType signalType, string sourceListKey, SourceListItem sourceListItem);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,38 +22,38 @@ namespace PepperDash.Essentials.Core.Config
|
||||
/// The key of the source device.
|
||||
/// </summary>
|
||||
public string SourceKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The key of the source card (if applicable, e.g., in a modular chassis).
|
||||
/// </summary>
|
||||
|
||||
/// <summary>
|
||||
/// The key of the source card (if applicable, e.g., in a modular chassis).
|
||||
/// </summary>
|
||||
public string SourceCard { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The key of the source output port, used for routing configurations.
|
||||
/// </summary>
|
||||
|
||||
/// <summary>
|
||||
/// The key of the source output port, used for routing configurations.
|
||||
/// </summary>
|
||||
public string SourcePort { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the DestinationKey
|
||||
/// </summary>
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the DestinationKey
|
||||
/// </summary>
|
||||
public string DestinationKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the DestinationCard
|
||||
/// </summary>
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the DestinationCard
|
||||
/// </summary>
|
||||
public string DestinationCard { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the DestinationPort
|
||||
/// </summary>
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the DestinationPort
|
||||
/// </summary>
|
||||
public string DestinationPort { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Optional override for the signal type of the tie line. If set, this overrides the destination port's type for routing calculations.
|
||||
/// </summary>
|
||||
[JsonProperty("type", NullValueHandling = NullValueHandling.Ignore)]
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public eRoutingSignalType? OverrideType { get; set; }
|
||||
/// <summary>
|
||||
/// Optional override for the signal type of the tie line. If set, this overrides the destination port's type for routing calculations.
|
||||
/// </summary>
|
||||
[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
|
||||
@@ -62,40 +62,39 @@ namespace PepperDash.Essentials.Core.Config
|
||||
/// <returns>null if config data does not match ports, cards or devices</returns>
|
||||
public TieLine GetTieLine()
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "Build TieLine: {0}",null, this);
|
||||
Debug.LogInformation("Build TieLine: {config}", ToString());
|
||||
|
||||
// Get the source device
|
||||
var sourceDev = DeviceManager.GetDeviceForKey(SourceKey) as IRoutingOutputs;
|
||||
if (sourceDev == null)
|
||||
if (!(DeviceManager.GetDeviceForKey(SourceKey) is IRoutingOutputs sourceDev))
|
||||
{
|
||||
LogError("Routable source not found");
|
||||
return null;
|
||||
}
|
||||
|
||||
// Get the destination device
|
||||
var destDev = DeviceManager.GetDeviceForKey(DestinationKey) as IRoutingInputs;
|
||||
if (destDev == null)
|
||||
if (!(DeviceManager.GetDeviceForKey(DestinationKey) is IRoutingInputs destDev))
|
||||
{
|
||||
LogError("Routable destination not found");
|
||||
return null;
|
||||
}
|
||||
|
||||
//Get the source port
|
||||
var sourceOutputPort = sourceDev.OutputPorts[SourcePort];
|
||||
//Get the source port
|
||||
var sourceOutputPort = sourceDev.OutputPorts[SourcePort];
|
||||
|
||||
if (sourceOutputPort == null)
|
||||
if (sourceOutputPort == null)
|
||||
{
|
||||
LogError("Source does not contain port");
|
||||
return null;
|
||||
}
|
||||
|
||||
//Get the Destination port
|
||||
var destinationInputPort = destDev.InputPorts[DestinationPort];
|
||||
//Get the Destination port
|
||||
var destinationInputPort = destDev.InputPorts[DestinationPort];
|
||||
|
||||
if (destinationInputPort == null)
|
||||
{
|
||||
LogError("Destination does not contain port");
|
||||
return null;
|
||||
}
|
||||
if (destinationInputPort == null)
|
||||
{
|
||||
LogError("Destination does not contain port");
|
||||
return null;
|
||||
}
|
||||
|
||||
return new TieLine(sourceOutputPort, destinationInputPort, OverrideType);
|
||||
}
|
||||
@@ -104,9 +103,9 @@ namespace PepperDash.Essentials.Core.Config
|
||||
/// Logs an error message related to creating this tie line configuration.
|
||||
/// </summary>
|
||||
/// <param name="msg">The specific error message.</param>
|
||||
void LogError(string msg)
|
||||
private void LogError(string msg)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Error, "WARNING: Cannot create tie line: {message}:\r {tieLineConfig}",null, msg, this);
|
||||
Debug.LogError("Cannot create tie line: {message}", msg);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -115,8 +114,7 @@ namespace PepperDash.Essentials.Core.Config
|
||||
/// <returns>A string describing the source and destination of the configured tie line.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0}.{1}.{2} --> {3}.{4}.{5}", SourceKey, SourceCard, SourcePort,
|
||||
DestinationKey, DestinationCard, DestinationPort);
|
||||
return $"{SourceKey}.{SourceCard}.{SourcePort} --> {DestinationKey}.{DestinationCard}.{DestinationPort}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,14 +14,14 @@ using Serilog.Events;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
////*****************************************************************************
|
||||
/// <summary>
|
||||
/// Base class for all subpage reference list controllers
|
||||
/// </summary>
|
||||
//public class SubpageReferenceListController
|
||||
//{
|
||||
// public SubpageReferenceList TheList { get; protected set; }
|
||||
//}
|
||||
////*****************************************************************************
|
||||
///// <summary>
|
||||
///// Base class for all subpage reference list controllers
|
||||
///// </summary>
|
||||
//public class SubpageReferenceListController
|
||||
//{
|
||||
// public SubpageReferenceList TheList { get; protected set; }
|
||||
//}
|
||||
|
||||
//*****************************************************************************
|
||||
/// <summary>
|
||||
@@ -34,26 +34,26 @@ namespace PepperDash.Essentials.Core
|
||||
public ushort Count
|
||||
{
|
||||
get { return SetNumberOfItemsSig.UShortValue; }
|
||||
set { SetNumberOfItemsSig.UShortValue = value; }
|
||||
set { SetNumberOfItemsSig.UShortValue = value; }
|
||||
}
|
||||
public ushort MaxDefinedItems { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ScrollToItemSig
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the ScrollToItemSig
|
||||
/// </summary>
|
||||
public UShortInputSig ScrollToItemSig { get; private set; }
|
||||
UShortInputSig SetNumberOfItemsSig;
|
||||
/// <summary>
|
||||
/// Gets or sets the BoolIncrement
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the BoolIncrement
|
||||
/// </summary>
|
||||
public uint BoolIncrement { get; protected set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the UShortIncrement
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the UShortIncrement
|
||||
/// </summary>
|
||||
public uint UShortIncrement { get; protected set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the StringIncrement
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the StringIncrement
|
||||
/// </summary>
|
||||
public uint StringIncrement { get; protected set; }
|
||||
|
||||
protected readonly SmartObject SRL;
|
||||
@@ -87,8 +87,8 @@ namespace PepperDash.Essentials.Core
|
||||
SRL.SigChange += new SmartObjectSigChangeEventHandler(SRL_SigChange);
|
||||
}
|
||||
else
|
||||
Debug.LogMessage(LogEventLevel.Information, "ERROR: TriList 0x{0:X2} Cannot load smart object {1}. Verify correct SGD file is loaded",
|
||||
triList.ID, smartObjectId);
|
||||
Debug.LogMessage(LogEventLevel.Information, "ERROR: TriList 0x{0:X2} Cannot load smart object {1}. Verify correct SGD file is loaded",
|
||||
triList.ID, smartObjectId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -96,17 +96,17 @@ namespace PepperDash.Essentials.Core
|
||||
/// DOES NOT adjust Count
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <summary>
|
||||
/// AddItem method
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// AddItem method
|
||||
/// </summary>
|
||||
public void AddItem(SubpageReferenceListItem item)
|
||||
{
|
||||
Items.Add(item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear method
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Clear method
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
// If a line item needs to disconnect an CueActionPair or do something to release RAM
|
||||
@@ -116,12 +116,12 @@ namespace PepperDash.Essentials.Core
|
||||
// Clean up the SRL
|
||||
Count = 1;
|
||||
|
||||
ScrollToItemSig.UShortValue = 1;
|
||||
ScrollToItemSig.UShortValue = 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refresh method
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Refresh method
|
||||
/// </summary>
|
||||
public void Refresh()
|
||||
{
|
||||
foreach (var item in Items) item.Refresh();
|
||||
@@ -157,7 +157,7 @@ namespace PepperDash.Essentials.Core
|
||||
public UShortOutputSig GetUShortOutputSig(uint index, uint sigNum)
|
||||
{
|
||||
if (sigNum > UShortIncrement) return null;
|
||||
return SRL.UShortOutput.FirstOrDefault(s => s.Name.Equals(GetUShortOutputSigName(index, sigNum)));
|
||||
return SRL.UShortOutput.FirstOrDefault(s => s.Name.Equals(GetUShortOutputSigName(index, sigNum)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -172,7 +172,7 @@ namespace PepperDash.Essentials.Core
|
||||
public StringOutputSig GetStringOutputSig(uint index, uint sigNum)
|
||||
{
|
||||
if (sigNum > StringIncrement) return null;
|
||||
return SRL.StringOutput.FirstOrDefault(s => s.Name.Equals(GetStringOutputSigName(index, sigNum)));
|
||||
return SRL.StringOutput.FirstOrDefault(s => s.Name.Equals(GetStringOutputSigName(index, sigNum)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -263,9 +263,9 @@ namespace PepperDash.Essentials.Core
|
||||
/// </summary>
|
||||
/// <param name="currentDevice"></param>
|
||||
/// <param name="args"></param>
|
||||
/// <summary>
|
||||
/// SRL_SigChange method
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// SRL_SigChange method
|
||||
/// </summary>
|
||||
public static void SRL_SigChange(GenericBase currentDevice, SmartObjectEventArgs args)
|
||||
{
|
||||
var uo = args.Sig.UserObject;
|
||||
|
||||
@@ -6,9 +6,9 @@ using Serilog.Events;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a ModalDialog
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Represents a ModalDialog
|
||||
/// </summary>
|
||||
public class ModalDialog
|
||||
{
|
||||
/// <summary>
|
||||
@@ -19,10 +19,10 @@ namespace PepperDash.Essentials.Core
|
||||
/// Bool press 3992
|
||||
/// </summary>
|
||||
public const uint Button2Join = 3992;
|
||||
/// <summary>
|
||||
/// 3993
|
||||
/// </summary>
|
||||
public const uint CancelButtonJoin = 3993;
|
||||
/// <summary>
|
||||
/// 3993
|
||||
/// </summary>
|
||||
public const uint CancelButtonJoin = 3993;
|
||||
/// <summary>
|
||||
///For visibility of single button. Bool feedback 3994
|
||||
/// </summary>
|
||||
@@ -35,19 +35,19 @@ namespace PepperDash.Essentials.Core
|
||||
/// Shows the timer guage if in use. Bool feedback 3996
|
||||
/// </summary>
|
||||
public const uint TimerVisibleJoin = 3996;
|
||||
/// <summary>
|
||||
/// Visibility join to show "X" button 3997
|
||||
/// </summary>
|
||||
public const uint CancelVisibleJoin = 3997;
|
||||
/// <summary>
|
||||
/// Visibility join to show "X" button 3997
|
||||
/// </summary>
|
||||
public const uint CancelVisibleJoin = 3997;
|
||||
/// <summary>
|
||||
/// Shows the modal subpage. Boolean feeback join 3999
|
||||
/// </summary>
|
||||
public const uint ModalVisibleJoin = 3999;
|
||||
|
||||
/// <summary>
|
||||
/// The seconds value of the countdown timer. Ushort join 3991
|
||||
/// </summary>
|
||||
//public const uint TimerSecondsJoin = 3991;
|
||||
///// <summary>
|
||||
///// The seconds value of the countdown timer. Ushort join 3991
|
||||
///// </summary>
|
||||
//public const uint TimerSecondsJoin = 3991;
|
||||
/// <summary>
|
||||
/// The full ushort value of the countdown timer for a gauge. Ushort join 3992
|
||||
/// </summary>
|
||||
@@ -77,15 +77,15 @@ namespace PepperDash.Essentials.Core
|
||||
/// <summary>
|
||||
/// Returns true when modal is showing
|
||||
/// </summary>
|
||||
public bool ModalIsVisible
|
||||
{
|
||||
get { return TriList.BooleanInput[ModalVisibleJoin].BoolValue; }
|
||||
public bool ModalIsVisible
|
||||
{
|
||||
get { return TriList.BooleanInput[ModalVisibleJoin].BoolValue; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool CanCancel { get; private set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool CanCancel { get; private set; }
|
||||
|
||||
|
||||
BasicTriList TriList;
|
||||
@@ -103,10 +103,10 @@ namespace PepperDash.Essentials.Core
|
||||
TriList = triList;
|
||||
// Attach actions to buttons
|
||||
|
||||
triList.SetSigFalseAction(Button1Join, () => OnModalComplete(1));
|
||||
triList.SetSigFalseAction(Button1Join, () => OnModalComplete(1));
|
||||
triList.SetSigFalseAction(Button2Join, () => OnModalComplete(2));
|
||||
triList.SetSigFalseAction(CancelButtonJoin, () => { if (CanCancel) CancelDialog(); });
|
||||
CanCancel = true;
|
||||
triList.SetSigFalseAction(CancelButtonJoin, () => { if (CanCancel) CancelDialog(); });
|
||||
CanCancel = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -117,7 +117,7 @@ namespace PepperDash.Essentials.Core
|
||||
/// <param name="decreasingGauge">If the progress bar gauge needs to count down instead of up</param>
|
||||
/// <param name="completeAction">The action to run when the dialog is dismissed. Parameter will be 1 or 2 if button pressed, or 0 if dialog times out</param>
|
||||
/// <returns>True when modal is created.</returns>
|
||||
public bool PresentModalDialog(uint numberOfButtons, string title, string iconName,
|
||||
public bool PresentModalDialog(uint numberOfButtons, string title, string iconName,
|
||||
string message, string button1Text,
|
||||
string button2Text, bool showGauge, bool showCancel, Action<uint> completeAction)
|
||||
{
|
||||
@@ -151,15 +151,15 @@ namespace PepperDash.Essentials.Core
|
||||
TriList.StringInput[Button2TextJoin].StringValue = button2Text;
|
||||
}
|
||||
// Show/hide guage
|
||||
TriList.BooleanInput[TimerVisibleJoin].BoolValue = showGauge;
|
||||
|
||||
CanCancel = showCancel;
|
||||
TriList.BooleanInput[CancelVisibleJoin].BoolValue = showCancel;
|
||||
TriList.BooleanInput[TimerVisibleJoin].BoolValue = showGauge;
|
||||
|
||||
CanCancel = showCancel;
|
||||
TriList.BooleanInput[CancelVisibleJoin].BoolValue = showCancel;
|
||||
|
||||
//Reveal and activate
|
||||
TriList.BooleanInput[ModalVisibleJoin].BoolValue = true;
|
||||
|
||||
WakePanel();
|
||||
WakePanel();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -167,48 +167,48 @@ namespace PepperDash.Essentials.Core
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// WakePanel method
|
||||
/// </summary>
|
||||
public void WakePanel()
|
||||
{
|
||||
try
|
||||
{
|
||||
var panel = TriList as TswFt5Button;
|
||||
|
||||
if (panel != null && panel.ExtenderSystemReservedSigs.BacklightOffFeedback.BoolValue)
|
||||
panel.ExtenderSystemReservedSigs.BacklightOn();
|
||||
}
|
||||
catch
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, "Error Waking Panel. Maybe testing with Xpanel?");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// CancelDialog method
|
||||
/// </summary>
|
||||
public void CancelDialog()
|
||||
/// <summary>
|
||||
/// WakePanel method
|
||||
/// </summary>
|
||||
public void WakePanel()
|
||||
{
|
||||
OnModalComplete(0);
|
||||
try
|
||||
{
|
||||
var panel = TriList as TswFt5Button;
|
||||
|
||||
if (panel != null && panel.ExtenderSystemReservedSigs.BacklightOffFeedback.BoolValue)
|
||||
panel.ExtenderSystemReservedSigs.BacklightOn();
|
||||
}
|
||||
catch
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, "Error Waking Panel. Maybe testing with Xpanel?");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hides dialog. Fires no action
|
||||
/// </summary>
|
||||
public void HideDialog()
|
||||
{
|
||||
TriList.BooleanInput[ModalVisibleJoin].BoolValue = false;
|
||||
}
|
||||
/// <summary>
|
||||
/// CancelDialog method
|
||||
/// </summary>
|
||||
public void CancelDialog()
|
||||
{
|
||||
OnModalComplete(0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hides dialog. Fires no action
|
||||
/// </summary>
|
||||
public void HideDialog()
|
||||
{
|
||||
TriList.BooleanInput[ModalVisibleJoin].BoolValue = false;
|
||||
}
|
||||
|
||||
// When the modal is cleared or times out, clean up the various bits
|
||||
void OnModalComplete(uint buttonNum)
|
||||
{
|
||||
TriList.BooleanInput[ModalVisibleJoin].BoolValue = false;
|
||||
|
||||
var action = ModalCompleteAction;
|
||||
if (action != null)
|
||||
action(buttonNum);
|
||||
var action = ModalCompleteAction;
|
||||
if (action != null)
|
||||
action(buttonNum);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
using Newtonsoft.Json;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Core.Logging;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Bridges;
|
||||
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
|
||||
@@ -52,9 +53,9 @@ namespace PepperDash.Essentials.Devices.Common.Displays
|
||||
/// </summary>
|
||||
public event SourceInfoChangeHandler CurrentSourceChange;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the CurrentSourceInfoKey
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the CurrentSourceInfoKey
|
||||
/// </summary>
|
||||
public string CurrentSourceInfoKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -89,29 +90,32 @@ namespace PepperDash.Essentials.Devices.Common.Displays
|
||||
/// <inheritdoc/>
|
||||
public Dictionary<eRoutingSignalType, string> CurrentSourceKeys { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public event EventHandler CurrentSourcesChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Gets feedback indicating whether the display is currently cooling down after being powered off.
|
||||
/// </summary>
|
||||
public BoolFeedback IsCoolingDownFeedback { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the IsWarmingUpFeedback
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the IsWarmingUpFeedback
|
||||
/// </summary>
|
||||
public BoolFeedback IsWarmingUpFeedback { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the UsageTracker
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the UsageTracker
|
||||
/// </summary>
|
||||
public UsageTracking UsageTracker { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the WarmupTime
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the WarmupTime
|
||||
/// </summary>
|
||||
public uint WarmupTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the CooldownTime
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the CooldownTime
|
||||
/// </summary>
|
||||
public uint CooldownTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -189,7 +193,7 @@ namespace PepperDash.Essentials.Devices.Common.Displays
|
||||
/// <summary>
|
||||
/// Gets the collection of feedback objects for this display device.
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
/// <inheritdoc />
|
||||
public virtual FeedbackCollection<Feedback> Feedbacks
|
||||
{
|
||||
get
|
||||
@@ -378,6 +382,53 @@ namespace PepperDash.Essentials.Devices.Common.Displays
|
||||
volumeDisplayWithFeedback.MuteFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.VolumeMuteOff.JoinNumber]);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual void SetCurrentSource(eRoutingSignalType signalType, string sourceListKey, SourceListItem sourceListItem)
|
||||
{
|
||||
foreach (eRoutingSignalType type in Enum.GetValues(typeof(eRoutingSignalType)))
|
||||
{
|
||||
var flagValue = Convert.ToInt32(type);
|
||||
// Skip if flagValue is 0 or not a power of two (i.e., not a single-bit flag).
|
||||
// (flagValue & (flagValue - 1)) != 0 checks if more than one bit is set.
|
||||
if (flagValue == 0 || (flagValue & (flagValue - 1)) != 0)
|
||||
{
|
||||
this.LogDebug("Skipping {type}", type);
|
||||
continue;
|
||||
}
|
||||
|
||||
this.LogDebug("setting {type}", type);
|
||||
|
||||
if (signalType.HasFlag(type))
|
||||
{
|
||||
UpdateCurrentSources(type, sourceListKey, sourceListItem);
|
||||
}
|
||||
}
|
||||
// Raise the CurrentSourcesChanged event
|
||||
CurrentSourcesChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
private void UpdateCurrentSources(eRoutingSignalType signalType, string sourceListKey, SourceListItem sourceListItem)
|
||||
{
|
||||
if (CurrentSources.ContainsKey(signalType))
|
||||
{
|
||||
CurrentSources[signalType] = sourceListItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentSources.Add(signalType, sourceListItem);
|
||||
}
|
||||
|
||||
// Update the current source key for the specified signal type
|
||||
if (CurrentSourceKeys.ContainsKey(signalType))
|
||||
{
|
||||
CurrentSourceKeys[signalType] = sourceListKey;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentSourceKeys.Add(signalType, sourceListKey);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -140,17 +140,19 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
||||
|
||||
if (Camera is IHasCameraPresets presetsCamera)
|
||||
{
|
||||
for (int i = 1; i <= 6; i++)
|
||||
AddAction("/recallPreset", (id, content) =>
|
||||
{
|
||||
var preset = i;
|
||||
AddAction("/cameraPreset" + i, (id, content) =>
|
||||
{
|
||||
var msg = content.ToObject<MobileControlSimpleContent<int>>();
|
||||
var msg = content.ToObject<MobileControlSimpleContent<int>>();
|
||||
|
||||
presetsCamera.PresetSelect(msg.Value);
|
||||
});
|
||||
presetsCamera.PresetSelect(msg.Value);
|
||||
});
|
||||
|
||||
}
|
||||
AddAction("/storePreset", (id, content) =>
|
||||
{
|
||||
var msg = content.ToObject<MobileControlSimpleContent<int>>();
|
||||
|
||||
presetsCamera.PresetStore(msg.Value, string.Empty);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,9 +166,8 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
||||
return;
|
||||
}
|
||||
|
||||
timerHandler(state.Value, cameraAction);
|
||||
timerHandler(Camera.Key, cameraAction);
|
||||
|
||||
cameraAction(state.Value.Equals("true", StringComparison.InvariantCultureIgnoreCase));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Routing;
|
||||
|
||||
namespace PepperDash.Essentials.AppServer.Messengers
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a IHasCurrentSourceInfoMessenger
|
||||
/// </summary>
|
||||
public class CurrentSourcesMessenger : MessengerBase
|
||||
{
|
||||
private readonly ICurrentSources sourceDevice;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CurrentSourcesMessenger"/> class.
|
||||
/// </summary>
|
||||
/// <param name="key">The key.</param>
|
||||
/// <param name="messagePath">The message path.</param>
|
||||
/// <param name="device">The device.</param>
|
||||
public CurrentSourcesMessenger(string key, string messagePath, ICurrentSources device) : base(key, messagePath, device as IKeyName)
|
||||
{
|
||||
sourceDevice = device;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers the actions for the messenger.
|
||||
/// </summary>
|
||||
protected override void RegisterActions()
|
||||
{
|
||||
base.RegisterActions();
|
||||
|
||||
AddAction("/fullStatus", (id, content) =>
|
||||
{
|
||||
var message = new CurrentSourcesStateMessage
|
||||
{
|
||||
CurrentSourceKeys = sourceDevice.CurrentSourceKeys,
|
||||
CurrentSources = sourceDevice.CurrentSources
|
||||
};
|
||||
|
||||
PostStatusMessage(message);
|
||||
});
|
||||
|
||||
sourceDevice.CurrentSourcesChanged += (sender, e) =>
|
||||
{
|
||||
PostStatusMessage(JToken.FromObject(new
|
||||
{
|
||||
currentSourceKeys = sourceDevice.CurrentSourceKeys,
|
||||
currentSources = sourceDevice.CurrentSources
|
||||
}));
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a CurrentSourcesStateMessage
|
||||
/// </summary>
|
||||
public class CurrentSourcesStateMessage : DeviceStateMessageBase
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the CurrentSourceKey
|
||||
/// </summary>
|
||||
[JsonProperty("currentSourceKeys", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public Dictionary<eRoutingSignalType, string> CurrentSourceKeys { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the CurrentSource
|
||||
/// </summary>
|
||||
[JsonProperty("currentSources")]
|
||||
public Dictionary<eRoutingSignalType, SourceListItem> CurrentSources { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace PepperDash.Essentials.AppServer.Messengers
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a IBasicVideoMuteWithFeedbackMessenger
|
||||
/// </summary>
|
||||
public class IBasicVideoMuteWithFeedbackMessenger : MessengerBase
|
||||
{
|
||||
private readonly IBasicVideoMuteWithFeedback device;
|
||||
|
||||
public IBasicVideoMuteWithFeedbackMessenger(string key, string messagePath, IBasicVideoMuteWithFeedback device)
|
||||
: base(key, messagePath, device as IKeyName)
|
||||
{
|
||||
this.device = device;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SendFullStatus method
|
||||
/// </summary>
|
||||
public void SendFullStatus()
|
||||
{
|
||||
var messageObj = new IBasicVideoMuteWithFeedbackMessage
|
||||
{
|
||||
VideoMuteState = device.VideoMuteIsOn.BoolValue
|
||||
};
|
||||
|
||||
PostStatusMessage(messageObj);
|
||||
}
|
||||
|
||||
protected override void RegisterActions()
|
||||
{
|
||||
base.RegisterActions();
|
||||
|
||||
AddAction("/fullStatus", (id, content) => SendFullStatus());
|
||||
|
||||
AddAction("/videoMuteToggle", (id, content) =>
|
||||
{
|
||||
device.VideoMuteToggle();
|
||||
});
|
||||
|
||||
AddAction("/videoMuteOn", (id, content) =>
|
||||
{
|
||||
device.VideoMuteOn();
|
||||
});
|
||||
|
||||
AddAction("/videoMuteOff", (id, content) =>
|
||||
{
|
||||
device.VideoMuteOff();
|
||||
});
|
||||
|
||||
device.VideoMuteIsOn.OutputChange += VideoMuteIsOnFeedback_OutputChange;
|
||||
}
|
||||
|
||||
private void VideoMuteIsOnFeedback_OutputChange(object sender, FeedbackEventArgs args)
|
||||
{
|
||||
PostStatusMessage(JToken.FromObject(new
|
||||
{
|
||||
videoMuteState = args.BoolValue
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a IBasicVideoMuteWithFeedbackMessage
|
||||
/// </summary>
|
||||
public class IBasicVideoMuteWithFeedbackMessage : DeviceStateMessageBase
|
||||
{
|
||||
[JsonProperty("videoMuteState")]
|
||||
public bool VideoMuteState { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -54,16 +54,18 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
||||
/// </summary>
|
||||
public class CurrentSourceStateMessage : DeviceStateMessageBase
|
||||
{
|
||||
[JsonProperty("currentSourceKey", NullValueHandling = NullValueHandling.Ignore)]
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the CurrentSourceKey
|
||||
/// </summary>
|
||||
[JsonProperty("currentSourceKey", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public string CurrentSourceKey { get; set; }
|
||||
|
||||
[JsonProperty("currentSource")]
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the CurrentSource
|
||||
/// </summary>
|
||||
[JsonProperty("currentSource")]
|
||||
public SourceListItem CurrentSource { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace PepperDash.Essentials
|
||||
{
|
||||
@@ -9,25 +9,34 @@ namespace PepperDash.Essentials
|
||||
/// </summary>
|
||||
public class MobileControlConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the ServerUrl
|
||||
/// </summary>
|
||||
[JsonProperty("serverUrl")]
|
||||
public string ServerUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ClientAppUrl
|
||||
/// </summary>
|
||||
[JsonProperty("clientAppUrl")]
|
||||
public string ClientAppUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the DirectServer
|
||||
/// </summary>
|
||||
[JsonProperty("directServer")]
|
||||
public MobileControlDirectServerPropertiesConfig DirectServer { get; set; }
|
||||
|
||||
[JsonProperty("applicationConfig")]
|
||||
/// <summary>
|
||||
/// Gets or sets the ApplicationConfig
|
||||
/// </summary>
|
||||
[JsonProperty("applicationConfig")]
|
||||
public MobileControlApplicationConfig ApplicationConfig { get; set; } = null;
|
||||
|
||||
[JsonProperty("enableApiServer")]
|
||||
/// <summary>
|
||||
/// Gets or sets the EnableApiServer
|
||||
/// </summary>
|
||||
[JsonProperty("enableApiServer")]
|
||||
public bool EnableApiServer { get; set; } = true;
|
||||
}
|
||||
|
||||
@@ -36,27 +45,42 @@ namespace PepperDash.Essentials
|
||||
/// </summary>
|
||||
public class MobileControlDirectServerPropertiesConfig
|
||||
{
|
||||
[JsonProperty("enableDirectServer")]
|
||||
/// <summary>
|
||||
/// Gets or sets the EnableDirectServer
|
||||
/// </summary>
|
||||
[JsonProperty("enableDirectServer")]
|
||||
public bool EnableDirectServer { get; set; }
|
||||
|
||||
[JsonProperty("port")]
|
||||
/// <summary>
|
||||
/// Gets or sets the Port
|
||||
/// </summary>
|
||||
[JsonProperty("port")]
|
||||
public int Port { get; set; }
|
||||
|
||||
[JsonProperty("logging")]
|
||||
/// <summary>
|
||||
/// Gets or sets the Logging
|
||||
/// </summary>
|
||||
[JsonProperty("logging")]
|
||||
public MobileControlLoggingConfig Logging { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the AutomaticallyForwardPortToCSLAN
|
||||
/// </summary>
|
||||
[JsonProperty("automaticallyForwardPortToCSLAN")]
|
||||
public bool? AutomaticallyForwardPortToCSLAN { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the CSLanUiDeviceKeys
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A list of device keys for the CS LAN UI. These devices will get the CS LAN IP address instead of the LAN IP Address
|
||||
/// </remarks>
|
||||
[JsonProperty("csLanUiDeviceKeys")]
|
||||
public List<string> CSLanUiDeviceKeys { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the MobileControlDirectServerPropertiesConfig class.
|
||||
/// </summary>
|
||||
public MobileControlDirectServerPropertiesConfig()
|
||||
{
|
||||
Logging = new MobileControlLoggingConfig();
|
||||
@@ -68,26 +92,26 @@ namespace PepperDash.Essentials
|
||||
/// </summary>
|
||||
public class MobileControlLoggingConfig
|
||||
{
|
||||
[JsonProperty("enableRemoteLogging")]
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the EnableRemoteLogging
|
||||
/// </summary>
|
||||
[JsonProperty("enableRemoteLogging")]
|
||||
public bool EnableRemoteLogging { get; set; }
|
||||
|
||||
[JsonProperty("host")]
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Host
|
||||
/// </summary>
|
||||
[JsonProperty("host")]
|
||||
public string Host { get; set; }
|
||||
|
||||
[JsonProperty("port")]
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Port
|
||||
/// </summary>
|
||||
[JsonProperty("port")]
|
||||
public int Port { get; set; }
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -95,16 +119,16 @@ namespace PepperDash.Essentials
|
||||
/// </summary>
|
||||
public class MobileControlRoomBridgePropertiesConfig
|
||||
{
|
||||
[JsonProperty("key")]
|
||||
/// <summary>
|
||||
/// Gets or sets the Key
|
||||
/// </summary>
|
||||
[JsonProperty("key")]
|
||||
public string Key { get; set; }
|
||||
|
||||
[JsonProperty("roomKey")]
|
||||
/// <summary>
|
||||
/// Gets or sets the RoomKey
|
||||
/// </summary>
|
||||
[JsonProperty("roomKey")]
|
||||
public string RoomKey { get; set; }
|
||||
}
|
||||
|
||||
@@ -113,53 +137,71 @@ namespace PepperDash.Essentials
|
||||
/// </summary>
|
||||
public class MobileControlSimplRoomBridgePropertiesConfig
|
||||
{
|
||||
[JsonProperty("eiscId")]
|
||||
/// <summary>
|
||||
/// Gets or sets the EiscId
|
||||
/// </summary>
|
||||
[JsonProperty("eiscId")]
|
||||
public string EiscId { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a MobileControlApplicationConfig
|
||||
/// </summary>
|
||||
public class MobileControlApplicationConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the ApiPath
|
||||
/// </summary>
|
||||
[JsonProperty("apiPath")]
|
||||
public string ApiPath { get; set; }
|
||||
|
||||
[JsonProperty("gatewayAppPath")]
|
||||
/// <summary>
|
||||
/// Gets or sets the GatewayAppPath
|
||||
/// </summary>
|
||||
[JsonProperty("gatewayAppPath")]
|
||||
public string GatewayAppPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the EnableDev
|
||||
/// </summary>
|
||||
[JsonProperty("enableDev")]
|
||||
public bool? EnableDev { get; set; }
|
||||
|
||||
[JsonProperty("logoPath")]
|
||||
/// <summary>
|
||||
/// Gets or sets the LogoPath
|
||||
/// </summary>
|
||||
[JsonProperty("logoPath")]
|
||||
public string LogoPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the IconSet
|
||||
/// </summary>
|
||||
[JsonProperty("iconSet")]
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public MCIconSet? IconSet { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the LoginMode
|
||||
/// </summary>
|
||||
[JsonProperty("loginMode")]
|
||||
public string LoginMode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Modes
|
||||
/// </summary>
|
||||
[JsonProperty("modes")]
|
||||
public Dictionary<string, McMode> Modes { get; set; }
|
||||
|
||||
[JsonProperty("enableRemoteLogging")]
|
||||
/// <summary>
|
||||
/// Gets or sets the Logging
|
||||
/// </summary>
|
||||
[JsonProperty("enableRemoteLogging")]
|
||||
public bool Logging { get; set; }
|
||||
|
||||
[JsonProperty("partnerMetadata", NullValueHandling = NullValueHandling.Ignore)]
|
||||
/// <summary>
|
||||
/// Gets or sets the PartnerMetadata
|
||||
/// </summary>
|
||||
[JsonProperty("partnerMetadata", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public List<MobileControlPartnerMetadata> PartnerMetadata { get; set; }
|
||||
}
|
||||
|
||||
@@ -168,22 +210,22 @@ namespace PepperDash.Essentials
|
||||
/// </summary>
|
||||
public class MobileControlPartnerMetadata
|
||||
{
|
||||
[JsonProperty("role")]
|
||||
/// <summary>
|
||||
/// Gets or sets the Role
|
||||
/// </summary>
|
||||
[JsonProperty("role")]
|
||||
public string Role { get; set; }
|
||||
|
||||
[JsonProperty("description")]
|
||||
/// <summary>
|
||||
/// Gets or sets the Description
|
||||
/// </summary>
|
||||
[JsonProperty("description")]
|
||||
public string Description { get; set; }
|
||||
|
||||
[JsonProperty("logoPath")]
|
||||
/// <summary>
|
||||
/// Gets or sets the LogoPath
|
||||
/// </summary>
|
||||
[JsonProperty("logoPath")]
|
||||
public string LogoPath { get; set; }
|
||||
}
|
||||
|
||||
@@ -192,21 +234,22 @@ namespace PepperDash.Essentials
|
||||
/// </summary>
|
||||
public class McMode
|
||||
{
|
||||
[JsonProperty("listPageText")]
|
||||
/// <summary>
|
||||
/// Gets or sets the ListPageText
|
||||
/// </summary>
|
||||
[JsonProperty("listPageText")]
|
||||
public string ListPageText { get; set; }
|
||||
[JsonProperty("loginHelpText")]
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the LoginHelpText
|
||||
/// </summary>
|
||||
[JsonProperty("loginHelpText")]
|
||||
public string LoginHelpText { get; set; }
|
||||
|
||||
[JsonProperty("passcodePageText")]
|
||||
/// <summary>
|
||||
/// Gets or sets the PasscodePageText
|
||||
/// </summary>
|
||||
[JsonProperty("passcodePageText")]
|
||||
public string PasscodePageText { get; set; }
|
||||
}
|
||||
|
||||
@@ -215,8 +258,19 @@ namespace PepperDash.Essentials
|
||||
/// </summary>
|
||||
public enum MCIconSet
|
||||
{
|
||||
/// <summary>
|
||||
/// Google icon set
|
||||
/// </summary>
|
||||
GOOGLE,
|
||||
|
||||
/// <summary>
|
||||
/// Habanero icon set
|
||||
/// </summary>
|
||||
HABANERO,
|
||||
|
||||
/// <summary>
|
||||
/// Neo icon set
|
||||
/// </summary>
|
||||
NEO
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,10 @@
|
||||
using Crestron.SimplSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharp.CrestronIO;
|
||||
using Crestron.SimplSharp.Net.Http;
|
||||
using Crestron.SimplSharp.WebScripting;
|
||||
@@ -30,12 +36,6 @@ using PepperDash.Essentials.RoomBridges;
|
||||
using PepperDash.Essentials.Services;
|
||||
using PepperDash.Essentials.WebApiHandlers;
|
||||
using PepperDash.Essentials.WebSocketServer;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using WebSocketSharp;
|
||||
|
||||
namespace PepperDash.Essentials
|
||||
@@ -505,6 +505,25 @@ namespace PepperDash.Essentials
|
||||
messengerAdded = true;
|
||||
}
|
||||
|
||||
if (device is IBasicVideoMuteWithFeedback)
|
||||
{
|
||||
var deviceKey = device.Key;
|
||||
this.LogVerbose(
|
||||
"Adding IBasicVideoMuteWithFeedback for {deviceKey}",
|
||||
deviceKey
|
||||
);
|
||||
|
||||
var videoMuteControlDevice = device as IBasicVideoMuteWithFeedback;
|
||||
var messenger = new IBasicVideoMuteWithFeedbackMessenger(
|
||||
$"{device.Key}-videoMute-{Key}",
|
||||
string.Format("/device/{0}", deviceKey),
|
||||
videoMuteControlDevice
|
||||
);
|
||||
AddDefaultDeviceMessenger(messenger);
|
||||
|
||||
messengerAdded = true;
|
||||
}
|
||||
|
||||
if (device is ILightingScenes || device is LightingBase)
|
||||
{
|
||||
var deviceKey = device.Key;
|
||||
@@ -582,7 +601,7 @@ namespace PepperDash.Essentials
|
||||
{
|
||||
this.LogVerbose(
|
||||
"Adding ISetTopBoxControlMessenger for {deviceKey}"
|
||||
);
|
||||
);
|
||||
|
||||
var messenger = new ISetTopBoxControlsMessenger(
|
||||
$"{device.Key}-stb-{Key}",
|
||||
@@ -599,7 +618,7 @@ namespace PepperDash.Essentials
|
||||
{
|
||||
this.LogVerbose(
|
||||
"Adding IChannelMessenger for {deviceKey}", device.Key
|
||||
);
|
||||
);
|
||||
|
||||
var messenger = new IChannelMessenger(
|
||||
$"{device.Key}-channel-{Key}",
|
||||
@@ -614,7 +633,7 @@ namespace PepperDash.Essentials
|
||||
|
||||
if (device is IColor colorDevice)
|
||||
{
|
||||
this.LogVerbose("Adding IColorMessenger for {deviceKey}", device.Key);
|
||||
this.LogVerbose("Adding IColorMessenger for {deviceKey}", device.Key);
|
||||
|
||||
var messenger = new IColorMessenger(
|
||||
$"{device.Key}-color-{Key}",
|
||||
@@ -629,7 +648,7 @@ namespace PepperDash.Essentials
|
||||
|
||||
if (device is IDPad dPadDevice)
|
||||
{
|
||||
this.LogVerbose("Adding IDPadMessenger for {deviceKey}", device.Key);
|
||||
this.LogVerbose("Adding IDPadMessenger for {deviceKey}", device.Key);
|
||||
|
||||
var messenger = new IDPadMessenger(
|
||||
$"{device.Key}-dPad-{Key}",
|
||||
@@ -644,7 +663,7 @@ namespace PepperDash.Essentials
|
||||
|
||||
if (device is INumericKeypad nkDevice)
|
||||
{
|
||||
this.LogVerbose("Adding INumericKeyapdMessenger for {deviceKey}", device.Key);
|
||||
this.LogVerbose("Adding INumericKeyapdMessenger for {deviceKey}", device.Key);
|
||||
|
||||
var messenger = new INumericKeypadMessenger(
|
||||
$"{device.Key}-numericKeypad-{Key}",
|
||||
@@ -659,7 +678,7 @@ namespace PepperDash.Essentials
|
||||
|
||||
if (device is IHasPowerControl pcDevice)
|
||||
{
|
||||
this.LogVerbose("Adding IHasPowerControlMessenger for {deviceKey}", device.Key);
|
||||
this.LogVerbose("Adding IHasPowerControlMessenger for {deviceKey}", device.Key);
|
||||
|
||||
var messenger = new IHasPowerMessenger(
|
||||
$"{device.Key}-powerControl-{Key}",
|
||||
@@ -693,7 +712,7 @@ namespace PepperDash.Essentials
|
||||
{
|
||||
this.LogVerbose(
|
||||
"Adding ITransportMessenger for {deviceKey}", device.Key
|
||||
);
|
||||
);
|
||||
|
||||
var messenger = new ITransportMessenger(
|
||||
$"{device.Key}-transport-{Key}",
|
||||
@@ -721,6 +740,17 @@ namespace PepperDash.Essentials
|
||||
messengerAdded = true;
|
||||
}
|
||||
|
||||
if (device is ICurrentSources currentSources)
|
||||
{
|
||||
this.LogVerbose("Adding CurrentSourcesMessenger for {deviceKey}", device.Key);
|
||||
|
||||
var messenger = new CurrentSourcesMessenger($"{device.Key}-currentSources-{Key}", $"/device/{device.Key}", currentSources);
|
||||
|
||||
AddDefaultDeviceMessenger(messenger);
|
||||
|
||||
messengerAdded = true;
|
||||
}
|
||||
|
||||
if (device is ISwitchedOutput switchedDevice)
|
||||
{
|
||||
this.LogVerbose(
|
||||
@@ -1625,15 +1655,14 @@ namespace PepperDash.Essentials
|
||||
if (Config.EnableApiServer)
|
||||
{
|
||||
CrestronConsole.ConsoleCommandResponse(
|
||||
@"Mobile Control Edge Server API Information:
|
||||
|
||||
Server address: {0}
|
||||
System Name: {1}
|
||||
System URL: {2}
|
||||
System UUID: {3}
|
||||
System User code: {4}
|
||||
Connected?: {5}
|
||||
Seconds Since Last Ack: {6}",
|
||||
"Mobile Control Edge Server API Information:\r\n\r\n" +
|
||||
"\tServer address: {0}\r\n" +
|
||||
"\tSystem Name: {1}\r\n" +
|
||||
"\tSystem URL: {2}\r\n" +
|
||||
"\tSystem UUID: {3}\r\n" +
|
||||
"\tSystem User code: {4}\r\n" +
|
||||
"\tConnected?: {5}\r\n" +
|
||||
"\tSeconds Since Last Ack: {6}\r\n",
|
||||
url,
|
||||
name,
|
||||
ConfigReader.ConfigObject.SystemUrl,
|
||||
@@ -1646,10 +1675,8 @@ namespace PepperDash.Essentials
|
||||
else
|
||||
{
|
||||
CrestronConsole.ConsoleCommandResponse(
|
||||
@"
|
||||
Mobile Control Edge Server API Information:
|
||||
Not Enabled in Config.
|
||||
"
|
||||
"\r\nMobile Control Edge Server API Information:\r\n" +
|
||||
" Not Enabled in Config.\r\n"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1660,21 +1687,17 @@ Mobile Control Edge Server API Information:
|
||||
)
|
||||
{
|
||||
CrestronConsole.ConsoleCommandResponse(
|
||||
@"
|
||||
Mobile Control Direct Server Information:
|
||||
User App URL: {0}
|
||||
Server port: {1}
|
||||
",
|
||||
"\r\nMobile Control Direct Server Information:\r\n" +
|
||||
" User App URL: {0}\r\n" +
|
||||
" Server port: {1}\r\n",
|
||||
string.Format("{0}[insert_client_token]", _directServer.UserAppUrlPrefix),
|
||||
_directServer.Port
|
||||
);
|
||||
|
||||
CrestronConsole.ConsoleCommandResponse(
|
||||
@"
|
||||
UI Client Info:
|
||||
Tokens Defined: {0}
|
||||
Clients Connected: {1}
|
||||
",
|
||||
"\r\n UI Client Info:\r\n" +
|
||||
" Tokens Defined: {0}\r\n" +
|
||||
" Clients Connected: {1}\r\n",
|
||||
_directServer.UiClients.Count,
|
||||
_directServer.ConnectedUiClientsCount
|
||||
);
|
||||
@@ -1692,15 +1715,13 @@ Mobile Control Direct Server Information:
|
||||
}
|
||||
|
||||
CrestronConsole.ConsoleCommandResponse(
|
||||
@"
|
||||
Client {0}:
|
||||
Room Key: {1}
|
||||
Touchpanel Key: {6}
|
||||
Token: {2}
|
||||
Client URL: {3}
|
||||
Connected: {4}
|
||||
Duration: {5}
|
||||
",
|
||||
"\r\nClient {0}:\r\n" +
|
||||
"Room Key: {1}\r\n" +
|
||||
"Touchpanel Key: {6}\r\n" +
|
||||
"Token: {2}\r\n" +
|
||||
"Client URL: {3}\r\n" +
|
||||
"Connected: {4}\r\n" +
|
||||
"Duration: {5}\r\n",
|
||||
clientNo,
|
||||
clientContext.Value.Token.RoomKey,
|
||||
clientContext.Key,
|
||||
@@ -1715,9 +1736,8 @@ Duration: {5}
|
||||
else
|
||||
{
|
||||
CrestronConsole.ConsoleCommandResponse(
|
||||
@"
|
||||
Mobile Control Direct Server Infromation:
|
||||
Not Enabled in Config."
|
||||
"\r\nMobile Control Direct Server Information:\r\n" +
|
||||
" Not Enabled in Config.\r\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2309,7 +2329,7 @@ Mobile Control Direct Server Infromation:
|
||||
{
|
||||
this.LogInformation("-- Warning: Incoming message has no registered handler {type}", message.Type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var handler in handlers)
|
||||
{
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
using Crestron.SimplSharpPro.UI;
|
||||
@@ -14,6 +16,7 @@ using PepperDash.Essentials.Core.Config;
|
||||
using PepperDash.Essentials.Core.DeviceInfo;
|
||||
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
|
||||
using PepperDash.Essentials.Core.UI;
|
||||
using Serilog.Events;
|
||||
using Feedback = PepperDash.Essentials.Core.Feedback;
|
||||
|
||||
namespace PepperDash.Essentials.Touchpanel
|
||||
@@ -106,6 +109,11 @@ namespace PepperDash.Essentials.Touchpanel
|
||||
|
||||
public ReadOnlyCollection<ConnectedIpInformation> ConnectedIps => Panel.ConnectedIpList;
|
||||
|
||||
private System.Net.IPAddress csIpAddress;
|
||||
|
||||
private System.Net.IPAddress csSubnetMask;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the MobileControlTouchpanelController class.
|
||||
/// </summary>
|
||||
@@ -182,6 +190,28 @@ namespace PepperDash.Essentials.Touchpanel
|
||||
};
|
||||
|
||||
RegisterForExtenders();
|
||||
|
||||
try
|
||||
{
|
||||
var csAdapterId = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(EthernetAdapterType.EthernetCSAdapter);
|
||||
var csSubnetMask = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, csAdapterId);
|
||||
var csIpAddress = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, csAdapterId);
|
||||
|
||||
this.csSubnetMask = System.Net.IPAddress.Parse(csSubnetMask);
|
||||
this.csIpAddress = System.Net.IPAddress.Parse(csIpAddress);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
Debug.LogInformation("This processor does not have a CS LAN", this);
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
Debug.LogInformation("This processor does not have a CS LAN", this);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError($"Unexpected exception when checking CS LAN: {ex}", this);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -381,19 +411,81 @@ namespace PepperDash.Essentials.Touchpanel
|
||||
McServerUrlFeedback.LinkInputSig(Panel.StringInput[3]);
|
||||
UserCodeFeedback.LinkInputSig(Panel.StringInput[4]);
|
||||
|
||||
Panel.IpInformationChange += (sender, args) =>
|
||||
{
|
||||
if (args.Connected)
|
||||
{
|
||||
this.LogVerbose("Connection from IP: {ip}", args.DeviceIpAddress);
|
||||
this.LogInformation("Sending {appUrl} on join 1", AppUrlFeedback.StringValue);
|
||||
|
||||
var appUrl = GetUrlWithCorrectIp(_appUrl);
|
||||
Panel.StringInput[1].StringValue = appUrl;
|
||||
|
||||
SetAppUrl(appUrl);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.LogVerbose("Disconnection from IP: {ip}", args.DeviceIpAddress);
|
||||
}
|
||||
};
|
||||
|
||||
Panel.OnlineStatusChange += (sender, args) =>
|
||||
{
|
||||
UpdateFeedbacks();
|
||||
|
||||
this.LogInformation("Sending {appUrl} on join 1", AppUrlFeedback.StringValue);
|
||||
|
||||
Panel.StringInput[1].StringValue = AppUrlFeedback.StringValue;
|
||||
UpdateFeedbacks();
|
||||
Panel.StringInput[1].StringValue = _appUrl;
|
||||
Panel.StringInput[2].StringValue = QrCodeUrlFeedback.StringValue;
|
||||
Panel.StringInput[3].StringValue = McServerUrlFeedback.StringValue;
|
||||
Panel.StringInput[4].StringValue = UserCodeFeedback.StringValue;
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the URL with the correct IP address based on the connected devices and the Crestron processor's IP address.
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <returns></returns>
|
||||
private string GetUrlWithCorrectIp(string url)
|
||||
{
|
||||
var lanAdapterId = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(EthernetAdapterType.EthernetLANAdapter);
|
||||
|
||||
var processorIp = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, lanAdapterId);
|
||||
|
||||
if(csIpAddress == null || csSubnetMask == null || url == null)
|
||||
{
|
||||
this.LogWarning("CS IP Address Subnet Mask or url is null, cannot determine correct IP for URL");
|
||||
return url;
|
||||
}
|
||||
|
||||
this.LogVerbose("Processor IP: {processorIp}, CS IP: {csIpAddress}, CS Subnet Mask: {csSubnetMask}", processorIp, csIpAddress, csSubnetMask);
|
||||
this.LogVerbose("Connected IP Count: {connectedIps}", ConnectedIps.Count);
|
||||
|
||||
var ip = ConnectedIps.Any(ipInfo =>
|
||||
{
|
||||
if (System.Net.IPAddress.TryParse(ipInfo.DeviceIpAddress, out var parsedIp))
|
||||
{
|
||||
return csIpAddress.IsInSameSubnet(parsedIp, csSubnetMask);
|
||||
}
|
||||
this.LogWarning("Invalid IP address: {deviceIpAddress}", ipInfo.DeviceIpAddress);
|
||||
return false;
|
||||
}) ? csIpAddress.ToString() : processorIp;
|
||||
|
||||
var match = Regex.Match(url, @"^http://([^:/]+):\d+/mc/app\?token=.+$");
|
||||
if (match.Success)
|
||||
{
|
||||
string ipa = match.Groups[1].Value;
|
||||
// ip will be "192.168.1.100"
|
||||
}
|
||||
|
||||
// replace ipa with ip but leave the rest of the string intact
|
||||
var updatedUrl = Regex.Replace(url, @"^http://[^:/]+", $"http://{ip}");
|
||||
|
||||
this.LogVerbose("Updated URL: {updatedUrl}", updatedUrl);
|
||||
|
||||
return updatedUrl;
|
||||
}
|
||||
|
||||
private void SubscribeForMobileControlUpdates()
|
||||
{
|
||||
foreach (var dev in DeviceManager.AllDevices)
|
||||
@@ -426,7 +518,7 @@ namespace PepperDash.Essentials.Touchpanel
|
||||
_bridge.UserCodeChanged += UpdateFeedbacks;
|
||||
_bridge.AppUrlChanged += (s, a) =>
|
||||
{
|
||||
this.LogInformation("AppURL changed");
|
||||
this.LogInformation("AppURL changed: {appURL}", _bridge.AppUrl);
|
||||
SetAppUrl(_bridge.AppUrl);
|
||||
UpdateFeedbacks(s, a);
|
||||
};
|
||||
@@ -443,7 +535,8 @@ namespace PepperDash.Essentials.Touchpanel
|
||||
/// </summary>
|
||||
public void SetAppUrl(string url)
|
||||
{
|
||||
_appUrl = url;
|
||||
_appUrl = GetUrlWithCorrectIp(url);
|
||||
|
||||
AppUrlFeedback.FireUpdate();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
@@ -41,8 +42,14 @@ namespace PepperDash.Essentials.WebSocketServer
|
||||
|
||||
private HttpServer _server;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the HttpServer instance
|
||||
/// </summary>
|
||||
public HttpServer Server => _server;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of UI client contexts
|
||||
/// </summary>
|
||||
public Dictionary<string, UiClientContext> UiClients { get; private set; }
|
||||
|
||||
private readonly MobileControlSystemController _parent;
|
||||
@@ -61,17 +68,20 @@ namespace PepperDash.Essentials.WebSocketServer
|
||||
}
|
||||
}
|
||||
|
||||
private string lanIpAddress => CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(EthernetAdapterType.EthernetLANAdapter));
|
||||
private string LanIpAddress => CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(EthernetAdapterType.EthernetLANAdapter));
|
||||
|
||||
private System.Net.IPAddress csIpAddress;
|
||||
private readonly System.Net.IPAddress csIpAddress;
|
||||
|
||||
private System.Net.IPAddress csSubnetMask;
|
||||
private readonly System.Net.IPAddress csSubnetMask;
|
||||
|
||||
/// <summary>
|
||||
/// The path for the WebSocket messaging
|
||||
/// </summary>
|
||||
private readonly string _wsPath = "/mc/api/ui/join/";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the WebSocket path
|
||||
/// </summary>
|
||||
public string WsPath => _wsPath;
|
||||
|
||||
/// <summary>
|
||||
@@ -89,6 +99,9 @@ namespace PepperDash.Essentials.WebSocketServer
|
||||
/// </summary>
|
||||
public int Port { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the user app URL prefix
|
||||
/// </summary>
|
||||
public string UserAppUrlPrefix
|
||||
{
|
||||
get
|
||||
@@ -101,6 +114,9 @@ namespace PepperDash.Essentials.WebSocketServer
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the count of connected UI clients
|
||||
/// </summary>
|
||||
public int ConnectedUiClientsCount
|
||||
{
|
||||
get
|
||||
@@ -119,6 +135,9 @@ namespace PepperDash.Essentials.WebSocketServer
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the MobileControlWebsocketServer class.
|
||||
/// </summary>
|
||||
public MobileControlWebsocketServer(string key, int customPort, MobileControlSystemController parent)
|
||||
: base(key)
|
||||
{
|
||||
@@ -327,17 +346,26 @@ namespace PepperDash.Essentials.WebSocketServer
|
||||
}
|
||||
|
||||
string ip = processorIp;
|
||||
if (touchpanel.Touchpanel is IMobileControlCrestronTouchpanelController crestronTouchpanel && csIpAddress != null)
|
||||
|
||||
// Moved to the MobileControlTouchpanelController class in the GetUrlWithCorrectIp method
|
||||
// triggered by the Panel.IpInformationChange event so that we know we have the necessary info
|
||||
// to make the determination of which IP to use.
|
||||
//if (touchpanel.Touchpanel is IMobileControlCrestronTouchpanelController crestronTouchpanel && csIpAddress != null)
|
||||
//{
|
||||
// ip = crestronTouchpanel.ConnectedIps.Any(ipInfo =>
|
||||
// {
|
||||
// if (System.Net.IPAddress.TryParse(ipInfo.DeviceIpAddress, out var parsedIp))
|
||||
// {
|
||||
// return csIpAddress.IsInSameSubnet(parsedIp, csSubnetMask);
|
||||
// }
|
||||
// this.LogWarning("Invalid IP address: {deviceIpAddress}", ipInfo.DeviceIpAddress);
|
||||
// return false;
|
||||
// }) ? csIpAddress.ToString() : processorIp;
|
||||
//}
|
||||
|
||||
if (_parent.Config.DirectServer.CSLanUiDeviceKeys != null && _parent.Config.DirectServer.CSLanUiDeviceKeys.Any(k => k.Equals(touchpanel.Touchpanel.Key, StringComparison.InvariantCultureIgnoreCase)) && csIpAddress != null)
|
||||
{
|
||||
ip = crestronTouchpanel.ConnectedIps.Any(ipInfo =>
|
||||
{
|
||||
if (System.Net.IPAddress.TryParse(ipInfo.DeviceIpAddress, out var parsedIp))
|
||||
{
|
||||
return csIpAddress.IsInSameSubnet(parsedIp, csSubnetMask);
|
||||
}
|
||||
this.LogWarning("Invalid IP address: {deviceIpAddress}", ipInfo.DeviceIpAddress);
|
||||
return false;
|
||||
}) ? csIpAddress.ToString() : processorIp;
|
||||
ip = csIpAddress.ToString();
|
||||
}
|
||||
|
||||
var appUrl = $"http://{ip}:{_parent.Config.DirectServer.Port}/mc/app?token={touchpanel.Key}";
|
||||
@@ -621,6 +649,9 @@ namespace PepperDash.Essentials.WebSocketServer
|
||||
CrestronConsole.ConsoleCommandResponse($"Token: {token}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the grant code against the room key
|
||||
/// </summary>
|
||||
public (string, string) ValidateGrantCode(string grantCode, string roomKey)
|
||||
{
|
||||
var bridge = _parent.GetRoomBridge(roomKey);
|
||||
@@ -634,6 +665,9 @@ namespace PepperDash.Essentials.WebSocketServer
|
||||
return ValidateGrantCode(grantCode, bridge);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the grant code against the room key
|
||||
/// </summary>
|
||||
public (string, string) ValidateGrantCode(string grantCode, MobileControlBridgeBase bridge)
|
||||
{
|
||||
// TODO: Authenticate grant code passed in
|
||||
@@ -655,6 +689,9 @@ namespace PepperDash.Essentials.WebSocketServer
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a new client token for the specified bridge
|
||||
/// </summary>
|
||||
public (string, string) GenerateClientToken(MobileControlBridgeBase bridge, string touchPanelKey = "")
|
||||
{
|
||||
var key = Guid.NewGuid().ToString();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
using System;
|
||||
using System;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Crestron.SimplSharp;
|
||||
@@ -41,29 +41,6 @@ namespace PepperDash.Essentials
|
||||
SystemMonitor.ProgramInitialization.ProgramInitializationUnderUserControl = true;
|
||||
|
||||
Debug.SetErrorLogMinimumDebugLevel(CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance ? LogEventLevel.Warning : LogEventLevel.Verbose);
|
||||
|
||||
// AppDomain.CurrentDomain.AssemblyResolve += CurrentDomainOnAssemblyResolve;
|
||||
}
|
||||
|
||||
private Assembly CurrentDomainOnAssemblyResolve(object sender, ResolveEventArgs args)
|
||||
{
|
||||
var assemblyName = new AssemblyName(args.Name).Name;
|
||||
if (assemblyName == "PepperDash_Core")
|
||||
{
|
||||
return Assembly.LoadFrom("PepperDashCore.dll");
|
||||
}
|
||||
|
||||
if (assemblyName == "PepperDash_Essentials_Core")
|
||||
{
|
||||
return Assembly.LoadFrom("PepperDash.Essentials.Core.dll");
|
||||
}
|
||||
|
||||
if (assemblyName == "Essentials Devices Common")
|
||||
{
|
||||
return Assembly.LoadFrom("PepperDash.Essentials.Devices.Common.dll");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -267,6 +244,8 @@ namespace PepperDash.Essentials
|
||||
// _ = new ProcessorExtensionDeviceFactory();
|
||||
// _ = new MobileControlFactory();
|
||||
|
||||
LoadAssets();
|
||||
|
||||
Debug.LogMessage(LogEventLevel.Information, "Starting Essentials load from configuration");
|
||||
|
||||
var filesReady = SetupFilesystem();
|
||||
@@ -568,5 +547,142 @@ namespace PepperDash.Essentials
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void LoadAssets()
|
||||
{
|
||||
var applicationDirectory = new DirectoryInfo(Global.ApplicationDirectoryPathPrefix);
|
||||
Debug.LogMessage(LogEventLevel.Information, "Searching: {applicationDirectory:l} for embedded assets - {Destination}", applicationDirectory.FullName, Global.FilePathPrefix);
|
||||
|
||||
var zipFiles = applicationDirectory.GetFiles("assets*.zip");
|
||||
|
||||
if (zipFiles.Length > 1)
|
||||
{
|
||||
throw new Exception("Multiple assets zip files found. Cannot continue.");
|
||||
}
|
||||
|
||||
if (zipFiles.Length == 1)
|
||||
{
|
||||
var zipFile = zipFiles[0];
|
||||
var assetsRoot = System.IO.Path.GetFullPath(Global.FilePathPrefix);
|
||||
if (!assetsRoot.EndsWith(Path.DirectorySeparatorChar.ToString()) && !assetsRoot.EndsWith(Path.AltDirectorySeparatorChar.ToString()))
|
||||
{
|
||||
assetsRoot += Path.DirectorySeparatorChar;
|
||||
}
|
||||
Debug.LogMessage(LogEventLevel.Information, "Found assets zip file: {zipFile:l}... Unzipping...", zipFile.FullName);
|
||||
using (var archive = ZipFile.OpenRead(zipFile.FullName))
|
||||
{
|
||||
foreach (var entry in archive.Entries)
|
||||
{
|
||||
var destinationPath = Path.Combine(Global.FilePathPrefix, entry.FullName);
|
||||
var fullDest = System.IO.Path.GetFullPath(destinationPath);
|
||||
if (!fullDest.StartsWith(assetsRoot, StringComparison.OrdinalIgnoreCase))
|
||||
throw new InvalidOperationException($"Entry '{entry.FullName}' is trying to extract outside of the target directory.");
|
||||
|
||||
if (string.IsNullOrEmpty(entry.Name))
|
||||
{
|
||||
Directory.CreateDirectory(destinationPath);
|
||||
continue;
|
||||
}
|
||||
|
||||
// If a directory exists where a file should go, delete it
|
||||
if (Directory.Exists(destinationPath))
|
||||
Directory.Delete(destinationPath, true);
|
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(destinationPath));
|
||||
entry.ExtractToFile(destinationPath, true);
|
||||
Debug.LogMessage(LogEventLevel.Information, "Extracted: {entry:l} to {Destination}", entry.FullName, destinationPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// cleaning up zip files
|
||||
foreach (var file in zipFiles)
|
||||
{
|
||||
File.Delete(file.FullName);
|
||||
}
|
||||
|
||||
var htmlZipFiles = applicationDirectory.GetFiles("htmlassets*.zip");
|
||||
|
||||
if (htmlZipFiles.Length > 1)
|
||||
{
|
||||
throw new Exception("Multiple htmlassets zip files found in application directory. Please ensure only one htmlassets*.zip file is present and retry.");
|
||||
}
|
||||
|
||||
|
||||
if (htmlZipFiles.Length == 1)
|
||||
{
|
||||
var htmlZipFile = htmlZipFiles[0];
|
||||
var programDir = new DirectoryInfo(Global.FilePathPrefix.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar));
|
||||
var userOrNvramDir = programDir.Parent;
|
||||
var rootDir = userOrNvramDir?.Parent;
|
||||
if (rootDir == null)
|
||||
{
|
||||
throw new Exception($"Unable to determine root directory for html extraction. Current path: {Global.FilePathPrefix}");
|
||||
}
|
||||
var htmlDir = Path.Combine(rootDir.FullName, "html");
|
||||
var htmlRoot = System.IO.Path.GetFullPath(htmlDir);
|
||||
if (!htmlRoot.EndsWith(Path.DirectorySeparatorChar.ToString()) &&
|
||||
!htmlRoot.EndsWith(Path.AltDirectorySeparatorChar.ToString()))
|
||||
{
|
||||
htmlRoot += Path.DirectorySeparatorChar;
|
||||
}
|
||||
Debug.LogMessage(LogEventLevel.Information, "Found htmlassets zip file: {zipFile:l}... Unzipping...", htmlZipFile.FullName);
|
||||
using (var archive = ZipFile.OpenRead(htmlZipFile.FullName))
|
||||
{
|
||||
foreach (var entry in archive.Entries)
|
||||
{
|
||||
var destinationPath = Path.Combine(htmlDir, entry.FullName);
|
||||
var fullDest = System.IO.Path.GetFullPath(destinationPath);
|
||||
if (!fullDest.StartsWith(htmlRoot, StringComparison.OrdinalIgnoreCase))
|
||||
throw new InvalidOperationException($"Entry '{entry.FullName}' is trying to extract outside of the target directory.");
|
||||
|
||||
if (string.IsNullOrEmpty(entry.Name))
|
||||
{
|
||||
Directory.CreateDirectory(destinationPath);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Only delete the file if it exists and is a file, not a directory
|
||||
if (File.Exists(destinationPath))
|
||||
File.Delete(destinationPath);
|
||||
|
||||
var parentDir = Path.GetDirectoryName(destinationPath);
|
||||
if (!string.IsNullOrEmpty(parentDir))
|
||||
Directory.CreateDirectory(parentDir);
|
||||
|
||||
entry.ExtractToFile(destinationPath, true);
|
||||
Debug.LogMessage(LogEventLevel.Information, "Extracted: {entry:l} to {Destination}", entry.FullName, destinationPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// cleaning up html zip files
|
||||
foreach (var file in htmlZipFiles)
|
||||
{
|
||||
File.Delete(file.FullName);
|
||||
}
|
||||
|
||||
var jsonFiles = applicationDirectory.GetFiles("*configurationFile*.json");
|
||||
|
||||
if (jsonFiles.Length > 1)
|
||||
{
|
||||
throw new Exception("Multiple configuration files found. Cannot continue.");
|
||||
}
|
||||
|
||||
if (jsonFiles.Length == 1)
|
||||
{
|
||||
var jsonFile = jsonFiles[0];
|
||||
var finalPath = Path.Combine(Global.FilePathPrefix, jsonFile.Name);
|
||||
Debug.LogMessage(LogEventLevel.Information, "Found configuration file: {jsonFile:l}... Moving to: {Destination}", jsonFile.FullName, finalPath);
|
||||
|
||||
if (File.Exists(finalPath))
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Information, "Removing existing configuration file: {Destination}", finalPath);
|
||||
File.Delete(finalPath);
|
||||
}
|
||||
|
||||
jsonFile.MoveTo(finalPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug 4.7.2|AnyCPU'">
|
||||
<DebugType>full</DebugType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<DocumentationFile>bin\$(Configuration)\PepperDashEssentials.xml</DocumentationFile>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<DocumentationFile>bin\$(Configuration)\PepperDashEssentials.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Example Configuration\EssentialsHuddleSpaceRoom\configurationFile-HuddleSpace-2-Source.json">
|
||||
@@ -49,6 +49,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Crestron.SimplSharp.SDK.Program" Version="2.21.90" />
|
||||
<PackageReference Include="System.IO.Compression" Version="4.0.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PepperDash.Core\PepperDash.Core.csproj" />
|
||||
|
||||
Reference in New Issue
Block a user