mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-15 12:44:58 +00:00
Compare commits
19 Commits
v2.17.0-fe
...
feature/un
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
473c6d4590 | ||
|
|
903236d6d9 | ||
|
|
9245ac9c74 | ||
|
|
b47f1d6b77 | ||
|
|
fda4a5a816 | ||
|
|
9f70e3c721 | ||
|
|
ec6aeb17f6 | ||
|
|
91dc655103 | ||
|
|
bf31fb10eb | ||
|
|
5e21bad596 | ||
|
|
2368f0c8cc | ||
|
|
be58a0bc29 | ||
|
|
8406f69e0d | ||
|
|
116d83394a | ||
|
|
9b8e452eb4 | ||
|
|
c9d86bd5dd | ||
|
|
b2b257020f | ||
|
|
6f58e18d14 | ||
|
|
60fc0298ec |
@@ -1,14 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Crestron.SimplSharp;
|
|
||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
|
|
||||||
|
|
||||||
namespace PepperDash.Core
|
namespace PepperDash.Essentials.Core.Communications
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines the string event handler for line events on the gather
|
/// Defines the string event handler for line events on the gather
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using PepperDash.Core;
|
|
||||||
|
|
||||||
namespace PepperDash.Core
|
namespace PepperDash.Core
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Converters;
|
using Newtonsoft.Json.Converters;
|
||||||
|
|
||||||
namespace PepperDash.Core
|
namespace PepperDash.Essentials.Core.Communications
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a ControlPropertiesConfig
|
/// Represents a ControlPropertiesConfig
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace PepperDash.Essentials.Core.Communications
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
|
|
||||||
namespace PepperDash.Core
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Crestron Control Methods for a comm object
|
/// Crestron Control Methods for a comm object
|
||||||
@@ -162,7 +162,7 @@ namespace PepperDash.Core.JsonToSimpl
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static JObject ParseObject(string json)
|
public static JObject ParseObject(string json)
|
||||||
{
|
{
|
||||||
#if NET6_0
|
#if NET8_0
|
||||||
using (var reader = new JsonTextReader(new System.IO.StringReader(json)))
|
using (var reader = new JsonTextReader(new System.IO.StringReader(json)))
|
||||||
#else
|
#else
|
||||||
using (var reader = new JsonTextReader(new Crestron.SimplSharp.CrestronIO.StringReader(json)))
|
using (var reader = new JsonTextReader(new Crestron.SimplSharp.CrestronIO.StringReader(json)))
|
||||||
@@ -186,7 +186,7 @@ namespace PepperDash.Core.JsonToSimpl
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static JArray ParseArray(string json)
|
public static JArray ParseArray(string json)
|
||||||
{
|
{
|
||||||
#if NET6_0
|
#if NET8_0
|
||||||
using (var reader = new JsonTextReader(new System.IO.StringReader(json)))
|
using (var reader = new JsonTextReader(new System.IO.StringReader(json)))
|
||||||
#else
|
#else
|
||||||
using (var reader = new JsonTextReader(new Crestron.SimplSharp.CrestronIO.StringReader(json)))
|
using (var reader = new JsonTextReader(new Crestron.SimplSharp.CrestronIO.StringReader(json)))
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<RootNamespace>PepperDash.Core</RootNamespace>
|
<RootNamespace>PepperDash.Core</RootNamespace>
|
||||||
<AssemblyName>PepperDashCore</AssemblyName>
|
<AssemblyName>PepperDashCore</AssemblyName>
|
||||||
<TargetFramework>net472</TargetFramework>
|
<TargetFramework>net8</TargetFramework>
|
||||||
<Deterministic>true</Deterministic>
|
<Deterministic>true</Deterministic>
|
||||||
<NeutralLanguage>en</NeutralLanguage>
|
<NeutralLanguage>en</NeutralLanguage>
|
||||||
<OutputPath>bin\$(Configuration)\</OutputPath>
|
<OutputPath>bin\$(Configuration)\</OutputPath>
|
||||||
@@ -44,6 +44,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="BouncyCastle.Cryptography" Version="2.4.0" />
|
<PackageReference Include="BouncyCastle.Cryptography" Version="2.4.0" />
|
||||||
<PackageReference Include="Crestron.SimplSharp.SDK.Library" Version="2.21.90" />
|
<PackageReference Include="Crestron.SimplSharp.SDK.Library" Version="2.21.90" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="Serilog" Version="3.1.1" />
|
<PackageReference Include="Serilog" Version="3.1.1" />
|
||||||
<PackageReference Include="Serilog.Expressions" Version="4.0.0" />
|
<PackageReference Include="Serilog.Expressions" Version="4.0.0" />
|
||||||
<PackageReference Include="Serilog.Formatting.Compact" Version="2.0.0" />
|
<PackageReference Include="Serilog.Formatting.Compact" Version="2.0.0" />
|
||||||
@@ -52,9 +53,6 @@
|
|||||||
<PackageReference Include="SSH.NET" Version="2024.2.0" />
|
<PackageReference Include="SSH.NET" Version="2024.2.0" />
|
||||||
<PackageReference Include="WebSocketSharp" Version="1.0.3-rc11" />
|
<PackageReference Include="WebSocketSharp" Version="1.0.3-rc11" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Condition="'$(TargetFramework)' == 'net6'">
|
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Remove="Comm\._GenericSshClient.cs" />
|
<Compile Remove="Comm\._GenericSshClient.cs" />
|
||||||
<Compile Remove="Comm\._GenericTcpIpClient.cs" />
|
<Compile Remove="Comm\._GenericTcpIpClient.cs" />
|
||||||
|
|||||||
@@ -3,15 +3,16 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using System.Reflection;
|
|
||||||
using Crestron.SimplSharpPro;
|
using Crestron.SimplSharpPro;
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
using Crestron.SimplSharpPro.EthernetCommunication;
|
using Crestron.SimplSharpPro.EthernetCommunication;
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using PepperDash.Essentials.Core.Communications;
|
||||||
using PepperDash.Core;
|
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
|
using PepperDash.Essentials.Core.Devices;
|
||||||
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
|
using PepperDash.Essentials.Core.Monitoring;
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
|
|
||||||
//using PepperDash.Essentials.Devices.Common.Cameras;
|
//using PepperDash.Essentials.Devices.Common.Cameras;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using PepperDash.Core;
|
using PepperDash.Essentials.Core.Devices;
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
|
|
||||||
//using PepperDash.Essentials.Devices.Common.Cameras;
|
//using PepperDash.Essentials.Devices.Common.Cameras;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a AirMediaControllerJoinMap
|
/// Represents a AirMediaControllerJoinMap
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a AppleTvJoinMap
|
/// Represents a AppleTvJoinMap
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a C2nRthsControllerJoinMap
|
/// Represents a C2nRthsControllerJoinMap
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a CameraControllerJoinMap
|
/// Represents a CameraControllerJoinMap
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a CenOdtOccupancySensorBaseJoinMap
|
/// Represents a CenOdtOccupancySensorBaseJoinMap
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a DisplayControllerJoinMap
|
/// Represents a DisplayControllerJoinMap
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using System;
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges {
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a DmBladeChassisControllerJoinMap
|
/// Represents a DmBladeChassisControllerJoinMap
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a DmChassisControllerJoinMap
|
/// Represents a DmChassisControllerJoinMap
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a DmRmcControllerJoinMap
|
/// Represents a DmRmcControllerJoinMap
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a DmTxControllerJoinMap
|
/// Represents a DmTxControllerJoinMap
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a DmpsAudioOutputControllerJoinMap
|
/// Represents a DmpsAudioOutputControllerJoinMap
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a DmpsMicrophoneControllerJoinMap
|
/// Represents a DmpsMicrophoneControllerJoinMap
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a DmpsRoutingControllerJoinMap
|
/// Represents a DmpsRoutingControllerJoinMap
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
using System;
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a GenericLightingJoinMap
|
/// Represents a GenericLightingJoinMap
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a GenericRelayControllerJoinMap
|
/// Represents a GenericRelayControllerJoinMap
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a GlsOccupancySensorBaseJoinMap
|
/// Represents a GlsOccupancySensorBaseJoinMap
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using System;
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
using PepperDash.Essentials.Core;
|
using System;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a HdMdNxM4kEControllerJoinMap
|
/// Represents a HdMdNxM4kEControllerJoinMap
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a HdMdxxxCEControllerJoinMap
|
/// Represents a HdMdxxxCEControllerJoinMap
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using System;
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
using PepperDash.Essentials.Core;
|
using System;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a HdPsXxxControllerJoinMap
|
/// Represents a HdPsXxxControllerJoinMap
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a Hrxxx0WirelessRemoteControllerJoinMap
|
/// Represents a Hrxxx0WirelessRemoteControllerJoinMap
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a IAnalogInputJoinMap
|
/// Represents a IAnalogInputJoinMap
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a IBasicCommunicationJoinMap
|
/// Represents a IBasicCommunicationJoinMap
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a IDigitalInputJoinMap
|
/// Represents a IDigitalInputJoinMap
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a IDigitalOutputJoinMap
|
/// Represents a IDigitalOutputJoinMap
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
using System;
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
using System.Collections.Generic;
|
using System;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Join map for IRBlurayBase devices
|
/// Join map for IRBlurayBase devices
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a PduJoinMapBase
|
/// Represents a PduJoinMapBase
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
using System;
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a SetTopBoxControllerJoinMap
|
/// Represents a SetTopBoxControllerJoinMap
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a StatusSignControllerJoinMap
|
/// Represents a StatusSignControllerJoinMap
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a SystemMonitorJoinMap
|
/// Represents a SystemMonitorJoinMap
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
using System;
|
using System;
|
||||||
using PepperDash.Essentials.Core;
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
72
src/PepperDash.Essentials.Core/Bridges/SigHelper.cs
Normal file
72
src/PepperDash.Essentials.Core/Bridges/SigHelper.cs
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
using System;
|
||||||
|
using Crestron.SimplSharpPro;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.Bridges
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Helper class for various Sig events
|
||||||
|
/// </summary>
|
||||||
|
public class SigHelper
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Runs action when Sig is pressed
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sig"></param>
|
||||||
|
public static void Pressed(Sig sig, Action act) { if (sig.BoolValue) act(); }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Runs action when Sig is released
|
||||||
|
/// </summary>
|
||||||
|
public static void Released(Sig sig, Action act) { if (!sig.BoolValue) act(); }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// SetBoolOutAction method
|
||||||
|
/// </summary>
|
||||||
|
public static void SetBoolOutAction(BoolOutputSig sig, Action<bool> a)
|
||||||
|
{
|
||||||
|
if (sig != null)
|
||||||
|
sig.UserObject = a;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Safely clears action of non-null sig.
|
||||||
|
/// </summary>
|
||||||
|
public static void ClearBoolOutAction(BoolOutputSig sig)
|
||||||
|
{
|
||||||
|
if (sig != null)
|
||||||
|
sig.UserObject = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Does a timed ramp, where the time is scaled proportional to the
|
||||||
|
/// remaining range to cover
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sig">Ushort sig to scale</param>
|
||||||
|
/// <param name="newLevel">Level to go to</param>
|
||||||
|
/// <param name="time">In ms (not hundredths like Crestron Sig ramp function)</param>
|
||||||
|
/// <summary>
|
||||||
|
/// RampTimeScaled method
|
||||||
|
/// </summary>
|
||||||
|
public static void RampTimeScaled(Sig sig, ushort newLevel, uint time)
|
||||||
|
{
|
||||||
|
var level = sig.UShortValue;
|
||||||
|
var diff = Math.Abs(level - newLevel);
|
||||||
|
var scaledTime = (uint)(diff * time / 65535);
|
||||||
|
Ramp(sig, newLevel, scaledTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ramps signal
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sig"></param>
|
||||||
|
/// <param name="level"></param>
|
||||||
|
/// <param name="time">In ms (not hundredths like Crestron Sig ramp function)</param>
|
||||||
|
/// <summary>
|
||||||
|
/// Ramp method
|
||||||
|
/// </summary>
|
||||||
|
public static void Ramp(Sig sig, ushort level, uint time)
|
||||||
|
{
|
||||||
|
sig.CreateRamp(level, time / 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Crestron.SimplSharpPro;
|
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
|
|
||||||
using PepperDash.Core;
|
|
||||||
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
public interface IComPortsDevice
|
|
||||||
{
|
|
||||||
IComPorts Device { get; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Crestron.SimplSharpPro;
|
|
||||||
using Crestron.SimplSharpPro.DM;
|
using Crestron.SimplSharpPro.DM;
|
||||||
|
|
||||||
using PepperDash.Core;
|
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core.Communications
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a CecPortController
|
/// Represents a CecPortController
|
||||||
@@ -139,7 +133,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
foreach (var t in split)
|
foreach (var t in split)
|
||||||
{
|
{
|
||||||
if (t.StartsWith(@"\") && t.Length == 4)
|
if (t.StartsWith(@"\") && t.Length == 4)
|
||||||
b.Append((char)(Convert.ToByte(t.Substring(2, 2), 16)));
|
b.Append((char)Convert.ToByte(t.Substring(2, 2), 16));
|
||||||
else
|
else
|
||||||
b.Append(t);
|
b.Append(t);
|
||||||
}
|
}
|
||||||
@@ -1,16 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Crestron.SimplSharpPro;
|
using Crestron.SimplSharpPro;
|
||||||
|
|
||||||
using PepperDash.Core;
|
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core.Communications
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a ComPortController
|
/// Represents a ComPortController
|
||||||
@@ -190,11 +185,11 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
// split out hex chars and build string
|
// split out hex chars and build string
|
||||||
var split = Regex.Split(s, @"(\\[Xx][0-9a-fA-F][0-9a-fA-F])");
|
var split = Regex.Split(s, @"(\\[Xx][0-9a-fA-F][0-9a-fA-F])");
|
||||||
StringBuilder b = new StringBuilder();
|
var b = new StringBuilder();
|
||||||
foreach (var t in split)
|
foreach (var t in split)
|
||||||
{
|
{
|
||||||
if (t.StartsWith(@"\") && t.Length == 4)
|
if (t.StartsWith(@"\") && t.Length == 4)
|
||||||
b.Append((char)(Convert.ToByte(t.Substring(2, 2), 16)));
|
b.Append((char)Convert.ToByte(t.Substring(2, 2), 16));
|
||||||
else
|
else
|
||||||
b.Append(t);
|
b.Append(t);
|
||||||
}
|
}
|
||||||
@@ -1,19 +1,12 @@
|
|||||||
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Crestron.SimplSharpPro;
|
using Crestron.SimplSharpPro;
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
|
|
||||||
using PepperDash.Core;
|
|
||||||
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core.Communications
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This converter creates a proper ComPort.ComPortSpec struct from more-friendly JSON values. It uses
|
/// This converter creates a proper ComPort.ComPortSpec struct from more-friendly JSON values. It uses
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.Communications
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public class ComTextHelper
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets escaped text for a byte array
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bytes"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetEscapedText(byte[] bytes)
|
||||||
|
{
|
||||||
|
return string.Concat(bytes.Select(b => string.Format(@"[{0:X2}]", (int)b)).ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets escaped text for a string
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <summary>
|
||||||
|
/// GetEscapedText method
|
||||||
|
/// </summary>
|
||||||
|
public static string GetEscapedText(string text)
|
||||||
|
{
|
||||||
|
var bytes = Encoding.GetEncoding(28591).GetBytes(text);
|
||||||
|
return string.Concat(bytes.Select(b => string.Format(@"[{0:X2}]", (int)b)).ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets debug text for a string
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <summary>
|
||||||
|
/// GetDebugText method
|
||||||
|
/// </summary>
|
||||||
|
public static string GetDebugText(string text)
|
||||||
|
{
|
||||||
|
return Regex.Replace(text, @"[^\u0020-\u007E]", a => GetEscapedText(a.Value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,16 +1,15 @@
|
|||||||
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Crestron.SimplSharpPro;
|
using Crestron.SimplSharpPro;
|
||||||
using Crestron.SimplSharpPro.DM;
|
using Crestron.SimplSharpPro.DM;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using PepperDash.Core;
|
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
|
using PepperDash.Essentials.Core.Devices;
|
||||||
|
using PepperDash.Essentials.Core.Routing;
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core.Communications
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
@@ -147,7 +146,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
if (dev == null)
|
if (dev == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(config.ControlPortName))
|
if (string.IsNullOrEmpty(config.ControlPortName))
|
||||||
{
|
{
|
||||||
Debug.LogMessage(LogEventLevel.Information, "GetCecPort: '{0}' - Configuration missing 'ControlPortName'", config.ControlPortDevKey);
|
Debug.LogMessage(LogEventLevel.Information, "GetCecPort: '{0}' - Configuration missing 'ControlPortName'", config.ControlPortDevKey);
|
||||||
return null;
|
return null;
|
||||||
@@ -196,8 +195,8 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static IComPorts GetIComPortsDeviceFromManagedDevice(string ComPortDevKey)
|
public static IComPorts GetIComPortsDeviceFromManagedDevice(string ComPortDevKey)
|
||||||
{
|
{
|
||||||
if ((ComPortDevKey.Equals("controlSystem", System.StringComparison.OrdinalIgnoreCase)
|
if ((ComPortDevKey.Equals("controlSystem", StringComparison.OrdinalIgnoreCase)
|
||||||
|| ComPortDevKey.Equals("processor", System.StringComparison.OrdinalIgnoreCase))
|
|| ComPortDevKey.Equals("processor", StringComparison.OrdinalIgnoreCase))
|
||||||
&& Global.ControlSystem is IComPorts)
|
&& Global.ControlSystem is IComPorts)
|
||||||
return Global.ControlSystem;
|
return Global.ControlSystem;
|
||||||
else
|
else
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.Communications
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public enum eGenericCommMethodStatusChangeType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Connected
|
||||||
|
/// </summary>
|
||||||
|
Connected,
|
||||||
|
/// <summary>
|
||||||
|
/// Disconnected
|
||||||
|
/// </summary>
|
||||||
|
Disconnected
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This delegate defines handler for IBasicCommunication status changes
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="comm">Device firing the status change</param>
|
||||||
|
/// <param name="status"></param>
|
||||||
|
public delegate void GenericCommMethodStatusHandler(IBasicCommunication comm, eGenericCommMethodStatusChangeType status);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public class GenericCommMethodReceiveBytesArgs : EventArgs
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the Bytes
|
||||||
|
/// </summary>
|
||||||
|
public byte[] Bytes { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bytes"></param>
|
||||||
|
public GenericCommMethodReceiveBytesArgs(byte[] bytes)
|
||||||
|
{
|
||||||
|
Bytes = bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// S+ Constructor
|
||||||
|
/// </summary>
|
||||||
|
public GenericCommMethodReceiveBytesArgs() { }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public class GenericCommMethodReceiveTextArgs : EventArgs
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string Text { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string Delimiter { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text"></param>
|
||||||
|
public GenericCommMethodReceiveTextArgs(string text)
|
||||||
|
{
|
||||||
|
Text = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text"></param>
|
||||||
|
/// <param name="delimiter"></param>
|
||||||
|
public GenericCommMethodReceiveTextArgs(string text, string delimiter)
|
||||||
|
:this(text)
|
||||||
|
{
|
||||||
|
Delimiter = delimiter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// S+ Constructor
|
||||||
|
/// </summary>
|
||||||
|
public GenericCommMethodReceiveTextArgs() { }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,173 @@
|
|||||||
|
using System;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.Communications
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Defines the string event handler for line events on the gather
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text"></param>
|
||||||
|
public delegate void LineReceivedHandler(string text);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Attaches to IBasicCommunication as a text gather
|
||||||
|
/// </summary>
|
||||||
|
public class CommunicationGather
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Event that fires when a line is received from the IBasicCommunication source.
|
||||||
|
/// The event merely contains the text, not an EventArgs type class.
|
||||||
|
/// </summary>
|
||||||
|
public event EventHandler<GenericCommMethodReceiveTextArgs> LineReceived;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The communication port that this gathers on
|
||||||
|
/// </summary>
|
||||||
|
public ICommunicationReceiver Port { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Default false. If true, the delimiter will be included in the line output
|
||||||
|
/// events
|
||||||
|
/// </summary>
|
||||||
|
public bool IncludeDelimiter { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// For receive buffer
|
||||||
|
/// </summary>
|
||||||
|
StringBuilder ReceiveBuffer = new StringBuilder();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delimiter, like it says!
|
||||||
|
/// </summary>
|
||||||
|
char Delimiter;
|
||||||
|
|
||||||
|
string[] StringDelimiters;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor for using a char delimiter
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="port"></param>
|
||||||
|
/// <param name="delimiter"></param>
|
||||||
|
public CommunicationGather(ICommunicationReceiver port, char delimiter)
|
||||||
|
{
|
||||||
|
Port = port;
|
||||||
|
Delimiter = delimiter;
|
||||||
|
port.TextReceived += new EventHandler<GenericCommMethodReceiveTextArgs>(Port_TextReceived);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor for using a single string delimiter
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="port"></param>
|
||||||
|
/// <param name="delimiter"></param>
|
||||||
|
public CommunicationGather(ICommunicationReceiver port, string delimiter)
|
||||||
|
:this(port, new string[] { delimiter} )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor for using an array of string delimiters
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="port"></param>
|
||||||
|
/// <param name="delimiters"></param>
|
||||||
|
public CommunicationGather(ICommunicationReceiver port, string[] delimiters)
|
||||||
|
{
|
||||||
|
Port = port;
|
||||||
|
StringDelimiters = delimiters;
|
||||||
|
port.TextReceived += Port_TextReceivedStringDelimiter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stop method
|
||||||
|
/// </summary>
|
||||||
|
public void Stop()
|
||||||
|
{
|
||||||
|
Port.TextReceived -= Port_TextReceived;
|
||||||
|
Port.TextReceived -= Port_TextReceivedStringDelimiter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handler for raw data coming from port
|
||||||
|
/// </summary>
|
||||||
|
void Port_TextReceived(object sender, GenericCommMethodReceiveTextArgs args)
|
||||||
|
{
|
||||||
|
var handler = LineReceived;
|
||||||
|
if (handler != null)
|
||||||
|
{
|
||||||
|
ReceiveBuffer.Append(args.Text);
|
||||||
|
var str = ReceiveBuffer.ToString();
|
||||||
|
var lines = str.Split(Delimiter);
|
||||||
|
if (lines.Length > 0)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < lines.Length - 1; i++)
|
||||||
|
{
|
||||||
|
string strToSend = null;
|
||||||
|
if (IncludeDelimiter)
|
||||||
|
strToSend = lines[i] + Delimiter;
|
||||||
|
else
|
||||||
|
strToSend = lines[i];
|
||||||
|
handler(this, new GenericCommMethodReceiveTextArgs(strToSend));
|
||||||
|
}
|
||||||
|
ReceiveBuffer = new StringBuilder(lines[lines.Length - 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="args"></param>
|
||||||
|
void Port_TextReceivedStringDelimiter(object sender, GenericCommMethodReceiveTextArgs args)
|
||||||
|
{
|
||||||
|
var handler = LineReceived;
|
||||||
|
if (handler != null)
|
||||||
|
{
|
||||||
|
// Receive buffer should either be empty or not contain the delimiter
|
||||||
|
// If the line does not have a delimiter, append the
|
||||||
|
ReceiveBuffer.Append(args.Text);
|
||||||
|
var str = ReceiveBuffer.ToString();
|
||||||
|
|
||||||
|
// Case: Receiving DEVICE get version\x0d\0x0a+OK "value":"1234"\x0d\x0a
|
||||||
|
|
||||||
|
// RX: DEV
|
||||||
|
// Split: (1) "DEV"
|
||||||
|
// RX: I
|
||||||
|
// Split: (1) "DEVI"
|
||||||
|
// RX: CE get version
|
||||||
|
// Split: (1) "DEVICE get version"
|
||||||
|
// RX: \x0d\x0a+OK "value":"1234"\x0d\x0a
|
||||||
|
// Split: (2) DEVICE get version, +OK "value":"1234"
|
||||||
|
|
||||||
|
// Iterate the delimiters and fire an event for any matching delimiter
|
||||||
|
foreach (var delimiter in StringDelimiters)
|
||||||
|
{
|
||||||
|
var lines = Regex.Split(str, delimiter);
|
||||||
|
if (lines.Length == 1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (int i = 0; i < lines.Length - 1; i++)
|
||||||
|
{
|
||||||
|
string strToSend = null;
|
||||||
|
if (IncludeDelimiter)
|
||||||
|
strToSend = lines[i] + delimiter;
|
||||||
|
else
|
||||||
|
strToSend = lines[i];
|
||||||
|
handler(this, new GenericCommMethodReceiveTextArgs(strToSend, delimiter));
|
||||||
|
}
|
||||||
|
ReceiveBuffer = new StringBuilder(lines[lines.Length - 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deconstructor. Disconnects from port TextReceived events.
|
||||||
|
/// </summary>
|
||||||
|
~CommunicationGather()
|
||||||
|
{
|
||||||
|
Stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,182 @@
|
|||||||
|
using System;
|
||||||
|
using Crestron.SimplSharp;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.Communications
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Controls the ability to disable/enable debugging of TX/RX data sent to/from a device with a built in timer to disable
|
||||||
|
/// </summary>
|
||||||
|
public class CommunicationStreamDebugging
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Device Key that this instance configures
|
||||||
|
/// </summary>
|
||||||
|
public string ParentDeviceKey { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Timer to disable automatically if not manually disabled
|
||||||
|
/// </summary>
|
||||||
|
private CTimer DebugExpiryPeriod;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the DebugSetting
|
||||||
|
/// </summary>
|
||||||
|
public eStreamDebuggingSetting DebugSetting { get; private set; }
|
||||||
|
|
||||||
|
private uint _DebugTimeoutInMs;
|
||||||
|
private const uint _DefaultDebugTimeoutMin = 30;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Timeout in Minutes
|
||||||
|
/// </summary>
|
||||||
|
public uint DebugTimeoutMinutes
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _DebugTimeoutInMs/60000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the RxStreamDebuggingIsEnabled
|
||||||
|
/// </summary>
|
||||||
|
public bool RxStreamDebuggingIsEnabled{ get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates that transmit stream debugging is enabled
|
||||||
|
/// </summary>
|
||||||
|
public bool TxStreamDebuggingIsEnabled { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parentDeviceKey"></param>
|
||||||
|
public CommunicationStreamDebugging(string parentDeviceKey)
|
||||||
|
{
|
||||||
|
ParentDeviceKey = parentDeviceKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the debugging setting and if not setting to off, assumes the default of 30 mintues
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="setting"></param>
|
||||||
|
/// <summary>
|
||||||
|
/// SetDebuggingWithDefaultTimeout method
|
||||||
|
/// </summary>
|
||||||
|
public void SetDebuggingWithDefaultTimeout(eStreamDebuggingSetting setting)
|
||||||
|
{
|
||||||
|
if (setting == eStreamDebuggingSetting.Off)
|
||||||
|
{
|
||||||
|
DisableDebugging();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetDebuggingWithSpecificTimeout(setting, _DefaultDebugTimeoutMin);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the debugging setting for the specified number of minutes
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="setting"></param>
|
||||||
|
/// <param name="minutes"></param>
|
||||||
|
/// <summary>
|
||||||
|
/// SetDebuggingWithSpecificTimeout method
|
||||||
|
/// </summary>
|
||||||
|
public void SetDebuggingWithSpecificTimeout(eStreamDebuggingSetting setting, uint minutes)
|
||||||
|
{
|
||||||
|
if (setting == eStreamDebuggingSetting.Off)
|
||||||
|
{
|
||||||
|
DisableDebugging();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_DebugTimeoutInMs = minutes * 60000;
|
||||||
|
|
||||||
|
StopDebugTimer();
|
||||||
|
|
||||||
|
DebugExpiryPeriod = new CTimer((o) => DisableDebugging(), _DebugTimeoutInMs);
|
||||||
|
|
||||||
|
if ((setting & eStreamDebuggingSetting.Rx) == eStreamDebuggingSetting.Rx)
|
||||||
|
RxStreamDebuggingIsEnabled = true;
|
||||||
|
|
||||||
|
if ((setting & eStreamDebuggingSetting.Tx) == eStreamDebuggingSetting.Tx)
|
||||||
|
TxStreamDebuggingIsEnabled = true;
|
||||||
|
|
||||||
|
Debug.SetDeviceDebugSettings(ParentDeviceKey, setting);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Disabled debugging
|
||||||
|
/// </summary>
|
||||||
|
private void DisableDebugging()
|
||||||
|
{
|
||||||
|
StopDebugTimer();
|
||||||
|
|
||||||
|
Debug.SetDeviceDebugSettings(ParentDeviceKey, eStreamDebuggingSetting.Off);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StopDebugTimer()
|
||||||
|
{
|
||||||
|
RxStreamDebuggingIsEnabled = false;
|
||||||
|
TxStreamDebuggingIsEnabled = false;
|
||||||
|
|
||||||
|
if (DebugExpiryPeriod == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DebugExpiryPeriod.Stop();
|
||||||
|
DebugExpiryPeriod.Dispose();
|
||||||
|
DebugExpiryPeriod = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The available settings for stream debugging
|
||||||
|
/// </summary>
|
||||||
|
[Flags]
|
||||||
|
/// <summary>
|
||||||
|
/// Enumeration of eStreamDebuggingSetting values
|
||||||
|
/// </summary>
|
||||||
|
public enum eStreamDebuggingSetting
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Debug off
|
||||||
|
/// </summary>
|
||||||
|
Off = 0,
|
||||||
|
/// <summary>
|
||||||
|
/// Debug received data
|
||||||
|
/// </summary>
|
||||||
|
Rx = 1,
|
||||||
|
/// <summary>
|
||||||
|
/// Debug transmitted data
|
||||||
|
/// </summary>
|
||||||
|
Tx = 2,
|
||||||
|
/// <summary>
|
||||||
|
/// Debug both received and transmitted data
|
||||||
|
/// </summary>
|
||||||
|
Both = Rx | Tx
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The available settings for stream debugging response types
|
||||||
|
/// </summary>
|
||||||
|
[Flags]
|
||||||
|
public enum eStreamDebuggingDataTypeSettings
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Debug data in byte format
|
||||||
|
/// </summary>
|
||||||
|
Bytes = 0,
|
||||||
|
/// <summary>
|
||||||
|
/// Debug data in text format
|
||||||
|
/// </summary>
|
||||||
|
Text = 1,
|
||||||
|
/// <summary>
|
||||||
|
/// Debug data in both byte and text formats
|
||||||
|
/// </summary>
|
||||||
|
Both = Bytes | Text,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,15 +1,12 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
|
|
||||||
using PepperDash.Core;
|
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
|
using PepperDash.Essentials.Core.Devices;
|
||||||
|
using PepperDash.Essentials.Core.Monitoring;
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core.Communications
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a ConsoleCommMockDevice
|
/// Represents a ConsoleCommMockDevice
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
using System;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Converters;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.Communications
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a ControlPropertiesConfig
|
||||||
|
/// </summary>
|
||||||
|
public class ControlPropertiesConfig
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The method of control
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("method")]
|
||||||
|
[JsonConverter(typeof(StringEnumConverter))]
|
||||||
|
public eControlMethod Method { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The key of the device that contains the control port
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("controlPortDevKey", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
|
public string ControlPortDevKey { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The number of the control port on the device specified by ControlPortDevKey
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("controlPortNumber", NullValueHandling = NullValueHandling.Ignore)] // In case "null" is present in config on this value
|
||||||
|
public uint? ControlPortNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The name of the control port on the device specified by ControlPortDevKey
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("controlPortName", NullValueHandling = NullValueHandling.Ignore)] // In case "null" is present in config on this value
|
||||||
|
public string ControlPortName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Properties for ethernet based communications
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("tcpSshProperties", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
|
public TcpSshPropertiesConfig TcpSshProperties { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The filename and path for the IR file
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("irFile", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
|
public string IrFile { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The IpId of a Crestron device
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("ipId", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
|
public string IpId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Readonly uint representation of the IpId
|
||||||
|
/// </summary>
|
||||||
|
[JsonIgnore]
|
||||||
|
public uint IpIdInt { get { return Convert.ToUInt32(IpId, 16); } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Char indicating end of line
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("endOfLineChar", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
|
public char EndOfLineChar { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Defaults to Environment.NewLine;
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("endOfLineString", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
|
public string EndOfLineString { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("deviceReadyResponsePattern", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
|
public string DeviceReadyResponsePattern { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Used when communcating to programs running in VC-4
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("roomId", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
|
public string RoomId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
|
public ControlPropertiesConfig()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
247
src/PepperDash.Essentials.Core/Communications/EventArgs.cs
Normal file
247
src/PepperDash.Essentials.Core/Communications/EventArgs.cs
Normal file
@@ -0,0 +1,247 @@
|
|||||||
|
/*PepperDash Technology Corp.
|
||||||
|
Copyright: 2017
|
||||||
|
------------------------------------
|
||||||
|
***Notice of Ownership and Copyright***
|
||||||
|
The material in which this notice appears is the property of PepperDash Technology Corporation,
|
||||||
|
which claims copyright under the laws of the United States of America in the entire body of material
|
||||||
|
and in all parts thereof, regardless of the use to which it is being put. Any use, in whole or in part,
|
||||||
|
of this material by another party without the express written permission of PepperDash Technology Corporation is prohibited.
|
||||||
|
PepperDash Technology Corporation reserves all rights under applicable laws.
|
||||||
|
------------------------------------ */
|
||||||
|
using System;
|
||||||
|
using Crestron.SimplSharp.CrestronSockets;
|
||||||
|
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.Communications
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Delegate for notifying of socket status changes
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="client"></param>
|
||||||
|
public delegate void GenericSocketStatusChangeEventDelegate(ISocketStatus client);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// EventArgs class for socket status changes
|
||||||
|
/// </summary>
|
||||||
|
public class GenericSocketStatusChageEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the Client
|
||||||
|
/// </summary>
|
||||||
|
public ISocketStatus Client { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="client"></param>
|
||||||
|
public GenericSocketStatusChageEventArgs(ISocketStatus client)
|
||||||
|
{
|
||||||
|
Client = client;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// S+ Constructor
|
||||||
|
/// </summary>
|
||||||
|
public GenericSocketStatusChageEventArgs() { }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delegate for notifying of TCP Server state changes
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="state"></param>
|
||||||
|
public delegate void GenericTcpServerStateChangedEventDelegate(ServerState state);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// EventArgs class for TCP Server state changes
|
||||||
|
/// </summary>
|
||||||
|
public class GenericTcpServerStateChangedEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the State
|
||||||
|
/// </summary>
|
||||||
|
public ServerState State { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="state"></param>
|
||||||
|
public GenericTcpServerStateChangedEventArgs(ServerState state)
|
||||||
|
{
|
||||||
|
State = state;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// S+ Constructor
|
||||||
|
/// </summary>
|
||||||
|
public GenericTcpServerStateChangedEventArgs() { }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delegate for TCP Server socket status changes
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="socket"></param>
|
||||||
|
/// <param name="clientIndex"></param>
|
||||||
|
/// <param name="clientStatus"></param>
|
||||||
|
public delegate void GenericTcpServerSocketStatusChangeEventDelegate(object socket, uint clientIndex, SocketStatus clientStatus);
|
||||||
|
/// <summary>
|
||||||
|
/// EventArgs for TCP server socket status changes
|
||||||
|
/// </summary>
|
||||||
|
public class GenericTcpServerSocketStatusChangeEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public object Socket { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public uint ReceivedFromClientIndex { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public SocketStatus ClientStatus { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="socket"></param>
|
||||||
|
/// <param name="clientStatus"></param>
|
||||||
|
public GenericTcpServerSocketStatusChangeEventArgs(object socket, SocketStatus clientStatus)
|
||||||
|
{
|
||||||
|
Socket = socket;
|
||||||
|
ClientStatus = clientStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="socket"></param>
|
||||||
|
/// <param name="clientIndex"></param>
|
||||||
|
/// <param name="clientStatus"></param>
|
||||||
|
public GenericTcpServerSocketStatusChangeEventArgs(object socket, uint clientIndex, SocketStatus clientStatus)
|
||||||
|
{
|
||||||
|
Socket = socket;
|
||||||
|
ReceivedFromClientIndex = clientIndex;
|
||||||
|
ClientStatus = clientStatus;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// S+ Constructor
|
||||||
|
/// </summary>
|
||||||
|
public GenericTcpServerSocketStatusChangeEventArgs() { }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// EventArgs for TCP server com method receive text
|
||||||
|
/// </summary>
|
||||||
|
public class GenericTcpServerCommMethodReceiveTextArgs : EventArgs
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public uint ReceivedFromClientIndex { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public ushort ReceivedFromClientIndexShort
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (ushort)ReceivedFromClientIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the Text
|
||||||
|
/// </summary>
|
||||||
|
public string Text { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text"></param>
|
||||||
|
public GenericTcpServerCommMethodReceiveTextArgs(string text)
|
||||||
|
{
|
||||||
|
Text = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text"></param>
|
||||||
|
/// <param name="clientIndex"></param>
|
||||||
|
public GenericTcpServerCommMethodReceiveTextArgs(string text, uint clientIndex)
|
||||||
|
{
|
||||||
|
Text = text;
|
||||||
|
ReceivedFromClientIndex = clientIndex;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// S+ Constructor
|
||||||
|
/// </summary>
|
||||||
|
public GenericTcpServerCommMethodReceiveTextArgs() { }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// EventArgs for TCP server client ready for communication
|
||||||
|
/// </summary>
|
||||||
|
public class GenericTcpServerClientReadyForcommunicationsEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public bool IsReady;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="isReady"></param>
|
||||||
|
public GenericTcpServerClientReadyForcommunicationsEventArgs(bool isReady)
|
||||||
|
{
|
||||||
|
IsReady = isReady;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// S+ Constructor
|
||||||
|
/// </summary>
|
||||||
|
public GenericTcpServerClientReadyForcommunicationsEventArgs() { }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// EventArgs for UDP connected
|
||||||
|
/// </summary>
|
||||||
|
public class GenericUdpConnectedEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public ushort UConnected;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public bool Connected;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
|
public GenericUdpConnectedEventArgs() { }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uconnected"></param>
|
||||||
|
public GenericUdpConnectedEventArgs(ushort uconnected)
|
||||||
|
{
|
||||||
|
UConnected = uconnected;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="connected"></param>
|
||||||
|
public GenericUdpConnectedEventArgs(bool connected)
|
||||||
|
{
|
||||||
|
Connected = connected;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,19 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Crestron.SimplSharp.CrestronSockets;
|
using Crestron.SimplSharp.CrestronSockets;
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
using PepperDash.Core;
|
|
||||||
using PepperDash.Essentials.Core.Bridges;
|
using PepperDash.Essentials.Core.Bridges;
|
||||||
using PepperDash.Essentials.Core.Devices;
|
using PepperDash.Essentials.Core.Devices;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
|
using PepperDash.Essentials.Core.Bridges.JoinMaps;
|
||||||
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
|
using PepperDash.Essentials.Core.Config.Essentials;
|
||||||
|
using PepperDash.Essentials.Core.Touchpanels;
|
||||||
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core.Communications
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Serves as a generic wrapper class for all styles of IBasicCommuncation ports
|
/// Serves as a generic wrapper class for all styles of IBasicCommuncation ports
|
||||||
@@ -120,7 +120,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
if (sComm == null) return;
|
if (sComm == null) return;
|
||||||
sComm.ConnectionChange += (s, a) =>
|
sComm.ConnectionChange += (s, a) =>
|
||||||
{
|
{
|
||||||
trilist.SetUshort(joinMap.Status.JoinNumber, (ushort)(a.Client.ClientStatus));
|
trilist.SetUshort(joinMap.Status.JoinNumber, (ushort)a.Client.ClientStatus);
|
||||||
trilist.SetBool(joinMap.Connected.JoinNumber, a.Client.ClientStatus ==
|
trilist.SetBool(joinMap.Connected.JoinNumber, a.Client.ClientStatus ==
|
||||||
SocketStatus.SOCKET_STATUS_CONNECTED);
|
SocketStatus.SOCKET_STATUS_CONNECTED);
|
||||||
};
|
};
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
using Crestron.SimplSharp.Net.Http;
|
using Crestron.SimplSharp.Net.Http;
|
||||||
using PepperDash.Core;
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core.Communications
|
||||||
{
|
{
|
||||||
[Obsolete("Please use the builtin HttpClient class instead: https://learn.microsoft.com/en-us/dotnet/fundamentals/networking/http/httpclient-guidelines")]
|
[Obsolete("Please use the builtin HttpClient class instead: https://learn.microsoft.com/en-us/dotnet/fundamentals/networking/http/httpclient-guidelines")]
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -33,17 +32,17 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void SendText(string path)
|
public void SendText(string path)
|
||||||
{
|
{
|
||||||
HttpClientRequest request = new HttpClientRequest();
|
var request = new HttpClientRequest();
|
||||||
string url = string.Format("http://{0}/{1}", Client.HostName, path);
|
var url = string.Format("http://{0}/{1}", Client.HostName, path);
|
||||||
request.Url = new UrlParser(url);
|
request.Url = new UrlParser(url);
|
||||||
HttpClient.DISPATCHASYNC_ERROR error = Client.DispatchAsyncEx(request, Response, request);
|
var error = Client.DispatchAsyncEx(request, Response, request);
|
||||||
}
|
}
|
||||||
public void SendText(string format, params object[] items)
|
public void SendText(string format, params object[] items)
|
||||||
{
|
{
|
||||||
HttpClientRequest request = new HttpClientRequest();
|
var request = new HttpClientRequest();
|
||||||
string url = string.Format("http://{0}/{1}", Client.HostName, string.Format(format, items));
|
var url = string.Format("http://{0}/{1}", Client.HostName, string.Format(format, items));
|
||||||
request.Url = new UrlParser(url);
|
request.Url = new UrlParser(url);
|
||||||
HttpClient.DISPATCHASYNC_ERROR error = Client.DispatchAsyncEx(request, Response, request);
|
var error = Client.DispatchAsyncEx(request, Response, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -51,8 +50,8 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void SendTextNoResponse(string format, params object[] items)
|
public void SendTextNoResponse(string format, params object[] items)
|
||||||
{
|
{
|
||||||
HttpClientRequest request = new HttpClientRequest();
|
var request = new HttpClientRequest();
|
||||||
string url = string.Format("http://{0}/{1}", Client.HostName, string.Format(format, items));
|
var url = string.Format("http://{0}/{1}", Client.HostName, string.Format(format, items));
|
||||||
request.Url = new UrlParser(url);
|
request.Url = new UrlParser(url);
|
||||||
Client.Dispatch(request);
|
Client.Dispatch(request);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.Communications
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Describes a device that can automatically attempt to reconnect
|
||||||
|
/// </summary>
|
||||||
|
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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
namespace PepperDash.Essentials.Core.Communications
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Defines the contract for IBasicCommunication
|
||||||
|
/// </summary>
|
||||||
|
public interface IBasicCommunication : ICommunicationReceiver
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Send text to the device
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text"></param>
|
||||||
|
void SendText(string text);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Send bytes to the device
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bytes"></param>
|
||||||
|
void SendBytes(byte[] bytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
namespace PepperDash.Essentials.Core.Communications
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a device that implements IBasicCommunication and IStreamDebugging
|
||||||
|
/// </summary>
|
||||||
|
public interface IBasicCommunicationWithStreamDebugging : IBasicCommunication, IStreamDebugging
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using Crestron.SimplSharpPro;
|
||||||
|
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.Communications
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public interface IComPortsDevice
|
||||||
|
{
|
||||||
|
IComPorts Device { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
using System;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.Communications
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// An incoming communication stream
|
||||||
|
/// </summary>
|
||||||
|
public interface ICommunicationReceiver : IKeyed
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Notifies of bytes received
|
||||||
|
/// </summary>
|
||||||
|
event EventHandler<GenericCommMethodReceiveBytesArgs> BytesReceived;
|
||||||
|
/// <summary>
|
||||||
|
/// Notifies of text received
|
||||||
|
/// </summary>
|
||||||
|
event EventHandler<GenericCommMethodReceiveTextArgs> TextReceived;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates connection status
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("isConnected")]
|
||||||
|
bool IsConnected { get; }
|
||||||
|
/// <summary>
|
||||||
|
/// Connect to the device
|
||||||
|
/// </summary>
|
||||||
|
void Connect();
|
||||||
|
/// <summary>
|
||||||
|
/// Disconnect from the device
|
||||||
|
/// </summary>
|
||||||
|
void Disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,18 +1,15 @@
|
|||||||
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Crestron.SimplSharp.CrestronIO;
|
|
||||||
using Crestron.SimplSharpPro;
|
using Crestron.SimplSharpPro;
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using PepperDash.Core;
|
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
|
using PepperDash.Essentials.Core.Devices;
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core.Communications
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using Crestron.SimplSharp.CrestronSockets;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.Communications
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// For IBasicCommunication classes that have SocketStatus. GenericSshClient,
|
||||||
|
/// GenericTcpIpClient
|
||||||
|
/// </summary>
|
||||||
|
public interface ISocketStatus : IBasicCommunication
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Notifies of socket status changes
|
||||||
|
/// </summary>
|
||||||
|
event EventHandler<GenericSocketStatusChageEventArgs> ConnectionChange;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The current socket status of the client
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("clientStatus")]
|
||||||
|
[JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
|
||||||
|
SocketStatus ClientStatus { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
namespace PepperDash.Essentials.Core.Communications
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Describes a device that implements ISocketStatus and IStreamDebugging
|
||||||
|
/// </summary>
|
||||||
|
public interface ISocketStatusWithStreamDebugging : ISocketStatus, IStreamDebugging
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.Communications
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a device with stream debugging capablities
|
||||||
|
/// </summary>
|
||||||
|
public interface IStreamDebugging
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Object to enable stream debugging
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("streamDebugging")]
|
||||||
|
CommunicationStreamDebugging StreamDebugging { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.Communications
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a TcpClientConfigObject
|
||||||
|
/// </summary>
|
||||||
|
public class TcpClientConfigObject
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// TcpSsh Properties
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("control")]
|
||||||
|
public ControlPropertiesConfig Control { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Bool value for secure. Currently not implemented in TCP sockets as they are not dynamic
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("secure")]
|
||||||
|
public bool Secure { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Require a shared key that both server and client negotiate. If negotiation fails server disconnects the client
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("sharedKeyRequired")]
|
||||||
|
public bool SharedKeyRequired { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The shared key that must match on the server and client
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("sharedKey")]
|
||||||
|
public string SharedKey { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Require a heartbeat on the client/server connection that will cause the server/client to disconnect if the heartbeat is not received.
|
||||||
|
/// heartbeats do not raise received events.
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("heartbeatRequired")]
|
||||||
|
public bool HeartbeatRequired { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The interval in seconds for the heartbeat from the client. If not received client is disconnected
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("heartbeatRequiredIntervalInSeconds")]
|
||||||
|
public ushort HeartbeatRequiredIntervalInSeconds { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// HeartbeatString that will be checked against the message received. defaults to heartbeat if no string is provided.
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("heartbeatStringToMatch")]
|
||||||
|
public string HeartbeatStringToMatch { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Receive Queue size must be greater than 20 or defaults to 20
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("receiveQueueSize")]
|
||||||
|
public int ReceiveQueueSize { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
namespace PepperDash.Essentials.Core.Communications
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Tcp Server Config object with properties for a tcp server with shared key and heartbeat capabilities
|
||||||
|
/// </summary>
|
||||||
|
public class TcpServerConfigObject
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Uique key
|
||||||
|
/// </summary>
|
||||||
|
public string Key { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Max Clients that the server will allow to connect.
|
||||||
|
/// </summary>
|
||||||
|
public ushort MaxClients { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Bool value for secure. Currently not implemented in TCP sockets as they are not dynamic
|
||||||
|
/// </summary>
|
||||||
|
public bool Secure { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Port for the server to listen on
|
||||||
|
/// </summary>
|
||||||
|
public int Port { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Require a shared key that both server and client negotiate. If negotiation fails server disconnects the client
|
||||||
|
/// </summary>
|
||||||
|
public bool SharedKeyRequired { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// The shared key that must match on the server and client
|
||||||
|
/// </summary>
|
||||||
|
public string SharedKey { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Require a heartbeat on the client/server connection that will cause the server/client to disconnect if the heartbeat is not received.
|
||||||
|
/// heartbeats do not raise received events.
|
||||||
|
/// </summary>
|
||||||
|
public bool HeartbeatRequired { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// The interval in seconds for the heartbeat from the client. If not received client is disconnected
|
||||||
|
/// </summary>
|
||||||
|
public ushort HeartbeatRequiredIntervalInSeconds { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// HeartbeatString that will be checked against the message received. defaults to heartbeat if no string is provided.
|
||||||
|
/// </summary>
|
||||||
|
public string HeartbeatStringToMatch { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Client buffer size. See Crestron help. defaults to 2000 if not greater than 2000
|
||||||
|
/// </summary>
|
||||||
|
public int BufferSize { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Receive Queue size must be greater than 20 or defaults to 20
|
||||||
|
/// </summary>
|
||||||
|
public int ReceiveQueueSize { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.Communications
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a TcpSshPropertiesConfig
|
||||||
|
/// </summary>
|
||||||
|
public class TcpSshPropertiesConfig
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Address to connect to
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty(Required = Required.Always)]
|
||||||
|
public string Address { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Port to connect to
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty(Required = Required.Always)]
|
||||||
|
public int Port { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Username credential
|
||||||
|
/// </summary>
|
||||||
|
public string Username { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the Password
|
||||||
|
/// </summary>
|
||||||
|
public string Password { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Defaults to 32768
|
||||||
|
/// </summary>
|
||||||
|
public int BufferSize { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the AutoReconnect
|
||||||
|
/// </summary>
|
||||||
|
public bool AutoReconnect { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the AutoReconnectIntervalMs
|
||||||
|
/// </summary>
|
||||||
|
public int AutoReconnectIntervalMs { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Default constructor
|
||||||
|
/// </summary>
|
||||||
|
public TcpSshPropertiesConfig()
|
||||||
|
{
|
||||||
|
BufferSize = 32768;
|
||||||
|
AutoReconnect = true;
|
||||||
|
AutoReconnectIntervalMs = 5000;
|
||||||
|
Username = "";
|
||||||
|
Password = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
namespace PepperDash.Essentials.Core.Communications
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Crestron Control Methods for a comm object
|
||||||
|
/// </summary>
|
||||||
|
public enum eControlMethod
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
None = 0,
|
||||||
|
/// <summary>
|
||||||
|
/// RS232/422/485
|
||||||
|
/// </summary>
|
||||||
|
Com,
|
||||||
|
/// <summary>
|
||||||
|
/// Crestron IpId (most Crestron ethernet devices)
|
||||||
|
/// </summary>
|
||||||
|
IpId,
|
||||||
|
/// <summary>
|
||||||
|
/// Crestron IpIdTcp (HD-MD series, etc.)
|
||||||
|
/// </summary>
|
||||||
|
IpidTcp,
|
||||||
|
/// <summary>
|
||||||
|
/// Crestron IR control
|
||||||
|
/// </summary>
|
||||||
|
IR,
|
||||||
|
/// <summary>
|
||||||
|
/// SSH client
|
||||||
|
/// </summary>
|
||||||
|
Ssh,
|
||||||
|
/// <summary>
|
||||||
|
/// TCP/IP client
|
||||||
|
/// </summary>
|
||||||
|
Tcpip,
|
||||||
|
/// <summary>
|
||||||
|
/// Telnet
|
||||||
|
/// </summary>
|
||||||
|
Telnet,
|
||||||
|
/// <summary>
|
||||||
|
/// Crestnet device
|
||||||
|
/// </summary>
|
||||||
|
Cresnet,
|
||||||
|
/// <summary>
|
||||||
|
/// CEC Control, via a DM HDMI port
|
||||||
|
/// </summary>
|
||||||
|
Cec,
|
||||||
|
/// <summary>
|
||||||
|
/// UDP Server
|
||||||
|
/// </summary>
|
||||||
|
Udp,
|
||||||
|
/// <summary>
|
||||||
|
/// HTTP client
|
||||||
|
/// </summary>
|
||||||
|
Http,
|
||||||
|
/// <summary>
|
||||||
|
/// HTTPS client
|
||||||
|
/// </summary>
|
||||||
|
Https,
|
||||||
|
/// <summary>
|
||||||
|
/// Websocket client
|
||||||
|
/// </summary>
|
||||||
|
Ws,
|
||||||
|
/// <summary>
|
||||||
|
/// Secure Websocket client
|
||||||
|
/// </summary>
|
||||||
|
Wss,
|
||||||
|
/// <summary>
|
||||||
|
/// Secure TCP/IP
|
||||||
|
/// </summary>
|
||||||
|
SecureTcpIp
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,6 @@
|
|||||||
using Crestron.SimplSharpPro;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json;
|
using PepperDash.Essentials.Core.Devices;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Config
|
namespace PepperDash.Essentials.Core.Config
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using PepperDash.Essentials.Core.Devices;
|
using PepperDash.Essentials.Core.Devices;
|
||||||
|
using PepperDash.Essentials.Core.Routing;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Config
|
namespace PepperDash.Essentials.Core.Config
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,15 +1,4 @@
|
|||||||
|
namespace PepperDash.Essentials.Core.Config
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using PepperDash.Essentials.Core;
|
|
||||||
using PepperDash.Core;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Config
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a ConfigPropertiesHelpers
|
/// Represents a ConfigPropertiesHelpers
|
||||||
|
|||||||
@@ -1,15 +1,9 @@
|
|||||||
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Crestron.SimplSharp.CrestronIO;
|
|
||||||
using Crestron.SimplSharpPro;
|
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using PepperDash.Core;
|
|
||||||
using PepperDash.Essentials.Core;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Config
|
namespace PepperDash.Essentials.Core.Config
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,13 +5,10 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using Crestron.SimplSharp.CrestronIO;
|
using Crestron.SimplSharp.CrestronIO;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using PepperDash.Core;
|
|
||||||
using PepperDash.Core.Config;
|
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Config
|
namespace PepperDash.Essentials.Core.Config.Essentials
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads the ConfigObject from the file
|
/// Loads the ConfigObject from the file
|
||||||
@@ -37,7 +34,7 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
// Check for local config file first
|
// Check for local config file first
|
||||||
var filePath = Global.FilePathPrefix + ConfigWriter.LocalConfigFolder + Global.DirectorySeparator + Global.ConfigFileName;
|
var filePath = Global.FilePathPrefix + ConfigWriter.LocalConfigFolder + Global.DirectorySeparator + Global.ConfigFileName;
|
||||||
|
|
||||||
bool localConfigFound = false;
|
var localConfigFound = false;
|
||||||
|
|
||||||
Debug.LogMessage(LogEventLevel.Information, "Attempting to load Local config file: '{0}'", filePath);
|
Debug.LogMessage(LogEventLevel.Information, "Attempting to load Local config file: '{0}'", filePath);
|
||||||
|
|
||||||
@@ -113,7 +110,7 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read the file
|
// Read the file
|
||||||
using (StreamReader fs = new StreamReader(filePath))
|
using (var fs = new StreamReader(filePath))
|
||||||
{
|
{
|
||||||
Debug.LogMessage(LogEventLevel.Information, "Loading config file: '{0}'", filePath);
|
Debug.LogMessage(LogEventLevel.Information, "Loading config file: '{0}'", filePath);
|
||||||
|
|
||||||
@@ -213,7 +210,7 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
{
|
{
|
||||||
debugStringWidth = 51;
|
debugStringWidth = 51;
|
||||||
}
|
}
|
||||||
var qualifier = (filePathLength % 2 != 0)
|
var qualifier = filePathLength % 2 != 0
|
||||||
? " Using Local Config File "
|
? " Using Local Config File "
|
||||||
: " Using Local Config File ";
|
: " Using Local Config File ";
|
||||||
var bookend1 = (debugStringWidth - qualifier.Length) / 2;
|
var bookend1 = (debugStringWidth - qualifier.Length) / 2;
|
||||||
|
|||||||
@@ -1,20 +1,13 @@
|
|||||||
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using Crestron.SimplSharp.CrestronIO;
|
using Crestron.SimplSharp.CrestronIO;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using Crestron.SimplSharp.Net.Http;
|
using Crestron.SimplSharp.Net.Http;
|
||||||
using Crestron.SimplSharpPro.Diagnostics;
|
|
||||||
|
|
||||||
using PepperDash.Core;
|
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Config
|
namespace PepperDash.Essentials.Core.Config.Essentials
|
||||||
{
|
{
|
||||||
public static class ConfigUpdater
|
public static class ConfigUpdater
|
||||||
{
|
{
|
||||||
@@ -146,7 +139,7 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
{
|
{
|
||||||
Debug.LogMessage(LogEventLevel.Information, "{0} Existing files found in archive folder. Deleting.", archivedConfigFiles.Length);
|
Debug.LogMessage(LogEventLevel.Information, "{0} Existing files found in archive folder. Deleting.", archivedConfigFiles.Length);
|
||||||
|
|
||||||
for (int i = 0; i < archivedConfigFiles.Length; i++ )
|
for (var i = 0; i < archivedConfigFiles.Length; i++ )
|
||||||
{
|
{
|
||||||
var file = archivedConfigFiles[i];
|
var file = archivedConfigFiles[i];
|
||||||
Debug.LogMessage(LogEventLevel.Information, "Deleting archived file: '{0}'", file.FullName);
|
Debug.LogMessage(LogEventLevel.Information, "Deleting archived file: '{0}'", file.FullName);
|
||||||
@@ -196,7 +189,7 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
|
|
||||||
OnStatusUpdate(eUpdateStatus.RestartingProgram);
|
OnStatusUpdate(eUpdateStatus.RestartingProgram);
|
||||||
|
|
||||||
string response = string.Empty;
|
var response = string.Empty;
|
||||||
|
|
||||||
CrestronConsole.SendControlSystemCommand(string.Format("progreset -p:{0}", InitialParametersClass.ApplicationNumber), ref response);
|
CrestronConsole.SendControlSystemCommand(string.Format("progreset -p:{0}", InitialParametersClass.ApplicationNumber), ref response);
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,14 @@
|
|||||||
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using Crestron.SimplSharp.CrestronIO;
|
using Crestron.SimplSharp.CrestronIO;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using PepperDash.Core;
|
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Config
|
namespace PepperDash.Essentials.Core.Config.Essentials
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Responsible for updating config at runtime, and writing the updates out to a local file
|
/// Responsible for updating config at runtime, and writing the updates out to a local file
|
||||||
@@ -36,7 +33,7 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool UpdateDeviceProperties(string deviceKey, JToken properties)
|
public static bool UpdateDeviceProperties(string deviceKey, JToken properties)
|
||||||
{
|
{
|
||||||
bool success = false;
|
var success = false;
|
||||||
|
|
||||||
// Get the current device config
|
// Get the current device config
|
||||||
var deviceConfig = ConfigReader.ConfigObject.Devices.FirstOrDefault(d => d.Key.Equals(deviceKey));
|
var deviceConfig = ConfigReader.ConfigObject.Devices.FirstOrDefault(d => d.Key.Equals(deviceKey));
|
||||||
@@ -61,7 +58,7 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool UpdateDeviceConfig(DeviceConfig config)
|
public static bool UpdateDeviceConfig(DeviceConfig config)
|
||||||
{
|
{
|
||||||
bool success = false;
|
var success = false;
|
||||||
|
|
||||||
var deviceConfigIndex = ConfigReader.ConfigObject.Devices.FindIndex(d => d.Key.Equals(config.Key));
|
var deviceConfigIndex = ConfigReader.ConfigObject.Devices.FindIndex(d => d.Key.Equals(config.Key));
|
||||||
|
|
||||||
@@ -84,7 +81,7 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool UpdateRoomConfig(DeviceConfig config)
|
public static bool UpdateRoomConfig(DeviceConfig config)
|
||||||
{
|
{
|
||||||
bool success = false;
|
var success = false;
|
||||||
|
|
||||||
var roomConfigIndex = ConfigReader.ConfigObject.Rooms.FindIndex(d => d.Key.Equals(config.Key));
|
var roomConfigIndex = ConfigReader.ConfigObject.Rooms.FindIndex(d => d.Key.Equals(config.Key));
|
||||||
|
|
||||||
@@ -149,7 +146,7 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
{
|
{
|
||||||
if (fileLock.TryEnter())
|
if (fileLock.TryEnter())
|
||||||
{
|
{
|
||||||
using (StreamWriter sw = new StreamWriter(filePath))
|
using (var sw = new StreamWriter(filePath))
|
||||||
{
|
{
|
||||||
sw.Write(configData);
|
sw.Write(configData);
|
||||||
sw.Flush();
|
sw.Flush();
|
||||||
|
|||||||
@@ -1,15 +1,8 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
using Crestron.SimplSharp.CrestronIO;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
using PepperDash.Core;
|
namespace PepperDash.Essentials.Core.Config.Essentials
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Config
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads the ConfigObject from the file
|
/// Loads the ConfigObject from the file
|
||||||
@@ -34,12 +27,12 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
if (SystemUrl.Contains("#"))
|
if (SystemUrl.Contains("#"))
|
||||||
{
|
{
|
||||||
var result = Regex.Match(SystemUrl, @"https?:\/\/.*\/systems\/(.*)\/#.*");
|
var result = Regex.Match(SystemUrl, @"https?:\/\/.*\/systems\/(.*)\/#.*");
|
||||||
string uuid = result.Groups[1].Value;
|
var uuid = result.Groups[1].Value;
|
||||||
return uuid;
|
return uuid;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
var result = Regex.Match(SystemUrl, @"https?:\/\/.*\/systems\/(.*)\/.*");
|
var result = Regex.Match(SystemUrl, @"https?:\/\/.*\/systems\/(.*)\/.*");
|
||||||
string uuid = result.Groups[1].Value;
|
var uuid = result.Groups[1].Value;
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -56,12 +49,12 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
if (TemplateUrl.Contains("#"))
|
if (TemplateUrl.Contains("#"))
|
||||||
{
|
{
|
||||||
var result = Regex.Match(TemplateUrl, @"https?:\/\/.*\/templates\/(.*)\/#.*");
|
var result = Regex.Match(TemplateUrl, @"https?:\/\/.*\/templates\/(.*)\/#.*");
|
||||||
string uuid = result.Groups[1].Value;
|
var uuid = result.Groups[1].Value;
|
||||||
return uuid;
|
return uuid;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
var result = Regex.Match(TemplateUrl, @"https?:\/\/.*\/system-templates\/(.*)\/system-template-versions\/(.*)\/.*");
|
var result = Regex.Match(TemplateUrl, @"https?:\/\/.*\/system-templates\/(.*)\/system-template-versions\/(.*)\/.*");
|
||||||
string uuid = result.Groups[2].Value;
|
var uuid = result.Groups[2].Value;
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace PepperDash.Essentials.Core.Config
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines the contract for ILoadConfig
|
/// Defines the contract for ILoadConfig
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using PepperDash.Essentials.Core.Global;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
@@ -112,7 +113,7 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
/// The information gathered by the processor at runtime about it's NICs and their IP addresses.
|
/// The information gathered by the processor at runtime about it's NICs and their IP addresses.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("ipInfo")]
|
[JsonProperty("ipInfo")]
|
||||||
public Dictionary<short, EthernetAdapterInfo> IpInfo
|
public Dictionary<short, Core.Global.EthernetAdapterInfo> IpInfo
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace PepperDash.Essentials.Core.Config
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Config
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a SourceDevicePropertiesConfigBase
|
/// Represents a SourceDevicePropertiesConfigBase
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
using System;
|
using System.Linq;
|
||||||
using System.Linq;
|
|
||||||
using Crestron.SimplSharpPro;
|
using Crestron.SimplSharpPro;
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
using PepperDash.Core;
|
|
||||||
using PepperDash.Core.JsonStandardObjects;
|
|
||||||
using PepperDash.Essentials.Core.Bridges;
|
using PepperDash.Essentials.Core.Bridges;
|
||||||
|
using PepperDash.Essentials.Core.Devices;
|
||||||
|
using PepperDash.Essentials.Core.Feedbacks;
|
||||||
|
using PepperDash.Essentials.Core.Monitoring;
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core.Crestron
|
||||||
{
|
{
|
||||||
public abstract class CrestronGenericBaseDevice : EssentialsDevice, IOnline, IHasFeedback, ICommunicationMonitor, IUsageTracking
|
public abstract class CrestronGenericBaseDevice : EssentialsDevice, IOnline, IHasFeedback, ICommunicationMonitor, IUsageTracking
|
||||||
{
|
{
|
||||||
@@ -16,7 +16,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the Feedbacks
|
/// Gets or sets the Feedbacks
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public FeedbackCollection<Feedback> Feedbacks { get; private set; }
|
public FeedbackCollection<Feedbacks.Feedback> Feedbacks { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the IsOnline
|
/// Gets or sets the IsOnline
|
||||||
@@ -39,7 +39,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
protected CrestronGenericBaseDevice(string key, string name, GenericBase hardware)
|
protected CrestronGenericBaseDevice(string key, string name, GenericBase hardware)
|
||||||
: base(key, name)
|
: base(key, name)
|
||||||
{
|
{
|
||||||
Feedbacks = new FeedbackCollection<Feedback>();
|
Feedbacks = new FeedbackCollection<Feedbacks.Feedback>();
|
||||||
|
|
||||||
Hardware = hardware;
|
Hardware = hardware;
|
||||||
IsOnline = new BoolFeedback("IsOnlineFeedback", () => Hardware.IsOnline);
|
IsOnline = new BoolFeedback("IsOnlineFeedback", () => Hardware.IsOnline);
|
||||||
@@ -53,7 +53,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
protected CrestronGenericBaseDevice(string key, string name)
|
protected CrestronGenericBaseDevice(string key, string name)
|
||||||
: base(key, name)
|
: base(key, name)
|
||||||
{
|
{
|
||||||
Feedbacks = new FeedbackCollection<Feedback>();
|
Feedbacks = new FeedbackCollection<Feedbacks.Feedback>();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,7 +142,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// AddToFeedbackList method
|
/// AddToFeedbackList method
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void AddToFeedbackList(params Feedback[] newFbs)
|
public void AddToFeedbackList(params Feedbacks.Feedback[] newFbs)
|
||||||
{
|
{
|
||||||
foreach (var f in newFbs)
|
foreach (var f in newFbs)
|
||||||
{
|
{
|
||||||
@@ -186,8 +186,10 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public UsageTracking UsageTracker { get; set; }
|
public UsageTracking UsageTracker { get; set; }
|
||||||
|
|
||||||
|
FeedbackCollection<Feedbacks.Feedback> IHasFeedback.Feedbacks => throw new System.NotImplementedException();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class CrestronGenericBridgeableBaseDevice : CrestronGenericBaseDevice, IBridgeAdvanced
|
public abstract class CrestronGenericBridgeableBaseDevice : CrestronGenericBaseDevice, IBridgeAdvanced
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,128 +0,0 @@
|
|||||||
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;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A bridge class to cover the basic features of GenericBase hardware
|
|
||||||
/// </summary>
|
|
||||||
public class CrestronGenericBaseDevice : Device, IOnline, IHasFeedback, ICommunicationMonitor, IUsageTracking
|
|
||||||
{
|
|
||||||
public virtual GenericBase Hardware { get; protected set; }
|
|
||||||
|
|
||||||
public BoolFeedback IsOnline { get; private set; }
|
|
||||||
public BoolFeedback IsRegistered { get; private set; }
|
|
||||||
public StringFeedback IpConnectionsText { get; private set; }
|
|
||||||
|
|
||||||
public CrestronGenericBaseDevice(string key, string name, GenericBase hardware)
|
|
||||||
: base(key, name)
|
|
||||||
{
|
|
||||||
Hardware = hardware;
|
|
||||||
IsOnline = new BoolFeedback(CommonBoolCue.IsOnlineFeedback, () => Hardware.IsOnline);
|
|
||||||
IsRegistered = new BoolFeedback(new Cue("IsRegistered", 0, eCueType.Bool), () => Hardware.Registered);
|
|
||||||
IpConnectionsText = new StringFeedback(CommonStringCue.IpConnectionsText, () =>
|
|
||||||
string.Join(",", Hardware.ConnectedIpList.Select(cip => cip.DeviceIpAddress).ToArray()));
|
|
||||||
CommunicationMonitor = new CrestronGenericBaseCommunicationMonitor(this, hardware, 120000, 300000);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Make sure that overriding classes call this!
|
|
||||||
/// Registers the Crestron device, connects up to the base events, starts communication monitor
|
|
||||||
/// </summary>
|
|
||||||
public override bool CustomActivate()
|
|
||||||
{
|
|
||||||
Debug.LogMessage(LogEventLevel.Information, this, "Activating");
|
|
||||||
var response = Hardware.RegisterWithLogging(Key);
|
|
||||||
if (response != eDeviceRegistrationUnRegistrationResponse.Success)
|
|
||||||
{
|
|
||||||
<<<<<<< HEAD
|
|
||||||
Debug.LogMessage(LogEventLevel.Information, this, "ERROR: Cannot register Crestron device: {0}", response);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
Debug.LogMessage(LogEventLevel.Information, this, "ERROR: Cannot register Crestron device: {0}", response);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
>>>>>>> origin/feature/ecs-342-neil
|
|
||||||
Hardware.OnlineStatusChange += new OnlineStatusChangeEventHandler(Hardware_OnlineStatusChange);
|
|
||||||
CommunicationMonitor.Start();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This disconnects events and unregisters the base hardware device.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public override bool Deactivate()
|
|
||||||
{
|
|
||||||
CommunicationMonitor.Stop();
|
|
||||||
Hardware.OnlineStatusChange -= Hardware_OnlineStatusChange;
|
|
||||||
|
|
||||||
return Hardware.UnRegister() == eDeviceRegistrationUnRegistrationResponse.Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a list containing the Outputs that we want to expose.
|
|
||||||
/// </summary>
|
|
||||||
public virtual List<Feedback> Feedbacks
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new List<Feedback>
|
|
||||||
{
|
|
||||||
IsOnline,
|
|
||||||
IsRegistered,
|
|
||||||
IpConnectionsText
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Hardware_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args)
|
|
||||||
{
|
|
||||||
IsOnline.FireUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
#region IStatusMonitor Members
|
|
||||||
|
|
||||||
public StatusMonitorBase CommunicationMonitor { get; private set; }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region IUsageTracking Members
|
|
||||||
|
|
||||||
public UsageTracking UsageTracker { get; set; }
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
|
|
||||||
//***********************************************************************************
|
|
||||||
public class CrestronGenericBaseDeviceEventIds
|
|
||||||
{
|
|
||||||
public const uint IsOnline = 1;
|
|
||||||
public const uint IpConnectionsText =2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds logging to Register() failure
|
|
||||||
/// </summary>
|
|
||||||
public static class GenericBaseExtensions
|
|
||||||
{
|
|
||||||
public static eDeviceRegistrationUnRegistrationResponse RegisterWithLogging(this GenericBase device, string key)
|
|
||||||
{
|
|
||||||
var result = device.Register();
|
|
||||||
if (result != eDeviceRegistrationUnRegistrationResponse.Success)
|
|
||||||
{
|
|
||||||
Debug.LogMessage(LogEventLevel.Information, "Cannot register device '{0}': {1}", key, result);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,15 +2,15 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Crestron.SimplSharpPro;
|
using Crestron.SimplSharpPro;
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using PepperDash.Core;
|
|
||||||
using PepperDash.Essentials.Core.Bridges;
|
using PepperDash.Essentials.Core.Bridges;
|
||||||
|
using PepperDash.Essentials.Core.Bridges.JoinMaps;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
|
using PepperDash.Essentials.Core.Devices;
|
||||||
|
using PepperDash.Essentials.Core.Feedbacks;
|
||||||
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,15 +2,16 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Crestron.SimplSharpPro;
|
using Crestron.SimplSharpPro;
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using PepperDash.Core;
|
|
||||||
using PepperDash.Essentials.Core.Bridges;
|
using PepperDash.Essentials.Core.Bridges;
|
||||||
|
using PepperDash.Essentials.Core.Bridges.JoinMaps;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
|
using PepperDash.Essentials.Core.Devices;
|
||||||
|
using PepperDash.Essentials.Core.Feedbacks;
|
||||||
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
|
using PepperDash.Essentials.Core.Touchpanels;
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.CrestronIO
|
namespace PepperDash.Essentials.Core.CrestronIO
|
||||||
|
|||||||
@@ -2,19 +2,19 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Crestron.SimplSharpPro;
|
using Crestron.SimplSharpPro;
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
|
|
||||||
using PepperDash.Core;
|
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
using PepperDash.Essentials.Core.Bridges;
|
using PepperDash.Essentials.Core.Bridges;
|
||||||
|
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
|
using PepperDash.Essentials.Core.Devices;
|
||||||
|
using PepperDash.Essentials.Core.Bridges.JoinMaps;
|
||||||
|
using PepperDash.Essentials.Core.Feedbacks;
|
||||||
|
using PepperDash.Essentials.Core.Touchpanels;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.CrestronIO
|
namespace PepperDash.Essentials.Core.CrestronIO
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,19 +2,19 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Crestron.SimplSharpPro;
|
using Crestron.SimplSharpPro;
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
|
|
||||||
using PepperDash.Core;
|
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
using PepperDash.Essentials.Core.Bridges;
|
using PepperDash.Essentials.Core.Bridges;
|
||||||
|
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
|
using PepperDash.Essentials.Core.Feedbacks;
|
||||||
|
using PepperDash.Essentials.Core.PartitionSensor;
|
||||||
|
using PepperDash.Essentials.Core.Bridges.JoinMaps;
|
||||||
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
|
using PepperDash.Essentials.Core.Devices;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.CrestronIO
|
namespace PepperDash.Essentials.Core.CrestronIO
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,19 +2,19 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Crestron.SimplSharpPro;
|
using Crestron.SimplSharpPro;
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
|
|
||||||
using PepperDash.Core;
|
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
using PepperDash.Essentials.Core.Bridges;
|
using PepperDash.Essentials.Core.Bridges;
|
||||||
|
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
|
using PepperDash.Essentials.Core.Bridges.JoinMaps;
|
||||||
|
using PepperDash.Essentials.Core.Feedbacks;
|
||||||
|
using PepperDash.Essentials.Core.JoinMaps;
|
||||||
|
using PepperDash.Essentials.Core.Devices;
|
||||||
|
using PepperDash.Essentials.Core.Touchpanels;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.CrestronIO
|
namespace PepperDash.Essentials.Core.CrestronIO
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,4 @@
|
|||||||
using System;
|
using PepperDash.Essentials.Core.Feedbacks;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using PepperDash.Essentials.Core;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.CrestronIO
|
namespace PepperDash.Essentials.Core.CrestronIO
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
using System;
|
using PepperDash.Essentials.Core.Feedbacks;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.CrestronIO
|
namespace PepperDash.Essentials.Core.CrestronIO
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
using System;
|
using PepperDash.Essentials.Core.Feedbacks;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.CrestronIO
|
namespace PepperDash.Essentials.Core.CrestronIO
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,12 +1,7 @@
|
|||||||
using System;
|
using Crestron.SimplSharpPro;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Crestron.SimplSharpPro;
|
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core.CrestronIO
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines the contract for IHasCresnetBranches
|
/// Defines the contract for IHasCresnetBranches
|
||||||
|
|||||||
@@ -1,11 +1,4 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.CrestronIO
|
namespace PepperDash.Essentials.Core.CrestronIO
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
using System;
|
using PepperDash.Essentials.Core.Feedbacks;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
|
|
||||||
using PepperDash.Essentials.Core;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.CrestronIO
|
namespace PepperDash.Essentials.Core.CrestronIO
|
||||||
{
|
{
|
||||||
|
|||||||
306
src/PepperDash.Essentials.Core/Debug.cs
Normal file
306
src/PepperDash.Essentials.Core/Debug.cs
Normal file
@@ -0,0 +1,306 @@
|
|||||||
|
using Crestron.SimplSharp;
|
||||||
|
using Crestron.SimplSharp.CrestronIO;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Serilog;
|
||||||
|
using Serilog.Context;
|
||||||
|
using Serilog.Events;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using static Crestron.SimplSharpPro.Lighting.ZumWired.ZumNetBridgeRoom.ZumWiredRoomInterface;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Contains debug commands for use in various situations
|
||||||
|
/// </summary>
|
||||||
|
public static class Debug
|
||||||
|
{
|
||||||
|
private static readonly Dictionary<uint, LogEventLevel> _logLevels = new Dictionary<uint, LogEventLevel>()
|
||||||
|
{
|
||||||
|
{0, LogEventLevel.Information },
|
||||||
|
{3, LogEventLevel.Warning },
|
||||||
|
{4, LogEventLevel.Error },
|
||||||
|
{5, LogEventLevel.Fatal },
|
||||||
|
{1, LogEventLevel.Debug },
|
||||||
|
{2, LogEventLevel.Verbose },
|
||||||
|
};
|
||||||
|
|
||||||
|
public static void LogMessage(LogEventLevel level, string message, params object[] args)
|
||||||
|
{
|
||||||
|
Log.Write(level, message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// LogMessage method
|
||||||
|
/// </summary>
|
||||||
|
public static void LogMessage(LogEventLevel level, Exception ex, string message, params object[] args)
|
||||||
|
{
|
||||||
|
Log.Write(level, ex, message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// LogMessage method
|
||||||
|
/// </summary>
|
||||||
|
public static void LogMessage(LogEventLevel level, IKeyed keyed, string message, params object[] args)
|
||||||
|
{
|
||||||
|
using (LogContext.PushProperty("Key", keyed.Key))
|
||||||
|
{
|
||||||
|
Log.Write(level, message, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// LogMessage method
|
||||||
|
/// </summary>
|
||||||
|
public static void LogMessage(LogEventLevel level, IKeyed keyed, Exception ex, string message, params object[] args)
|
||||||
|
{
|
||||||
|
using (LogContext.PushProperty("Key", keyed.Key))
|
||||||
|
{
|
||||||
|
Log.Write(level, ex, message, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Explicit methods for logging levels
|
||||||
|
/// <summary>
|
||||||
|
/// LogVerbose method
|
||||||
|
/// </summary>
|
||||||
|
public static void LogVerbose(IKeyed keyed, string message, params object[] args)
|
||||||
|
{
|
||||||
|
using (LogContext.PushProperty("Key", keyed?.Key))
|
||||||
|
{
|
||||||
|
Log.Write(LogEventLevel.Verbose, message, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// LogVerbose method
|
||||||
|
/// </summary>
|
||||||
|
public static void LogVerbose(IKeyed keyed, Exception ex, string message, params object[] args)
|
||||||
|
{
|
||||||
|
using (LogContext.PushProperty("Key", keyed?.Key))
|
||||||
|
{
|
||||||
|
Log.Write(LogEventLevel.Verbose, ex, message, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// LogVerbose method
|
||||||
|
/// </summary>
|
||||||
|
public static void LogVerbose(string message, params object[] args)
|
||||||
|
{
|
||||||
|
Log.Write(LogEventLevel.Verbose, message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// LogVerbose method
|
||||||
|
/// </summary>
|
||||||
|
public static void LogVerbose(Exception ex, string message, params object[] args)
|
||||||
|
{
|
||||||
|
Log.Write(LogEventLevel.Verbose, ex, message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// LogDebug method
|
||||||
|
/// </summary>
|
||||||
|
public static void LogDebug(IKeyed keyed, string message, params object[] args)
|
||||||
|
{
|
||||||
|
LogMessage(LogEventLevel.Debug, keyed, message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// LogDebug method
|
||||||
|
/// </summary>
|
||||||
|
public static void LogDebug(IKeyed keyed, Exception ex, string message, params object[] args)
|
||||||
|
{
|
||||||
|
LogMessage(LogEventLevel.Debug, keyed, ex, message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// LogDebug method
|
||||||
|
/// </summary>
|
||||||
|
public static void LogDebug(string message, params object[] args)
|
||||||
|
{
|
||||||
|
Log.Debug(message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// LogDebug method
|
||||||
|
/// </summary>
|
||||||
|
public static void LogDebug(Exception ex, string message, params object[] args)
|
||||||
|
{
|
||||||
|
Log.Debug(ex, message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// LogInformation method
|
||||||
|
/// </summary>
|
||||||
|
public static void LogInformation(IKeyed keyed, string message, params object[] args)
|
||||||
|
{
|
||||||
|
LogMessage(LogEventLevel.Information, keyed, message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// LogInformation method
|
||||||
|
/// </summary>
|
||||||
|
public static void LogInformation(IKeyed keyed, Exception ex, string message, params object[] args)
|
||||||
|
{
|
||||||
|
LogMessage(LogEventLevel.Information, keyed, ex, message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// LogInformation method
|
||||||
|
/// </summary>
|
||||||
|
public static void LogInformation(string message, params object[] args)
|
||||||
|
{
|
||||||
|
Log.Information(message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// LogInformation method
|
||||||
|
/// </summary>
|
||||||
|
public static void LogInformation(Exception ex, string message, params object[] args)
|
||||||
|
{
|
||||||
|
Log.Information(ex, message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// LogWarning method
|
||||||
|
/// </summary>
|
||||||
|
public static void LogWarning(IKeyed keyed, string message, params object[] args)
|
||||||
|
{
|
||||||
|
LogMessage(LogEventLevel.Warning, keyed, message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// LogWarning method
|
||||||
|
/// </summary>
|
||||||
|
public static void LogWarning(Exception ex, IKeyed keyed, string message, params object[] args)
|
||||||
|
{
|
||||||
|
LogMessage(LogEventLevel.Warning, keyed, ex, message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// LogWarning method
|
||||||
|
/// </summary>
|
||||||
|
public static void LogWarning(string message, params object[] args)
|
||||||
|
{
|
||||||
|
LogMessage(LogEventLevel.Warning, message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// LogWarning method
|
||||||
|
/// </summary>
|
||||||
|
public static void LogWarning(Exception ex, string message, params object[] args)
|
||||||
|
{
|
||||||
|
LogMessage(LogEventLevel.Warning, ex, message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// LogError method
|
||||||
|
/// </summary>
|
||||||
|
public static void LogError(IKeyed keyed, string message, params object[] args)
|
||||||
|
{
|
||||||
|
LogMessage(LogEventLevel.Error, keyed, message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// LogError method
|
||||||
|
/// </summary>
|
||||||
|
public static void LogError(IKeyed keyed, Exception ex, string message, params object[] args)
|
||||||
|
{
|
||||||
|
LogMessage(LogEventLevel.Error, keyed, ex, message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// LogError method
|
||||||
|
/// </summary>
|
||||||
|
public static void LogError(string message, params object[] args)
|
||||||
|
{
|
||||||
|
LogMessage(LogEventLevel.Error, message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// LogError method
|
||||||
|
/// </summary>
|
||||||
|
public static void LogError(Exception ex, string message, params object[] args)
|
||||||
|
{
|
||||||
|
LogMessage(LogEventLevel.Error, ex, message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// LogFatal method
|
||||||
|
/// </summary>
|
||||||
|
public static void LogFatal(IKeyed keyed, string message, params object[] args)
|
||||||
|
{
|
||||||
|
LogMessage(LogEventLevel.Fatal, keyed, message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// LogFatal method
|
||||||
|
/// </summary>
|
||||||
|
public static void LogFatal(IKeyed keyed, Exception ex, string message, params object[] args)
|
||||||
|
{
|
||||||
|
LogMessage(LogEventLevel.Fatal, keyed, ex, message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// LogFatal method
|
||||||
|
/// </summary>
|
||||||
|
public static void LogFatal(string message, params object[] args)
|
||||||
|
{
|
||||||
|
LogMessage(LogEventLevel.Fatal, message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// LogFatal method
|
||||||
|
/// </summary>
|
||||||
|
public static void LogFatal(Exception ex, string message, params object[] args)
|
||||||
|
{
|
||||||
|
LogMessage(LogEventLevel.Fatal, ex, message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private static void LogMessage(uint level, string format, params object[] items)
|
||||||
|
{
|
||||||
|
if (!_logLevels.ContainsKey(level)) return;
|
||||||
|
|
||||||
|
var logLevel = _logLevels[level];
|
||||||
|
|
||||||
|
LogMessage(logLevel, format, items);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void LogMessage(uint level, IKeyed keyed, string format, params object[] items)
|
||||||
|
{
|
||||||
|
if (!_logLevels.ContainsKey(level)) return;
|
||||||
|
|
||||||
|
var logLevel = _logLevels[level];
|
||||||
|
|
||||||
|
LogMessage(logLevel, keyed, format, items);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enumeration of ErrorLogLevel values
|
||||||
|
/// </summary>
|
||||||
|
public enum ErrorLogLevel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Error
|
||||||
|
/// </summary>
|
||||||
|
Error,
|
||||||
|
/// <summary>
|
||||||
|
/// Warning
|
||||||
|
/// </summary>
|
||||||
|
Warning,
|
||||||
|
/// <summary>
|
||||||
|
/// Notice
|
||||||
|
/// </summary>
|
||||||
|
Notice,
|
||||||
|
/// <summary>
|
||||||
|
/// None
|
||||||
|
/// </summary>
|
||||||
|
None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,4 @@
|
|||||||
using System;
|
namespace PepperDash.Essentials.Core.DeviceInfo
|
||||||
using PepperDash.Core;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.DeviceInfo
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines the contract for IDeviceInfoProvider
|
/// Defines the contract for IDeviceInfoProvider
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using PepperDash.Core;
|
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core.Extensions;
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.DeviceInfo
|
namespace PepperDash.Essentials.Core.DeviceInfo
|
||||||
|
|||||||
199
src/PepperDash.Essentials.Core/Device.cs
Normal file
199
src/PepperDash.Essentials.Core/Device.cs
Normal file
@@ -0,0 +1,199 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core
|
||||||
|
{
|
||||||
|
//*********************************************************************************************************
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a Device
|
||||||
|
/// </summary>
|
||||||
|
public class Device : IKeyName
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Unique Key
|
||||||
|
/// </summary>
|
||||||
|
public string Key { get; protected set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the Name
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; protected set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public bool Enabled { get; protected set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A place to store reference to the original config object, if any. These values should
|
||||||
|
/// NOT be used as properties on the device as they are all publicly-settable values.
|
||||||
|
/// </summary>
|
||||||
|
//public DeviceConfig Config { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Helper method to check if Config exists
|
||||||
|
/// </summary>
|
||||||
|
//public bool HasConfig { get { return Config != null; } }
|
||||||
|
|
||||||
|
List<Action> _PreActivationActions;
|
||||||
|
List<Action> _PostActivationActions;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public static Device DefaultDevice { get { return _DefaultDevice; } }
|
||||||
|
static Device _DefaultDevice = new Device("Default", "Default");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Base constructor for all Devices.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
public Device(string key)
|
||||||
|
{
|
||||||
|
Key = key;
|
||||||
|
if (key.Contains(".")) Debug.LogMessage(LogEventLevel.Information, "WARNING: Device key should not include '.'", this);
|
||||||
|
Name = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor with key and name
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <param name="name"></param>
|
||||||
|
public Device(string key, string name) : this(key)
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//public Device(DeviceConfig config)
|
||||||
|
// : this(config.Key, config.Name)
|
||||||
|
//{
|
||||||
|
// Config = config;
|
||||||
|
//}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a pre activation action
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="act"></param>
|
||||||
|
public void AddPreActivationAction(Action act)
|
||||||
|
{
|
||||||
|
if (_PreActivationActions == null)
|
||||||
|
_PreActivationActions = new List<Action>();
|
||||||
|
_PreActivationActions.Add(act);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a post activation action
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="act"></param>
|
||||||
|
/// <summary>
|
||||||
|
/// AddPostActivationAction method
|
||||||
|
/// </summary>
|
||||||
|
public void AddPostActivationAction(Action act)
|
||||||
|
{
|
||||||
|
if (_PostActivationActions == null)
|
||||||
|
_PostActivationActions = new List<Action>();
|
||||||
|
_PostActivationActions.Add(act);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// PreActivate method
|
||||||
|
/// </summary>
|
||||||
|
public void PreActivate()
|
||||||
|
{
|
||||||
|
if (_PreActivationActions != null)
|
||||||
|
_PreActivationActions.ForEach(a =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
a.Invoke();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogMessage(e, "Error in PreActivationAction: " + e.Message, this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Activate method
|
||||||
|
/// </summary>
|
||||||
|
public bool Activate()
|
||||||
|
{
|
||||||
|
//if (_PreActivationActions != null)
|
||||||
|
// _PreActivationActions.ForEach(a => a.Invoke());
|
||||||
|
var result = CustomActivate();
|
||||||
|
//if(result && _PostActivationActions != null)
|
||||||
|
// _PostActivationActions.ForEach(a => a.Invoke());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// PostActivate method
|
||||||
|
/// </summary>
|
||||||
|
public void PostActivate()
|
||||||
|
{
|
||||||
|
if (_PostActivationActions != null)
|
||||||
|
_PostActivationActions.ForEach(a =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
a.Invoke();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogMessage(e, "Error in PostActivationAction: " + e.Message, this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called in between Pre and PostActivationActions when Activate() is called.
|
||||||
|
/// Override to provide addtitional setup when calling activation. Overriding classes
|
||||||
|
/// do not need to call base.CustomActivate()
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>true if device activated successfully.</returns>
|
||||||
|
/// <summary>
|
||||||
|
/// CustomActivate method
|
||||||
|
/// </summary>
|
||||||
|
public virtual bool CustomActivate() { return true; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Call to deactivate device - unlink events, etc. Overriding classes do not
|
||||||
|
/// need to call base.Deactivate()
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual bool Deactivate() { return true; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Call this method to start communications with a device. Overriding classes do not need to call base.Initialize()
|
||||||
|
/// </summary>
|
||||||
|
public virtual void Initialize()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Helper method to check object for bool value false and fire an Action method
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="o">Should be of type bool, others will be ignored</param>
|
||||||
|
/// <param name="a">Action to be run when o is false</param>
|
||||||
|
public void OnFalse(object o, Action a)
|
||||||
|
{
|
||||||
|
if (o is bool && !(bool)o) a();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a string representation of the object, including its key and name.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>The returned string is formatted as "{Key} - {Name}". If the <c>Name</c> property is
|
||||||
|
/// null or empty, "---" is used in place of the name.</remarks>
|
||||||
|
/// <returns>A string that represents the object, containing the key and name in the format "{Key} - {Name}".</returns>
|
||||||
|
/// <summary>
|
||||||
|
/// ToString method
|
||||||
|
/// </summary>
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return string.Format("{0} - {1}", Key, string.IsNullOrEmpty(Name) ? "---" : Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
//using System;
|
|
||||||
//using System.Collections.Generic;
|
|
||||||
//using Crestron.SimplSharpPro;
|
|
||||||
//using Crestron.SimplSharpPro.DeviceSupport;
|
|
||||||
|
|
||||||
//using PepperDash.Core;
|
|
||||||
|
|
||||||
|
|
||||||
//namespace PepperDash.Essentials.Core
|
|
||||||
//{
|
|
||||||
// public interface IPresentationSource : IKeyed
|
|
||||||
// {
|
|
||||||
// string Name { get; }
|
|
||||||
// PresentationSourceType Type { get; }
|
|
||||||
// string IconName { get; set; }
|
|
||||||
// BoolFeedback HasPowerOnFeedback { get; }
|
|
||||||
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
@@ -1,10 +1,7 @@
|
|||||||
using Crestron.SimplSharpPro;
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
using PepperDash.Essentials.Core.Touchpanels;
|
||||||
|
|
||||||
using PepperDash.Essentials.Core;
|
namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
|
||||||
using PepperDash.Essentials.Core.SmartObjects;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
using Crestron.SimplSharpPro;
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
using PepperDash.Essentials.Core.Touchpanels;
|
||||||
|
|
||||||
using PepperDash.Essentials.Core;
|
namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
|
||||||
using PepperDash.Essentials.Core.SmartObjects;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
using Crestron.SimplSharpPro;
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
using PepperDash.Essentials.Core.Touchpanels;
|
||||||
using PepperDash.Core;
|
|
||||||
using PepperDash.Essentials.Core;
|
|
||||||
using PepperDash.Essentials.Core.SmartObjects;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user