Skip to content

Commit

Permalink
Merge pull request #1191 from PepperDash/feature-2.0.0/fix-touchpanel…
Browse files Browse the repository at this point in the history
…-config

Add JSON Props & Control Config
  • Loading branch information
ndorin authored May 28, 2024
2 parents a8c36ba + 0bef5d4 commit 16d32bc
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ public class ComSpecJsonConverter : JsonConverter
{
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
if (objectType == typeof(ComPort.ComPortSpec))
if (objectType == typeof(ComPort.ComPortSpec?))
{
var newSer = new JsonSerializer();
newSer.Converters.Add(new ComSpecPropsJsonConverter());
newSer.ObjectCreationHandling = ObjectCreationHandling.Replace;
return newSer.Deserialize<ComPort.ComPortSpec>(reader);
return newSer.Deserialize<ComPort.ComPortSpec?>(reader);
}
return null;
}
Expand All @@ -38,7 +38,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
/// </summary>
public override bool CanConvert(Type objectType)
{
return objectType == typeof(ComPort.ComPortSpec);
return objectType == typeof(ComPort.ComPortSpec?);
}

public override bool CanRead { get { return true; } }
Expand Down
19 changes: 12 additions & 7 deletions src/PepperDash.Essentials.Core/Comm and IR/CommFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static IBasicCommunication CreateCommForDevice(DeviceConfig deviceConfig)
switch (controlConfig.Method)
{
case eControlMethod.Com:
comm = new ComPortController(deviceConfig.Key + "-com", GetComPort, controlConfig.ComParams, controlConfig);
comm = new ComPortController(deviceConfig.Key + "-com", GetComPort, controlConfig.ComParams.Value, controlConfig);
break;
case eControlMethod.Cec:
comm = new CecPortController(deviceConfig.Key + "-cec", GetCecPort, controlConfig);
Expand Down Expand Up @@ -115,7 +115,7 @@ public static ComPort GetComPort(EssentialsControlPropertiesConfig config)
var comPar = config.ComParams;
var dev = GetIComPortsDeviceFromManagedDevice(config.ControlPortDevKey);
if (dev != null && config.ControlPortNumber <= dev.NumberOfComPorts)
return dev.ComPorts[config.ControlPortNumber];
return dev.ComPorts[config.ControlPortNumber.Value];
Debug.LogMessage(LogEventLevel.Information, "GetComPort: Device '{0}' does not have com port {1}", config.ControlPortDevKey, config.ControlPortNumber);
return null;
}
Expand Down Expand Up @@ -201,23 +201,26 @@ public static IComPorts GetIComPortsDeviceFromManagedDevice(string ComPortDevKey
/// <summary>
///
/// </summary>
public class EssentialsControlPropertiesConfig :
PepperDash.Core.ControlPropertiesConfig
public class EssentialsControlPropertiesConfig :
ControlPropertiesConfig
{

[JsonProperty("comParams", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(ComSpecJsonConverter))]
public ComPort.ComPortSpec ComParams { get; set; }
public ComPort.ComPortSpec? ComParams { get; set; }

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
try
{
return Convert.ToUInt32(CresnetId, 16);
}
Expand All @@ -228,11 +231,13 @@ public uint CresnetIdInt
}
}

[JsonProperty("infinetId", NullValueHandling = NullValueHandling.Ignore)]
public string InfinetId { get; set; }

/// <summary>
/// Attepmts to provide uiont conversion of string InifinetId
/// </summary>
[JsonIgnore]
public uint InfinetIdInt
{
get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Crestron.SimplSharp.SDK.ProgramLibrary" Version="2.20.66" />
<PackageReference Include="PepperDashCore" Version="2.0.0-beta-418" />
<PackageReference Include="PepperDashCore" Version="2.0.0-beta-423" />
</ItemGroup>
<ItemGroup>
<None Include="Crestron\CrestronGenericBaseDevice.cs.orig" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,74 @@
namespace PepperDash.Essentials.Core
using Newtonsoft.Json;

namespace PepperDash.Essentials.Core
{
public class CrestronTouchpanelPropertiesConfig
{
[JsonProperty("control")]
public EssentialsControlPropertiesConfig ControlProperties { get; set; }

[JsonProperty("ipId", NullValueHandling = NullValueHandling.Ignore)]
public string IpId { get; set; }

[JsonProperty("defaultRoomKey", NullValueHandling = NullValueHandling.Ignore)]
public string DefaultRoomKey { get; set; }

[JsonProperty("roomListKey", NullValueHandling = NullValueHandling.Ignore)]
public string RoomListKey { get; set; }

[JsonProperty("sgdFile", NullValueHandling = NullValueHandling.Ignore)]
public string SgdFile { get; set; }

[JsonProperty("projectName", NullValueHandling = NullValueHandling.Ignore)]
public string ProjectName { get; set; }
public bool ShowVolumeGauge { get; set; }
public bool UsesSplashPage { get; set; }
public bool ShowDate { get; set; }
public bool ShowTime { get; set; }

[JsonProperty("showVolumeGauge", NullValueHandling = NullValueHandling.Ignore)]
public bool? ShowVolumeGauge { get; set; }

[JsonProperty("usesSplashPage", NullValueHandling = NullValueHandling.Ignore)]
public bool? UsesSplashPage { get; set; }

[JsonProperty("showDate", NullValueHandling = NullValueHandling.Ignore)]
public bool? ShowDate { get; set; }

[JsonProperty("showTime", NullValueHandling = NullValueHandling.Ignore)]
public bool? ShowTime { get; set; }

[JsonProperty("setup", NullValueHandling = NullValueHandling.Ignore)]
public UiSetupPropertiesConfig Setup { get; set; }

[JsonProperty("headerStyle", NullValueHandling = NullValueHandling.Ignore)]
public string HeaderStyle { get; set; }
public bool IncludeInFusionRoomHealth { get; set; }
public uint ScreenSaverTimeoutMin { get; set; }
public uint ScreenSaverMovePositionIntervalMs { get; set; }

[JsonProperty("includeInFusionRoomHealth", NullValueHandling = NullValueHandling.Ignore)]
public bool? IncludeInFusionRoomHealth { get; set; }

[JsonProperty("screenSaverTimeoutMin", NullValueHandling = NullValueHandling.Ignore)]
public uint? ScreenSaverTimeoutMin { get; set; }

[JsonProperty("screenSaverMovePositionIntervalMs", NullValueHandling = NullValueHandling.Ignore)]
public uint? ScreenSaverMovePositionIntervalMs { get; set; }


/// <summary>
/// The count of sources that will trigger the "additional" arrows to show on the SRL.
/// Defaults to 5
/// </summary>
public int SourcesOverflowCount { get; set; }
[JsonProperty("sourcesOverflowCount", NullValueHandling = NullValueHandling.Ignore)]
public int? SourcesOverflowCount { get; set; }

public CrestronTouchpanelPropertiesConfig() : this(false) { }

public CrestronTouchpanelPropertiesConfig()
public CrestronTouchpanelPropertiesConfig(bool setDefaultValues = false)
{
if(!setDefaultValues) { return; }
SourcesOverflowCount = 5;
HeaderStyle = CrestronTouchpanelPropertiesConfig.Habanero;
HeaderStyle = Habanero;

// Default values
ScreenSaverTimeoutMin = 5;
ScreenSaverMovePositionIntervalMs = 15000;
}
}

/// <summary>
/// "habanero"
Expand All @@ -49,6 +85,7 @@ public CrestronTouchpanelPropertiesConfig()
/// </summary>
public class UiSetupPropertiesConfig
{
[JsonProperty("isVisible", NullValueHandling = NullValueHandling.Ignore)]
public bool IsVisible { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Crestron.SimplSharp.SDK.ProgramLibrary" Version="2.20.66" />
<PackageReference Include="PepperDashCore" Version="2.0.0-beta-418" />
<PackageReference Include="PepperDashCore" Version="2.0.0-beta-423" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/PepperDash.Essentials/PepperDash.Essentials.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Crestron.SimplSharp.SDK.Program" Version="2.20.66" />
<PackageReference Include="PepperDashCore" Version="2.0.0-beta-418" />
<PackageReference Include="PepperDashCore" Version="2.0.0-beta-423" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PepperDash.Essentials.Core\PepperDash.Essentials.Core.csproj" />
Expand Down

0 comments on commit 16d32bc

Please sign in to comment.