Compare commits

..

2 Commits

Author SHA1 Message Date
Andrew Welker
2f3babef91 build(force-patch): add props to package with Essentials version 2025-04-30 11:01:10 -05:00
Andrew Welker
ec1b99498a feat: set base MinimumEssentialsFrameworkVersion to Essentials version 2025-04-30 09:51:55 -05:00
544 changed files with 2381 additions and 12415 deletions

4
.gitignore vendored
View File

@@ -393,6 +393,4 @@ essentials-framework/Essentials Interfaces/PepperDash_Essentials_Interfaces/Pepp
/._PepperDash.Essentials.sln
.vscode/settings.json
_site/
api/
*.DS_Store
/._PepperDash.Essentials.4Series.sln
api/

View File

@@ -1,9 +0,0 @@
{
"recommendations": [
"ms-dotnettools.vscode-dotnet-runtime",
"ms-dotnettools.csharp",
"ms-dotnettools.csdevkit",
"vivaxy.vscode-conventional-commits",
"mhutchie.git-graph"
]
}

View File

@@ -1,282 +0,0 @@
# Crestron Library Usage Analysis - PepperDash Essentials
This document provides a comprehensive analysis of Crestron classes and interfaces used throughout the PepperDash Essentials framework, organized by namespace and library component.
## Executive Summary
The PepperDash Essentials framework extensively leverages Crestron SDK components across 100+ files, providing abstractions for:
- Control system hardware (processors, touchpanels, IO devices)
- Communication interfaces (Serial, TCP/IP, SSH, CEC, IR)
- Device management and routing
- User interface components and smart objects
- System monitoring and diagnostics
## 1. Core Crestron Libraries
### 1.1 Crestron.SimplSharp
**Primary Usage**: Foundational framework components, collections, and basic types.
**Key Files**:
- Multiple files across all projects use `Crestron.SimplSharp` namespaces
- Provides basic C# runtime support for Crestron processors
### 1.2 Crestron.SimplSharpPro
**Primary Usage**: Main hardware abstraction layer for Crestron devices.
**Key Classes Used**:
#### CrestronControlSystem
- **File**: `/src/PepperDash.Essentials/ControlSystem.cs`
- **Usage**: Base class for the main control system implementation
- **Implementation**: `public class ControlSystem : CrestronControlSystem, ILoadConfig`
#### Device (Base Class)
- **Files**: 50+ files inherit from or use this class
- **Key Implementations**:
- `/src/PepperDash.Core/Device.cs` - Core device abstraction
- `/src/PepperDash.Essentials.Core/Devices/EssentialsDevice.cs` - Extended device base
- `/src/PepperDash.Essentials.Core/Room/Room.cs` - Room device implementation
- `/src/PepperDash.Essentials.Core/Devices/CrestronProcessor.cs` - Processor device wrapper
#### BasicTriList
- **Files**: 30+ files use this class extensively
- **Primary Usage**: Touchpanel communication and SIMPL bridging
- **Key Files**:
- `/src/PepperDash.Essentials.Core/Touchpanels/TriListExtensions.cs` - Extension methods for signal handling
- `/src/PepperDash.Essentials.Core/Devices/EssentialsBridgeableDevice.cs` - Bridge interface
- `/src/PepperDash.Essentials.Core/Touchpanels/ModalDialog.cs` - UI dialog implementation
#### BasicTriListWithSmartObject
- **Files**: Multiple touchpanel and UI files
- **Usage**: Enhanced touchpanel support with smart object integration
- **Key Files**:
- `/src/PepperDash.Essentials.Core/Touchpanels/Interfaces.cs` - Interface definitions
- `/src/PepperDash.Essentials.Core/SmartObjects/SubpageReferenceList/SubpageReferenceList.cs`
## 2. Communication Hardware
### 2.1 Serial Communication (ComPort)
**Primary Class**: `ComPort`
**Key Files**:
- `/src/PepperDash.Essentials.Core/Comm and IR/ComPortController.cs`
- `/src/PepperDash.Essentials.Core/Comm and IR/CommFactory.cs`
**Usage Pattern**:
```csharp
public class ComPortController : Device, IBasicCommunicationWithStreamDebugging
public static ComPort GetComPort(EssentialsControlPropertiesConfig config)
```
**Interface Support**: `IComPorts` - Used for devices that provide multiple COM ports
### 2.2 IR Communication (IROutputPort)
**Primary Class**: `IROutputPort`
**Key Files**:
- `/src/PepperDash.Essentials.Core/Devices/IrOutputPortController.cs`
- `/src/PepperDash.Essentials.Core/Devices/GenericIRController.cs`
- `/src/PepperDash.Essentials.Core/Comm and IR/IRPortHelper.cs`
**Usage Pattern**:
```csharp
public class IrOutputPortController : Device
IROutputPort IrPort;
public IrOutputPortController(string key, IROutputPort port, string irDriverFilepath)
```
### 2.3 CEC Communication (ICec)
**Primary Interface**: `ICec`
**Key Files**:
- `/src/PepperDash.Essentials.Core/Comm and IR/CecPortController.cs`
- `/src/PepperDash.Essentials.Core/Comm and IR/CommFactory.cs`
**Usage Pattern**:
```csharp
public class CecPortController : Device, IBasicCommunicationWithStreamDebugging
public static ICec GetCecPort(ControlPropertiesConfig config)
```
## 3. Input/Output Hardware
### 3.1 Digital Input
**Primary Interface**: `IDigitalInput`
**Key Files**:
- `/src/PepperDash.Essentials.Core/CrestronIO/GenericDigitalInputDevice.cs`
- `/src/PepperDash.Essentials.Core/Microphone Privacy/MicrophonePrivacyController.cs`
**Usage Pattern**:
```csharp
public List<IDigitalInput> Inputs { get; private set; }
void AddInput(IDigitalInput input)
```
### 3.2 Versiport Support
**Key Files**:
- `/src/PepperDash.Essentials.Core/CrestronIO/GenericVersiportInputDevice.cs`
- `/src/PepperDash.Essentials.Core/CrestronIO/GenericVersiportAnalogInputDevice.cs`
- `/src/PepperDash.Essentials.Core/CrestronIO/GenericVersiportOutputDevice.cs`
**Usage**: Provides flexible I/O port configuration for various signal types
## 4. Touchpanel Hardware
### 4.1 MPC3 Touchpanel
**Primary Class**: `MPC3Basic`
**Key File**: `/src/PepperDash.Essentials.Core/Touchpanels/Mpc3Touchpanel.cs`
**Usage Pattern**:
```csharp
public class Mpc3TouchpanelController : Device
readonly MPC3Basic _touchpanel;
_touchpanel = processor.ControllerTouchScreenSlotDevice as MPC3Basic;
```
### 4.2 TSW Series Support
**Evidence**: References found in messenger files and mobile control components
**Usage**: Integrated through mobile control messaging system for TSW touchpanel features
## 5. Timer and Threading
### 5.1 CTimer
**Primary Class**: `CTimer`
**Key File**: `/src/PepperDash.Core/PasswordManagement/PasswordManager.cs`
**Usage Pattern**:
```csharp
Debug.Console(1, string.Format("PasswordManager.UpdatePassword: CTimer Started"));
Debug.Console(1, string.Format("PasswordManager.UpdatePassword: CTimer Reset"));
```
## 6. Networking and Communication
### 6.1 Ethernet Communication
**Libraries Used**:
- `Crestron.SimplSharpPro.EthernetCommunication`
- `Crestron.SimplSharp.Net.Utilities.EthernetHelper`
**Key Files**:
- `/src/PepperDash.Core/Comm/GenericTcpIpClient.cs`
- `/src/PepperDash.Core/Comm/GenericTcpIpServer.cs`
- `/src/PepperDash.Core/Comm/GenericSecureTcpIpClient.cs`
- `/src/PepperDash.Core/Comm/GenericSshClient.cs`
- `/src/PepperDash.Core/Comm/GenericUdpServer.cs`
**Usage Pattern**:
```csharp
public class GenericTcpIpClient : Device, ISocketStatusWithStreamDebugging, IAutoReconnect
public class GenericSecureTcpIpClient : Device, ISocketStatusWithStreamDebugging, IAutoReconnect
```
## 7. Device Management Libraries
### 7.1 DeviceSupport
**Library**: `Crestron.SimplSharpPro.DeviceSupport`
**Usage**: Core device support infrastructure used throughout the framework
### 7.2 DM (DigitalMedia)
**Library**: `Crestron.SimplSharpPro.DM`
**Usage**: Digital media routing and switching support
**Evidence**: Found in routing configuration and DM output card references
## 8. User Interface Libraries
### 8.1 UI Components
**Library**: `Crestron.SimplSharpPro.UI`
**Usage**: User interface elements and touchpanel controls
### 8.2 Smart Objects
**Key Files**:
- `/src/PepperDash.Essentials.Core/SmartObjects/SmartObjectDynamicList.cs`
- `/src/PepperDash.Essentials.Core/SmartObjects/SubpageReferenceList/SubpageReferenceList.cs`
**Usage**: Advanced UI components with dynamic content
## 9. System Monitoring and Diagnostics
### 9.1 Diagnostics
**Library**: `Crestron.SimplSharpPro.Diagnostics`
**Usage**: System health monitoring and performance tracking
### 9.2 System Information
**Key Files**:
- `/src/PepperDash.Essentials.Core/Monitoring/SystemMonitorController.cs`
**Usage**: Provides system status, Ethernet information, and program details
## 10. Integration Patterns
### 10.1 SIMPL Bridging
**Pattern**: Extensive use of `BasicTriList` for SIMPL integration
**Files**: Bridge classes throughout the framework implement `LinkToApi` methods:
```csharp
public abstract void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge);
```
### 10.2 Device Factory Pattern
**Implementation**: Factory classes create hardware-specific implementations
**Example**: `CommFactory.cs` provides communication device creation
### 10.3 Extension Methods
**Pattern**: Extensive use of extension methods for Crestron classes
**Example**: `TriListExtensions.cs` adds 30+ extension methods to `BasicTriList`
## 11. Signal Processing
### 11.1 Signal Types
**Bool Signals**: Digital control and feedback
**UShort Signals**: Analog values and numeric data
**String Signals**: Text and configuration data
**Implementation**: Comprehensive signal handling in `TriListExtensions.cs`
## 12. Error Handling and Logging
**Pattern**: Consistent use of Crestron's Debug logging throughout
**Examples**:
```csharp
Debug.LogMessage(LogEventLevel.Information, "Device {0} is not a valid device", dc.PortDeviceKey);
Debug.LogMessage(LogEventLevel.Debug, "Error Waking Panel. Maybe testing with Xpanel?");
```
## 13. Threading and Synchronization
**Components**:
- CTimer for time-based operations
- Thread-safe collections and patterns
- Event-driven programming models
## Conclusion
The PepperDash Essentials framework demonstrates sophisticated integration with the Crestron ecosystem, leveraging:
- **Core Infrastructure**: CrestronControlSystem, Device base classes
- **Communication**: COM, IR, CEC, TCP/IP, SSH protocols
- **Hardware Abstraction**: Touchpanels, I/O devices, processors
- **User Interface**: Smart objects, signal processing, SIMPL bridging
- **System Services**: Monitoring, diagnostics, device management
This analysis shows that Essentials serves as a comprehensive middleware layer, abstracting Crestron hardware complexities while providing modern software development patterns and practices.
---
*Generated: [Current Date]*
*Framework Version: PepperDash Essentials (Based on codebase analysis)*

View File

@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>2.15.1-local</Version>
<Version>2.4.0-local</Version>
<InformationalVersion>$(Version)</InformationalVersion>
<Authors>PepperDash Technology</Authors>
<Company>PepperDash Technology</Company>
@@ -19,5 +19,6 @@
<ItemGroup>
<None Include="..\..\LICENSE.md" Pack="true" PackagePath=""/>
<None Include="..\..\README.md" Pack="true" PackagePath=""/>
<None Include=".\build\**" Pack="true" PackagePath="build"/>
</ItemGroup>
</Project>

View File

@@ -84,9 +84,10 @@ namespace PepperDash.Core
port.TextReceived += Port_TextReceivedStringDelimiter;
}
/// <summary>
/// Stop method
/// </summary>
/// <summary>
/// Disconnects this gather from the Port's TextReceived event. This will not fire LineReceived
/// after the this call.
/// </summary>
public void Stop()
{
Port.TextReceived -= Port_TextReceived;

View File

@@ -23,7 +23,7 @@ namespace PepperDash.Core
private CTimer DebugExpiryPeriod;
/// <summary>
/// Gets or sets the DebugSetting
/// The current debug setting
/// </summary>
public eStreamDebuggingSetting DebugSetting { get; private set; }
@@ -42,7 +42,7 @@ namespace PepperDash.Core
}
/// <summary>
/// Gets or sets the RxStreamDebuggingIsEnabled
/// Indicates that receive stream debugging is enabled
/// </summary>
public bool RxStreamDebuggingIsEnabled{ get; private set; }
@@ -65,9 +65,6 @@ namespace PepperDash.Core
/// 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)
@@ -84,9 +81,6 @@ namespace PepperDash.Core
/// </summary>
/// <param name="setting"></param>
/// <param name="minutes"></param>
/// <summary>
/// SetDebuggingWithSpecificTimeout method
/// </summary>
public void SetDebuggingWithSpecificTimeout(eStreamDebuggingSetting setting, uint minutes)
{
if (setting == eStreamDebuggingSetting.Off)
@@ -141,9 +135,6 @@ namespace PepperDash.Core
/// The available settings for stream debugging
/// </summary>
[Flags]
/// <summary>
/// Enumeration of eStreamDebuggingSetting values
/// </summary>
public enum eStreamDebuggingSetting
{
/// <summary>

View File

@@ -6,7 +6,7 @@ using Newtonsoft.Json.Converters;
namespace PepperDash.Core
{
/// <summary>
/// Represents a ControlPropertiesConfig
/// Config properties that indicate how to communicate with a device for control
/// </summary>
public class ControlPropertiesConfig
{

View File

@@ -29,9 +29,9 @@ namespace PepperDash.Core
/// </summary>
public class GenericSocketStatusChageEventArgs : EventArgs
{
/// <summary>
/// Gets or sets the Client
/// </summary>
/// <summary>
///
/// </summary>
public ISocketStatus Client { get; private set; }
/// <summary>
@@ -60,7 +60,7 @@ namespace PepperDash.Core
public class GenericTcpServerStateChangedEventArgs : EventArgs
{
/// <summary>
/// Gets or sets the State
///
/// </summary>
public ServerState State { get; private set; }
@@ -154,7 +154,7 @@ namespace PepperDash.Core
}
/// <summary>
/// Gets or sets the Text
///
/// </summary>
public string Text { get; private set; }

View File

@@ -79,7 +79,7 @@ namespace PepperDash.Core
}
/// <summary>
/// Gets or sets the Port
/// Port on server
/// </summary>
public int Port { get; set; }
@@ -149,7 +149,7 @@ namespace PepperDash.Core
public string ConnectionFailure { get { return ClientStatus.ToString(); } }
/// <summary>
/// Gets or sets the AutoReconnect
/// bool to track if auto reconnect should be set on the socket
/// </summary>
public bool AutoReconnect { get; set; }
@@ -188,7 +188,7 @@ namespace PepperDash.Core
#region GenericSecureTcpIpClient properties
/// <summary>
/// Gets or sets the SharedKeyRequired
/// Bool to show whether the server requires a preshared key. This is used in the DynamicTCPServer class
/// </summary>
public bool SharedKeyRequired { get; set; }
@@ -207,7 +207,7 @@ namespace PepperDash.Core
}
/// <summary>
/// Gets or sets the SharedKey
/// SharedKey is sent for varification to the server. Shared key can be any text (255 char limit in SIMPL+ Module), but must match the Shared Key on the Server module
/// </summary>
public string SharedKey { get; set; }
@@ -222,7 +222,7 @@ namespace PepperDash.Core
bool IsTryingToConnect;
/// <summary>
/// Gets or sets the IsReadyForCommunication
/// Bool showing if socket is ready for communication after shared key exchange
/// </summary>
public bool IsReadyForCommunication { get; set; }
@@ -342,7 +342,7 @@ namespace PepperDash.Core
}
/// <summary>
/// Initialize method
/// Just to help S+ set the key
/// </summary>
public void Initialize(string key)
{
@@ -421,9 +421,6 @@ namespace PepperDash.Core
/// Deactivate the client
/// </summary>
/// <returns></returns>
/// <summary>
/// Deactivate method
/// </summary>
public override bool Deactivate()
{
if (_client != null)
@@ -435,7 +432,7 @@ namespace PepperDash.Core
}
/// <summary>
/// Connect method
/// Connect Method. Will return if already connected. Will write errors if missing address, port, or unique key/name.
/// </summary>
public void Connect()
{
@@ -566,7 +563,7 @@ namespace PepperDash.Core
}
/// <summary>
/// Disconnect method
///
/// </summary>
public void Disconnect()
{
@@ -589,7 +586,7 @@ namespace PepperDash.Core
}
/// <summary>
/// DisconnectClient method
/// Does the actual disconnect business
/// </summary>
public void DisconnectClient()
{
@@ -849,7 +846,7 @@ namespace PepperDash.Core
}
/// <summary>
/// SendText method
/// General send method
/// </summary>
public void SendText(string text)
{
@@ -878,7 +875,7 @@ namespace PepperDash.Core
}
/// <summary>
/// SendBytes method
///
/// </summary>
public void SendBytes(byte[] bytes)
{

View File

@@ -80,7 +80,7 @@ namespace PepperDash.Core
public string Hostname { get; set; }
/// <summary>
/// Gets or sets the Port
/// Port on server
/// </summary>
public int Port { get; set; }
@@ -113,7 +113,7 @@ namespace PepperDash.Core
}
/// <summary>
/// Gets or sets the SharedKey
/// SharedKey is sent for varification to the server. Shared key can be any text (255 char limit in SIMPL+ Module), but must match the Shared Key on the Server module
/// </summary>
public string SharedKey { get; set; }
@@ -123,7 +123,7 @@ namespace PepperDash.Core
private bool WaitingForSharedKeyResponse { get; set; }
/// <summary>
/// Gets or sets the BufferSize
/// Defaults to 2000
/// </summary>
public int BufferSize { get; set; }
@@ -336,7 +336,7 @@ namespace PepperDash.Core
#region Methods
/// <summary>
/// Initialize method
/// Just to help S+ set the key
/// </summary>
public void Initialize(string key)
{
@@ -395,7 +395,7 @@ namespace PepperDash.Core
}
/// <summary>
/// Connect method
/// Connect Method. Will return if already connected. Will write errors if missing address, port, or unique key/name.
/// </summary>
public void Connect()
{
@@ -526,7 +526,7 @@ namespace PepperDash.Core
}
/// <summary>
/// Disconnect method
///
/// </summary>
public void Disconnect()
{
@@ -804,7 +804,7 @@ namespace PepperDash.Core
}
/// <summary>
/// SendText method
/// General send method
/// </summary>
public void SendText(string text)
{
@@ -833,7 +833,7 @@ namespace PepperDash.Core
}
/// <summary>
/// SendBytes method
///
/// </summary>
public void SendBytes(byte[] bytes)
{

View File

@@ -58,7 +58,7 @@ namespace PepperDash.Core
public ServerHasChokedCallbackDelegate ServerHasChoked { get; set; }
/// <summary>
/// Delegate for ServerHasChokedCallbackDelegate
///
/// </summary>
public delegate void ServerHasChokedCallbackDelegate();
@@ -104,7 +104,7 @@ namespace PepperDash.Core
int MonitorClientFailureCount;
/// <summary>
/// Gets or sets the MonitorClientMaxFailureCount
/// 3 by default
/// </summary>
public int MonitorClientMaxFailureCount { get; set; }
@@ -190,7 +190,7 @@ namespace PepperDash.Core
}
/// <summary>
/// Gets or sets the Port
/// Port Server should listen on
/// </summary>
public int Port { get; set; }
@@ -223,7 +223,8 @@ namespace PepperDash.Core
}
/// <summary>
/// Gets or sets the SharedKey
/// SharedKey is sent for varification to the server. Shared key can be any text (255 char limit in SIMPL+ Module), but must match the Shared Key on the Server module.
/// If SharedKey changes while server is listening or clients are connected, disconnect and stop listening will be called
/// </summary>
public string SharedKey { get; set; }
@@ -247,7 +248,7 @@ namespace PepperDash.Core
}
/// <summary>
/// Gets or sets the HeartbeatRequiredIntervalMs
/// Milliseconds before server expects another heartbeat. Set by property HeartbeatRequiredIntervalInSeconds which is driven from S+
/// </summary>
public int HeartbeatRequiredIntervalMs { get; set; }
@@ -257,7 +258,7 @@ namespace PepperDash.Core
public ushort HeartbeatRequiredIntervalInSeconds { set { HeartbeatRequiredIntervalMs = (value * 1000); } }
/// <summary>
/// Gets or sets the HeartbeatStringToMatch
/// String to Match for heartbeat. If null or empty any string will reset heartbeat timer
/// </summary>
public string HeartbeatStringToMatch { get; set; }
@@ -275,7 +276,7 @@ namespace PepperDash.Core
public List<uint> ConnectedClientsIndexes = new List<uint>();
/// <summary>
/// Gets or sets the BufferSize
/// Defaults to 2000
/// </summary>
public int BufferSize { get; set; }
@@ -338,7 +339,7 @@ namespace PepperDash.Core
#region Methods - Server Actions
/// <summary>
/// KillServer method
/// Disconnects all clients and stops the server
/// </summary>
public void KillServer()
{
@@ -355,9 +356,6 @@ namespace PepperDash.Core
/// Initialize Key for device using client name from SIMPL+. Called on Listen from SIMPL+
/// </summary>
/// <param name="key"></param>
/// <summary>
/// Initialize method
/// </summary>
public void Initialize(string key)
{
Key = key;
@@ -397,7 +395,7 @@ namespace PepperDash.Core
}
/// <summary>
/// Listen method
/// Start listening on the specified port
/// </summary>
public void Listen()
{
@@ -455,7 +453,7 @@ namespace PepperDash.Core
}
/// <summary>
/// StopListening method
/// Stop Listeneing
/// </summary>
public void StopListening()
{
@@ -480,9 +478,6 @@ namespace PepperDash.Core
/// Disconnects Client
/// </summary>
/// <param name="client"></param>
/// <summary>
/// DisconnectClient method
/// </summary>
public void DisconnectClient(uint client)
{
try
@@ -496,7 +491,7 @@ namespace PepperDash.Core
}
}
/// <summary>
/// DisconnectAllClientsForShutdown method
/// Disconnect All Clients
/// </summary>
public void DisconnectAllClientsForShutdown()
{
@@ -538,9 +533,6 @@ namespace PepperDash.Core
/// Broadcast text from server to all connected clients
/// </summary>
/// <param name="text"></param>
/// <summary>
/// BroadcastText method
/// </summary>
public void BroadcastText(string text)
{
CCriticalSection CCBroadcast = new CCriticalSection();
@@ -574,9 +566,6 @@ namespace PepperDash.Core
/// </summary>
/// <param name="text"></param>
/// <param name="clientIndex"></param>
/// <summary>
/// SendTextToClient method
/// </summary>
public void SendTextToClient(string text, uint clientIndex)
{
try
@@ -645,9 +634,6 @@ namespace PepperDash.Core
/// </summary>
/// <param name="clientIndex"></param>
/// <returns></returns>
/// <summary>
/// GetClientIPAddress method
/// </summary>
public string GetClientIPAddress(uint clientIndex)
{
Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "GetClientIPAddress Index: {0}", clientIndex);

View File

@@ -36,13 +36,13 @@ namespace PepperDash.Core
/// </summary>
public event EventHandler<GenericSocketStatusChageEventArgs> ConnectionChange;
/// <summary>
///// <summary>
/////
///// </summary>
//public event GenericSocketStatusChangeEventDelegate SocketStatusChange;
/// <summary>
/// Gets or sets the Hostname
/// Address of server
/// </summary>
public string Hostname { get; set; }
@@ -52,12 +52,12 @@ namespace PepperDash.Core
public int Port { get; set; }
/// <summary>
/// Gets or sets the Username
/// Username for server
/// </summary>
public string Username { get; set; }
/// <summary>
/// Gets or sets the Password
/// And... Password for server. That was worth documenting!
/// </summary>
public string Password { get; set; }
@@ -79,7 +79,7 @@ namespace PepperDash.Core
}
/// <summary>
/// Socket status change event
///
/// </summary>
public SocketStatus ClientStatus
{
@@ -123,7 +123,8 @@ namespace PepperDash.Core
}
/// <summary>
/// Gets or sets the AutoReconnectIntervalMs
/// Millisecond value, determines the timeout period in between reconnect attempts.
/// Set to 5000 by default
/// </summary>
public int AutoReconnectIntervalMs { get; set; }
@@ -146,31 +147,31 @@ namespace PepperDash.Core
base(key)
{
StreamDebugging = new CommunicationStreamDebugging(key);
CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
Key = key;
Hostname = hostname;
Port = port;
Username = username;
Password = password;
AutoReconnectIntervalMs = 5000;
CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
Key = key;
Hostname = hostname;
Port = port;
Username = username;
Password = password;
AutoReconnectIntervalMs = 5000;
ReconnectTimer = new CTimer(o =>
{
{
if (ConnectEnabled)
{
Connect();
}
}, System.Threading.Timeout.Infinite);
}
}, System.Threading.Timeout.Infinite);
}
/// <summary>
/// S+ Constructor - Must set all properties before calling Connect
/// </summary>
public GenericSshClient()
: base(SPlusKey)
{
CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
AutoReconnectIntervalMs = 5000;
/// <summary>
/// S+ Constructor - Must set all properties before calling Connect
/// </summary>
public GenericSshClient()
: base(SPlusKey)
{
CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
AutoReconnectIntervalMs = 5000;
ReconnectTimer = new CTimer(o =>
{
@@ -179,25 +180,25 @@ namespace PepperDash.Core
Connect();
}
}, System.Threading.Timeout.Infinite);
}
}
/// <summary>
/// Handles closing this up when the program shuts down
/// </summary>
void CrestronEnvironment_ProgramStatusEventHandler(eProgramStatusEventType programEventType)
{
if (programEventType == eProgramStatusEventType.Stopping)
{
if (Client != null)
{
this.LogDebug("Program stopping. Closing connection");
/// <summary>
/// Handles closing this up when the program shuts down
/// </summary>
void CrestronEnvironment_ProgramStatusEventHandler(eProgramStatusEventType programEventType)
{
if (programEventType == eProgramStatusEventType.Stopping)
{
if (Client != null)
{
this.LogDebug("Program stopping. Closing connection");
Disconnect();
}
}
}
/// <summary>
/// Connect method
/// Connect to the server, using the provided properties.
/// </summary>
public void Connect()
{
@@ -223,7 +224,10 @@ namespace PepperDash.Core
this.LogDebug("Attempting connect");
// Cancel reconnect if running.
ReconnectTimer?.Stop();
if (ReconnectTimer != null)
{
ReconnectTimer.Stop();
}
// Cleanup the old client if it already exists
if (Client != null)
@@ -265,26 +269,20 @@ namespace PepperDash.Core
if (ie is SocketException)
{
this.LogError("CONNECTION failure: Cannot reach host");
this.LogVerbose(ie, "Exception details: ");
this.LogException(ie, "CONNECTION failure: Cannot reach host");
}
if (ie is System.Net.Sockets.SocketException socketException)
{
this.LogError("Connection failure: Cannot reach {host} on {port}",
this.LogException(ie, "Connection failure: Cannot reach {host} on {port}",
Hostname, Port);
this.LogVerbose(socketException, "SocketException details: ");
}
if (ie is SshAuthenticationException)
{
this.LogError("Authentication failure for username {userName}", Username);
this.LogVerbose(ie, "AuthenticationException details: ");
this.LogException(ie, "Authentication failure for username {userName}", Username);
}
else
{
this.LogError("Error on connect: {error}", ie.Message);
this.LogVerbose(ie, "Exception details: ");
}
this.LogException(ie, "Error on connect");
DisconnectLogged = true;
KillClient(SocketStatus.SOCKET_STATUS_CONNECT_FAILED);
@@ -294,7 +292,7 @@ namespace PepperDash.Core
ReconnectTimer.Reset(AutoReconnectIntervalMs);
}
}
catch (SshOperationTimeoutException ex)
catch(SshOperationTimeoutException ex)
{
this.LogWarning("Connection attempt timed out: {message}", ex.Message);
@@ -309,8 +307,7 @@ namespace PepperDash.Core
catch (Exception e)
{
var errorLogLevel = DisconnectLogged == true ? Debug.ErrorLogLevel.None : Debug.ErrorLogLevel.Error;
this.LogError("Unhandled exception on connect: {error}", e.Message);
this.LogVerbose(e, "Exception details: ");
this.LogException(e, "Unhandled exception on connect");
DisconnectLogged = true;
KillClient(SocketStatus.SOCKET_STATUS_CONNECT_FAILED);
if (AutoReconnect)
@@ -327,18 +324,18 @@ namespace PepperDash.Core
}
}
/// <summary>
/// Disconnect method
/// </summary>
public void Disconnect()
{
ConnectEnabled = false;
// Stop trying reconnects, if we are
if (ReconnectTimer != null)
{
ReconnectTimer.Stop();
// ReconnectTimer = null;
}
/// <summary>
/// Disconnect the clients and put away it's resources.
/// </summary>
public void Disconnect()
{
ConnectEnabled = false;
// Stop trying reconnects, if we are
if (ReconnectTimer != null)
{
ReconnectTimer.Stop();
// ReconnectTimer = null;
}
KillClient(SocketStatus.SOCKET_STATUS_BROKEN_LOCALLY);
}
@@ -364,7 +361,7 @@ namespace PepperDash.Core
}
catch (Exception ex)
{
this.LogException(ex, "Exception in Kill Client");
this.LogException(ex,"Exception in Kill Client");
}
}
@@ -372,7 +369,7 @@ namespace PepperDash.Core
/// Kills the stream
/// </summary>
void KillStream()
{
{
try
{
if (TheStream != null)
@@ -388,59 +385,59 @@ namespace PepperDash.Core
{
this.LogException(ex, "Exception in Kill Stream:{0}");
}
}
}
/// <summary>
/// Handles the keyboard interactive authentication, should it be required.
/// </summary>
void kauth_AuthenticationPrompt(object sender, AuthenticationPromptEventArgs e)
{
foreach (AuthenticationPrompt prompt in e.Prompts)
if (prompt.Request.IndexOf("Password:", StringComparison.InvariantCultureIgnoreCase) != -1)
prompt.Response = Password;
}
/// <summary>
/// Handler for data receive on ShellStream. Passes data across to queue for line parsing.
/// </summary>
void Stream_DataReceived(object sender, ShellDataEventArgs e)
{
/// <summary>
/// Handles the keyboard interactive authentication, should it be required.
/// </summary>
void kauth_AuthenticationPrompt(object sender, AuthenticationPromptEventArgs e)
{
foreach (AuthenticationPrompt prompt in e.Prompts)
if (prompt.Request.IndexOf("Password:", StringComparison.InvariantCultureIgnoreCase) != -1)
prompt.Response = Password;
}
/// <summary>
/// Handler for data receive on ShellStream. Passes data across to queue for line parsing.
/// </summary>
void Stream_DataReceived(object sender, ShellDataEventArgs e)
{
if (((ShellStream)sender).Length <= 0L)
{
return;
}
var response = ((ShellStream)sender).Read();
var bytesHandler = BytesReceived;
if (bytesHandler != null)
{
var response = ((ShellStream)sender).Read();
var bytesHandler = BytesReceived;
if (bytesHandler != null)
{
var bytes = Encoding.UTF8.GetBytes(response);
if (StreamDebugging.RxStreamDebuggingIsEnabled)
{
this.LogInformation("Received {1} bytes: '{0}'", ComTextHelper.GetEscapedText(bytes), bytes.Length);
}
if (StreamDebugging.RxStreamDebuggingIsEnabled)
{
this.LogInformation("Received {1} bytes: '{0}'", ComTextHelper.GetEscapedText(bytes), bytes.Length);
}
bytesHandler(this, new GenericCommMethodReceiveBytesArgs(bytes));
}
var textHandler = TextReceived;
if (textHandler != null)
{
}
var textHandler = TextReceived;
if (textHandler != null)
{
if (StreamDebugging.RxStreamDebuggingIsEnabled)
this.LogInformation("Received: '{0}'", ComTextHelper.GetDebugText(response));
textHandler(this, new GenericCommMethodReceiveTextArgs(response));
}
}
}
/// <summary>
/// Error event handler for client events - disconnect, etc. Will forward those events via ConnectionChange
/// event
/// </summary>
void Client_ErrorOccurred(object sender, ExceptionEventArgs e)
{
/// <summary>
/// Error event handler for client events - disconnect, etc. Will forward those events via ConnectionChange
/// event
/// </summary>
void Client_ErrorOccurred(object sender, ExceptionEventArgs e)
{
CrestronInvoke.BeginInvoke(o =>
{
if (e.Exception is SshConnectionException || e.Exception is System.Net.Sockets.SocketException)
@@ -469,54 +466,55 @@ namespace PepperDash.Core
/// </summary>
void OnConnectionChange()
{
ConnectionChange?.Invoke(this, new GenericSocketStatusChageEventArgs(this));
if (ConnectionChange != null)
ConnectionChange(this, new GenericSocketStatusChageEventArgs(this));
}
#region IBasicCommunication Members
/// <summary>
/// Sends text to the server
/// </summary>
/// <param name="text">The text to send</param>
public void SendText(string text)
{
try
{
if (Client != null && TheStream != null && IsConnected)
{
if (StreamDebugging.TxStreamDebuggingIsEnabled)
this.LogInformation(
"Sending {length} characters of text: '{text}'",
text.Length,
ComTextHelper.GetDebugText(text));
/// <summary>
/// Sends text to the server
/// </summary>
/// <param name="text"></param>
public void SendText(string text)
{
try
{
if (Client != null && TheStream != null && IsConnected)
{
if (StreamDebugging.TxStreamDebuggingIsEnabled)
this.LogInformation(
"Sending {length} characters of text: '{text}'",
text.Length,
ComTextHelper.GetDebugText(text));
TheStream.Write(text);
TheStream.Flush();
}
else
{
this.LogDebug("Client is null or disconnected. Cannot Send Text");
}
}
catch (ObjectDisposedException)
TheStream.Write(text);
TheStream.Flush();
}
else
{
this.LogDebug("Client is null or disconnected. Cannot Send Text");
}
}
catch (ObjectDisposedException)
{
this.LogError("ObjectDisposedException sending '{message}'. Restarting connection...", text.Trim());
this.LogError("ObjectDisposedException sending '{message}'. Restarting connection...", text.Trim());
KillClient(SocketStatus.SOCKET_STATUS_CONNECT_FAILED);
ReconnectTimer.Reset();
}
catch (Exception ex)
{
}
catch (Exception ex)
{
this.LogException(ex, "Exception sending text: '{message}'", text);
}
}
}
}
/// <summary>
/// Sends Bytes to the server
/// </summary>
/// <param name="bytes">The bytes to send</param>
public void SendBytes(byte[] bytes)
{
/// <param name="bytes"></param>
public void SendBytes(byte[] bytes)
{
try
{
if (Client != null && TheStream != null && IsConnected)
@@ -542,38 +540,38 @@ namespace PepperDash.Core
catch (Exception ex)
{
this.LogException(ex, "Exception sending {message}", ComTextHelper.GetEscapedText(bytes));
}
}
#endregion
}
}
#endregion
}
}
//*****************************************************************************************************
//*****************************************************************************************************
/// <summary>
/// Represents a SshConnectionChangeEventArgs
/// </summary>
public class SshConnectionChangeEventArgs : EventArgs
{
//*****************************************************************************************************
//*****************************************************************************************************
/// <summary>
/// Fired when connection changes
/// </summary>
public class SshConnectionChangeEventArgs : EventArgs
{
/// <summary>
/// Connection State
/// </summary>
public bool IsConnected { get; private set; }
/// <summary>
/// Gets or sets the UIsConnected
/// Connection Status represented as a ushort
/// </summary>
public ushort UIsConnected { get { return (ushort)(Client.IsConnected ? 1 : 0); } }
public ushort UIsConnected { get { return (ushort)(Client.IsConnected ? 1 : 0); } }
/// <summary>
/// Gets or sets the Client
/// The client
/// </summary>
public GenericSshClient Client { get; private set; }
public GenericSshClient Client { get; private set; }
/// <summary>
/// Gets or sets the Status
/// Socket Status as represented by
/// </summary>
public ushort Status { get { return Client.UStatus; } }
public ushort Status { get { return Client.UStatus; } }
/// <summary>
/// S+ Constructor

View File

@@ -59,7 +59,7 @@ namespace PepperDash.Core
}
/// <summary>
/// Gets or sets the Port
/// Port on server
/// </summary>
public int Port { get; set; }
@@ -135,9 +135,9 @@ namespace PepperDash.Core
/// </summary>
public string ConnectionFailure { get { return ClientStatus.ToString(); } }
/// <summary>
/// Gets or sets the AutoReconnect
/// </summary>
/// <summary>
/// bool to track if auto reconnect should be set on the socket
/// </summary>
public bool AutoReconnect { get; set; }
/// <summary>
@@ -232,7 +232,7 @@ namespace PepperDash.Core
}
/// <summary>
/// Initialize method
/// Just to help S+ set the key
/// </summary>
public void Initialize(string key)
{
@@ -255,9 +255,6 @@ namespace PepperDash.Core
///
/// </summary>
/// <returns></returns>
/// <summary>
/// Deactivate method
/// </summary>
public override bool Deactivate()
{
RetryTimer.Stop();
@@ -270,9 +267,9 @@ namespace PepperDash.Core
return true;
}
/// <summary>
/// Connect method
/// </summary>
/// <summary>
/// Attempts to connect to the server
/// </summary>
public void Connect()
{
if (string.IsNullOrEmpty(Hostname))
@@ -337,9 +334,9 @@ namespace PepperDash.Core
}
}
/// <summary>
/// Disconnect method
/// </summary>
/// <summary>
/// Attempts to disconnect the client
/// </summary>
public void Disconnect()
{
try
@@ -358,7 +355,7 @@ namespace PepperDash.Core
}
/// <summary>
/// DisconnectClient method
/// Does the actual disconnect business
/// </summary>
public void DisconnectClient()
{
@@ -449,9 +446,9 @@ namespace PepperDash.Core
}
}
/// <summary>
/// SendText method
/// </summary>
/// <summary>
/// General send method
/// </summary>
public void SendText(string text)
{
var bytes = Encoding.GetEncoding(28591).GetBytes(text);
@@ -462,9 +459,9 @@ namespace PepperDash.Core
_client.SendData(bytes, bytes.Length);
}
/// <summary>
/// SendEscapedText method
/// </summary>
/// <summary>
/// This is useful from console and...?
/// </summary>
public void SendEscapedText(string text)
{
var unescapedText = Regex.Replace(text, @"\\x([0-9a-fA-F][0-9a-fA-F])", s =>
@@ -479,9 +476,6 @@ namespace PepperDash.Core
/// Sends Bytes to the server
/// </summary>
/// <param name="bytes"></param>
/// <summary>
/// SendBytes method
/// </summary>
public void SendBytes(byte[] bytes)
{
if (StreamDebugging.TxStreamDebuggingIsEnabled)
@@ -514,9 +508,9 @@ namespace PepperDash.Core
}
}
/// <summary>
/// Represents a TcpSshPropertiesConfig
/// </summary>
/// <summary>
/// Configuration properties for TCP/SSH Connections
/// </summary>
public class TcpSshPropertiesConfig
{
/// <summary>
@@ -535,9 +529,9 @@ namespace PepperDash.Core
/// Username credential
/// </summary>
public string Username { get; set; }
/// <summary>
/// Gets or sets the Password
/// </summary>
/// <summary>
/// Passord credential
/// </summary>
public string Password { get; set; }
/// <summary>
@@ -545,14 +539,14 @@ namespace PepperDash.Core
/// </summary>
public int BufferSize { get; set; }
/// <summary>
/// Gets or sets the AutoReconnect
/// </summary>
/// <summary>
/// Defaults to true
/// </summary>
public bool AutoReconnect { get; set; }
/// <summary>
/// Gets or sets the AutoReconnectIntervalMs
/// </summary>
/// <summary>
/// Defaults to 5000ms
/// </summary>
public int AutoReconnectIntervalMs { get; set; }
/// <summary>

View File

@@ -69,7 +69,7 @@ namespace PepperDash.Core
public string Hostname { get; set; }
/// <summary>
/// Gets or sets the Port
/// Port on server
/// </summary>
public int Port { get; set; }
@@ -102,7 +102,7 @@ namespace PepperDash.Core
}
/// <summary>
/// Gets or sets the SharedKey
/// SharedKey is sent for varification to the server. Shared key can be any text (255 char limit in SIMPL+ Module), but must match the Shared Key on the Server module
/// </summary>
public string SharedKey { get; set; }
@@ -112,7 +112,7 @@ namespace PepperDash.Core
private bool WaitingForSharedKeyResponse { get; set; }
/// <summary>
/// Gets or sets the BufferSize
/// Defaults to 2000
/// </summary>
public int BufferSize { get; set; }
@@ -289,7 +289,7 @@ namespace PepperDash.Core
#region Methods
/// <summary>
/// Initialize method
/// Just to help S+ set the key
/// </summary>
public void Initialize(string key)
{
@@ -311,7 +311,7 @@ namespace PepperDash.Core
}
/// <summary>
/// Connect method
/// Connect Method. Will return if already connected. Will write errors if missing address, port, or unique key/name.
/// </summary>
public void Connect()
{
@@ -442,7 +442,7 @@ namespace PepperDash.Core
}
/// <summary>
/// Disconnect method
///
/// </summary>
public void Disconnect()
{
@@ -669,7 +669,7 @@ namespace PepperDash.Core
}
/// <summary>
/// SendText method
/// General send method
/// </summary>
public void SendText(string text)
{
@@ -698,7 +698,7 @@ namespace PepperDash.Core
}
/// <summary>
/// SendBytes method
///
/// </summary>
public void SendBytes(byte[] bytes)
{

View File

@@ -52,7 +52,7 @@ namespace PepperDash.Core
public ServerHasChokedCallbackDelegate ServerHasChoked { get; set; }
/// <summary>
/// Delegate for ServerHasChokedCallbackDelegate
///
/// </summary>
public delegate void ServerHasChokedCallbackDelegate();
@@ -82,7 +82,7 @@ namespace PepperDash.Core
int MonitorClientFailureCount;
/// <summary>
/// Gets or sets the MonitorClientMaxFailureCount
/// 3 by default
/// </summary>
public int MonitorClientMaxFailureCount { get; set; }
@@ -171,7 +171,7 @@ namespace PepperDash.Core
}
/// <summary>
/// Gets or sets the Port
/// Port Server should listen on
/// </summary>
public int Port { get; set; }
@@ -204,7 +204,8 @@ namespace PepperDash.Core
}
/// <summary>
/// Gets or sets the SharedKey
/// SharedKey is sent for varification to the server. Shared key can be any text (255 char limit in SIMPL+ Module), but must match the Shared Key on the Server module.
/// If SharedKey changes while server is listening or clients are connected, disconnect and stop listening will be called
/// </summary>
public string SharedKey { get; set; }
@@ -228,7 +229,7 @@ namespace PepperDash.Core
}
/// <summary>
/// Gets or sets the HeartbeatRequiredIntervalMs
/// Milliseconds before server expects another heartbeat. Set by property HeartbeatRequiredIntervalInSeconds which is driven from S+
/// </summary>
public int HeartbeatRequiredIntervalMs { get; set; }
@@ -238,7 +239,7 @@ namespace PepperDash.Core
public ushort HeartbeatRequiredIntervalInSeconds { set { HeartbeatRequiredIntervalMs = (value * 1000); } }
/// <summary>
/// Gets or sets the HeartbeatStringToMatch
/// String to Match for heartbeat. If null or empty any string will reset heartbeat timer
/// </summary>
public string HeartbeatStringToMatch { get; set; }
@@ -256,7 +257,7 @@ namespace PepperDash.Core
public List<uint> ConnectedClientsIndexes = new List<uint>();
/// <summary>
/// Gets or sets the BufferSize
/// Defaults to 2000
/// </summary>
public int BufferSize { get; set; }
@@ -319,7 +320,7 @@ namespace PepperDash.Core
#region Methods - Server Actions
/// <summary>
/// KillServer method
/// Disconnects all clients and stops the server
/// </summary>
public void KillServer()
{
@@ -336,9 +337,6 @@ namespace PepperDash.Core
/// Initialize Key for device using client name from SIMPL+. Called on Listen from SIMPL+
/// </summary>
/// <param name="key"></param>
/// <summary>
/// Initialize method
/// </summary>
public void Initialize(string key)
{
Key = key;
@@ -377,7 +375,7 @@ namespace PepperDash.Core
}
/// <summary>
/// Listen method
/// Start listening on the specified port
/// </summary>
public void Listen()
{
@@ -434,7 +432,7 @@ namespace PepperDash.Core
}
/// <summary>
/// StopListening method
/// Stop Listening
/// </summary>
public void StopListening()
{
@@ -459,9 +457,6 @@ namespace PepperDash.Core
/// Disconnects Client
/// </summary>
/// <param name="client"></param>
/// <summary>
/// DisconnectClient method
/// </summary>
public void DisconnectClient(uint client)
{
try
@@ -475,7 +470,7 @@ namespace PepperDash.Core
}
}
/// <summary>
/// DisconnectAllClientsForShutdown method
/// Disconnect All Clients
/// </summary>
public void DisconnectAllClientsForShutdown()
{
@@ -517,9 +512,6 @@ namespace PepperDash.Core
/// Broadcast text from server to all connected clients
/// </summary>
/// <param name="text"></param>
/// <summary>
/// BroadcastText method
/// </summary>
public void BroadcastText(string text)
{
CCriticalSection CCBroadcast = new CCriticalSection();
@@ -553,9 +545,6 @@ namespace PepperDash.Core
/// </summary>
/// <param name="text"></param>
/// <param name="clientIndex"></param>
/// <summary>
/// SendTextToClient method
/// </summary>
public void SendTextToClient(string text, uint clientIndex)
{
try
@@ -624,9 +613,6 @@ namespace PepperDash.Core
/// </summary>
/// <param name="clientIndex"></param>
/// <returns>IP address of the client</returns>
/// <summary>
/// GetClientIPAddress method
/// </summary>
public string GetClientIPAddress(uint clientIndex)
{
Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "GetClientIPAddress Index: {0}", clientIndex);

View File

@@ -150,9 +150,6 @@ namespace PepperDash.Core
/// <param name="key"></param>
/// <param name="address"></param>
/// <param name="port"></param>
/// <summary>
/// Initialize method
/// </summary>
public void Initialize(string key, string address, ushort port)
{
Key = key;
@@ -188,7 +185,7 @@ namespace PepperDash.Core
}
/// <summary>
/// Connect method
/// Enables the UDP Server
/// </summary>
public void Connect()
{
@@ -225,7 +222,7 @@ namespace PepperDash.Core
}
/// <summary>
/// Disconnect method
/// Disabled the UDP Server
/// </summary>
public void Disconnect()
{
@@ -295,9 +292,6 @@ namespace PepperDash.Core
/// General send method
/// </summary>
/// <param name="text"></param>
/// <summary>
/// SendText method
/// </summary>
public void SendText(string text)
{
var bytes = Encoding.GetEncoding(28591).GetBytes(text);
@@ -315,9 +309,6 @@ namespace PepperDash.Core
///
/// </summary>
/// <param name="bytes"></param>
/// <summary>
/// SendBytes method
/// </summary>
public void SendBytes(byte[] bytes)
{
if (StreamDebugging.TxStreamDebuggingIsEnabled)
@@ -329,9 +320,9 @@ namespace PepperDash.Core
}
/// <summary>
/// Represents a GenericUdpReceiveTextExtraArgs
/// </summary>
/// <summary>
///
/// </summary>
public class GenericUdpReceiveTextExtraArgs : EventArgs
{
/// <summary>

View File

@@ -3,7 +3,7 @@
namespace PepperDash.Core
{
/// <summary>
/// Represents a TcpClientConfigObject
/// Client config object for TCP client with server that inherits from TcpSshPropertiesConfig and adds properties for shared key and heartbeat
/// </summary>
public class TcpClientConfigObject
{

View File

@@ -74,10 +74,6 @@ namespace PepperDash.Core
/// <summary>
/// Secure TCP/IP
/// </summary>
SecureTcpIp,
/// <summary>
/// Used when comms needs to be handled in SIMPL and bridged opposite the normal direction
/// </summary>
ComBridge
SecureTcpIp
}
}

View File

@@ -38,9 +38,9 @@ namespace PepperDash.Core
void Disconnect();
}
/// <summary>
/// Defines the contract for IBasicCommunication
/// </summary>
/// <summary>
/// Represents a device that uses basic connection
/// </summary>
public interface IBasicCommunication : ICommunicationReceiver
{
/// <summary>
@@ -147,9 +147,9 @@ namespace PepperDash.Core
/// </summary>
public class GenericCommMethodReceiveBytesArgs : EventArgs
{
/// <summary>
/// Gets or sets the Bytes
/// </summary>
/// <summary>
///
/// </summary>
public byte[] Bytes { get; private set; }
/// <summary>
@@ -228,9 +228,6 @@ namespace PepperDash.Core
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
/// <summary>
/// GetEscapedText method
/// </summary>
public static string GetEscapedText(string text)
{
var bytes = Encoding.GetEncoding(28591).GetBytes(text);
@@ -242,9 +239,6 @@ namespace PepperDash.Core
/// </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));

View File

@@ -67,9 +67,6 @@ namespace PepperDash.Core.Config
/// </summary>
/// <param name="doubleConfig"></param>
/// <returns></returns>
/// <summary>
/// MergeConfigs method
/// </summary>
public static JObject MergeConfigs(JObject doubleConfig)
{
var system = JObject.FromObject(doubleConfig["system"]);

View File

@@ -6,22 +6,13 @@ using Crestron.SimplSharp;
namespace PepperDash.Core
{
/// <summary>
/// Represents a EncodingHelper
/// </summary>
public class EncodingHelper
{
/// <summary>
/// ConvertUtf8ToAscii method
/// </summary>
public static string ConvertUtf8ToAscii(string utf8String)
{
return Encoding.ASCII.GetString(Encoding.UTF8.GetBytes(utf8String), 0, utf8String.Length);
}
/// <summary>
/// ConvertUtf8ToUtf16 method
/// </summary>
public static string ConvertUtf8ToUtf16(string utf8String)
{
return Encoding.Unicode.GetString(Encoding.UTF8.GetBytes(utf8String), 0, utf8String.Length);

View File

@@ -5,41 +5,41 @@ using Serilog.Events;
namespace PepperDash.Core
{
//*********************************************************************************************************
/// <summary>
/// Represents a Device
/// </summary>
/// <summary>
/// The core event and status-bearing class that most if not all device and connectors can derive from.
/// </summary>
public class Device : IKeyName
{
/// <summary>
/// Unique Key
/// </summary>
/// <summary>
/// Unique Key
/// </summary>
public string Key { get; protected set; }
/// <summary>
/// Gets or sets the Name
/// </summary>
public string Name { get; protected set; }
/// <summary>
///
/// Name of the devie
/// </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; } }
///// <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>
/// <summary>
///
/// </summary>
public static Device DefaultDevice { get { return _DefaultDevice; } }
static Device _DefaultDevice = new Device("Default", "Default");
@@ -54,27 +54,27 @@ namespace PepperDash.Core
Name = "";
}
/// <summary>
/// Constructor with key and name
/// </summary>
/// <param name="key"></param>
/// <param name="name"></param>
/// <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;
//}
//public Device(DeviceConfig config)
// : this(config.Key, config.Name)
//{
// Config = config;
//}
/// <summary>
/// Adds a pre activation action
/// </summary>
/// <param name="act"></param>
/// <summary>
/// Adds a pre activation action
/// </summary>
/// <param name="act"></param>
public void AddPreActivationAction(Action act)
{
if (_PreActivationActions == null)
@@ -82,13 +82,10 @@ namespace PepperDash.Core
_PreActivationActions.Add(act);
}
/// <summary>
/// Adds a post activation action
/// </summary>
/// <param name="act"></param>
/// <summary>
/// AddPostActivationAction method
/// </summary>
/// <summary>
/// Adds a post activation action
/// </summary>
/// <param name="act"></param>
public void AddPostActivationAction(Action act)
{
if (_PostActivationActions == null)
@@ -96,56 +93,55 @@ namespace PepperDash.Core
_PostActivationActions.Add(act);
}
/// <summary>
/// PreActivate method
/// </summary>
public void PreActivate()
{
if (_PreActivationActions != null)
_PreActivationActions.ForEach(a =>
{
/// <summary>
/// Executes the preactivation actions
/// </summary>
public void PreActivate()
{
if (_PreActivationActions != null)
_PreActivationActions.ForEach(a => {
try
{
a.Invoke();
}
catch (Exception e)
{
} catch (Exception e)
{
Debug.LogMessage(e, "Error in PreActivationAction: " + e.Message, this);
}
});
}
});
}
/// <summary>
/// Activate method
/// </summary>
public bool Activate()
/// <summary>
/// Gets this device ready to be used in the system. Runs any added pre-activation items, and
/// all post-activation at end. Classes needing additional logic to
/// run should override CustomActivate()
/// </summary>
public bool Activate()
{
//if (_PreActivationActions != null)
// _PreActivationActions.ForEach(a => a.Invoke());
//if (_PreActivationActions != null)
// _PreActivationActions.ForEach(a => a.Invoke());
var result = CustomActivate();
//if(result && _PostActivationActions != null)
// _PostActivationActions.ForEach(a => a.Invoke());
return result;
//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>
/// Executes the postactivation actions
/// </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.
@@ -153,9 +149,6 @@ namespace PepperDash.Core
/// 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>
@@ -165,14 +158,14 @@ namespace PepperDash.Core
/// <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>
/// Call this method to start communications with a device. Overriding classes do not need to call base.Initialize()
/// </summary>
public virtual void Initialize()
{
}
/// <summary>
/// <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>
@@ -182,18 +175,5 @@ namespace PepperDash.Core
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);
}
}
}

View File

@@ -4,9 +4,9 @@ using Serilog.Events;
namespace PepperDash.Core
{
/// <summary>
/// Represents a EthernetHelper
/// </summary>
/// <summary>
/// Class to help with accessing values from the CrestronEthernetHelper class
/// </summary>
public class EthernetHelper
{
/// <summary>
@@ -24,9 +24,9 @@ namespace PepperDash.Core
// ADD OTHER HELPERS HERE
/// <summary>
/// Gets or sets the PortNumber
/// </summary>
/// <summary>
///
/// </summary>
public int PortNumber { get; private set; }
private EthernetHelper(int portNumber)

View File

@@ -16,19 +16,19 @@ namespace PepperDash.Core
/// </summary>
public bool State { get; set; }
/// <summary>
/// Gets or sets the IntValue
/// </summary>
/// <summary>
/// Boolean ushort value property
/// </summary>
public ushort IntValue { get { return (ushort)(State ? 1 : 0); } }
/// <summary>
/// Gets or sets the Type
/// </summary>
/// <summary>
/// Boolean change event args type
/// </summary>
public ushort Type { get; set; }
/// <summary>
/// Gets or sets the Index
/// </summary>
/// <summary>
/// Boolean change event args index
/// </summary>
public ushort Index { get; set; }
/// <summary>
@@ -64,9 +64,9 @@ namespace PepperDash.Core
}
}
/// <summary>
/// Represents a UshrtChangeEventArgs
/// </summary>
/// <summary>
/// Ushort change event args
/// </summary>
public class UshrtChangeEventArgs : EventArgs
{
/// <summary>
@@ -74,14 +74,14 @@ namespace PepperDash.Core
/// </summary>
public ushort IntValue { get; set; }
/// <summary>
/// Gets or sets the Type
/// </summary>
/// <summary>
/// Ushort change event args type
/// </summary>
public ushort Type { get; set; }
/// <summary>
/// Gets or sets the Index
/// </summary>
/// <summary>
/// Ushort change event args index
/// </summary>
public ushort Index { get; set; }
/// <summary>
@@ -117,9 +117,9 @@ namespace PepperDash.Core
}
}
/// <summary>
/// Represents a StringChangeEventArgs
/// </summary>
/// <summary>
/// String change event args
/// </summary>
public class StringChangeEventArgs : EventArgs
{
/// <summary>
@@ -127,14 +127,14 @@ namespace PepperDash.Core
/// </summary>
public string StringValue { get; set; }
/// <summary>
/// Gets or sets the Type
/// </summary>
/// <summary>
/// String change event args type
/// </summary>
public ushort Type { get; set; }
/// <summary>
/// Gets or sets the Index
/// </summary>
/// <summary>
/// string change event args index
/// </summary>
public ushort Index { get; set; }
/// <summary>

View File

@@ -32,14 +32,14 @@ namespace PepperDash.Core.JsonStandardObjects
/// </summary>
public DeviceConfig Device { get; set; }
/// <summary>
/// Gets or sets the Type
/// </summary>
/// <summary>
/// Device change event args type
/// </summary>
public ushort Type { get; set; }
/// <summary>
/// Gets or sets the Index
/// </summary>
/// <summary>
/// Device change event args index
/// </summary>
public ushort Index { get; set; }
/// <summary>

View File

@@ -58,9 +58,6 @@ namespace PepperDash.Core.JsonStandardObjects
/// </summary>
/// <param name="uniqueID"></param>
/// <param name="deviceKey"></param>
/// <summary>
/// Initialize method
/// </summary>
public void Initialize(string uniqueID, string deviceKey)
{
// S+ set EvaluateFb low

View File

@@ -47,14 +47,14 @@ namespace PepperDash.Core.JsonStandardObjects
]
}
*/
/// <summary>
/// Represents a ComParamsConfig
/// </summary>
/// <summary>
/// Device communication parameter class
/// </summary>
public class ComParamsConfig
{
/// <summary>
/// Gets or sets the baudRate
/// </summary>
/// <summary>
///
/// </summary>
public int baudRate { get; set; }
/// <summary>
///
@@ -86,13 +86,13 @@ namespace PepperDash.Core.JsonStandardObjects
public int pacing { get; set; }
// convert properties for simpl
/// <summary>
/// Gets or sets the simplBaudRate
/// </summary>
/// <summary>
///
/// </summary>
public ushort simplBaudRate { get { return Convert.ToUInt16(baudRate); } }
/// <summary>
/// Gets or sets the simplDataBits
/// </summary>
/// <summary>
///
/// </summary>
public ushort simplDataBits { get { return Convert.ToUInt16(dataBits); } }
/// <summary>
///
@@ -143,13 +143,13 @@ namespace PepperDash.Core.JsonStandardObjects
public int autoReconnectIntervalMs { get; set; }
// convert properties for simpl
/// <summary>
/// Gets or sets the simplPort
/// </summary>
/// <summary>
///
/// </summary>
public ushort simplPort { get { return Convert.ToUInt16(port); } }
/// <summary>
/// Gets or sets the simplAutoReconnect
/// </summary>
/// <summary>
///
/// </summary>
public ushort simplAutoReconnect { get { return (ushort)(autoReconnect ? 1 : 0); } }
/// <summary>
///
@@ -192,9 +192,9 @@ namespace PepperDash.Core.JsonStandardObjects
public TcpSshPropertiesConfig tcpSshProperties { get; set; }
// convert properties for simpl
/// <summary>
/// Gets or sets the simplControlPortNumber
/// </summary>
/// <summary>
///
/// </summary>
public ushort simplControlPortNumber { get { return Convert.ToUInt16(controlPortNumber); } }
/// <summary>
@@ -207,9 +207,9 @@ namespace PepperDash.Core.JsonStandardObjects
}
}
/// <summary>
/// Represents a PropertiesConfig
/// </summary>
/// <summary>
/// Device properties class
/// </summary>
public class PropertiesConfig
{
/// <summary>
@@ -226,13 +226,13 @@ namespace PepperDash.Core.JsonStandardObjects
public ControlConfig control { get; set; }
// convert properties for simpl
/// <summary>
/// Gets or sets the simplDeviceId
/// </summary>
/// <summary>
///
/// </summary>
public ushort simplDeviceId { get { return Convert.ToUInt16(deviceId); } }
/// <summary>
/// Gets or sets the simplEnabled
/// </summary>
/// <summary>
///
/// </summary>
public ushort simplEnabled { get { return (ushort)(enabled ? 1 : 0); } }
/// <summary>

View File

@@ -88,9 +88,9 @@ namespace PepperDash.Core.JsonToSimpl
/// </summary>
public class SPlusValueWrapper
{
/// <summary>
/// Gets or sets the ValueType
/// </summary>
/// <summary>
///
/// </summary>
public SPlusType ValueType { get; private set; }
/// <summary>
///
@@ -122,9 +122,9 @@ namespace PepperDash.Core.JsonToSimpl
}
}
/// <summary>
/// Enumeration of SPlusType values
/// </summary>
/// <summary>
/// S+ types enum
/// </summary>
public enum SPlusType
{
/// <summary>

View File

@@ -23,9 +23,6 @@ namespace PepperDash.Core.JsonToSimpl
/// </summary>
/// <param name="master">New master to add</param>
///
/// <summary>
/// AddMaster method
/// </summary>
public static void AddMaster(JsonToSimplMaster master)
{
if (master == null)
@@ -52,9 +49,9 @@ namespace PepperDash.Core.JsonToSimpl
}
}
/// <summary>
/// GetMasterByFile method
/// </summary>
/// <summary>
/// Gets a master by its key. Case-insensitive
/// </summary>
public static JsonToSimplMaster GetMasterByFile(string file)
{
return Masters.FirstOrDefault(m => m.UniqueID.Equals(file, StringComparison.OrdinalIgnoreCase));

View File

@@ -5,9 +5,9 @@ using Serilog.Events;
namespace PepperDash.Core.JsonToSimpl
{
/// <summary>
/// Represents a JsonToSimplArrayLookupChild
/// </summary>
/// <summary>
/// Used to interact with an array of values with the S+ modules
/// </summary>
public class JsonToSimplArrayLookupChild : JsonToSimplChildObjectBase
{
/// <summary>
@@ -76,10 +76,9 @@ namespace PepperDash.Core.JsonToSimpl
PathSuffix == null ? "" : PathSuffix);
}
/// <summary>
/// ProcessAll method
/// </summary>
/// <inheritdoc />
/// <summary>
/// Process all values
/// </summary>
public override void ProcessAll()
{
if (FindInArray())

View File

@@ -28,14 +28,14 @@ namespace PepperDash.Core.JsonToSimpl
/// </summary>
public SPlusValuesDelegate GetAllValuesDelegate { get; set; }
/// <summary>
/// Gets or sets the SetAllPathsDelegate
/// </summary>
/// <summary>
/// Use a callback to reduce task switch/threading
/// </summary>
public SPlusValuesDelegate SetAllPathsDelegate { get; set; }
/// <summary>
/// Gets or sets the Key
/// </summary>
/// <summary>
/// Unique identifier for instance
/// </summary>
public string Key { get; protected set; }
/// <summary>
@@ -49,9 +49,9 @@ namespace PepperDash.Core.JsonToSimpl
/// </summary>
public string PathSuffix { get; protected set; }
/// <summary>
/// Gets or sets the LinkedToObject
/// </summary>
/// <summary>
/// Indicates if the instance is linked to an object
/// </summary>
public bool LinkedToObject { get; protected set; }
/// <summary>
@@ -96,9 +96,6 @@ namespace PepperDash.Core.JsonToSimpl
/// Sets the path prefix for the object
/// </summary>
/// <param name="pathPrefix"></param>
/// <summary>
/// SetPathPrefix method
/// </summary>
public void SetPathPrefix(string pathPrefix)
{
PathPrefix = pathPrefix;
@@ -113,9 +110,9 @@ namespace PepperDash.Core.JsonToSimpl
BoolPaths[index] = path;
}
/// <summary>
/// SetUshortPath method
/// </summary>
/// <summary>
/// Set the JPath for a ushort out index.
/// </summary>
public void SetUshortPath(ushort index, string path)
{
Debug.Console(1, "JSON Child[{0}] SetUshortPath {1}={2}", Key, index, path);
@@ -123,9 +120,9 @@ namespace PepperDash.Core.JsonToSimpl
UshortPaths[index] = path;
}
/// <summary>
/// SetStringPath method
/// </summary>
/// <summary>
/// Set the JPath for a string output index.
/// </summary>
public void SetStringPath(ushort index, string path)
{
Debug.Console(1, "JSON Child[{0}] SetStringPath {1}={2}", Key, index, path);
@@ -133,10 +130,10 @@ namespace PepperDash.Core.JsonToSimpl
StringPaths[index] = path;
}
/// <summary>
/// ProcessAll method
/// </summary>
/// <inheritdoc />
/// <summary>
/// Evalutates all outputs with defined paths. called by S+ when paths are ready to process
/// and by Master when file is read.
/// </summary>
public virtual void ProcessAll()
{
if (!LinkedToObject)
@@ -280,9 +277,6 @@ namespace PepperDash.Core.JsonToSimpl
/// </summary>
/// <param name="key"></param>
/// <param name="theValue"></param>
/// <summary>
/// USetBoolValue method
/// </summary>
public void USetBoolValue(ushort key, ushort theValue)
{
SetBoolValue(key, theValue == 1);
@@ -293,9 +287,6 @@ namespace PepperDash.Core.JsonToSimpl
/// </summary>
/// <param name="key"></param>
/// <param name="theValue"></param>
/// <summary>
/// SetBoolValue method
/// </summary>
public void SetBoolValue(ushort key, bool theValue)
{
if (BoolPaths.ContainsKey(key))
@@ -307,9 +298,6 @@ namespace PepperDash.Core.JsonToSimpl
/// </summary>
/// <param name="key"></param>
/// <param name="theValue"></param>
/// <summary>
/// SetUShortValue method
/// </summary>
public void SetUShortValue(ushort key, ushort theValue)
{
if (UshortPaths.ContainsKey(key))
@@ -321,9 +309,6 @@ namespace PepperDash.Core.JsonToSimpl
/// </summary>
/// <param name="key"></param>
/// <param name="theValue"></param>
/// <summary>
/// SetStringValue method
/// </summary>
public void SetStringValue(ushort key, string theValue)
{
if (StringPaths.ContainsKey(key))
@@ -335,9 +320,6 @@ namespace PepperDash.Core.JsonToSimpl
/// </summary>
/// <param name="keyPath"></param>
/// <param name="valueToSave"></param>
/// <summary>
/// SetValueOnMaster method
/// </summary>
public void SetValueOnMaster(string keyPath, JValue valueToSave)
{
var path = GetFullPath(keyPath);

View File

@@ -20,12 +20,12 @@ namespace PepperDash.Core.JsonToSimpl
public string Filepath { get; private set; }
/// <summary>
/// Gets or sets the ActualFilePath
/// Filepath to the actual file that will be read (Portal or local)
/// </summary>
public string ActualFilePath { get; private set; }
/// <summary>
/// Gets or sets the Filename
///
/// </summary>
public string Filename { get; private set; }
/// <summary>
@@ -194,9 +194,6 @@ namespace PepperDash.Core.JsonToSimpl
/// Sets the debug level
/// </summary>
/// <param name="level"></param>
/// <summary>
/// setDebugLevel method
/// </summary>
public void setDebugLevel(uint level)
{
Debug.SetDebugLevel(level);

View File

@@ -2,9 +2,9 @@
namespace PepperDash.Core.JsonToSimpl
{
/// <summary>
/// Represents a JsonToSimplFixedPathObject
/// </summary>
/// <summary>
///
/// </summary>
public class JsonToSimplFixedPathObject : JsonToSimplChildObjectBase
{
/// <summary>

View File

@@ -5,9 +5,9 @@ using Newtonsoft.Json.Linq;
namespace PepperDash.Core.JsonToSimpl
{
/// <summary>
/// Represents a JsonToSimplGenericMaster
/// </summary>
/// <summary>
/// Generic Master
/// </summary>
public class JsonToSimplGenericMaster : JsonToSimplMaster
{
/*****************************************************************************************/
@@ -20,9 +20,9 @@ namespace PepperDash.Core.JsonToSimpl
// To prevent multiple same-file access
static object WriteLock = new object();
/// <summary>
/// Gets or sets the SaveCallback
/// </summary>
/// <summary>
/// Callback action for saving
/// </summary>
public Action<string> SaveCallback { get; set; }
/*****************************************************************************************/
@@ -60,9 +60,6 @@ namespace PepperDash.Core.JsonToSimpl
/// Loads JSON into JsonObject, but does not trigger evaluation by children
/// </summary>
/// <param name="json"></param>
/// <summary>
/// SetJsonWithoutEvaluating method
/// </summary>
public void SetJsonWithoutEvaluating(string json)
{
try
@@ -75,10 +72,9 @@ namespace PepperDash.Core.JsonToSimpl
}
}
/// <summary>
/// Save method
/// </summary>
/// <inheritdoc />
/// <summary>
///
/// </summary>
public override void Save()
{
// this code is duplicated in the other masters!!!!!!!!!!!!!

View File

@@ -38,9 +38,9 @@ namespace PepperDash.Core.JsonToSimpl
/// </summary>
public string Key { get { return UniqueID; } }
/// <summary>
/// Gets or sets the UniqueID
/// </summary>
/// <summary>
/// A unique ID
/// </summary>
public string UniqueID { get; protected set; }
/// <summary>
@@ -53,9 +53,10 @@ namespace PepperDash.Core.JsonToSimpl
}
string _DebugName = "";
/// <summary>
/// Gets or sets the PathPrefix
/// </summary>
/// <summary>
/// This will be prepended to all paths to allow path swapping or for more organized
/// sub-paths
/// </summary>
public string PathPrefix { get; set; }
/// <summary>
@@ -82,9 +83,9 @@ namespace PepperDash.Core.JsonToSimpl
}
}
/// <summary>
/// Gets or sets the JsonObject
/// </summary>
/// <summary>
///
/// </summary>
public JObject JsonObject { get; protected set; }
/*****************************************************************************************/
@@ -119,9 +120,6 @@ namespace PepperDash.Core.JsonToSimpl
/// Adds a child "module" to this master
/// </summary>
/// <param name="child"></param>
/// <summary>
/// AddChild method
/// </summary>
public void AddChild(JsonToSimplChildObjectBase child)
{
if (!Children.Contains(child))
@@ -130,9 +128,9 @@ namespace PepperDash.Core.JsonToSimpl
}
}
/// <summary>
/// AddUnsavedValue method
/// </summary>
/// <summary>
/// Called from the child to add changed or new values for saving
/// </summary>
public void AddUnsavedValue(string path, JValue value)
{
if (UnsavedValues.ContainsKey(path))
@@ -181,9 +179,6 @@ namespace PepperDash.Core.JsonToSimpl
/// </summary>
/// <param name="json"></param>
/// <returns></returns>
/// <summary>
/// ParseArray method
/// </summary>
public static JArray ParseArray(string json)
{
#if NET6_0

View File

@@ -19,7 +19,7 @@ namespace PepperDash.Core.JsonToSimpl
public string PortalFilepath { get; private set; }
/// <summary>
/// Gets or sets the ActualFilePath
/// File path of the actual file being read (Portal or local)
/// </summary>
public string ActualFilePath { get; private set; }
@@ -128,9 +128,6 @@ namespace PepperDash.Core.JsonToSimpl
///
/// </summary>
/// <param name="level"></param>
/// <summary>
/// setDebugLevel method
/// </summary>
public void setDebugLevel(uint level)
{
Debug.SetDebugLevel(level);

View File

@@ -9,9 +9,6 @@ using System.Threading.Tasks;
namespace PepperDash.Core.Logging
{
/// <summary>
/// Represents a CrestronEnricher
/// </summary>
public class CrestronEnricher : ILogEventEnricher
{
static readonly string _appName;
@@ -30,9 +27,6 @@ namespace PepperDash.Core.Logging
}
/// <summary>
/// Enrich method
/// </summary>
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
{
var property = propertyFactory.CreateProperty("App", _appName);

View File

@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Net;
using System.Reflection;
using System.Text.RegularExpressions;
using Crestron.SimplSharp;
using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronDataStore;
using Crestron.SimplSharp.CrestronIO;
using Crestron.SimplSharp.CrestronLogger;
@@ -16,10 +11,15 @@ using Serilog.Events;
using Serilog.Formatting.Compact;
using Serilog.Formatting.Json;
using Serilog.Templates;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text.RegularExpressions;
namespace PepperDash.Core
{
/// <summary>
/// Contains debug commands for use in various situations
/// </summary>
public static class Debug
{
@@ -48,9 +48,6 @@ namespace PepperDash.Core
private static readonly LoggingLevelSwitch _fileLevelSwitch;
/// <summary>
/// Gets the minimum log level for the websocket sink.
/// </summary>
public static LogEventLevel WebsocketMinimumLogLevel
{
get { return _websocketLoggingLevelSwitch.MinimumLevel; }
@@ -58,9 +55,6 @@ namespace PepperDash.Core
private static readonly DebugWebsocketSink _websocketSink;
/// <summary>
/// Gets the websocket sink for debug logging.
/// </summary>
public static DebugWebsocketSink WebsocketSink
{
get { return _websocketSink; }
@@ -84,12 +78,12 @@ namespace PepperDash.Core
public static string FileName = string.Format(@"app{0}Debug.json", InitialParametersClass.ApplicationNumber);
/// <summary>
/// Gets or sets the Level
/// Debug level to set for a given program.
/// </summary>
public static int Level { get; private set; }
/// <summary>
/// Gets or sets the DoNotLoadConfigOnNextBoot
/// When this is true, the configuration file will NOT be loaded until triggered by either a console command or a signal
/// </summary>
public static bool DoNotLoadConfigOnNextBoot { get; private set; }
@@ -97,33 +91,29 @@ namespace PepperDash.Core
private const int SaveTimeoutMs = 30000;
/// <summary>
/// Indicates whether the system is running on an appliance.
/// </summary>
public static bool IsRunningOnAppliance = CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance;
/// <summary>
/// Gets or sets the PepperDashCoreVersion
/// Version for the currently loaded PepperDashCore dll
/// </summary>
public static string PepperDashCoreVersion { get; private set; }
public static string PepperDashCoreVersion { get; private set; }
private static CTimer _saveTimer;
/// <summary>
/// When true, the IncludedExcludedKeys dict will contain keys to include.
/// When false (default), IncludedExcludedKeys will contain keys to exclude.
/// </summary>
private static bool _excludeAllMode;
/// <summary>
/// When true, the IncludedExcludedKeys dict will contain keys to include.
/// When false (default), IncludedExcludedKeys will contain keys to exclude.
/// </summary>
private static bool _excludeAllMode;
private static readonly Dictionary<string, object> IncludedExcludedKeys;
//static bool ExcludeNoKeyMessages;
private static readonly Dictionary<string, object> IncludedExcludedKeys;
private static readonly LoggerConfiguration _defaultLoggerConfiguration;
private static LoggerConfiguration _loggerConfiguration;
/// <summary>
/// Gets the logger configuration for the debug logging.
/// </summary>
public static LoggerConfiguration LoggerConfiguration => _loggerConfiguration;
static Debug()
@@ -138,7 +128,7 @@ namespace PepperDash.Core
var defaultFileLogLevel = GetStoredLogEventLevel(FileLevelStoreKey);
_consoleLoggingLevelSwitch = new LoggingLevelSwitch(initialMinimumLevel: defaultConsoleLevel);
_consoleLoggingLevelSwitch = new LoggingLevelSwitch(initialMinimumLevel: defaultConsoleLevel);
_websocketLoggingLevelSwitch = new LoggingLevelSwitch(initialMinimumLevel: defaultWebsocketLevel);
@@ -154,7 +144,7 @@ namespace PepperDash.Core
CrestronConsole.PrintLine($"Saving log files to {logFilePath}");
var errorLogTemplate = CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance
var errorLogTemplate = CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance
? "{@t:fff}ms [{@l:u4}]{#if Key is not null}[{Key}]{#end} {@m}{#if @x is not null}\r\n{@x}{#end}"
: "[{@t:yyyy-MM-dd HH:mm:ss.fff}][{@l:u4}][{App}]{#if Key is not null}[{Key}]{#end} {@m}{#if @x is not null}\r\n{@x}{#end}";
@@ -165,7 +155,7 @@ namespace PepperDash.Core
.WriteTo.Sink(new DebugConsoleSink(new ExpressionTemplate("[{@t:yyyy-MM-dd HH:mm:ss.fff}][{@l:u4}][{App}]{#if Key is not null}[{Key}]{#end} {@m}{#if @x is not null}\r\n{@x}{#end}")), levelSwitch: _consoleLoggingLevelSwitch)
.WriteTo.Sink(_websocketSink, levelSwitch: _websocketLoggingLevelSwitch)
.WriteTo.Sink(new DebugErrorLogSink(new ExpressionTemplate(errorLogTemplate)), levelSwitch: _errorLogLevelSwitch)
.WriteTo.File(new RenderedCompactJsonFormatter(), logFilePath,
.WriteTo.File(new RenderedCompactJsonFormatter(), logFilePath,
rollingInterval: RollingInterval.Day,
restrictedToMinimumLevel: LogEventLevel.Debug,
retainedFileCountLimit: CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance ? 30 : 60,
@@ -203,27 +193,27 @@ namespace PepperDash.Core
CrestronConsole.PrintLine(msg);
LogMessage(LogEventLevel.Information, msg);
IncludedExcludedKeys = new Dictionary<string, object>();
LogMessage(LogEventLevel.Information,msg);
IncludedExcludedKeys = new Dictionary<string, object>();
if (CrestronEnvironment.RuntimeEnvironment == eRuntimeEnvironment.SimplSharpPro)
{
// Add command to console
CrestronConsole.AddNewConsoleCommand(SetDoNotLoadOnNextBootFromConsole, "donotloadonnextboot",
CrestronConsole.AddNewConsoleCommand(SetDoNotLoadOnNextBootFromConsole, "donotloadonnextboot",
"donotloadonnextboot:P [true/false]: Should the application load on next boot", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(SetDebugFromConsole, "appdebug",
"appdebug:P [0-5]: Sets the application's console debug message level",
ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(ShowDebugLog, "appdebuglog",
"appdebuglog:P [all] Use \"all\" for full log.",
"appdebuglog:P [all] Use \"all\" for full log.",
ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s => CrestronLogger.Clear(false), "appdebugclear",
"appdebugclear:P Clears the current custom log",
"appdebugclear:P Clears the current custom log",
ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(SetDebugFilterFromConsole, "appdebugfilter",
"appdebugfilter [params]", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(SetDebugFilterFromConsole, "appdebugfilter",
"appdebugfilter [params]", ConsoleAccessLevelEnum.AccessOperator);
}
CrestronEnvironment.ProgramStatusEventHandler += CrestronEnvironment_ProgramStatusEventHandler;
@@ -234,7 +224,7 @@ namespace PepperDash.Core
Level = context.Level;
DoNotLoadConfigOnNextBoot = context.DoNotLoadOnNextBoot;
if (DoNotLoadConfigOnNextBoot)
if(DoNotLoadConfigOnNextBoot)
CrestronConsole.PrintLine(string.Format("Program {0} will not load config after next boot. Use console command go:{0} to load the config manually", InitialParametersClass.ApplicationNumber));
_consoleLoggingLevelSwitch.MinimumLevelChanged += (sender, args) =>
@@ -243,9 +233,6 @@ namespace PepperDash.Core
};
}
/// <summary>
/// UpdateLoggerConfiguration method
/// </summary>
public static void UpdateLoggerConfiguration(LoggerConfiguration config)
{
_loggerConfiguration = config;
@@ -253,9 +240,6 @@ namespace PepperDash.Core
_logger = config.CreateLogger();
}
/// <summary>
/// ResetLoggerConfiguration method
/// </summary>
public static void ResetLoggerConfiguration()
{
_loggerConfiguration = _defaultLoggerConfiguration;
@@ -267,26 +251,22 @@ namespace PepperDash.Core
{
try
{
var result = CrestronDataStoreStatic.GetLocalIntValue(levelStoreKey, out int logLevel);
var result = CrestronDataStoreStatic.GetLocalIntValue(levelStoreKey, out int logLevel);
if (result != CrestronDataStore.CDS_ERROR.CDS_SUCCESS)
{
CrestronConsole.Print($"Unable to retrieve stored log level for {levelStoreKey}.\r\nError: {result}.\r\nSetting level to {LogEventLevel.Information}\r\n");
CrestronDataStoreStatic.SetLocalIntValue(levelStoreKey, (int)LogEventLevel.Information);
return LogEventLevel.Information;
}
if (logLevel < 0 || logLevel > 5)
if(logLevel < 0 || logLevel > 5)
{
CrestronConsole.PrintLine($"Stored Log level not valid for {levelStoreKey}: {logLevel}. Setting level to {LogEventLevel.Information}");
return LogEventLevel.Information;
}
return (LogEventLevel)logLevel;
}
catch (Exception ex)
} catch (Exception ex)
{
CrestronConsole.PrintLine($"Exception retrieving log level for {levelStoreKey}: {ex.Message}");
return LogEventLevel.Information;
@@ -298,7 +278,7 @@ namespace PepperDash.Core
var assembly = Assembly.GetExecutingAssembly();
var ver =
assembly
.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false);
.GetCustomAttributes(typeof (AssemblyInformationalVersionAttribute), false);
if (ver != null && ver.Length > 0)
{
@@ -339,9 +319,6 @@ namespace PepperDash.Core
/// Callback for console command
/// </summary>
/// <param name="levelString"></param>
/// <summary>
/// SetDebugFromConsole method
/// </summary>
public static void SetDebugFromConsole(string levelString)
{
try
@@ -349,13 +326,13 @@ namespace PepperDash.Core
if (levelString.Trim() == "?")
{
CrestronConsole.ConsoleCommandResponse(
"Used to set the minimum level of debug messages to be printed to the console:\r\n" +
$"{_logLevels[0]} = 0\r\n" +
$"{_logLevels[1]} = 1\r\n" +
$"{_logLevels[2]} = 2\r\n" +
$"{_logLevels[3]} = 3\r\n" +
$"{_logLevels[4]} = 4\r\n" +
$"{_logLevels[5]} = 5");
$@"Used to set the minimum level of debug messages to be printed to the console:
{_logLevels[0]} = 0
{_logLevels[1]} = 1
{_logLevels[2]} = 2
{_logLevels[3]} = 3
{_logLevels[4]} = 4
{_logLevels[5]} = 5");
return;
}
@@ -365,25 +342,25 @@ namespace PepperDash.Core
return;
}
if (int.TryParse(levelString, out var levelInt))
if(int.TryParse(levelString, out var levelInt))
{
if (levelInt < 0 || levelInt > 5)
if(levelInt < 0 || levelInt > 5)
{
CrestronConsole.ConsoleCommandResponse($"Error: Unable to parse {levelString} to valid log level. If using a number, value must be between 0-5");
return;
}
SetDebugLevel((uint)levelInt);
SetDebugLevel((uint) levelInt);
return;
}
if (Enum.TryParse<LogEventLevel>(levelString, true, out var levelEnum))
if(Enum.TryParse<LogEventLevel>(levelString, out var levelEnum))
{
SetDebugLevel(levelEnum);
return;
}
CrestronConsole.ConsoleCommandResponse($"Error: Unable to parse {levelString} to valid log level");
}
}
catch
{
CrestronConsole.ConsoleCommandResponse("Usage: appdebug:P [0-5]");
@@ -394,12 +371,9 @@ namespace PepperDash.Core
/// Sets the debug level
/// </summary>
/// <param name="level"> Valid values 0-5</param>
/// <summary>
/// SetDebugLevel method
/// </summary>
public static void SetDebugLevel(uint level)
{
if (!_logLevels.TryGetValue(level, out var logLevel))
if(!_logLevels.TryGetValue(level, out var logLevel))
{
logLevel = LogEventLevel.Information;
@@ -411,9 +385,6 @@ namespace PepperDash.Core
SetDebugLevel(logLevel);
}
/// <summary>
/// SetDebugLevel method
/// </summary>
public static void SetDebugLevel(LogEventLevel level)
{
_consoleLoggingLevelSwitch.MinimumLevel = level;
@@ -421,9 +392,9 @@ namespace PepperDash.Core
CrestronConsole.ConsoleCommandResponse("[Application {0}], Debug level set to {1}\r\n",
InitialParametersClass.ApplicationNumber, _consoleLoggingLevelSwitch.MinimumLevel);
CrestronConsole.ConsoleCommandResponse($"Storing level {level}:{(int)level}");
CrestronConsole.ConsoleCommandResponse($"Storing level {level}:{(int) level}");
var err = CrestronDataStoreStatic.SetLocalIntValue(LevelStoreKey, (int)level);
var err = CrestronDataStoreStatic.SetLocalIntValue(LevelStoreKey, (int) level);
CrestronConsole.ConsoleCommandResponse($"Store result: {err}:{(int)level}");
@@ -431,14 +402,11 @@ namespace PepperDash.Core
CrestronConsole.PrintLine($"Error saving console debug level setting: {err}");
}
/// <summary>
/// SetWebSocketMinimumDebugLevel method
/// </summary>
public static void SetWebSocketMinimumDebugLevel(LogEventLevel level)
{
_websocketLoggingLevelSwitch.MinimumLevel = level;
_websocketLoggingLevelSwitch.MinimumLevel = level;
var err = CrestronDataStoreStatic.SetLocalUintValue(WebSocketLevelStoreKey, (uint)level);
var err = CrestronDataStoreStatic.SetLocalUintValue(WebSocketLevelStoreKey, (uint) level);
if (err != CrestronDataStore.CDS_ERROR.CDS_SUCCESS)
LogMessage(LogEventLevel.Information, "Error saving websocket debug level setting: {erro}", err);
@@ -446,9 +414,6 @@ namespace PepperDash.Core
LogMessage(LogEventLevel.Information, "Websocket debug level set to {0}", _websocketLoggingLevelSwitch.MinimumLevel);
}
/// <summary>
/// SetErrorLogMinimumDebugLevel method
/// </summary>
public static void SetErrorLogMinimumDebugLevel(LogEventLevel level)
{
_errorLogLevelSwitch.MinimumLevel = level;
@@ -461,9 +426,6 @@ namespace PepperDash.Core
LogMessage(LogEventLevel.Information, "Error log debug level set to {0}", _websocketLoggingLevelSwitch.MinimumLevel);
}
/// <summary>
/// SetFileMinimumDebugLevel method
/// </summary>
public static void SetFileMinimumDebugLevel(LogEventLevel level)
{
_errorLogLevelSwitch.MinimumLevel = level;
@@ -480,9 +442,6 @@ namespace PepperDash.Core
/// Callback for console command
/// </summary>
/// <param name="stateString"></param>
/// <summary>
/// SetDoNotLoadOnNextBootFromConsole method
/// </summary>
public static void SetDoNotLoadOnNextBootFromConsole(string stateString)
{
try
@@ -505,83 +464,80 @@ namespace PepperDash.Core
/// Callback for console command
/// </summary>
/// <param name="items"></param>
/// <summary>
/// SetDebugFilterFromConsole method
/// </summary>
public static void SetDebugFilterFromConsole(string items)
{
var str = items.Trim();
if (str == "?")
{
CrestronConsole.ConsoleCommandResponse("Usage:\r APPDEBUGFILTER key1 key2 key3....\r " +
"+all: at beginning puts filter into 'default include' mode\r" +
" All keys that follow will be excluded from output.\r" +
"-all: at beginning puts filter into 'default exclude all' mode.\r" +
" All keys that follow will be the only keys that are shown\r" +
"+nokey: Enables messages with no key (default)\r" +
"-nokey: Disables messages with no key.\r" +
"(nokey settings are independent of all other settings)");
return;
}
var keys = Regex.Split(str, @"\s*");
foreach (var keyToken in keys)
{
var lkey = keyToken.ToLower();
if (lkey == "+all")
{
IncludedExcludedKeys.Clear();
_excludeAllMode = false;
}
else if (lkey == "-all")
{
IncludedExcludedKeys.Clear();
_excludeAllMode = true;
}
//else if (lkey == "+nokey")
//{
// ExcludeNoKeyMessages = false;
//}
//else if (lkey == "-nokey")
//{
// ExcludeNoKeyMessages = true;
//}
else
{
string key;
if (lkey.StartsWith("-"))
{
key = lkey.Substring(1);
// if in exclude all mode, we need to remove this from the inclusions
if (_excludeAllMode)
{
if (IncludedExcludedKeys.ContainsKey(key))
IncludedExcludedKeys.Remove(key);
}
// otherwise include all mode, add to the exclusions
else
{
IncludedExcludedKeys[key] = new object();
}
}
else if (lkey.StartsWith("+"))
{
key = lkey.Substring(1);
// if in exclude all mode, we need to add this as inclusion
if (_excludeAllMode)
{
public static void SetDebugFilterFromConsole(string items)
{
var str = items.Trim();
if (str == "?")
{
CrestronConsole.ConsoleCommandResponse("Usage:\r APPDEBUGFILTER key1 key2 key3....\r " +
"+all: at beginning puts filter into 'default include' mode\r" +
" All keys that follow will be excluded from output.\r" +
"-all: at beginning puts filter into 'default exclude all' mode.\r" +
" All keys that follow will be the only keys that are shown\r" +
"+nokey: Enables messages with no key (default)\r" +
"-nokey: Disables messages with no key.\r" +
"(nokey settings are independent of all other settings)");
return;
}
var keys = Regex.Split(str, @"\s*");
foreach (var keyToken in keys)
{
var lkey = keyToken.ToLower();
if (lkey == "+all")
{
IncludedExcludedKeys.Clear();
_excludeAllMode = false;
}
else if (lkey == "-all")
{
IncludedExcludedKeys.Clear();
_excludeAllMode = true;
}
//else if (lkey == "+nokey")
//{
// ExcludeNoKeyMessages = false;
//}
//else if (lkey == "-nokey")
//{
// ExcludeNoKeyMessages = true;
//}
else
{
string key;
if (lkey.StartsWith("-"))
{
key = lkey.Substring(1);
// if in exclude all mode, we need to remove this from the inclusions
if (_excludeAllMode)
{
if (IncludedExcludedKeys.ContainsKey(key))
IncludedExcludedKeys.Remove(key);
}
// otherwise include all mode, add to the exclusions
else
{
IncludedExcludedKeys[key] = new object();
}
}
else if (lkey.StartsWith("+"))
{
key = lkey.Substring(1);
// if in exclude all mode, we need to add this as inclusion
if (_excludeAllMode)
{
IncludedExcludedKeys[key] = new object();
}
// otherwise include all mode, remove this from exclusions
else
{
if (IncludedExcludedKeys.ContainsKey(key))
IncludedExcludedKeys.Remove(key);
}
}
}
}
}
IncludedExcludedKeys[key] = new object();
}
// otherwise include all mode, remove this from exclusions
else
{
if (IncludedExcludedKeys.ContainsKey(key))
IncludedExcludedKeys.Remove(key);
}
}
}
}
}
@@ -603,13 +559,10 @@ namespace PepperDash.Core
/// </summary>
/// <param name="deviceKey"></param>
/// <returns></returns>
/// <summary>
/// GetDeviceDebugSettingsForKey method
/// </summary>
public static object GetDeviceDebugSettingsForKey(string deviceKey)
{
return _contexts.GetDebugSettingsForKey(deviceKey);
}
}
/// <summary>
/// Sets the flag to prevent application starting on next boot
@@ -626,7 +579,7 @@ namespace PepperDash.Core
}
/// <summary>
/// ShowDebugLog method
///
/// </summary>
public static void ShowDebugLog(string s)
{
@@ -642,9 +595,6 @@ namespace PepperDash.Core
/// <param name="message">Message template</param>
/// <param name="device">Optional IKeyed device. If provided, the Key of the device will be added to the log message</param>
/// <param name="args">Args to put into message template</param>
/// <summary>
/// LogMessage method
/// </summary>
public static void LogMessage(Exception ex, string message, IKeyed device = null, params object[] args)
{
using (LogContext.PushProperty("Key", device?.Key))
@@ -668,36 +618,21 @@ namespace PepperDash.Core
}
}
/// <summary>
/// Logs a message at the specified log level.
/// </summary>
/// <param name="level">Level to log at</param>
/// <param name="message">Message template</param>
/// <param name="args">Args to put into message template</param>
public static void LogMessage(LogEventLevel level, string message, params object[] args)
{
_logger.Write(level, message, args);
_logger.Write(level, message, args);
}
/// <summary>
/// LogMessage method
/// </summary>
public static void LogMessage(LogEventLevel level, Exception ex, string message, params object[] args)
{
_logger.Write(level, ex, message, args);
}
/// <summary>
/// LogMessage method
/// </summary>
public static void LogMessage(LogEventLevel level, IKeyed keyed, string message, params object[] args)
{
LogMessage(level, message, keyed, args);
}
/// <summary>
/// LogMessage method
/// </summary>
public static void LogMessage(LogEventLevel level, Exception ex, IKeyed device, string message, params object[] args)
{
using (LogContext.PushProperty("Key", device?.Key))
@@ -707,47 +642,32 @@ namespace PepperDash.Core
}
#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))
using(LogContext.PushProperty("Key", keyed?.Key))
{
_logger.Write(LogEventLevel.Verbose, message, args);
}
}
/// <summary>
/// LogVerbose method
/// </summary>
public static void LogVerbose(Exception ex, IKeyed keyed, string message, params object[] args)
{
using (LogContext.PushProperty("Key", keyed?.Key))
using(LogContext.PushProperty("Key", keyed?.Key))
{
_logger.Write(LogEventLevel.Verbose, ex, message, args);
}
}
/// <summary>
/// LogVerbose method
/// </summary>
public static void LogVerbose(string message, params object[] args)
{
_logger.Write(LogEventLevel.Verbose, message, args);
}
/// <summary>
/// LogVerbose method
/// </summary>
public static void LogVerbose(Exception ex, string message, params object[] args)
{
_logger.Write(LogEventLevel.Verbose, ex, message, args);
_logger.Write(LogEventLevel.Verbose, ex, null, message, args);
}
/// <summary>
/// LogDebug method
/// </summary>
public static void LogDebug(IKeyed keyed, string message, params object[] args)
{
using (LogContext.PushProperty("Key", keyed?.Key))
@@ -756,9 +676,6 @@ namespace PepperDash.Core
}
}
/// <summary>
/// LogDebug method
/// </summary>
public static void LogDebug(Exception ex, IKeyed keyed, string message, params object[] args)
{
using (LogContext.PushProperty("Key", keyed?.Key))
@@ -767,25 +684,16 @@ namespace PepperDash.Core
}
}
/// <summary>
/// LogDebug method
/// </summary>
public static void LogDebug(string message, params object[] args)
{
_logger.Write(LogEventLevel.Debug, message, args);
}
/// <summary>
/// LogDebug method
/// </summary>
public static void LogDebug(Exception ex, string message, params object[] args)
{
_logger.Write(LogEventLevel.Debug, ex, null, message, args);
}
/// <summary>
/// LogInformation method
/// </summary>
public static void LogInformation(IKeyed keyed, string message, params object[] args)
{
using (LogContext.PushProperty("Key", keyed?.Key))
@@ -794,9 +702,6 @@ namespace PepperDash.Core
}
}
/// <summary>
/// LogInformation method
/// </summary>
public static void LogInformation(Exception ex, IKeyed keyed, string message, params object[] args)
{
using (LogContext.PushProperty("Key", keyed?.Key))
@@ -805,25 +710,16 @@ namespace PepperDash.Core
}
}
/// <summary>
/// LogInformation method
/// </summary>
public static void LogInformation(string message, params object[] args)
{
_logger.Write(LogEventLevel.Information, message, args);
}
/// <summary>
/// LogInformation method
/// </summary>
public static void LogInformation(Exception ex, string message, params object[] args)
{
_logger.Write(LogEventLevel.Information, ex, message, args);
_logger.Write(LogEventLevel.Information, ex, null, message, args);
}
/// <summary>
/// LogWarning method
/// </summary>
public static void LogWarning(IKeyed keyed, string message, params object[] args)
{
using (LogContext.PushProperty("Key", keyed?.Key))
@@ -832,9 +728,6 @@ namespace PepperDash.Core
}
}
/// <summary>
/// LogWarning method
/// </summary>
public static void LogWarning(Exception ex, IKeyed keyed, string message, params object[] args)
{
using (LogContext.PushProperty("Key", keyed?.Key))
@@ -843,25 +736,16 @@ namespace PepperDash.Core
}
}
/// <summary>
/// LogWarning method
/// </summary>
public static void LogWarning(string message, params object[] args)
{
_logger.Write(LogEventLevel.Warning, message, args);
}
/// <summary>
/// LogWarning method
/// </summary>
public static void LogWarning(Exception ex, string message, params object[] args)
{
_logger.Write(LogEventLevel.Warning, ex, message, args);
_logger.Write(LogEventLevel.Warning, ex, null, message, args);
}
/// <summary>
/// LogError method
/// </summary>
public static void LogError(IKeyed keyed, string message, params object[] args)
{
using (LogContext.PushProperty("Key", keyed?.Key))
@@ -870,9 +754,6 @@ namespace PepperDash.Core
}
}
/// <summary>
/// LogError method
/// </summary>
public static void LogError(Exception ex, IKeyed keyed, string message, params object[] args)
{
using (LogContext.PushProperty("Key", keyed?.Key))
@@ -881,25 +762,16 @@ namespace PepperDash.Core
}
}
/// <summary>
/// LogError method
/// </summary>
public static void LogError(string message, params object[] args)
{
_logger.Write(LogEventLevel.Error, message, args);
}
/// <summary>
/// LogError method
/// </summary>
public static void LogError(Exception ex, string message, params object[] args)
{
_logger.Write(LogEventLevel.Error, ex, message, args);
_logger.Write(LogEventLevel.Error, ex, null, message, args);
}
/// <summary>
/// LogFatal method
/// </summary>
public static void LogFatal(IKeyed keyed, string message, params object[] args)
{
using (LogContext.PushProperty("Key", keyed?.Key))
@@ -908,9 +780,6 @@ namespace PepperDash.Core
}
}
/// <summary>
/// LogFatal method
/// </summary>
public static void LogFatal(Exception ex, IKeyed keyed, string message, params object[] args)
{
using (LogContext.PushProperty("Key", keyed?.Key))
@@ -919,20 +788,14 @@ namespace PepperDash.Core
}
}
/// <summary>
/// LogFatal method
/// </summary>
public static void LogFatal(string message, params object[] args)
{
_logger.Write(LogEventLevel.Fatal, message, args);
}
/// <summary>
/// LogFatal method
/// </summary>
public static void LogFatal(Exception ex, string message, params object[] args)
{
_logger.Write(LogEventLevel.Fatal, ex, message, args);
_logger.Write(LogEventLevel.Fatal, ex, null, message, args);
}
#endregion
@@ -943,7 +806,7 @@ namespace PepperDash.Core
if (!_logLevels.ContainsKey(level)) return;
var logLevel = _logLevels[level];
LogMessage(logLevel, format, items);
}
@@ -998,7 +861,7 @@ namespace PepperDash.Core
[Obsolete("Use LogMessage methods, Will be removed in 2.2.0 and later versions")]
public static void Console(uint level, IKeyed dev, ErrorLogLevel errorLogLevel,
string format, params object[] items)
{
{
LogMessage(level, dev, format, items);
}
@@ -1006,9 +869,6 @@ namespace PepperDash.Core
/// Logs to Console when at-level, and all messages to error log
/// </summary>
[Obsolete("Use LogMessage methods, Will be removed in 2.2.0 and later versions")]
/// <summary>
/// Console method
/// </summary>
public static void Console(uint level, ErrorLogLevel errorLogLevel,
string format, params object[] items)
{
@@ -1021,9 +881,6 @@ namespace PepperDash.Core
/// it will only be written to the log.
/// </summary>
[Obsolete("Use LogMessage methods, Will be removed in 2.2.0 and later versions")]
/// <summary>
/// ConsoleWithLog method
/// </summary>
public static void ConsoleWithLog(uint level, string format, params object[] items)
{
LogMessage(level, format, items);
@@ -1142,26 +999,26 @@ namespace PepperDash.Core
return string.Format(@"\user\debugSettings\program{0}", InitialParametersClass.ApplicationNumber);
}
return string.Format("{0}{1}user{1}debugSettings{1}{2}.json", Directory.GetApplicationRootDirectory(), Path.DirectorySeparatorChar, InitialParametersClass.RoomId);
return string.Format("{0}{1}user{1}debugSettings{1}{2}.json",Directory.GetApplicationRootDirectory(), Path.DirectorySeparatorChar, InitialParametersClass.RoomId);
}
/// <summary>
/// Enumeration of ErrorLogLevel values
/// Error level to for message to be logged at
/// </summary>
public enum ErrorLogLevel
{
/// <summary>
/// Error
/// </summary>
Error,
Error,
/// <summary>
/// Warning
/// </summary>
Warning,
Warning,
/// <summary>
/// Notice
/// </summary>
Notice,
Notice,
/// <summary>
/// None
/// </summary>

View File

@@ -11,16 +11,10 @@ using System.Text;
namespace PepperDash.Core
{
/// <summary>
/// Represents a DebugConsoleSink
/// </summary>
public class DebugConsoleSink : ILogEventSink
{
private readonly ITextFormatter _textFormatter;
/// <summary>
/// Emit method
/// </summary>
public void Emit(LogEvent logEvent)
{
if (!Debug.IsRunningOnAppliance) return;
@@ -50,9 +44,6 @@ namespace PepperDash.Core
public static class DebugConsoleSinkExtensions
{
/// <summary>
/// DebugConsoleSink method
/// </summary>
public static LoggerConfiguration DebugConsoleSink(
this LoggerSinkConfiguration loggerConfiguration,
ITextFormatter formatProvider = null)

View File

@@ -19,9 +19,9 @@ namespace PepperDash.Core
/// </summary>
public string Key { get; private set; }
/// <summary>
/// The name of the file containing the current debug settings.
/// </summary>
///// <summary>
///// The name of the file containing the current debug settings.
///// </summary>
//string FileName = string.Format(@"\nvram\debug\app{0}Debug.json", InitialParametersClass.ApplicationNumber);
DebugContextSaveData SaveData;
@@ -38,9 +38,6 @@ namespace PepperDash.Core
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
/// <summary>
/// GetDebugContext method
/// </summary>
public static DebugContext GetDebugContext(string key)
{
var context = Contexts.FirstOrDefault(c => c.Key.Equals(key, StringComparison.OrdinalIgnoreCase));
@@ -95,9 +92,6 @@ namespace PepperDash.Core
/// Callback for console command
/// </summary>
/// <param name="levelString"></param>
/// <summary>
/// SetDebugFromConsole method
/// </summary>
public void SetDebugFromConsole(string levelString)
{
try
@@ -120,9 +114,6 @@ namespace PepperDash.Core
/// Sets the debug level
/// </summary>
/// <param name="level"> Valid values 0 (no debug), 1 (critical), 2 (all messages)</param>
/// <summary>
/// SetDebugLevel method
/// </summary>
public void SetDebugLevel(int level)
{
if (level <= 2)
@@ -150,7 +141,7 @@ namespace PepperDash.Core
}
/// <summary>
/// Console method
/// Appends a device Key to the beginning of a message
/// </summary>
public void Console(uint level, IKeyed dev, string format, params object[] items)
{
@@ -200,9 +191,6 @@ namespace PepperDash.Core
/// </summary>
/// <param name="errorLogLevel"></param>
/// <param name="str"></param>
/// <summary>
/// LogError method
/// </summary>
public void LogError(Debug.ErrorLogLevel errorLogLevel, string str)
{
string msg = string.Format("App {0}:{1}", InitialParametersClass.ApplicationNumber, str);

View File

@@ -5,14 +5,8 @@ using Serilog.Events;
namespace PepperDash.Core.Logging
{
/// <summary>
/// Represents a DebugCrestronLoggerSink
/// </summary>
public class DebugCrestronLoggerSink : ILogEventSink
{
/// <summary>
/// Emit method
/// </summary>
public void Emit(LogEvent logEvent)
{
if (!Debug.IsRunningOnAppliance) return;

View File

@@ -11,9 +11,6 @@ using System.Threading.Tasks;
namespace PepperDash.Core.Logging
{
/// <summary>
/// Represents a DebugErrorLogSink
/// </summary>
public class DebugErrorLogSink : ILogEventSink
{
private ITextFormatter _formatter;
@@ -27,9 +24,6 @@ namespace PepperDash.Core.Logging
{LogEventLevel.Error, (msg) => ErrorLog.Error(msg) },
{LogEventLevel.Fatal, (msg) => ErrorLog.Error(msg) }
};
/// <summary>
/// Emit method
/// </summary>
public void Emit(LogEvent logEvent)
{
string message;

View File

@@ -1,113 +1,74 @@
using System;
using Serilog.Events;
using Serilog.Events;
using System;
using Log = PepperDash.Core.Debug;
namespace PepperDash.Core.Logging
{
public static class DebugExtensions
{
/// <summary>
/// LogException method
/// </summary>
public static void LogException(this IKeyed device, Exception ex, string message, params object[] args)
{
Log.LogMessage(ex, message, device: device, args);
Log.LogMessage(ex, message, device, args);
}
/// <summary>
/// LogVerbose method
/// </summary>
public static void LogVerbose(this IKeyed device, Exception ex, string message, params object[] args)
{
Log.LogVerbose(ex, device, message, args);
Log.LogMessage(LogEventLevel.Verbose, ex, message, device, args);
}
/// <summary>
/// LogVerbose method
/// </summary>
public static void LogVerbose(this IKeyed device, string message, params object[] args)
{
Log.LogVerbose(device, message, args);
Log.LogMessage(LogEventLevel.Verbose, device, message, args);
}
/// <summary>
/// LogDebug method
/// </summary>
public static void LogDebug(this IKeyed device, Exception ex, string message, params object[] args)
{
Log.LogDebug(ex, device, message, args);
Log.LogMessage(LogEventLevel.Debug, ex, message, device, args);
}
/// <summary>
/// LogDebug method
/// </summary>
public static void LogDebug(this IKeyed device, string message, params object[] args)
{
Log.LogDebug(device, message, args);
Log.LogMessage(LogEventLevel.Debug, device, message, args);
}
/// <summary>
/// LogInformation method
/// </summary>
public static void LogInformation(this IKeyed device, Exception ex, string message, params object[] args)
{
Log.LogInformation(ex, device, message, args);
Log.LogMessage(LogEventLevel.Information, ex, message, device, args);
}
/// <summary>
/// LogInformation method
/// </summary>
public static void LogInformation(this IKeyed device, string message, params object[] args)
{
Log.LogInformation(device, message, args);
Log.LogMessage(LogEventLevel.Information, device, message, args);
}
/// <summary>
/// LogWarning method
/// </summary>
public static void LogWarning(this IKeyed device, Exception ex, string message, params object[] args)
{
Log.LogWarning(ex, device, message, args);
Log.LogMessage(LogEventLevel.Warning, ex, message, device, args);
}
/// <summary>
/// LogWarning method
/// </summary>
public static void LogWarning(this IKeyed device, string message, params object[] args)
{
Log.LogWarning(device, message, args);
Log.LogMessage(LogEventLevel.Warning, device, message, args);
}
/// <summary>
/// LogError method
/// </summary>
public static void LogError(this IKeyed device, Exception ex, string message, params object[] args)
{
Log.LogError(ex, device, message, args);
Log.LogMessage(LogEventLevel.Error, ex, message, device, args);
}
/// <summary>
/// LogError method
/// </summary>
public static void LogError(this IKeyed device, string message, params object[] args)
{
Log.LogError(device, message, args);
Log.LogMessage(LogEventLevel.Error, device, message, args);
}
/// <summary>
/// LogFatal method
/// </summary>
public static void LogFatal(this IKeyed device, Exception ex, string message, params object[] args)
{
Log.LogFatal(ex, device, message, args);
Log.LogMessage(LogEventLevel.Fatal, ex, message, device, args);
}
/// <summary>
/// LogFatal method
/// </summary>
public static void LogFatal(this IKeyed device, string message, params object[] args)
{
Log.LogFatal(device, message, args);
Log.LogMessage(LogEventLevel.Fatal, device, message, args);
}
}
}

View File

@@ -4,9 +4,9 @@ using Newtonsoft.Json;
namespace PepperDash.Core.Logging
{
/// <summary>
/// Represents a DebugContextCollection
/// </summary>
/// <summary>
/// Class to persist current Debug settings across program restarts
/// </summary>
public class DebugContextCollection
{
/// <summary>
@@ -39,9 +39,6 @@ namespace PepperDash.Core.Logging
/// </summary>
/// <param name="contextKey"></param>
/// <param name="level"></param>
/// <summary>
/// SetLevel method
/// </summary>
public void SetLevel(string contextKey, int level)
{
if (level < 0 || level > 2)
@@ -54,9 +51,6 @@ namespace PepperDash.Core.Logging
/// </summary>
/// <param name="contextKey"></param>
/// <returns></returns>
/// <summary>
/// GetOrCreateItem method
/// </summary>
public DebugContextItem GetOrCreateItem(string contextKey)
{
if (!_items.ContainsKey(contextKey))
@@ -71,9 +65,6 @@ namespace PepperDash.Core.Logging
/// <param name="deviceKey"></param>
/// <param name="settings"></param>
/// <returns></returns>
/// <summary>
/// SetDebugSettingsForKey method
/// </summary>
public void SetDebugSettingsForKey(string deviceKey, object settings)
{
try
@@ -98,9 +89,6 @@ namespace PepperDash.Core.Logging
/// </summary>
/// <param name="deviceKey"></param>
/// <returns></returns>
/// <summary>
/// GetDebugSettingsForKey method
/// </summary>
public object GetDebugSettingsForKey(string deviceKey)
{
return DeviceDebugSettings[deviceKey];

View File

@@ -21,9 +21,6 @@ using Serilog.Formatting.Json;
namespace PepperDash.Core
{
/// <summary>
/// Represents a DebugWebsocketSink
/// </summary>
public class DebugWebsocketSink : ILogEventSink
{
private HttpServer _httpsServer;
@@ -50,9 +47,6 @@ namespace PepperDash.Core
}
}
/// <summary>
/// Gets or sets the IsRunning
/// </summary>
public bool IsRunning { get => _httpsServer?.IsListening ?? false; }
@@ -111,9 +105,6 @@ namespace PepperDash.Core
}
}
/// <summary>
/// Emit method
/// </summary>
public void Emit(LogEvent logEvent)
{
if (_httpsServer == null || !_httpsServer.IsListening) return;
@@ -125,9 +116,6 @@ namespace PepperDash.Core
}
/// <summary>
/// StartServerAndSetPort method
/// </summary>
public void StartServerAndSetPort(int port)
{
Debug.Console(0, "Starting Websocket Server on port: {0}", port);
@@ -205,9 +193,6 @@ namespace PepperDash.Core
}
}
/// <summary>
/// StopServer method
/// </summary>
public void StopServer()
{
Debug.Console(0, "Stopping Websocket Server");
@@ -219,9 +204,6 @@ namespace PepperDash.Core
public static class DebugWebsocketSinkExtensions
{
/// <summary>
/// DebugWebsocketSink method
/// </summary>
public static LoggerConfiguration DebugWebsocketSink(
this LoggerSinkConfiguration loggerConfiguration,
ITextFormatter formatProvider = null)
@@ -230,9 +212,6 @@ namespace PepperDash.Core
}
}
/// <summary>
/// Represents a DebugClient
/// </summary>
public class DebugClient : WebSocketBehavior
{
private DateTime _connectionTime;

View File

@@ -2,9 +2,9 @@
namespace PepperDash.Core.PasswordManagement
{
/// <summary>
/// Represents a PasswordClient
/// </summary>
/// <summary>
/// A class to allow user interaction with the PasswordManager
/// </summary>
public class PasswordClient
{
/// <summary>
@@ -59,9 +59,6 @@ namespace PepperDash.Core.PasswordManagement
/// Retrieve password by index
/// </summary>
/// <param name="key"></param>
/// <summary>
/// GetPasswordByIndex method
/// </summary>
public void GetPasswordByIndex(ushort key)
{
OnUshrtChange((ushort)PasswordManager.Passwords.Count, 0, PasswordManagementConstants.PasswordManagerCountChange);
@@ -84,9 +81,6 @@ namespace PepperDash.Core.PasswordManagement
/// Password validation method
/// </summary>
/// <param name="password"></param>
/// <summary>
/// ValidatePassword method
/// </summary>
public void ValidatePassword(string password)
{
if (string.IsNullOrEmpty(password))
@@ -105,9 +99,6 @@ namespace PepperDash.Core.PasswordManagement
/// password against the selected password when the length of the 2 are equal
/// </summary>
/// <param name="data"></param>
/// <summary>
/// BuildPassword method
/// </summary>
public void BuildPassword(string data)
{
PasswordToValidate = String.Concat(PasswordToValidate, data);
@@ -117,9 +108,9 @@ namespace PepperDash.Core.PasswordManagement
ValidatePassword(PasswordToValidate);
}
/// <summary>
/// ClearPassword method
/// </summary>
/// <summary>
/// Clears the user entered password and resets the LEDs
/// </summary>
public void ClearPassword()
{
PasswordToValidate = "";

View File

@@ -4,9 +4,9 @@ using Crestron.SimplSharp;
namespace PepperDash.Core.PasswordManagement
{
/// <summary>
/// Represents a PasswordManager
/// </summary>
/// <summary>
/// Allows passwords to be stored and managed
/// </summary>
public class PasswordManager
{
/// <summary>
@@ -71,9 +71,6 @@ namespace PepperDash.Core.PasswordManagement
/// </summary>
/// <param name="key"></param>
/// <param name="password"></param>
/// <summary>
/// UpdatePassword method
/// </summary>
public void UpdatePassword(ushort key, string password)
{
// validate the parameters
@@ -155,9 +152,6 @@ namespace PepperDash.Core.PasswordManagement
/// Method to change the default timer value, (default 5000ms/5s)
/// </summary>
/// <param name="time"></param>
/// <summary>
/// PasswordTimerMs method
/// </summary>
public void PasswordTimerMs(ushort time)
{
PasswordTimerElapsedMs = Convert.ToInt64(time);

View File

@@ -68,9 +68,9 @@ namespace PepperDash.Core.SystemInfo
public const ushort ProgramConfigChange = 305;
}
/// <summary>
/// Represents a ProcessorChangeEventArgs
/// </summary>
/// <summary>
/// Processor Change Event Args Class
/// </summary>
public class ProcessorChangeEventArgs : EventArgs
{
/// <summary>
@@ -114,9 +114,9 @@ namespace PepperDash.Core.SystemInfo
}
}
/// <summary>
/// Represents a EthernetChangeEventArgs
/// </summary>
/// <summary>
/// Ethernet Change Event Args Class
/// </summary>
public class EthernetChangeEventArgs : EventArgs
{
/// <summary>
@@ -165,9 +165,9 @@ namespace PepperDash.Core.SystemInfo
}
}
/// <summary>
/// Represents a ControlSubnetChangeEventArgs
/// </summary>
/// <summary>
/// Control Subnet Chage Event Args Class
/// </summary>
public class ControlSubnetChangeEventArgs : EventArgs
{
/// <summary>
@@ -211,9 +211,9 @@ namespace PepperDash.Core.SystemInfo
}
}
/// <summary>
/// Represents a ProgramChangeEventArgs
/// </summary>
/// <summary>
/// Program Change Event Args Class
/// </summary>
public class ProgramChangeEventArgs : EventArgs
{
/// <summary>

View File

@@ -100,9 +100,9 @@ namespace PepperDash.Core.SystemInfo
OnBoolChange(false, 0, SystemInfoConstants.BusyBoolChange);
}
/// <summary>
/// GetEthernetInfo method
/// </summary>
/// <summary>
/// Gets the current ethernet info
/// </summary>
public void GetEthernetInfo()
{
OnBoolChange(true, 0, SystemInfoConstants.BusyBoolChange);
@@ -161,9 +161,9 @@ namespace PepperDash.Core.SystemInfo
OnBoolChange(false, 0, SystemInfoConstants.BusyBoolChange);
}
/// <summary>
/// GetControlSubnetInfo method
/// </summary>
/// <summary>
/// Gets the current control subnet info
/// </summary>
public void GetControlSubnetInfo()
{
OnBoolChange(true, 0, SystemInfoConstants.BusyBoolChange);
@@ -206,9 +206,6 @@ namespace PepperDash.Core.SystemInfo
/// Gets the program info by index
/// </summary>
/// <param name="index"></param>
/// <summary>
/// GetProgramInfoByIndex method
/// </summary>
public void GetProgramInfoByIndex(ushort index)
{
if (index < 1 || index > 10)
@@ -266,9 +263,9 @@ namespace PepperDash.Core.SystemInfo
OnBoolChange(false, 0, SystemInfoConstants.BusyBoolChange);
}
/// <summary>
/// RefreshProcessorUptime method
/// </summary>
/// <summary>
/// Gets the processor uptime and passes it to S+
/// </summary>
public void RefreshProcessorUptime()
{
try
@@ -290,9 +287,6 @@ namespace PepperDash.Core.SystemInfo
/// Gets the program uptime, by index, and passes it to S+
/// </summary>
/// <param name="index"></param>
/// <summary>
/// RefreshProgramUptimeByIndex method
/// </summary>
public void RefreshProgramUptimeByIndex(int index)
{
try
@@ -314,9 +308,6 @@ namespace PepperDash.Core.SystemInfo
/// Sends command to console, passes response back using string change event
/// </summary>
/// <param name="cmd"></param>
/// <summary>
/// SendConsoleCommand method
/// </summary>
public void SendConsoleCommand(string cmd)
{
if (string.IsNullOrEmpty(cmd))

View File

@@ -35,9 +35,6 @@ namespace PepperDash.Core
return issuerCertificate;
}
/// <summary>
/// IssueCertificate method
/// </summary>
public X509Certificate2 IssueCertificate(string subjectName, X509Certificate2 issuerCertificate, string[] subjectAlternativeNames, KeyPurposeID[] usages)
{
// It's self-signed, so these are the same.
@@ -59,9 +56,6 @@ namespace PepperDash.Core
return ConvertCertificate(certificate, subjectKeyPair, random);
}
/// <summary>
/// CreateCertificateAuthorityCertificate method
/// </summary>
public X509Certificate2 CreateCertificateAuthorityCertificate(string subjectName, string[] subjectAlternativeNames, KeyPurposeID[] usages)
{
// It's self-signed, so these are the same.
@@ -84,9 +78,6 @@ namespace PepperDash.Core
return ConvertCertificate(certificate, subjectKeyPair, random);
}
/// <summary>
/// CreateSelfSignedCertificate method
/// </summary>
public X509Certificate2 CreateSelfSignedCertificate(string subjectName, string[] subjectAlternativeNames, KeyPurposeID[] usages)
{
// It's self-signed, so these are the same.
@@ -314,9 +305,6 @@ namespace PepperDash.Core
return convertedCertificate;
}
/// <summary>
/// WriteCertificate method
/// </summary>
public void WriteCertificate(X509Certificate2 certificate, string outputDirectory, string certName)
{
// This password is the one attached to the PFX file. Use 'null' for no password.
@@ -344,9 +332,6 @@ namespace PepperDash.Core
}
}
}
/// <summary>
/// AddCertToStore method
/// </summary>
public bool AddCertToStore(X509Certificate2 cert, System.Security.Cryptography.X509Certificates.StoreName st, System.Security.Cryptography.X509Certificates.StoreLocation sl)
{
bool bRet = false;

View File

@@ -2,9 +2,9 @@
namespace PepperDash.Core.Web.RequestHandlers
{
/// <summary>
/// Represents a DefaultRequestHandler
/// </summary>
/// <summary>
/// Web API default request handler
/// </summary>
public class DefaultRequestHandler : WebApiBaseRequestHandler
{
/// <summary>

View File

@@ -142,9 +142,6 @@ namespace PepperDash.Core.Web.RequestHandlers
/// Process request
/// </summary>
/// <param name="context"></param>
/// <summary>
/// ProcessRequest method
/// </summary>
public void ProcessRequest(HttpCwsContext context)
{
if (!_handlers.TryGetValue(context.Request.HttpMethod, out Func<HttpCwsContext, Task> handler))

View File

@@ -144,9 +144,6 @@ namespace PepperDash.Core.Web.RequestHandlers
/// Process request
/// </summary>
/// <param name="context"></param>
/// <summary>
/// ProcessRequest method
/// </summary>
public void ProcessRequest(HttpCwsContext context)
{
Action<HttpCwsContext> handler;

View File

@@ -25,24 +25,24 @@ namespace PepperDash.Core.Web
private readonly CCriticalSection _serverLock = new CCriticalSection();
private HttpCwsServer _server;
/// <summary>
/// Gets or sets the Key
/// </summary>
/// <summary>
/// Web API server key
/// </summary>
public string Key { get; private set; }
/// <summary>
/// Gets or sets the Name
/// </summary>
/// <summary>
/// Web API server name
/// </summary>
public string Name { get; private set; }
/// <summary>
/// Gets or sets the BasePath
/// </summary>
/// <summary>
/// CWS base path, will default to "/api" if not set via initialize method
/// </summary>
public string BasePath { get; private set; }
/// <summary>
/// Gets or sets the IsRegistered
/// </summary>
/// <summary>
/// Indicates CWS is registered with base path
/// </summary>
public bool IsRegistered { get; private set; }
/// <summary>
@@ -137,9 +137,9 @@ namespace PepperDash.Core.Web
Start();
}
/// <summary>
/// Initialize method
/// </summary>
/// <summary>
/// Initializes CWS class
/// </summary>
public void Initialize(string key, string basePath)
{
Key = key;
@@ -165,9 +165,6 @@ namespace PepperDash.Core.Web
/// Removes a route from CWS
/// </summary>
/// <param name="route"></param>
/// <summary>
/// RemoveRoute method
/// </summary>
public void RemoveRoute(HttpCwsRoute route)
{
if (route == null)
@@ -179,9 +176,9 @@ namespace PepperDash.Core.Web
_server.Routes.Remove(route);
}
/// <summary>
/// GetRouteCollection method
/// </summary>
/// <summary>
/// Returns a list of the current routes
/// </summary>
public HttpCwsRouteCollection GetRouteCollection()
{
return _server.Routes;
@@ -225,9 +222,9 @@ namespace PepperDash.Core.Web
}
}
/// <summary>
/// Stop method
/// </summary>
/// <summary>
/// Stop CWS instance
/// </summary>
public void Stop()
{
try

View File

@@ -2,9 +2,9 @@
namespace PepperDash.Core.WebApi.Presets
{
/// <summary>
/// Represents a Preset
/// </summary>
/// <summary>
/// Represents a preset
/// </summary>
public class Preset
{
/// <summary>
@@ -12,29 +12,29 @@ namespace PepperDash.Core.WebApi.Presets
/// </summary>
public int Id { get; set; }
/// <summary>
/// Gets or sets the UserId
/// </summary>
/// <summary>
/// User ID
/// </summary>
public int UserId { get; set; }
/// <summary>
/// Gets or sets the RoomTypeId
/// </summary>
/// <summary>
/// Room Type ID
/// </summary>
public int RoomTypeId { get; set; }
/// <summary>
/// Gets or sets the PresetName
/// </summary>
/// <summary>
/// Preset Name
/// </summary>
public string PresetName { get; set; }
/// <summary>
/// Gets or sets the PresetNumber
/// </summary>
/// <summary>
/// Preset Number
/// </summary>
public int PresetNumber { get; set; }
/// <summary>
/// Gets or sets the Data
/// </summary>
/// <summary>
/// Preset Data
/// </summary>
public string Data { get; set; }
/// <summary>
@@ -48,9 +48,9 @@ namespace PepperDash.Core.WebApi.Presets
}
}
/// <summary>
/// Represents a PresetReceivedEventArgs
/// </summary>
/// <summary>
///
/// </summary>
public class PresetReceivedEventArgs : EventArgs
{
/// <summary>
@@ -59,12 +59,12 @@ namespace PepperDash.Core.WebApi.Presets
public bool LookupSuccess { get; private set; }
/// <summary>
/// Gets or sets the ULookupSuccess
/// S+ helper
/// </summary>
public ushort ULookupSuccess { get { return (ushort)(LookupSuccess ? 1 : 0); } }
/// <summary>
/// Gets or sets the Preset
/// The preset
/// </summary>
public Preset Preset { get; private set; }

View File

@@ -16,19 +16,19 @@ namespace PepperDash.Core.WebApi.Presets
/// </summary>
public int Id { get; set; }
/// <summary>
/// Gets or sets the ExternalId
/// </summary>
/// <summary>
///
/// </summary>
public string ExternalId { get; set; }
/// <summary>
/// Gets or sets the FirstName
/// </summary>
/// <summary>
///
/// </summary>
public string FirstName { get; set; }
/// <summary>
/// Gets or sets the LastName
/// </summary>
/// <summary>
///
/// </summary>
public string LastName { get; set; }
}
@@ -44,13 +44,13 @@ namespace PepperDash.Core.WebApi.Presets
public bool LookupSuccess { get; private set; }
/// <summary>
/// Gets or sets the ULookupSuccess
/// For stupid S+
/// </summary>
public ushort ULookupSuccess { get { return (ushort)(LookupSuccess ? 1 : 0); } }
/// <summary>
/// Gets or sets the User
/// </summary>
/// <summary>
///
/// </summary>
public User User { get; private set; }
/// <summary>
@@ -70,9 +70,9 @@ namespace PepperDash.Core.WebApi.Presets
}
}
/// <summary>
/// Represents a UserAndRoomMessage
/// </summary>
/// <summary>
///
/// </summary>
public class UserAndRoomMessage
{
/// <summary>
@@ -80,14 +80,14 @@ namespace PepperDash.Core.WebApi.Presets
/// </summary>
public int UserId { get; set; }
/// <summary>
/// Gets or sets the RoomTypeId
/// </summary>
/// <summary>
///
/// </summary>
public int RoomTypeId { get; set; }
/// <summary>
/// Gets or sets the PresetNumber
/// </summary>
/// <summary>
///
/// </summary>
public int PresetNumber { get; set; }
}
}

View File

@@ -25,9 +25,9 @@ namespace PepperDash.Core.WebApi.Presets
/// </summary>
public event EventHandler<PresetReceivedEventArgs> PresetReceived;
/// <summary>
/// Gets or sets the Key
/// </summary>
/// <summary>
/// Unique identifier for this instance
/// </summary>
public string Key { get; private set; }
//string JsonMasterKey;
@@ -77,9 +77,6 @@ namespace PepperDash.Core.WebApi.Presets
/// Gets the user for a passcode
/// </summary>
/// <param name="passcode"></param>
/// <summary>
/// GetUserForPasscode method
/// </summary>
public void GetUserForPasscode(string passcode)
{
// Bullshit duplicate code here... These two cases should be the same
@@ -118,9 +115,6 @@ namespace PepperDash.Core.WebApi.Presets
/// </summary>
/// <param name="roomTypeId"></param>
/// <param name="presetNumber"></param>
/// <summary>
/// GetPresetForThisUser method
/// </summary>
public void GetPresetForThisUser(int roomTypeId, int presetNumber)
{
if (CurrentUser == null)
@@ -218,9 +212,6 @@ namespace PepperDash.Core.WebApi.Presets
/// </summary>
/// <param name="roomTypeId"></param>
/// <param name="presetNumber"></param>
/// <summary>
/// SavePresetForThisUser method
/// </summary>
public void SavePresetForThisUser(int roomTypeId, int presetNumber)
{
if (CurrentPreset == null)

View File

@@ -59,9 +59,6 @@ namespace PepperDash.Core.Intersystem.Tokens
/// </summary>
/// <param name="offset"></param>
/// <returns></returns>
/// <summary>
/// GetTokenWithOffset method
/// </summary>
public override XSigToken GetTokenWithOffset(int offset)
{
if (offset == 0) return this;
@@ -72,10 +69,6 @@ namespace PepperDash.Core.Intersystem.Tokens
///
/// </summary>
/// <returns></returns>
/// <summary>
/// ToString method
/// </summary>
/// <inheritdoc />
public override string ToString()
{
return Index + " = 0x" + Value.ToString("X4");
@@ -87,9 +80,6 @@ namespace PepperDash.Core.Intersystem.Tokens
/// <param name="format"></param>
/// <param name="formatProvider"></param>
/// <returns></returns>
/// <summary>
/// ToString method
/// </summary>
public string ToString(string format, IFormatProvider formatProvider)
{
return Value.ToString(format, formatProvider);

View File

@@ -57,9 +57,6 @@ namespace PepperDash.Core.Intersystem.Tokens
/// </summary>
/// <param name="offset"></param>
/// <returns></returns>
/// <summary>
/// GetTokenWithOffset method
/// </summary>
public override XSigToken GetTokenWithOffset(int offset)
{
if (offset == 0) return this;
@@ -70,10 +67,6 @@ namespace PepperDash.Core.Intersystem.Tokens
///
/// </summary>
/// <returns></returns>
/// <summary>
/// ToString method
/// </summary>
/// <inheritdoc />
public override string ToString()
{
return Index + " = " + (Value ? "High" : "Low");
@@ -84,9 +77,6 @@ namespace PepperDash.Core.Intersystem.Tokens
/// </summary>
/// <param name="formatProvider"></param>
/// <returns></returns>
/// <summary>
/// ToString method
/// </summary>
public string ToString(IFormatProvider formatProvider)
{
return Value.ToString(formatProvider);

View File

@@ -63,9 +63,6 @@ namespace PepperDash.Core.Intersystem.Tokens
/// </summary>
/// <param name="offset"></param>
/// <returns></returns>
/// <summary>
/// GetTokenWithOffset method
/// </summary>
public override XSigToken GetTokenWithOffset(int offset)
{
if (offset == 0) return this;
@@ -76,10 +73,6 @@ namespace PepperDash.Core.Intersystem.Tokens
///
/// </summary>
/// <returns></returns>
/// <summary>
/// ToString method
/// </summary>
/// <inheritdoc />
public override string ToString()
{
return Index + " = \"" + Value + "\"";

View File

@@ -52,9 +52,6 @@ namespace PepperDash.Core.Intersystem
/// </summary>
/// <param name="xSigSerialization">XSig state resolver.</param>
/// <returns>Bytes in XSig format for each token within the state representation.</returns>
/// <summary>
/// GetBytes method
/// </summary>
public static byte[] GetBytes(IXSigSerialization xSigSerialization)
{
return GetBytes(xSigSerialization, 0);
@@ -66,9 +63,6 @@ namespace PepperDash.Core.Intersystem
/// <param name="xSigSerialization">XSig state resolver.</param>
/// <param name="offset">Offset to which the data will be aligned.</param>
/// <returns>Bytes in XSig format for each token within the state representation.</returns>
/// <summary>
/// GetBytes method
/// </summary>
public static byte[] GetBytes(IXSigSerialization xSigSerialization, int offset)
{
var tokens = xSigSerialization.Serialize();
@@ -88,9 +82,6 @@ namespace PepperDash.Core.Intersystem
/// <param name="index">1-based digital index</param>
/// <param name="value">Digital data to be encoded</param>
/// <returns>Bytes in XSig format for digtial information.</returns>
/// <summary>
/// GetBytes method
/// </summary>
public static byte[] GetBytes(int index, bool value)
{
return GetBytes(index, 0, value);
@@ -103,9 +94,6 @@ namespace PepperDash.Core.Intersystem
/// <param name="offset">Index offset.</param>
/// <param name="value">Digital data to be encoded</param>
/// <returns>Bytes in XSig format for digtial information.</returns>
/// <summary>
/// GetBytes method
/// </summary>
public static byte[] GetBytes(int index, int offset, bool value)
{
return new XSigDigitalToken(index + offset, value).GetBytes();
@@ -117,9 +105,6 @@ namespace PepperDash.Core.Intersystem
/// <param name="startIndex">Starting index of the sequence.</param>
/// <param name="values">Digital signal value array.</param>
/// <returns>Byte sequence in XSig format for digital signal information.</returns>
/// <summary>
/// GetBytes method
/// </summary>
public static byte[] GetBytes(int startIndex, bool[] values)
{
return GetBytes(startIndex, 0, values);
@@ -132,9 +117,6 @@ namespace PepperDash.Core.Intersystem
/// <param name="offset">Index offset.</param>
/// <param name="values">Digital signal value array.</param>
/// <returns>Byte sequence in XSig format for digital signal information.</returns>
/// <summary>
/// GetBytes method
/// </summary>
public static byte[] GetBytes(int startIndex, int offset, bool[] values)
{
// Digital XSig data is 2 bytes per value
@@ -152,9 +134,6 @@ namespace PepperDash.Core.Intersystem
/// <param name="index">1-based analog index</param>
/// <param name="value">Analog data to be encoded</param>
/// <returns>Bytes in XSig format for analog signal information.</returns>
/// <summary>
/// GetBytes method
/// </summary>
public static byte[] GetBytes(int index, ushort value)
{
return GetBytes(index, 0, value);
@@ -167,9 +146,6 @@ namespace PepperDash.Core.Intersystem
/// <param name="offset">Index offset.</param>
/// <param name="value">Analog data to be encoded</param>
/// <returns>Bytes in XSig format for analog signal information.</returns>
/// <summary>
/// GetBytes method
/// </summary>
public static byte[] GetBytes(int index, int offset, ushort value)
{
return new XSigAnalogToken(index + offset, value).GetBytes();
@@ -181,9 +157,6 @@ namespace PepperDash.Core.Intersystem
/// <param name="startIndex">Starting index of the sequence.</param>
/// <param name="values">Analog signal value array.</param>
/// <returns>Byte sequence in XSig format for analog signal information.</returns>
/// <summary>
/// GetBytes method
/// </summary>
public static byte[] GetBytes(int startIndex, ushort[] values)
{
return GetBytes(startIndex, 0, values);
@@ -196,9 +169,6 @@ namespace PepperDash.Core.Intersystem
/// <param name="offset">Index offset.</param>
/// <param name="values">Analog signal value array.</param>
/// <returns>Byte sequence in XSig format for analog signal information.</returns>
/// <summary>
/// GetBytes method
/// </summary>
public static byte[] GetBytes(int startIndex, int offset, ushort[] values)
{
// Analog XSig data is 4 bytes per value
@@ -216,9 +186,6 @@ namespace PepperDash.Core.Intersystem
/// <param name="index">1-based serial index</param>
/// <param name="value">Serial data to be encoded</param>
/// <returns>Bytes in XSig format for serial signal information.</returns>
/// <summary>
/// GetBytes method
/// </summary>
public static byte[] GetBytes(int index, string value)
{
return GetBytes(index, 0, value);
@@ -231,9 +198,6 @@ namespace PepperDash.Core.Intersystem
/// <param name="offset">Index offset.</param>
/// <param name="value">Serial data to be encoded</param>
/// <returns>Bytes in XSig format for serial signal information.</returns>
/// <summary>
/// GetBytes method
/// </summary>
public static byte[] GetBytes(int index, int offset, string value)
{
return new XSigSerialToken(index + offset, value).GetBytes();
@@ -245,9 +209,6 @@ namespace PepperDash.Core.Intersystem
/// <param name="startIndex">Starting index of the sequence.</param>
/// <param name="values">Serial signal value array.</param>
/// <returns>Byte sequence in XSig format for serial signal information.</returns>
/// <summary>
/// GetBytes method
/// </summary>
public static byte[] GetBytes(int startIndex, string[] values)
{
return GetBytes(startIndex, 0, values);
@@ -260,9 +221,6 @@ namespace PepperDash.Core.Intersystem
/// <param name="offset">Index offset.</param>
/// <param name="values">Serial signal value array.</param>
/// <returns>Byte sequence in XSig format for serial signal information.</returns>
/// <summary>
/// GetBytes method
/// </summary>
public static byte[] GetBytes(int startIndex, int offset, string[] values)
{
// Serial XSig data is not fixed-length like the other formats

View File

@@ -48,9 +48,6 @@ namespace PepperDash.Core.Intersystem
/// <param name="stream">Input stream</param>
/// <param name="value">Result</param>
/// <returns>True if successful, otherwise false.</returns>
/// <summary>
/// TryReadUInt16BE method
/// </summary>
public static bool TryReadUInt16BE(Stream stream, out ushort value)
{
value = 0;
@@ -68,9 +65,6 @@ namespace PepperDash.Core.Intersystem
/// </summary>
/// <returns>XSigToken</returns>
/// <exception cref="ArgumentOutOfRangeException">Offset is less than 0.</exception>
/// <summary>
/// ReadXSigToken method
/// </summary>
public XSigToken ReadXSigToken()
{
ushort prefix;
@@ -120,9 +114,6 @@ namespace PepperDash.Core.Intersystem
/// Reads all available XSig tokens from the stream.
/// </summary>
/// <returns>XSigToken collection.</returns>
/// <summary>
/// ReadAllXSigTokens method
/// </summary>
public IEnumerable<XSigToken> ReadAllXSigTokens()
{
var tokens = new List<XSigToken>();

View File

@@ -47,9 +47,6 @@ namespace PepperDash.Core.Intersystem
/// Write XSig data gathered from an IXSigStateResolver to the stream.
/// </summary>
/// <param name="xSigSerialization">IXSigStateResolver object.</param>
/// <summary>
/// WriteXSigData method
/// </summary>
public void WriteXSigData(IXSigSerialization xSigSerialization)
{
WriteXSigData(xSigSerialization, 0);
@@ -60,9 +57,6 @@ namespace PepperDash.Core.Intersystem
/// </summary>
/// <param name="xSigSerialization">IXSigStateResolver object.</param>
/// <param name="offset">Index offset for each XSigToken.</param>
/// <summary>
/// WriteXSigData method
/// </summary>
public void WriteXSigData(IXSigSerialization xSigSerialization, int offset)
{
if (xSigSerialization == null)
@@ -76,9 +70,6 @@ namespace PepperDash.Core.Intersystem
/// Write XSigToken to the stream.
/// </summary>
/// <param name="token">XSigToken object.</param>
/// <summary>
/// WriteXSigData method
/// </summary>
public void WriteXSigData(XSigToken token)
{
WriteXSigData(token, 0);
@@ -89,9 +80,6 @@ namespace PepperDash.Core.Intersystem
/// </summary>
/// <param name="token">XSigToken object.</param>
/// <param name="offset">Index offset for each XSigToken.</param>
/// <summary>
/// WriteXSigData method
/// </summary>
public void WriteXSigData(XSigToken token, int offset)
{
WriteXSigData(new[] { token }, offset);
@@ -120,9 +108,6 @@ namespace PepperDash.Core.Intersystem
/// </summary>
/// <param name="tokens">XSigToken objects.</param>
/// <param name="offset">Index offset for each XSigToken.</param>
/// <summary>
/// WriteXSigData method
/// </summary>
public void WriteXSigData(IEnumerable<XSigToken> tokens, int offset)
{
if (offset < 0)
@@ -140,7 +125,7 @@ namespace PepperDash.Core.Intersystem
}
/// <summary>
/// Dispose method
/// Disposes of the internal stream if specified to not leave open.
/// </summary>
public void Dispose()
{

View File

@@ -31,7 +31,7 @@ namespace PepperDash.Essentials.Core.Bridges
}
/// <summary>
/// Represents a EiscApiAdvanced
/// Bridge API using EISC
/// </summary>
public class EiscApiAdvanced : BridgeApi, ICommunicationMonitor
{
@@ -60,19 +60,12 @@ namespace PepperDash.Essentials.Core.Bridges
AddPostActivationAction(RegisterEisc);
}
/// <summary>
/// CustomActivate method
/// </summary>
/// <inheritdoc />
public override bool CustomActivate()
{
CommunicationMonitor.Start();
return base.CustomActivate();
}
/// <summary>
/// Deactivate method
/// </summary>
public override bool Deactivate()
{
CommunicationMonitor.Stop();
@@ -130,9 +123,6 @@ namespace PepperDash.Essentials.Core.Bridges
Debug.LogMessage(LogEventLevel.Debug, this, "EISC registration successful");
}
/// <summary>
/// LinkRooms method
/// </summary>
public void LinkRooms()
{
Debug.LogMessage(LogEventLevel.Debug, this, "Linking Rooms...");
@@ -163,9 +153,6 @@ namespace PepperDash.Essentials.Core.Bridges
/// </summary>
/// <param name="deviceKey"></param>
/// <param name="joinMap"></param>
/// <summary>
/// AddJoinMap method
/// </summary>
public void AddJoinMap(string deviceKey, JoinMapBaseAdvanced joinMap)
{
if (!JoinMaps.ContainsKey(deviceKey))
@@ -179,9 +166,8 @@ namespace PepperDash.Essentials.Core.Bridges
}
/// <summary>
/// PrintJoinMaps method
/// Prints all the join maps on this bridge
/// </summary>
/// <inheritdoc />
public virtual void PrintJoinMaps()
{
CrestronConsole.ConsoleCommandResponse("Join Maps for EISC IPID: {0}\r\n", Eisc.ID.ToString("X"));
@@ -193,9 +179,8 @@ namespace PepperDash.Essentials.Core.Bridges
}
}
/// <summary>
/// MarkdownForBridge method
/// Generates markdown for all join maps on this bridge
/// </summary>
/// <inheritdoc />
public virtual void MarkdownForBridge(string bridgeKey)
{
Debug.LogMessage(LogEventLevel.Information, this, "Writing Joinmaps to files for EISC IPID: {0}", Eisc.ID.ToString("X"));
@@ -211,9 +196,6 @@ namespace PepperDash.Essentials.Core.Bridges
/// Prints the join map for a device by key
/// </summary>
/// <param name="deviceKey"></param>
/// <summary>
/// PrintJoinMapForDevice method
/// </summary>
public void PrintJoinMapForDevice(string deviceKey)
{
var joinMap = JoinMaps[deviceKey];
@@ -231,9 +213,6 @@ namespace PepperDash.Essentials.Core.Bridges
/// Prints the join map for a device by key
/// </summary>
/// <param name="deviceKey"></param>
/// <summary>
/// MarkdownJoinMapForDevice method
/// </summary>
public void MarkdownJoinMapForDevice(string deviceKey, string bridgeKey)
{
var joinMap = JoinMaps[deviceKey];
@@ -254,9 +233,6 @@ namespace PepperDash.Essentials.Core.Bridges
/// <param name="join"></param>
/// <param name="type"></param>
/// <param name="state"></param>
/// <summary>
/// ExecuteJoinAction method
/// </summary>
public void ExecuteJoinAction(uint join, string type, object state)
{
try
@@ -342,91 +318,49 @@ namespace PepperDash.Essentials.Core.Bridges
#region Implementation of ICommunicationMonitor
/// <summary>
/// Gets or sets the CommunicationMonitor
/// </summary>
public StatusMonitorBase CommunicationMonitor { get; private set; }
#endregion
}
/// <summary>
/// Represents a EiscApiPropertiesConfig
/// </summary>
public class EiscApiPropertiesConfig
{
[JsonProperty("control")]
/// <summary>
/// Gets or sets the Control
/// </summary>
public EssentialsControlPropertiesConfig Control { get; set; }
[JsonProperty("devices")]
/// <summary>
/// Gets or sets the Devices
/// </summary>
public List<ApiDevicePropertiesConfig> Devices { get; set; }
[JsonProperty("rooms")]
/// <summary>
/// Gets or sets the Rooms
/// </summary>
public List<ApiRoomPropertiesConfig> Rooms { get; set; }
/// <summary>
/// Represents a ApiDevicePropertiesConfig
/// </summary>
public class ApiDevicePropertiesConfig
{
[JsonProperty("deviceKey")]
/// <summary>
/// Gets or sets the DeviceKey
/// </summary>
public string DeviceKey { get; set; }
[JsonProperty("joinStart")]
/// <summary>
/// Gets or sets the JoinStart
/// </summary>
public uint JoinStart { get; set; }
[JsonProperty("joinMapKey")]
/// <summary>
/// Gets or sets the JoinMapKey
/// </summary>
public string JoinMapKey { get; set; }
}
/// <summary>
/// Represents a ApiRoomPropertiesConfig
/// </summary>
public class ApiRoomPropertiesConfig
{
[JsonProperty("roomKey")]
/// <summary>
/// Gets or sets the RoomKey
/// </summary>
public string RoomKey { get; set; }
[JsonProperty("joinStart")]
/// <summary>
/// Gets or sets the JoinStart
/// </summary>
public uint JoinStart { get; set; }
[JsonProperty("joinMapKey")]
/// <summary>
/// Gets or sets the JoinMapKey
/// </summary>
public string JoinMapKey { get; set; }
}
}
/// <summary>
/// Represents a EiscApiAdvancedFactory
/// </summary>
public class EiscApiAdvancedFactory : EssentialsDeviceFactory<EiscApiAdvanced>
{
public EiscApiAdvancedFactory()
@@ -434,10 +368,6 @@ namespace PepperDash.Essentials.Core.Bridges
TypeNames = new List<string> { "eiscapiadv", "eiscapiadvanced", "eiscapiadvancedserver", "eiscapiadvancedclient", "vceiscapiadv", "vceiscapiadvanced" };
}
/// <summary>
/// BuildDevice method
/// </summary>
/// <inheritdoc />
public override EssentialsDevice BuildDevice(DeviceConfig dc)
{
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new EiscApiAdvanced Device");

View File

@@ -34,9 +34,6 @@ namespace PepperDash.Essentials.Core.Bridges
bridge.PrintJoinMaps();
}
}
/// <summary>
/// JoinmapMarkdown method
/// </summary>
public static void JoinmapMarkdown(string command)
{
var targets = command.Split(' ');

View File

@@ -3,17 +3,10 @@
namespace PepperDash.Essentials.Core.Bridges
{
/// <summary>
/// Defines the contract for IBridgeAdvanced
/// Defines a device that uses JoinMapBaseAdvanced for its join map
/// </summary>
public interface IBridgeAdvanced
{
/// <summary>
/// Links the bridge to the API using the provided trilist, join start, join map key, and bridge.
/// </summary>
/// <param name="trilist">The trilist to link to.</param>
/// <param name="joinStart">The starting join number.</param>
/// <param name="joinMapKey">The key for the join map.</param>
/// <param name="bridge">The EISC API bridge.</param>
void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge);
}
}

View File

@@ -2,9 +2,6 @@ using System;
namespace PepperDash.Essentials.Core.Bridges
{
/// <summary>
/// Represents a AirMediaControllerJoinMap
/// </summary>
public class AirMediaControllerJoinMap : JoinMapBaseAdvanced
{
[JoinName("IsOnline")]

View File

@@ -2,9 +2,6 @@
namespace PepperDash.Essentials.Core.Bridges
{
/// <summary>
/// Represents a AppleTvJoinMap
/// </summary>
public class AppleTvJoinMap : JoinMapBaseAdvanced
{
[JoinName("UpArrow")]

View File

@@ -2,9 +2,6 @@
namespace PepperDash.Essentials.Core.Bridges
{
/// <summary>
/// Represents a C2nRthsControllerJoinMap
/// </summary>
public class C2nRthsControllerJoinMap : JoinMapBaseAdvanced
{
[JoinName("IsOnline")]

View File

@@ -3,7 +3,7 @@
namespace PepperDash.Essentials.Core.Bridges
{
/// <summary>
/// Represents a CameraControllerJoinMap
/// Join map for CameraBase devices
/// </summary>
public class CameraControllerJoinMap : JoinMapBaseAdvanced
{

View File

@@ -2,9 +2,6 @@
namespace PepperDash.Essentials.Core.Bridges
{
/// <summary>
/// Represents a CenOdtOccupancySensorBaseJoinMap
/// </summary>
public class CenOdtOccupancySensorBaseJoinMap : JoinMapBaseAdvanced
{
#region Digitals

View File

@@ -2,9 +2,6 @@
namespace PepperDash.Essentials.Core.Bridges
{
/// <summary>
/// Represents a DisplayControllerJoinMap
/// </summary>
public class DisplayControllerJoinMap : JoinMapBaseAdvanced
{
[JoinName("Name")]

View File

@@ -1,9 +1,6 @@
using System;
namespace PepperDash.Essentials.Core.Bridges {
/// <summary>
/// Represents a DmBladeChassisControllerJoinMap
/// </summary>
public class DmBladeChassisControllerJoinMap : JoinMapBaseAdvanced {
[JoinName("IsOnline")]

View File

@@ -2,9 +2,6 @@ using System;
namespace PepperDash.Essentials.Core.Bridges
{
/// <summary>
/// Represents a DmChassisControllerJoinMap
/// </summary>
public class DmChassisControllerJoinMap : JoinMapBaseAdvanced
{
[JoinName("EnableAudioBreakaway")]

View File

@@ -2,9 +2,6 @@ using System;
namespace PepperDash.Essentials.Core.Bridges
{
/// <summary>
/// Represents a DmRmcControllerJoinMap
/// </summary>
public class DmRmcControllerJoinMap : JoinMapBaseAdvanced
{
[JoinName("IsOnline")]

View File

@@ -2,9 +2,6 @@
namespace PepperDash.Essentials.Core.Bridges
{
/// <summary>
/// Represents a DmTxControllerJoinMap
/// </summary>
public class DmTxControllerJoinMap : JoinMapBaseAdvanced
{
[JoinName("IsOnline")]

View File

@@ -2,9 +2,6 @@
namespace PepperDash.Essentials.Core.Bridges
{
/// <summary>
/// Represents a DmpsAudioOutputControllerJoinMap
/// </summary>
public class DmpsAudioOutputControllerJoinMap : JoinMapBaseAdvanced
{

View File

@@ -2,9 +2,6 @@
namespace PepperDash.Essentials.Core.Bridges
{
/// <summary>
/// Represents a DmpsMicrophoneControllerJoinMap
/// </summary>
public class DmpsMicrophoneControllerJoinMap : JoinMapBaseAdvanced
{
[JoinName("MicGain")]

View File

@@ -2,9 +2,6 @@
namespace PepperDash.Essentials.Core.Bridges
{
/// <summary>
/// Represents a DmpsRoutingControllerJoinMap
/// </summary>
public class DmpsRoutingControllerJoinMap : JoinMapBaseAdvanced
{
[JoinName("EnableRouting")]

View File

@@ -3,9 +3,6 @@
namespace PepperDash.Essentials.Core.Bridges
{
/// <summary>
/// Represents a GenericLightingJoinMap
/// </summary>
public class GenericLightingJoinMap : JoinMapBaseAdvanced
{

View File

@@ -2,9 +2,6 @@
namespace PepperDash.Essentials.Core.Bridges
{
/// <summary>
/// Represents a GenericRelayControllerJoinMap
/// </summary>
public class GenericRelayControllerJoinMap : JoinMapBaseAdvanced
{

View File

@@ -2,9 +2,6 @@
namespace PepperDash.Essentials.Core.Bridges
{
/// <summary>
/// Represents a GlsOccupancySensorBaseJoinMap
/// </summary>
public class GlsOccupancySensorBaseJoinMap : JoinMapBaseAdvanced
{
[JoinName("IsOnline")]

View File

@@ -3,9 +3,6 @@ using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
{
/// <summary>
/// Represents a GlsPartitionSensorJoinMap
/// </summary>
public class GlsPartitionSensorJoinMap : JoinMapBaseAdvanced
{

View File

@@ -2,9 +2,6 @@
namespace PepperDash.Essentials.Core.Bridges
{
/// <summary>
/// Represents a HdMdNxM4kEControllerJoinMap
/// </summary>
public class HdMdNxM4kEControllerJoinMap : JoinMapBaseAdvanced
{
[JoinName("Name")]

View File

@@ -2,9 +2,6 @@
namespace PepperDash.Essentials.Core.Bridges
{
/// <summary>
/// Represents a HdMdxxxCEControllerJoinMap
/// </summary>
public class HdMdxxxCEControllerJoinMap : JoinMapBaseAdvanced
{

View File

@@ -3,9 +3,6 @@ using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Core.Bridges
{
/// <summary>
/// Represents a HdPsXxxControllerJoinMap
/// </summary>
public class HdPsXxxControllerJoinMap : JoinMapBaseAdvanced
{

View File

@@ -2,9 +2,6 @@
namespace PepperDash.Essentials.Core.Bridges
{
/// <summary>
/// Represents a Hrxxx0WirelessRemoteControllerJoinMap
/// </summary>
public class Hrxxx0WirelessRemoteControllerJoinMap : JoinMapBaseAdvanced
{
[JoinName("Power")]

View File

@@ -2,9 +2,6 @@
namespace PepperDash.Essentials.Core.Bridges
{
/// <summary>
/// Represents a IAnalogInputJoinMap
/// </summary>
public class IAnalogInputJoinMap : JoinMapBaseAdvanced
{

View File

@@ -2,9 +2,6 @@
namespace PepperDash.Essentials.Core.Bridges
{
/// <summary>
/// Represents a IBasicCommunicationJoinMap
/// </summary>
public class IBasicCommunicationJoinMap : JoinMapBaseAdvanced
{
[JoinName("TextReceived")]

View File

@@ -2,9 +2,6 @@
namespace PepperDash.Essentials.Core.Bridges
{
/// <summary>
/// Represents a IDigitalInputJoinMap
/// </summary>
public class IDigitalInputJoinMap : JoinMapBaseAdvanced
{

View File

@@ -2,9 +2,6 @@
namespace PepperDash.Essentials.Core.Bridges
{
/// <summary>
/// Represents a IDigitalOutputJoinMap
/// </summary>
public class IDigitalOutputJoinMap : JoinMapBaseAdvanced
{

View File

@@ -2,9 +2,6 @@
namespace PepperDash.Essentials.Core.Bridges
{
/// <summary>
/// Represents a PduJoinMapBase
/// </summary>
public class PduJoinMapBase : JoinMapBaseAdvanced
{
[JoinName("Name")]

View File

@@ -3,9 +3,6 @@
namespace PepperDash.Essentials.Core.Bridges
{
/// <summary>
/// Represents a SetTopBoxControllerJoinMap
/// </summary>
public class SetTopBoxControllerJoinMap : JoinMapBaseAdvanced
{
[JoinName("PowerOn")]

View File

@@ -2,9 +2,6 @@
namespace PepperDash.Essentials.Core.Bridges
{
/// <summary>
/// Represents a StatusSignControllerJoinMap
/// </summary>
public class StatusSignControllerJoinMap : JoinMapBaseAdvanced
{
[JoinName("IsOnline")]

View File

@@ -2,9 +2,6 @@
namespace PepperDash.Essentials.Core.Bridges
{
/// <summary>
/// Represents a SystemMonitorJoinMap
/// </summary>
public class SystemMonitorJoinMap : JoinMapBaseAdvanced
{
[JoinName("TimeZone")]

View File

@@ -2,9 +2,6 @@ using System;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
{
/// <summary>
/// Represents a VideoCodecControllerJoinMap
/// </summary>
public class VideoCodecControllerJoinMap : JoinMapBaseAdvanced
{
#region Digital

View File

@@ -12,22 +12,13 @@ using Serilog.Events;
namespace PepperDash.Essentials.Core
{
/// <summary>
/// Represents a CecPortController
/// </summary>
public class CecPortController : Device, IBasicCommunicationWithStreamDebugging
{
/// <summary>
/// Gets or sets the StreamDebugging
/// </summary>
public CommunicationStreamDebugging StreamDebugging { get; private set; }
public event EventHandler<GenericCommMethodReceiveBytesArgs> BytesReceived;
public event EventHandler<GenericCommMethodReceiveTextArgs> TextReceived;
/// <summary>
/// Gets or sets the IsConnected
/// </summary>
public bool IsConnected { get { return true; } }
ICec Port;
@@ -83,9 +74,6 @@ namespace PepperDash.Essentials.Core
#region IBasicCommunication Members
/// <summary>
/// SendText method
/// </summary>
public void SendText(string text)
{
if (Port == null)
@@ -95,9 +83,6 @@ namespace PepperDash.Essentials.Core
Port.StreamCec.Send.StringValue = text;
}
/// <summary>
/// SendBytes method
/// </summary>
public void SendBytes(byte[] bytes)
{
if (Port == null)
@@ -108,16 +93,10 @@ namespace PepperDash.Essentials.Core
Port.StreamCec.Send.StringValue = text;
}
/// <summary>
/// Connect method
/// </summary>
public void Connect()
{
}
/// <summary>
/// Disconnect method
/// </summary>
public void Disconnect()
{
}
@@ -128,9 +107,6 @@ namespace PepperDash.Essentials.Core
///
/// </summary>
/// <param name="s"></param>
/// <summary>
/// SimulateReceive method
/// </summary>
public void SimulateReceive(string s)
{
// split out hex chars and build string

View File

@@ -12,22 +12,13 @@ using Serilog.Events;
namespace PepperDash.Essentials.Core
{
/// <summary>
/// Represents a ComPortController
/// </summary>
public class ComPortController : Device, IBasicCommunicationWithStreamDebugging
{
/// <summary>
/// Gets or sets the StreamDebugging
/// </summary>
public CommunicationStreamDebugging StreamDebugging { get; private set; }
public event EventHandler<GenericCommMethodReceiveBytesArgs> BytesReceived;
public event EventHandler<GenericCommMethodReceiveTextArgs> TextReceived;
/// <summary>
/// Gets or sets the IsConnected
/// </summary>
public bool IsConnected { get { return true; } }
ComPort Port;
@@ -125,10 +116,6 @@ namespace PepperDash.Essentials.Core
if(!eventSubscribed) Debug.LogMessage(LogEventLevel.Warning, this, "Received data but no handler is registered");
}
/// <summary>
/// Deactivate method
/// </summary>
/// <inheritdoc />
public override bool Deactivate()
{
return Port.UnRegister() == eDeviceRegistrationUnRegistrationResponse.Success;
@@ -136,9 +123,6 @@ namespace PepperDash.Essentials.Core
#region IBasicCommunication Members
/// <summary>
/// SendText method
/// </summary>
public void SendText(string text)
{
if (Port == null)
@@ -149,9 +133,6 @@ namespace PepperDash.Essentials.Core
Port.Send(text);
}
/// <summary>
/// SendBytes method
/// </summary>
public void SendBytes(byte[] bytes)
{
if (Port == null)
@@ -163,16 +144,10 @@ namespace PepperDash.Essentials.Core
Port.Send(text);
}
/// <summary>
/// Connect method
/// </summary>
public void Connect()
{
}
/// <summary>
/// Disconnect method
/// </summary>
public void Disconnect()
{
}
@@ -183,9 +158,6 @@ namespace PepperDash.Essentials.Core
///
/// </summary>
/// <param name="s"></param>
/// <summary>
/// SimulateReceive method
/// </summary>
public void SimulateReceive(string s)
{
// split out hex chars and build string

View File

@@ -34,9 +34,8 @@ namespace PepperDash.Essentials.Core
}
/// <summary>
/// CanConvert method
///
/// </summary>
/// <inheritdoc />
public override bool CanConvert(Type objectType)
{
return objectType == typeof(ComPort.ComPortSpec?);
@@ -45,15 +44,10 @@ namespace PepperDash.Essentials.Core
public override bool CanRead { get { return true; } }
/// <summary>
/// Gets or sets the CanWrite
/// This converter will not be used for writing
/// </summary>
/// <inheritdoc />
public override bool CanWrite { get { return false; } }
/// <summary>
/// WriteJson method
/// </summary>
/// <inheritdoc />
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
throw new NotImplementedException();
@@ -61,11 +55,12 @@ namespace PepperDash.Essentials.Core
}
/// <summary>
/// Represents a ComSpecPropsJsonConverter
/// The gist of this converter: The comspec JSON comes in with normal values that need to be converted
/// into enum names. This converter takes the value and applies the appropriate enum's name prefix to the value
/// and then returns the enum value using Enum.Parse. NOTE: Does not write
/// </summary>
public class ComSpecPropsJsonConverter : JsonConverter
{
/// <inheritdoc />
public override bool CanConvert(Type objectType)
{
return objectType == typeof(ComPort.eComBaudRates)
@@ -77,15 +72,8 @@ namespace PepperDash.Essentials.Core
|| objectType == typeof(ComPort.eComStopBits);
}
/// <summary>
/// Gets or sets the CanRead
/// </summary>
/// <inheritdoc />
public override bool CanRead { get { return true; } }
/// <summary>
/// ReadJson method
/// </summary>
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
//Debug.LogMessage(LogEventLevel.Verbose, "ReadJson type: " + objectType.Name);
@@ -106,10 +94,6 @@ namespace PepperDash.Essentials.Core
return null;
}
/// <summary>
/// WriteJson method
/// </summary>
/// <inheritdoc />
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
throw new NotImplementedException();

View File

@@ -1,138 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using Crestron.SimplSharp.CrestronSockets;
using Crestron.SimplSharpPro.DeviceSupport;
using Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Core.Logging;
using PepperDash.Essentials.Core.Bridges;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.Devices;
namespace PepperDash.Essentials.Core
{
/// <summary>
/// Implements IBasicCommunication and sends all communication through an EISC
/// </summary>
[Description("Generic communication wrapper class for any IBasicCommunication type")]
public class CommBridge : EssentialsBridgeableDevice, IBasicCommunication
{
private EiscApiAdvanced eisc;
private IBasicCommunicationJoinMap joinMap;
/// <summary>
/// Event triggered when text is received through the communication bridge.
/// </summary>
public event EventHandler<GenericCommMethodReceiveTextArgs> TextReceived;
/// <summary>
/// Event triggered when bytes are received through the communication bridge.
/// </summary>
public event EventHandler<GenericCommMethodReceiveBytesArgs> BytesReceived;
/// <summary>
/// Indicates whether the communication bridge is currently connected.
/// </summary>
public bool IsConnected { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="CommBridge"/> class.
/// </summary>
/// <param name="key">The unique key for the communication bridge.</param>
/// <param name="name">The display name for the communication bridge.</param>
public CommBridge(string key, string name)
: base(key, name)
{
}
/// <summary>
/// Sends a byte array through the communication bridge.
/// </summary>
/// <param name="bytes">The byte array to send.</param>
public void SendBytes(byte[] bytes)
{
if (eisc == null)
{
this.LogWarning("EISC is null, cannot send bytes.");
return;
}
eisc.Eisc.SetString(joinMap.SendText.JoinNumber, Encoding.ASCII.GetString(bytes, 0, bytes.Length));
}
/// <summary>
/// Sends a text string through the communication bridge.
/// </summary>
/// <param name="text">The text string to send.</param>
public void SendText(string text)
{
if (eisc == null)
{
this.LogWarning("EISC is null, cannot send text.");
return;
}
eisc.Eisc.SetString(joinMap.SendText.JoinNumber, text);
}
/// <summary>
/// Initiates a connection through the communication bridge.
/// </summary>
public void Connect()
{
if (eisc == null)
{
this.LogWarning("EISC is null, cannot connect.");
return;
}
eisc.Eisc.SetBool(joinMap.Connect.JoinNumber, true);
}
/// <summary>
/// Terminates the connection through the communication bridge.
/// </summary>
public void Disconnect()
{
if (eisc == null)
{
this.LogWarning("EISC is null, cannot disconnect.");
return;
}
eisc.Eisc.SetBool(joinMap.Connect.JoinNumber, false);
}
/// <inheritdoc />
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
{
joinMap = new IBasicCommunicationJoinMap(joinStart);
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<IBasicCommunicationJoinMap>(joinMapSerialized);
if (bridge != null)
{
bridge.AddJoinMap(Key, joinMap);
}
else
{
this.LogWarning("Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
}
this.LogDebug("Linking to Trilist '{0}'", trilist.ID.ToString("X"));
eisc = bridge;
trilist.SetBoolSigAction(joinMap.Connected.JoinNumber, (b) => IsConnected = b);
trilist.SetStringSigAction(joinMap.TextReceived.JoinNumber, (s) =>
{
TextReceived?.Invoke(this, new GenericCommMethodReceiveTextArgs(s));
BytesReceived?.Invoke(this, new GenericCommMethodReceiveBytesArgs(Encoding.ASCII.GetBytes(s)));
});
}
}
}

Some files were not shown because too many files have changed in this diff Show More