Merge pull request #176 from PepperDash/feature-2/device-control-config

Make control properties serialize & deserialize correctly
This commit is contained in:
Neil Dorin
2024-05-28 13:49:06 -06:00
committed by GitHub

View File

@@ -1,6 +1,7 @@
using System; using System;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace PepperDash.Core namespace PepperDash.Core
{ {
@@ -12,38 +13,44 @@ namespace PepperDash.Core
/// <summary> /// <summary>
/// The method of control /// The method of control
/// </summary> /// </summary>
[JsonProperty("method")]
[JsonConverter(typeof(StringEnumConverter))]
public eControlMethod Method { get; set; } public eControlMethod Method { get; set; }
/// <summary> /// <summary>
/// The key of the device that contains the control port /// The key of the device that contains the control port
/// </summary> /// </summary>
[JsonProperty("controlPortDevKey", NullValueHandling = NullValueHandling.Ignore)]
public string ControlPortDevKey { get; set; } public string ControlPortDevKey { get; set; }
/// <summary> /// <summary>
/// The number of the control port on the device specified by ControlPortDevKey /// The number of the control port on the device specified by ControlPortDevKey
/// </summary> /// </summary>
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] // In case "null" is present in config on this value [JsonProperty("controlPortNumber", NullValueHandling = NullValueHandling.Ignore)] // In case "null" is present in config on this value
public uint ControlPortNumber { get; set; } public uint? ControlPortNumber { get; set; }
/// <summary> /// <summary>
/// The name of the control port on the device specified by ControlPortDevKey /// The name of the control port on the device specified by ControlPortDevKey
/// </summary> /// </summary>
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] // In case "null" is present in config on this value [JsonProperty("controlPortName", NullValueHandling = NullValueHandling.Ignore)] // In case "null" is present in config on this value
public string ControlPortName { get; set; } public string ControlPortName { get; set; }
/// <summary> /// <summary>
/// Properties for ethernet based communications /// Properties for ethernet based communications
/// </summary> /// </summary>
[JsonProperty("tcpSshProperties", NullValueHandling = NullValueHandling.Ignore)]
public TcpSshPropertiesConfig TcpSshProperties { get; set; } public TcpSshPropertiesConfig TcpSshProperties { get; set; }
/// <summary> /// <summary>
/// The filename and path for the IR file /// The filename and path for the IR file
/// </summary> /// </summary>
[JsonProperty("irFile", NullValueHandling = NullValueHandling.Ignore)]
public string IrFile { get; set; } public string IrFile { get; set; }
/// <summary> /// <summary>
/// The IpId of a Crestron device /// The IpId of a Crestron device
/// </summary> /// </summary>
[JsonProperty("ipId", NullValueHandling = NullValueHandling.Ignore)]
public string IpId { get; set; } public string IpId { get; set; }
/// <summary> /// <summary>
@@ -55,21 +62,25 @@ namespace PepperDash.Core
/// <summary> /// <summary>
/// Char indicating end of line /// Char indicating end of line
/// </summary> /// </summary>
[JsonProperty("endOfLineChar", NullValueHandling = NullValueHandling.Ignore)]
public char EndOfLineChar { get; set; } public char EndOfLineChar { get; set; }
/// <summary> /// <summary>
/// Defaults to Environment.NewLine; /// Defaults to Environment.NewLine;
/// </summary> /// </summary>
[JsonProperty("endOfLineString", NullValueHandling = NullValueHandling.Ignore)]
public string EndOfLineString { get; set; } public string EndOfLineString { get; set; }
/// <summary> /// <summary>
/// Indicates /// Indicates
/// </summary> /// </summary>
[JsonProperty("deviceReadyResponsePattern", NullValueHandling = NullValueHandling.Ignore)]
public string DeviceReadyResponsePattern { get; set; } public string DeviceReadyResponsePattern { get; set; }
/// <summary> /// <summary>
/// Used when communcating to programs running in VC-4 /// Used when communcating to programs running in VC-4
/// </summary> /// </summary>
[JsonProperty("roomId", NullValueHandling = NullValueHandling.Ignore)]
public string RoomId { get; set; } public string RoomId { get; set; }
/// <summary> /// <summary>
@@ -77,7 +88,6 @@ namespace PepperDash.Core
/// </summary> /// </summary>
public ControlPropertiesConfig() public ControlPropertiesConfig()
{ {
EndOfLineString = CrestronEnvironment.NewLine;
} }
} }
} }