Skip to content

Commit

Permalink
Merge pull request #184 from PepperDash/feature-2/device-ikeyed-ikeyn…
Browse files Browse the repository at this point in the history
…ame-updates

IKeyName changes/updates
  • Loading branch information
andrew-welker authored Mar 5, 2025
2 parents 0454410 + 23d15a1 commit 51ad2e2
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/CommunicationExtras.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronSockets;
using System.Text.RegularExpressions;
using Newtonsoft.Json;

namespace PepperDash.Core
{
Expand All @@ -25,6 +26,7 @@ public interface ICommunicationReceiver : IKeyed
/// <summary>
/// Indicates connection status
/// </summary>
[JsonProperty("isConnected")]
bool IsConnected { get; }
/// <summary>
/// Connect to the device
Expand Down Expand Up @@ -70,6 +72,7 @@ public interface IStreamDebugging
/// <summary>
/// Object to enable stream debugging
/// </summary>
[JsonProperty("streamDebugging")]
CommunicationStreamDebugging StreamDebugging { get; }
}

Expand All @@ -87,7 +90,9 @@ public interface ISocketStatus : IBasicCommunication
/// <summary>
/// The current socket status of the client
/// </summary>
SocketStatus ClientStatus { get; }
[JsonProperty("clinetStatus")]
[JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
SocketStatus ClientStatus { get; }
}

/// <summary>
Expand All @@ -106,10 +111,12 @@ public interface IAutoReconnect
/// <summary>
/// Enable automatic recconnect
/// </summary>
[JsonProperty("autoReconnect")]
bool AutoReconnect { get; set; }
/// <summary>
/// Interval in ms to attempt automatic recconnections
/// </summary>
[JsonProperty("autoReconnectIntervalMs")]
int AutoReconnectIntervalMs { get; set; }
}

Expand Down
3 changes: 3 additions & 0 deletions src/CoreInterfaces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Newtonsoft.Json;
using Serilog;

namespace PepperDash.Core
Expand All @@ -15,6 +16,7 @@ public interface IKeyed
/// <summary>
/// Unique Key
/// </summary>
[JsonProperty("key")]
string Key { get; }
}

Expand All @@ -26,6 +28,7 @@ public interface IKeyName : IKeyed
/// <summary>
/// Isn't it obvious :)
/// </summary>
[JsonProperty("name")]
string Name { get; }
}

Expand Down
21 changes: 19 additions & 2 deletions src/Device.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,15 @@ public void AddPostActivationAction(Action act)
public void PreActivate()
{
if (_PreActivationActions != null)
_PreActivationActions.ForEach(a => a.Invoke());
_PreActivationActions.ForEach(a => {
try
{
a.Invoke();
} catch (Exception e)
{
Debug.LogMessage(e, "Error in PreActivationAction: " + e.Message, this);
}
});
}

/// <summary>
Expand All @@ -123,7 +131,16 @@ public bool Activate()
public void PostActivate()
{
if (_PostActivationActions != null)
_PostActivationActions.ForEach(a => a.Invoke());
_PostActivationActions.ForEach(a => {
try
{
a.Invoke();
}
catch (Exception e)
{
Debug.LogMessage(e, "Error in PostActivationAction: " + e.Message, this);
}
});
}

/// <summary>
Expand Down
8 changes: 8 additions & 0 deletions src/PepperDash.Core.4Series.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
<DebugType>pdbonly</DebugType>
<DocumentationFile>bin\4Series\$(Configuration)\PepperDashCore.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Compile Remove="lib\**" />
<Compile Remove="Properties\**" />
<EmbeddedResource Remove="lib\**" />
<EmbeddedResource Remove="Properties\**" />
<None Remove="lib\**" />
<None Remove="Properties\**" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand Down

0 comments on commit 51ad2e2

Please sign in to comment.