mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-07 08:45:06 +00:00
Compare commits
7 Commits
v2.1.0-fea
...
v2.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
09dd8f0bcd | ||
|
|
99c6163c0e | ||
|
|
90aa4a5d62 | ||
|
|
8b3eda1d18 | ||
|
|
6c710dd209 | ||
|
|
7629836732 | ||
|
|
a5bc79c469 |
@@ -741,7 +741,7 @@ namespace PepperDash.Core
|
||||
{
|
||||
if (HeartbeatEnabled)
|
||||
{
|
||||
Debug.Console(2, this, "Starting Heartbeat");
|
||||
this.LogVerbose("Starting Heartbeat");
|
||||
if (HeartbeatSendTimer == null)
|
||||
{
|
||||
|
||||
|
||||
@@ -686,7 +686,7 @@ namespace PepperDash.Core
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
this.LogException(ex, "DequeueEvent error");
|
||||
this.LogException(e, "DequeueEvent error");
|
||||
}
|
||||
// Make sure to leave the CCritical section in case an exception above stops this thread, or we won't be able to restart it.
|
||||
if (DequeueLock != null)
|
||||
|
||||
@@ -17,6 +17,7 @@ using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharp.CrestronSockets;
|
||||
using PepperDash.Core.Logging;
|
||||
|
||||
namespace PepperDash.Core
|
||||
{
|
||||
@@ -445,7 +446,7 @@ namespace PepperDash.Core
|
||||
/// </summary>
|
||||
public void Disconnect()
|
||||
{
|
||||
Debug.Console(2, "Disconnect Called");
|
||||
this.LogVerbose("Disconnect Called");
|
||||
|
||||
DisconnectCalledByUser = true;
|
||||
if (IsConnected)
|
||||
|
||||
@@ -15,6 +15,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharp.CrestronSockets;
|
||||
using PepperDash.Core.Logging;
|
||||
|
||||
namespace PepperDash.Core
|
||||
{
|
||||
@@ -526,7 +527,7 @@ namespace PepperDash.Core
|
||||
{
|
||||
SocketErrorCodes error = myTcpServer.SendDataAsync(i, b, b.Length, (x, y, z) => { });
|
||||
if (error != SocketErrorCodes.SOCKET_OK && error != SocketErrorCodes.SOCKET_OPERATION_PENDING)
|
||||
Debug.Console(2, error.ToString());
|
||||
this.LogError("{error}",error.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharp.CrestronSockets;
|
||||
using Newtonsoft.Json;
|
||||
using PepperDash.Core.Logging;
|
||||
|
||||
namespace PepperDash.Core
|
||||
{
|
||||
@@ -279,7 +280,7 @@ namespace PepperDash.Core
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.Console(0, "GenericUdpServer Receive error: {0}{1}", ex.Message, ex.StackTrace);
|
||||
this.LogException(ex, "GenericUdpServer Receive error");
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Crestron.SimplSharp;
|
||||
using Newtonsoft.Json;
|
||||
using Serilog.Events;
|
||||
|
||||
namespace PepperDash.Core
|
||||
{
|
||||
@@ -43,7 +44,7 @@ namespace PepperDash.Core
|
||||
{
|
||||
var status = CrestronEthernetHelper.GetEthernetParameter(
|
||||
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_LINK_STATUS, 0);
|
||||
Debug.Console(0, "LinkActive = {0}", status);
|
||||
Debug.LogMessage(LogEventLevel.Information, "LinkActive = {0}", status);
|
||||
return status == "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Serilog.Events;
|
||||
|
||||
//using PepperDash.Core;
|
||||
|
||||
@@ -30,7 +31,7 @@ namespace PepperDash.Core.JsonToSimpl
|
||||
if (string.IsNullOrEmpty(master.UniqueID))
|
||||
throw new InvalidOperationException("JSON Master cannot be added with a null UniqueId");
|
||||
|
||||
Debug.Console(1, "JSON Global adding master {0}", master.UniqueID);
|
||||
Debug.LogMessage(LogEventLevel.Debug, "JSON Global adding master {0}", master.UniqueID);
|
||||
|
||||
if (Masters.Contains(master)) return;
|
||||
|
||||
|
||||
@@ -229,7 +229,7 @@ namespace PepperDash.Core
|
||||
|
||||
_consoleLoggingLevelSwitch.MinimumLevelChanged += (sender, args) =>
|
||||
{
|
||||
Console(0, "Console debug level set to {0}", _consoleLoggingLevelSwitch.MinimumLevel);
|
||||
LogMessage(LogEventLevel.Information, "Console debug level set to {minimumLevel}", _consoleLoggingLevelSwitch.MinimumLevel);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ namespace PepperDash.Core
|
||||
_saveTimer.Stop();
|
||||
_saveTimer = null;
|
||||
}
|
||||
Console(0, "Saving debug settings");
|
||||
LogMessage(LogEventLevel.Information, "Saving debug settings");
|
||||
SaveMemory();
|
||||
}
|
||||
}
|
||||
@@ -589,7 +589,7 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Log an Exception using Serilog's default Exception logging mechanism
|
||||
/// Log an Exception as an Error
|
||||
/// </summary>
|
||||
/// <param name="ex">Exception to log</param>
|
||||
/// <param name="message">Message template</param>
|
||||
@@ -610,7 +610,7 @@ namespace PepperDash.Core
|
||||
/// <param name="message">Message template</param>
|
||||
/// <param name="device">Optional IKeyed device. If provided, the Key of the device will be added to the log message</param>
|
||||
/// <param name="args">Args to put into message template</param>
|
||||
public static void LogMessage(LogEventLevel level, string message, IKeyed device=null, params object[] args)
|
||||
public static void LogMessage(LogEventLevel level, string message, IKeyed device = null, params object[] args)
|
||||
{
|
||||
using (LogContext.PushProperty("Key", device?.Key))
|
||||
{
|
||||
@@ -620,7 +620,12 @@ namespace PepperDash.Core
|
||||
|
||||
public static void LogMessage(LogEventLevel level, string message, params object[] args)
|
||||
{
|
||||
LogMessage(level, message, null, args);
|
||||
_logger.Write(level, message, args);
|
||||
}
|
||||
|
||||
public static void LogMessage(LogEventLevel level, Exception ex, string message, params object[] args)
|
||||
{
|
||||
_logger.Write(level, ex, message, args);
|
||||
}
|
||||
|
||||
public static void LogMessage(LogEventLevel level, IKeyed keyed, string message, params object[] args)
|
||||
@@ -628,6 +633,173 @@ namespace PepperDash.Core
|
||||
LogMessage(level, message, keyed, args);
|
||||
}
|
||||
|
||||
public static void LogMessage(LogEventLevel level, Exception ex, IKeyed device, string message, params object[] args)
|
||||
{
|
||||
using (LogContext.PushProperty("Key", device?.Key))
|
||||
{
|
||||
_logger.Write(level, ex, message, args);
|
||||
}
|
||||
}
|
||||
|
||||
#region Explicit methods for logging levels
|
||||
public static void LogVerbose(IKeyed keyed, string message, params object[] args)
|
||||
{
|
||||
using(LogContext.PushProperty("Key", keyed?.Key))
|
||||
{
|
||||
_logger.Write(LogEventLevel.Verbose, message, args);
|
||||
}
|
||||
}
|
||||
|
||||
public static void LogVerbose(Exception ex, IKeyed keyed, string message, params object[] args)
|
||||
{
|
||||
using(LogContext.PushProperty("Key", keyed?.Key))
|
||||
{
|
||||
_logger.Write(LogEventLevel.Verbose, ex, message, args);
|
||||
}
|
||||
}
|
||||
|
||||
public static void LogVerbose(string message, params object[] args)
|
||||
{
|
||||
_logger.Write(LogEventLevel.Verbose, message, args);
|
||||
}
|
||||
|
||||
public static void LogVerbose(Exception ex, string message, params object[] args)
|
||||
{
|
||||
_logger.Write(LogEventLevel.Verbose, ex, null, message, args);
|
||||
}
|
||||
|
||||
public static void LogDebug(IKeyed keyed, string message, params object[] args)
|
||||
{
|
||||
using (LogContext.PushProperty("Key", keyed?.Key))
|
||||
{
|
||||
_logger.Write(LogEventLevel.Debug, message, args);
|
||||
}
|
||||
}
|
||||
|
||||
public static void LogDebug(Exception ex, IKeyed keyed, string message, params object[] args)
|
||||
{
|
||||
using (LogContext.PushProperty("Key", keyed?.Key))
|
||||
{
|
||||
_logger.Write(LogEventLevel.Debug, ex, message, args);
|
||||
}
|
||||
}
|
||||
|
||||
public static void LogDebug(string message, params object[] args)
|
||||
{
|
||||
_logger.Write(LogEventLevel.Debug, message, args);
|
||||
}
|
||||
|
||||
public static void LogDebug(Exception ex, string message, params object[] args)
|
||||
{
|
||||
_logger.Write(LogEventLevel.Debug, ex, null, message, args);
|
||||
}
|
||||
|
||||
public static void LogInformation(IKeyed keyed, string message, params object[] args)
|
||||
{
|
||||
using (LogContext.PushProperty("Key", keyed?.Key))
|
||||
{
|
||||
_logger.Write(LogEventLevel.Information, message, args);
|
||||
}
|
||||
}
|
||||
|
||||
public static void LogInformation(Exception ex, IKeyed keyed, string message, params object[] args)
|
||||
{
|
||||
using (LogContext.PushProperty("Key", keyed?.Key))
|
||||
{
|
||||
_logger.Write(LogEventLevel.Information, ex, message, args);
|
||||
}
|
||||
}
|
||||
|
||||
public static void LogInformation(string message, params object[] args)
|
||||
{
|
||||
_logger.Write(LogEventLevel.Information, message, args);
|
||||
}
|
||||
|
||||
public static void LogInformation(Exception ex, string message, params object[] args)
|
||||
{
|
||||
_logger.Write(LogEventLevel.Information, ex, null, message, args);
|
||||
}
|
||||
|
||||
public static void LogWarning(IKeyed keyed, string message, params object[] args)
|
||||
{
|
||||
using (LogContext.PushProperty("Key", keyed?.Key))
|
||||
{
|
||||
_logger.Write(LogEventLevel.Warning, message, args);
|
||||
}
|
||||
}
|
||||
|
||||
public static void LogWarning(Exception ex, IKeyed keyed, string message, params object[] args)
|
||||
{
|
||||
using (LogContext.PushProperty("Key", keyed?.Key))
|
||||
{
|
||||
_logger.Write(LogEventLevel.Warning, ex, message, args);
|
||||
}
|
||||
}
|
||||
|
||||
public static void LogWarning(string message, params object[] args)
|
||||
{
|
||||
_logger.Write(LogEventLevel.Warning, message, args);
|
||||
}
|
||||
|
||||
public static void LogWarning(Exception ex, string message, params object[] args)
|
||||
{
|
||||
_logger.Write(LogEventLevel.Warning, ex, null, message, args);
|
||||
}
|
||||
|
||||
public static void LogError(IKeyed keyed, string message, params object[] args)
|
||||
{
|
||||
using (LogContext.PushProperty("Key", keyed?.Key))
|
||||
{
|
||||
_logger.Write(LogEventLevel.Error, message, args);
|
||||
}
|
||||
}
|
||||
|
||||
public static void LogError(Exception ex, IKeyed keyed, string message, params object[] args)
|
||||
{
|
||||
using (LogContext.PushProperty("Key", keyed?.Key))
|
||||
{
|
||||
_logger.Write(LogEventLevel.Error, ex, message, args);
|
||||
}
|
||||
}
|
||||
|
||||
public static void LogError(string message, params object[] args)
|
||||
{
|
||||
_logger.Write(LogEventLevel.Error, message, args);
|
||||
}
|
||||
|
||||
public static void LogError(Exception ex, string message, params object[] args)
|
||||
{
|
||||
_logger.Write(LogEventLevel.Error, ex, null, message, args);
|
||||
}
|
||||
|
||||
public static void LogFatal(IKeyed keyed, string message, params object[] args)
|
||||
{
|
||||
using (LogContext.PushProperty("Key", keyed?.Key))
|
||||
{
|
||||
_logger.Write(LogEventLevel.Fatal, message, args);
|
||||
}
|
||||
}
|
||||
|
||||
public static void LogFatal(Exception ex, IKeyed keyed, string message, params object[] args)
|
||||
{
|
||||
using (LogContext.PushProperty("Key", keyed?.Key))
|
||||
{
|
||||
_logger.Write(LogEventLevel.Fatal, ex, message, args);
|
||||
}
|
||||
}
|
||||
|
||||
public static void LogFatal(string message, params object[] args)
|
||||
{
|
||||
_logger.Write(LogEventLevel.Fatal, message, args);
|
||||
}
|
||||
|
||||
public static void LogFatal(Exception ex, string message, params object[] args)
|
||||
{
|
||||
_logger.Write(LogEventLevel.Fatal, ex, null, message, args);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
private static void LogMessage(uint level, string format, params object[] items)
|
||||
{
|
||||
@@ -655,7 +827,7 @@ namespace PepperDash.Core
|
||||
/// <param name="level"></param>
|
||||
/// <param name="format">Console format string</param>
|
||||
/// <param name="items">Object parameters</param>
|
||||
[Obsolete("Use LogMessage methods")]
|
||||
[Obsolete("Use LogMessage methods. Will be removed in 2.2.0 and later versions")]
|
||||
public static void Console(uint level, string format, params object[] items)
|
||||
{
|
||||
|
||||
@@ -673,7 +845,7 @@ namespace PepperDash.Core
|
||||
/// <summary>
|
||||
/// Logs to Console when at-level, and all messages to error log, including device key
|
||||
/// </summary>
|
||||
[Obsolete("Use LogMessage methods")]
|
||||
[Obsolete("Use LogMessage methods, Will be removed in 2.2.0 and later versions")]
|
||||
public static void Console(uint level, IKeyed dev, string format, params object[] items)
|
||||
{
|
||||
LogMessage(level, dev, format, items);
|
||||
@@ -686,7 +858,7 @@ namespace PepperDash.Core
|
||||
/// Prints message to console if current debug level is equal to or higher than the level of this message. Always sends message to Error Log.
|
||||
/// Uses CrestronConsole.PrintLine.
|
||||
/// </summary>
|
||||
[Obsolete("Use LogMessage methods")]
|
||||
[Obsolete("Use LogMessage methods, Will be removed in 2.2.0 and later versions")]
|
||||
public static void Console(uint level, IKeyed dev, ErrorLogLevel errorLogLevel,
|
||||
string format, params object[] items)
|
||||
{
|
||||
@@ -696,7 +868,7 @@ namespace PepperDash.Core
|
||||
/// <summary>
|
||||
/// Logs to Console when at-level, and all messages to error log
|
||||
/// </summary>
|
||||
[Obsolete("Use LogMessage methods")]
|
||||
[Obsolete("Use LogMessage methods, Will be removed in 2.2.0 and later versions")]
|
||||
public static void Console(uint level, ErrorLogLevel errorLogLevel,
|
||||
string format, params object[] items)
|
||||
{
|
||||
@@ -708,7 +880,7 @@ namespace PepperDash.Core
|
||||
/// or above the level provided, then the output will be written to both console and the log. Otherwise
|
||||
/// it will only be written to the log.
|
||||
/// </summary>
|
||||
[Obsolete("Use LogMessage methods")]
|
||||
[Obsolete("Use LogMessage methods, Will be removed in 2.2.0 and later versions")]
|
||||
public static void ConsoleWithLog(uint level, string format, params object[] items)
|
||||
{
|
||||
LogMessage(level, format, items);
|
||||
@@ -724,7 +896,7 @@ namespace PepperDash.Core
|
||||
/// or above the level provided, then the output will be written to both console and the log. Otherwise
|
||||
/// it will only be written to the log.
|
||||
/// </summary>
|
||||
[Obsolete("Use LogMessage methods")]
|
||||
[Obsolete("Use LogMessage methods, Will be removed in 2.2.0 and later versions")]
|
||||
public static void ConsoleWithLog(uint level, IKeyed dev, string format, params object[] items)
|
||||
{
|
||||
LogMessage(level, dev, format, items);
|
||||
@@ -738,7 +910,7 @@ namespace PepperDash.Core
|
||||
/// </summary>
|
||||
/// <param name="errorLogLevel"></param>
|
||||
/// <param name="str"></param>
|
||||
[Obsolete("Use LogMessage methods")]
|
||||
[Obsolete("Use LogMessage methods, Will be removed in 2.2.0 and later versions")]
|
||||
public static void LogError(ErrorLogLevel errorLogLevel, string str)
|
||||
{
|
||||
switch (errorLogLevel)
|
||||
@@ -782,7 +954,7 @@ namespace PepperDash.Core
|
||||
|
||||
var fileName = GetMemoryFileName();
|
||||
|
||||
Console(0, ErrorLogLevel.Notice, "Loading debug settings file from {0}", fileName);
|
||||
LogMessage(LogEventLevel.Information, "Loading debug settings file from {fileName}", fileName);
|
||||
|
||||
using (var sw = new StreamWriter(fileName))
|
||||
{
|
||||
@@ -807,7 +979,7 @@ namespace PepperDash.Core
|
||||
|
||||
if (_contexts != null)
|
||||
{
|
||||
Console(1, "Debug memory restored from file");
|
||||
LogMessage(LogEventLevel.Debug, "Debug memory restored from file");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -830,45 +1002,6 @@ namespace PepperDash.Core
|
||||
return string.Format("{0}{1}user{1}debugSettings{1}{2}.json",Directory.GetApplicationRootDirectory(), Path.DirectorySeparatorChar, InitialParametersClass.RoomId);
|
||||
}
|
||||
|
||||
private static void CheckForMigration()
|
||||
{
|
||||
var oldFilePath = String.Format(@"\nvram\debugSettings\program{0}", InitialParametersClass.ApplicationNumber);
|
||||
var newFilePath = String.Format(@"\user\debugSettings\program{0}", InitialParametersClass.ApplicationNumber);
|
||||
|
||||
//check for file at old path
|
||||
if (!File.Exists(oldFilePath))
|
||||
{
|
||||
Console(0, ErrorLogLevel.Notice,
|
||||
String.Format(
|
||||
@"Debug settings file migration not necessary. Using file at \user\debugSettings\program{0}",
|
||||
InitialParametersClass.ApplicationNumber));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//create the new directory if it doesn't already exist
|
||||
if (!Directory.Exists(@"\user\debugSettings"))
|
||||
{
|
||||
Directory.CreateDirectory(@"\user\debugSettings");
|
||||
}
|
||||
|
||||
Console(0, ErrorLogLevel.Notice,
|
||||
String.Format(
|
||||
@"File found at \nvram\debugSettings\program{0}. Migrating to \user\debugSettings\program{0}", InitialParametersClass.ApplicationNumber));
|
||||
|
||||
//Copy file from old path to new path, then delete it. This will overwrite the existing file
|
||||
File.Copy(oldFilePath, newFilePath, true);
|
||||
File.Delete(oldFilePath);
|
||||
|
||||
//Check if the old directory is empty, then delete it if it is
|
||||
if (Directory.GetFiles(@"\nvram\debugSettings").Length > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Directory.Delete(@"\nvram\debugSettings");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Error level to for message to be logged at
|
||||
/// </summary>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Serilog;
|
||||
using Serilog.Events;
|
||||
using Serilog.Events;
|
||||
using System;
|
||||
using Log = PepperDash.Core.Debug;
|
||||
|
||||
@@ -11,31 +10,62 @@ namespace PepperDash.Core.Logging
|
||||
{
|
||||
Log.LogMessage(ex, message, device, args);
|
||||
}
|
||||
|
||||
public static void LogVerbose(this IKeyed device, Exception ex, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Verbose, ex, message, device, args);
|
||||
}
|
||||
|
||||
public static void LogVerbose(this IKeyed device, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Verbose, device, message, args);
|
||||
}
|
||||
|
||||
public static void LogDebug(this IKeyed device, Exception ex, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Debug, ex, message, device, args);
|
||||
}
|
||||
|
||||
public static void LogDebug(this IKeyed device, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Debug, device, message, args);
|
||||
}
|
||||
|
||||
public static void LogInformation(this IKeyed device, Exception ex, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Information, ex, message, device, args);
|
||||
}
|
||||
|
||||
public static void LogInformation(this IKeyed device, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Information, device, message, args);
|
||||
}
|
||||
|
||||
public static void LogWarning(this IKeyed device, Exception ex, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Warning, ex, message, device, args);
|
||||
}
|
||||
|
||||
public static void LogWarning(this IKeyed device, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Warning, device, message, args);
|
||||
}
|
||||
|
||||
public static void LogError(this IKeyed device, Exception ex, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Error, ex, message, device, args);
|
||||
}
|
||||
|
||||
public static void LogError(this IKeyed device, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Error, device, message, args);
|
||||
}
|
||||
|
||||
public static void LogFatal(this IKeyed device, Exception ex, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Fatal, ex, message, device, args);
|
||||
}
|
||||
|
||||
public static void LogFatal(this IKeyed device, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Fatal, device, message, args);
|
||||
|
||||
@@ -1,27 +1,7 @@
|
||||
using PepperDash.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Describes a device that has selectable inputs
|
||||
/// </summary>
|
||||
/// <typeparam name="TKey">the type to use as the key for each input item. Most likely an enum or string</typeparam>\
|
||||
/// <example>
|
||||
/// See MockDisplay for example implemntation
|
||||
/// </example>
|
||||
[Obsolete("Use IHasInputs<T> instead. Will be removed for 2.0 release")]
|
||||
public interface IHasInputs<T, TSelector>: IKeyName
|
||||
{
|
||||
ISelectableItems<T> Inputs { get; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Describes a device that has selectable inputs
|
||||
/// </summary>
|
||||
|
||||
@@ -8,9 +8,9 @@ namespace PepperDash.Essentials.Room.MobileControl
|
||||
{
|
||||
private readonly IChannel channelDevice;
|
||||
|
||||
public IChannelMessenger(string key, string messagePath, Device device) : base(key, messagePath, device)
|
||||
public IChannelMessenger(string key, string messagePath, IChannel device) : base(key, messagePath, device as IKeyName)
|
||||
{
|
||||
channelDevice = device as IChannel;
|
||||
channelDevice = device;
|
||||
}
|
||||
|
||||
protected override void RegisterActions()
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace PepperDash.Essentials.Room.MobileControl
|
||||
public class IColorMessenger : MessengerBase
|
||||
{
|
||||
private readonly IColor colorDevice;
|
||||
public IColorMessenger(string key, string messagePath, Device device) : base(key, messagePath, device)
|
||||
public IColorMessenger(string key, string messagePath, IColor device) : base(key, messagePath, device as IKeyName)
|
||||
{
|
||||
colorDevice = device as IColor;
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@ namespace PepperDash.Essentials.Room.MobileControl
|
||||
public class IDPadMessenger : MessengerBase
|
||||
{
|
||||
private readonly IDPad dpadDevice;
|
||||
public IDPadMessenger(string key, string messagePath, Device device) : base(key, messagePath, device)
|
||||
public IDPadMessenger(string key, string messagePath, IDPad device) : base(key, messagePath, device as IKeyName)
|
||||
{
|
||||
dpadDevice = device as IDPad;
|
||||
dpadDevice = device;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@ namespace PepperDash.Essentials.Room.MobileControl
|
||||
public class IDvrMessenger : MessengerBase
|
||||
{
|
||||
private readonly IDvr dvrDevice;
|
||||
public IDvrMessenger(string key, string messagePath, Device device) : base(key, messagePath, device)
|
||||
public IDvrMessenger(string key, string messagePath, IDvr device) : base(key, messagePath, device as IKeyName)
|
||||
{
|
||||
dvrDevice = device as IDvr;
|
||||
dvrDevice = device;
|
||||
}
|
||||
|
||||
protected override void RegisterActions()
|
||||
|
||||
@@ -7,9 +7,9 @@ namespace PepperDash.Essentials.Room.MobileControl
|
||||
public class IHasPowerMessenger : MessengerBase
|
||||
{
|
||||
private readonly IHasPowerControl powerDevice;
|
||||
public IHasPowerMessenger(string key, string messagePath, Device device) : base(key, messagePath, device)
|
||||
public IHasPowerMessenger(string key, string messagePath, IHasPowerControl device) : base(key, messagePath, device as IKeyName)
|
||||
{
|
||||
powerDevice = device as IHasPowerControl;
|
||||
powerDevice = device;
|
||||
}
|
||||
|
||||
protected override void RegisterActions()
|
||||
|
||||
@@ -7,9 +7,9 @@ namespace PepperDash.Essentials.Room.MobileControl
|
||||
public class INumericKeypadMessenger : MessengerBase
|
||||
{
|
||||
private readonly INumericKeypad keypadDevice;
|
||||
public INumericKeypadMessenger(string key, string messagePath, Device device) : base(key, messagePath, device)
|
||||
public INumericKeypadMessenger(string key, string messagePath, INumericKeypad device) : base(key, messagePath, device as IKeyName)
|
||||
{
|
||||
keypadDevice = device as INumericKeypad;
|
||||
keypadDevice = device;
|
||||
}
|
||||
|
||||
protected override void RegisterActions()
|
||||
|
||||
@@ -7,9 +7,9 @@ namespace PepperDash.Essentials.Room.MobileControl
|
||||
public class ISetTopBoxControlsMessenger : MessengerBase
|
||||
{
|
||||
private readonly ISetTopBoxControls stbDevice;
|
||||
public ISetTopBoxControlsMessenger(string key, string messagePath, IKeyName device) : base(key, messagePath, device)
|
||||
public ISetTopBoxControlsMessenger(string key, string messagePath, ISetTopBoxControls device) : base(key, messagePath, device as IKeyName)
|
||||
{
|
||||
stbDevice = device as ISetTopBoxControls;
|
||||
stbDevice = device;
|
||||
}
|
||||
|
||||
protected override void RegisterActions()
|
||||
|
||||
@@ -7,9 +7,9 @@ namespace PepperDash.Essentials.Room.MobileControl
|
||||
public class ITransportMessenger : MessengerBase
|
||||
{
|
||||
private readonly ITransport transportDevice;
|
||||
public ITransportMessenger(string key, string messagePath, Device device) : base(key, messagePath, device)
|
||||
public ITransportMessenger(string key, string messagePath, ITransport device) : base(key, messagePath, device as IKeyName)
|
||||
{
|
||||
transportDevice = device as ITransport;
|
||||
transportDevice = device;
|
||||
}
|
||||
|
||||
protected override void RegisterActions()
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
||||
private readonly IEssentialsRoomCombiner _roomCombiner;
|
||||
|
||||
public IEssentialsRoomCombinerMessenger(string key, string messagePath, IEssentialsRoomCombiner roomCombiner)
|
||||
: base(key, messagePath, roomCombiner as Device)
|
||||
: base(key, messagePath, roomCombiner as IKeyName)
|
||||
{
|
||||
_roomCombiner = roomCombiner;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
||||
private readonly IHasPowerControlWithFeedback _powerControl;
|
||||
|
||||
public IHasPowerControlWithFeedbackMessenger(string key, string messagePath, IHasPowerControlWithFeedback powerControl)
|
||||
: base(key, messagePath, powerControl as Device)
|
||||
: base(key, messagePath, powerControl as IKeyName)
|
||||
{
|
||||
_powerControl = powerControl;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
||||
public IHasScheduleAwareness ScheduleSource { get; private set; }
|
||||
|
||||
public IHasScheduleAwarenessMessenger(string key, IHasScheduleAwareness scheduleSource, string messagePath)
|
||||
: base(key, messagePath, scheduleSource as Device)
|
||||
: base(key, messagePath, scheduleSource as IKeyName)
|
||||
{
|
||||
ScheduleSource = scheduleSource ?? throw new ArgumentNullException("scheduleSource");
|
||||
ScheduleSource.CodecSchedule.MeetingsListHasChanged += new EventHandler<EventArgs>(CodecSchedule_MeetingsListHasChanged);
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
||||
private readonly IHumiditySensor device;
|
||||
|
||||
public IHumiditySensorMessenger(string key, IHumiditySensor device, string messagePath)
|
||||
: base(key, messagePath, device as Device)
|
||||
: base(key, messagePath, device as IKeyName)
|
||||
{
|
||||
this.device = device;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
||||
public class ILevelControlsMessenger : MessengerBase
|
||||
{
|
||||
private ILevelControls levelControlsDevice;
|
||||
public ILevelControlsMessenger(string key, string messagePath, ILevelControls device) : base(key, messagePath, device as Device)
|
||||
public ILevelControlsMessenger(string key, string messagePath, ILevelControls device) : base(key, messagePath, device as IKeyName)
|
||||
{
|
||||
levelControlsDevice = device;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
||||
public class IMatrixRoutingMessenger : MessengerBase
|
||||
{
|
||||
private readonly IMatrixRouting matrixDevice;
|
||||
public IMatrixRoutingMessenger(string key, string messagePath, IMatrixRouting device) : base(key, messagePath, device as Device)
|
||||
public IMatrixRoutingMessenger(string key, string messagePath, IMatrixRouting device) : base(key, messagePath, device as IKeyName)
|
||||
{
|
||||
matrixDevice = device;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
||||
private readonly IProjectorScreenLiftControl device;
|
||||
|
||||
public IProjectorScreenLiftControlMessenger(string key, string messagePath, IProjectorScreenLiftControl screenLiftDevice)
|
||||
: base(key, messagePath, screenLiftDevice as Device)
|
||||
: base(key, messagePath, screenLiftDevice as IKeyName)
|
||||
{
|
||||
device = screenLiftDevice;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
||||
public IRunRouteAction RoutingDevice { get; private set; }
|
||||
|
||||
public RunRouteActionMessenger(string key, IRunRouteAction routingDevice, string messagePath)
|
||||
: base(key, messagePath, routingDevice as Device)
|
||||
: base(key, messagePath, routingDevice as IKeyName)
|
||||
{
|
||||
RoutingDevice = routingDevice ?? throw new ArgumentNullException("routingDevice");
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
||||
public class ISelectableItemsMessenger<TKey> : MessengerBase
|
||||
{
|
||||
private static readonly JsonSerializer serializer = new JsonSerializer { Converters = { new StringEnumConverter() } };
|
||||
private ISelectableItems<TKey> itemDevice;
|
||||
private readonly ISelectableItems<TKey> itemDevice;
|
||||
|
||||
private readonly string _propName;
|
||||
public ISelectableItemsMessenger(string key, string messagePath, ISelectableItems<TKey> device, string propName) : base(key, messagePath, device as Device)
|
||||
public ISelectableItemsMessenger(string key, string messagePath, ISelectableItems<TKey> device, string propName) : base(key, messagePath, device as IKeyName)
|
||||
{
|
||||
itemDevice = device;
|
||||
_propName = propName;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
||||
private readonly IShutdownPromptTimer _room;
|
||||
|
||||
public IShutdownPromptTimerMessenger(string key, string messagePath, IShutdownPromptTimer room)
|
||||
: base(key, messagePath, room as Device)
|
||||
: base(key, messagePath, room as IKeyName)
|
||||
{
|
||||
_room = room;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
||||
private readonly ISwitchedOutput device;
|
||||
|
||||
public ISwitchedOutputMessenger(string key, ISwitchedOutput device, string messagePath)
|
||||
: base(key, messagePath, device as Device)
|
||||
: base(key, messagePath, device as IKeyName)
|
||||
{
|
||||
this.device = device;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
||||
private readonly ITechPassword _room;
|
||||
|
||||
public ITechPasswordMessenger(string key, string messagePath, ITechPassword room)
|
||||
: base(key, messagePath, room as Device)
|
||||
: base(key, messagePath, room as IKeyName)
|
||||
{
|
||||
_room = room;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
||||
private readonly ITemperatureSensor device;
|
||||
|
||||
public ITemperatureSensorMessenger(string key, ITemperatureSensor device, string messagePath)
|
||||
: base(key, messagePath, device as Device)
|
||||
: base(key, messagePath, device as IKeyName)
|
||||
{
|
||||
this.device = device;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
||||
protected ILightingScenes Device { get; private set; }
|
||||
|
||||
public ILightingScenesMessenger(string key, ILightingScenes device, string messagePath)
|
||||
: base(key, messagePath, device as Device)
|
||||
: base(key, messagePath, device as IKeyName)
|
||||
{
|
||||
Device = device ?? throw new ArgumentNullException("device");
|
||||
Device.LightingSceneChange += new EventHandler<LightingSceneChangeEventArgs>(LightingDevice_LightingSceneChange);
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
||||
|
||||
|
||||
public RoomEventScheduleMessenger(string key, string messagePath, IRoomEventSchedule room)
|
||||
: base(key, messagePath, room as Device)
|
||||
: base(key, messagePath, room as IKeyName)
|
||||
{
|
||||
_room = room;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
||||
private readonly IShadesOpenCloseStop device;
|
||||
|
||||
public IShadesOpenCloseStopMessenger(string key, IShadesOpenCloseStop shades, string messagePath)
|
||||
: base(key, messagePath, shades as Device)
|
||||
: base(key, messagePath, shades as IKeyName)
|
||||
{
|
||||
device = shades;
|
||||
}
|
||||
|
||||
@@ -9,12 +9,8 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
||||
{
|
||||
private readonly TwoWayDisplayBase _display;
|
||||
|
||||
public TwoWayDisplayBaseMessenger(string key, string messagePath) : base(key, messagePath)
|
||||
{
|
||||
}
|
||||
|
||||
public TwoWayDisplayBaseMessenger(string key, string messagePath, TwoWayDisplayBase display)
|
||||
: this(key, messagePath)
|
||||
: base(key, messagePath, display)
|
||||
{
|
||||
_display = display;
|
||||
}
|
||||
|
||||
@@ -566,18 +566,16 @@ namespace PepperDash.Essentials
|
||||
messengerAdded = true;
|
||||
}
|
||||
|
||||
if (device is ISetTopBoxControls)
|
||||
if (device is ISetTopBoxControls stbDevice)
|
||||
{
|
||||
this.LogVerbose(
|
||||
"Adding ISetTopBoxControlMessenger for {deviceKey}"
|
||||
);
|
||||
|
||||
var dev = device as Device;
|
||||
);
|
||||
|
||||
var messenger = new ISetTopBoxControlsMessenger(
|
||||
$"{device.Key}-stb-{Key}",
|
||||
$"/device/{device.Key}",
|
||||
dev
|
||||
stbDevice
|
||||
);
|
||||
|
||||
AddDefaultDeviceMessenger(messenger);
|
||||
@@ -585,18 +583,16 @@ namespace PepperDash.Essentials
|
||||
messengerAdded = true;
|
||||
}
|
||||
|
||||
if (device is IChannel)
|
||||
if (device is IChannel channelDevice)
|
||||
{
|
||||
this.LogVerbose(
|
||||
"Adding IChannelMessenger for {deviceKey}", device.Key
|
||||
);
|
||||
|
||||
var dev = device as PepperDash.Core.Device;
|
||||
);
|
||||
|
||||
var messenger = new IChannelMessenger(
|
||||
$"{device.Key}-channel-{Key}",
|
||||
$"/device/{device.Key}",
|
||||
dev
|
||||
channelDevice
|
||||
);
|
||||
|
||||
AddDefaultDeviceMessenger(messenger);
|
||||
@@ -604,16 +600,14 @@ namespace PepperDash.Essentials
|
||||
messengerAdded = true;
|
||||
}
|
||||
|
||||
if (device is IColor)
|
||||
if (device is IColor colorDevice)
|
||||
{
|
||||
this.LogVerbose("Adding IColorMessenger for {deviceKey}", device.Key);
|
||||
|
||||
var dev = device as PepperDash.Core.Device;
|
||||
this.LogVerbose("Adding IColorMessenger for {deviceKey}", device.Key);
|
||||
|
||||
var messenger = new IColorMessenger(
|
||||
$"{device.Key}-color-{Key}",
|
||||
$"/device/{device.Key}",
|
||||
dev
|
||||
colorDevice
|
||||
);
|
||||
|
||||
AddDefaultDeviceMessenger(messenger);
|
||||
@@ -621,16 +615,14 @@ namespace PepperDash.Essentials
|
||||
messengerAdded = true;
|
||||
}
|
||||
|
||||
if (device is IDPad)
|
||||
if (device is IDPad dPadDevice)
|
||||
{
|
||||
this.LogVerbose("Adding IDPadMessenger for {deviceKey}", device.Key);
|
||||
|
||||
var dev = device as PepperDash.Core.Device;
|
||||
this.LogVerbose("Adding IDPadMessenger for {deviceKey}", device.Key);
|
||||
|
||||
var messenger = new IDPadMessenger(
|
||||
$"{device.Key}-dPad-{Key}",
|
||||
$"/device/{device.Key}",
|
||||
dev
|
||||
dPadDevice
|
||||
);
|
||||
|
||||
AddDefaultDeviceMessenger(messenger);
|
||||
@@ -638,16 +630,14 @@ namespace PepperDash.Essentials
|
||||
messengerAdded = true;
|
||||
}
|
||||
|
||||
if (device is INumericKeypad)
|
||||
if (device is INumericKeypad nkDevice)
|
||||
{
|
||||
this.LogVerbose("Adding INumericKeyapdMessenger for {deviceKey}", device.Key);
|
||||
|
||||
var dev = device as PepperDash.Core.Device;
|
||||
this.LogVerbose("Adding INumericKeyapdMessenger for {deviceKey}", device.Key);
|
||||
|
||||
var messenger = new INumericKeypadMessenger(
|
||||
$"{device.Key}-numericKeypad-{Key}",
|
||||
$"/device/{device.Key}",
|
||||
dev
|
||||
nkDevice
|
||||
);
|
||||
|
||||
AddDefaultDeviceMessenger(messenger);
|
||||
@@ -655,16 +645,14 @@ namespace PepperDash.Essentials
|
||||
messengerAdded = true;
|
||||
}
|
||||
|
||||
if (device is IHasPowerControl)
|
||||
if (device is IHasPowerControl pcDevice)
|
||||
{
|
||||
this.LogVerbose("Adding IHasPowerControlMessenger for {deviceKey}", device.Key);
|
||||
|
||||
var dev = device as PepperDash.Core.Device;
|
||||
this.LogVerbose("Adding IHasPowerControlMessenger for {deviceKey}", device.Key);
|
||||
|
||||
var messenger = new IHasPowerMessenger(
|
||||
$"{device.Key}-powerControl-{Key}",
|
||||
$"/device/{device.Key}",
|
||||
dev
|
||||
pcDevice
|
||||
);
|
||||
|
||||
AddDefaultDeviceMessenger(messenger);
|
||||
@@ -689,18 +677,16 @@ namespace PepperDash.Essentials
|
||||
messengerAdded = true;
|
||||
}
|
||||
|
||||
if (device is ITransport)
|
||||
if (device is ITransport transportDevice)
|
||||
{
|
||||
this.LogVerbose(
|
||||
"Adding ITransportMessenger for {deviceKey}", device.Key
|
||||
);
|
||||
);
|
||||
|
||||
var dev = device as PepperDash.Core.Device;
|
||||
|
||||
var messenger = new IChannelMessenger(
|
||||
var messenger = new ITransportMessenger(
|
||||
$"{device.Key}-transport-{Key}",
|
||||
$"/device/{device.Key}",
|
||||
dev
|
||||
transportDevice
|
||||
);
|
||||
|
||||
AddDefaultDeviceMessenger(messenger);
|
||||
@@ -708,14 +694,14 @@ namespace PepperDash.Essentials
|
||||
messengerAdded = true;
|
||||
}
|
||||
|
||||
if (device is IHasCurrentSourceInfoChange)
|
||||
if (device is IHasCurrentSourceInfoChange csiChange)
|
||||
{
|
||||
this.LogVerbose("Adding IHasCurrentSourceInfoMessenger for {deviceKey}", device.Key);
|
||||
|
||||
var messenger = new IHasCurrentSourceInfoMessenger(
|
||||
$"{device.Key}-currentSource-{Key}",
|
||||
$"/device/{device.Key}",
|
||||
device as IHasCurrentSourceInfoChange
|
||||
csiChange
|
||||
);
|
||||
|
||||
AddDefaultDeviceMessenger(messenger);
|
||||
@@ -723,7 +709,7 @@ namespace PepperDash.Essentials
|
||||
messengerAdded = true;
|
||||
}
|
||||
|
||||
if (device is ISwitchedOutput)
|
||||
if (device is ISwitchedOutput switchedDevice)
|
||||
{
|
||||
this.LogVerbose(
|
||||
"Adding ISwitchedOutputMessenger for {deviceKey}", device.Key
|
||||
@@ -731,7 +717,7 @@ namespace PepperDash.Essentials
|
||||
|
||||
var messenger = new ISwitchedOutputMessenger(
|
||||
$"{device.Key}-switchedOutput-{Key}",
|
||||
device as ISwitchedOutput,
|
||||
switchedDevice,
|
||||
$"/device/{device.Key}"
|
||||
);
|
||||
|
||||
@@ -773,40 +759,6 @@ namespace PepperDash.Essentials
|
||||
messengerAdded = true;
|
||||
}
|
||||
|
||||
// This will work if TKey and TSelector are both string types.
|
||||
// Otherwise plugin device needs to instantiate ISelectableItemsMessenger and add it to the controller.
|
||||
//if (device is IHasInputs<string, string> inputs)
|
||||
//{
|
||||
// this.LogVerbose("Adding InputsMessenger<string,string> for {deviceKey}", device.Key);
|
||||
|
||||
// var messenger = new ISelectableItemsMessenger<string>(
|
||||
// $"{device.Key}-inputs-{Key}",
|
||||
// $"/device/{device.Key}",
|
||||
// inputs.Inputs,
|
||||
// "inputs"
|
||||
// );
|
||||
|
||||
// AddDefaultDeviceMessenger(messenger);
|
||||
|
||||
// messengerAdded = true;
|
||||
//}
|
||||
|
||||
//if (device is IHasInputs<byte, int> byteIntInputs)
|
||||
//{
|
||||
// this.LogVerbose("Adding InputsMessenger<byte, int> for {deviceKey}", device.Key);
|
||||
|
||||
// var messenger = new ISelectableItemsMessenger<byte>(
|
||||
// $"{device.Key}-inputs-{Key}",
|
||||
// $"/device/{device.Key}",
|
||||
// byteIntInputs.Inputs,
|
||||
// "inputs"
|
||||
// );
|
||||
|
||||
// AddDefaultDeviceMessenger(messenger);
|
||||
|
||||
// messengerAdded = true;
|
||||
//}
|
||||
|
||||
if (device is IHasInputs<string> stringInputs)
|
||||
{
|
||||
this.LogVerbose("Adding InputsMessenger<string> for {deviceKey}", device.Key);
|
||||
@@ -855,7 +807,6 @@ namespace PepperDash.Essentials
|
||||
messengerAdded = true;
|
||||
}
|
||||
|
||||
|
||||
if (device is IMatrixRouting matrix)
|
||||
{
|
||||
this.LogVerbose(
|
||||
|
||||
Reference in New Issue
Block a user