Compare commits
360 Commits
v2.4.6-lig
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3fb30d5561 | ||
|
|
57cd77f019 | ||
|
|
7f2bb078c8 | ||
|
|
316bb849b4 | ||
|
|
a983e2c87f | ||
|
|
babb9a77df | ||
|
|
7629921113 | ||
|
|
3878c85a7a | ||
|
|
7ad8218af0 | ||
|
|
0c4aec14d1 | ||
|
|
7d3f871460 | ||
|
|
78c9381108 | ||
|
|
a7ff2e8903 | ||
|
|
ae0b2fe086 | ||
|
|
bd11c827da | ||
|
|
7ea1efbabf | ||
|
|
9d6aaa2a0e | ||
|
|
53e7a30224 | ||
|
|
39c1f60a4d | ||
|
|
2cc37a4e40 | ||
|
|
076e5dfa9d | ||
|
|
092896bb25 | ||
|
|
7c8f0586e6 | ||
|
|
c5b0872a4c | ||
|
|
a7b88ec38d | ||
|
|
210b398a13 | ||
|
|
bce1e3610e | ||
|
|
6a33e7c99d | ||
|
|
2048e3f65d | ||
|
|
81df2738de | ||
|
|
08fbec416f | ||
|
|
7594b22096 | ||
|
|
d1babf6b9b | ||
|
|
2187c9fb0d | ||
|
|
a5e6059160 | ||
|
|
9ef4aedcce | ||
|
|
f7c7160bf0 | ||
|
|
dbf5740841 | ||
|
|
c07e099a79 | ||
|
|
06cb508f3a | ||
|
|
e93b5b34cc | ||
|
|
4f5d4ef87a | ||
|
|
636da8cc8c | ||
|
|
5de1e2d7bb | ||
|
|
03bbb84894 | ||
|
|
d17394cdd7 | ||
|
|
8467afde38 | ||
|
|
5c016fb4b8 | ||
|
|
2fbc32947c | ||
|
|
c06b57a5f9 | ||
|
|
6d64fffc50 | ||
|
|
0c4ebdaf1d | ||
|
|
2c49fb9321 | ||
|
|
c55de61da9 | ||
|
|
42444ede0a | ||
|
|
3d50f5f5ac | ||
|
|
11d62aebe1 | ||
|
|
edc10a9c2a | ||
|
|
9be5823956 | ||
|
|
35371dde22 | ||
|
|
d3ceb4d7e7 | ||
|
|
a782b57100 | ||
|
|
1360de599f | ||
|
|
fd95f5fed1 | ||
|
|
9426dff5df | ||
|
|
0d083e63c6 | ||
|
|
6ed7c96ec7 | ||
|
|
314570d6c3 | ||
|
|
ff609dfecd | ||
|
|
666be5ae59 | ||
|
|
bfc9b7e7fa | ||
|
|
b02e952765 | ||
|
|
72861a5097 | ||
|
|
44ed067f4d | ||
|
|
faa2169baf | ||
|
|
fd40b0c6d1 | ||
|
|
afcddad1cc | ||
|
|
c4cf8f13e9 | ||
|
|
c852f87a27 | ||
|
|
071174fa7d | ||
|
|
da0f28a10c | ||
|
|
0538a304ed | ||
|
|
705c5db237 | ||
|
|
2e95f5337e | ||
|
|
ba576180a7 | ||
|
|
92c9db8237 | ||
|
|
c4d064965f | ||
|
|
f27965ac29 | ||
|
|
3ce282e2db | ||
|
|
32a332a6e2 | ||
|
|
151a90c9be | ||
|
|
89e893b3b7 | ||
|
|
d01eb03890 | ||
|
|
16c92afabb | ||
|
|
dff5d2d32e | ||
|
|
317bde3814 | ||
|
|
8bab3dc966 | ||
|
|
514ac850ca | ||
|
|
44432f7a41 | ||
|
|
99253b30c2 | ||
|
|
bf248fe33e | ||
|
|
2f44040e4f | ||
|
|
10399a1be8 | ||
|
|
5409db193c | ||
|
|
f1ce54a524 | ||
|
|
7c72a0d905 | ||
|
|
5d5e78629e | ||
|
|
dab5484d6e | ||
|
|
5c35a3be45 | ||
|
|
6cb98e12fa | ||
|
|
608601990b | ||
|
|
3e0f318f7f | ||
|
|
98d0cc8fdc | ||
|
|
c557c6cdd6 | ||
|
|
8525134ae7 | ||
|
|
1197b15a33 | ||
|
|
ea6a7568fc | ||
|
|
3a2a059ce1 | ||
|
|
f9d9df9d5c | ||
|
|
c284c4275f | ||
|
|
0418f8a7cc | ||
|
|
a5d409e93a | ||
|
|
59944c0e2f | ||
|
|
419177ccd5 | ||
|
|
bd01e2bacc | ||
|
|
2928c5cf94 | ||
|
|
82b5dc96c1 | ||
|
|
37cea8a11c | ||
|
|
a3f0901fa0 | ||
|
|
f91f435768 | ||
|
|
5120b2b574 | ||
|
|
7c90027578 | ||
|
|
bb694b4200 | ||
|
|
087d0a1149 | ||
|
|
4747c16b02 | ||
|
|
aa4d241dde | ||
|
|
9fc5586531 | ||
|
|
d33fd56529 | ||
|
|
8fc4d21f02 | ||
|
|
6d93662b31 | ||
|
|
11b190e76f | ||
|
|
df03a71cbc | ||
|
|
72e67a1c4c | ||
|
|
f8728b6825 | ||
|
|
d9ef8a2289 | ||
|
|
278408a3bc | ||
|
|
fd70377c7f | ||
|
|
06341b14f3 | ||
|
|
d7f9c74b2f | ||
|
|
5921b5dbb0 | ||
|
|
ba0de5128f | ||
|
|
b0a090062f | ||
|
|
9c0cab8218 | ||
|
|
c0af637108 | ||
|
|
9c9eaea928 | ||
|
|
9de94bd65f | ||
|
|
ff46fb8f29 | ||
|
|
d9243def30 | ||
|
|
258699fbcd | ||
|
|
738504e9fc | ||
|
|
cae1bbd6e6 | ||
|
|
dea4407e3e | ||
|
|
ab08a546f7 | ||
|
|
ef98d47792 | ||
|
|
c05976ee60 | ||
|
|
4ca1031bef | ||
|
|
6d61c4525e | ||
|
|
3db274ace5 | ||
|
|
f0f708294c | ||
|
|
a00d186c62 | ||
|
|
51da668dfd | ||
|
|
d2b7400039 | ||
|
|
2424838b7f | ||
|
|
9556edc064 | ||
|
|
f9088691fd | ||
|
|
e40b6a8b4c | ||
|
|
c3b39a87da | ||
|
|
06dc0e947e | ||
|
|
147997f460 | ||
|
|
49abec5eea | ||
|
|
6830efe42a | ||
|
|
d013068a0c | ||
|
|
52916d29f4 | ||
|
|
19e8489166 | ||
|
|
fe33443b25 | ||
|
|
8cf195b262 | ||
|
|
40406b797d | ||
|
|
65bc408ebf | ||
|
|
9d49fb8357 | ||
|
|
fb7797dac7 | ||
|
|
574f5f6dc9 | ||
|
|
e49c69a12f | ||
|
|
7889cba196 | ||
|
|
033aa1f3dd | ||
|
|
9b6c2d80ea | ||
|
|
a0fc731701 | ||
|
|
f2d0dca7b8 | ||
|
|
ab4e85d081 | ||
|
|
47017da527 | ||
|
|
4f0d464ba4 | ||
|
|
0107422507 | ||
|
|
1a366790e7 | ||
|
|
97448f4f0f | ||
|
|
cf3ece4237 | ||
|
|
bb4b2f88b6 | ||
|
|
808e8042a7 | ||
|
|
0bc4388bfd | ||
|
|
dbc132c0da | ||
|
|
5bb0ab2626 | ||
|
|
27bf36c58c | ||
|
|
ce886aea63 | ||
|
|
ef920bf54c | ||
|
|
88466818ce | ||
|
|
0871a902e1 | ||
|
|
a031424752 | ||
|
|
fd1ba345aa | ||
|
|
e03874a7a9 | ||
|
|
2efab4f196 | ||
|
|
a41aba1904 | ||
|
|
d0ca6721f5 | ||
|
|
c732eb48f2 | ||
|
|
efe70208d3 | ||
|
|
615f640ebb | ||
|
|
ee6f9416a3 | ||
|
|
4fc6ecbd0b | ||
|
|
58bcc3315d | ||
|
|
08cc84a8e8 | ||
|
|
226014fee0 | ||
|
|
dc7f99e176 | ||
|
|
f0af9f8d19 | ||
|
|
31143f56df | ||
|
|
43989b9588 | ||
|
|
8db559f197 | ||
|
|
86f20da116 | ||
|
|
0674dbda37 | ||
|
|
592607f3c8 | ||
|
|
ea0a779f8b | ||
|
|
86e4d2f7fb | ||
|
|
0069233e13 | ||
|
|
4048efb07e | ||
|
|
b12cdbc75c | ||
|
|
b47f1d6b77 | ||
|
|
1dbac7d1c8 | ||
|
|
799d4c127c | ||
|
|
a6cd9a0571 | ||
|
|
80da4ad98f | ||
|
|
b283ed34b4 | ||
|
|
899f13eadb | ||
|
|
fc1e29565e | ||
|
|
f9a74567d2 | ||
|
|
53b1e5d142 | ||
|
|
78e9ea8070 | ||
|
|
df201558a5 | ||
|
|
130c874684 | ||
|
|
aee40ffe14 | ||
|
|
3ffad13abf | ||
|
|
5ee7aaa991 | ||
|
|
4fa8433e73 | ||
|
|
5fe99518a0 | ||
|
|
5a2a2129e6 | ||
|
|
4fbfda62d6 | ||
|
|
b8ab54cbe0 | ||
|
|
f6f1619bc2 | ||
|
|
41fd4d6adc | ||
|
|
5b73f8fbd2 | ||
|
|
c70a8edc24 | ||
|
|
7987eb8f9b | ||
|
|
260677a37f | ||
|
|
eeb0e84dc7 | ||
|
|
d282487da6 | ||
|
|
da30424657 | ||
|
|
311452beac | ||
|
|
789113008e | ||
|
|
660836bd5a | ||
|
|
97b2ffed9c | ||
|
|
2bbefa062d | ||
|
|
3421b2f28c | ||
|
|
82889e9794 | ||
|
|
1dcd4e328c | ||
|
|
e76369726d | ||
|
|
2bf0f2092b | ||
|
|
f8455d4110 | ||
|
|
c1eccfd790 | ||
|
|
f1a89161bc | ||
|
|
e59c50d0aa | ||
|
|
9d313d8c7c | ||
|
|
9813673b66 | ||
|
|
f006ed0076 | ||
|
|
ddbcc13c50 | ||
|
|
2a70fc678e | ||
|
|
056614cba1 | ||
|
|
5ff587a8c9 | ||
|
|
26c1baa1f8 | ||
|
|
2b15c2a56f | ||
|
|
a076d531bc | ||
|
|
5e880f0111 | ||
|
|
8f1fb86d37 | ||
|
|
fda4a5a816 | ||
|
|
471d5b701b | ||
|
|
96ac266d24 | ||
|
|
c1809459a6 | ||
|
|
1a9e1087de | ||
|
|
8d55615837 | ||
|
|
19e799f11d | ||
|
|
a3c1c444b7 | ||
|
|
9f70e3c721 | ||
|
|
c9b3205736 | ||
|
|
253b2cddaf | ||
|
|
d96edfa8d0 | ||
|
|
2fa297a204 | ||
|
|
95c1c01396 | ||
|
|
9c94806e4f | ||
|
|
183879f1c4 | ||
|
|
f3159738ce | ||
|
|
2c5cae9f41 | ||
|
|
7178d8e284 | ||
|
|
af98a92f8c | ||
|
|
0a6896910d | ||
|
|
9b1dd099f6 | ||
|
|
3f5269de2f | ||
|
|
60f1adcd35 | ||
|
|
12c8660015 | ||
|
|
ec6aeb17f6 | ||
|
|
e7c3fcbbd9 | ||
|
|
0c7ec82529 | ||
|
|
feb99ecbb6 | ||
|
|
91dc655103 | ||
|
|
bf31fb10eb | ||
|
|
d78b9ea313 | ||
|
|
15172a5509 | ||
|
|
5e21bad596 | ||
|
|
a4de9f2241 | ||
|
|
13cd84b73d | ||
|
|
81a01b7960 | ||
|
|
d9dc70bea2 | ||
|
|
2368f0c8cc | ||
|
|
4a77955987 | ||
|
|
a7e4d1b7c1 | ||
|
|
6295e10c08 | ||
|
|
b9553f486a | ||
|
|
e08f250ee8 | ||
|
|
e38ac6bab5 | ||
|
|
aaee3d1317 | ||
|
|
c40acca47a | ||
|
|
b128199d25 | ||
|
|
cc9492938b | ||
|
|
be58a0bc29 | ||
|
|
e8276c4165 | ||
|
|
817b5eccb5 | ||
|
|
702443f953 | ||
|
|
8406f69e0d | ||
|
|
1306247c32 | ||
|
|
d3d7b400ae | ||
|
|
c9c3a74f2f | ||
|
|
116d83394a | ||
|
|
9b8e452eb4 | ||
|
|
c9d86bd5dd | ||
|
|
b2b257020f | ||
|
|
6f58e18d14 | ||
|
|
60fc0298ec |
13
.config/dotnet-tools.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"csharpier": {
|
||||
"version": "1.2.4",
|
||||
"commands": [
|
||||
"csharpier"
|
||||
],
|
||||
"rollForward": false
|
||||
}
|
||||
}
|
||||
}
|
||||
45
.github/workflows/publish-docs.yml
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
name: Publish Docs
|
||||
|
||||
# Trigger the action on push to main
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
||||
permissions:
|
||||
actions: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
|
||||
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
|
||||
concurrency:
|
||||
group: "pages"
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
publish-docs:
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Dotnet Setup
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: 8.x
|
||||
|
||||
- run: dotnet tool update -g docfx
|
||||
- run: docfx ./docs/docfx.json
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
# Upload entire repository
|
||||
path: './docs/_site'
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v4
|
||||
5
.gitignore
vendored
@@ -392,3 +392,8 @@ essentials-framework/Essentials Interfaces/PepperDash_Essentials_Interfaces/Pepp
|
||||
.DS_Store
|
||||
/._PepperDash.Essentials.sln
|
||||
.vscode/settings.json
|
||||
_site/
|
||||
api/
|
||||
*.DS_Store
|
||||
/._PepperDash.Essentials.4Series.sln
|
||||
dotnet
|
||||
|
||||
9
.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"ms-dotnettools.vscode-dotnet-runtime",
|
||||
"ms-dotnettools.csharp",
|
||||
"ms-dotnettools.csdevkit",
|
||||
"vivaxy.vscode-conventional-commits",
|
||||
"mhutchie.git-graph"
|
||||
]
|
||||
}
|
||||
282
Crestron-Library-Usage-Analysis.md
Normal file
@@ -0,0 +1,282 @@
|
||||
# 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)*
|
||||
@@ -1,47 +0,0 @@
|
||||
devjson:1 {"deviceKey":"display-1-comMonitor","methodName":"PrintStatus"}
|
||||
|
||||
devjson:1 {"deviceKey":"display-1-com","methodName":"SimulateReceive", "params": ["\\x05\\x06taco\\xAA"]}
|
||||
|
||||
devjson:1 {"deviceKey":"display-1","methodName":"InputHdmi1", "params": []}
|
||||
|
||||
devjson:1 {"deviceKey":"display-1","methodName":"PowerOff", "params": []}
|
||||
|
||||
devjson:1 {"deviceKey":"timer","methodName":"Start" }
|
||||
|
||||
devjson:1 {"deviceKey":"timer","methodName":"Cancel" }
|
||||
|
||||
devjson:1 {"deviceKey":"timer","methodName":"Reset" }
|
||||
|
||||
devjson:1 {"deviceKey":"room1","methodName":"Shutdown" }
|
||||
|
||||
devjson:1 {"deviceKey":"mockVc-1", "methodName":"TestIncomingVideoCall", "params": ["123-456-7890"]}
|
||||
|
||||
devjson:1 {"deviceKey":"mockVc-1", "methodName":"TestIncomingAudioCall", "params": ["111-111-1111"]}
|
||||
|
||||
devjson:1 {"deviceKey":"mockVc-1", "methodName":"TestIncomingVideoCall", "params": ["444-444-4444"]}
|
||||
|
||||
devjson:1 {"deviceKey":"mockVc-1", "methodName":"ListCalls"}
|
||||
|
||||
devjson:1 {"deviceKey":"room1-emergency", "methodName":"RunEmergencyBehavior"}
|
||||
|
||||
devjson:1 {"deviceKey":"microphonePrivacyController-1", "methodName":"TogglePrivacyMute"}
|
||||
|
||||
devjson:1 {"deviceKey":"room1.InCallFeedback","methodName":"SetTestValue", "params": [ true ]}
|
||||
|
||||
devjson:1 {"deviceKey":"room1.InCallFeedback","methodName":"ClearTestValue", "params": []}
|
||||
|
||||
devjson:3 {"deviceKey":"room1.RoomOccupancy.RoomIsOccupiedFeedback","methodName":"SetTestValue", "params": [ true ]}
|
||||
|
||||
devjson:2 {"deviceKey":"codec-comms-ssh", "methodName":"SendText", "params": ["xcommand dial number: 10.11.50.211\r"]}
|
||||
|
||||
devjson:2 {"deviceKey":"codec-comms-ssh", "methodName":"Connect", "params": []}
|
||||
|
||||
devjson:1 {"deviceKey":"commBridge", "methodName":"ExecuteJoinAction", "params":[ 301, "digital", true ]}
|
||||
|
||||
devjson:2 {"deviceKey":"display01Comm-com", "methodName":"SendText", "params": [ "I'M GETTING TIRED OF THIS" ]}
|
||||
|
||||
devjson:10 {"deviceKey":"dmLink-ssh", "methodName":"Connect", "params": []}
|
||||
|
||||
devjson:2 {"deviceKey":"roomCombiner", "methodName":"SetRoomCombinationScenario", "params": ["combined"]}
|
||||
|
||||
devjson:2 {"deviceKey":"roomCombiner", "methodName":"SetRoomCombinationScenario", "params": ["divided"]}
|
||||
58
docs/docfx.json
Normal file
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/dotnet/docfx/main/schemas/docfx.schema.json",
|
||||
"metadata": [
|
||||
{
|
||||
"src": [
|
||||
{
|
||||
"src": "../",
|
||||
"files": [
|
||||
"src/**/*.csproj"
|
||||
]
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"TargetFramework": "net472"
|
||||
},
|
||||
"dest": "api",
|
||||
"namespaceLayout": "nested",
|
||||
"outputFormat": "apiPage"
|
||||
}
|
||||
],
|
||||
"build": {
|
||||
"content": [
|
||||
{
|
||||
"files": [
|
||||
"docs/**/*.{md,yml}",
|
||||
"api/**/*.{md,yml}",
|
||||
"index.md",
|
||||
"toc.yml"
|
||||
],
|
||||
"exclude": [
|
||||
"_site/**",
|
||||
".github/**"
|
||||
]
|
||||
}
|
||||
],
|
||||
"resource": [
|
||||
{
|
||||
"files": [
|
||||
"docs/images/**"
|
||||
]
|
||||
}
|
||||
],
|
||||
"output": "_site",
|
||||
"template": [
|
||||
"default",
|
||||
"modern"
|
||||
],
|
||||
"globalMetadata": {
|
||||
"_appName": "PepperDash Essentials",
|
||||
"_appTitle": "PepperDash Essentials",
|
||||
"_enableSearch": true,
|
||||
"_appLogoPath": "docs/images/favicon-32x32.png",
|
||||
"_appFaviconPath": "docs/images/favicon.ico",
|
||||
"_disableToc": false,
|
||||
"pdf": false
|
||||
}
|
||||
}
|
||||
}
|
||||
41
docs/docs/Arch-1.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# Essentials architecture
|
||||
|
||||
## Device and DeviceManager
|
||||
|
||||
---
|
||||
[YouTube Video - The Device Model in PepperDash Essentials](https://youtu.be/QF4vCQfOYGw)
|
||||
***
|
||||
|
||||
A `Device` (`PepperDash.Core.Device`) is a logical construct. It may represent a piece of hardware, a port, a socket, a collection of other devices/ports/constructs that define an operation, or any unit of logic that should be created at startup and exist independent of other devices.
|
||||
|
||||
`DeviceManager` (`PepperDash.Essentials.Core.DeviceManager`) is the collection of all Devices. The collection of everything we control, and other business logic in a system. See the list below for what is typical in the device manager.
|
||||
|
||||
## Flat system design
|
||||
|
||||
In Essentials, most everything we do is focused in one layer: The Devices layer. This layer interacts with the physical Crestron and other hardware and logical constructs underneath, and is designed so that we rarely act directly on the often-inconsistent hardware layer. The `DeviceManager` is responsible for containing all of the devices in this layer.
|
||||
|
||||
Types of things in `DeviceManager`:
|
||||
|
||||
* Rooms
|
||||
* Sources
|
||||
* Codecs, DSPs, displays, routing hardware
|
||||
* IR Ports, Com ports, SSh Clients, ...
|
||||
* Occupancy sensors and relay-driven devices
|
||||
* Logical devices that manage multiple devices and other business, like shade or lighting scene controllers
|
||||
* Fusion connectors to rooms
|
||||
|
||||
A Device doesn't always represent a physical piece of hardware, but rather a logical construct that "does something" and is used by one or more other devices in the running program. For example, we create a room device, and its corresponding Fusion device, and that room has a Cisco codec device, with an attached SSh client device. All of these lie in a flat collection in the `DeviceManager`.
|
||||
|
||||
> The `DeviceManager` is nothing more than a modified collection of things, and technically those things don't have to be Devices, but must at least implement the `IKeyed` (`PepperDash.Core.IKeyed`) interface (simply so items can be looked up by their key.) Items in the `DeviceManager` that are Devices are run through additional steps of [activation](~/docs/Arch-activate.md#2-pre-activation) at startup. This collection of devices is all interrelated by their string keys.
|
||||
|
||||
In this flat design, we spin up devices, and then introduce them to their "coworkers and bosses" - the other devices and logical units that they will interact with - and get them all operating together to form a running unit. For example: A room configuration will contain a "VideoCodecKey" property and a "DefaultDisplayKey" property. The `DeviceManager` provides the room with the codec or displays having the appropriate keys. What the room does with those is dependent on its coding.
|
||||
|
||||
> In the default Essentials routing scheme, the routing system gets the various devices involved in given route from `DeviceManager`, as they are discovered along the defined tie-lines. This is all done at route-time, on the fly, using only device and port keys. As soon as the routing operation is done, the whole process is released from memory. This is extremely-loose coupling between objects.
|
||||
|
||||
This flat structure ensures that every device in a system exists in one place and may be shared and reused with relative ease. There is no hierarchy.
|
||||
|
||||
## Architecture drawing
|
||||
|
||||

|
||||
|
||||
Next: [Configurable lifecycle](~/docs/Arch-lifecycle.md)
|
||||
158
docs/docs/Arch-activate.md
Normal file
@@ -0,0 +1,158 @@
|
||||
# Essentials architecture: DeviceManager activation
|
||||
|
||||
## What is all this?
|
||||
|
||||
The Essentials system architecture is a loose collection of "things" - generally real or logical Devices - that all need to relate to each other. In the interest of keeping Essentials extensible and flexible, we use an non-ordered collection of objects that should only have references to each other in the least-binding way possible. Meaning: Devices should be designed to be able to function without related objects present, and when they are present they should only retain loose reference to those other objects for memory management and later deconstruction as Essentials grows into a real-time configurable environment.
|
||||
|
||||
In order to facilitate this loose coupling, Essentials devices go through five phases during the startup process: Construction; addition to `DeviceManager`; pre-activation; activation; post-activation. We will describe what is optimal behavior for each of the steps below:
|
||||
|
||||
### Classes Referenced
|
||||
|
||||
* `PepperDash.Core.Device`
|
||||
* `PepperDash.Essentials.Core.EssentialsDevice`
|
||||
* `PepperDash.Essentials.Core.DeviceManager`
|
||||
* `PepperDash.Essentials.Core.Privacy.MicrophonePrivacyController`
|
||||
|
||||
## 1. Construction and addition to the DeviceManager
|
||||
|
||||
In general, a device's constructor should only be used to get the "framework" of the device in place. All devices are constructed in this stage. Rooms and fusion bridges included. Simple devices like IR driver devices, and devices with no controls can be completely spun up in this phase. All devices are added to the `DeviceManager` after they are constructed, but may not be fully functional.
|
||||
|
||||
## 2. Pre-activation
|
||||
|
||||
This stage is rarely used. It exists to allow an opportunity for any necessary logic to take place before the main activation phase.
|
||||
|
||||
## 3. Activation
|
||||
|
||||
This stage is the main phase of startup, and where most devices will get up and running, if they need additional startup behavior defined. The developer will code an optional overridden `CustomActivate()` method on the device class. This is where hardware ports may be set up; signals and feedbacks linked; UI drivers fired up; rooms linked to their displays and codec... With the exception of early-designed devices, most new Essentials classes do all of their startup here, rather than in their constructors.
|
||||
|
||||
Remember that in your `CustomActivate()` method, you cannot assume that a device you depend on is alive and running yet. It may be activating later. You _can_ depend on that device's existence, and link yourself to it, but it may not be functional yet. In general, there should be no conditions in any Essentials code that depend on device startup sequence and ordering. All rooms, devices, classes should be able to function without linked devices being alive, and respond appropriately when they do come to life. Any post-activation steps can be done in step four below - and should be avoided in general.
|
||||
|
||||
If the `CustomActivate()` method is long, consider breaking it up into many smaller methods. This will enhance exception handling and debugging when things go wrong, with more-detailed stack traces, and makes for easier-to-read code.
|
||||
|
||||
Note: It is best-practice in Essentials to not write arbitrarily-timed startup sequences to ensure that a "system" or room is functional. Rather, we encourage the developer to use various properties and conditions on devices to aggregate together "room is ready" statuses that can trigger further action. This ensures that all devices can be up and alive, allowing them to be debugged within a program that may otherwise be misbehaving - as well as not making users and expensive developers wait for code to start up!
|
||||
|
||||
```cs
|
||||
public override bool CustomActivate()
|
||||
{
|
||||
Debug.Console(0, this, "Final activation. Setting up actions and feedbacks");
|
||||
SetupFunctions();
|
||||
SetupFeedbacks();
|
||||
|
||||
EISC.SigChange += EISC_SigChange;
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
## 4. Post-activation
|
||||
|
||||
This phase is used primarily to handle any logic in a device that might be dependent on another device, and we need to ensure that we have waited for the dependent device to be activated first. For example, if we look at the `MicrophonePrivacyController` class, this is a "virtual" device whose purpose is to control the mute state of microphones from one or more contact closure inputs as well as provide feedback via different colored LEDs as to the current mute state. This virtual-device doesn't actually represent any sort of physical hardware device, but rather relies on associating itself with other devices that represent digital inputs and relays as well as whatever device is responsible for preforming the actual muting of the microphones.
|
||||
|
||||
We can see in the example below that during the `CustomActivate()` phase, we define a post-activation action via a lambda in `AddPostActivationAction()` that will execute during the post-activation phase. The purpose here is to check the state of the microphone mute and set the state of the relays that control the LEDs accordingly. We need to do this as a post-activation action because we need to make sure that the devices PrivacyDevice, RedLedRelay and GreenLedRelay are fully activated before we can attempt to interact with them.
|
||||
|
||||
### **Example**
|
||||
|
||||
```cs
|
||||
public override bool CustomActivate()
|
||||
{
|
||||
foreach (var i in Config.Inputs)
|
||||
{
|
||||
var input = DeviceManager.GetDeviceForKey(i.DeviceKey) as IDigitalInput;
|
||||
if(input != null)
|
||||
AddInput(input);
|
||||
}
|
||||
|
||||
var greenLed = DeviceManager.GetDeviceForKey(Config.GreenLedRelay.DeviceKey) as GenericRelayDevice;
|
||||
if (greenLed != null)
|
||||
GreenLedRelay = greenLed;
|
||||
else
|
||||
Debug.Console(0, this, "Unable to add Green LED device");
|
||||
|
||||
var redLed = DeviceManager.GetDeviceForKey(Config.RedLedRelay.DeviceKey) as GenericRelayDevice;
|
||||
if (redLed != null)
|
||||
RedLedRelay = redLed;
|
||||
else
|
||||
Debug.Console(0, this, "Unable to add Red LED device");
|
||||
|
||||
AddPostActivationAction(() => {
|
||||
CheckPrivacyMode();
|
||||
PrivacyDevice.PrivacyModeIsOnFeedback.OutputChange -= PrivacyModeIsOnFeedback_OutputChange;
|
||||
PrivacyDevice.PrivacyModeIsOnFeedback.OutputChange += PrivacyModeIsOnFeedback_OutputChange;
|
||||
});
|
||||
|
||||
initialized = true;
|
||||
|
||||
return base.CustomActivate();
|
||||
}
|
||||
|
||||
void CheckPrivacyMode()
|
||||
{
|
||||
if (PrivacyDevice != null)
|
||||
{
|
||||
var privacyState = PrivacyDevice.PrivacyModeIsOnFeedback.BoolValue;
|
||||
if (privacyState)
|
||||
TurnOnRedLeds();
|
||||
else
|
||||
TurnOnGreenLeds();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Activation exceptions
|
||||
|
||||
Each of the three activation phases operates in a try/catch block for each device. This way if one device has a fatal failure during activation, the failure will be logged and the system can continue to activate. This allows the developer to chase down multiple issues per load while testing, or to fix configuration omissions/errors as a group rather than one-at-a-time. A program can theoretically be fully-initialized and have many or all devices fail. We generally do not want to depend on exception handling to log device failures. Construction and activation code should have plenty of null checks, parameter validity checks, and debugging output to prevent exceptions from occurring. `String.IsEmptyOrNull(myString)` and `if(myObject == null)` are your friends. Invite them often.
|
||||
|
||||
## Interdependence
|
||||
|
||||
In any real-world system, devices and business logic need to talk to each other, otherwise, what's the point of all this coding? When creating your classes and configuration, it is best practice to _try_ not to "plug" one device into another during construction or activation. For example your touchpanel controller class has a `Display1` property that holds the display-1 object. Rather, it may be better to refer to the device as it is stored in the `DeviceManager` when it's needed using the static `DeviceManager.GetDeviceForKey(key)` method to get a reference to the device, which can be cast using various interfaces/class types, and then interacted with. This prevents objects from being referenced in places where the developer may later forget to dereference them, causing memory leak. This will become more important as Essentials becomes more able to be reconfigured at runtime.
|
||||
|
||||
As an example, [connection-based routing](~/docs/Connection-based-routing.md#essentials-connection-based-routing) uses these methods. When a route is requested, the collection of tielines and devices is searched for the devices and paths necessary to complete a route, but there are no devices or tie lines that are object-referenced in running code. It can all be torn down and reconfigured without any memory-management dereferencing, setting things to null.
|
||||
|
||||
## Device Initialization
|
||||
|
||||
Once the `DeviceManager` has completed the activation phase cycle for all devices, the devices themselves can be initialized. The `EssentialsDevice` class subscribes to the `DeviceManager.AllDevicesActivated` event and invokes the virtual `Initialize()` method on `Device` in a separate thread. This allows all devices to concurrently initialize in parallel threads.
|
||||
|
||||
The main task that should be undertaken in the `Initialize()` method for any 3rd party device class, it to begin communication with the device via its API. Ideally, no class that communicates with a 3rd party device outside the program should attempt to start communicating before this point.
|
||||
|
||||
### Example (from `PepperDash.Essentials.Devices.Common.VideoCodec.Cisco.CiscoSparkCodec`)
|
||||
```cs
|
||||
public override void Initialize()
|
||||
{
|
||||
var socket = Communication as ISocketStatus;
|
||||
if (socket != null)
|
||||
{
|
||||
socket.ConnectionChange += new EventHandler<GenericSocketStatusChageEventArgs>(socket_ConnectionChange);
|
||||
}
|
||||
|
||||
Communication.Connect();
|
||||
|
||||
CommunicationMonitor.Start();
|
||||
|
||||
const string prefix = "xFeedback register ";
|
||||
|
||||
CliFeedbackRegistrationExpression =
|
||||
prefix + "/Configuration" + Delimiter +
|
||||
prefix + "/Status/Audio" + Delimiter +
|
||||
prefix + "/Status/Call" + Delimiter +
|
||||
prefix + "/Status/Conference/Presentation" + Delimiter +
|
||||
prefix + "/Status/Cameras/SpeakerTrack" + Delimiter +
|
||||
prefix + "/Status/RoomAnalytics" + Delimiter +
|
||||
prefix + "/Status/RoomPreset" + Delimiter +
|
||||
prefix + "/Status/Standby" + Delimiter +
|
||||
prefix + "/Status/Video/Selfview" + Delimiter +
|
||||
prefix + "/Status/Video/Layout" + Delimiter +
|
||||
prefix + "/Status/Video/Input/MainVideoMute" + Delimiter +
|
||||
prefix + "/Bookings" + Delimiter +
|
||||
prefix + "/Event/CallDisconnect" + Delimiter +
|
||||
prefix + "/Event/Bookings" + Delimiter +
|
||||
prefix + "/Event/CameraPresetListUpdated" + Delimiter +
|
||||
prefix + "/Event/UserInterface/Presentation/ExternalSource/Selected/SourceIdentifier" + Delimiter;
|
||||
}
|
||||
```
|
||||
|
||||
## The goal
|
||||
|
||||
Robust C#-based system code should not depend on "order" or "time" to get running. We do not need to manage the order of our startup in this environment. Our Room class may come alive before our DSP and or Codec, and the Room is responsible for handling things when those devices become available. The UI layer is responsible for blocking the UI or providing status when the Room's requirements are coming alive, or if something has gone away. We use events or `Feedbacks` to notify dependents that other devices/classes are ready or not, but we do not prevent continued construction/activation of the system when many of these events don't happen, or don't happen in a timely fashion. This removes the need for startup management, which is often prolonged and consumes _tons_ of developer/installer time. A fully-loaded Essentials system may go through activation in several seconds, with all devices concurrently getting themselves going, where legacy code may take 10 minutes.
|
||||
|
||||
When designing new Device-based classes, be it rooms, devices, port controllers, bridges, make them as independent as possible. They could exist alone in a program with no required partner objects, and just quietly exist without failing. We want the system to be fast and flexible, and keeping the interdependence between objects at a minimum improves this flexibility into the future.
|
||||
|
||||
Next: [More architecture](~/docs/Arch-topics.md)
|
||||
9
docs/docs/Arch-lifecycle.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# Essentials Configurable System Lifecycle
|
||||
|
||||
The diagram below describes how Essentials gets a program up and running.
|
||||
|
||||
(The various activation phases are covered in more detail on the [next page](~/docs/Arch-activate.md))
|
||||
|
||||

|
||||
|
||||
Next: [Activation phases](~/docs/Arch-activate.md)
|
||||
19
docs/docs/Arch-summary.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Essentials architecture
|
||||
|
||||
## Summary
|
||||
|
||||
PepperDash Essentials is an open-source framework for control systems, built on Crestron's Simpl# Pro framework. It can be configured as a standalone program capable of running a wide variety of system designs and can also be used to augment other Crestron programs.
|
||||
|
||||
Essentials is a collection of C# libraries that can be used in many ways. It is a 100% configuration-driven framework that can be extended to add different workflows and behaviors, either through the addition of new device-types and classes, or via a plug-in mechanism. The framework is a collection of things that are all related and interconnected, but in general do not have strong dependencies on each other.
|
||||
|
||||
## Framework Libraries
|
||||
|
||||
The table below is a guide to understand the basic organization of code concepts within the various libraries that make up the architecture.
|
||||
|
||||

|
||||
|
||||
The diagram below shows the reference dependencies that exist between the different component libraries that make up the Essentials Framework.
|
||||
|
||||

|
||||
|
||||
Next: [Architecture](~/docs/Arch-1.md)
|
||||
156
docs/docs/Arch-topics.md
Normal file
@@ -0,0 +1,156 @@
|
||||
# Configuration topics
|
||||
|
||||
Configuration is central to Essentials. On this page we will cover configuration-related topics, including the important concept of configure-first and some details about the config file process.
|
||||
|
||||
## Classes Referenced
|
||||
|
||||
- `PepperDash.Essentials.Core.Config.DeviceConfig`
|
||||
|
||||
## Configure-first development
|
||||
|
||||
## Framework Libraries
|
||||
|
||||
The table below is meant to serve as a guide to understand the basic organization of code concepts within the various libraries that make up the architecture.
|
||||
|
||||
_Todo, try a text-based table:_
|
||||
|
||||

|
||||
|
||||
The diagram below shows the reference dependencies that exist between the different component libraries that make up the Essentials Framework.
|
||||
|
||||

|
||||
|
||||
### Architecture
|
||||
|
||||
#### Device and DeviceManager
|
||||
|
||||
A `Device` is a logical construct. It may represent a piece of hardware, a port, a socket, a collection of other devices/ports/constructs that define an operation, or any unit of logic that should be created at startup and exist independent of other devices.
|
||||
|
||||
`DeviceManager` is the collection of all Devices. The collection of everything we control on a system. **ADD SOME MORE HERE**
|
||||
|
||||
#### Flat system design
|
||||
|
||||
In Essentials, most everything we do is focused in one layer: The Devices layer. This layer interacts with the physical Crestron and other hardware and logical constructs underneath, and is designed so that we rarely act directly on the often-inconsistent hardware layer. The `DeviceManager` is responsible for containing all of the devices in this layer.
|
||||
|
||||
Types of devices:
|
||||
|
||||
- Rooms
|
||||
- Sources
|
||||
- Codecs, DSPs, displays, routing hardware
|
||||
- IR Ports, Com ports, SSh Clients, ...
|
||||
- Occupancy sensors and relay-driven devices
|
||||
- Logical devices that manage multiple devices and other business, like shade or lighting scene controllers
|
||||
- Fusion connectors to rooms
|
||||
|
||||
A Device doesn't always represent a physical piece of hardware, but rather a logical construct that "does something" and is used by one or more other devices in the running program. For example, we create a room device, and its corresponding Fusion device, and that room has a Cisco codec device, with an attached SSh client device. All of these lie in a flat collection in the `DeviceManager`.
|
||||
|
||||
> The `DeviceManager` is a modified collection of objects, and those objects don't have to inherit from Devices or EssentialsDevices, but must at least implement the `IKeyed` interface (so items can be looked up by their key.) Items in the `DeviceManager` that are Devices are run through additional steps of activation at startup. This collection of devices is all interrelated by their string keys.
|
||||
|
||||
In this flat design, we spin up devices, and then introduce them to their "coworkers and bosses" - the other devices and logical units that they will interact with - and get them all operating together to form a running unit. For example: A room configuration will contain a "VideoCodecKey" property and a "DefaultDisplayKey" property. The `DeviceManager` provides the room with the codec or displays having the appropriate keys. What the room does with those is dependent on its coding.
|
||||
|
||||
> In the default Essentials routing scheme, the routing system gets the various devices involved in given route from `DeviceManager`, as they are discovered along the defined tie-lines. This is all done at route-time, on the fly, using only device and port keys. As soon as the routing operation is done, the whole process is released from memory. This is extremely-loose coupling between objects.
|
||||
|
||||
This flat structure ensures that every device in a system exists in one place and may be shared and reused with relative ease. There is no hierarchy.
|
||||
|
||||
#### Architecture drawing
|
||||
|
||||

|
||||
|
||||
#### Essentials Configurable System Lifecycle
|
||||
|
||||

|
||||
|
||||
### Activation phases additional topics and examples (OTHER DOCS)
|
||||
|
||||
Concepts (link)
|
||||
|
||||
Room and touchpanel activation (link)
|
||||
|
||||
#### Configure first development
|
||||
|
||||
One of the primary concepts that has been adopted and must be adhered to when writing for Essentials framework is the concept of "configure first." The simple version is: Write what you need to do in the related configuration file (and configuration tool) first, then write the code that runs from that configuration. This ensures that the running code can actually be configured in the "flat" structure of devices and rooms that Essentials uses.
|
||||
|
||||
Often, code is written and tested first without consideration for configurability. Then, when a developer tries to make it configurable, they discover that the code as written doesn’t support it without complicated configuration files. This creates spaghetti code in tools that are written to generate configurations and tends to create tighter coupling between objects than we desire. Later, a modified version of the original program is desired, but because the code was written in such a specific fashion, the code is hard to refactor and extend. This causes the configuration tool and configuration files to become even more convoluted. The modern versions of configuration tools that are starting to come out are modular and componentized. We want to ensure as much re-use of these modules as possible, with extensions and added features added on, rather than complete rewrites of existing code. In our running systems, we want to ensure as much flexibility in design as possible, eliminating multiple classes with similar code.
|
||||
|
||||
### Configuration reader process
|
||||
|
||||
At the heart of the Essentials framework is the configuration system. While not technically necessary for a system written with the Essentials framework, it is the preferred and, currently, the only way to build an Essentials system. The configuration file is JSON, and well-defined (but not well documented, yet). It is comprised of blocks:
|
||||
|
||||
- info (object) Contains metadata about the config file
|
||||
- devices (array) Contains, well, the devices we intend to build and load
|
||||
- rooms (array, typically only one) Contains the rooms we need
|
||||
- sourceLists (object) Used by one or more rooms to represent list(s) of sources for those rooms
|
||||
- tieLines (array) Used by the routing system to discover routing between sources and displays
|
||||
|
||||
In addition, a downloaded Portal config file will most likely be in a template/system form, meaning that the file contains two main objects, representing the template configuration and its system-level overrides. Other metadata, such as Portal UUIDs or URLs may be present.
|
||||
|
||||
At startup, the configuration file is read, and a ReadyEvent is fired. Upon being ready, that configuration is loaded by the ConfigReader.LoadConfig() method. The template and system are merged into a single configuration object, and that object is then deserialized into configuration wrapper classes that define most of the structure of the program to be built. (Custom configuration objects were built to allow for better type handling rather than using JToken methods to parse out error-prone property names.)
|
||||
|
||||
For example, a `DeviceConfig` object:
|
||||
|
||||
```cs
|
||||
namespace PepperDash.Essentials.Core.Config
|
||||
{
|
||||
public class DeviceConfig
|
||||
{
|
||||
[JsonProperty("key")]
|
||||
public string Key { get; set; }
|
||||
|
||||
[JsonProperty("uid")]
|
||||
public int Uid { get; set; }
|
||||
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonProperty("group")]
|
||||
public string Group { get; set; }
|
||||
|
||||
[JsonProperty("type")]
|
||||
public string Type { get; set; }
|
||||
|
||||
[JsonProperty("properties")]
|
||||
[JsonConverter(typeof(DevicePropertiesConverter))]
|
||||
public JToken Properties { get; set; }
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
_Every_ `Device` present must adhere to those five properties plus a properties object. The properties object will have its own deserialization helpers, depending on what its structure is.
|
||||
|
||||
Once the ConfigReader has successfully read and deserialized the config file, then `ControlSystem.Load()` is called. This does the following in order:
|
||||
|
||||
1. Loads Devices
|
||||
2. Loads TieLines
|
||||
3. Loads Rooms
|
||||
4. Loads LogoServer
|
||||
5. Activation sequence
|
||||
|
||||
This ordering ensures that all devices are at least present before building tie lines and rooms. Rooms can be built without their required devices being present. In principle, this could break from the loosely-coupled goal we have described, but it is the clearest way to build the system in code. The goal is still to build a room class that doesn't have functional dependencies on devices that may not be ready for use.
|
||||
|
||||
In each device/room step, a device factory process is called. We call subsequent device factory methods in the various libraries that make up Essentials until one of them returns a functional device. This allows us to break up the factory process into individual libraries, and not have a huge list of types and build procedures. Here's part of the code:
|
||||
|
||||
```cs
|
||||
// Try local factories first
|
||||
var newDev = DeviceFactory.GetDevice(devConf);
|
||||
|
||||
if (newDev == null)
|
||||
newDev = BridgeFactory.GetDevice(devConf);
|
||||
|
||||
// Then associated library factories
|
||||
if (newDev == null)
|
||||
newDev = PepperDash.Essentials.Core.DeviceFactory.GetDevice(devConf);
|
||||
if (newDev == null)
|
||||
newDev = PepperDash.Essentials.Devices.Common.DeviceFactory.GetDevice(devConf);
|
||||
if (newDev == null)
|
||||
newDev = PepperDash.Essentials.DM.DeviceFactory.GetDevice(devConf);
|
||||
if (newDev == null)
|
||||
newDev = PepperDash.Essentials.Devices.Displays.DisplayDeviceFactory.GetDevice(devConf);
|
||||
```
|
||||
|
||||
In each respective factory, or device constructor, the configuration's properties object is either converted to a config object or read from using `JToken` methods. This builds the device which may be ready to go, or may require activation as described above.
|
||||
|
||||
A similar process is carried out for rooms, but as of now, the room types are so few that they are all handled in the `ControlSystem.LoadRooms()` method.
|
||||
|
||||
_This process will soon be enhanced by a plug-in mechanism that will drill into dynamically-loaded DLLs and load types from factories in those libraries. This is where custom essentials systems will grow from._
|
||||
|
||||
After those five steps, the system will be running and ready to use.
|
||||
15
docs/docs/Bridging-To-Hardware-Resources.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# Bridging to Hardware and Network Resources
|
||||
|
||||
One of the most powerful features of Essentials is the ability to bridge SIMPL to and hardware resource to any piece of equipment instantiated inside of essentials. You can bridge directly to a comport on the processor just as easily as you can to the comport of an instantiated DM device. A simple change in the connection location of a display can be made with just a few keystrokes. This isn't restricted to comports either. Devices and direct connections can be linked to Digital Inputs, IR Ports, Relays, Comports, SSH, TCP/IP, UDP, and Cresnet resources.
|
||||
|
||||
## Examples
|
||||
|
||||
Follow the links below for examples of bridging to hardware and network resources.
|
||||
|
||||
**[GenericComm Bridging](~/docs/GenericComm.md)**
|
||||
|
||||
**[RelayOutput Bridging](~/docs/RelayOutput.md)**
|
||||
|
||||
**[Digital Input Bridging](~/docs/DigitalInput.md)**
|
||||
|
||||
**[Card Frame Bridging](~/docs/CardFrame.md)**
|
||||
14
docs/docs/CardFrame.md
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"key": "cardCage1",
|
||||
"uid": 1,
|
||||
"name": "Internal Card Cage",
|
||||
"type": "internalcardcage",
|
||||
"group": "cardCage",
|
||||
"properties": {
|
||||
"cards": {
|
||||
"1": "c3com3",
|
||||
"2": "c3com3",
|
||||
"3": ""
|
||||
}
|
||||
}
|
||||
},
|
||||
75
docs/docs/Communication-Basics.md
Normal file
@@ -0,0 +1,75 @@
|
||||
# Unifying communication methods
|
||||
|
||||
In networked A/V systems, devices can use many different methods of communication: COM ports, TCP/IP sockets, Telnet, SSH. Generally, the data protocol and commands that are sent and received using any of these methods are the same, and it is not necessary for a device to know the details of the communication method it is using. A Samsung MDC protocol display in room 1 using RS232 speaks the same language as another Samsung MDC does in the next room using TCP/IP. For these, and most cases where the device doesn't need to know its communication method, we introduce the `IBasicCommunication` interface.
|
||||
## Classes Referenced
|
||||
|
||||
* `PepperDash.Core.IBasicCommunication`
|
||||
* `PepperDash.Core.ISocketStatus`
|
||||
* `PepperDash.Core.GenericTcpIpClient`
|
||||
* `PepperDash.Core.GenericSshClient`
|
||||
* `PepperDash.Core.GenericSecureTcpIpClient`
|
||||
* `PepperDash.Essentials.Core.ComPortController`
|
||||
* `PepperDash.Essentials.Core.StatusMonitorBase`
|
||||
## IBasicCommunication and ISocketStatus
|
||||
|
||||
All common communication controllers will implement the `IBasicCommunication` interface, which is an extension of `ICommunicationReceiver`. This defines receive events, connection state properties, and send methods. Devices that need to use COM port, TCP, SSh or other similar communication will require an `IBasicCommunication` type object to be injected at construction time.
|
||||
|
||||
```cs
|
||||
/// <summary>
|
||||
/// An incoming communication stream
|
||||
/// </summary>
|
||||
public interface ICommunicationReceiver : IKeyed
|
||||
{
|
||||
event EventHandler<GenericCommMethodReceiveBytesArgs> BytesReceived;
|
||||
event EventHandler<GenericCommMethodReceiveTextArgs> TextReceived;
|
||||
|
||||
bool IsConnected { get; }
|
||||
void Connect();
|
||||
void Disconnect();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a device that uses basic connection
|
||||
/// </summary>
|
||||
public interface IBasicCommunication : ICommunicationReceiver
|
||||
{
|
||||
void SendText(string text);
|
||||
void SendBytes(byte[] bytes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For IBasicCommunication classes that have SocketStatus. GenericSshClient,
|
||||
/// GenericTcpIpClient
|
||||
/// </summary>
|
||||
public interface ISocketStatus : IBasicCommunication
|
||||
{
|
||||
event EventHandler<GenericSocketStatusChageEventArgs> ConnectionChange;
|
||||
SocketStatus ClientStatus { get; }
|
||||
}
|
||||
```
|
||||
|
||||
### Developing devices with communication
|
||||
|
||||
Essentials uses dependency injection concepts in its start up phase. Simply, most devices use the same methods of communication, and are often communication-agnostic. During the build-from-configuration phase, the communication method device is instantiated, and then injected into the device that will use it. Since the communication device is of `IBasicCommunication`, the device controller receiving it knows that it can do things like listen for events, send text, or be notified when sockets change.
|
||||
|
||||
### Device Factory, Codec example
|
||||
|
||||

|
||||
|
||||
The DeviceManager will contain two new devices after this: The Cisco codec, and the codec's `GenericSshClient`. This enables easier debugging of the client using console methods. Some devices like this codec will also have a `StatusMonitorBase` device, for Fusion and other reporting.
|
||||
|
||||
> `ComPortController` is `IBasicCommunication` as well, but methods like `Connect()` and `Disconnect()` do nothing on these types.
|
||||
|
||||
#### ISocketStatus
|
||||
|
||||
`PepperDash.Core.GenericTcpIpClient`, `GenericSshClient` and some other socket controllers implement `ISocketStatus`, which is an extension of `IBasicCommunication`. This interface reveals connection status properties and events.
|
||||
|
||||
```cs
|
||||
public interface ISocketStatus : IBasicCommunication
|
||||
{
|
||||
event EventHandler<GenericSocketStatusChageEventArgs> ConnectionChange;
|
||||
SocketStatus ClientStatus { get; }
|
||||
}
|
||||
```
|
||||
|
||||
Classes that are using socket-based comms will need to check if the communication is `ISocketStatus` and link up to the `ConnectionChange` event for connection handling.
|
||||
291
docs/docs/ConfigurationStructure.md
Normal file
@@ -0,0 +1,291 @@
|
||||
# Configuration Structure
|
||||
|
||||
---
|
||||
|
||||
[YouTube Video - Configuring PepperDash Essentials](https://youtu.be/EK8Ti9a1o7s)
|
||||
|
||||
***
|
||||
|
||||
The Essentials configuration structure is designed to allow minimum duplication of data across systems that share many similarities, which makes it ideally suited for applications where large numbers of duplicate room types must be deployed.
|
||||
|
||||
At a high level, the idea is to define a template of all of the common configuration shared by a group of systems of the same type. Then individual differences per system instance can be defined in a system block that either add data missing in the template, or override the default values set in the template.
|
||||
|
||||
## Top Level Object Structure (Double Config)
|
||||
|
||||
```cs
|
||||
{
|
||||
// This object is deserialized to type PepperDash.Essentials.Core.Config.EssentialsConfig
|
||||
|
||||
"system_url":"", // For Portal use only
|
||||
"template_url":"", // For Portal use only
|
||||
"template":{
|
||||
// This object is deserialized to type PepperDash.Essentials.Core.EssentialsConfig
|
||||
// For most manually generated configuration, only define data here. Leave system empty
|
||||
},
|
||||
"system":{
|
||||
// This object is deserialized to type PepperDash.Essentials.Core.EssentialsConfig
|
||||
// Any data here will be overlayed on top of the data in template. In the case of duplicate values
|
||||
// the value in system will be overwrite any value in template
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Object Structure for `template` and `system` (`PepperDash.Essentials.Core.EssentialsConfig`)
|
||||
|
||||
``` js
|
||||
{
|
||||
"info": {
|
||||
// This object is deserialized to type PepperDash.Essentials.Core.Config.InfoConfig
|
||||
// Contains information about the system/configuration
|
||||
},
|
||||
"devices": [
|
||||
// This object is deserialized to type List<PepperDash.Essentials.Core.Config.DeviceConfig>
|
||||
// An array of devices
|
||||
],
|
||||
"rooms": [
|
||||
// This object is deserialized to type List<PepperDash.Essentials.Core.Config.DeviceConfig>
|
||||
// An array of rooms. These are not automatically deserialized
|
||||
],
|
||||
"tielines":[
|
||||
// An array of tie lines that describe the connections between routing ports on devices
|
||||
],
|
||||
"sourceLists":{
|
||||
// This object is deserialized to type Dictionary<string, Dictionary<string, PepperDash.Essentials.Core.SourceListItem>>
|
||||
// An object that contains a collection
|
||||
},
|
||||
"joinMaps":{
|
||||
// This object is deserialized to type Dictionary<string, string> where the value is a serialized class that inherits from JoinMapBase to be deserialized later
|
||||
// Used to define custom join maps for bridging devices to SIMPL
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## The Template and System Concept (Merging Configurations)
|
||||
|
||||
In order to understand how and why we use a double configuration concept, it's important to understand the relationship between a Template and a System in Portal. A System represents a physical installed group of hardware(either currently or in the future), acting together usually as part of a single control system program. A system MUST inherit from a Template. A Template represents the common elements of one or more systems.
|
||||
|
||||
The idea being that configuration values that are common to all systems can be stored in the configuration for the template. Then, any configuration values that are unique to a particular system cane be stored in the configuration of the System. By "merging" the System configuration values over top of the Template configuration values, the resulting data contains all of the values that should be shared by each system that inherits from a common template, as well as the unique values for each individual system.
|
||||
|
||||
Below is an example of a double configuration containing both template and system properties.
|
||||
|
||||
```JSON
|
||||
{
|
||||
"template": {
|
||||
"info": {
|
||||
"name": "Template Name",
|
||||
"description": "A 12 person conference room"
|
||||
},
|
||||
"devices": [
|
||||
|
||||
],
|
||||
"rooms": [
|
||||
|
||||
]
|
||||
},
|
||||
"system": {
|
||||
"info": {
|
||||
"name": "System Name",
|
||||
"myNewSystemProperty": "Some Value"
|
||||
},
|
||||
"devices": [
|
||||
|
||||
],
|
||||
"rooms": [
|
||||
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Below is an example of the result of merging the above double configuration example into a single configuration.
|
||||
|
||||
```JSON
|
||||
{
|
||||
"info": {
|
||||
"name": "System Name", // Since this property existed in both the template and system, the system value replaces the template value after the merge
|
||||
"description": "A 12 person conference room", // This property existed only in the template and is unchanged after the merge
|
||||
"myNewSystemProperty": "Some Value" // This property existed only in the system and is unchanged after the merge
|
||||
},
|
||||
"devices": [
|
||||
|
||||
],
|
||||
"rooms": [
|
||||
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Device Object Structure
|
||||
|
||||
The devices array is meant to hold a series of device objects. The basic device object structure is defined below.
|
||||
|
||||
```JSON
|
||||
{
|
||||
"key": "someUniqueString", // *required* a unique string
|
||||
"name": "A friendly Name", // *required* a friendly name meant for display to users
|
||||
"type": "exampleType", // *required* the type identifier for this object.
|
||||
"group": "exampleGroup", // *required* the group identifier for this object. This really equates to a category for the device,
|
||||
// such as "lighting" or "displays" and may be deprecated in future in favor of "category"
|
||||
"uid":0, // *required* a unique numeric identifier for each device
|
||||
"properties": { // *required* an object where the configurable properties of the device are contained
|
||||
"control": { // an object to contain all of the properties to connect to and control the device
|
||||
"method": "ssh", // the control method used by this device
|
||||
"tcpSshProperties": { // contains the necessary properties for the specified method
|
||||
"address": "1.2.3.4",
|
||||
"port": 22,
|
||||
"username": "admin",
|
||||
"password": "uncrackablepassword"
|
||||
}
|
||||
},
|
||||
"someCustomProperty": "I Love Tacos!"
|
||||
}
|
||||
// Do NOT add any custom data at the top level of the device object. All custom data must be in the properties object.
|
||||
}
|
||||
```
|
||||
|
||||
Some additional details about specific properties that are important to note:
|
||||
|
||||
* "key": This value needs to be unique in the array of devices objects
|
||||
* "uid": This value also needs to be unique for reasons related to configuration tools and template/system merging
|
||||
* "type": Think of this as a way to identify what specific module you might associate with this device. In Essentials, this value is used to determine what class will be instantiated for the device (ex. "necmpsx" or "samsungMdc" for two types of displays)
|
||||
* "properties": This object is used to store both specific and miscellaneous data about the device.
|
||||
* Specific data, like that shown above in the "control" object has a pre-defined structure.
|
||||
* Other data must be stored as objects or new properties inside the "properties" object such as "someCustomProperty" in the example above.
|
||||
* Do NOT add any additional properties at the top level of the device object. All custom data must be in the "properties" object.
|
||||
|
||||
## The Device Properties.Control Object
|
||||
|
||||
The control object inside properties has some reserved properties that are used by configuration tools and Essentials that require some caution.
|
||||
|
||||
```JSON
|
||||
{
|
||||
"properties": { // *required* an object where the configurable properties of the device are contained
|
||||
"control": { // an object to contain all of the properties to connect to and control the device
|
||||
// Example of the reserved properties for a socket based port (ssh, tcpIp, udp)
|
||||
"method": "ssh", // the control method used by this device
|
||||
"tcpSshProperties": { // contains the necessary properties for the specified method
|
||||
"address": "1.2.3.4", // IP Address or hostname
|
||||
"port": 22,
|
||||
"username": "admin",
|
||||
"password": "uncrackablepassword",
|
||||
"autoReconnect": true, // If true, the client will attempt to re-connect if the connection is broken externally
|
||||
"AutoReconnectIntervalMs": 2000 // The time between re-connection attempts
|
||||
},
|
||||
|
||||
// Example of the reserved properties for a Com port
|
||||
"method": "com",
|
||||
"controlPortNumber": 1, // The number of the com port on the device specified by controlPortDevKey
|
||||
"controlPortDevKey": "processor", // The key of the device where the com port is located
|
||||
"comParams": { // This object contains all of the com spec properties for the com port
|
||||
"hardwareHandshake": "None",
|
||||
"parity": "None",
|
||||
"protocol": "RS232",
|
||||
"baudRate": 9600,
|
||||
"dataBits": 8,
|
||||
"softwareHandshake": "None",
|
||||
"stopBits": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Device Merging
|
||||
|
||||
The following examples illustrate how the device key and uid properties affect how devices are merged together in a double configuration scenario. In order for a template device and a system device to merge, they must have the same key and uid values
|
||||
|
||||
```JSON
|
||||
{
|
||||
"template": {
|
||||
"info": {
|
||||
"name": "Template Name",
|
||||
"description": "A 12 person conference room"
|
||||
},
|
||||
"devices": [
|
||||
{ // This is the template device
|
||||
"key": "display-1",
|
||||
"name": "Display",
|
||||
"type": "samsungMdc",
|
||||
"group": "displays",
|
||||
"uid":0,
|
||||
"properties": {
|
||||
"control": {
|
||||
"method": "ssh",
|
||||
"tcpSshProperties": {
|
||||
"address": "", // Note that at the template level we won't know the actual IP address so this value is left empty
|
||||
"port": 22,
|
||||
"username": "admin",
|
||||
"password": "uncrackablepassword"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"rooms": [
|
||||
|
||||
]
|
||||
},
|
||||
"system": {
|
||||
"info": {
|
||||
"name": "System Name",
|
||||
"myNewSystemProperty": "Some Value"
|
||||
},
|
||||
"devices": [
|
||||
{ // This is the system device
|
||||
"key": "display-1",
|
||||
"uid":0,
|
||||
"properties": {
|
||||
"control": {
|
||||
"tcpSshProperties": {
|
||||
"address": "10.10.10.10" // Note that the actual IP address is specified at the system level
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"rooms": [
|
||||
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Below is an example of the result of merging the above double configuration example into a single configuration.
|
||||
|
||||
```JSON
|
||||
{
|
||||
"info": {
|
||||
"name": "System Name",
|
||||
"description": "A 12 person conference room",
|
||||
"myNewSystemProperty": "Some Value"
|
||||
},
|
||||
"devices": [
|
||||
{
|
||||
"key": "display-1",
|
||||
"name": "Display",
|
||||
"type": "samsungMdc",
|
||||
"group": "displays",
|
||||
"uid":0,
|
||||
"properties": {
|
||||
"control": {
|
||||
"method": "ssh",
|
||||
"tcpSshProperties": {
|
||||
"address": "10.10.10.10", // Note that the merged device object inherits all of the template
|
||||
// properties and overwrites the template address property with the system value
|
||||
"port": 22,
|
||||
"username": "admin",
|
||||
"password": "uncrackablepassword"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"rooms": [
|
||||
|
||||
]
|
||||
}
|
||||
```
|
||||
81
docs/docs/Connection-Based-Routing.md
Normal file
@@ -0,0 +1,81 @@
|
||||
# Essentials connection-based routing
|
||||
|
||||
## TL;DR
|
||||
|
||||
Routing is defined by a connection graph or a wiring diagram. Routeable devices are sources, midpoints, or destinations. Devices are connected by tie lines. Tie lines represent the cables connecting devices, and are of type audio, video or both. Routes are made by telling a destination to get an audio/video/combined route from a source.
|
||||
|
||||
## Summary
|
||||
|
||||
Essentials routing is described by defining a graph of connections between devices in a system, typically in configuration. The audio, video and combination connections are like a wiring diagram. This graph is a collection of devices and tie lines, each tie line connecting a source device, source output port, destination device and destination input port. Tie lines are logically represented as a collection.
|
||||
|
||||
When routes are to be executed, Essentials will use this connection graph to decide on routes from source to destination. A method call is made on a destination, which says “destination, find a way for source xyz to get to you.” An algorithm analyzes the tie lines, instantly walking backwards from the destination, down every connection until it finds a complete path from the source. If a connected path is found, the algorithm then walks forward through all midpoints to the destination, executing switches as required until the full route is complete. The developer or configurer only needs to say “destination, get source xyz” and Essentials figures out how, regardless of what devices lie in between.
|
||||
|
||||
### Classes Referenced
|
||||
|
||||
* `PepperDash.Essentials.Core.Routing.IRoutingSource`
|
||||
* `PepperDash.Essentials.Core.Routing.IRoutingOutputs`
|
||||
* `PepperDash.Essentials.Core.Routing.IRoutingInputs`
|
||||
* `PepperDash.Essentials.Core.Routing.IRoutingInputsOutputs`
|
||||
* `PepperDash.Essentials.Core.Routing.IRoutingSinkNoSwitching`
|
||||
* `PepperDash.Essentials.Core.Routing.IRoutingSinkWithSwitching`
|
||||
|
||||
## Example system, a simple presentation system
|
||||
|
||||
The diagram below shows the connections in a simple presentation system, with a few variations in connection paths. Example routes will be described following the diagram.
|
||||
|
||||
Each visible line between ports on devices represents a tie line. A tie line connects an output port on one device to an input port on another device, for example: an HDMI port on a document camera to an HDMI input on a matrix switcher. A tie line may be audio, video or both. It is essentially a logical representation of a physical cable in a system. This diagram has 12 tie lines, and those tie lines are defined in the tieLines array in configuration.
|
||||
|
||||

|
||||
|
||||
Let’s go through some examples of routing, using pseudo-code:
|
||||
|
||||
1. Method call: “Projector 1, show Doc cam.” Routing will walk backwards through DM-RMC-3 and DM-8x8 iterating through all “wired up” ports until it finds a path back to the Doc cam. Routing will then step back through all devices in the discovered chain, switching routes on those that are switchable: Doc cam: no switching; DM 8x8: route input 3 to output 3; DM-RMC-3: no switching; Projector 1: Select input HDMI In. Route is complete.
|
||||
2. Method call: “Projector 2, show Laptop, video-only.” Routing will walk backwards through DM-RMC-4, DM 8x8, DM-TX-1, iterating through all connected ports until it finds a connection to the laptop. Routing then steps back through all devices, switching video where it can: Laptop: No switching; DM-TX-1: Select HDMI in; DM 8x8: Route input 5 to output 4; DM-RMC-4: No switching; Projector 2: Select HDMI input. Route is complete.
|
||||
3. Method call: “Amplifier, connect Laptop audio.” Again walking backwards to Laptop, as in #2 above. Switching will take place on DM-TX-1, DM 8x8, audio-only.
|
||||
4. Very simple call: “Lobby display, show signage controller.” Routing will walk back on HDMI input 1 and immediately find the signage controller. It then does a switch to HDMI 1 on the display.
|
||||
|
||||
All four of the above could be logically combined in a series of calls to define a possible “scene” in a room: Put Document camera on Projector 1, put Laptop on Projector 2 and the audio, put Signage on the Lobby display. They key takeaway is that the developer doesn’t need to define what is involved in making a certain route. The person configuring the system defines how it’s wired up, and the code only needs to tell a given destination to get a source, likely through configuration as well.
|
||||
|
||||
All of the above routes can be defined in source list routing tables, covered elsewhere (**make link)**.
|
||||
|
||||
---
|
||||
|
||||
### Definitions
|
||||
|
||||
#### Ports
|
||||
|
||||
Ports are logical representations of the input and output ports on a device.
|
||||
|
||||
#### Source
|
||||
|
||||
A source is a device at the beginning of a signal chain. For example, a set-top box, or a camera. Source devices typically have only output ports.
|
||||
|
||||
Source devices in Essentials must implement `IRoutingOutputs` or `IRoutingSource`
|
||||
|
||||
#### Midpoint
|
||||
|
||||
A midpoint is a device in the middle of the signal chain. Typically a switcher, matrix or otherwise. Examples: DM chassis; DM-TX; DM-RMC; A video codec. These devices will have input and output ports.
|
||||
|
||||
Midpoint devices must implement `IRoutingInputsOutputs`. Midpoints with switching must implement `IRouting`.
|
||||
|
||||
#### Sink
|
||||
|
||||
A sink is a device at the end of a full signal path. For example, a display, amplifier, encoder, etc. Sinks typically contain only input ports. They may or may not have switching, like a display with several inputs. Classes defining sink devices must implement `IRoutingSinkNoSwitching` or `IRoutingSinkWithSwitching`.
|
||||
|
||||
#### Tie-line
|
||||
|
||||
A tie-line is a logical representation of a physical cable connection between two devices. It has five properties that define how the tie-line connects two devices. A configuration snippet for a single tie line connecting HDMI output 1 on a Cisco RoomKit to HDMI input 1 on a display, carrying both audio and video, is shown below.
|
||||
|
||||
```json
|
||||
{
|
||||
"sourceKey": "ciscoSparkPlusCodec-1",
|
||||
"sourcePort": "HdmiOut1",
|
||||
"destinationKey": "display-1",
|
||||
"destinationPort": "HdmiIn1",
|
||||
"type": "audioVideo"
|
||||
}
|
||||
```
|
||||
|
||||
### Interfaces
|
||||
|
||||
Todo: Define Interfaces IRouting, IRoutingOutputs, IRoutingInputs
|
||||
274
docs/docs/Debugging.md
Normal file
@@ -0,0 +1,274 @@
|
||||
# Methods of Debugging
|
||||
|
||||
1. You can use Visual Studio step debugging
|
||||
- Pros:
|
||||
- Detailed real time debugging into with breakpoints and object inspection
|
||||
- Cons:
|
||||
- Doesn't really work remotely
|
||||
- On processors with Control Subnet, you must be connected to the CS interface to use step debugging. Often not practical or possible.
|
||||
- No logging
|
||||
- Using breakpoints stops the program and can interrupt system usage
|
||||
- Requires the running application to be built in debug mode, not release mode
|
||||
2. You can use the Debug class features build into the PepperDash.Core library.
|
||||
- Pros:
|
||||
- Can be easily enabled from console
|
||||
- Allows for setting the level of verbosity
|
||||
- Works when troubleshooting remotely and doesn't require a connection to the CS interface of the processor.
|
||||
- Allows for logging to the Crestron error log or a custom log stored on removable media
|
||||
- Works regardless of build type setting (debug/release)
|
||||
- Can easily identify which class instance is generating console messages
|
||||
- Can use console commands to view the state of public properties on devices
|
||||
- Can use console commands to call methods on devices
|
||||
- Doesn't stop the program
|
||||
- Cons:
|
||||
- No detailed object inspection in real time
|
||||
- Only prints console statements already in code
|
||||
- When enabled at the highest level of verbosity, it can produce a significant amount of data in console. Can be hard to find messages easily.
|
||||
- No current mechanism to filter messages by device. (can be filtered by 3rd party tools easily, though)
|
||||
- Not very effective in debugging applications running on the VC-4 platform as only log messages get printed to the Syslog
|
||||
|
||||
## How to use the PepperDash.Core Debug Class
|
||||
|
||||
The majority of interaction is done via console, preferably via an SSH session through Crestron Toolbox, PuTTy or any other suitable application.
|
||||
|
||||
In code, the most useful method is `Debug.Console()` which has several overloads. All variations take an integer value for the level (0-2) as the first argument. Level 0 will ALWAYS print. Level 1 is for typical debug messages and level 2 is for verbose debugging. In cases where the overloads that accept a `Debug.ErrorLogLevel` parameter are used, the message will ALWAYS be logged, but will only print to console if the current debug level is the same or higher than the level set in the `Debug.Console()` statement.
|
||||
|
||||
All statements printed to console are prefixed by a timestamp which can be greatly helpful in debugging order of operations.
|
||||
|
||||
```cs
|
||||
// The most basic use, sets the level (0) and the message to print.
|
||||
Debug.Console(0, "Hello World");
|
||||
// prints: [timestamp]App 1:Hello World
|
||||
|
||||
// The string parameter has a built in string.Format() that takes params object[] items
|
||||
string world = "World";
|
||||
Debug.Console(0, "Hello {0}", world);
|
||||
// prints: [timestamp]App 1:Hello World
|
||||
|
||||
// This overload takes an IKeyed as the second parameter and the resulting statement will
|
||||
// print the Key of the device in console to help identify the class instance the message
|
||||
// originated from
|
||||
Debug.Console(0, this, "Hello World");
|
||||
// prints: [timestamp]App 1:[deviceKey]Hello World
|
||||
|
||||
// Each of the above overloads has a corresponding variant that takes an argument to indicate
|
||||
// the level of error to log the message at as well as printing to console
|
||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Hello World");
|
||||
// prints: [timestamp]App 1:Hello World
|
||||
```
|
||||
|
||||
## Console Commands
|
||||
|
||||
### General Console Commands
|
||||
|
||||
Below are is a non-exhaustive list of some of the Essentials specific console commands that allow interaction with the application at runtime.
|
||||
|
||||
### `help user`
|
||||
|
||||
Will print the available console commands for each program slot. Console commands can be added and removed dynamically by Essentials and may vary by the version of Essentials that is running. This is the best place to start to determine the available commands registered for each instance of Essentials running on a processor.
|
||||
|
||||
### `reportversions:[slot]`
|
||||
|
||||
Will print the running versions of all .dll libraries. Useful for determining the exact build version of the Essentials application and all plugins
|
||||
|
||||
### `gettypes:[slot] [searchString(optional)]`
|
||||
|
||||
The `searchString` value is an optional parameter to filter the results.
|
||||
|
||||
Will print all of the valid `type` values registered in the `DeviceFactory` for the running Essentials application. This helps when generating config structure and defining devices. Device types added by plugins will also be shown.
|
||||
|
||||
### `showconfig:[slot]`
|
||||
|
||||
Will print out the merged config object
|
||||
|
||||
### `donotloadonnextboot:[slot] [true/false]`
|
||||
|
||||
When the value is set to true, Essentials will pause when starting up, to allow for a developer to attach to the running process from an IDE for purposes of step debugging. Once attached, issuing the command `go:[slot]` will cause the configuration file to be read and the program to initialize. This value gets set to false when the `go` command is issues.
|
||||
|
||||
### DeviceManager Console Commands
|
||||
|
||||
The following console commands all perform actions on devices that have been registered with the `PepperDash.Essentials.Core.DeviceManager` static class
|
||||
|
||||
### `Appdebug:[slot][0-2]`
|
||||
|
||||
Gets or sets the current debug level where 0 is the lowest setting and 2 is the most verbose
|
||||
|
||||
### `getjoinmap:[slot] [bridgeKey][deviceKey (optional)]
|
||||
|
||||
For use with SIMPL Bridging. Prints the join map for the specified bridge. If a device key is specified, only the joins for that device will be printed.
|
||||
|
||||
Example:
|
||||
|
||||
```sh
|
||||
RMC3>appdebug:1 // Gets current level
|
||||
RMC3>AppDebug level = 0
|
||||
|
||||
RMC3>appdebug:1 1 // Sets level to 1 (all messages level 1 or lower will print)
|
||||
RMC3>[Application 1], Debug level set to 1
|
||||
```
|
||||
|
||||
### `Devlist:[slot]`
|
||||
|
||||
Gets the current list of devices from `DeviceManager`
|
||||
|
||||
Prints in the form [deviceKey] deviceName
|
||||
|
||||
Example:
|
||||
|
||||
```sh
|
||||
// Get the list of devices for program 1
|
||||
RMC3>devlist:1
|
||||
|
||||
RMC3>[16:34:05.819]App 1:28 Devices registered with Device Mangager:
|
||||
[16:34:05.834]App 1: [cec-1] Tx 5 cec 1
|
||||
[16:34:05.835]App 1: [cec-1-cec]
|
||||
[16:34:05.835]App 1: [cec-5] Rmc 1 cec 1
|
||||
[16:34:05.836]App 1: [cec-5-cec]
|
||||
[16:34:05.836]App 1: [cec-6] Dm Chassis In 1 cec 1
|
||||
[16:34:05.837]App 1: [cec-6-cec]
|
||||
[16:34:05.837]App 1: [cec-7] Dm Chassis Out 1 cec 1
|
||||
[16:34:05.838]App 1: [cec-7-cec]
|
||||
[16:34:05.838]App 1: [comm-1] Generic comm 1
|
||||
[16:34:05.838]App 1: [comm-1-com]
|
||||
[16:34:05.839]App 1: [comm-2] Rmc comm 1
|
||||
[16:34:05.839]App 1: [comm-2-com]
|
||||
[16:34:05.840]App 1: [comm-3] Rmc comm 2
|
||||
[16:34:05.840]App 1: [comm-3-com]
|
||||
[16:34:05.841]App 1: [dmMd8x8-1] DM-MD8x8 Chassis 1
|
||||
[16:34:05.842]App 1: [dmRmc100C-1] DM-RMC-100-C Out 3
|
||||
[16:34:05.843]App 1: [dmRmc200C-1] DM-RMC-200-C Out 2
|
||||
[16:34:05.843]App 1: [dmRmc4kScalerC-1] DM-RMC-4K-SCALER-C Out 1
|
||||
[16:34:05.844]App 1: [dmTx201C-1] DM-TX-201C 1
|
||||
[16:34:05.845]App 1: [eisc-1A]
|
||||
[16:34:05.845]App 1: [gls-odt-1] GLS-ODT-CN 1
|
||||
[16:34:05.846]App 1: [gls-oir-1] GLS-OIR-CN 1
|
||||
[16:34:05.846]App 1: [processor]
|
||||
[16:34:05.847]App 1: [ssh-1] Generic SSH 1
|
||||
[16:34:05.847]App 1: [ssh-1-ssh]
|
||||
[16:34:05.848]App 1: [systemMonitor]
|
||||
[16:34:05.848]App 1: [tcp-1] Generic TCP 1
|
||||
[16:34:05.849]App 1: [tcp-1-tcp]
|
||||
```
|
||||
### `Setdevicestreamdebug:[slot][devicekey][both/rx/tx/off]`
|
||||
|
||||
Enables debug for communication on a single device
|
||||
|
||||
Example:
|
||||
|
||||
```sh
|
||||
PRO3>setdevicestreamdebug:1 lights-1-com both
|
||||
|
||||
[13:13:57.000]App 1:[lights-1-com] Sending 4 characters of text: 'test'
|
||||
|
||||
PRO3>setdevicestreamdebug:1 lights-1-com off
|
||||
```
|
||||
|
||||
### `Devprops:[slot][devicekey]`
|
||||
|
||||
Gets the list of public properties on the device with the corresponding `deviceKey`
|
||||
|
||||
Example:
|
||||
|
||||
```sh
|
||||
// Get the properties on the device with Key 'cec-1-cec'
|
||||
// This device happens to be a CEC port on a DM-TX-201-C's HDMI input
|
||||
RMC3>devprops:1 cec-1-cec
|
||||
[
|
||||
{
|
||||
"Name": "IsConnected",
|
||||
"Type": "Boolean",
|
||||
"Value": "True",
|
||||
"CanRead": true,
|
||||
"CanWrite": false
|
||||
},
|
||||
{
|
||||
"Name": "Key",
|
||||
"Type": "String",
|
||||
"Value": "cec-1-cec",
|
||||
"CanRead": true,
|
||||
"CanWrite": true
|
||||
},
|
||||
{
|
||||
"Name": "Name",
|
||||
"Type": "String",
|
||||
"Value": "",
|
||||
"CanRead": true,
|
||||
"CanWrite": true
|
||||
},
|
||||
{
|
||||
"Name": "Enabled",
|
||||
"Type": "Boolean",
|
||||
"Value": "False",
|
||||
"CanRead": true,
|
||||
"CanWrite": true
|
||||
}
|
||||
]
|
||||
|
||||
RMC3>
|
||||
|
||||
```
|
||||
|
||||
### `Devmethods:[slot][devicekey]`
|
||||
|
||||
Gets the list of public methods available on the device
|
||||
|
||||
Example:
|
||||
|
||||
```sh
|
||||
// Get the methods on the device with Key 'cec-1-cec'
|
||||
RMC3>devmethods:1 cec-1-cec
|
||||
[
|
||||
{
|
||||
"Name": "SendText",
|
||||
"Params": [
|
||||
{
|
||||
"Name": "text",
|
||||
"Type": "String"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"Name": "SendBytes",
|
||||
"Params": [
|
||||
{
|
||||
"Name": "bytes",
|
||||
"Type": "Byte[]"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"Name": "SimulateReceive",
|
||||
"Params": [
|
||||
{
|
||||
"Name": "s",
|
||||
"Type": "String"
|
||||
}
|
||||
]
|
||||
},
|
||||
//... Response abbreviated for clarity ...
|
||||
]
|
||||
|
||||
RMC3>
|
||||
```
|
||||
|
||||
### `Devjson:[slot][json formatted object {"devicekey", "methodname", "params"}]`
|
||||
|
||||
Used in conjunction with devmethods, this command allows any of the public methods to be called from console and the appropriate arguments can be passed in to the method via a JSON object.
|
||||
|
||||
This command is most useful for testing without access to hardware as it allows both simulated input and output for a device.
|
||||
|
||||
Example:
|
||||
|
||||
```sh
|
||||
// This command will call the SendText(string text) method on the
|
||||
// device with the Key 'cec-1-cec' and pass in "hello world" as the
|
||||
// argument parameter. On this particular device, it would cause
|
||||
// the string to be sent via the CEC Transmit
|
||||
RMC3>devjson:1 {"deviceKey":"cec-1-cec", "methodName":"SendText", "params": ["hello world\r"]}
|
||||
|
||||
// This command will call SimulateReceive(string text) on the device with Key 'cec-1-cec'
|
||||
// This would simulate receiving data on the CEC port of the DM-TX-201-C's HDMI input
|
||||
RMC3>devjson:1 {"deviceKey":"cec-1-cec", "methodName":"SimulateReceive", "params": ["hello citizen of Earth\r"]}
|
||||
```
|
||||
|
||||
For additional examples, see this [file](https://github.com/PepperDash/Essentials/blob/main/devjson%20commands.json).
|
||||
171
docs/docs/DigitalInput.md
Normal file
@@ -0,0 +1,171 @@
|
||||
# DigitalInput
|
||||
|
||||
Digital Inputs can be bridged directly to SIMPL from any device that is both inlcuded within essentials and has a relay.
|
||||
|
||||
Consider the following example.
|
||||
|
||||
```JSON
|
||||
{
|
||||
"template": {
|
||||
"roomInfo": [
|
||||
{}
|
||||
],
|
||||
"devices": [
|
||||
{
|
||||
"key": "processor",
|
||||
"uid": 0,
|
||||
"type": "pro3",
|
||||
"name": "pro3",
|
||||
"group": "processor",
|
||||
"supportedConfigModes": [
|
||||
"compliance",
|
||||
"essentials"
|
||||
],
|
||||
"supportedSystemTypes": [
|
||||
"hudType",
|
||||
"presType",
|
||||
"vtcType",
|
||||
"custom"
|
||||
],
|
||||
"supportsCompliance": true,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"key": "DigitalInput-1",
|
||||
"uid": 3,
|
||||
"name": "Digital Input 1",
|
||||
"group": "api",
|
||||
"type": "digitalInput",
|
||||
"properties": {
|
||||
"portDeviceKey" : "processor",
|
||||
"portNumber" : 1,
|
||||
"disablePullUpResistor" : true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "DigitalInput-2",
|
||||
"uid": 3,
|
||||
"name": "Digital Input 2",
|
||||
"group": "api",
|
||||
"type": "digitalInput",
|
||||
"properties": {
|
||||
"portDeviceKey" : "processor",
|
||||
"portNumber" : 2,
|
||||
"disablePullUpResistor" : true
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "deviceBridge",
|
||||
"uid": 4,
|
||||
"name": "BridgeToDevices",
|
||||
"group": "api",
|
||||
"type": "eiscapiadv",
|
||||
"properties": {
|
||||
"control": {
|
||||
"tcpSshProperties": {
|
||||
"address": "127.0.0.2",
|
||||
"port": 0
|
||||
},
|
||||
"ipid": "03",
|
||||
"method": "ipidTcp"
|
||||
},
|
||||
"devices": [
|
||||
{
|
||||
"deviceKey": "DigitalInput-1",
|
||||
"joinStart": 1
|
||||
},
|
||||
{
|
||||
"deviceKey": "DigitalInput-2",
|
||||
"joinStart": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## RelayOutput Configuration Explanation
|
||||
|
||||
This configuration is meant for a Pro3 device, and instantiates two relay ports and links them to an eisc bridge to another processor slot on ipid 3. Let's break down the ```DigitalInput-1``` device.
|
||||
|
||||
```JSON
|
||||
{
|
||||
"key": "DigitalInput-1",
|
||||
"uid": 3,
|
||||
"name": "Digital Input 1",
|
||||
"group": "api",
|
||||
"type": "digitalInput",
|
||||
"properties": {
|
||||
"portDeviceKey" : "processor",
|
||||
"portNumber" : 1,
|
||||
"disablePullUpResistor" : true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**```Key```**
|
||||
|
||||
The Key is a unique identifier for essentials. The key allows the device to be linked to other devices also defined by key. All Keys MUST be unique, as every device is added to a globally-accessible dictionary. If you have accidentally utilized the same key twice, Essentials will notify you during startup that there is an issue with the device.
|
||||
|
||||
**```Uid```**
|
||||
|
||||
The Uid is reserved for use with an PepperDash internal config generation tool, and is not useful to Essentials in any way.
|
||||
|
||||
**```Name```**
|
||||
|
||||
The Name a friendly name assigned to the device. Many devices pass this data to the bridge for utilization in SIMPL.
|
||||
|
||||
**```Group```**
|
||||
|
||||
Utilized in certain Essentials devices. In this case, the value is unimportant.
|
||||
|
||||
**```Type```**
|
||||
|
||||
The Type is the identifier for a specific type of device in Essentials. A list of all valid types can be reported by using the consolecommand ```gettypes``` in Essentials. In this case, the type is ```digitalInput```. This type is valid for any instance of a Relay Output.
|
||||
|
||||
**```Properties```**
|
||||
|
||||
These are the properties essential to the instantiation of the identified type.
|
||||
|
||||
### Properties
|
||||
|
||||
There are two properties relevant to the instantiation of a relay device.
|
||||
|
||||
**```portDeviceKey```**
|
||||
|
||||
This property maps to the ```key``` of the device upon which the relay resides.
|
||||
|
||||
**```portNumber```**
|
||||
|
||||
This property maps to the number of the relay on the device you have mapped the relay device to. Even if the device has only a single relay, ```portNumber``` must be defined.
|
||||
|
||||
**```disablePullUpResistor```**
|
||||
|
||||
This is a boolean value, therefore it is a case-sensitive ```true``` or ```false``` utilized to determine if the pullup resistor on the digital input will be disabled or not.
|
||||
|
||||
### The JoinMap
|
||||
|
||||
The joinmap for a ```digitalInput``` device is comprised of a single digital join.
|
||||
|
||||
```cs
|
||||
namespace PepperDash.Essentials.Core.Bridges
|
||||
{
|
||||
public class IDigitalInputJoinMap : JoinMapBaseAdvanced
|
||||
{
|
||||
|
||||
[JoinName("InputState")]
|
||||
public JoinDataComplete InputState = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Room Email Url", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital });
|
||||
|
||||
|
||||
public IDigitalInputJoinMap(uint joinStart)
|
||||
: base(joinStart, typeof(IDigitalInputJoinMap))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```InputState``` is a digital join that represents the feedback for the associated Digital Input Device. Its join is set to 1.
|
||||
128
docs/docs/Feedback-Classes.md
Normal file
@@ -0,0 +1,128 @@
|
||||
# Feedback classes
|
||||
|
||||
***
|
||||
* [YouTube Video - Using Feedbacks in PepperDash Essentials](https://youtu.be/5GQVRKbD9Rk)
|
||||
***
|
||||
|
||||
The various Feedback classes are like "signals". They can enable various events, and are designed to be used where we need small data events to be sent without requiring custom handlers.
|
||||
|
||||
## Why Feedbacks?
|
||||
|
||||
We have been writing "code" in an environment, Simpl, for years and have taken for granted the power that signals in that environment give us. With the release of the ability to develop in C#, we have been handed a massive set of tools to potentially make our lives better, but because of the age and limited scope of the .NET 3.5 Compact Framework, many of the things that have been very easy to do in the past have become challenging or bulky to write. Crestron classes have things called "Sigs", which are a less-functional version of the signal that we used in Simpl, but we have no ability to use our own Sigs around our own classes. This forces us to break out of the constraints and mindset of Simpl programming, but simultaneously keeps us partially bound to the "old way" of doing things.
|
||||
|
||||
Signals as we have known them since Simpl came around are great. They allow a certain type of functional programming to be built, where things operate in solutions, and we are given a whole set of behaviors that we don't really have to think about: Something goes high, the next thing responds, something else happens, etc. With our older C# framework, it is most straightforward (and least-flexible) to take Sig transitions and handle them using very-flat and bulky coding techniques: Switch/case blocks, if/else blocks, slow dictionaries... In the Essentials environment (and in many other frameworks) these methods quickly reveal their flaws.
|
||||
|
||||
Enter the Feedback. We want to define simple events that can be attached to various things - TP Sigs, EISC, event handlers - and maintain their own state. This simplifies the interface to various device classes, and allows us to define functional, simple classes with well-defined means of connecting them together.
|
||||
|
||||
### Feedbacks are similar to signals
|
||||
|
||||
Feedbacks can:
|
||||
|
||||
- Fire an event (OutputChange)
|
||||
- Be linked to one or more matching Crestron Sigs and update those Sigs
|
||||
- May contain complex computations to define the output value
|
||||
- Be put into test mode and have their value function overridden
|
||||
|
||||
A Feedback is defined on a class using a C# construct called a `Func`. A `Func` is a small operation that returns a single value and is typically written in a lambda. The operation/expression in the `Func` is calculated when FireUpdate() is called on the Feedback. The result is then available for all objects listening to this Feedback.
|
||||
|
||||
[Func documentation (MSDN)](<https://msdn.microsoft.com/en-us/library/bb534960(v=vs.110).aspx>)
|
||||
|
||||
#### Creating Feedbacks
|
||||
|
||||
The following `IntFeedback` returns the value of the `_VolumeLevel` field in this display class:
|
||||
|
||||
```cs
|
||||
public class MyDisplay
|
||||
{
|
||||
public IntFeedback VolumeLevelFeedback { get; private set; }
|
||||
|
||||
...
|
||||
|
||||
public MyDisplay(...)
|
||||
{
|
||||
VolumeLevelFeedback = new IntFeedback(() => { return _VolumeLevel; });
|
||||
|
||||
...
|
||||
```
|
||||
|
||||
This BoolFeedback, adapted from the DmTx201Controller class, defines the `Func` first, and then creates the BoolFeedback using that `Func`. The value returned is true if the input is the digital-HDMI connection, and the TX hardware's VideoAttributes.HdcpActiveFeedback is true as well.
|
||||
|
||||
```cs
|
||||
public class MyTx
|
||||
{
|
||||
public BoolFeedback HdcpActiveFeedback { get; private set; }
|
||||
|
||||
Func HdcpActiveFeedbackFunc = () =>
|
||||
ActualVideoInput == DmTx200Base.eSourceSelection.Digital
|
||||
&& tx.HdmiInput.VideoAttributes.HdcpActiveFeedback.BoolValue,
|
||||
|
||||
...
|
||||
|
||||
public MyTx(...)
|
||||
{
|
||||
HdcpActiveFeedback = new BoolFeedback(HdcpActiveFeedbackFunc);
|
||||
|
||||
...
|
||||
```
|
||||
|
||||
#### Triggering Feedback
|
||||
|
||||
In your classes, when you need to update the objects listening to a Feedback, you will call MyFeedback.FireUpdate() inside your class. This will trigger the evaluation of the Func value, update any linked Sigs, and fire the OutputChange event.
|
||||
|
||||
```cs
|
||||
int _VolumeLevel;
|
||||
|
||||
void ComDataChanged(string data) // volume=77
|
||||
{
|
||||
if(data.StartsWith("volume="))
|
||||
{
|
||||
_VolumeLevel = MyParseVolumeMethod(data); // get the level, 77
|
||||
VolumeLevelFeedback.FireUpdate(); // all listeners updated
|
||||
|
||||
```
|
||||
|
||||
#### Using Feedbacks
|
||||
|
||||
Feedbacks of the various types have BoolValue, IntValue, UShortValue, and StringValue properties that return the current value of the Feedback.
|
||||
|
||||
```cs
|
||||
if (MyTxDevice.HdcpActiveFeedback.BoolValue)
|
||||
{
|
||||
... do something that needs to happen when HDCP is active ...
|
||||
```
|
||||
|
||||
Feedbacks all share an OutputChange event, that fires an event with an empty EventArgs object. The event handler can go get the appropriate \*Value property when the event fires. The example below is a bit contrived, but explains the idea.
|
||||
|
||||
```cs
|
||||
...
|
||||
MyDisplayDevice.VolumeLevelFeedback.OutputChange += MyDisplayVolumeHandler;
|
||||
|
||||
...
|
||||
}
|
||||
|
||||
void MyDisplayVolumeHandler(object o, EventArgs a)
|
||||
{
|
||||
MobileControlServer.VolumeLevel = MyDisplayDevice.VolumeLevelFeedback.IntValue;
|
||||
```
|
||||
|
||||
Feedbacks also have a LinkInputSig(\*InputSig sig) method that can directly trigger one or more Sigs on a Crestron device, without requiring an event handler. This is very useful for attaching states of our devices to Crestron touchpanels or EISCs, for example. The BoolFeedback class also has a LinkComplementInputSig(BoolInputSig sig) method that will invert the BoolFeedback's value to one or more attached Sigs.
|
||||
|
||||
As well as updating upon change, the Feedback will set the Sig's value to the Feedback value upon calling the LinkInputSig method. This eliminates the need to walk through an object, property-by-property, and update several Sig values - as well as setting up to watch those values for changes. It is all handled in one step.
|
||||
|
||||
```cs
|
||||
public class MyClass
|
||||
{
|
||||
Tsw760 MyTp;
|
||||
|
||||
MyDisplay Display;
|
||||
|
||||
HookUpSigsMethod()
|
||||
{
|
||||
...
|
||||
|
||||
// changes to VolumeLevelFeedback will automatically propagate to UShortInputSig 123
|
||||
// changes to HdcpActiveFeedback will propagate to BoolInputSig 456
|
||||
// and these two panel Sigs are updated immediately as well.
|
||||
Display.VolumeLevelFeedback.LinkInputSig(MyTp.UshortInput[123]);
|
||||
MyHdcpDevice.HdcpActiveFeedback.LinkInputSig(MyTp.BoolInput[456]);
|
||||
```
|
||||
381
docs/docs/GenericComm.md
Normal file
@@ -0,0 +1,381 @@
|
||||
# GenericComm
|
||||
|
||||
One of the most common scenarios in control system development is utilizing RS232 to connect to a device. Essentials doesn't restrict you to connecting a native essentials device or plugin to the comport. You can directly access the comport, and even set baudrates on the fly if you so desire.
|
||||
|
||||
Similarly you can instantiate one of several socket types in this manner and bridge them directly to SIMPL.
|
||||
|
||||
Consider the following example.
|
||||
|
||||
```JSON
|
||||
{
|
||||
"template": {
|
||||
"roomInfo": [
|
||||
{}
|
||||
],
|
||||
"devices": [
|
||||
{
|
||||
"key": "processor",
|
||||
"uid": 0,
|
||||
"type": "pro3",
|
||||
"name": "pro3",
|
||||
"group": "processor",
|
||||
"supportedConfigModes": [
|
||||
"compliance",
|
||||
"essentials"
|
||||
],
|
||||
"supportedSystemTypes": [
|
||||
"hudType",
|
||||
"presType",
|
||||
"vtcType",
|
||||
"custom"
|
||||
],
|
||||
"supportsCompliance": true,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"key": "Comport-1",
|
||||
"uid": 3,
|
||||
"name": "Comport 1",
|
||||
"group": "api",
|
||||
"type": "genericComm",
|
||||
"properties": {
|
||||
"control": {
|
||||
"method": "com",
|
||||
"comParams": {
|
||||
"hardwareHandshake": "None",
|
||||
"parity": "None",
|
||||
"protocol": "RS232",
|
||||
"baudRate": 115200,
|
||||
"dataBits": 8,
|
||||
"softwareHandshake": "None",
|
||||
"stopBits": 1
|
||||
},
|
||||
"controlPortNumber": 1,
|
||||
"controlPortDevKey": "processor",
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "Comport-2",
|
||||
"uid": 3,
|
||||
"name": "Comport 2",
|
||||
"group": "api",
|
||||
"type": "genericComm",
|
||||
"properties": {
|
||||
"control": {
|
||||
"method": "ssh",
|
||||
"tcpSshProperties": {
|
||||
"address": "192.168.1.57",
|
||||
"port": 22,
|
||||
"username": "",
|
||||
"password": "",
|
||||
"autoReconnect": true,
|
||||
"autoReconnectIntervalMs": 10000
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "deviceBridge",
|
||||
"uid": 4,
|
||||
"name": "BridgeToDevices",
|
||||
"group": "api",
|
||||
"type": "eiscapiadv",
|
||||
"properties": {
|
||||
"control": {
|
||||
"tcpSshProperties": {
|
||||
"address": "127.0.0.2",
|
||||
"port": 0
|
||||
},
|
||||
"ipid": "03",
|
||||
"method": "ipidTcp"
|
||||
},
|
||||
"devices": [
|
||||
{
|
||||
"deviceKey": "Comport-1",
|
||||
"joinStart": 1
|
||||
},
|
||||
{
|
||||
"deviceKey": "Comport-2",
|
||||
"joinStart": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## GenericComm Configuration Explanation
|
||||
|
||||
This configuration is meant for a Pro3 device, and instantiates one comport and one SSH session and links them to an eisc bridge to another processor slot on ipid 3. Let's break down the ```Comport-1``` device.
|
||||
|
||||
```JSON
|
||||
{
|
||||
"key": "Comport-1",
|
||||
"uid": 3,
|
||||
"name": "Comport 1",
|
||||
"group": "comm",
|
||||
"type": "genericComm",
|
||||
"properties": {
|
||||
"control": {
|
||||
"comParams": {
|
||||
"hardwareHandshake": "None",
|
||||
"parity": "None",
|
||||
"protocol": "RS232",
|
||||
"baudRate": 115200,
|
||||
"dataBits": 8,
|
||||
"softwareHandshake": "None",
|
||||
"stopBits": 1
|
||||
},
|
||||
"controlPortNumber": 1,
|
||||
"controlPortDevKey": "processor",
|
||||
"method": "com"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**```Key```**
|
||||
|
||||
The Key is a unique identifier for essentials. The key allows the device to be linked to other devices also defined by key. All Keys MUST be unique, as every device is added to a globally-accessible dictionary. If you have accidentally utilized the same key twice, Essentials will notify you during startup that there is an issue with the device.
|
||||
|
||||
**```Uid```**
|
||||
|
||||
The Uid is reserved for use with an PepperDash internal config generation tool, and is not useful to Essentials in any way.
|
||||
|
||||
**```Name```**
|
||||
|
||||
The Name a friendly name assigned to the device. Many devices pass this data to the bridge for utilization in SIMPL.
|
||||
|
||||
**```Group```**
|
||||
|
||||
Utilized in certain Essentials devices. In this case, the value is unimportant.
|
||||
|
||||
**```Type```**
|
||||
|
||||
The Type is the identifier for a specific type of device in Essentials. A list of all valid types can be reported by using the consolecommand ```gettypes``` in Essentials. In this case, the type is ```genericComm```. This type is valid for any instance of a serial-based communications channel such as a Serial Port, SSH, UDP, or standard TCP/IP Socket.
|
||||
|
||||
**```Properties```**
|
||||
|
||||
These are the properties essential to the instantiation of the identified type.
|
||||
|
||||
#### Control
|
||||
|
||||
The properties within this property are dependant on the type of genericComm you wish to instantiate. There is one common property for control of any type, and that is ```method```. The ```method``` property requires a string that maps to the following enumerations in Essentials :
|
||||
|
||||
```cs
|
||||
namespace PepperDash.Core
|
||||
{
|
||||
// Summary:
|
||||
// Crestron Control Methods for a comm object
|
||||
public enum eControlMethod
|
||||
{
|
||||
None = 0,
|
||||
Com = 1,
|
||||
IpId = 2,
|
||||
IpidTcp = 3,
|
||||
IR = 4,
|
||||
Ssh = 5,
|
||||
Tcpip = 6,
|
||||
Telnet = 7,
|
||||
Cresnet = 8,
|
||||
Cec = 9,
|
||||
Udp = 10,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
These enumerations are not case sensitive. Not all methods are valid for a ```genericComm``` device. For a comport, the only valid type would be ```Com```. For a direct network socket, valid options are ```Ssh```, ```Tcpip```, ```Telnet```, and ```Udp```.
|
||||
|
||||
##### ComParams
|
||||
|
||||
A ```Com``` device requires a ```comParams``` object to set the properties of the comport. The values of all properties are case-insensitive.
|
||||
|
||||
```JSON
|
||||
{
|
||||
"comParams": {
|
||||
"hardwareHandshake": "None",
|
||||
"parity": "None",
|
||||
"protocol": "RS232",
|
||||
"baudRate": 115200,
|
||||
"dataBits": 8,
|
||||
"softwareHandshake": "None",
|
||||
"stopBits": 1
|
||||
}
|
||||
```
|
||||
|
||||
**Valid ```hardwareHandshake``` values are as follows**
|
||||
|
||||
```sh
|
||||
"None"
|
||||
"Rts"
|
||||
"Cts"
|
||||
"RtsCts"
|
||||
```
|
||||
|
||||
**Valid ```parity``` values are as follows**
|
||||
|
||||
```sh
|
||||
"None"
|
||||
"Even"
|
||||
"Odd"
|
||||
"Mark"
|
||||
```
|
||||
|
||||
**Valid ```protocol``` values are as follows**
|
||||
|
||||
```sh
|
||||
"RS232"
|
||||
"RS422"
|
||||
"RS485"
|
||||
```
|
||||
|
||||
**Valid ```baudRate``` values are as follows**
|
||||
|
||||
```sh
|
||||
300
|
||||
600
|
||||
1200
|
||||
1800
|
||||
2400
|
||||
3600
|
||||
4800
|
||||
7200
|
||||
9600
|
||||
14400
|
||||
19200
|
||||
28800
|
||||
38400
|
||||
57600
|
||||
115200
|
||||
```
|
||||
|
||||
**Valid ```dataBits``` values are as follows**
|
||||
|
||||
```sh
|
||||
7
|
||||
8
|
||||
```
|
||||
|
||||
**Valid ```softwareHandshake``` values are as follows**
|
||||
|
||||
```sh
|
||||
"None"
|
||||
"XON"
|
||||
"XONT"
|
||||
"XONR"
|
||||
```
|
||||
|
||||
**Valid ```stopBits``` values are as follows**
|
||||
|
||||
```sh
|
||||
1
|
||||
2
|
||||
```
|
||||
|
||||
Additionally, a ```control``` object for a physical hardware port needs to map to that physical port. This is accomplished by utilizing the ```controlPortDevKey``` and ```port``` properties.
|
||||
|
||||
**```controlPortDevKey```**
|
||||
|
||||
This property maps to the ```key``` of the device upon which the port resides.
|
||||
|
||||
**```port```**
|
||||
|
||||
This property maps to the number of the port on the device you have mapped the relay device to. Even if the device has only a single port, ```port``` must be defined.
|
||||
|
||||
##### TcpSshParams
|
||||
|
||||
A ```Ssh```, ```TcpIp```, or ```Udp``` device requires a ```tcpSshProperties``` object to set the propeties of the socket.
|
||||
|
||||
```Json
|
||||
{
|
||||
"tcpSshProperties": {
|
||||
"address": "192.168.1.57",
|
||||
"port": 22,
|
||||
"username": "",
|
||||
"password": "",
|
||||
"autoReconnect": true,
|
||||
"autoReconnectIntervalMs": 10000
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**```address```**
|
||||
|
||||
This is the IP address, hostname, or FQDN of the resource you wish to open a socket to. In the case of a UDP device, you can set either a single whitelist address with this data, or an appropriate broadcast address.
|
||||
|
||||
**```port```**
|
||||
|
||||
This is the port you wish to utilize for the socket connection. Certain protocols require certain ports - ```Ssh``` being ```22``` and ```Telnet``` being ```23```.
|
||||
|
||||
**```username```**
|
||||
|
||||
This is the username (if required) for authentication to the device you are connecting to. Typcally only required for ```Ssh``` connections.
|
||||
|
||||
**```password```**
|
||||
|
||||
This is the password (if required) for authentication to the device you are connecting to. Typcally only required for ```Ssh``` connections.
|
||||
|
||||
**```autoreconnect```**
|
||||
|
||||
This is a boolean value, therefore it is a case-sensitive ```true``` or ```false``` utilized to determine if the socket will attempt to reconnect upon loss of connection.
|
||||
|
||||
**```autoReconnectIntervalMs```**
|
||||
|
||||
This is the duration of time, in Miliseconds, that the socket will wait before discrete connection attempts if ```autoreconnect``` is set to true.
|
||||
|
||||
##### The JoinMap
|
||||
|
||||
The join map for a generic comms device is fairly simple.
|
||||
|
||||
```cs
|
||||
namespace PepperDash.Essentials.Core.Bridges
|
||||
{
|
||||
public class IBasicCommunicationJoinMap : JoinMapBaseAdvanced
|
||||
{
|
||||
[JoinName("TextReceived")]
|
||||
public JoinDataComplete TextReceived = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Text Received From Remote Device", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial });
|
||||
|
||||
[JoinName("SendText")]
|
||||
public JoinDataComplete SendText = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Text Sent To Remote Device", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial });
|
||||
|
||||
[JoinName("SetPortConfig")]
|
||||
public JoinDataComplete SetPortConfig = new JoinDataComplete(new JoinData() { JoinNumber = 2, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Set Port Config", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial });
|
||||
|
||||
[JoinName("Connect")]
|
||||
public JoinDataComplete Connect = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Connect", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital });
|
||||
|
||||
[JoinName("Connected")]
|
||||
public JoinDataComplete Connected = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Connected", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital });
|
||||
|
||||
[JoinName("Status")]
|
||||
public JoinDataComplete Status = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Status", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog });
|
||||
|
||||
|
||||
public IBasicCommunicationJoinMap(uint joinStart)
|
||||
: base(joinStart, typeof(IBasicCommunicationJoinMap))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```TextReceived``` is a stream of strings received **FROM** the connected device.
|
||||
|
||||
```SendText``` is for any strings you wish to send **TO** the connected device.
|
||||
|
||||
```Connect``` connects to a remote socket device on the rising edge of the signal.
|
||||
|
||||
```Connected``` represents the current connection state. High for Connected, low for Disconnected.
|
||||
|
||||
```Status``` is an analog value that is representative of the connection states as reported by the SIMPL TCP/IP socket symbol.
|
||||
|
||||
All of the preceeding joins are set to join ```1```. The second serial input join is reserved for ```2```. It allows you to send a ```comparams``` json object as a string, utilizing the same format mentioned previously in this document. Doing so will override the configured comport specifications.
|
||||
26
docs/docs/Get-started.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# Get started
|
||||
|
||||
---
|
||||
[YouTube Video - Getting Started with PepperDash Essentials](https://youtu.be/FxEZtbpCwiQ)
|
||||
***
|
||||
|
||||
## Download or clone
|
||||
|
||||
You may clone Essentials at <https://github.com/PepperDash/Essentials.git>
|
||||
|
||||
## How to Get Started
|
||||
|
||||
This section assumes knowledge of loading programs to and working with the file system on a Crestron processor.
|
||||
|
||||
1. Using an SFTP client, load `PepperDashEssentials1.4.32.cpz` to the processor in program slot 1 and start the program by sending console command `progload -p:1`
|
||||
1. On first boot, the Essentials Application will build the necessary configuration folder structure in the User/Program1/ path.
|
||||
1. The application has some example configuration files included. Copy `/Program01/Example Configuration/EssentialsSpaceHuddleRoom/configurationFile-HuddleSpace-2-Source.json` to the `/User/Program1/` folder.
|
||||
1. Copy the SGD files from `/Program01/SGD` to `/User/Program1/sgd`
|
||||
1. Reset the program via console `progreset -p:1`. The program will load the example configuration file.
|
||||
1. Via console, you can run the `devlist:1` command to get some insight into what has been loaded from the configuration file into the system . This will print the basic device information in the form of ["key"] "Name". The "key" value is what we can use to interact with each device uniquely.
|
||||
1. Run the command `devprops:1 display-1`. This will print the real-time property values of the device with key "display-1".
|
||||
1. Run the command `devmethods:1 display-1`. This will print the public methods available for the device with key "display-1".
|
||||
1. Run the command `devjson:1 {"deviceKey":"display-1","methodName":"PowerOn", "params": []}`. This will call the method PowerOn() on the device with key "display-1".
|
||||
1. Run the provided example XPanel SmartGraphics project and connect to your processor at the appropriate IPID.
|
||||
|
||||
Next: [Standalone use](~/docs/Standalone-Use.md)
|
||||
25
docs/docs/Glossary-of-Terms.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# Glossary of Terms
|
||||
|
||||
**Assembly**
|
||||
An assembly is a file that is automatically generated by the compiler upon successful compilation of every . NET application. It can be either a Dynamic Link Library or an executable file. It is generated only once for an application and upon each subsequent compilation the assembly gets updated.
|
||||
|
||||
**Device**
|
||||
A base class, defined in the PepperDash.Core library (`PepperDash.Core.Device`). It can represent a physical device, or a virtual device or behaviour. Generally, most new classes defined in the Essentials ecosystem should derive from Device.
|
||||
|
||||
**DeviceManager**
|
||||
A static class (`PepperDash.Core.Essentials.DeviceManager`) that contains an unordered collection of Devices. Devices are added/registered to the DeviceManager and later can be retrieved as references by Key.
|
||||
|
||||
**Essentials Application**
|
||||
A Crestron SIMPL# Pro application that is made up of the Essentials Framework and any optionally any number of Essentials Plugins
|
||||
|
||||
**Essentials Framework**
|
||||
The collection of core libraries that make up the framework
|
||||
|
||||
**Essentials Plugins**
|
||||
SIMPL# Pro libraries that reference the Essentials Framework and are loaded at runtime to add or extend functionality
|
||||
|
||||
**IKeyed**
|
||||
An important interface defined in PepperDash.Core that requires a string property named Key, whose value must be unique.
|
||||
|
||||
**PepperDash.Core**
|
||||
A SIMPL# utility library referenced by Essentials Framework.
|
||||
59
docs/docs/Home.md
Normal file
@@ -0,0 +1,59 @@
|
||||
# Welcome to PepperDash Essentials!
|
||||
|
||||
PepperDash Essentials is an open-source framework for control systems, built on Crestron's Simpl# Pro framework. It can be configured as a standalone program capable of running a wide variety of system designs and can also be used to augment other Crestron programs.
|
||||
|
||||
Essentials is a collection of C# libraries that can be used in many ways. It is a 100% configuration-driven framework that can be extended to add different workflows and behaviors, either through the addition of new device-types and classes, or via a plug-in mechanism. The framework is a collection of things that are all related and interconnected, but in general do not have strong dependencies on each other.
|
||||
|
||||
---
|
||||
|
||||
## Get started
|
||||
|
||||
- [Download essentials build or clone repo](~/docs/Get-started.md)
|
||||
- [How to get started](~/docs/Get-started.md)
|
||||
- [YouTube Video Series Playlist](https://youtube.com/playlist?list=PLKOoNNwgPFZdV5wDEBDZxTHu1KROspaBu)
|
||||
- [Discord Server](https://discord.gg/6Vh3ssDdPs)
|
||||
|
||||
Or use the links to the right to navigate our documentation.
|
||||
|
||||
---
|
||||
|
||||
## Benefits
|
||||
|
||||
- Runs on Crestron 3-Series, **4-Series** and VC-4 Control System platforms
|
||||
- Reduced hardware overhead compared to S+ and Simpl solutions
|
||||
- Quick development cycle
|
||||
- Shared resources made easily available
|
||||
- More flexibility with less code
|
||||
- Configurable using simple JSON files
|
||||
- Is awesome
|
||||
|
||||
---
|
||||
|
||||
## Comment
|
||||
|
||||
The Essentials wiki is clearly in-progress right now. Take a look at the links to the right. We are actively working on this documentation, so please be patient with us. If you have any comments on or suggestions for the documentation, please file an issue here, with as much detail as you can provide: <https://github.com/PepperDash/Essentials/issues>
|
||||
|
||||
Thanks!
|
||||
|
||||
---
|
||||
|
||||
## Collaboration
|
||||
|
||||
Essentials is an open-source project and we encourage collaboration on this community project. For features that may not be useful to the greater community, or for just-plain learning, we want to remind developers to try writing plugins for Essentials. More information can be found here: [Plugins](~/docs/Plugins.md)
|
||||
|
||||
### Open-source-collaborative workflow
|
||||
|
||||
The `main` branch always contain the latest stable version. The `development` branch is used for most development efforts.
|
||||
|
||||
[GitFlow](https://nvie.com/posts/a-successful-git-branching-model/) will be used as the workflow for this collaborative project. To contribute, follow this process:
|
||||
|
||||
1. Fork this repository ([More Info](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/working-with-forks))
|
||||
2. Create a branch using standard GitFlow branch prefixes (feature/hotfix) followed by a descriptive name.
|
||||
- Example: `feature/add-awesomeness` or `hotfix/really-big-oops`
|
||||
- When working on a new feature or bugfix, branch from the `development` branch. When working on a hotfix, branch from `main`.
|
||||
3. Make commits as necessary (often is better). And use concise, descriptive language, leveraging issue notation and/or [Closing Keywords](https://help.github.com/articles/closing-issues-using-keywords) to ensure any issues addressed by your work are referenced accordingly.
|
||||
4. When the scope of the work for your branch is complete, make sure to rebase your branch in case further progress has been made since the repo was forked
|
||||
5. Create a Pull Request to pull your branch into the appropriate branch in the main repository.
|
||||
6. Your Pull Request will be reviewed by our team and evaluated for inclusion into the main repository.
|
||||
|
||||
Next: [Get started](~/docs/Get-started.md)
|
||||
103
docs/docs/IR-Driver-Bridging.md
Normal file
@@ -0,0 +1,103 @@
|
||||
## Legacy IR Driver Bridging
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "1",
|
||||
"name": "Apple TV",
|
||||
"key": "appleTv-1",
|
||||
"type": "genericIrController",
|
||||
"uid": 3,
|
||||
"group": "devices",
|
||||
"properties": {
|
||||
"control": {
|
||||
"method": "ir",
|
||||
"irFile": "Apple_AppleTV_4th_Gen_Essentials.ir",
|
||||
"controlPortDevKey": "processor",
|
||||
"controlPortNumber": "1"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Bridge Join Map IR Driver Bridging
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "1",
|
||||
"name": "Apple TV",
|
||||
"key": "appleTv-1",
|
||||
"type": "genericIrController",
|
||||
"uid": 3,
|
||||
"group": "devices",
|
||||
"properties": {
|
||||
"control": {
|
||||
"method": "ir",
|
||||
"irFile": "Apple_AppleTV_4th_Gen_Essentials.ir",
|
||||
"controlPortDevKey": "processor",
|
||||
"controlPortNumber": "1",
|
||||
"useBridgeJoinMap": true
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Both methods will bridge the IR signals with `Standard Command` defined in the IR file.
|
||||
|
||||
The `useBridgeJoinMap` property implements `GenericIrControllerJoinMap.cs` to standardized IR driver `Standard Command` signal joins. This allows users to swap IR drivers that implement `Standard Command` while bridging IR signals consistently between drivers. For example, when `useBridgeJoinMap` is present, channel up will be mapped to join-22 + device `joinstart` for any IR driver that has the signal marked as `Standard Command`.
|
||||
|
||||
|
||||
## GenericIrControllerJoinMap (Example)
|
||||
|
||||
### Digitals
|
||||
|
||||
| Join Number | Join Span | Description | Type | Capabilities |
|
||||
| ----------- | --------- | ----------- | ------------------- | ------------ |
|
||||
| 1 | 1 | PLAY | Digital | FromSIMPL |
|
||||
| 2 | 1 | STOP | Digital | FromSIMPL |
|
||||
| 3 | 1 | PAUSE | Digital | FromSIMPL |
|
||||
| 4 | 1 | FSCAN | Digital | FromSIMPL |
|
||||
| 5 | 1 | RSCAN | Digital | FromSIMPL |
|
||||
| 9 | 1 | POWER | Digital | FromSIMPL |
|
||||
| 10 | 1 | 0 | Digital | FromSIMPL |
|
||||
| 11 | 1 | 1 | Digital | FromSIMPL |
|
||||
| 12 | 1 | 2 | Digital | FromSIMPL |
|
||||
| 13 | 1 | 3 | Digital | FromSIMPL |
|
||||
| 14 | 1 | 4 | Digital | FromSIMPL |
|
||||
| 15 | 1 | 5 | Digital | FromSIMPL |
|
||||
| 16 | 1 | 6 | Digital | FromSIMPL |
|
||||
| 17 | 1 | 7 | Digital | FromSIMPL |
|
||||
| 18 | 1 | 8 | Digital | FromSIMPL |
|
||||
| 19 | 1 | 9 | Digital | FromSIMPL |
|
||||
| 21 | 1 | ENTER | Digital | FromSIMPL |
|
||||
| 22 | 1 | CH+ | Digital | FromSIMPL |
|
||||
| 23 | 1 | CH- | Digital | FromSIMPL |
|
||||
| 27 | 1 | POWER_ON | Digital | FromSIMPL |
|
||||
| 28 | 1 | POWER_OFF | Digital | FromSIMPL |
|
||||
| 30 | 1 | LAST | Digital | FromSIMPL |
|
||||
| 41 | 1 | BACK | Digital | FromSIMPL |
|
||||
| 42 | 1 | GUIDE | Digital | FromSIMPL |
|
||||
| 43 | 1 | INFO | Digital | FromSIMPL |
|
||||
| 44 | 1 | MENU | Digital | FromSIMPL |
|
||||
| 45 | 1 | UP_ARROW | Digital | FromSIMPL |
|
||||
| 46 | 1 | DN_ARROW | Digital | FromSIMPL |
|
||||
| 47 | 1 | LEFT_ARROW | Digital | FromSIMPL |
|
||||
| 48 | 1 | RIGHT_ARROW | Digital | FromSIMPL |
|
||||
| 49 | 1 | SELECT | Digital | FromSIMPL |
|
||||
| 54 | 1 | PAGE_UP | Digital | FromSIMPL |
|
||||
| 55 | 1 | PAGE_DOWN | Digital | FromSIMPL |
|
||||
| 61 | 1 | A | Digital | FromSIMPL |
|
||||
| 62 | 1 | B | Digital | FromSIMPL |
|
||||
| 63 | 1 | C | Digital | FromSIMPL |
|
||||
| 64 | 1 | D | Digital | FromSIMPL |
|
||||
|
||||
### Analogs
|
||||
|
||||
| Join Number | Join Span | Description | Type | Capabilities |
|
||||
| ----------- | --------- | ----------- | ------------------- | ------------ |
|
||||
|
||||
### Serials
|
||||
|
||||
| Join Number | Join Span | Description | Type | Capabilities |
|
||||
| ----------- | --------- | ----------- | ------------------- | ------------ |
|
||||
|
||||
|
||||
155
docs/docs/JoinMaps.md
Normal file
@@ -0,0 +1,155 @@
|
||||
# What is a Join Map?
|
||||
|
||||
A join map is a class that defines the list of joins accessible to an `EssentialsBridgeableDevice` across an EISC Bridge.
|
||||
|
||||
## Why use a Join Map?
|
||||
|
||||
A join map is necessary to bridge joins across an EISC bridge from Essentials to a SIMPL program. Join maps can be overriden in a configuration as necessary, but by default each device has a standard join map that publishes joins as a function of the joinOffset property of the device within a given Essentials Bridge. Join maps are reusable and extensible. Several join maps for standard device types already exist within Essentials, and those can be utilized for plugin creation without creation of a new join map. Utilizing standard join maps allows you to create a consistent API between device types that allows switching of devices via config without any new SIMPL or SIMPL#Pro code being written.
|
||||
|
||||
## How Join maps Work
|
||||
|
||||
Whenever you instantiate a device and link that device to an EISC bridge utilizing your configuration in Essentials, the method `LinkToApi()` is called. This method matches various methods, feedbacks, and properties to joins on the EISC bridge in order to create a consistent API for communication to SIMPL.
|
||||
|
||||
Whenever `LinkToApi()` is called, it creates a new instance of the device's joinMap class on demand. The constructor of that joinMap creates an object containing the join metadata, adds any configured join offsets to the standard join map, and adds all associated joins to a global join list that can be easily referenced from the command line.
|
||||
|
||||
There are several components for each join within a join map.
|
||||
|
||||
```cs
|
||||
[JoinName("Online")]
|
||||
public JoinDataComplete Online = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Reports Online Status", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital });
|
||||
```
|
||||
|
||||
### Attribute
|
||||
|
||||
```cs
|
||||
[JoinName("Online")]
|
||||
```
|
||||
|
||||
If the attribute is present, the join data is added to the publically available list `Joins`. This can be used to "prebuild" functionality within a join map that you may not yet need. If you do not add this attribute (or simply comment it out), the join data will not be displayed whenever join data is printed using the `getjoinmap` command.
|
||||
|
||||
### JoinData
|
||||
|
||||
```cs
|
||||
JoinData() { JoinNumber = 1, JoinSpan = 1 };
|
||||
```
|
||||
|
||||
`JoinData` contains the pertinent information for the bridge. JoinData contains the information that the bridge utilizes to create each associated connection from the EISC to the methods, properties, and feedbacks associated with a device.
|
||||
|
||||
`JoinNumber` is the 1-based index of the join you wish to tie to a given method, property, or feedback. This join, combined with the offset defined in the brdige's configuration for a device, will give you the SIMPL EISC join linked to the given data.
|
||||
|
||||
`JoinSpan` determines a number of associated joins. Perhaps you have a list of Camera Presets, or a list of inputs. You can create one single join map entry and define the span of all associated join types.
|
||||
|
||||
A `JoinData` object with a `JoinNumber` of 11 and a `JoinSpan` of 10 and a `joinOffset` of 0 is associated with joins 11-20 on the EISC.
|
||||
|
||||
### JoinMetadata
|
||||
|
||||
```cs
|
||||
JoinMetadata() { Label = "Reports Online Status", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }
|
||||
```
|
||||
|
||||
`JoinMetadata` provides the data reported when the `getjoinmap` command is used.
|
||||
|
||||
`Label` is the description of the what this join does.
|
||||
|
||||
`JoinCapabilities` is represented by an enum defining the direction that the data is flowing for this join. Appropriate values are:
|
||||
|
||||
```cs
|
||||
public enum eJoinCapabilities
|
||||
{
|
||||
None = 0,
|
||||
ToSIMPL = 1,
|
||||
FromSIMPL = 2,
|
||||
ToFromSIMPL = ToSIMPL | FromSIMPL
|
||||
}
|
||||
```
|
||||
|
||||
`JoinType` is represented by an enum defining the data type in SIMPL. Appropriate values are:
|
||||
|
||||
```cs
|
||||
public enum eJoinType
|
||||
{
|
||||
None = 0,
|
||||
Digital = 1,
|
||||
Analog = 2,
|
||||
Serial = 4,
|
||||
DigitalAnalog = Digital | Analog,
|
||||
DigitalSerial = Digital | Serial,
|
||||
AnalogSerial = Analog | Serial,
|
||||
DigitalAnalogSerial = Digital | Analog | Serial
|
||||
}
|
||||
```
|
||||
|
||||
### JoinDataComplete
|
||||
|
||||
```chsarp
|
||||
JoinDataComplete(JoinData data, JoinMetadata metadata);
|
||||
```
|
||||
|
||||
`JoinDataComplete` represents the `JoinData` and the `JoinMetadata` in a single object. You can call an instance of `JoinDataComplete` to report any information about a specific join. In a device bridge, you would utilize the `JoinNumber` property to link a feature from the plugin to the EISC API.
|
||||
|
||||
### Example Join Map
|
||||
|
||||
This is the join map for `IBasicCommunication` Devices
|
||||
|
||||
```cs
|
||||
namespace PepperDash.Essentials.Core.Bridges
|
||||
{
|
||||
public class IBasicCommunicationJoinMap : JoinMapBaseAdvanced
|
||||
{
|
||||
[JoinName("TextReceived")]
|
||||
public JoinDataComplete TextReceived = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Text Received From Remote Device", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial });
|
||||
|
||||
[JoinName("SendText")]
|
||||
public JoinDataComplete SendText = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Text Sent To Remote Device", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial });
|
||||
|
||||
[JoinName("SetPortConfig")]
|
||||
public JoinDataComplete SetPortConfig = new JoinDataComplete(new JoinData() { JoinNumber = 2, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Set Port Config", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial });
|
||||
|
||||
[JoinName("Connect")]
|
||||
public JoinDataComplete Connect = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Connect", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital });
|
||||
|
||||
[JoinName("Connected")]
|
||||
public JoinDataComplete Connected = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Connected", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital });
|
||||
|
||||
[JoinName("Status")]
|
||||
public JoinDataComplete Status = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Status", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog });
|
||||
|
||||
|
||||
public IBasicCommunicationJoinMap(uint joinStart)
|
||||
: base(joinStart, typeof(IBasicCommunicationJoinMap))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Returning Data on Join Maps
|
||||
|
||||
A mechanism for printing join maps to console from a running Essentials program is built in to Essentials.
|
||||
|
||||
Given a single Generic Communication device with a `joinStart` of 11 and a key of "Com-1", defined on a bridge with a key of "Bridge-1" and IPID of A0, the command `getjoinmap Bridge-1 Com-1` would return:
|
||||
|
||||
```sh
|
||||
Join Map for device 'Com-1' on EISC 'Bridge-1':
|
||||
GenericComm:
|
||||
|
||||
Digitals:
|
||||
Found 2 Digital Joins
|
||||
Join Number: '11' | JoinSpan: '1' | Label : 'Connect' | Type: 'Digital' | Capabilities : 'FromSimpl'
|
||||
Join Number: '11' | JoinSpan: '1' | Label : 'Connected' | Type: 'Digital' | Capabilities : 'ToSimpl'
|
||||
Analogs:
|
||||
Found 1 Analog Joins
|
||||
Join Number: '11' | JoinSpan: '1' | Label : 'Status' | Type: 'Analog' | Capabilities : 'ToSimpl'
|
||||
Serials:
|
||||
Found 3 Serial Joins
|
||||
Join Number: '11' | JoinSpan: '1' | Label : 'Text Received From Remote Device' | Type: 'Serial' | Capabilities : 'FromSimpl'
|
||||
Join Number: '11' | JoinSpan: '1' | Label : 'Text Sent To Remote Device' | Type: 'Serial' | Capabilities : 'ToSimpl'
|
||||
Join Number: '12' | JoinSpan: '1' | Label : 'Set Port Config' | Type: 'Serial' | Capabilities : 'FromSimpl'
|
||||
```
|
||||
74
docs/docs/Plugins-Deprecated.md
Normal file
@@ -0,0 +1,74 @@
|
||||
# Deprecated
|
||||
|
||||
**Note : this entry is out of date - please see [Plugins](~/docs/Plugins.md)**
|
||||
|
||||
## What are Essentials Plugins?
|
||||
|
||||
Plugins are SIMPL# Pro libraries that reference the Essentials Framework and can be loaded into an Essentials Application at runtime to extend functionality beyond what the Essentials Framework provides on its own.
|
||||
|
||||
## Why Use Plugins?
|
||||
|
||||
Plugins are a way to extend or add new functionality to the Essentials Application without having to modify the actual Framework. In most cases, a plugin can be written to support a new device or behavior. Using plugins also limits the scope of understanding needed to work within the Essentials Framework.
|
||||
|
||||
## Should I use a Plugin?
|
||||
|
||||
Essentials is meant to be a lightweight framework and an extensible basis for development. While some devices are included in the framework, mostly for the purposes of providing examples and developing and prototyping new device types, the bulk of new development is intended to take place in Plugins. Once a plugin adds new functionality that may be of benefit if shared across multiple plugins, it may make sense to port that common logic (base classes and/or interfaces) back into the framework to make it available to others. The thrust of future Essentials development is targeted towards building a library of plugins.
|
||||
|
||||
## How do Plugins Work?
|
||||
|
||||
One or more plugins can be loaded to the /user/ProgramX/plugins as .dlls or .cplz packages. When the Essentials Application starts, it looks for any .cplz files, unzips them and then iterates any .dll assemblies in that folder and loads them. Once the plugin assemblies are loaded the Essentials Application will then attempt to load a configuration file and construct items as defined in the file. Those items can be defined in either the Essentials Framework or in any of the loaded plugin assemblies.
|
||||
|
||||

|
||||
|
||||
## What Must be Implemented in a Plugin for it to Work?
|
||||
|
||||
All plugin assemblies must contain a static method called LoadPlugin():
|
||||
|
||||
```cs
|
||||
public class SomeDevice : Device , IBridge //IBridge only needs to be implemented if using a bridge
|
||||
{
|
||||
// This string is used to define the minimum version of the
|
||||
// Essentials Framework required for this plugin
|
||||
public static string MinimumEssentialsFrameworkVersion = "1.4.23";
|
||||
|
||||
// This method gets called by the Essentials Framework when the application starts.
|
||||
// It is intended to be used to load the new Device type(s) specified in the plugin
|
||||
public static void LoadPlugin()
|
||||
{
|
||||
DeviceFactory.AddFactoryForType("typeName", FactoryMethod);
|
||||
// typeName should be the unique string that identifies the type of device to build,
|
||||
// FactoryMethod represents the method that takes a DevicConfig object as and argument
|
||||
// and returns an instance of the desired device type
|
||||
}
|
||||
|
||||
// This is a factory method to construct a device and return it to be
|
||||
// added to the DeviceManager
|
||||
public static Device FactoryMethod(DeviceConfig dc)
|
||||
{
|
||||
return new SomeDevice(dc.key, dc.name, dc);
|
||||
}
|
||||
|
||||
#region IBridge
|
||||
// This method is called by an EiscApi bridge instance and should call an extension method
|
||||
// defined in your plugin. Required for implementing IBridge
|
||||
public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey)
|
||||
{
|
||||
this.LinkToApiExt(trilist, joinStart, joinMapKey);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
```
|
||||
|
||||
## SIMPL Bridging
|
||||
|
||||
Optionally, if your plugin device needs to be able to bridge to a SIMPL program over EISC, and there isn't already an existing bridge class in the Essentials Framework, you can write a new bridge class in your plugin. However, in order for the Essentials Application to be able to us that new bridge, the bridge must implement the IBridge interface with the required LinkToApi() Extension method.
|
||||
|
||||
Often though, you may find that a bridge class already exists in the Essentials Framework that you can leverage. For example, if you were writing a plugin to support a new display model that isn't already in the Essentials Framework, you would define a class in your plugin that inherits from PepperDash.Essentials.Core.DisplayBase. If you're only implementing the standard display control functions such as power/input/volume control, then the existing bridge class `DisplayControllerBridge` can be used. If you needed to add additional functions to the bridge, then you would need to write your own bridge in the plugin.
|
||||
|
||||
For additional info see the [SIMPL-Bridging article](~/docs/SIMPL-Bridging.md).
|
||||
|
||||
## Template Essentials Plugin Repository
|
||||
|
||||
Fork this repository when starting a new plugin. The template repository uses the essentials-builds repository as a submodule. This allows the plugin to reference a specific build version of Essentials. You must make sure that you checkout the correct build of the Essentials-Builds repo that contains any dependencies that your plugin may rely on.
|
||||
|
||||
[Essentials Plugin Template Repository](https://github.com/PepperDash/EssentialsPluginTemplate)
|
||||
131
docs/docs/Plugins.md
Normal file
@@ -0,0 +1,131 @@
|
||||
# What are Essentials Plugins?
|
||||
|
||||
**Note : this entry updates a deprecated method - for information related to that deprecated method, see [Plugins - Deprecated](~/docs/Plugins-Deprecated.md)**
|
||||
|
||||
***
|
||||
* [YouTube Video - Loading Plugins in PepperDash Essentials](https://youtu.be/NA64iyNNAgE)
|
||||
* [YouTube Video - Build Your Own Plugin, Part 1](https://youtu.be/m2phC8g3Kfk)
|
||||
* [YouTube Video - Build Your Own Plugin, Part 2](https://youtu.be/2_PrWRk6Gy0)
|
||||
***
|
||||
|
||||
Plugins are SIMPL# Pro libraries that reference the Essentials Framework and can be loaded into an Essentials Application at runtime to extend functionality beyond what the Essentials Framework provides on its own.
|
||||
|
||||
## Why Use Plugins?
|
||||
|
||||
Plugins are a way to extend or add new functionality to the Essentials Application without having to modify the actual Framework. In most cases, a plugin can be written to support a new device or behavior. Using plugins also limits the scope of understanding needed to work within the Essentials Framework.
|
||||
|
||||
## Should I use a Plugin?
|
||||
|
||||
Essentials is meant to be a lightweight framework and an extensible basis for development. While some devices are included in the framework, mostly for the purposes of providing examples and developing and prototyping new device types, the bulk of new development is intended to take place in Plugins. Once a plugin adds new functionality that may be of benefit if shared across multiple plugins, it may make sense to port that common logic (base classes and/or interfaces) back into the framework to make it available to others. The thrust of future Essentials development is targeted towards building a library of plugins.
|
||||
|
||||
## How do Plugins Work?
|
||||
|
||||
One or more plugins can be loaded to the /user/ProgramX/plugins as .dlls or .cplz packages. When the Essentials Application starts, it looks for any .cplz files, unzips them and then iterates any .dll assemblies in that folder and loads them. Once the plugin assemblies are loaded the Essentials Application will then attempt to load a configuration file and construct items as defined in the file. Those items can be defined in either the Essentials Framework or in any of the loaded plugin assemblies.
|
||||
|
||||

|
||||
|
||||
## What Must be Implemented in a Plugin for it to Work?
|
||||
|
||||
All plugin assemblies must contain a class which inherits from ```EssentialsPluginDeviceFactory<T>```, where ```<T>``` is a class which inherits from ```PepperDash.Essentials.Core.EssentialsDevice```
|
||||
|
||||
Within this class, we will define some metadata for the plugin and define which constructor to use
|
||||
for instantiating each class as defined by type.
|
||||
|
||||
Note that multiple types can be loaded from the same plugin.
|
||||
|
||||
```cs
|
||||
using System;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using PepperDash.Core;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MyPlugin
|
||||
{
|
||||
public class SomeDeviceFactory : EssentialsPluginDeviceFactory<SomeDevice>
|
||||
{
|
||||
// This method defines metadata for the devices in the plugin
|
||||
public SomeDeviceFactory()
|
||||
{
|
||||
// This string is used to define the minimum version of the
|
||||
// Essentials Framework required for this plugin
|
||||
MinimumEssentialsFrameworkVersion = "1.5.0";
|
||||
|
||||
// This string is used to define all valid type names for
|
||||
// this plugin. This string is case insensitive
|
||||
TypeNames = new List<string> { "SomeDevice" , "ThisNewDevice" };
|
||||
}
|
||||
|
||||
// This method instantiates new devices for the defined type
|
||||
// within the plugin
|
||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||
{
|
||||
// Deserialize the json properties for the loaded type to a new object
|
||||
var props = dc.Properties.ToObject<SomeDeviceProperties>();
|
||||
|
||||
// Return a newly instantiated device using the desired constructor
|
||||
// If no valid property data exists, return null with console print
|
||||
// describing the failure.
|
||||
if (props == null)
|
||||
{
|
||||
Debug.Console(0, "No valid property data for 'SomeDevice' - Verify Configuration.");
|
||||
Debug.Console(0, dc.Properties.ToString());
|
||||
return null;
|
||||
}
|
||||
return new SomeDevice(dc.Key, dc.Name, props);
|
||||
}
|
||||
}
|
||||
|
||||
public class OtherDeviceFactory : EssentialsPluginDeviceFactory<OtherDevice>
|
||||
{
|
||||
// This method defines metadata for the devices in the plugin
|
||||
public OtherDeviceFactory()
|
||||
{
|
||||
// This string is used to define the minimum version of the
|
||||
// Essentials Framework required for this plugin
|
||||
MinimumEssentialsFrameworkVersion = "1.5.0";
|
||||
|
||||
// This string is used to define all valid type names for
|
||||
// this plugin. This string is case insensitive
|
||||
TypeNames = new List<string> { "OtherDevice", "ThisOtherDevice" };
|
||||
}
|
||||
|
||||
// This method instantiates new devices for the defined type
|
||||
// within the plugin
|
||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||
{
|
||||
// Deserialize the json properties for the loaded type to a new object
|
||||
var props = dc.Properties.ToObject<OtherDeviceProperties>();
|
||||
|
||||
// Return a newly instantiated device using the desired constructor
|
||||
// If no valid property data exists, return null with console print
|
||||
// describing the failure.
|
||||
if (props == null)
|
||||
{
|
||||
Debug.Console(0, "No valid property data for 'OtherDevice' - Verify Configuration.");
|
||||
Debug.Console(0, dc.Properties.ToString());
|
||||
return null;
|
||||
}
|
||||
return new OtherDevice(dc.Key, dc.Name, props);
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## SIMPL Bridging
|
||||
|
||||
Optionally, if your plugin device needs to be able to bridge to a SIMPL program over EISC, and there isn't already an existing bridge class in the Essentials Framework, you can write a new bridge class in your plugin. However, in order for the Essentials Application to be able to us that new bridge, the bridge must implement the ```IBridgeAdvanced``` interface with the required ```LinkToApi()``` Extension method.
|
||||
|
||||
If you are writing code for a bridgeable device, you should be inheriting from ```EssentialsBridgeableDevice```, which inherits from the already-required ```EssentialsDevice``` and implements ```IBridgeAdvanced```.
|
||||
|
||||
Often though, you may find that a bridge class already exists in the Essentials Framework that you can leverage. For example, if you were writing a plugin to support a new display model that isn't already in the Essentials Framework, you would define a class in your plugin that inherits from PepperDash.Essentials.Core.DisplayBase. If you're only implementing the standard display control functions such as power/input/volume control, then the existing bridge class `DisplayControllerBridge` can be used. If you needed to add additional functions to the bridge, then you would need to write your own bridge in the plugin.
|
||||
|
||||
For additional info see the [SIMPL-Bridging article](~/docs/SIMPL-Bridging.md).
|
||||
|
||||
## Template Essentials Plugin Repository
|
||||
|
||||
Fork this repository when starting a new plugin. The template repository uses the essentials-builds repository as a submodule. This allows the plugin to reference a specific build version of Essentials. You must make sure that you checkout the correct build of the Essentials-Builds repo that contains any dependencies that your plugin may rely on.
|
||||
|
||||
[Essentials Plugin Template Repository](https://github.com/PepperDash/EssentialsPluginTemplate)
|
||||
164
docs/docs/RelayOutput.md
Normal file
@@ -0,0 +1,164 @@
|
||||
# RelayOutput
|
||||
|
||||
Relays can be bridged directly to SIMPL from any device that is both inlcuded within essentials and has a relay.
|
||||
|
||||
Consider the following example.
|
||||
|
||||
```JSON
|
||||
{
|
||||
"template": {
|
||||
"roomInfo": [
|
||||
{}
|
||||
],
|
||||
"devices": [
|
||||
{
|
||||
"key": "processor",
|
||||
"uid": 0,
|
||||
"type": "pro3",
|
||||
"name": "pro3",
|
||||
"group": "processor",
|
||||
"supportedConfigModes": [
|
||||
"compliance",
|
||||
"essentials"
|
||||
],
|
||||
"supportedSystemTypes": [
|
||||
"hudType",
|
||||
"presType",
|
||||
"vtcType",
|
||||
"custom"
|
||||
],
|
||||
"supportsCompliance": true,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"key": "Relay-1",
|
||||
"uid": 3,
|
||||
"name": "Relay 1",
|
||||
"group": "api",
|
||||
"type": "relayOutput",
|
||||
"properties": {
|
||||
"portDeviceKey" : "processor",
|
||||
"portNumber" : 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "Relay-2",
|
||||
"uid": 3,
|
||||
"name": "Relay 2",
|
||||
"group": "api",
|
||||
"type": "relayOutput",
|
||||
"properties": {
|
||||
"portDeviceKey" : "processor",
|
||||
"portNumber" : 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "deviceBridge",
|
||||
"uid": 4,
|
||||
"name": "BridgeToDevices",
|
||||
"group": "api",
|
||||
"type": "eiscapiadv",
|
||||
"properties": {
|
||||
"control": {
|
||||
"tcpSshProperties": {
|
||||
"address": "127.0.0.2",
|
||||
"port": 0
|
||||
},
|
||||
"ipid": "03",
|
||||
"method": "ipidTcp"
|
||||
},
|
||||
"devices": [
|
||||
{
|
||||
"deviceKey": "Relay-1",
|
||||
"joinStart": 1
|
||||
},
|
||||
{
|
||||
"deviceKey": "Relay-2",
|
||||
"joinStart": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## RelayOutput Configuration Explanation
|
||||
|
||||
This configuration is meant for a Pro3 device, and instantiates two relay ports and links them to an eisc bridge to another processor slot on ipid 3. Let's break down the ```Relay-1``` device.
|
||||
|
||||
```JSON
|
||||
{
|
||||
"key": "Relay-1",
|
||||
"uid": 3,
|
||||
"name": "Relay 1",
|
||||
"group": "api",
|
||||
"type": "relayOutput",
|
||||
"properties": {
|
||||
"portDeviceKey" : "processor",
|
||||
"portNumber" : 1
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**```Key```**
|
||||
|
||||
The Key is a unique identifier for essentials. The key allows the device to be linked to other devices also defined by key. All Keys MUST be unique, as every device is added to a globally-accessible dictionary. If you have accidentally utilized the same key twice, Essentials will notify you during startup that there is an issue with the device.
|
||||
|
||||
**```Uid```**
|
||||
|
||||
The Uid is reserved for use with an PepperDash internal config generation tool, and is not useful to Essentials in any way.
|
||||
|
||||
**```Name```**
|
||||
|
||||
The Name a friendly name assigned to the device. Many devices pass this data to the bridge for utilization in SIMPL.
|
||||
|
||||
**```Group```**
|
||||
|
||||
Utilized in certain Essentials devices. In this case, the value is unimportant.
|
||||
|
||||
**```Type```**
|
||||
|
||||
The Type is the identifier for a specific type of device in Essentials. A list of all valid types can be reported by using the consolecommand ```gettypes``` in Essentials. In this case, the type is ```relayOutput```. This type is valid for any instance of a Relay Output.
|
||||
|
||||
**```Properties```**
|
||||
|
||||
These are the properties essential to the instantiation of the identified type.
|
||||
|
||||
### Properties
|
||||
|
||||
There are two properties relevant to the instantiation of a relay device.
|
||||
|
||||
**```portDeviceKey```**
|
||||
|
||||
This property maps to the ```key``` of the device upon which the relay resides.
|
||||
|
||||
**```portNumber```**
|
||||
|
||||
This property maps to the number of the relay on the device you have mapped the relay device to. Even if the device has only a single relay, ```portNumber``` must be defined.
|
||||
|
||||
### The JoinMap
|
||||
|
||||
The joinmap for a ```relayOutput``` device is comprised of a single digital join.
|
||||
|
||||
```cs
|
||||
namespace PepperDash.Essentials.Core.Bridges
|
||||
{
|
||||
public class GenericRelayControllerJoinMap : JoinMapBaseAdvanced
|
||||
{
|
||||
|
||||
[JoinName("Relay")]
|
||||
public JoinDataComplete Relay = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Device Relay State Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital });
|
||||
|
||||
|
||||
public GenericRelayControllerJoinMap(uint joinStart)
|
||||
: base(joinStart, typeof(GenericRelayControllerJoinMap))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```Relay``` is a digital join that represents both the trigger and the feedback for the associated relay device. Its join is set to 1.
|
||||
477
docs/docs/SIMPL-Bridging-Deprecated.md
Normal file
@@ -0,0 +1,477 @@
|
||||
# Deprecated
|
||||
|
||||
**Note : this entry is out of date - please see [SIMPL Windows Bridging](~/docs/SIMPL-Bridging.md)**
|
||||
|
||||
## SIMPL Windows Bridging - Deprecated
|
||||
|
||||
Essentials allows for devices defined within the SIMPL# Pro application to be bridged to a SIMPL Windows application over Ethernet Intersystem Communication (EISC). This allows a SIMPL Windows program to take advantage of some of the features of the SIMPL# Pro environment, without requiring the entire application to be written in C#.
|
||||
|
||||
Some of the main advantages are:
|
||||
|
||||
1. The ability to instantiate devices from configuration.
|
||||
1. The ability to leverage C# concepts to handle data intensive tasks (Serialization/Deserialization of JSON/XML, cyrptography, etc.).
|
||||
1. The ability to reuse the same compiled SIMPL Windows program (regardless of target processor type) by offloading all the variables that may be room or hardware specific to Essentials.
|
||||
1. The ability to handle multiple communciation types generically without changing the SIMPL Program (TCP/UDP/SSH/HTTP/HTTPS/CEC, etc.)
|
||||
1. Much faster development cycle
|
||||
1. Reduced processor overhead
|
||||
1. Ability to easily share devices defined in Essentials between multiple other programs
|
||||
|
||||
## Implementation
|
||||
|
||||
Bridges are devices that are defined within the devices array in the config file. They are unique devices with a specialized purpose; to act as a bridge between Essentials Devices and applications programmed traditionally in Simpl Windows. This is accomplished by instantiating a Three Series Intersystem Communication symbol within the bridge device, and linking its Boolean/Ushort/String inputs and outputs to actions on one or multiple Essentials device(s). The definition for which joins map to which actions is defined within the device to be bridged to in a class that derives from JoinMapBase.
|
||||
|
||||
Let's consider the following Essentials Configuration:
|
||||
|
||||
```JSON
|
||||
{
|
||||
"template": {
|
||||
"roomInfo": [
|
||||
{}
|
||||
],
|
||||
"devices": [
|
||||
{
|
||||
"key": "processor",
|
||||
"uid": 1,
|
||||
"type": "pro3",
|
||||
"name": "PRO3 w/o cards",
|
||||
"group": "processor",
|
||||
"supportedConfigModes": [
|
||||
"essentials"
|
||||
],
|
||||
"supportedSystemTypes": [
|
||||
"hudType",
|
||||
"presType",
|
||||
"vtcType",
|
||||
"custom"
|
||||
],
|
||||
"supportsCompliance": true,
|
||||
"properties": {
|
||||
"numberOfComPorts": 6,
|
||||
"numberOfIrPorts": 8,
|
||||
"numberOfRelays": 8,
|
||||
"numberOfDIOPorts": 8
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "panasonicDisplay01",
|
||||
"type": "PanasonicThefDisplay",
|
||||
"name": "Main Display",
|
||||
"group": "displays",
|
||||
"uid": 2,
|
||||
"properties": {
|
||||
"id": "01",
|
||||
"inputNumber": 1,
|
||||
"outputNumber": 1,
|
||||
"control": {
|
||||
"comParams": {
|
||||
"hardwareHandshake": "None",
|
||||
"parity": "None",
|
||||
"protocol": "RS232",
|
||||
"baudRate": 9600,
|
||||
"dataBits": 8,
|
||||
"softwareHandshake": "None",
|
||||
"stopBits": 1
|
||||
},
|
||||
"controlPortNumber": 1,
|
||||
"controlPortDevKey": "processor",
|
||||
"method": "com"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "vtcComPort",
|
||||
"uid": 3,
|
||||
"name": "VTC Coms",
|
||||
"group": "comm",
|
||||
"type": "genericComm",
|
||||
"properties": {
|
||||
"control": {
|
||||
"comParams": {
|
||||
"hardwareHandshake": "None",
|
||||
"parity": "None",
|
||||
"protocol": "RS232",
|
||||
"baudRate": 38400,
|
||||
"dataBits": 8,
|
||||
"softwareHandshake": "None",
|
||||
"stopBits": 1
|
||||
},
|
||||
"controlPortNumber": 2,
|
||||
"controlPortDevKey": "processor",
|
||||
"method": "com"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "deviceBridge",
|
||||
"uid": 4,
|
||||
"name": "BridgeToDevices",
|
||||
"group": "api",
|
||||
"type": "eiscApi",
|
||||
"properties": {
|
||||
"control": {
|
||||
"tcpSshProperties": {
|
||||
"address": "127.0.0.2",
|
||||
"port": 0
|
||||
},
|
||||
"ipid": "03",
|
||||
"method": "ipidTcp"
|
||||
},
|
||||
"devices": [
|
||||
{
|
||||
"deviceKey": "panasonicDisplay01",
|
||||
"joinStart": 1
|
||||
},
|
||||
{
|
||||
"deviceKey": "vtcComPort",
|
||||
"joinStart": 51
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
We have four Essentials Devices configured:
|
||||
|
||||
1. Pro3 with a Key of "processor"
|
||||
|
||||
1. Panasonic Display with a Key of "panasonicDisplay01"
|
||||
|
||||
1. Com port with a Key of "vtcComPort"
|
||||
|
||||
1. Bridge with a Key of "deviceBridge"
|
||||
|
||||
We want to have access to the com port for VTC Control from Simpl Windows and we want to control the display from Simpl Windows. To accomplish this, we have created a bridge device and added the devices to be bridged to the "devices" array on the bridge. As you can see we define the device key and the join start, which will determine which joins we will use on the resulting EISC to interact with the devices. In the Bridge control properties we defined ipid 03, and we will need a corresponding Ethernet System Intercommunication in the Simpl Windows program at ipid 03.
|
||||
|
||||
Now that our devices have been built, we can refer to the device join maps to see which joins correspond to which actions.
|
||||
|
||||
See below:
|
||||
|
||||
```cs
|
||||
namespace PepperDash.Essentials.Bridges
|
||||
{
|
||||
public class DisplayControllerJoinMap : JoinMapBase
|
||||
{
|
||||
#region Digitals
|
||||
/// <summary>
|
||||
/// Turns the display off and reports power off feedback
|
||||
/// </summary>
|
||||
public uint PowerOff { get; set; }
|
||||
/// <summary>
|
||||
/// Turns the display on and repots power on feedback
|
||||
/// </summary>
|
||||
public uint PowerOn { get; set; }
|
||||
/// <summary>
|
||||
/// Indicates that the display device supports two way communication when high
|
||||
/// </summary>
|
||||
public uint IsTwoWayDisplay { get; set; }
|
||||
/// <summary>
|
||||
/// Increments the volume while high
|
||||
/// </summary>
|
||||
public uint VolumeUp { get; set; }
|
||||
/// <summary>
|
||||
/// Decrements teh volume while high
|
||||
/// </summary>
|
||||
public uint VolumeDown { get; set; }
|
||||
/// <summary>
|
||||
/// Toggles the mute state. Feedback is high when volume is muted
|
||||
/// </summary>
|
||||
public uint VolumeMute { get; set; }
|
||||
/// <summary>
|
||||
/// Range of digital joins to select inputs and report current input as feedback
|
||||
/// </summary>
|
||||
public uint InputSelectOffset { get; set; }
|
||||
/// <summary>
|
||||
/// Range of digital joins to report visibility for input buttons
|
||||
/// </summary>
|
||||
public uint ButtonVisibilityOffset { get; set; }
|
||||
/// <summary>
|
||||
/// High if the device is online
|
||||
/// </summary>
|
||||
public uint IsOnline { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Analogs
|
||||
/// <summary>
|
||||
/// Analog join to set the input and report current input as feedback
|
||||
/// </summary>
|
||||
public uint InputSelect { get; set; }
|
||||
/// <summary>
|
||||
/// Sets the volume level and reports the current level as feedback
|
||||
/// </summary>
|
||||
public uint VolumeLevel { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Serials
|
||||
/// <summary>
|
||||
/// Reports the name of the display as defined in config as feedback
|
||||
/// </summary>
|
||||
public uint Name { get; set; }
|
||||
/// <summary>
|
||||
/// Range of serial joins that reports the names of the inputs as feedback
|
||||
/// </summary>
|
||||
public uint InputNamesOffset { get; set; }
|
||||
#endregion
|
||||
|
||||
public DisplayControllerJoinMap()
|
||||
{
|
||||
// Digital
|
||||
IsOnline = 50;
|
||||
PowerOff = 1;
|
||||
PowerOn = 2;
|
||||
IsTwoWayDisplay = 3;
|
||||
VolumeUp = 5;
|
||||
VolumeDown = 6;
|
||||
VolumeMute = 7;
|
||||
|
||||
ButtonVisibilityOffset = 40;
|
||||
InputSelectOffset = 10;
|
||||
|
||||
// Analog
|
||||
InputSelect = 11;
|
||||
VolumeLevel = 5;
|
||||
|
||||
// Serial
|
||||
Name = 1;
|
||||
InputNamesOffset = 10;
|
||||
}
|
||||
|
||||
public override void OffsetJoinNumbers(uint joinStart)
|
||||
{
|
||||
var joinOffset = joinStart - 1;
|
||||
|
||||
IsOnline = IsOnline + joinOffset;
|
||||
PowerOff = PowerOff + joinOffset;
|
||||
PowerOn = PowerOn + joinOffset;
|
||||
IsTwoWayDisplay = IsTwoWayDisplay + joinOffset;
|
||||
ButtonVisibilityOffset = ButtonVisibilityOffset + joinOffset;
|
||||
Name = Name + joinOffset;
|
||||
InputNamesOffset = InputNamesOffset + joinOffset;
|
||||
InputSelectOffset = InputSelectOffset + joinOffset;
|
||||
|
||||
InputSelect = InputSelect + joinOffset;
|
||||
|
||||
VolumeUp = VolumeUp + joinOffset;
|
||||
VolumeDown = VolumeDown + joinOffset;
|
||||
VolumeMute = VolumeMute + joinOffset;
|
||||
VolumeLevel = VolumeLevel + joinOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
We know that the Panasonic Display uses the DisplayControllerJoinMap class and can see the join numbers that will give us access to functionality in the Device.
|
||||
|
||||
IsOnline = 50
|
||||
PowerOff = 1
|
||||
PowerOn = 2
|
||||
IsTwoWayDisplay = 3
|
||||
VolumeUp = 5
|
||||
VolumeDown = 6
|
||||
VolumeMute = 7
|
||||
|
||||
```cs
|
||||
namespace PepperDash.Essentials.Bridges
|
||||
{
|
||||
public class IBasicCommunicationJoinMap : JoinMapBase
|
||||
{
|
||||
#region Digitals
|
||||
/// <summary>
|
||||
/// Set High to connect, Low to disconnect
|
||||
/// </summary>
|
||||
public uint Connect { get; set; }
|
||||
/// <summary>
|
||||
/// Reports Connected State (High = Connected)
|
||||
/// </summary>
|
||||
public uint Connected { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Analogs
|
||||
/// <summary>
|
||||
/// Reports the connections status value
|
||||
/// </summary>
|
||||
public uint Status { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Serials
|
||||
/// <summary>
|
||||
/// Data back from port
|
||||
/// </summary>
|
||||
public uint TextReceived { get; set; }
|
||||
/// <summary>
|
||||
/// Sends data to the port
|
||||
/// </summary>
|
||||
public uint SendText { get; set; }
|
||||
/// <summary>
|
||||
/// Takes a JSON serialized string that sets a COM port's parameters
|
||||
/// </summary>
|
||||
public uint SetPortConfig { get; set; }
|
||||
#endregion
|
||||
|
||||
public IBasicCommunicationJoinMap()
|
||||
{
|
||||
TextReceived = 1;
|
||||
SendText = 1;
|
||||
SetPortConfig = 2;
|
||||
Connect = 1;
|
||||
Connected = 1;
|
||||
Status = 1;
|
||||
}
|
||||
|
||||
public override void OffsetJoinNumbers(uint joinStart)
|
||||
{
|
||||
var joinOffset = joinStart - 1;
|
||||
|
||||
TextReceived = TextReceived + joinOffset;
|
||||
SendText = SendText + joinOffset;
|
||||
SetPortConfig = SetPortConfig + joinOffset;
|
||||
Connect = Connect + joinOffset;
|
||||
Connected = Connected + joinOffset;
|
||||
Status = Status + joinOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
TextReceived = 1
|
||||
SendText = 1
|
||||
SetPortConfig = 2
|
||||
Connect = 1
|
||||
Connected = 1
|
||||
Status = 1
|
||||
|
||||
Considering our Bridge config, we can see that the display controls will start at join 1, and the VTC Com port will start at join 51. The result is a single EISC that allows us to interact with our Essentials devices.
|
||||
|
||||
To control diplay power from Simpl Windows, we would connect Digital Signals to joins 1 & 2 on the EISC to control Display Power On & Off.
|
||||
To utilize the com port device, we would connect Serial Signals (VTC_TX$ and VTC_RX$) to join 51 on the EISC.
|
||||
|
||||
You can refer to our [Simpl Windows Bridging Example](https://github.com/PepperDash/EssentialsSIMPLWindowsBridgeExample) for a more complex example.
|
||||
Example device config: <https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Example%20Configuration/SIMPLBridging/SIMPLBridgeExample_configurationFile.json>
|
||||
|
||||
## Notes
|
||||
|
||||
1. It is important to realize that there are no safety checks (yet) when assigning joinStarts in bridge configurations. If you were to put two devices on a bridge with overlapping joins, the most recently bridged join would overwrite previously bridged joins. For now it is on the programmer to ensure there are no conflicting join maps.
|
||||
|
||||
1. There is _no_ limit to the amount of times a device may be bridged to. You may have the same device on multiple bridges across multiple applications without problem. That being said, we recommend using common sense. Accessing a single com port for VTC control via multiple bridges may not be wise...
|
||||
|
||||
1. A bridge need not only bridge between applications on the same processor. A bridge may bridge to an application on a completely separate processor; simply define the ip address in the Bridge control properties accordingly.
|
||||
|
||||
1. For devices included in Essentials, you will be able to find defined join maps below. If you are building your own plugins, you will need to build the join map yourself. It would be beneficial to review the wiki entry on the [Feedback Class](~/docs/Feedback-Classes.md) for this.
|
||||
|
||||
1. When building plugins, we highly recommend reusing JoinMaps, as this will make code more easily interchangeable. For example; if you were to build a display plugin, we'd recommend you use/extend the existing DisplayControllerJoinMap. This way, you can swap plugins without needing any change on the Simpl Windows side. This is extremely powerful when maintaining Simpl Windows code bases for large deployments that may utilize differing equipment per room. If you can build a Simpl Windows program that interacts with established join maps, you can swap out the device via config without any change needed to Simpl Windows.
|
||||
|
||||
1. Related to item 5, you can use the same paradigm with respect to physical device communication. If you were to have a DSP device in some rooms communicating over RS232 and some via SSH, it would be trival to swap the device from a Com port to an SSH client in the Essentials Devicee Config and update the Bridge Config to brigde to the desired communication method. Again this would require no change on the Simpl Windows side as long as you maintain the same join Start in the Bridge Device Configuration.
|
||||
|
||||
## Common Use Cases
|
||||
|
||||
1. There are 10 conference rooms that all operate the same, but have hardware differences that are impossible to account for in SIMPL Windows. For example, each room might have a DM-MD8X8 chassis, but the input and output cards aren't all in the same order, or they might be different models but function the same. You can use Essentials with a unique configuration file for each hardware configuration.
|
||||
|
||||
1. You have a floor of conference rooms that all share some centralized hardware like DSP, AV Routing and a shared CEN-GWEXER gateway with multiple GLS-OIR-CSM-EX-BATT occupancy sensors. All the shared hardware can be defined in the Essentials configuration and bridged over an EISC to each program that needs access. The same device can even be exposed to multiple programs over different EISCs.
|
||||
|
||||
1. You have a SIMPL program that works for many room types, but because some rooms have different models of processors than others (CP3/CP3N/AV3/PRO3/DMPS3 variants), you have to maintain several versions of the program, compiled for each processor model to maintain access to features like the System Monitor slot. You can use Essentials running in a slot on a processor to expose the System Monitor and many other features of the processor, regardless of model. Now you only need to maintain a single SIMPL program defined for your most complex processor application (ex. PRO3)
|
||||
|
||||
## Device Type Join Maps
|
||||
|
||||
### AirMediaController
|
||||
|
||||
> supports: AM-200, AM-300
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/AirMediaControllerJoinMap.cs>
|
||||
|
||||
### AppleTvController
|
||||
|
||||
> supports: IR control of Apple TV
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/AppleTvJoinMap.cs>
|
||||
|
||||
### CameraControlBase
|
||||
|
||||
> supports: any camera that derives from CameraBase
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs>
|
||||
|
||||
### DisplayController
|
||||
|
||||
> supports: IR controlled displays, any two way display driver that derives from PepperDash.Essentials.Core.DisplayBase
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/DisplayControllerJoinMap.cs>
|
||||
|
||||
### DmChasisController
|
||||
|
||||
> supports: All DM-MD-8x8/16x16/32x32 chassis, with or w/o DM-CPU3 Card
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/DmChassisControllerJoinMap.cs>
|
||||
|
||||
### DmRmcController
|
||||
|
||||
> supports: All DM-RMC devices
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/DmRmcControllerJoinMap.cs>
|
||||
|
||||
### DmTxController
|
||||
|
||||
> supports: All Dm-Tx devices
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/DmTxControllerJoinMap.cs>
|
||||
|
||||
### DmpsAudioOutputController
|
||||
|
||||
> supports: Program, Aux1, Aux2 outputs of all DMPS3 Control Systems
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/DmpsAudioOutputControllerJoinMap.cs>
|
||||
|
||||
### DmpsRoutingController
|
||||
|
||||
> supports: Av routing for all DMPS3 Control Systems
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/DmpsRoutingControllerJoinMap.cs>
|
||||
|
||||
### GenericRelayController
|
||||
|
||||
> supports: Any relay port on a Crestron Control System or Dm Endpoint
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/GenericRelayControllerJoinMap.cs>
|
||||
|
||||
### GenericLightingJoinMap
|
||||
|
||||
> supports: Devices derived from PepperDash.Essentials.Core.Lighting.LightingBase
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/GenericLightingJoinMap.cs>
|
||||
|
||||
### GlsOccupancySensorBase
|
||||
|
||||
> supports: Any Crestron GLS-Type Occupancy sensor - single/dual type
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/GlsOccupancySensorBaseJoinMap.cs>
|
||||
|
||||
### HdMdxxxCEController
|
||||
|
||||
> supports: HD-MD-400-C-E, HD-MD-300-C-E, HD-MD-200-C-E, HD-MD-200-C-1G-E-B/W
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/HdMdxxxCEControllerJoinMap.cs>
|
||||
|
||||
### IBasicCommunication
|
||||
|
||||
> supports: Any COM Port on a Control System or Dm Endpoint device, TCP Client, SSH Client, or UDP Server
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs>
|
||||
|
||||
### IDigitalInput
|
||||
|
||||
> supports: Any Digital Input on a Control System, or DM Endpoint device
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/IDigitalInputJoinMap.cs>
|
||||
|
||||
### SystemMonitorController
|
||||
|
||||
> supports: Exposing the system monitor slot for any Control System
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/SystemMonitorJoinMap.cs>
|
||||
|
||||
## Example SIMPL Windows Program
|
||||
|
||||
We've provided an [example program](https://github.com/PepperDash/EssentialsSIMPLWindowsBridgeExample) for SIMPL Windows that works with the provided example Essentials configuration file [SIMPLBridgeExample_configurationFile.json](https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Example%20Configuration/SIMPLBridging/SIMPLBridgeExample_configurationFile.json). Load Essentials and the example SIMPL program to two slots on the same processor and you can get a better idea of how to take advantage of SIMPL Windows bridging.
|
||||
|
||||
Next: [Essentials architecture](~/docs/Arch-summary.md)
|
||||
411
docs/docs/SIMPL-Bridging-Updated.md
Normal file
@@ -0,0 +1,411 @@
|
||||
# Use with SIMPL Windows
|
||||
|
||||
***
|
||||
* [YouTube Video - SIMPL Windows in PepperDash Essentials](https://youtu.be/P2jNzsfpgJE)
|
||||
***
|
||||
|
||||
Essentials allows for devices defined within the SIMPL# Pro application to be bridged to a SIMPL Windows application over Ethernet Intersystem Communication (EISC). This allows a SIMPL Windows program to take advantage of some of the features of the SIMPL# Pro environment, without requiring the entire application to be written in C#.
|
||||
|
||||
Some of the main advantages are:
|
||||
|
||||
1. The ability to instantiate devices from configuration.
|
||||
2. The ability to leverage C# concepts to handle data intensive tasks (Serialization/Deserialization of JSON/XML, cyrptography, etc.).
|
||||
3. The ability to reuse the same compiled SIMPL Windows program (regardless of target processor type) by offloading all the variables that may be room or hardware specific to Essentials.
|
||||
4. The ability to handle multiple communciation types generically without changing the SIMPL Program (TCP/UDP/SSH/HTTP/HTTPS/CEC, etc.)
|
||||
5. Much faster development cycle
|
||||
6. Reduced processor overhead
|
||||
7. Ability to easily share devices defined in Essentials between multiple other programs
|
||||
|
||||
## Implementation
|
||||
|
||||
Bridges are devices that are defined within the devices array in the config file. They are unique devices with a specialized purpose: to act as a bridge between Essentials Devices and applications programmed traditionally in SIMPL Windows. This is accomplished by instantiating a Three Series Intersystem Communication symbol within the bridge device, and linking its Boolean/Ushort/String inputs and outputs to actions on one or multiple Essentials device(s). The definition for which joins map to which actions is defined within the device to be bridged to in a class that derives from JoinMapBase.
|
||||
|
||||
Let's consider the following Essentials Configuration:
|
||||
|
||||
```JSON
|
||||
{
|
||||
"template": {
|
||||
"roomInfo": [
|
||||
{}
|
||||
],
|
||||
"devices": [
|
||||
{
|
||||
"key": "processor",
|
||||
"uid": 1,
|
||||
"type": "pro3",
|
||||
"name": "PRO3 w/o cards",
|
||||
"group": "processor",
|
||||
"supportedConfigModes": [
|
||||
"essentials"
|
||||
],
|
||||
"supportedSystemTypes": [
|
||||
"hudType",
|
||||
"presType",
|
||||
"vtcType",
|
||||
"custom"
|
||||
],
|
||||
"supportsCompliance": true,
|
||||
"properties": {
|
||||
"numberOfComPorts": 6,
|
||||
"numberOfIrPorts": 8,
|
||||
"numberOfRelays": 8,
|
||||
"numberOfDIOPorts": 8
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "panasonicDisplay01",
|
||||
"type": "PanasonicThefDisplay",
|
||||
"name": "Main Display",
|
||||
"group": "displays",
|
||||
"uid": 2,
|
||||
"properties": {
|
||||
"id": "01",
|
||||
"inputNumber": 1,
|
||||
"outputNumber": 1,
|
||||
"control": {
|
||||
"comParams": {
|
||||
"hardwareHandshake": "None",
|
||||
"parity": "None",
|
||||
"protocol": "RS232",
|
||||
"baudRate": 9600,
|
||||
"dataBits": 8,
|
||||
"softwareHandshake": "None",
|
||||
"stopBits": 1
|
||||
},
|
||||
"controlPortNumber": 1,
|
||||
"controlPortDevKey": "processor",
|
||||
"method": "com"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "vtcComPort",
|
||||
"uid": 3,
|
||||
"name": "VTC Coms",
|
||||
"group": "comm",
|
||||
"type": "genericComm",
|
||||
"properties": {
|
||||
"control": {
|
||||
"comParams": {
|
||||
"hardwareHandshake": "None",
|
||||
"parity": "None",
|
||||
"protocol": "RS232",
|
||||
"baudRate": 38400,
|
||||
"dataBits": 8,
|
||||
"softwareHandshake": "None",
|
||||
"stopBits": 1
|
||||
},
|
||||
"controlPortNumber": 2,
|
||||
"controlPortDevKey": "processor",
|
||||
"method": "com"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "deviceBridge",
|
||||
"uid": 4,
|
||||
"name": "BridgeToDevices",
|
||||
"group": "api",
|
||||
"type": "eiscApi",
|
||||
"properties": {
|
||||
"control": {
|
||||
"tcpSshProperties": {
|
||||
"address": "127.0.0.2",
|
||||
"port": 0
|
||||
},
|
||||
"ipid": "03",
|
||||
"method": "ipidTcp"
|
||||
},
|
||||
"devices": [
|
||||
{
|
||||
"deviceKey": "panasonicDisplay01",
|
||||
"joinStart": 1
|
||||
},
|
||||
{
|
||||
"deviceKey": "vtcComPort",
|
||||
"joinStart": 51
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
We have four Essentials Devices configured:
|
||||
|
||||
1. Pro3 with a Key of "processor"
|
||||
|
||||
1. Panasonic Display with a Key of "panasonicDisplay01"
|
||||
|
||||
1. Com port with a Key of "vtcComPort"
|
||||
|
||||
1. Bridge with a Key of "deviceBridge"
|
||||
|
||||
We want to have access to the com port for VTC Control from SIMPL Windows and we want to control the display from SIMPL Windows. To accomplish this, we have created a bridge device and added the devices to be bridged to the "devices" array on the bridge. As you can see we define the device key and the join start, which will determine which joins we will use on the resulting EISC to interact with the devices. In the Bridge control properties we defined ipid 03, and we will need a corresponding Ethernet System Intercommunication in the SIMPL Windows program at ipid 03.
|
||||
|
||||
Now that our devices have been built, we can refer to the device join maps to see which joins correspond to which actions.
|
||||
|
||||
See below:
|
||||
|
||||
```cs
|
||||
namespace PepperDash.Essentials.Core.Bridges
|
||||
{
|
||||
public class DisplayControllerJoinMap : JoinMapBaseAdvanced
|
||||
{
|
||||
[JoinName("Name")]
|
||||
public JoinDataComplete Name = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial });
|
||||
|
||||
[JoinName("PowerOff")]
|
||||
public JoinDataComplete PowerOff = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Power Off", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital });
|
||||
|
||||
[JoinName("PowerOn")]
|
||||
public JoinDataComplete PowerOn = new JoinDataComplete(new JoinData() { JoinNumber = 2, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Power On", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital });
|
||||
|
||||
[JoinName("IsTwoWayDisplay")]
|
||||
public JoinDataComplete IsTwoWayDisplay = new JoinDataComplete(new JoinData() { JoinNumber = 3, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Is Two Way Display", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital });
|
||||
|
||||
[JoinName("VolumeUp")]
|
||||
public JoinDataComplete VolumeUp = new JoinDataComplete(new JoinData() { JoinNumber = 5, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Volume Up", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital });
|
||||
|
||||
[JoinName("VolumeLevel")]
|
||||
public JoinDataComplete VolumeLevel = new JoinDataComplete(new JoinData() { JoinNumber = 5, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Volume Level", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog });
|
||||
|
||||
[JoinName("VolumeDown")]
|
||||
public JoinDataComplete VolumeDown = new JoinDataComplete(new JoinData() { JoinNumber = 6, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Volume Down", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital });
|
||||
|
||||
[JoinName("VolumeMute")]
|
||||
public JoinDataComplete VolumeMute = new JoinDataComplete(new JoinData() { JoinNumber = 7, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Volume Mute", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital });
|
||||
|
||||
[JoinName("VolumeMuteOn")]
|
||||
public JoinDataComplete VolumeMuteOn = new JoinDataComplete(new JoinData() { JoinNumber = 8, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Volume Mute On", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital });
|
||||
|
||||
[JoinName("VolumeMuteOff")]
|
||||
public JoinDataComplete VolumeMuteOff = new JoinDataComplete(new JoinData() { JoinNumber = 9, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Volume Mute Off", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital });
|
||||
|
||||
[JoinName("InputSelectOffset")]
|
||||
public JoinDataComplete InputSelectOffset = new JoinDataComplete(new JoinData() { JoinNumber = 11, JoinSpan = 10 },
|
||||
new JoinMetadata() { Label = "Input Select", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital });
|
||||
|
||||
[JoinName("InputNamesOffset")]
|
||||
public JoinDataComplete InputNamesOffset = new JoinDataComplete(new JoinData() { JoinNumber = 11, JoinSpan = 10 },
|
||||
new JoinMetadata() { Label = "Input Names Offset", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial });
|
||||
|
||||
[JoinName("InputSelect")]
|
||||
public JoinDataComplete InputSelect = new JoinDataComplete(new JoinData() { JoinNumber = 11, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Input Select", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog });
|
||||
|
||||
[JoinName("ButtonVisibilityOffset")]
|
||||
public JoinDataComplete ButtonVisibilityOffset = new JoinDataComplete(new JoinData() { JoinNumber = 41, JoinSpan = 10 },
|
||||
new JoinMetadata() { Label = "Button Visibility Offset", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.DigitalSerial });
|
||||
|
||||
[JoinName("IsOnline")]
|
||||
public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData() { JoinNumber = 50, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Is Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital });
|
||||
|
||||
public DisplayControllerJoinMap(uint joinStart)
|
||||
: base(joinStart, typeof(CameraControllerJoinMap))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
We know that the Panasonic Display uses the DisplayControllerJoinMap class and can see the join numbers that will give us access to functionality in the Device.
|
||||
|
||||
IsOnline = 50
|
||||
PowerOff = 1
|
||||
PowerOn = 2
|
||||
IsTwoWayDisplay = 3
|
||||
VolumeUp = 5
|
||||
VolumeDown = 6
|
||||
VolumeMute = 7
|
||||
|
||||
```cs
|
||||
namespace PepperDash.Essentials.Core.Bridges
|
||||
{
|
||||
public class IBasicCommunicationJoinMap : JoinMapBaseAdvanced
|
||||
{
|
||||
[JoinName("TextReceived")]
|
||||
public JoinDataComplete TextReceived = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Text Received From Remote Device", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial });
|
||||
|
||||
[JoinName("SendText")]
|
||||
public JoinDataComplete SendText = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Text Sent To Remote Device", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial });
|
||||
|
||||
[JoinName("SetPortConfig")]
|
||||
public JoinDataComplete SetPortConfig = new JoinDataComplete(new JoinData() { JoinNumber = 2, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Set Port Config", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial });
|
||||
|
||||
[JoinName("Connect")]
|
||||
public JoinDataComplete Connect = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Connect", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital });
|
||||
|
||||
[JoinName("Connected")]
|
||||
public JoinDataComplete Connected = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Connected", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital });
|
||||
|
||||
[JoinName("Status")]
|
||||
public JoinDataComplete Status = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 },
|
||||
new JoinMetadata() { Label = "Status", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog });
|
||||
|
||||
|
||||
public IBasicCommunicationJoinMap(uint joinStart)
|
||||
: base(joinStart, typeof(IBasicCommunicationJoinMap))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Considering our Bridge config, we can see that the display controls will start at join 1, and the VTC Com port will start at join 51. The result is a single EISC that allows us to interact with our Essentials devices.
|
||||
|
||||
To control diplay power from SIMPL Windows, we would connect Digital Signals to joins 1 & 2 on the EISC to control Display Power On & Off.
|
||||
To utilize the com port device, we would connect Serial Signals (VTC_TX$ and VTC_RX$) to join 51 on the EISC.
|
||||
|
||||
You can refer to our [SIMPL Windows Bridging Example](https://github.com/PepperDash/EssentialsSIMPLWindowsBridgeExample) for a more complex example.
|
||||
Example device config: <https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Example%20Configuration/SIMPLBridging/SIMPLBridgeExample_configurationFile.json>
|
||||
|
||||
## Notes
|
||||
|
||||
1. It is important to realize that there are no safety checks (yet) when assigning joinStarts in bridge configurations. If you were to put two devices on a bridge with overlapping joins, the most recently bridged join would overwrite previously bridged joins. For now it is on the programmer to ensure there are no conflicting join maps.
|
||||
|
||||
2. There is _no_ limit to the amount of times a device may be bridged to. You may have the same device on multiple bridges across multiple applications without problem. That being said, we recommend using common sense. Accessing a single com port for VTC control via multiple bridges may not be wise...
|
||||
|
||||
3. A bridge need not only bridge between applications on the same processor. A bridge may bridge to an application on a completely separate processor; simply define the ip address in the Bridge control properties accordingly.
|
||||
|
||||
4. For devices included in Essentials, you will be able to find defined join maps below. If you are building your own plugins, you will need to build the join map yourself. It would be beneficial to review the wiki entry on the [Feedback Class](~/docs/Feedback-Classes.md) for this.
|
||||
|
||||
5. When building plugins, we highly recommend reusing JoinMaps, as this will make code more easily interchangeable. For example; if you were to build a display plugin, we'd recommend you use/extend the existing `DisplayControllerJoinMap`. This way, you can swap plugins without needing any change on the SIMPL Windows side. This is extremely powerful when maintaining SIMPL Windows code bases for large deployments that may utilize differing equipment per room. If you can build a SIMPL Windows program that interacts with established join maps, you can swap out the device via config without any change needed to SIMPL Windows.
|
||||
|
||||
6. Related to item 5, you can use the same paradigm with respect to physical device communication. If you were to have a DSP device in some rooms communicating over RS232 and some via SSH, it would be trival to swap the device from a Com port to an SSH client in the Essentials Devicee Config and update the Bridge Config to brigde to the desired communication method. Again this would require no change on the SIMPL Windows side as long as you maintain the same join Start in the Bridge Device Configuration.
|
||||
|
||||
## Common Use Cases
|
||||
|
||||
1. There are 10 conference rooms that all operate the same, but have hardware differences that are impossible to account for in SIMPL Windows. For example, each room might have a DM-MD8X8 chassis, but the input and output cards aren't all in the same order, or they might be different models but function the same. You can use Essentials with a unique configuration file for each hardware configuration.
|
||||
|
||||
2. You have a floor of conference rooms that all share some centralized hardware like DSP, AV Routing and a shared CEN-GWEXER gateway with multiple GLS-OIR-CSM-EX-BATT occupancy sensors. All the shared hardware can be defined in the Essentials configuration and bridged over an EISC to each program that needs access. The same device can even be exposed to multiple programs over different EISCs.
|
||||
|
||||
3. You have a SIMPL program that works for many room types, but because some rooms have different models of processors than others (CP3/CP3N/AV3/PRO3/DMPS3 variants), you have to maintain several versions of the program, compiled for each processor model to maintain access to features like the System Monitor slot. You can use Essentials running in a slot on a processor to expose the System Monitor and many other features of the processor, regardless of model. Now you only need to maintain a single SIMPL program defined for your most complex processor application (ex. PRO3)
|
||||
|
||||
## Join Map Documentation
|
||||
|
||||
[Join Map Documentation](~/docs/JoinMaps.md)
|
||||
|
||||
## Device Type Join Maps
|
||||
|
||||
Please note that these joinmaps _may_ be using a deprecated implementation. The implementation is valid but nonetheless frowned upon for new features and plugins.
|
||||
|
||||
### AirMediaController
|
||||
|
||||
> supports: AM-200, AM-300
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/essentials-framework/Essentials%20Core/PepperDashEssentialsBase/Bridges/JoinMaps/AirMediaControllerJoinMap.cs>
|
||||
|
||||
### AppleTvController
|
||||
|
||||
> supports: IR control of Apple TV
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/essentials-framework/Essentials%20Core/PepperDashEssentialsBase/Bridges/JoinMaps/AppleTvJoinMap.cs>
|
||||
|
||||
### CameraControlBase
|
||||
|
||||
> supports: any camera that derives from CameraBase
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/essentials-framework/Essentials%20Core/PepperDashEssentialsBase/Bridges/JoinMaps/CameraControllerJoinMap.cs>
|
||||
|
||||
### DisplayController
|
||||
|
||||
> supports: IR controlled displays, any two way display driver that derives from PepperDash.Essentials.Core.DisplayBase
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/essentials-framework/Essentials%20Core/PepperDashEssentialsBase/Bridges/JoinMaps/DisplayControllerJoinMap.cs>
|
||||
|
||||
### DmChasisController
|
||||
|
||||
> supports: All DM-MD-8x8/16x16/32x32 chassis, with or w/o DM-CPU3 Card
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/essentials-framework/Essentials%20Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmChassisControllerJoinMap.cs>
|
||||
|
||||
### DmRmcController
|
||||
|
||||
> supports: All DM-RMC devices
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/essentials-framework/Essentials%20Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmRmcControllerJoinMap.cs>
|
||||
|
||||
### DmTxController
|
||||
|
||||
> supports: All Dm-Tx devices
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/essentials-framework/Essentials%20Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmTxControllerJoinMap.cs>
|
||||
|
||||
### DmpsAudioOutputController
|
||||
|
||||
> supports: Program, Aux1, Aux2 outputs of all DMPS3 Control Systems
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/essentials-framework/Essentials%20Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmpsAudioOutputControllerJoinMap.cs>
|
||||
|
||||
### DmpsRoutingController
|
||||
|
||||
> supports: Av routing for all DMPS3 Control Systems
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/essentials-framework/Essentials%20Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmpsRoutingControllerJoinMap.cs>
|
||||
|
||||
### GenericRelayController
|
||||
|
||||
> supports: Any relay port on a Crestron Control System or Dm Endpoint
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/essentials-framework/Essentials%20Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericRelayControllerJoinMap.cs>
|
||||
|
||||
### GenericLightingJoinMap
|
||||
|
||||
> supports: Devices derived from PepperDash.Essentials.Core.Lighting.LightingBase
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/essentials-framework/Essentials%20Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericLightingJoinMap.cs>
|
||||
|
||||
### GlsOccupancySensorBase
|
||||
|
||||
> supports: Any Crestron GLS-Type Occupancy sensor - single/dual type
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/essentials-framework/Essentials%20Core/PepperDashEssentialsBase/Bridges/JoinMaps/GlsOccupancySensorBaseJoinMap.cs>
|
||||
|
||||
### HdMdxxxCEController
|
||||
|
||||
> supports: HD-MD-400-C-E, HD-MD-300-C-E, HD-MD-200-C-E, HD-MD-200-C-1G-E-B/W
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/essentials-framework/Essentials%20Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdMdxxxCEControllerJoinMap.cs>
|
||||
|
||||
### IBasicCommunication
|
||||
|
||||
> supports: Any COM Port on a Control System or Dm Endpoint device, TCP Client, SSH Client, or UDP Server
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/essentials-framework/Essentials%20Core/PepperDashEssentialsBase/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs>
|
||||
|
||||
### IDigitalInput
|
||||
|
||||
> supports: Any Digital Input on a Control System, or DM Endpoint device
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/essentials-framework/Essentials%20Core/PepperDashEssentialsBase/Bridges/JoinMaps/IDigitalInputJoinMap.cs>
|
||||
|
||||
### SystemMonitorController
|
||||
|
||||
> supports: Exposing the system monitor slot for any Control System
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/essentials-framework/Essentials%20Core/PepperDashEssentialsBase/Bridges/JoinMaps/SystemMonitorJoinMap.cs>
|
||||
|
||||
## Example SIMPL Windows Program
|
||||
|
||||
We've provided an [example program](https://github.com/PepperDash/EssentialsSIMPLWindowsBridgeExample) for SIMPL Windows that works with the provided example Essentials configuration file [SIMPLBridgeExample_configurationFile.json](https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Example%20Configuration/SIMPLBridging/SIMPLBridgeExample_configurationFile.json). Load Essentials and the example SIMPL program to two slots on the same processor and you can get a better idea of how to take advantage of SIMPL Windows bridging.
|
||||
|
||||
Next: [Essentials architecture](~/docs/Arch-summary.md)
|
||||
475
docs/docs/SIMPL-Bridging.md
Normal file
@@ -0,0 +1,475 @@
|
||||
# SIMPL Windows Bridging
|
||||
|
||||
**Note : this entry is out of date - please see [SIMPL Windows Bridging - Updated](~/docs/SIMPL-Bridging-Updated.md)**
|
||||
|
||||
Essentials allows for devices defined within the SIMPL# Pro application to be bridged to a SIMPL Windows application over Ethernet Intersystem Communication (EISC). This allows a SIMPL Windows program to take advantage of some of the features of the SIMPL# Pro environment, without requiring the entire application to be written in C#.
|
||||
|
||||
Some of the main advantages are:
|
||||
|
||||
1. The ability to instantiate devices from configuration.
|
||||
1. The ability to leverage C# concepts to handle data intensive tasks (Serialization/Deserialization of JSON/XML, cyrptography, etc.).
|
||||
1. The ability to reuse the same compiled SIMPL Windows program (regardless of target processor type) by offloading all the variables that may be room or hardware specific to Essentials.
|
||||
1. The ability to handle multiple communciation types generically without changing the SIMPL Program (TCP/UDP/SSH/HTTP/HTTPS/CEC, etc.)
|
||||
1. Much faster development cycle
|
||||
1. Reduced processor overhead
|
||||
1. Ability to easily share devices defined in Essentials between multiple other programs
|
||||
|
||||
## Implementation
|
||||
|
||||
Bridges are devices that are defined within the devices array in the config file. They are unique devices with a specialized purpose; to act as a bridge between Essentials Devices and applications programmed traditionally in Simpl Windows. This is accomplished by instantiating a Three Series Intersystem Communication symbol within the bridge device, and linking its Boolean/Ushort/String inputs and outputs to actions on one or multiple Essentials device(s). The definition for which joins map to which actions is defined within the device to be bridged to in a class that derives from JoinMapBase.
|
||||
|
||||
Let's consider the following Essentials Configuration:
|
||||
|
||||
```JSON
|
||||
{
|
||||
"template": {
|
||||
"roomInfo": [
|
||||
{}
|
||||
],
|
||||
"devices": [
|
||||
{
|
||||
"key": "processor",
|
||||
"uid": 1,
|
||||
"type": "pro3",
|
||||
"name": "PRO3 w/o cards",
|
||||
"group": "processor",
|
||||
"supportedConfigModes": [
|
||||
"essentials"
|
||||
],
|
||||
"supportedSystemTypes": [
|
||||
"hudType",
|
||||
"presType",
|
||||
"vtcType",
|
||||
"custom"
|
||||
],
|
||||
"supportsCompliance": true,
|
||||
"properties": {
|
||||
"numberOfComPorts": 6,
|
||||
"numberOfIrPorts": 8,
|
||||
"numberOfRelays": 8,
|
||||
"numberOfDIOPorts": 8
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "panasonicDisplay01",
|
||||
"type": "PanasonicThefDisplay",
|
||||
"name": "Main Display",
|
||||
"group": "displays",
|
||||
"uid": 2,
|
||||
"properties": {
|
||||
"id": "01",
|
||||
"inputNumber": 1,
|
||||
"outputNumber": 1,
|
||||
"control": {
|
||||
"comParams": {
|
||||
"hardwareHandshake": "None",
|
||||
"parity": "None",
|
||||
"protocol": "RS232",
|
||||
"baudRate": 9600,
|
||||
"dataBits": 8,
|
||||
"softwareHandshake": "None",
|
||||
"stopBits": 1
|
||||
},
|
||||
"controlPortNumber": 1,
|
||||
"controlPortDevKey": "processor",
|
||||
"method": "com"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "vtcComPort",
|
||||
"uid": 3,
|
||||
"name": "VTC Coms",
|
||||
"group": "comm",
|
||||
"type": "genericComm",
|
||||
"properties": {
|
||||
"control": {
|
||||
"comParams": {
|
||||
"hardwareHandshake": "None",
|
||||
"parity": "None",
|
||||
"protocol": "RS232",
|
||||
"baudRate": 38400,
|
||||
"dataBits": 8,
|
||||
"softwareHandshake": "None",
|
||||
"stopBits": 1
|
||||
},
|
||||
"controlPortNumber": 2,
|
||||
"controlPortDevKey": "processor",
|
||||
"method": "com"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "deviceBridge",
|
||||
"uid": 4,
|
||||
"name": "BridgeToDevices",
|
||||
"group": "api",
|
||||
"type": "eiscApi",
|
||||
"properties": {
|
||||
"control": {
|
||||
"tcpSshProperties": {
|
||||
"address": "127.0.0.2",
|
||||
"port": 0
|
||||
},
|
||||
"ipid": "03",
|
||||
"method": "ipidTcp"
|
||||
},
|
||||
"devices": [
|
||||
{
|
||||
"deviceKey": "panasonicDisplay01",
|
||||
"joinStart": 1
|
||||
},
|
||||
{
|
||||
"deviceKey": "vtcComPort",
|
||||
"joinStart": 51
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
We have four Essentials Devices configured:
|
||||
|
||||
1. Pro3 with a Key of "processor"
|
||||
|
||||
1. Panasonic Display with a Key of "panasonicDisplay01"
|
||||
|
||||
1. Com port with a Key of "vtcComPort"
|
||||
|
||||
1. Bridge with a Key of "deviceBridge"
|
||||
|
||||
We want to have access to the com port for VTC Control from Simpl Windows and we want to control the display from Simpl Windows. To accomplish this, we have created a bridge device and added the devices to be bridged to the "devices" array on the bridge. As you can see we define the device key and the join start, which will determine which joins we will use on the resulting EISC to interact with the devices. In the Bridge control properties we defined ipid 03, and we will need a corresponding Ethernet System Intercommunication in the Simpl Windows program at ipid 03.
|
||||
|
||||
Now that our devices have been built, we can refer to the device join maps to see which joins correspond to which actions.
|
||||
|
||||
See below:
|
||||
|
||||
```cs
|
||||
namespace PepperDash.Essentials.Bridges
|
||||
{
|
||||
public class DisplayControllerJoinMap : JoinMapBase
|
||||
{
|
||||
#region Digitals
|
||||
/// <summary>
|
||||
/// Turns the display off and reports power off feedback
|
||||
/// </summary>
|
||||
public uint PowerOff { get; set; }
|
||||
/// <summary>
|
||||
/// Turns the display on and repots power on feedback
|
||||
/// </summary>
|
||||
public uint PowerOn { get; set; }
|
||||
/// <summary>
|
||||
/// Indicates that the display device supports two way communication when high
|
||||
/// </summary>
|
||||
public uint IsTwoWayDisplay { get; set; }
|
||||
/// <summary>
|
||||
/// Increments the volume while high
|
||||
/// </summary>
|
||||
public uint VolumeUp { get; set; }
|
||||
/// <summary>
|
||||
/// Decrements teh volume while high
|
||||
/// </summary>
|
||||
public uint VolumeDown { get; set; }
|
||||
/// <summary>
|
||||
/// Toggles the mute state. Feedback is high when volume is muted
|
||||
/// </summary>
|
||||
public uint VolumeMute { get; set; }
|
||||
/// <summary>
|
||||
/// Range of digital joins to select inputs and report current input as feedback
|
||||
/// </summary>
|
||||
public uint InputSelectOffset { get; set; }
|
||||
/// <summary>
|
||||
/// Range of digital joins to report visibility for input buttons
|
||||
/// </summary>
|
||||
public uint ButtonVisibilityOffset { get; set; }
|
||||
/// <summary>
|
||||
/// High if the device is online
|
||||
/// </summary>
|
||||
public uint IsOnline { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Analogs
|
||||
/// <summary>
|
||||
/// Analog join to set the input and report current input as feedback
|
||||
/// </summary>
|
||||
public uint InputSelect { get; set; }
|
||||
/// <summary>
|
||||
/// Sets the volume level and reports the current level as feedback
|
||||
/// </summary>
|
||||
public uint VolumeLevel { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Serials
|
||||
/// <summary>
|
||||
/// Reports the name of the display as defined in config as feedback
|
||||
/// </summary>
|
||||
public uint Name { get; set; }
|
||||
/// <summary>
|
||||
/// Range of serial joins that reports the names of the inputs as feedback
|
||||
/// </summary>
|
||||
public uint InputNamesOffset { get; set; }
|
||||
#endregion
|
||||
|
||||
public DisplayControllerJoinMap()
|
||||
{
|
||||
// Digital
|
||||
IsOnline = 50;
|
||||
PowerOff = 1;
|
||||
PowerOn = 2;
|
||||
IsTwoWayDisplay = 3;
|
||||
VolumeUp = 5;
|
||||
VolumeDown = 6;
|
||||
VolumeMute = 7;
|
||||
|
||||
ButtonVisibilityOffset = 40;
|
||||
InputSelectOffset = 10;
|
||||
|
||||
// Analog
|
||||
InputSelect = 11;
|
||||
VolumeLevel = 5;
|
||||
|
||||
// Serial
|
||||
Name = 1;
|
||||
InputNamesOffset = 10;
|
||||
}
|
||||
|
||||
public override void OffsetJoinNumbers(uint joinStart)
|
||||
{
|
||||
var joinOffset = joinStart - 1;
|
||||
|
||||
IsOnline = IsOnline + joinOffset;
|
||||
PowerOff = PowerOff + joinOffset;
|
||||
PowerOn = PowerOn + joinOffset;
|
||||
IsTwoWayDisplay = IsTwoWayDisplay + joinOffset;
|
||||
ButtonVisibilityOffset = ButtonVisibilityOffset + joinOffset;
|
||||
Name = Name + joinOffset;
|
||||
InputNamesOffset = InputNamesOffset + joinOffset;
|
||||
InputSelectOffset = InputSelectOffset + joinOffset;
|
||||
|
||||
InputSelect = InputSelect + joinOffset;
|
||||
|
||||
VolumeUp = VolumeUp + joinOffset;
|
||||
VolumeDown = VolumeDown + joinOffset;
|
||||
VolumeMute = VolumeMute + joinOffset;
|
||||
VolumeLevel = VolumeLevel + joinOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
We know that the Panasonic Display uses the DisplayControllerJoinMap class and can see the join numbers that will give us access to functionality in the Device.
|
||||
|
||||
IsOnline = 50
|
||||
PowerOff = 1
|
||||
PowerOn = 2
|
||||
IsTwoWayDisplay = 3
|
||||
VolumeUp = 5
|
||||
VolumeDown = 6
|
||||
VolumeMute = 7
|
||||
|
||||
```cs
|
||||
namespace PepperDash.Essentials.Bridges
|
||||
{
|
||||
public class IBasicCommunicationJoinMap : JoinMapBase
|
||||
{
|
||||
#region Digitals
|
||||
/// <summary>
|
||||
/// Set High to connect, Low to disconnect
|
||||
/// </summary>
|
||||
public uint Connect { get; set; }
|
||||
/// <summary>
|
||||
/// Reports Connected State (High = Connected)
|
||||
/// </summary>
|
||||
public uint Connected { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Analogs
|
||||
/// <summary>
|
||||
/// Reports the connections status value
|
||||
/// </summary>
|
||||
public uint Status { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Serials
|
||||
/// <summary>
|
||||
/// Data back from port
|
||||
/// </summary>
|
||||
public uint TextReceived { get; set; }
|
||||
/// <summary>
|
||||
/// Sends data to the port
|
||||
/// </summary>
|
||||
public uint SendText { get; set; }
|
||||
/// <summary>
|
||||
/// Takes a JSON serialized string that sets a COM port's parameters
|
||||
/// </summary>
|
||||
public uint SetPortConfig { get; set; }
|
||||
#endregion
|
||||
|
||||
public IBasicCommunicationJoinMap()
|
||||
{
|
||||
TextReceived = 1;
|
||||
SendText = 1;
|
||||
SetPortConfig = 2;
|
||||
Connect = 1;
|
||||
Connected = 1;
|
||||
Status = 1;
|
||||
}
|
||||
|
||||
public override void OffsetJoinNumbers(uint joinStart)
|
||||
{
|
||||
var joinOffset = joinStart - 1;
|
||||
|
||||
TextReceived = TextReceived + joinOffset;
|
||||
SendText = SendText + joinOffset;
|
||||
SetPortConfig = SetPortConfig + joinOffset;
|
||||
Connect = Connect + joinOffset;
|
||||
Connected = Connected + joinOffset;
|
||||
Status = Status + joinOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
TextReceived = 1
|
||||
SendText = 1
|
||||
SetPortConfig = 2
|
||||
Connect = 1
|
||||
Connected = 1
|
||||
Status = 1
|
||||
|
||||
Considering our Bridge config, we can see that the display controls will start at join 1, and the VTC Com port will start at join 51. The result is a single EISC that allows us to interact with our Essentials devices.
|
||||
|
||||
To control diplay power from Simpl Windows, we would connect Digital Signals to joins 1 & 2 on the EISC to control Display Power On & Off.
|
||||
To utilize the com port device, we would connect Serial Signals (VTC_TX$ and VTC_RX$) to join 51 on the EISC.
|
||||
|
||||
You can refer to our [Simpl Windows Bridging Example](https://github.com/PepperDash/EssentialsSIMPLWindowsBridgeExample) for a more complex example.
|
||||
Example device config: <https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Example%20Configuration/SIMPLBridging/SIMPLBridgeExample_configurationFile.json>
|
||||
|
||||
## Notes
|
||||
|
||||
1. It is important to realize that there are no safety checks (yet) when assigning joinStarts in bridge configurations. If you were to put two devices on a bridge with overlapping joins, the most recently bridged join would overwrite previously bridged joins. For now it is on the programmer to ensure there are no conflicting join maps.
|
||||
|
||||
1. There is _no_ limit to the amount of times a device may be bridged to. You may have the same device on multiple bridges across multiple applications without problem. That being said, we recommend using common sense. Accessing a single com port for VTC control via multiple bridges may not be wise...
|
||||
|
||||
1. A bridge need not only bridge between applications on the same processor. A bridge may bridge to an application on a completely separate processor; simply define the ip address in the Bridge control properties accordingly.
|
||||
|
||||
1. For devices included in Essentials, you will be able to find defined join maps below. If you are building your own plugins, you will need to build the join map yourself. It would be beneficial to review the wiki entry on the [Feedback Class](~/docs/Feedback-Classes.md) for this.
|
||||
|
||||
1. When building plugins, we highly recommend reusing JoinMaps, as this will make code more easily interchangeable. For example; if you were to build a display plugin, we'd recommend you use/extend the existing DisplayControllerJoinMap. This way, you can swap plugins without needing any change on the Simpl Windows side. This is extremely powerful when maintaining Simpl Windows code bases for large deployments that may utilize differing equipment per room. If you can build a Simpl Windows program that interacts with established join maps, you can swap out the device via config without any change needed to Simpl Windows.
|
||||
|
||||
1. Related to item 5, you can use the same paradigm with respect to physical device communication. If you were to have a DSP device in some rooms communicating over RS232 and some via SSH, it would be trival to swap the device from a Com port to an SSH client in the Essentials Devicee Config and update the Bridge Config to brigde to the desired communication method. Again this would require no change on the Simpl Windows side as long as you maintain the same join Start in the Bridge Device Configuration.
|
||||
|
||||
## Common Use Cases
|
||||
|
||||
1. There are 10 conference rooms that all operate the same, but have hardware differences that are impossible to account for in SIMPL Windows. For example, each room might have a DM-MD8X8 chassis, but the input and output cards aren't all in the same order, or they might be different models but function the same. You can use Essentials with a unique configuration file for each hardware configuration.
|
||||
|
||||
1. You have a floor of conference rooms that all share some centralized hardware like DSP, AV Routing and a shared CEN-GWEXER gateway with multiple GLS-OIR-CSM-EX-BATT occupancy sensors. All the shared hardware can be defined in the Essentials configuration and bridged over an EISC to each program that needs access. The same device can even be exposed to multiple programs over different EISCs.
|
||||
|
||||
1. You have a SIMPL program that works for many room types, but because some rooms have different models of processors than others (CP3/CP3N/AV3/PRO3/DMPS3 variants), you have to maintain several versions of the program, compiled for each processor model to maintain access to features like the System Monitor slot. You can use Essentials running in a slot on a processor to expose the System Monitor and many other features of the processor, regardless of model. Now you only need to maintain a single SIMPL program defined for your most complex processor application (ex. PRO3)
|
||||
|
||||
## Device Type Join Maps
|
||||
|
||||
### AirMediaController
|
||||
|
||||
> supports: AM-200, AM-300
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/AirMediaControllerJoinMap.cs>
|
||||
|
||||
### AppleTvController
|
||||
|
||||
> supports: IR control of Apple TV
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/AppleTvJoinMap.cs>
|
||||
|
||||
### CameraControlBase
|
||||
|
||||
> supports: any camera that derives from CameraBase
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs>
|
||||
|
||||
### DisplayController
|
||||
|
||||
> supports: IR controlled displays, any two way display driver that derives from PepperDash.Essentials.Core.DisplayBase
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/DisplayControllerJoinMap.cs>
|
||||
|
||||
### DmChasisController
|
||||
|
||||
> supports: All DM-MD-8x8/16x16/32x32 chassis, with or w/o DM-CPU3 Card
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/DmChassisControllerJoinMap.cs>
|
||||
|
||||
### DmRmcController
|
||||
|
||||
> supports: All DM-RMC devices
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/DmRmcControllerJoinMap.cs>
|
||||
|
||||
### DmTxController
|
||||
|
||||
> supports: All Dm-Tx devices
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/DmTxControllerJoinMap.cs>
|
||||
|
||||
### DmpsAudioOutputController
|
||||
|
||||
> supports: Program, Aux1, Aux2 outputs of all DMPS3 Control Systems
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/DmpsAudioOutputControllerJoinMap.cs>
|
||||
|
||||
### DmpsRoutingController
|
||||
|
||||
> supports: Av routing for all DMPS3 Control Systems
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/DmpsRoutingControllerJoinMap.cs>
|
||||
|
||||
### GenericRelayController
|
||||
|
||||
> supports: Any relay port on a Crestron Control System or Dm Endpoint
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/GenericRelayControllerJoinMap.cs>
|
||||
|
||||
### GenericLightingJoinMap
|
||||
|
||||
> supports: Devices derived from PepperDash.Essentials.Core.Lighting.LightingBase
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/GenericLightingJoinMap.cs>
|
||||
|
||||
### GlsOccupancySensorBase
|
||||
|
||||
> supports: Any Crestron GLS-Type Occupancy sensor - single/dual type
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/GlsOccupancySensorBaseJoinMap.cs>
|
||||
|
||||
### HdMdxxxCEController
|
||||
|
||||
> supports: HD-MD-400-C-E, HD-MD-300-C-E, HD-MD-200-C-E, HD-MD-200-C-1G-E-B/W
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/HdMdxxxCEControllerJoinMap.cs>
|
||||
|
||||
### IBasicCommunication
|
||||
|
||||
> supports: Any COM Port on a Control System or Dm Endpoint device, TCP Client, SSH Client, or UDP Server
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/IBasicCommunicationJoinMap.cs>
|
||||
|
||||
### IDigitalInput
|
||||
|
||||
> supports: Any Digital Input on a Control System, or DM Endpoint device
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/IDigitalInputJoinMap.cs>
|
||||
|
||||
### SystemMonitorController
|
||||
|
||||
> supports: Exposing the system monitor slot for any Control System
|
||||
|
||||
<https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Bridges/JoinMaps/SystemMonitorJoinMap.cs>
|
||||
|
||||
## Example SIMPL Windows Program
|
||||
|
||||
We've provided an [example program](https://github.com/PepperDash/EssentialsSIMPLWindowsBridgeExample) for SIMPL Windows that works with the provided example Essentials configuration file [SIMPLBridgeExample_configurationFile.json](https://github.com/PepperDash/Essentials/blob/main/PepperDashEssentials/Example%20Configuration/SIMPLBridging/SIMPLBridgeExample_configurationFile.json). Load Essentials and the example SIMPL program to two slots on the same processor and you can get a better idea of how to take advantage of SIMPL Windows bridging.
|
||||
|
||||
Next: [Essentials architecture](~/docs/Arch-summary.md)
|
||||
19
docs/docs/Standalone-Use.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Stand-alone Application
|
||||
|
||||
Essentials was originally designed as a standalone SIMPL# Pro control system application and has developed into a versatile, pluggable application. This page describes how to use our built-in room types for a completely self-contained "one-slot" control program.
|
||||
|
||||
By defining devices and a room in a JSON configuration file, Essentials can control an entire AV control system for a room. A file can be manually created in an IDE such as Visual Studio Code, or it can be generated by a friendly web-based configuration tool on [PepperDash Portal](http://pepperdash.com/products/), or some other configuration tool application, both requiring no knowledge of JSON. These tools step a user through building the necessary devices and setting to achieve a full working room.
|
||||
|
||||
## Plugins
|
||||
|
||||
### Devices
|
||||
|
||||
Essentials supports device plugins for communicating with various devices using both standard Crestron CIP communications, Cresnet, SSH, or other TCP/IP-based communication methods. See [the Plugins section](~/docs/Plugins.md) for more details
|
||||
|
||||
### Rooms
|
||||
|
||||
In order to tie together equipment into a unit that comprises what devices are used in a room, Essentials supports Room plugins. These plugins are similar to device plugins, in that they're loaded at runtime and allow for customization of business logic and behavior. They're loaded into a different section of the Device Manager, and can reference devices created by device plugins using the device's key.
|
||||
|
||||
See Also: [[Supported Devices|Supported-Devices]]
|
||||
|
||||
Next: [Simpl Windows bridging](~/docs/SIMPL-Bridging-Updated.md)
|
||||
68
docs/docs/Supported-Devices.md
Normal file
@@ -0,0 +1,68 @@
|
||||
# Essentials Framework Devices by Type
|
||||
|
||||
## Cameras
|
||||
|
||||
* VISCA protocol
|
||||
* Cisco (via codec)
|
||||
* Zoom (via Zoom Room)
|
||||
|
||||
## Disc Player
|
||||
|
||||
* Any IR disc player that implements standard RAD commands
|
||||
|
||||
## Displays
|
||||
|
||||
* Any IR display that implements standard RAD commands
|
||||
* Samsung MDC protocol (commercial)
|
||||
* NEC Professional series flat panel
|
||||
* Avocor VTF
|
||||
* Panasonic TH series flat panels
|
||||
* Panasonic Projectors [(via plugin)](https://github.com/PepperDash/epi-display-panasonic-projectors)
|
||||
* LG Commercial series [(via plugin)](https://github.com/PepperDash/epi-display-lg)
|
||||
* Generic CEC control via HDMI [(via plugin)](https://github.com/PepperDash/epi-generic-cec-display)
|
||||
* Crestron Certified Driver Display [(via plugin)](https://github.com/batourin/epi-display-ccd)
|
||||
|
||||
## Lighting/Shading
|
||||
|
||||
* Lutron Quantum
|
||||
* Somfy Shades (relay control)
|
||||
|
||||
## Power Controllers
|
||||
|
||||
* Digital Logger
|
||||
|
||||
## Set Top Boxes
|
||||
|
||||
* Any IR set top box that implements standard RAD commands
|
||||
|
||||
## Streaming Players
|
||||
|
||||
* AppleTV (IR)
|
||||
* Roku (IR)
|
||||
|
||||
## Video Codecs
|
||||
|
||||
* Cisco CE series (C/SX/RoomKit)
|
||||
* Zoom Room
|
||||
|
||||
## DSPs / Audio Codecs
|
||||
|
||||
* BiAmp Tesira [(via plugin](https://github.com/PepperDash/epi-dsp-tesira)
|
||||
|
||||
## Crestron Devices
|
||||
|
||||
* AM-200/300 Airmedia
|
||||
* All DM Chassis (8x8 * 128x128)
|
||||
* All DM input/output cards
|
||||
* All DMPS Processors
|
||||
* All DM Transmitter models (with COM/IR/Relay/CEC port access)
|
||||
* All DM Receiver models (with COM/IR/Relay/CEC port access)
|
||||
* DGE-100
|
||||
* DM-DGE-200-C
|
||||
* DIN-8SW8
|
||||
* CEN-IO-DIGIN-104
|
||||
* CEN-RFGWEX/GWEXER
|
||||
* GLS-ODT/OIR-C-CN Occupancy Sensors
|
||||
* TSW-XXX series touchpanels
|
||||
* XPanel for SmartGraphics
|
||||
* Fusion Room and Assets
|
||||
1
docs/docs/getting-started.md
Normal file
@@ -0,0 +1 @@
|
||||
# Getting Started
|
||||
|
Before Width: | Height: | Size: 398 KiB After Width: | Height: | Size: 398 KiB |
|
Before Width: | Height: | Size: 228 KiB After Width: | Height: | Size: 228 KiB |
|
Before Width: | Height: | Size: 337 KiB After Width: | Height: | Size: 337 KiB |
|
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 100 KiB |
|
Before Width: | Height: | Size: 104 KiB After Width: | Height: | Size: 104 KiB |
BIN
docs/docs/images/essentials_bug_blue-500.png
Normal file
|
After Width: | Height: | Size: 29 KiB |
BIN
docs/docs/images/favicon-32x32.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
docs/docs/images/favicon.ico
Normal file
|
After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 648 KiB After Width: | Height: | Size: 648 KiB |
|
Before Width: | Height: | Size: 230 KiB After Width: | Height: | Size: 230 KiB |
48
docs/docs/toc.yml
Normal file
@@ -0,0 +1,48 @@
|
||||
- name: Get Started With Essentials
|
||||
- href: ../index.md
|
||||
- href: Get-started.md
|
||||
- name: Usage
|
||||
items:
|
||||
- href: Standalone-Use.md
|
||||
- href: SIMPL-Bridging-Updated.md
|
||||
items:
|
||||
- name: Join Maps
|
||||
href: JoinMaps.md
|
||||
- name: Bridging to Hardware Resources
|
||||
href: Bridging-To-Hardware-Resources.md
|
||||
items:
|
||||
- name: GenericComm Bridging
|
||||
href: GenericComm.md
|
||||
- name: RelayOutput Bridging
|
||||
href: RelayOutput.md
|
||||
- name: Digital Input Bridging
|
||||
href: DigitalInput.md
|
||||
- name: IR Driver Bridging
|
||||
href: IR-Driver-Bridging.md
|
||||
- name: Technical documentation
|
||||
items:
|
||||
- href: Arch-summary.md
|
||||
- name: Devices and DeviceManager
|
||||
href: Arch-1.md
|
||||
- name: Configurable lifecycle
|
||||
href: Arch-lifecycle.md
|
||||
- name: Activation phases
|
||||
href: Arch-activate.md
|
||||
- name: More
|
||||
href: Arch-topics.md
|
||||
- name: Plugins
|
||||
href: Plugins.md
|
||||
- name: Communication Basics
|
||||
href: Communication-Basics.md
|
||||
- name: Debugging
|
||||
href: Debugging.md
|
||||
- name: Feedback Classes
|
||||
href: Feedback-Classes.md
|
||||
- name: Connection Based Routing
|
||||
href: Connection-Based-Routing.md
|
||||
- name: Configuration Structure
|
||||
href: ConfigurationStructure.md
|
||||
- name: Supported Devices
|
||||
href: Supported-Devices.md
|
||||
- name: Glossary of Terms
|
||||
href: Glossary-of-Terms.md
|
||||
59
docs/index.md
Normal file
@@ -0,0 +1,59 @@
|
||||
# Welcome to PepperDash Essentials!
|
||||
|
||||
PepperDash Essentials is an open-source framework for control systems, built on Crestron's Simpl# Pro framework. It can be configured as a standalone program capable of running a wide variety of system designs and can also be used to augment other Crestron programs.
|
||||
|
||||
Essentials is a collection of C# libraries that can be used in many ways. It is a 100% configuration-driven framework that can be extended to add different workflows and behaviors, either through the addition of new device-types and classes, or via a plug-in mechanism. The framework is a collection of things that are all related and interconnected, but in general do not have strong dependencies on each other.
|
||||
|
||||
---
|
||||
|
||||
## Get started
|
||||
|
||||
- [Download essentials build or clone repo](~/docs/Get-started.md)
|
||||
- [How to get started](~/docs/Get-started.md)
|
||||
- [YouTube Video Series Playlist](https://youtube.com/playlist?list=PLKOoNNwgPFZdV5wDEBDZxTHu1KROspaBu)
|
||||
- [Discord Server](https://discord.gg/6Vh3ssDdPs)
|
||||
|
||||
Or use the links to the right to navigate our documentation.
|
||||
|
||||
---
|
||||
|
||||
## Benefits
|
||||
|
||||
- Runs on Crestron 3-Series, **4-Series** and VC-4 Control System platforms
|
||||
- Reduced hardware overhead compared to S+ and Simpl solutions
|
||||
- Quick development cycle
|
||||
- Shared resources made easily available
|
||||
- More flexibility with less code
|
||||
- Configurable using simple JSON files
|
||||
- Is awesome
|
||||
|
||||
---
|
||||
|
||||
## Comment
|
||||
|
||||
The Essentials wiki is clearly in-progress right now. Take a look at the links to the right. We are actively working on this documentation, so please be patient with us. If you have any comments on or suggestions for the documentation, please file an issue here, with as much detail as you can provide: <https://github.com/PepperDash/Essentials/issues>
|
||||
|
||||
Thanks!
|
||||
|
||||
---
|
||||
|
||||
## Collaboration
|
||||
|
||||
Essentials is an open-source project and we encourage collaboration on this community project. For features that may not be useful to the greater community, or for just-plain learning, we want to remind developers to try writing plugins for Essentials. More information can be found here: [Plugins](~/docs/Plugins.md)
|
||||
|
||||
### Open-source-collaborative workflow
|
||||
|
||||
The `main` branch always contain the latest stable version. The `development` branch is used for most development efforts.
|
||||
|
||||
[GitFlow](https://nvie.com/posts/a-successful-git-branching-model/) will be used as the workflow for this collaborative project. To contribute, follow this process:
|
||||
|
||||
1. Fork this repository ([More Info](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/working-with-forks))
|
||||
2. Create a branch using standard GitFlow branch prefixes (feature/hotfix) followed by a descriptive name.
|
||||
- Example: `feature/add-awesomeness` or `hotfix/really-big-oops`
|
||||
- When working on a new feature or bugfix, branch from the `development` branch. When working on a hotfix, branch from `main`.
|
||||
3. Make commits as necessary (often is better). And use concise, descriptive language, leveraging issue notation and/or [Closing Keywords](https://help.github.com/articles/closing-issues-using-keywords) to ensure any issues addressed by your work are referenced accordingly.
|
||||
4. When the scope of the work for your branch is complete, make sure to rebase your branch in case further progress has been made since the repo was forked
|
||||
5. Create a Pull Request to pull your branch into the appropriate branch in the main repository.
|
||||
6. Your Pull Request will be reviewed by our team and evaluated for inclusion into the main repository.
|
||||
|
||||
Next: [Get started](~/docs/Get-started.md)
|
||||
4
docs/toc.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
- name: Docs
|
||||
href: docs/
|
||||
- name: API
|
||||
href: api/
|
||||
@@ -1,6 +1,6 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<Version>2.4.0-local</Version>
|
||||
<Version>2.19.4-local</Version>
|
||||
<InformationalVersion>$(Version)</InformationalVersion>
|
||||
<Authors>PepperDash Technology</Authors>
|
||||
<Company>PepperDash Technology</Company>
|
||||
@@ -13,6 +13,8 @@
|
||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
|
||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\LICENSE.md" Pack="true" PackagePath=""/>
|
||||
|
||||
@@ -23,23 +23,32 @@
|
||||
<FileName>$(TargetDir)$(TargetName).$(Version).$(TargetFramework).cpz</FileName>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="DeleteCLZ" BeforeTargets="PreBuildEvent" Condition="$(ProjectType) == 'Library' And $(TargetDir) != '' And Exists($(FileName))">
|
||||
<Delete Files="$(TargetDir)$(TargetName).$(Version).$(TargetFramework).clz">
|
||||
<Target Name="DeleteCLZ" BeforeTargets="CoreBuild" Condition="$(ProjectType) == 'Library' And $(TargetDir) != ''">
|
||||
<ItemGroup>
|
||||
<OldCLZFiles Include="$(TargetDir)$(TargetName).*.$(TargetFramework).clz" />
|
||||
</ItemGroup>
|
||||
<Delete Files="@(OldCLZFiles)" Condition="@(OldCLZFiles) != ''">
|
||||
<Output TaskParameter="DeletedFiles" ItemName="DeletedList"/>
|
||||
</Delete>
|
||||
<Message Text="Deleted files: '@(DeletedList)'" />
|
||||
<Message Text="Deleted old CLZ files: '@(DeletedList)'" Condition="@(DeletedList) != ''" />
|
||||
</Target>
|
||||
<Target Name="DeleteCPZ" BeforeTargets="PreBuildEvent" Condition="$(ProjectType) == 'Program' And $(TargetDir) != '' And Exists($(FileName))">
|
||||
<Delete Files="$(TargetDir)$(TargetName).$(Version).$(TargetFramework).cpz">
|
||||
<Target Name="DeleteCPZ" BeforeTargets="CoreBuild" Condition="$(ProjectType) == 'Program' And $(TargetDir) != ''">
|
||||
<ItemGroup>
|
||||
<OldCPZFiles Include="$(TargetDir)$(TargetName).*.$(TargetFramework).cpz" />
|
||||
</ItemGroup>
|
||||
<Delete Files="@(OldCPZFiles)" Condition="@(OldCPZFiles) != ''">
|
||||
<Output TaskParameter="DeletedFiles" ItemName="DeletedList"/>
|
||||
</Delete>
|
||||
<Message Text="Deleted files: '@(DeletedList)'" />
|
||||
<Message Text="Deleted old CPZ files: '@(DeletedList)'" Condition="@(DeletedList) != ''" />
|
||||
</Target>
|
||||
<Target Name="DeleteCPLZ" BeforeTargets="PreBuildEvent" Condition="$(ProjectType) == 'ProgramLibrary' And $(TargetDir) != '' And Exists($(FileName))">
|
||||
<Delete Files="$(TargetDir)$(TargetName).$(Version).$(TargetFramework).cplz">
|
||||
<Target Name="DeleteCPLZ" BeforeTargets="CoreBuild" Condition="$(ProjectType) == 'ProgramLibrary' And $(TargetDir) != ''">
|
||||
<ItemGroup>
|
||||
<OldCPLZFiles Include="$(TargetDir)$(TargetName).*.$(TargetFramework).cplz" />
|
||||
</ItemGroup>
|
||||
<Delete Files="@(OldCPLZFiles)" Condition="@(OldCPLZFiles) != ''">
|
||||
<Output TaskParameter="DeletedFiles" ItemName="DeletedList"/>
|
||||
</Delete>
|
||||
<Message Text="Deleted files: '@(DeletedList)'" />
|
||||
<Message Text="Deleted old CPLZ files: '@(DeletedList)'" Condition="@(DeletedList) != ''" />
|
||||
</Target>
|
||||
|
||||
<Target Name="CreateCPLZ" AfterTargets="Build" Condition="$(ProjectType) == 'ProgramLibrary' And $(TargetDir) != ''" DependsOnTargets="DeleteCPLZ">
|
||||
|
||||
43
src/PepperDash.Core/ComTextHelper.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace PepperDash.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper class for formatting communication text and byte data for debugging purposes.
|
||||
/// </summary>
|
||||
public class ComTextHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets escaped text for a byte array
|
||||
/// </summary>
|
||||
/// <param name="bytes"></param>
|
||||
/// <returns>string with all bytes escaped</returns>
|
||||
public static string GetEscapedText(byte[] bytes)
|
||||
{
|
||||
return string.Concat(bytes.Select(b => string.Format(@"[{0:X2}]", (int)b)).ToArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets escaped text for a string
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
/// <returns>string with all bytes escaped</returns>
|
||||
public static string GetEscapedText(string text)
|
||||
{
|
||||
var bytes = Encoding.GetEncoding(28591).GetBytes(text);
|
||||
return string.Concat(bytes.Select(b => string.Format(@"[{0:X2}]", (int)b)).ToArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets debug text for a string
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
/// <returns>string with all non-printable characters escaped</returns>
|
||||
public static string GetDebugText(string text)
|
||||
{
|
||||
return Regex.Replace(text, @"[^\u0020-\u007E]", a => GetEscapedText(a.Value));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,10 +84,9 @@ namespace PepperDash.Core
|
||||
port.TextReceived += Port_TextReceivedStringDelimiter;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disconnects this gather from the Port's TextReceived event. This will not fire LineReceived
|
||||
/// after the this call.
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Stop method
|
||||
/// </summary>
|
||||
public void Stop()
|
||||
{
|
||||
Port.TextReceived -= Port_TextReceived;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
@@ -23,7 +22,7 @@ namespace PepperDash.Core
|
||||
private CTimer DebugExpiryPeriod;
|
||||
|
||||
/// <summary>
|
||||
/// The current debug setting
|
||||
/// Gets or sets the DebugSetting
|
||||
/// </summary>
|
||||
public eStreamDebuggingSetting DebugSetting { get; private set; }
|
||||
|
||||
@@ -37,14 +36,14 @@ namespace PepperDash.Core
|
||||
{
|
||||
get
|
||||
{
|
||||
return _DebugTimeoutInMs/60000;
|
||||
return _DebugTimeoutInMs / 60000;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that receive stream debugging is enabled
|
||||
/// Gets or sets the RxStreamDebuggingIsEnabled
|
||||
/// </summary>
|
||||
public bool RxStreamDebuggingIsEnabled{ get; private set; }
|
||||
public bool RxStreamDebuggingIsEnabled { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that transmit stream debugging is enabled
|
||||
@@ -65,6 +64,9 @@ 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)
|
||||
@@ -81,6 +83,9 @@ 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)
|
||||
@@ -102,7 +107,7 @@ namespace PepperDash.Core
|
||||
TxStreamDebuggingIsEnabled = true;
|
||||
|
||||
Debug.SetDeviceDebugSettings(ParentDeviceKey, setting);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -130,48 +135,4 @@ namespace PepperDash.Core
|
||||
DebugExpiryPeriod = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The available settings for stream debugging
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum eStreamDebuggingSetting
|
||||
{
|
||||
/// <summary>
|
||||
/// Debug off
|
||||
/// </summary>
|
||||
Off = 0,
|
||||
/// <summary>
|
||||
/// Debug received data
|
||||
/// </summary>
|
||||
Rx = 1,
|
||||
/// <summary>
|
||||
/// Debug transmitted data
|
||||
/// </summary>
|
||||
Tx = 2,
|
||||
/// <summary>
|
||||
/// Debug both received and transmitted data
|
||||
/// </summary>
|
||||
Both = Rx | Tx
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The available settings for stream debugging response types
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum eStreamDebuggingDataTypeSettings
|
||||
{
|
||||
/// <summary>
|
||||
/// Debug data in byte format
|
||||
/// </summary>
|
||||
Bytes = 0,
|
||||
/// <summary>
|
||||
/// Debug data in text format
|
||||
/// </summary>
|
||||
Text = 1,
|
||||
/// <summary>
|
||||
/// Debug data in both byte and text formats
|
||||
/// </summary>
|
||||
Both = Bytes | Text,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ using Newtonsoft.Json.Converters;
|
||||
namespace PepperDash.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Config properties that indicate how to communicate with a device for control
|
||||
/// Represents a ControlPropertiesConfig
|
||||
/// </summary>
|
||||
public class ControlPropertiesConfig
|
||||
{
|
||||
|
||||
@@ -29,9 +29,9 @@ namespace PepperDash.Core
|
||||
/// </summary>
|
||||
public class GenericSocketStatusChageEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the Client
|
||||
/// </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; }
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Port on server
|
||||
/// Gets or sets the Port
|
||||
/// </summary>
|
||||
public int Port { get; set; }
|
||||
|
||||
@@ -149,7 +149,7 @@ namespace PepperDash.Core
|
||||
public string ConnectionFailure { get { return ClientStatus.ToString(); } }
|
||||
|
||||
/// <summary>
|
||||
/// bool to track if auto reconnect should be set on the socket
|
||||
/// Gets or sets the AutoReconnect
|
||||
/// </summary>
|
||||
public bool AutoReconnect { get; set; }
|
||||
|
||||
@@ -188,7 +188,7 @@ namespace PepperDash.Core
|
||||
#region GenericSecureTcpIpClient properties
|
||||
|
||||
/// <summary>
|
||||
/// Bool to show whether the server requires a preshared key. This is used in the DynamicTCPServer class
|
||||
/// Gets or sets the SharedKeyRequired
|
||||
/// </summary>
|
||||
public bool SharedKeyRequired { get; set; }
|
||||
|
||||
@@ -207,7 +207,7 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// Gets or sets the SharedKey
|
||||
/// </summary>
|
||||
public string SharedKey { get; set; }
|
||||
|
||||
@@ -222,7 +222,7 @@ namespace PepperDash.Core
|
||||
bool IsTryingToConnect;
|
||||
|
||||
/// <summary>
|
||||
/// Bool showing if socket is ready for communication after shared key exchange
|
||||
/// Gets or sets the IsReadyForCommunication
|
||||
/// </summary>
|
||||
public bool IsReadyForCommunication { get; set; }
|
||||
|
||||
@@ -342,7 +342,7 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Just to help S+ set the key
|
||||
/// Initialize method
|
||||
/// </summary>
|
||||
public void Initialize(string key)
|
||||
{
|
||||
@@ -421,6 +421,9 @@ namespace PepperDash.Core
|
||||
/// Deactivate the client
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <summary>
|
||||
/// Deactivate method
|
||||
/// </summary>
|
||||
public override bool Deactivate()
|
||||
{
|
||||
if (_client != null)
|
||||
@@ -432,7 +435,7 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Connect Method. Will return if already connected. Will write errors if missing address, port, or unique key/name.
|
||||
/// Connect method
|
||||
/// </summary>
|
||||
public void Connect()
|
||||
{
|
||||
@@ -563,7 +566,7 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Disconnect method
|
||||
/// </summary>
|
||||
public void Disconnect()
|
||||
{
|
||||
@@ -586,7 +589,7 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Does the actual disconnect business
|
||||
/// DisconnectClient method
|
||||
/// </summary>
|
||||
public void DisconnectClient()
|
||||
{
|
||||
@@ -846,7 +849,7 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// General send method
|
||||
/// SendText method
|
||||
/// </summary>
|
||||
public void SendText(string text)
|
||||
{
|
||||
@@ -875,7 +878,7 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// SendBytes method
|
||||
/// </summary>
|
||||
public void SendBytes(byte[] bytes)
|
||||
{
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace PepperDash.Core
|
||||
public string Hostname { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Port on server
|
||||
/// Gets or sets the Port
|
||||
/// </summary>
|
||||
public int Port { get; set; }
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// Gets or sets the SharedKey
|
||||
/// </summary>
|
||||
public string SharedKey { get; set; }
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace PepperDash.Core
|
||||
private bool WaitingForSharedKeyResponse { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Defaults to 2000
|
||||
/// Gets or sets the BufferSize
|
||||
/// </summary>
|
||||
public int BufferSize { get; set; }
|
||||
|
||||
@@ -336,7 +336,7 @@ namespace PepperDash.Core
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Just to help S+ set the key
|
||||
/// Initialize method
|
||||
/// </summary>
|
||||
public void Initialize(string key)
|
||||
{
|
||||
@@ -395,7 +395,7 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Connect Method. Will return if already connected. Will write errors if missing address, port, or unique key/name.
|
||||
/// Connect method
|
||||
/// </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>
|
||||
/// General send method
|
||||
/// SendText method
|
||||
/// </summary>
|
||||
public void SendText(string text)
|
||||
{
|
||||
@@ -833,7 +833,7 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// SendBytes method
|
||||
/// </summary>
|
||||
public void SendBytes(byte[] bytes)
|
||||
{
|
||||
|
||||
@@ -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>
|
||||
/// 3 by default
|
||||
/// Gets or sets the MonitorClientMaxFailureCount
|
||||
/// </summary>
|
||||
public int MonitorClientMaxFailureCount { get; set; }
|
||||
|
||||
@@ -190,7 +190,7 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Port Server should listen on
|
||||
/// Gets or sets the Port
|
||||
/// </summary>
|
||||
public int Port { get; set; }
|
||||
|
||||
@@ -223,8 +223,7 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// Gets or sets the SharedKey
|
||||
/// </summary>
|
||||
public string SharedKey { get; set; }
|
||||
|
||||
@@ -248,7 +247,7 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Milliseconds before server expects another heartbeat. Set by property HeartbeatRequiredIntervalInSeconds which is driven from S+
|
||||
/// Gets or sets the HeartbeatRequiredIntervalMs
|
||||
/// </summary>
|
||||
public int HeartbeatRequiredIntervalMs { get; set; }
|
||||
|
||||
@@ -258,7 +257,7 @@ namespace PepperDash.Core
|
||||
public ushort HeartbeatRequiredIntervalInSeconds { set { HeartbeatRequiredIntervalMs = (value * 1000); } }
|
||||
|
||||
/// <summary>
|
||||
/// String to Match for heartbeat. If null or empty any string will reset heartbeat timer
|
||||
/// Gets or sets the HeartbeatStringToMatch
|
||||
/// </summary>
|
||||
public string HeartbeatStringToMatch { get; set; }
|
||||
|
||||
@@ -276,7 +275,7 @@ namespace PepperDash.Core
|
||||
public List<uint> ConnectedClientsIndexes = new List<uint>();
|
||||
|
||||
/// <summary>
|
||||
/// Defaults to 2000
|
||||
/// Gets or sets the BufferSize
|
||||
/// </summary>
|
||||
public int BufferSize { get; set; }
|
||||
|
||||
@@ -339,7 +338,7 @@ namespace PepperDash.Core
|
||||
|
||||
#region Methods - Server Actions
|
||||
/// <summary>
|
||||
/// Disconnects all clients and stops the server
|
||||
/// KillServer method
|
||||
/// </summary>
|
||||
public void KillServer()
|
||||
{
|
||||
@@ -356,6 +355,9 @@ 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;
|
||||
@@ -395,7 +397,7 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start listening on the specified port
|
||||
/// Listen method
|
||||
/// </summary>
|
||||
public void Listen()
|
||||
{
|
||||
@@ -453,7 +455,7 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stop Listeneing
|
||||
/// StopListening method
|
||||
/// </summary>
|
||||
public void StopListening()
|
||||
{
|
||||
@@ -478,6 +480,9 @@ namespace PepperDash.Core
|
||||
/// Disconnects Client
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <summary>
|
||||
/// DisconnectClient method
|
||||
/// </summary>
|
||||
public void DisconnectClient(uint client)
|
||||
{
|
||||
try
|
||||
@@ -491,7 +496,7 @@ namespace PepperDash.Core
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Disconnect All Clients
|
||||
/// DisconnectAllClientsForShutdown method
|
||||
/// </summary>
|
||||
public void DisconnectAllClientsForShutdown()
|
||||
{
|
||||
@@ -533,6 +538,9 @@ 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();
|
||||
@@ -566,6 +574,9 @@ namespace PepperDash.Core
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
/// <param name="clientIndex"></param>
|
||||
/// <summary>
|
||||
/// SendTextToClient method
|
||||
/// </summary>
|
||||
public void SendTextToClient(string text, uint clientIndex)
|
||||
{
|
||||
try
|
||||
@@ -634,6 +645,9 @@ 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);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using Crestron.SimplSharp;
|
||||
@@ -11,11 +12,12 @@ using Renci.SshNet.Common;
|
||||
namespace PepperDash.Core
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// SSH Client
|
||||
/// </summary>
|
||||
public class GenericSshClient : Device, ISocketStatusWithStreamDebugging, IAutoReconnect
|
||||
{
|
||||
private const string SPlusKey = "Uninitialized SshClient";
|
||||
|
||||
/// <summary>
|
||||
/// Object to enable stream debugging
|
||||
/// </summary>
|
||||
@@ -36,13 +38,8 @@ namespace PepperDash.Core
|
||||
/// </summary>
|
||||
public event EventHandler<GenericSocketStatusChageEventArgs> ConnectionChange;
|
||||
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
//public event GenericSocketStatusChangeEventDelegate SocketStatusChange;
|
||||
|
||||
/// <summary>
|
||||
/// Address of server
|
||||
/// Gets or sets the Hostname
|
||||
/// </summary>
|
||||
public string Hostname { get; set; }
|
||||
|
||||
@@ -52,12 +49,12 @@ namespace PepperDash.Core
|
||||
public int Port { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Username for server
|
||||
/// Gets or sets the Username
|
||||
/// </summary>
|
||||
public string Username { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// And... Password for server. That was worth documenting!
|
||||
/// Gets or sets the Password
|
||||
/// </summary>
|
||||
public string Password { get; set; }
|
||||
|
||||
@@ -67,7 +64,7 @@ namespace PepperDash.Core
|
||||
public bool IsConnected
|
||||
{
|
||||
// returns false if no client or not connected
|
||||
get { return Client != null && ClientStatus == SocketStatus.SOCKET_STATUS_CONNECTED; }
|
||||
get { return client != null && ClientStatus == SocketStatus.SOCKET_STATUS_CONNECTED; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -79,20 +76,30 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Socket status change event
|
||||
/// </summary>
|
||||
public SocketStatus ClientStatus
|
||||
{
|
||||
get { return _ClientStatus; }
|
||||
get { lock (_stateLock) { return _ClientStatus; } }
|
||||
private set
|
||||
{
|
||||
if (_ClientStatus == value)
|
||||
return;
|
||||
_ClientStatus = value;
|
||||
OnConnectionChange();
|
||||
bool shouldFireEvent = false;
|
||||
lock (_stateLock)
|
||||
{
|
||||
if (_ClientStatus != value)
|
||||
{
|
||||
_ClientStatus = value;
|
||||
shouldFireEvent = true;
|
||||
}
|
||||
}
|
||||
// Fire event outside lock to avoid deadlock
|
||||
if (shouldFireEvent)
|
||||
OnConnectionChange();
|
||||
}
|
||||
}
|
||||
SocketStatus _ClientStatus;
|
||||
|
||||
private SocketStatus _ClientStatus;
|
||||
private bool _ConnectEnabled;
|
||||
|
||||
/// <summary>
|
||||
/// Contains the familiar Simpl analog status values. This drives the ConnectionChange event
|
||||
@@ -100,7 +107,7 @@ namespace PepperDash.Core
|
||||
/// </summary>
|
||||
public ushort UStatus
|
||||
{
|
||||
get { return (ushort)_ClientStatus; }
|
||||
get { lock (_stateLock) { return (ushort)_ClientStatus; } }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -111,7 +118,11 @@ namespace PepperDash.Core
|
||||
/// <summary>
|
||||
/// Will be set and unset by connect and disconnect only
|
||||
/// </summary>
|
||||
public bool ConnectEnabled { get; private set; }
|
||||
public bool ConnectEnabled
|
||||
{
|
||||
get { lock (_stateLock) { return _ConnectEnabled; } }
|
||||
private set { lock (_stateLock) { _ConnectEnabled = value; } }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// S+ helper for AutoReconnect
|
||||
@@ -123,22 +134,29 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Millisecond value, determines the timeout period in between reconnect attempts.
|
||||
/// Set to 5000 by default
|
||||
/// Gets or sets the AutoReconnectIntervalMs
|
||||
/// </summary>
|
||||
public int AutoReconnectIntervalMs { get; set; }
|
||||
|
||||
SshClient Client;
|
||||
private SshClient client;
|
||||
|
||||
ShellStream TheStream;
|
||||
private ShellStream shellStream;
|
||||
|
||||
CTimer ReconnectTimer;
|
||||
private readonly Timer reconnectTimer;
|
||||
|
||||
//Lock object to prevent simulatneous connect/disconnect operations
|
||||
//private CCriticalSection connectLock = new CCriticalSection();
|
||||
private SemaphoreSlim connectLock = new SemaphoreSlim(1);
|
||||
private readonly SemaphoreSlim connectLock = new SemaphoreSlim(1);
|
||||
|
||||
private bool DisconnectLogged = false;
|
||||
// Thread-safety lock for state changes
|
||||
private readonly object _stateLock = new object();
|
||||
|
||||
private bool disconnectLogged = false;
|
||||
|
||||
/// <summary>
|
||||
/// When true, turns off echo for the SSH session
|
||||
/// </summary>
|
||||
public bool DisableEcho { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Typical constructor.
|
||||
@@ -147,58 +165,58 @@ 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)
|
||||
reconnectTimer = new Timer(o =>
|
||||
{
|
||||
if (ConnectEnabled) // Now thread-safe property access
|
||||
{
|
||||
Connect();
|
||||
}
|
||||
}, System.Threading.Timeout.Infinite);
|
||||
}
|
||||
}, null, 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 =>
|
||||
reconnectTimer = new Timer(o =>
|
||||
{
|
||||
if (ConnectEnabled)
|
||||
if (ConnectEnabled) // Now thread-safe property access
|
||||
{
|
||||
Connect();
|
||||
}
|
||||
}, System.Threading.Timeout.Infinite);
|
||||
}
|
||||
}, null, System.Threading.Timeout.Infinite, 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>
|
||||
private void CrestronEnvironment_ProgramStatusEventHandler(eProgramStatusEventType programEventType)
|
||||
{
|
||||
if (programEventType == eProgramStatusEventType.Stopping)
|
||||
{
|
||||
if (client != null)
|
||||
{
|
||||
this.LogDebug("Program stopping. Closing connection");
|
||||
Disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Connect to the server, using the provided properties.
|
||||
/// Connect method
|
||||
/// </summary>
|
||||
public void Connect()
|
||||
{
|
||||
@@ -224,13 +242,10 @@ namespace PepperDash.Core
|
||||
this.LogDebug("Attempting connect");
|
||||
|
||||
// Cancel reconnect if running.
|
||||
if (ReconnectTimer != null)
|
||||
{
|
||||
ReconnectTimer.Stop();
|
||||
}
|
||||
StopReconnectTimer();
|
||||
|
||||
// Cleanup the old client if it already exists
|
||||
if (Client != null)
|
||||
if (client != null)
|
||||
{
|
||||
this.LogDebug("Cleaning up disconnected client");
|
||||
KillClient(SocketStatus.SOCKET_STATUS_BROKEN_LOCALLY);
|
||||
@@ -243,77 +258,90 @@ namespace PepperDash.Core
|
||||
|
||||
this.LogDebug("Creating new SshClient");
|
||||
ConnectionInfo connectionInfo = new ConnectionInfo(Hostname, Port, Username, pauth, kauth);
|
||||
Client = new SshClient(connectionInfo);
|
||||
Client.ErrorOccurred += Client_ErrorOccurred;
|
||||
client = new SshClient(connectionInfo);
|
||||
client.ErrorOccurred += Client_ErrorOccurred;
|
||||
|
||||
//Attempt to connect
|
||||
ClientStatus = SocketStatus.SOCKET_STATUS_WAITING;
|
||||
try
|
||||
{
|
||||
Client.Connect();
|
||||
TheStream = Client.CreateShellStream("PDTShell", 0, 0, 0, 0, 65534);
|
||||
if (TheStream.DataAvailable)
|
||||
client.Connect();
|
||||
|
||||
var modes = new Dictionary<TerminalModes, uint>();
|
||||
|
||||
if (DisableEcho)
|
||||
{
|
||||
modes.Add(TerminalModes.ECHO, 0);
|
||||
}
|
||||
|
||||
shellStream = client.CreateShellStream("PDTShell", 0, 0, 0, 0, 65534, modes);
|
||||
if (shellStream.DataAvailable)
|
||||
{
|
||||
// empty the buffer if there is data
|
||||
string str = TheStream.Read();
|
||||
shellStream.Read();
|
||||
}
|
||||
TheStream.DataReceived += Stream_DataReceived;
|
||||
shellStream.DataReceived += Stream_DataReceived;
|
||||
this.LogInformation("Connected");
|
||||
ClientStatus = SocketStatus.SOCKET_STATUS_CONNECTED;
|
||||
DisconnectLogged = false;
|
||||
disconnectLogged = false;
|
||||
}
|
||||
catch (SshConnectionException e)
|
||||
{
|
||||
var ie = e.InnerException; // The details are inside!!
|
||||
var errorLogLevel = DisconnectLogged == true ? Debug.ErrorLogLevel.None : Debug.ErrorLogLevel.Error;
|
||||
|
||||
if (ie is SocketException)
|
||||
{
|
||||
this.LogException(ie, "CONNECTION failure: Cannot reach host");
|
||||
this.LogError("CONNECTION failure: Cannot reach host");
|
||||
this.LogVerbose(ie, "Exception details: ");
|
||||
}
|
||||
|
||||
if (ie is System.Net.Sockets.SocketException socketException)
|
||||
{
|
||||
this.LogException(ie, "Connection failure: Cannot reach {host} on {port}",
|
||||
this.LogError("Connection failure: Cannot reach {host} on {port}",
|
||||
Hostname, Port);
|
||||
this.LogVerbose(socketException, "SocketException details: ");
|
||||
}
|
||||
if (ie is SshAuthenticationException)
|
||||
{
|
||||
this.LogException(ie, "Authentication failure for username {userName}", Username);
|
||||
this.LogError("Authentication failure for username {userName}", Username);
|
||||
this.LogVerbose(ie, "AuthenticationException details: ");
|
||||
}
|
||||
else
|
||||
this.LogException(ie, "Error on connect");
|
||||
{
|
||||
this.LogError("Error on connect: {error}", ie.Message);
|
||||
this.LogVerbose(ie, "Exception details: ");
|
||||
}
|
||||
|
||||
DisconnectLogged = true;
|
||||
disconnectLogged = true;
|
||||
KillClient(SocketStatus.SOCKET_STATUS_CONNECT_FAILED);
|
||||
if (AutoReconnect)
|
||||
{
|
||||
this.LogDebug("Checking autoreconnect: {autoReconnect}, {autoReconnectInterval}ms", AutoReconnect, AutoReconnectIntervalMs);
|
||||
ReconnectTimer.Reset(AutoReconnectIntervalMs);
|
||||
StartReconnectTimer();
|
||||
}
|
||||
}
|
||||
catch(SshOperationTimeoutException ex)
|
||||
catch (SshOperationTimeoutException ex)
|
||||
{
|
||||
this.LogWarning("Connection attempt timed out: {message}", ex.Message);
|
||||
|
||||
DisconnectLogged = true;
|
||||
disconnectLogged = true;
|
||||
KillClient(SocketStatus.SOCKET_STATUS_CONNECT_FAILED);
|
||||
if (AutoReconnect)
|
||||
{
|
||||
this.LogDebug("Checking autoreconnect: {0}, {1}ms", AutoReconnect, AutoReconnectIntervalMs);
|
||||
ReconnectTimer.Reset(AutoReconnectIntervalMs);
|
||||
StartReconnectTimer();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
var errorLogLevel = DisconnectLogged == true ? Debug.ErrorLogLevel.None : Debug.ErrorLogLevel.Error;
|
||||
this.LogException(e, "Unhandled exception on connect");
|
||||
DisconnectLogged = true;
|
||||
this.LogError("Unhandled exception on connect: {error}", e.Message);
|
||||
this.LogVerbose(e, "Exception details: ");
|
||||
disconnectLogged = true;
|
||||
KillClient(SocketStatus.SOCKET_STATUS_CONNECT_FAILED);
|
||||
if (AutoReconnect)
|
||||
{
|
||||
this.LogDebug("Checking autoreconnect: {0}, {1}ms", AutoReconnect, AutoReconnectIntervalMs);
|
||||
ReconnectTimer.Reset(AutoReconnectIntervalMs);
|
||||
StartReconnectTimer();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -324,18 +352,14 @@ namespace PepperDash.Core
|
||||
}
|
||||
}
|
||||
|
||||
/// <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;
|
||||
}
|
||||
/// <summary>
|
||||
/// Disconnect method
|
||||
/// </summary>
|
||||
public void Disconnect()
|
||||
{
|
||||
ConnectEnabled = false;
|
||||
// Stop trying reconnects, if we are
|
||||
StopReconnectTimer();
|
||||
|
||||
KillClient(SocketStatus.SOCKET_STATUS_BROKEN_LOCALLY);
|
||||
}
|
||||
@@ -349,35 +373,35 @@ namespace PepperDash.Core
|
||||
|
||||
try
|
||||
{
|
||||
if (Client != null)
|
||||
if (client != null)
|
||||
{
|
||||
Client.ErrorOccurred -= Client_ErrorOccurred;
|
||||
Client.Disconnect();
|
||||
Client.Dispose();
|
||||
Client = null;
|
||||
client.ErrorOccurred -= Client_ErrorOccurred;
|
||||
client.Disconnect();
|
||||
client.Dispose();
|
||||
client = null;
|
||||
ClientStatus = status;
|
||||
this.LogDebug("Disconnected");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.LogException(ex,"Exception in Kill Client");
|
||||
this.LogException(ex, "Exception in Kill Client");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Kills the stream
|
||||
/// </summary>
|
||||
void KillStream()
|
||||
{
|
||||
private void KillStream()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (TheStream != null)
|
||||
if (shellStream != null)
|
||||
{
|
||||
TheStream.DataReceived -= Stream_DataReceived;
|
||||
TheStream.Close();
|
||||
TheStream.Dispose();
|
||||
TheStream = null;
|
||||
shellStream.DataReceived -= Stream_DataReceived;
|
||||
shellStream.Close();
|
||||
shellStream.Dispose();
|
||||
shellStream = null;
|
||||
this.LogDebug("Disconnected stream");
|
||||
}
|
||||
}
|
||||
@@ -385,59 +409,55 @@ 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>
|
||||
private 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>
|
||||
private 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);
|
||||
}
|
||||
this.PrintReceivedBytes(bytes);
|
||||
bytesHandler(this, new GenericCommMethodReceiveBytesArgs(bytes));
|
||||
}
|
||||
|
||||
var textHandler = TextReceived;
|
||||
if (textHandler != null)
|
||||
{
|
||||
if (StreamDebugging.RxStreamDebuggingIsEnabled)
|
||||
this.LogInformation("Received: '{0}'", ComTextHelper.GetDebugText(response));
|
||||
}
|
||||
|
||||
var textHandler = TextReceived;
|
||||
if (textHandler != null)
|
||||
{
|
||||
this.PrintReceivedText(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>
|
||||
private void Client_ErrorOccurred(object sender, ExceptionEventArgs e)
|
||||
{
|
||||
CrestronInvoke.BeginInvoke(o =>
|
||||
{
|
||||
if (e.Exception is SshConnectionException || e.Exception is System.Net.Sockets.SocketException)
|
||||
@@ -456,7 +476,7 @@ namespace PepperDash.Core
|
||||
if (AutoReconnect && ConnectEnabled)
|
||||
{
|
||||
this.LogDebug("Checking autoreconnect: {0}, {1}ms", AutoReconnect, AutoReconnectIntervalMs);
|
||||
ReconnectTimer.Reset(AutoReconnectIntervalMs);
|
||||
StartReconnectTimer();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -464,66 +484,60 @@ namespace PepperDash.Core
|
||||
/// <summary>
|
||||
/// Helper for ConnectionChange event
|
||||
/// </summary>
|
||||
void OnConnectionChange()
|
||||
private void OnConnectionChange()
|
||||
{
|
||||
if (ConnectionChange != null)
|
||||
ConnectionChange(this, new GenericSocketStatusChageEventArgs(this));
|
||||
ConnectionChange?.Invoke(this, new GenericSocketStatusChageEventArgs(this));
|
||||
}
|
||||
|
||||
#region IBasicCommunication Members
|
||||
|
||||
/// <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)
|
||||
/// <summary>
|
||||
/// Sends text to the server
|
||||
/// </summary>
|
||||
/// <param name="text">The text to send</param>
|
||||
public void SendText(string text)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.LogError("ObjectDisposedException sending '{message}'. Restarting connection...", text.Trim());
|
||||
if (client != null && shellStream != null && IsConnected)
|
||||
{
|
||||
this.PrintSentText(text);
|
||||
|
||||
shellStream.Write(text);
|
||||
shellStream.Flush();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.LogDebug("Client is null or disconnected. Cannot Send Text");
|
||||
}
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
this.LogError("ObjectDisposedException sending '{message}'. Restarting connection...", text.Trim());
|
||||
|
||||
KillClient(SocketStatus.SOCKET_STATUS_CONNECT_FAILED);
|
||||
ReconnectTimer.Reset();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
StartReconnectTimer();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.LogException(ex, "Exception sending text: '{message}'", text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends Bytes to the server
|
||||
/// </summary>
|
||||
/// <param name="bytes"></param>
|
||||
public void SendBytes(byte[] bytes)
|
||||
{
|
||||
/// <param name="bytes">The bytes to send</param>
|
||||
public void SendBytes(byte[] bytes)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Client != null && TheStream != null && IsConnected)
|
||||
if (client != null && shellStream != null && IsConnected)
|
||||
{
|
||||
if (StreamDebugging.TxStreamDebuggingIsEnabled)
|
||||
this.LogInformation("Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes));
|
||||
this.PrintSentBytes(bytes);
|
||||
|
||||
TheStream.Write(bytes, 0, bytes.Length);
|
||||
TheStream.Flush();
|
||||
shellStream.Write(bytes, 0, bytes.Length);
|
||||
shellStream.Flush();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -535,43 +549,120 @@ namespace PepperDash.Core
|
||||
this.LogException(ex, "ObjectDisposedException sending {message}", ComTextHelper.GetEscapedText(bytes));
|
||||
|
||||
KillClient(SocketStatus.SOCKET_STATUS_CONNECT_FAILED);
|
||||
ReconnectTimer.Reset();
|
||||
StartReconnectTimer();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.LogException(ex, "Exception sending {message}", ComTextHelper.GetEscapedText(bytes));
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Safely starts the reconnect timer with exception handling
|
||||
/// </summary>
|
||||
private void StartReconnectTimer()
|
||||
{
|
||||
try
|
||||
{
|
||||
reconnectTimer?.Change(AutoReconnectIntervalMs, System.Threading.Timeout.Infinite);
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
// Timer was disposed, ignore
|
||||
this.LogDebug("Attempted to start timer but it was already disposed");
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************************************
|
||||
//*****************************************************************************************************
|
||||
/// <summary>
|
||||
/// Fired when connection changes
|
||||
/// </summary>
|
||||
public class SshConnectionChangeEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Safely stops the reconnect timer with exception handling
|
||||
/// </summary>
|
||||
private void StopReconnectTimer()
|
||||
{
|
||||
try
|
||||
{
|
||||
reconnectTimer?.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
// Timer was disposed, ignore
|
||||
this.LogDebug("Attempted to stop timer but it was already disposed");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deactivate method - properly dispose of resources
|
||||
/// </summary>
|
||||
public override bool Deactivate()
|
||||
{
|
||||
try
|
||||
{
|
||||
this.LogDebug("Deactivating SSH client - disposing resources");
|
||||
|
||||
// Stop trying reconnects
|
||||
ConnectEnabled = false;
|
||||
StopReconnectTimer();
|
||||
|
||||
// Disconnect and cleanup client
|
||||
KillClient(SocketStatus.SOCKET_STATUS_BROKEN_LOCALLY);
|
||||
|
||||
// Dispose timer
|
||||
try
|
||||
{
|
||||
reconnectTimer?.Dispose();
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
// Already disposed, ignore
|
||||
}
|
||||
|
||||
// Dispose semaphore
|
||||
try
|
||||
{
|
||||
connectLock?.Dispose();
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
// Already disposed, ignore
|
||||
}
|
||||
|
||||
return base.Deactivate();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.LogException(ex, "Error during SSH client deactivation");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//*****************************************************************************************************
|
||||
//*****************************************************************************************************
|
||||
/// <summary>
|
||||
/// Represents a SshConnectionChangeEventArgs
|
||||
/// </summary>
|
||||
public class SshConnectionChangeEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Connection State
|
||||
/// </summary>
|
||||
public bool IsConnected { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Connection Status represented as a ushort
|
||||
/// Gets or sets the UIsConnected
|
||||
/// </summary>
|
||||
public ushort UIsConnected { get { return (ushort)(Client.IsConnected ? 1 : 0); } }
|
||||
public ushort UIsConnected { get { return (ushort)(Client.IsConnected ? 1 : 0); } }
|
||||
|
||||
/// <summary>
|
||||
/// The client
|
||||
/// Gets or sets the Client
|
||||
/// </summary>
|
||||
public GenericSshClient Client { get; private set; }
|
||||
public GenericSshClient Client { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Socket Status as represented by
|
||||
/// Gets or sets the Status
|
||||
/// </summary>
|
||||
public ushort Status { get { return Client.UStatus; } }
|
||||
public ushort Status { get { return Client.UStatus; } }
|
||||
|
||||
/// <summary>
|
||||
/// S+ Constructor
|
||||
|
||||
@@ -19,47 +19,47 @@ namespace PepperDash.Core
|
||||
/// </summary>
|
||||
public CommunicationStreamDebugging StreamDebugging { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Fires when data is received from the server and returns it as a Byte array
|
||||
/// </summary>
|
||||
public event EventHandler<GenericCommMethodReceiveBytesArgs> BytesReceived;
|
||||
/// <summary>
|
||||
/// Fires when data is received from the server and returns it as a Byte array
|
||||
/// </summary>
|
||||
public event EventHandler<GenericCommMethodReceiveBytesArgs> BytesReceived;
|
||||
|
||||
/// <summary>
|
||||
/// Fires when data is received from the server and returns it as text
|
||||
/// </summary>
|
||||
public event EventHandler<GenericCommMethodReceiveTextArgs> TextReceived;
|
||||
/// <summary>
|
||||
/// Fires when data is received from the server and returns it as text
|
||||
/// </summary>
|
||||
public event EventHandler<GenericCommMethodReceiveTextArgs> TextReceived;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//public event GenericSocketStatusChangeEventDelegate SocketStatusChange;
|
||||
public event EventHandler<GenericSocketStatusChageEventArgs> ConnectionChange;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//public event GenericSocketStatusChangeEventDelegate SocketStatusChange;
|
||||
public event EventHandler<GenericSocketStatusChageEventArgs> ConnectionChange;
|
||||
|
||||
|
||||
private string _hostname;
|
||||
private string _hostname;
|
||||
|
||||
/// <summary>
|
||||
/// Address of server
|
||||
/// </summary>
|
||||
public string Hostname
|
||||
{
|
||||
get
|
||||
{
|
||||
return _hostname;
|
||||
}
|
||||
get
|
||||
{
|
||||
return _hostname;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_hostname = value;
|
||||
if (_client != null)
|
||||
{
|
||||
_client.AddressClientConnectedTo = _hostname;
|
||||
}
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
_hostname = value;
|
||||
if (_client != null)
|
||||
{
|
||||
_client.AddressClientConnectedTo = _hostname;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Port on server
|
||||
/// Gets or sets the Port
|
||||
/// </summary>
|
||||
public int Port { get; set; }
|
||||
|
||||
@@ -78,19 +78,19 @@ namespace PepperDash.Core
|
||||
/// </summary>
|
||||
public int BufferSize { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The actual client class
|
||||
/// </summary>
|
||||
private TCPClient _client;
|
||||
/// <summary>
|
||||
/// The actual client class
|
||||
/// </summary>
|
||||
private TCPClient _client;
|
||||
|
||||
/// <summary>
|
||||
/// Bool showing if socket is connected
|
||||
/// </summary>
|
||||
public bool IsConnected
|
||||
{
|
||||
get { return _client != null && _client.ClientStatus == SocketStatus.SOCKET_STATUS_CONNECTED; }
|
||||
/// <summary>
|
||||
/// Bool showing if socket is connected
|
||||
/// </summary>
|
||||
public bool IsConnected
|
||||
{
|
||||
get { return _client != null && _client.ClientStatus == SocketStatus.SOCKET_STATUS_CONNECTED; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// S+ helper for IsConnected
|
||||
/// </summary>
|
||||
@@ -99,15 +99,15 @@ namespace PepperDash.Core
|
||||
get { return (ushort)(IsConnected ? 1 : 0); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// _client socket status Read only
|
||||
/// </summary>
|
||||
public SocketStatus ClientStatus
|
||||
{
|
||||
get
|
||||
/// <summary>
|
||||
/// _client socket status Read only
|
||||
/// </summary>
|
||||
public SocketStatus ClientStatus
|
||||
{
|
||||
get
|
||||
{
|
||||
return _client == null ? SocketStatus.SOCKET_STATUS_NO_CONNECT : _client.ClientStatus;
|
||||
}
|
||||
return _client == null ? SocketStatus.SOCKET_STATUS_NO_CONNECT : _client.ClientStatus;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -119,26 +119,26 @@ namespace PepperDash.Core
|
||||
get { return (ushort)ClientStatus; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// Status text shows the message associated with socket status
|
||||
/// </summary>
|
||||
public string ClientStatusText { get { return ClientStatus.ToString(); } }
|
||||
/// </summary>
|
||||
public string ClientStatusText { get { return ClientStatus.ToString(); } }
|
||||
|
||||
/// <summary>
|
||||
/// Ushort representation of client status
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Ushort representation of client status
|
||||
/// </summary>
|
||||
[Obsolete]
|
||||
public ushort UClientStatus { get { return (ushort)ClientStatus; } }
|
||||
public ushort UClientStatus { get { return (ushort)ClientStatus; } }
|
||||
|
||||
/// <summary>
|
||||
/// Connection failure reason
|
||||
/// </summary>
|
||||
public string ConnectionFailure { get { return ClientStatus.ToString(); } }
|
||||
/// <summary>
|
||||
/// Connection failure reason
|
||||
/// </summary>
|
||||
public string ConnectionFailure { get { return ClientStatus.ToString(); } }
|
||||
|
||||
/// <summary>
|
||||
/// bool to track if auto reconnect should be set on the socket
|
||||
/// </summary>
|
||||
public bool AutoReconnect { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the AutoReconnect
|
||||
/// </summary>
|
||||
public bool AutoReconnect { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// S+ helper for AutoReconnect
|
||||
@@ -149,29 +149,29 @@ namespace PepperDash.Core
|
||||
set { AutoReconnect = value == 1; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Milliseconds to wait before attempting to reconnect. Defaults to 5000
|
||||
/// </summary>
|
||||
public int AutoReconnectIntervalMs { get; set; }
|
||||
/// <summary>
|
||||
/// Milliseconds to wait before attempting to reconnect. Defaults to 5000
|
||||
/// </summary>
|
||||
public int AutoReconnectIntervalMs { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Set only when the disconnect method is called
|
||||
/// </summary>
|
||||
bool DisconnectCalledByUser;
|
||||
/// <summary>
|
||||
/// Set only when the disconnect method is called
|
||||
/// </summary>
|
||||
bool DisconnectCalledByUser;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool Connected
|
||||
{
|
||||
get { return _client.ClientStatus == SocketStatus.SOCKET_STATUS_CONNECTED; }
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool Connected
|
||||
{
|
||||
get { return _client.ClientStatus == SocketStatus.SOCKET_STATUS_CONNECTED; }
|
||||
}
|
||||
|
||||
//Lock object to prevent simulatneous connect/disconnect operations
|
||||
private CCriticalSection connectLock = new CCriticalSection();
|
||||
|
||||
// private Timer for auto reconnect
|
||||
private CTimer RetryTimer;
|
||||
private CTimer RetryTimer;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
@@ -181,8 +181,8 @@ namespace PepperDash.Core
|
||||
/// <param name="port"></param>
|
||||
/// <param name="bufferSize"></param>
|
||||
public GenericTcpIpClient(string key, string address, int port, int bufferSize)
|
||||
: base(key)
|
||||
{
|
||||
: base(key)
|
||||
{
|
||||
StreamDebugging = new CommunicationStreamDebugging(key);
|
||||
CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
|
||||
AutoReconnectIntervalMs = 5000;
|
||||
@@ -218,21 +218,21 @@ namespace PepperDash.Core
|
||||
/// Default constructor for S+
|
||||
/// </summary>
|
||||
public GenericTcpIpClient()
|
||||
: base(SplusKey)
|
||||
: base(SplusKey)
|
||||
{
|
||||
StreamDebugging = new CommunicationStreamDebugging(SplusKey);
|
||||
CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
|
||||
AutoReconnectIntervalMs = 5000;
|
||||
CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
|
||||
AutoReconnectIntervalMs = 5000;
|
||||
BufferSize = 2000;
|
||||
|
||||
RetryTimer = new CTimer(o =>
|
||||
{
|
||||
Reconnect();
|
||||
}, Timeout.Infinite);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Just to help S+ set the key
|
||||
/// Initialize method
|
||||
/// </summary>
|
||||
public void Initialize(string key)
|
||||
{
|
||||
@@ -255,23 +255,26 @@ namespace PepperDash.Core
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override bool Deactivate()
|
||||
{
|
||||
/// <summary>
|
||||
/// Deactivate method
|
||||
/// </summary>
|
||||
public override bool Deactivate()
|
||||
{
|
||||
RetryTimer.Stop();
|
||||
RetryTimer.Dispose();
|
||||
if (_client != null)
|
||||
{
|
||||
_client.SocketStatusChange -= this.Client_SocketStatusChange;
|
||||
_client.SocketStatusChange -= this.Client_SocketStatusChange;
|
||||
DisconnectClient();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to connect to the server
|
||||
/// Connect method
|
||||
/// </summary>
|
||||
public void Connect()
|
||||
{
|
||||
public void Connect()
|
||||
{
|
||||
if (string.IsNullOrEmpty(Hostname))
|
||||
{
|
||||
Debug.Console(1, Debug.ErrorLogLevel.Warning, "GenericTcpIpClient '{0}': No address set", Key);
|
||||
@@ -307,7 +310,7 @@ namespace PepperDash.Core
|
||||
{
|
||||
connectLock.Leave();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Reconnect()
|
||||
{
|
||||
@@ -335,10 +338,10 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to disconnect the client
|
||||
/// Disconnect method
|
||||
/// </summary>
|
||||
public void Disconnect()
|
||||
{
|
||||
public void Disconnect()
|
||||
{
|
||||
try
|
||||
{
|
||||
connectLock.Enter();
|
||||
@@ -352,10 +355,10 @@ namespace PepperDash.Core
|
||||
{
|
||||
connectLock.Leave();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Does the actual disconnect business
|
||||
/// DisconnectClient method
|
||||
/// </summary>
|
||||
public void DisconnectClient()
|
||||
{
|
||||
@@ -372,7 +375,7 @@ namespace PepperDash.Core
|
||||
/// </summary>
|
||||
/// <param name="c"></param>
|
||||
void ConnectToServerCallback(TCPClient c)
|
||||
{
|
||||
{
|
||||
if (c.ClientStatus != SocketStatus.SOCKET_STATUS_CONNECTED)
|
||||
{
|
||||
Debug.Console(0, this, "Server connection result: {0}", c.ClientStatus);
|
||||
@@ -382,13 +385,13 @@ namespace PepperDash.Core
|
||||
{
|
||||
Debug.Console(1, this, "Server connection result: {0}", c.ClientStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disconnects, waits and attemtps to connect again
|
||||
/// </summary>
|
||||
void WaitAndTryReconnect()
|
||||
{
|
||||
{
|
||||
CrestronInvoke.BeginInvoke(o =>
|
||||
{
|
||||
try
|
||||
@@ -406,7 +409,7 @@ namespace PepperDash.Core
|
||||
connectLock.Leave();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recieves incoming data
|
||||
@@ -414,7 +417,7 @@ namespace PepperDash.Core
|
||||
/// <param name="client"></param>
|
||||
/// <param name="numBytes"></param>
|
||||
void Receive(TCPClient client, int numBytes)
|
||||
{
|
||||
{
|
||||
if (client != null)
|
||||
{
|
||||
if (numBytes > 0)
|
||||
@@ -423,10 +426,7 @@ namespace PepperDash.Core
|
||||
var bytesHandler = BytesReceived;
|
||||
if (bytesHandler != null)
|
||||
{
|
||||
if (StreamDebugging.RxStreamDebuggingIsEnabled)
|
||||
{
|
||||
Debug.Console(0, this, "Received {1} bytes: '{0}'", ComTextHelper.GetEscapedText(bytes), bytes.Length);
|
||||
}
|
||||
this.PrintReceivedBytes(bytes);
|
||||
bytesHandler(this, new GenericCommMethodReceiveBytesArgs(bytes));
|
||||
}
|
||||
var textHandler = TextReceived;
|
||||
@@ -434,55 +434,53 @@ namespace PepperDash.Core
|
||||
{
|
||||
var str = Encoding.GetEncoding(28591).GetString(bytes, 0, bytes.Length);
|
||||
|
||||
if (StreamDebugging.RxStreamDebuggingIsEnabled)
|
||||
{
|
||||
Debug.Console(0, this, "Received {1} characters of text: '{0}'", ComTextHelper.GetDebugText(str), str.Length);
|
||||
}
|
||||
this.PrintReceivedText(str);
|
||||
|
||||
textHandler(this, new GenericCommMethodReceiveTextArgs(str));
|
||||
}
|
||||
}
|
||||
}
|
||||
client.ReceiveDataAsync(Receive);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// General send method
|
||||
/// </summary>
|
||||
public void SendText(string text)
|
||||
{
|
||||
var bytes = Encoding.GetEncoding(28591).GetBytes(text);
|
||||
// Check debug level before processing byte array
|
||||
if (StreamDebugging.TxStreamDebuggingIsEnabled)
|
||||
Debug.Console(0, this, "Sending {0} characters of text: '{1}'", text.Length, ComTextHelper.GetDebugText(text));
|
||||
/// <summary>
|
||||
/// SendText method
|
||||
/// </summary>
|
||||
public void SendText(string text)
|
||||
{
|
||||
var bytes = Encoding.GetEncoding(28591).GetBytes(text);
|
||||
// Check debug level before processing byte array
|
||||
this.PrintSentText(text);
|
||||
if (_client != null)
|
||||
_client.SendData(bytes, bytes.Length);
|
||||
}
|
||||
_client.SendData(bytes, bytes.Length);
|
||||
}
|
||||
|
||||
/// <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 =>
|
||||
{
|
||||
var hex = s.Groups[1].Value;
|
||||
return ((char)Convert.ToByte(hex, 16)).ToString();
|
||||
});
|
||||
SendText(unescapedText);
|
||||
}
|
||||
/// <summary>
|
||||
/// SendEscapedText method
|
||||
/// </summary>
|
||||
public void SendEscapedText(string text)
|
||||
{
|
||||
var unescapedText = Regex.Replace(text, @"\\x([0-9a-fA-F][0-9a-fA-F])", s =>
|
||||
{
|
||||
var hex = s.Groups[1].Value;
|
||||
return ((char)Convert.ToByte(hex, 16)).ToString();
|
||||
});
|
||||
SendText(unescapedText);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends Bytes to the server
|
||||
/// </summary>
|
||||
/// <param name="bytes"></param>
|
||||
public void SendBytes(byte[] bytes)
|
||||
{
|
||||
if (StreamDebugging.TxStreamDebuggingIsEnabled)
|
||||
Debug.Console(0, this, "Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes));
|
||||
/// <summary>
|
||||
/// SendBytes method
|
||||
/// </summary>
|
||||
public void SendBytes(byte[] bytes)
|
||||
{
|
||||
this.PrintSentBytes(bytes);
|
||||
if (_client != null)
|
||||
_client.SendData(bytes, bytes.Length);
|
||||
}
|
||||
_client.SendData(bytes, bytes.Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Socket Status Change Handler
|
||||
@@ -490,7 +488,7 @@ namespace PepperDash.Core
|
||||
/// <param name="client"></param>
|
||||
/// <param name="clientSocketStatus"></param>
|
||||
void Client_SocketStatusChange(TCPClient client, SocketStatus clientSocketStatus)
|
||||
{
|
||||
{
|
||||
if (clientSocketStatus != SocketStatus.SOCKET_STATUS_CONNECTED)
|
||||
{
|
||||
Debug.Console(0, this, "Socket status change {0} ({1})", clientSocketStatus, ClientStatusText);
|
||||
@@ -499,68 +497,73 @@ namespace PepperDash.Core
|
||||
else
|
||||
{
|
||||
Debug.Console(1, this, "Socket status change {0} ({1})", clientSocketStatus, ClientStatusText);
|
||||
_client.ReceiveDataAsync(Receive);
|
||||
_client.ReceiveDataAsync(Receive);
|
||||
}
|
||||
|
||||
var handler = ConnectionChange;
|
||||
if (handler != null)
|
||||
ConnectionChange(this, new GenericSocketStatusChageEventArgs(this));
|
||||
}
|
||||
}
|
||||
var handler = ConnectionChange;
|
||||
if (handler != null)
|
||||
ConnectionChange(this, new GenericSocketStatusChageEventArgs(this));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configuration properties for TCP/SSH Connections
|
||||
/// Represents a TcpSshPropertiesConfig
|
||||
/// </summary>
|
||||
public class TcpSshPropertiesConfig
|
||||
{
|
||||
public class TcpSshPropertiesConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Address to connect to
|
||||
/// </summary>
|
||||
[JsonProperty(Required = Required.Always)]
|
||||
public string Address { get; set; }
|
||||
|
||||
public string Address { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Port to connect to
|
||||
/// </summary>
|
||||
[JsonProperty(Required = Required.Always)]
|
||||
public int Port { get; set; }
|
||||
|
||||
[JsonProperty(Required = Required.Always)]
|
||||
public int Port { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Username credential
|
||||
/// </summary>
|
||||
public string Username { get; set; }
|
||||
public string Username { get; set; }
|
||||
/// <summary>
|
||||
/// Passord credential
|
||||
/// Gets or sets the Password
|
||||
/// </summary>
|
||||
public string Password { get; set; }
|
||||
public string Password { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Defaults to 32768
|
||||
/// </summary>
|
||||
public int BufferSize { get; set; }
|
||||
/// <summary>
|
||||
/// Defaults to 32768
|
||||
/// </summary>
|
||||
public int BufferSize { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Defaults to true
|
||||
/// </summary>
|
||||
public bool AutoReconnect { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the AutoReconnect
|
||||
/// </summary>
|
||||
public bool AutoReconnect { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Defaults to 5000ms
|
||||
/// </summary>
|
||||
public int AutoReconnectIntervalMs { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the AutoReconnectIntervalMs
|
||||
/// </summary>
|
||||
public int AutoReconnectIntervalMs { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// When true, turns off echo for the SSH session
|
||||
/// </summary>
|
||||
[JsonProperty("disableSshEcho")]
|
||||
public bool DisableSshEcho { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
public TcpSshPropertiesConfig()
|
||||
{
|
||||
BufferSize = 32768;
|
||||
AutoReconnect = true;
|
||||
AutoReconnectIntervalMs = 5000;
|
||||
{
|
||||
BufferSize = 32768;
|
||||
AutoReconnect = true;
|
||||
AutoReconnectIntervalMs = 5000;
|
||||
Username = "";
|
||||
Password = "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DisableSshEcho = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace PepperDash.Core
|
||||
public string Hostname { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Port on server
|
||||
/// Gets or sets the Port
|
||||
/// </summary>
|
||||
public int Port { get; set; }
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// Gets or sets the SharedKey
|
||||
/// </summary>
|
||||
public string SharedKey { get; set; }
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace PepperDash.Core
|
||||
private bool WaitingForSharedKeyResponse { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Defaults to 2000
|
||||
/// Gets or sets the BufferSize
|
||||
/// </summary>
|
||||
public int BufferSize { get; set; }
|
||||
|
||||
@@ -289,7 +289,7 @@ namespace PepperDash.Core
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Just to help S+ set the key
|
||||
/// Initialize method
|
||||
/// </summary>
|
||||
public void Initialize(string key)
|
||||
{
|
||||
@@ -311,7 +311,7 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Connect Method. Will return if already connected. Will write errors if missing address, port, or unique key/name.
|
||||
/// Connect method
|
||||
/// </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>
|
||||
/// General send method
|
||||
/// SendText method
|
||||
/// </summary>
|
||||
public void SendText(string text)
|
||||
{
|
||||
@@ -698,7 +698,7 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// SendBytes method
|
||||
/// </summary>
|
||||
public void SendBytes(byte[] bytes)
|
||||
{
|
||||
|
||||
@@ -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>
|
||||
/// 3 by default
|
||||
/// Gets or sets the MonitorClientMaxFailureCount
|
||||
/// </summary>
|
||||
public int MonitorClientMaxFailureCount { get; set; }
|
||||
|
||||
@@ -171,7 +171,7 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Port Server should listen on
|
||||
/// Gets or sets the Port
|
||||
/// </summary>
|
||||
public int Port { get; set; }
|
||||
|
||||
@@ -204,8 +204,7 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// Gets or sets the SharedKey
|
||||
/// </summary>
|
||||
public string SharedKey { get; set; }
|
||||
|
||||
@@ -229,7 +228,7 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Milliseconds before server expects another heartbeat. Set by property HeartbeatRequiredIntervalInSeconds which is driven from S+
|
||||
/// Gets or sets the HeartbeatRequiredIntervalMs
|
||||
/// </summary>
|
||||
public int HeartbeatRequiredIntervalMs { get; set; }
|
||||
|
||||
@@ -239,7 +238,7 @@ namespace PepperDash.Core
|
||||
public ushort HeartbeatRequiredIntervalInSeconds { set { HeartbeatRequiredIntervalMs = (value * 1000); } }
|
||||
|
||||
/// <summary>
|
||||
/// String to Match for heartbeat. If null or empty any string will reset heartbeat timer
|
||||
/// Gets or sets the HeartbeatStringToMatch
|
||||
/// </summary>
|
||||
public string HeartbeatStringToMatch { get; set; }
|
||||
|
||||
@@ -257,7 +256,7 @@ namespace PepperDash.Core
|
||||
public List<uint> ConnectedClientsIndexes = new List<uint>();
|
||||
|
||||
/// <summary>
|
||||
/// Defaults to 2000
|
||||
/// Gets or sets the BufferSize
|
||||
/// </summary>
|
||||
public int BufferSize { get; set; }
|
||||
|
||||
@@ -320,7 +319,7 @@ namespace PepperDash.Core
|
||||
|
||||
#region Methods - Server Actions
|
||||
/// <summary>
|
||||
/// Disconnects all clients and stops the server
|
||||
/// KillServer method
|
||||
/// </summary>
|
||||
public void KillServer()
|
||||
{
|
||||
@@ -337,6 +336,9 @@ 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;
|
||||
@@ -375,7 +377,7 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start listening on the specified port
|
||||
/// Listen method
|
||||
/// </summary>
|
||||
public void Listen()
|
||||
{
|
||||
@@ -432,7 +434,7 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stop Listening
|
||||
/// StopListening method
|
||||
/// </summary>
|
||||
public void StopListening()
|
||||
{
|
||||
@@ -457,6 +459,9 @@ namespace PepperDash.Core
|
||||
/// Disconnects Client
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <summary>
|
||||
/// DisconnectClient method
|
||||
/// </summary>
|
||||
public void DisconnectClient(uint client)
|
||||
{
|
||||
try
|
||||
@@ -470,7 +475,7 @@ namespace PepperDash.Core
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Disconnect All Clients
|
||||
/// DisconnectAllClientsForShutdown method
|
||||
/// </summary>
|
||||
public void DisconnectAllClientsForShutdown()
|
||||
{
|
||||
@@ -512,6 +517,9 @@ 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();
|
||||
@@ -545,6 +553,9 @@ namespace PepperDash.Core
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
/// <param name="clientIndex"></param>
|
||||
/// <summary>
|
||||
/// SendTextToClient method
|
||||
/// </summary>
|
||||
public void SendTextToClient(string text, uint clientIndex)
|
||||
{
|
||||
try
|
||||
@@ -613,6 +624,9 @@ 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);
|
||||
|
||||
@@ -124,21 +124,21 @@ namespace PepperDash.Core
|
||||
CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
|
||||
CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(CrestronEnvironment_EthernetEventHandler);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="address"></param>
|
||||
/// <param name="port"></param>
|
||||
/// <param name="buffefSize"></param>
|
||||
public GenericUdpServer(string key, string address, int port, int buffefSize)
|
||||
/// <param name="bufferSize"></param>
|
||||
public GenericUdpServer(string key, string address, int port, int bufferSize)
|
||||
: base(key)
|
||||
{
|
||||
StreamDebugging = new CommunicationStreamDebugging(key);
|
||||
StreamDebugging = new CommunicationStreamDebugging(key);
|
||||
Hostname = address;
|
||||
Port = port;
|
||||
BufferSize = buffefSize;
|
||||
BufferSize = bufferSize;
|
||||
|
||||
CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
|
||||
CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(CrestronEnvironment_EthernetEventHandler);
|
||||
@@ -150,6 +150,9 @@ 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;
|
||||
@@ -177,7 +180,7 @@ namespace PepperDash.Core
|
||||
/// <param name="programEventType"></param>
|
||||
void CrestronEnvironment_ProgramStatusEventHandler(eProgramStatusEventType programEventType)
|
||||
{
|
||||
if (programEventType != eProgramStatusEventType.Stopping)
|
||||
if (programEventType != eProgramStatusEventType.Stopping)
|
||||
return;
|
||||
|
||||
Debug.Console(1, this, "Program stopping. Disabling Server");
|
||||
@@ -185,13 +188,27 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enables the UDP Server
|
||||
/// Connect method
|
||||
/// </summary>
|
||||
public void Connect()
|
||||
{
|
||||
if (Server == null)
|
||||
{
|
||||
Server = new UDPServer();
|
||||
try
|
||||
{
|
||||
var address = IPAddress.Parse(Hostname);
|
||||
|
||||
Server = new UDPServer(address, Port, BufferSize);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.LogError("Error parsing IP Address '{ipAddress}': message: {message}", Hostname, ex.Message);
|
||||
this.LogInformation("Creating UDPServer with default buffersize");
|
||||
|
||||
Server = new UDPServer();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(Hostname))
|
||||
@@ -222,11 +239,11 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disabled the UDP Server
|
||||
/// Disconnect method
|
||||
/// </summary>
|
||||
public void Disconnect()
|
||||
{
|
||||
if(Server != null)
|
||||
if (Server != null)
|
||||
Server.DisableUDPServer();
|
||||
|
||||
IsConnected = false;
|
||||
@@ -248,7 +265,7 @@ namespace PepperDash.Core
|
||||
|
||||
try
|
||||
{
|
||||
if (numBytes <= 0)
|
||||
if (numBytes <= 0)
|
||||
return;
|
||||
|
||||
var sourceIp = Server.IPAddressLastMessageReceivedFrom;
|
||||
@@ -264,17 +281,13 @@ namespace PepperDash.Core
|
||||
var bytesHandler = BytesReceived;
|
||||
if (bytesHandler != null)
|
||||
{
|
||||
if (StreamDebugging.RxStreamDebuggingIsEnabled)
|
||||
{
|
||||
Debug.Console(0, this, "Received {1} bytes: '{0}'", ComTextHelper.GetEscapedText(bytes), bytes.Length);
|
||||
}
|
||||
this.PrintReceivedBytes(bytes);
|
||||
bytesHandler(this, new GenericCommMethodReceiveBytesArgs(bytes));
|
||||
}
|
||||
var textHandler = TextReceived;
|
||||
if (textHandler != null)
|
||||
{
|
||||
if (StreamDebugging.RxStreamDebuggingIsEnabled)
|
||||
Debug.Console(0, this, "Received {1} characters of text: '{0}'", ComTextHelper.GetDebugText(str), str.Length);
|
||||
this.PrintReceivedText(str);
|
||||
textHandler(this, new GenericCommMethodReceiveTextArgs(str));
|
||||
}
|
||||
}
|
||||
@@ -292,14 +305,16 @@ 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);
|
||||
|
||||
if (IsConnected && Server != null)
|
||||
{
|
||||
if (StreamDebugging.TxStreamDebuggingIsEnabled)
|
||||
Debug.Console(0, this, "Sending {0} characters of text: '{1}'", text.Length, ComTextHelper.GetDebugText(text));
|
||||
this.PrintSentText(text);
|
||||
|
||||
Server.SendData(bytes, bytes.Length);
|
||||
}
|
||||
@@ -309,10 +324,12 @@ namespace PepperDash.Core
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="bytes"></param>
|
||||
/// <summary>
|
||||
/// SendBytes method
|
||||
/// </summary>
|
||||
public void SendBytes(byte[] bytes)
|
||||
{
|
||||
if (StreamDebugging.TxStreamDebuggingIsEnabled)
|
||||
Debug.Console(0, this, "Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes));
|
||||
this.PrintSentBytes(bytes);
|
||||
|
||||
if (IsConnected && Server != null)
|
||||
Server.SendData(bytes, bytes.Length);
|
||||
@@ -321,10 +338,10 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Represents a GenericUdpReceiveTextExtraArgs
|
||||
/// </summary>
|
||||
public class GenericUdpReceiveTextExtraArgs : EventArgs
|
||||
{
|
||||
public class GenericUdpReceiveTextExtraArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
@@ -336,7 +353,7 @@ namespace PepperDash.Core
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int Port { get; private set; }
|
||||
public int Port { get; private set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
@@ -350,18 +367,18 @@ namespace PepperDash.Core
|
||||
/// <param name="port"></param>
|
||||
/// <param name="bytes"></param>
|
||||
public GenericUdpReceiveTextExtraArgs(string text, string ipAddress, int port, byte[] bytes)
|
||||
{
|
||||
Text = text;
|
||||
IpAddress = ipAddress;
|
||||
Port = port;
|
||||
Bytes = bytes;
|
||||
}
|
||||
{
|
||||
Text = text;
|
||||
IpAddress = ipAddress;
|
||||
Port = port;
|
||||
Bytes = bytes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stupid S+ Constructor
|
||||
/// </summary>
|
||||
public GenericUdpReceiveTextExtraArgs() { }
|
||||
}
|
||||
/// <summary>
|
||||
/// Stupid S+ Constructor
|
||||
/// </summary>
|
||||
public GenericUdpReceiveTextExtraArgs() { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
|
||||
69
src/PepperDash.Core/Comm/StreamDebuggingExtensions.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
namespace PepperDash.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods for stream debugging
|
||||
/// </summary>
|
||||
public static class StreamDebuggingExtensions
|
||||
{
|
||||
private static readonly string app = CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance ? $"App {InitialParametersClass.ApplicationNumber}" : $"{InitialParametersClass.RoomId}";
|
||||
|
||||
/// <summary>
|
||||
/// Print the sent bytes to the console
|
||||
/// </summary>
|
||||
/// <param name="comms">comms device</param>
|
||||
/// <param name="bytes">bytes to print</param>
|
||||
public static void PrintSentBytes(this IStreamDebugging comms, byte[] bytes)
|
||||
{
|
||||
if (!comms.StreamDebugging.TxStreamDebuggingIsEnabled) return;
|
||||
|
||||
var timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
|
||||
|
||||
CrestronConsole.PrintLine($"[{timestamp}][{app}][{comms.Key}] Sending {bytes.Length} bytes: '{ComTextHelper.GetEscapedText(bytes)}'");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Print the received bytes to the console
|
||||
/// </summary>
|
||||
/// <param name="comms">comms device</param>
|
||||
/// <param name="bytes">bytes to print</param>
|
||||
public static void PrintReceivedBytes(this IStreamDebugging comms, byte[] bytes)
|
||||
{
|
||||
if (!comms.StreamDebugging.RxStreamDebuggingIsEnabled) return;
|
||||
|
||||
var timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
|
||||
|
||||
CrestronConsole.PrintLine($"[{timestamp}][{app}][{comms.Key}] Received {bytes.Length} bytes: '{ComTextHelper.GetEscapedText(bytes)}'");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Print the sent text to the console
|
||||
/// </summary>
|
||||
/// <param name="comms">comms device</param>
|
||||
/// <param name="text">text to print</param>
|
||||
public static void PrintSentText(this IStreamDebugging comms, string text)
|
||||
{
|
||||
if (!comms.StreamDebugging.TxStreamDebuggingIsEnabled) return;
|
||||
|
||||
var timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
|
||||
|
||||
CrestronConsole.PrintLine($"[{timestamp}][{app}][{comms.Key}] Sending Text: '{ComTextHelper.GetDebugText(text)}'");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Print the received text to the console
|
||||
/// </summary>
|
||||
/// <param name="comms">comms device</param>
|
||||
/// <param name="text">text to print</param>
|
||||
public static void PrintReceivedText(this IStreamDebugging comms, string text)
|
||||
{
|
||||
if (!comms.StreamDebugging.RxStreamDebuggingIsEnabled) return;
|
||||
|
||||
var timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
|
||||
|
||||
CrestronConsole.PrintLine($"[{timestamp}][{app}][{comms.Key}] Received Text: '{ComTextHelper.GetDebugText(text)}'");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace PepperDash.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Client config object for TCP client with server that inherits from TcpSshPropertiesConfig and adds properties for shared key and heartbeat
|
||||
/// Represents a TcpClientConfigObject
|
||||
/// </summary>
|
||||
public class TcpClientConfigObject
|
||||
{
|
||||
|
||||
@@ -74,6 +74,14 @@ namespace PepperDash.Core
|
||||
/// <summary>
|
||||
/// Secure TCP/IP
|
||||
/// </summary>
|
||||
SecureTcpIp
|
||||
SecureTcpIp,
|
||||
/// <summary>
|
||||
/// Used when comms needs to be handled in SIMPL and bridged opposite the normal direction
|
||||
/// </summary>
|
||||
ComBridge,
|
||||
/// <summary>
|
||||
/// InfinetEX control
|
||||
/// </summary>
|
||||
InfinetEx
|
||||
}
|
||||
}
|
||||
24
src/PepperDash.Core/Comm/eStreamDebuggingDataTypeSettings.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
|
||||
namespace PepperDash.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// The available settings for stream debugging data format types
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum eStreamDebuggingDataTypeSettings
|
||||
{
|
||||
/// <summary>
|
||||
/// Debug data in byte format
|
||||
/// </summary>
|
||||
Bytes = 0,
|
||||
/// <summary>
|
||||
/// Debug data in text format
|
||||
/// </summary>
|
||||
Text = 1,
|
||||
/// <summary>
|
||||
/// Debug data in both byte and text formats
|
||||
/// </summary>
|
||||
Both = Bytes | Text
|
||||
}
|
||||
}
|
||||
28
src/PepperDash.Core/Comm/eStreamDebuggingSetting.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
|
||||
namespace PepperDash.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// The available settings for stream debugging
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum eStreamDebuggingSetting
|
||||
{
|
||||
/// <summary>
|
||||
/// Debug off
|
||||
/// </summary>
|
||||
Off = 0,
|
||||
/// <summary>
|
||||
/// Debug received data
|
||||
/// </summary>
|
||||
Rx = 1,
|
||||
/// <summary>
|
||||
/// Debug transmitted data
|
||||
/// </summary>
|
||||
Tx = 2,
|
||||
/// <summary>
|
||||
/// Debug both received and transmitted data
|
||||
/// </summary>
|
||||
Both = Rx | Tx
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharp.CrestronSockets;
|
||||
using System.Text.RegularExpressions;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace PepperDash.Core
|
||||
@@ -38,11 +35,11 @@ namespace PepperDash.Core
|
||||
void Disconnect();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a device that uses basic connection
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Defines the contract for IBasicCommunication
|
||||
/// </summary>
|
||||
public interface IBasicCommunication : ICommunicationReceiver
|
||||
{
|
||||
{
|
||||
/// <summary>
|
||||
/// Send text to the device
|
||||
/// </summary>
|
||||
@@ -54,7 +51,7 @@ namespace PepperDash.Core
|
||||
/// </summary>
|
||||
/// <param name="bytes"></param>
|
||||
void SendBytes(byte[] bytes);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a device that implements IBasicCommunication and IStreamDebugging
|
||||
@@ -67,7 +64,7 @@ namespace PepperDash.Core
|
||||
/// <summary>
|
||||
/// Represents a device with stream debugging capablities
|
||||
/// </summary>
|
||||
public interface IStreamDebugging
|
||||
public interface IStreamDebugging : IKeyed
|
||||
{
|
||||
/// <summary>
|
||||
/// Object to enable stream debugging
|
||||
@@ -76,12 +73,12 @@ namespace PepperDash.Core
|
||||
CommunicationStreamDebugging StreamDebugging { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For IBasicCommunication classes that have SocketStatus. GenericSshClient,
|
||||
/// GenericTcpIpClient
|
||||
/// </summary>
|
||||
public interface ISocketStatus : IBasicCommunication
|
||||
{
|
||||
/// <summary>
|
||||
/// For IBasicCommunication classes that have SocketStatus. GenericSshClient,
|
||||
/// GenericTcpIpClient
|
||||
/// </summary>
|
||||
public interface ISocketStatus : IBasicCommunication
|
||||
{
|
||||
/// <summary>
|
||||
/// Notifies of socket status changes
|
||||
/// </summary>
|
||||
@@ -93,7 +90,7 @@ namespace PepperDash.Core
|
||||
[JsonProperty("clientStatus")]
|
||||
[JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
|
||||
SocketStatus ClientStatus { get; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Describes a device that implements ISocketStatus and IStreamDebugging
|
||||
@@ -107,24 +104,24 @@ namespace PepperDash.Core
|
||||
/// Describes a device that can automatically attempt to reconnect
|
||||
/// </summary>
|
||||
public interface IAutoReconnect
|
||||
{
|
||||
{
|
||||
/// <summary>
|
||||
/// Enable automatic recconnect
|
||||
/// </summary>
|
||||
[JsonProperty("autoReconnect")]
|
||||
bool AutoReconnect { get; set; }
|
||||
bool AutoReconnect { get; set; }
|
||||
/// <summary>
|
||||
/// Interval in ms to attempt automatic recconnections
|
||||
/// </summary>
|
||||
[JsonProperty("autoReconnectIntervalMs")]
|
||||
int AutoReconnectIntervalMs { get; set; }
|
||||
}
|
||||
int AutoReconnectIntervalMs { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public enum eGenericCommMethodStatusChangeType
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public enum eGenericCommMethodStatusChangeType
|
||||
{
|
||||
/// <summary>
|
||||
/// Connected
|
||||
/// </summary>
|
||||
@@ -133,45 +130,45 @@ namespace PepperDash.Core
|
||||
/// Disconnected
|
||||
/// </summary>
|
||||
Disconnected
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This delegate defines handler for IBasicCommunication status changes
|
||||
/// </summary>
|
||||
/// <param name="comm">Device firing the status change</param>
|
||||
/// <param name="status"></param>
|
||||
public delegate void GenericCommMethodStatusHandler(IBasicCommunication comm, eGenericCommMethodStatusChangeType status);
|
||||
/// <summary>
|
||||
/// This delegate defines handler for IBasicCommunication status changes
|
||||
/// </summary>
|
||||
/// <param name="comm">Device firing the status change</param>
|
||||
/// <param name="status"></param>
|
||||
public delegate void GenericCommMethodStatusHandler(IBasicCommunication comm, eGenericCommMethodStatusChangeType status);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class GenericCommMethodReceiveBytesArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class GenericCommMethodReceiveBytesArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// Gets or sets the Bytes
|
||||
/// </summary>
|
||||
public byte[] Bytes { get; private set; }
|
||||
public byte[] Bytes { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="bytes"></param>
|
||||
public GenericCommMethodReceiveBytesArgs(byte[] bytes)
|
||||
{
|
||||
Bytes = bytes;
|
||||
}
|
||||
{
|
||||
Bytes = bytes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// S+ Constructor
|
||||
/// </summary>
|
||||
public GenericCommMethodReceiveBytesArgs() { }
|
||||
}
|
||||
/// <summary>
|
||||
/// S+ Constructor
|
||||
/// </summary>
|
||||
public GenericCommMethodReceiveBytesArgs() { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class GenericCommMethodReceiveTextArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class GenericCommMethodReceiveTextArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
@@ -185,9 +182,9 @@ namespace PepperDash.Core
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
public GenericCommMethodReceiveTextArgs(string text)
|
||||
{
|
||||
Text = text;
|
||||
}
|
||||
{
|
||||
Text = text;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -195,53 +192,14 @@ namespace PepperDash.Core
|
||||
/// <param name="text"></param>
|
||||
/// <param name="delimiter"></param>
|
||||
public GenericCommMethodReceiveTextArgs(string text, string delimiter)
|
||||
:this(text)
|
||||
: this(text)
|
||||
{
|
||||
Delimiter = delimiter;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// S+ Constructor
|
||||
/// </summary>
|
||||
public GenericCommMethodReceiveTextArgs() { }
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class ComTextHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets escaped text for a byte array
|
||||
/// S+ Constructor
|
||||
/// </summary>
|
||||
/// <param name="bytes"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetEscapedText(byte[] bytes)
|
||||
{
|
||||
return String.Concat(bytes.Select(b => string.Format(@"[{0:X2}]", (int)b)).ToArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets escaped text for a string
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetEscapedText(string text)
|
||||
{
|
||||
var bytes = Encoding.GetEncoding(28591).GetBytes(text);
|
||||
return String.Concat(bytes.Select(b => string.Format(@"[{0:X2}]", (int)b)).ToArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets debug text for a string
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetDebugText(string text)
|
||||
{
|
||||
return Regex.Replace(text, @"[^\u0020-\u007E]", a => GetEscapedText(a.Value));
|
||||
}
|
||||
}
|
||||
public GenericCommMethodReceiveTextArgs() { }
|
||||
}
|
||||
}
|
||||
@@ -9,40 +9,59 @@ using Serilog.Events;
|
||||
|
||||
namespace PepperDash.Core.Config
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Reads a Portal formatted config file
|
||||
/// </summary>
|
||||
public class PortalConfigReader
|
||||
{
|
||||
/// <summary>
|
||||
/// Reads the config file, checks if it needs a merge, merges and saves, then returns the merged Object.
|
||||
/// </summary>
|
||||
/// <returns>JObject of config file</returns>
|
||||
public static void ReadAndMergeFileIfNecessary(string filePath, string savePath)
|
||||
const string template = "template";
|
||||
const string system = "system";
|
||||
const string systemUrl = "system_url";
|
||||
const string templateUrl = "template_url";
|
||||
const string info = "info";
|
||||
const string devices = "devices";
|
||||
const string rooms = "rooms";
|
||||
const string sourceLists = "sourceLists";
|
||||
const string destinationLists = "destinationLists";
|
||||
const string cameraLists = "cameraLists";
|
||||
const string audioControlPointLists = "audioControlPointLists";
|
||||
|
||||
const string tieLines = "tieLines";
|
||||
const string joinMaps = "joinMaps";
|
||||
const string global = "global";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Reads the config file, checks if it needs a merge, merges and saves, then returns the merged Object.
|
||||
/// </summary>
|
||||
/// <returns>JObject of config file</returns>
|
||||
public static void ReadAndMergeFileIfNecessary(string filePath, string savePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
Debug.Console(1, Debug.ErrorLogLevel.Error,
|
||||
Debug.LogError(
|
||||
"ERROR: Configuration file not present. Please load file to {0} and reset program", filePath);
|
||||
}
|
||||
|
||||
using (StreamReader fs = new StreamReader(filePath))
|
||||
{
|
||||
var jsonObj = JObject.Parse(fs.ReadToEnd());
|
||||
if(jsonObj["template"] != null && jsonObj["system"] != null)
|
||||
if(jsonObj[template] != null && jsonObj[system] != null)
|
||||
{
|
||||
// it's a double-config, merge it.
|
||||
var merged = MergeConfigs(jsonObj);
|
||||
if (jsonObj["system_url"] != null)
|
||||
if (jsonObj[systemUrl] != null)
|
||||
{
|
||||
merged["systemUrl"] = jsonObj["system_url"].Value<string>();
|
||||
merged[systemUrl] = jsonObj[systemUrl].Value<string>();
|
||||
}
|
||||
|
||||
if (jsonObj["template_url"] != null)
|
||||
if (jsonObj[templateUrl] != null)
|
||||
{
|
||||
merged["templateUrl"] = jsonObj["template_url"].Value<string>();
|
||||
merged[templateUrl] = jsonObj[templateUrl].Value<string>();
|
||||
}
|
||||
|
||||
jsonObj = merged;
|
||||
@@ -67,6 +86,9 @@ 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"]);
|
||||
@@ -74,62 +96,62 @@ namespace PepperDash.Core.Config
|
||||
var merged = new JObject();
|
||||
|
||||
// Put together top-level objects
|
||||
if (system["info"] != null)
|
||||
merged.Add("info", Merge(template["info"], system["info"], "infO"));
|
||||
if (system[info] != null)
|
||||
merged.Add(info, Merge(template[info], system[info], info));
|
||||
else
|
||||
merged.Add("info", template["info"]);
|
||||
merged.Add(info, template[info]);
|
||||
|
||||
merged.Add("devices", MergeArraysOnTopLevelProperty(template["devices"] as JArray,
|
||||
system["devices"] as JArray, "key", "devices"));
|
||||
merged.Add(devices, MergeArraysOnTopLevelProperty(template[devices] as JArray,
|
||||
system[devices] as JArray, "key", devices));
|
||||
|
||||
if (system["rooms"] == null)
|
||||
merged.Add("rooms", template["rooms"]);
|
||||
if (system[rooms] == null)
|
||||
merged.Add(rooms, template[rooms]);
|
||||
else
|
||||
merged.Add("rooms", MergeArraysOnTopLevelProperty(template["rooms"] as JArray,
|
||||
system["rooms"] as JArray, "key", "rooms"));
|
||||
merged.Add(rooms, MergeArraysOnTopLevelProperty(template[rooms] as JArray,
|
||||
system[rooms] as JArray, "key", rooms));
|
||||
|
||||
if (system["sourceLists"] == null)
|
||||
merged.Add("sourceLists", template["sourceLists"]);
|
||||
if (system[sourceLists] == null)
|
||||
merged.Add(sourceLists, template[sourceLists]);
|
||||
else
|
||||
merged.Add("sourceLists", Merge(template["sourceLists"], system["sourceLists"], "sourceLists"));
|
||||
merged.Add(sourceLists, Merge(template[sourceLists], system[sourceLists], sourceLists));
|
||||
|
||||
if (system["destinationLists"] == null)
|
||||
merged.Add("destinationLists", template["destinationLists"]);
|
||||
if (system[destinationLists] == null)
|
||||
merged.Add(destinationLists, template[destinationLists]);
|
||||
else
|
||||
merged.Add("destinationLists",
|
||||
Merge(template["destinationLists"], system["destinationLists"], "destinationLists"));
|
||||
merged.Add(destinationLists,
|
||||
Merge(template[destinationLists], system[destinationLists], destinationLists));
|
||||
|
||||
|
||||
if (system["cameraLists"] == null)
|
||||
merged.Add("cameraLists", template["cameraLists"]);
|
||||
if (system[cameraLists] == null)
|
||||
merged.Add(cameraLists, template[cameraLists]);
|
||||
else
|
||||
merged.Add("cameraLists", Merge(template["cameraLists"], system["cameraLists"], "cameraLists"));
|
||||
merged.Add(cameraLists, Merge(template[cameraLists], system[cameraLists], cameraLists));
|
||||
|
||||
if (system["audioControlPointLists"] == null)
|
||||
merged.Add("audioControlPointLists", template["audioControlPointLists"]);
|
||||
if (system[audioControlPointLists] == null)
|
||||
merged.Add(audioControlPointLists, template[audioControlPointLists]);
|
||||
else
|
||||
merged.Add("audioControlPointLists",
|
||||
Merge(template["audioControlPointLists"], system["audioControlPointLists"], "audioControlPointLists"));
|
||||
merged.Add(audioControlPointLists,
|
||||
Merge(template[audioControlPointLists], system[audioControlPointLists], audioControlPointLists));
|
||||
|
||||
|
||||
// Template tie lines take precedence. Config tool doesn't do them at system
|
||||
// level anyway...
|
||||
if (template["tieLines"] != null)
|
||||
merged.Add("tieLines", template["tieLines"]);
|
||||
else if (system["tieLines"] != null)
|
||||
merged.Add("tieLines", system["tieLines"]);
|
||||
if (template[tieLines] != null)
|
||||
merged.Add(tieLines, template[tieLines]);
|
||||
else if (system[tieLines] != null)
|
||||
merged.Add(tieLines, system[tieLines]);
|
||||
else
|
||||
merged.Add("tieLines", new JArray());
|
||||
merged.Add(tieLines, new JArray());
|
||||
|
||||
if (template["joinMaps"] != null)
|
||||
merged.Add("joinMaps", template["joinMaps"]);
|
||||
if (template[joinMaps] != null)
|
||||
merged.Add(joinMaps, template[joinMaps]);
|
||||
else
|
||||
merged.Add("joinMaps", new JObject());
|
||||
merged.Add(joinMaps, new JObject());
|
||||
|
||||
if (system["global"] != null)
|
||||
merged.Add("global", Merge(template["global"], system["global"], "global"));
|
||||
if (system[global] != null)
|
||||
merged.Add(global, Merge(template[global], system[global], global));
|
||||
else
|
||||
merged.Add("global", template["global"]);
|
||||
merged.Add(global, template[global]);
|
||||
|
||||
//Debug.Console(2, "MERGED CONFIG RESULT: \x0d\x0a{0}", merged);
|
||||
return merged;
|
||||
@@ -225,7 +247,7 @@ namespace PepperDash.Core.Config
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(1, Debug.ErrorLogLevel.Warning, "Cannot merge items at path {0}: \r{1}", propPath, e);
|
||||
Debug.LogError($"Cannot merge items at path {propPath}: \r{e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,13 +6,22 @@ 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);
|
||||
|
||||
@@ -5,41 +5,41 @@ using Serilog.Events;
|
||||
namespace PepperDash.Core
|
||||
{
|
||||
//*********************************************************************************************************
|
||||
/// <summary>
|
||||
/// The core event and status-bearing class that most if not all device and connectors can derive from.
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Represents a Device
|
||||
/// </summary>
|
||||
public class Device : IKeyName
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Unique Key
|
||||
/// </summary>
|
||||
public string Key { get; protected set; }
|
||||
/// <summary>
|
||||
/// Name of the devie
|
||||
/// Unique Key
|
||||
/// </summary>
|
||||
public string Key { get; protected set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the Name
|
||||
/// </summary>
|
||||
public string Name { get; protected set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public 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,10 +82,13 @@ namespace PepperDash.Core
|
||||
_PreActivationActions.Add(act);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a post activation action
|
||||
/// </summary>
|
||||
/// <param name="act"></param>
|
||||
/// <summary>
|
||||
/// Adds a post activation action
|
||||
/// </summary>
|
||||
/// <param name="act"></param>
|
||||
/// <summary>
|
||||
/// AddPostActivationAction method
|
||||
/// </summary>
|
||||
public void AddPostActivationAction(Action act)
|
||||
{
|
||||
if (_PostActivationActions == null)
|
||||
@@ -93,55 +96,56 @@ namespace PepperDash.Core
|
||||
_PostActivationActions.Add(act);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the preactivation actions
|
||||
/// </summary>
|
||||
public void PreActivate()
|
||||
{
|
||||
if (_PreActivationActions != null)
|
||||
_PreActivationActions.ForEach(a => {
|
||||
/// <summary>
|
||||
/// PreActivate method
|
||||
/// </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>
|
||||
/// 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());
|
||||
var result = CustomActivate();
|
||||
//if(result && _PostActivationActions != null)
|
||||
// _PostActivationActions.ForEach(a => a.Invoke());
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
/// <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>
|
||||
/// Activate method
|
||||
/// </summary>
|
||||
public bool Activate()
|
||||
{
|
||||
//if (_PreActivationActions != null)
|
||||
// _PreActivationActions.ForEach(a => a.Invoke());
|
||||
var result = CustomActivate();
|
||||
//if(result && _PostActivationActions != null)
|
||||
// _PostActivationActions.ForEach(a => a.Invoke());
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PostActivate method
|
||||
/// </summary>
|
||||
public void PostActivate()
|
||||
{
|
||||
if (_PostActivationActions != null)
|
||||
_PostActivationActions.ForEach(a =>
|
||||
{
|
||||
try
|
||||
{
|
||||
a.Invoke();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogMessage(e, "Error in PostActivationAction: " + e.Message, this);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called in between Pre and PostActivationActions when Activate() is called.
|
||||
@@ -149,6 +153,9 @@ 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>
|
||||
@@ -158,14 +165,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>
|
||||
@@ -175,5 +182,18 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
<Project>
|
||||
<ItemGroup>
|
||||
<None Include="$(TargetDir)\$(TargetName).$(Version).cpz" Condition="$(ProjectType) == 'Program'">
|
||||
<Pack>true</Pack>
|
||||
<PackagePath>content;</PackagePath>
|
||||
</None>
|
||||
<None Include="$(PackageOutputPath)\$(TargetName).$(Version).cplz" Condition="$(ProjectType) == 'ProgramLibrary'">
|
||||
<Pack>true</Pack>
|
||||
<PackagePath>content;</PackagePath>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<Target Name="Create CPLZ" AfterTargets="Build; Rebuild" Condition="$(ProjectType) == 'ProgramLibrary'">
|
||||
<Message Text="Creating CPLZ"></Message>
|
||||
<MakeDir Directories="$(PackageOutputPath)" Condition="!Exists($(PackageOutputPath))"></MakeDir>
|
||||
<ZipDirectory SourceDirectory="$(TargetDir)" DestinationFile="$(PackageOutputPath)\$(TargetName).$(Version).cplz" Overwrite="true"/>
|
||||
</Target>
|
||||
<Target Name="Clean CPLZ" AfterTargets="AfterClean" Condition="$(ProjectType) == 'ProgramLibrary'">
|
||||
<Delete Files="$(PackageOutputPath)\$(TargetName).$(Version).cplz"/>
|
||||
</Target>
|
||||
<Target Name="Copy CPZ" AfterTargets="SimplSharpPostProcess" Condition="$(ProjectType) == 'Program'">
|
||||
<Message Text="Copying CPZ"></Message>
|
||||
<Move SourceFiles="$(TargetDir)\$(TargetName).cpz" DestinationFiles="$(TargetDir)\$(TargetName).$(Version).cpz"/>
|
||||
<Copy SourceFiles="$(TargetDir)\$(TargetName).$(Version).cpz" DestinationFiles="$(PackageOutputPath)\$(TargetName).$(Version).cpz"/>
|
||||
</Target>
|
||||
<Target Name="Clean CPZ" AfterTargets="AfterClean" Condition="$(ProjectType) == 'Program'">
|
||||
<Delete Files="$(PackageOutputPath)\$(TargetName).$(Version).cpz"/>
|
||||
</Target>
|
||||
<Target Name="Copy CLZ" AfterTargets="SimplSharpPostProcess">
|
||||
<Message Text="Copying CLZ"></Message>
|
||||
<Move SourceFiles="$(TargetDir)\$(TargetName).clz" DestinationFiles="$(TargetDir)\$(TargetName).$(Version).clz"/>
|
||||
<Copy SourceFiles="$(TargetDir)\$(TargetName).$(Version).clz" DestinationFiles="$(PackageOutputPath)\$(TargetName).$(Version).clz"/>
|
||||
</Target>
|
||||
<Target Name="Clean CLZ" AfterTargets="AfterClean">
|
||||
<Delete Files="$(PackageOutputPath)\$(TargetName).$(Version).clz"/>
|
||||
</Target>
|
||||
<Target Name="SimplSharpNewtonsoft" BeforeTargets="FindReferenceAssembliesForReferences;ResolveReferences">
|
||||
<ItemGroup>
|
||||
<ReferencePath Condition="'%(FileName)' == 'Newtonsoft.Json.Compact'">
|
||||
<Aliases>doNotUse</Aliases>
|
||||
</ReferencePath>
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -1,21 +0,0 @@
|
||||
name: Build Essentials Plugin
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '**'
|
||||
|
||||
jobs:
|
||||
getVersion:
|
||||
uses: PepperDash/workflow-templates/.github/workflows/essentialsplugins-getversion.yml@main
|
||||
secrets: inherit
|
||||
build-4Series:
|
||||
uses: PepperDash/workflow-templates/.github/workflows/essentialsplugins-4Series-builds.yml@main
|
||||
secrets: inherit
|
||||
needs: getVersion
|
||||
if: needs.getVersion.outputs.newVersion == 'true'
|
||||
with:
|
||||
newVersion: ${{ needs.getVersion.outputs.newVersion }}
|
||||
version: ${{ needs.getVersion.outputs.version }}
|
||||
tag: ${{ needs.getVersion.outputs.tag }}
|
||||
channel: ${{ needs.getVersion.outputs.channel }}
|
||||
@@ -4,9 +4,9 @@ using Serilog.Events;
|
||||
|
||||
namespace PepperDash.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Class to help with accessing values from the CrestronEthernetHelper class
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Represents a EthernetHelper
|
||||
/// </summary>
|
||||
public class EthernetHelper
|
||||
{
|
||||
/// <summary>
|
||||
@@ -24,9 +24,9 @@ namespace PepperDash.Core
|
||||
|
||||
// ADD OTHER HELPERS HERE
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the PortNumber
|
||||
/// </summary>
|
||||
public int PortNumber { get; private set; }
|
||||
|
||||
private EthernetHelper(int portNumber)
|
||||
|
||||
@@ -16,19 +16,19 @@ namespace PepperDash.Core
|
||||
/// </summary>
|
||||
public bool State { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Boolean ushort value property
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the IntValue
|
||||
/// </summary>
|
||||
public ushort IntValue { get { return (ushort)(State ? 1 : 0); } }
|
||||
|
||||
/// <summary>
|
||||
/// Boolean change event args type
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the Type
|
||||
/// </summary>
|
||||
public ushort Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Boolean change event args index
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the Index
|
||||
/// </summary>
|
||||
public ushort Index { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -64,9 +64,9 @@ namespace PepperDash.Core
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ushort change event args
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Represents a UshrtChangeEventArgs
|
||||
/// </summary>
|
||||
public class UshrtChangeEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
@@ -74,14 +74,14 @@ namespace PepperDash.Core
|
||||
/// </summary>
|
||||
public ushort IntValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Ushort change event args type
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the Type
|
||||
/// </summary>
|
||||
public ushort Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Ushort change event args index
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the Index
|
||||
/// </summary>
|
||||
public ushort Index { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -117,9 +117,9 @@ namespace PepperDash.Core
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// String change event args
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Represents a StringChangeEventArgs
|
||||
/// </summary>
|
||||
public class StringChangeEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
@@ -127,14 +127,14 @@ namespace PepperDash.Core
|
||||
/// </summary>
|
||||
public string StringValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// String change event args type
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the Type
|
||||
/// </summary>
|
||||
public ushort Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// string change event args index
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the Index
|
||||
/// </summary>
|
||||
public ushort Index { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -32,14 +32,14 @@ namespace PepperDash.Core.JsonStandardObjects
|
||||
/// </summary>
|
||||
public DeviceConfig Device { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Device change event args type
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the Type
|
||||
/// </summary>
|
||||
public ushort Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Device change event args index
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the Index
|
||||
/// </summary>
|
||||
public ushort Index { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -58,6 +58,9 @@ 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
|
||||
|
||||
@@ -47,14 +47,14 @@ namespace PepperDash.Core.JsonStandardObjects
|
||||
]
|
||||
}
|
||||
*/
|
||||
/// <summary>
|
||||
/// Device communication parameter class
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Represents a ComParamsConfig
|
||||
/// </summary>
|
||||
public class ComParamsConfig
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the baudRate
|
||||
/// </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>
|
||||
///
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the simplBaudRate
|
||||
/// </summary>
|
||||
public ushort simplBaudRate { get { return Convert.ToUInt16(baudRate); } }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the simplDataBits
|
||||
/// </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>
|
||||
///
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the simplPort
|
||||
/// </summary>
|
||||
public ushort simplPort { get { return Convert.ToUInt16(port); } }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the simplAutoReconnect
|
||||
/// </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>
|
||||
///
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the simplControlPortNumber
|
||||
/// </summary>
|
||||
public ushort simplControlPortNumber { get { return Convert.ToUInt16(controlPortNumber); } }
|
||||
|
||||
/// <summary>
|
||||
@@ -207,9 +207,9 @@ namespace PepperDash.Core.JsonStandardObjects
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Device properties class
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Represents a PropertiesConfig
|
||||
/// </summary>
|
||||
public class PropertiesConfig
|
||||
{
|
||||
/// <summary>
|
||||
@@ -226,13 +226,13 @@ namespace PepperDash.Core.JsonStandardObjects
|
||||
public ControlConfig control { get; set; }
|
||||
|
||||
// convert properties for simpl
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the simplDeviceId
|
||||
/// </summary>
|
||||
public ushort simplDeviceId { get { return Convert.ToUInt16(deviceId); } }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the simplEnabled
|
||||
/// </summary>
|
||||
public ushort simplEnabled { get { return (ushort)(enabled ? 1 : 0); } }
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -88,9 +88,9 @@ namespace PepperDash.Core.JsonToSimpl
|
||||
/// </summary>
|
||||
public class SPlusValueWrapper
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the ValueType
|
||||
/// </summary>
|
||||
public SPlusType ValueType { get; private set; }
|
||||
/// <summary>
|
||||
///
|
||||
@@ -122,9 +122,9 @@ namespace PepperDash.Core.JsonToSimpl
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// S+ types enum
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Enumeration of SPlusType values
|
||||
/// </summary>
|
||||
public enum SPlusType
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -23,6 +23,9 @@ 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)
|
||||
@@ -49,9 +52,9 @@ namespace PepperDash.Core.JsonToSimpl
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a master by its key. Case-insensitive
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// GetMasterByFile method
|
||||
/// </summary>
|
||||
public static JsonToSimplMaster GetMasterByFile(string file)
|
||||
{
|
||||
return Masters.FirstOrDefault(m => m.UniqueID.Equals(file, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
@@ -5,9 +5,9 @@ using Serilog.Events;
|
||||
|
||||
namespace PepperDash.Core.JsonToSimpl
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to interact with an array of values with the S+ modules
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Represents a JsonToSimplArrayLookupChild
|
||||
/// </summary>
|
||||
public class JsonToSimplArrayLookupChild : JsonToSimplChildObjectBase
|
||||
{
|
||||
/// <summary>
|
||||
@@ -76,9 +76,10 @@ namespace PepperDash.Core.JsonToSimpl
|
||||
PathSuffix == null ? "" : PathSuffix);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Process all values
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// ProcessAll method
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
public override void ProcessAll()
|
||||
{
|
||||
if (FindInArray())
|
||||
|
||||
@@ -28,14 +28,14 @@ namespace PepperDash.Core.JsonToSimpl
|
||||
/// </summary>
|
||||
public SPlusValuesDelegate GetAllValuesDelegate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Use a callback to reduce task switch/threading
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the SetAllPathsDelegate
|
||||
/// </summary>
|
||||
public SPlusValuesDelegate SetAllPathsDelegate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Unique identifier for instance
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the Key
|
||||
/// </summary>
|
||||
public string Key { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -49,9 +49,9 @@ namespace PepperDash.Core.JsonToSimpl
|
||||
/// </summary>
|
||||
public string PathSuffix { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if the instance is linked to an object
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the LinkedToObject
|
||||
/// </summary>
|
||||
public bool LinkedToObject { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -96,6 +96,9 @@ 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;
|
||||
@@ -110,9 +113,9 @@ namespace PepperDash.Core.JsonToSimpl
|
||||
BoolPaths[index] = path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the JPath for a ushort out index.
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// SetUshortPath method
|
||||
/// </summary>
|
||||
public void SetUshortPath(ushort index, string path)
|
||||
{
|
||||
Debug.Console(1, "JSON Child[{0}] SetUshortPath {1}={2}", Key, index, path);
|
||||
@@ -120,9 +123,9 @@ namespace PepperDash.Core.JsonToSimpl
|
||||
UshortPaths[index] = path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the JPath for a string output index.
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// SetStringPath method
|
||||
/// </summary>
|
||||
public void SetStringPath(ushort index, string path)
|
||||
{
|
||||
Debug.Console(1, "JSON Child[{0}] SetStringPath {1}={2}", Key, index, path);
|
||||
@@ -130,10 +133,10 @@ namespace PepperDash.Core.JsonToSimpl
|
||||
StringPaths[index] = path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Evalutates all outputs with defined paths. called by S+ when paths are ready to process
|
||||
/// and by Master when file is read.
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// ProcessAll method
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
public virtual void ProcessAll()
|
||||
{
|
||||
if (!LinkedToObject)
|
||||
@@ -277,6 +280,9 @@ 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);
|
||||
@@ -287,6 +293,9 @@ 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))
|
||||
@@ -298,6 +307,9 @@ 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))
|
||||
@@ -309,6 +321,9 @@ 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))
|
||||
@@ -320,6 +335,9 @@ 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);
|
||||
|
||||
@@ -20,12 +20,12 @@ namespace PepperDash.Core.JsonToSimpl
|
||||
public string Filepath { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Filepath to the actual file that will be read (Portal or local)
|
||||
/// Gets or sets the ActualFilePath
|
||||
/// </summary>
|
||||
public string ActualFilePath { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Gets or sets the Filename
|
||||
/// </summary>
|
||||
public string Filename { get; private set; }
|
||||
/// <summary>
|
||||
@@ -194,6 +194,9 @@ 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);
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace PepperDash.Core.JsonToSimpl
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Represents a JsonToSimplFixedPathObject
|
||||
/// </summary>
|
||||
public class JsonToSimplFixedPathObject : JsonToSimplChildObjectBase
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -5,9 +5,9 @@ using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace PepperDash.Core.JsonToSimpl
|
||||
{
|
||||
/// <summary>
|
||||
/// Generic Master
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Represents a JsonToSimplGenericMaster
|
||||
/// </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>
|
||||
/// Callback action for saving
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the SaveCallback
|
||||
/// </summary>
|
||||
public Action<string> SaveCallback { get; set; }
|
||||
|
||||
/*****************************************************************************************/
|
||||
@@ -60,6 +60,9 @@ 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
|
||||
@@ -72,9 +75,10 @@ namespace PepperDash.Core.JsonToSimpl
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Save method
|
||||
/// </summary>
|
||||
/// <inheritdoc />
|
||||
public override void Save()
|
||||
{
|
||||
// this code is duplicated in the other masters!!!!!!!!!!!!!
|
||||
|
||||
@@ -38,9 +38,9 @@ namespace PepperDash.Core.JsonToSimpl
|
||||
/// </summary>
|
||||
public string Key { get { return UniqueID; } }
|
||||
|
||||
/// <summary>
|
||||
/// A unique ID
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the UniqueID
|
||||
/// </summary>
|
||||
public string UniqueID { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -53,10 +53,9 @@ namespace PepperDash.Core.JsonToSimpl
|
||||
}
|
||||
string _DebugName = "";
|
||||
|
||||
/// <summary>
|
||||
/// This will be prepended to all paths to allow path swapping or for more organized
|
||||
/// sub-paths
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the PathPrefix
|
||||
/// </summary>
|
||||
public string PathPrefix { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -83,9 +82,9 @@ namespace PepperDash.Core.JsonToSimpl
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Gets or sets the JsonObject
|
||||
/// </summary>
|
||||
public JObject JsonObject { get; protected set; }
|
||||
|
||||
/*****************************************************************************************/
|
||||
@@ -120,6 +119,9 @@ 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))
|
||||
@@ -128,9 +130,9 @@ namespace PepperDash.Core.JsonToSimpl
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called from the child to add changed or new values for saving
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// AddUnsavedValue method
|
||||
/// </summary>
|
||||
public void AddUnsavedValue(string path, JValue value)
|
||||
{
|
||||
if (UnsavedValues.ContainsKey(path))
|
||||
@@ -179,6 +181,9 @@ namespace PepperDash.Core.JsonToSimpl
|
||||
/// </summary>
|
||||
/// <param name="json"></param>
|
||||
/// <returns></returns>
|
||||
/// <summary>
|
||||
/// ParseArray method
|
||||
/// </summary>
|
||||
public static JArray ParseArray(string json)
|
||||
{
|
||||
#if NET6_0
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace PepperDash.Core.JsonToSimpl
|
||||
public string PortalFilepath { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// File path of the actual file being read (Portal or local)
|
||||
/// Gets or sets the ActualFilePath
|
||||
/// </summary>
|
||||
public string ActualFilePath { get; private set; }
|
||||
|
||||
@@ -128,6 +128,9 @@ namespace PepperDash.Core.JsonToSimpl
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="level"></param>
|
||||
/// <summary>
|
||||
/// setDebugLevel method
|
||||
/// </summary>
|
||||
public void setDebugLevel(uint level)
|
||||
{
|
||||
Debug.SetDebugLevel(level);
|
||||
|
||||
@@ -9,6 +9,9 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace PepperDash.Core.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a CrestronEnricher
|
||||
/// </summary>
|
||||
public class CrestronEnricher : ILogEventEnricher
|
||||
{
|
||||
static readonly string _appName;
|
||||
@@ -27,6 +30,9 @@ namespace PepperDash.Core.Logging
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Enrich method
|
||||
/// </summary>
|
||||
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
|
||||
{
|
||||
var property = propertyFactory.CreateProperty("App", _appName);
|
||||
|
||||
@@ -11,10 +11,16 @@ 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;
|
||||
@@ -44,6 +50,9 @@ namespace PepperDash.Core
|
||||
|
||||
public static class DebugConsoleSinkExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// DebugConsoleSink method
|
||||
/// </summary>
|
||||
public static LoggerConfiguration DebugConsoleSink(
|
||||
this LoggerSinkConfiguration loggerConfiguration,
|
||||
ITextFormatter formatProvider = null)
|
||||
|
||||
@@ -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,6 +38,9 @@ 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));
|
||||
@@ -92,6 +95,9 @@ namespace PepperDash.Core
|
||||
/// Callback for console command
|
||||
/// </summary>
|
||||
/// <param name="levelString"></param>
|
||||
/// <summary>
|
||||
/// SetDebugFromConsole method
|
||||
/// </summary>
|
||||
public void SetDebugFromConsole(string levelString)
|
||||
{
|
||||
try
|
||||
@@ -114,6 +120,9 @@ 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)
|
||||
@@ -141,7 +150,7 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Appends a device Key to the beginning of a message
|
||||
/// Console method
|
||||
/// </summary>
|
||||
public void Console(uint level, IKeyed dev, string format, params object[] items)
|
||||
{
|
||||
@@ -191,6 +200,9 @@ 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);
|
||||
|
||||
@@ -5,8 +5,14 @@ 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;
|
||||
|
||||
@@ -11,6 +11,9 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace PepperDash.Core.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a DebugErrorLogSink
|
||||
/// </summary>
|
||||
public class DebugErrorLogSink : ILogEventSink
|
||||
{
|
||||
private ITextFormatter _formatter;
|
||||
@@ -24,6 +27,9 @@ 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;
|
||||
|
||||
@@ -1,74 +1,113 @@
|
||||
using Serilog.Events;
|
||||
using System;
|
||||
using System;
|
||||
using Serilog.Events;
|
||||
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, args);
|
||||
Log.LogMessage(ex, message, device: device, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LogVerbose method
|
||||
/// </summary>
|
||||
public static void LogVerbose(this IKeyed device, Exception ex, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Verbose, ex, message, device, args);
|
||||
Log.LogVerbose(ex, device, message, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LogVerbose method
|
||||
/// </summary>
|
||||
public static void LogVerbose(this IKeyed device, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Verbose, device, message, args);
|
||||
Log.LogVerbose(device, message, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LogDebug method
|
||||
/// </summary>
|
||||
public static void LogDebug(this IKeyed device, Exception ex, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Debug, ex, message, device, args);
|
||||
Log.LogDebug(ex, device, message, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LogDebug method
|
||||
/// </summary>
|
||||
public static void LogDebug(this IKeyed device, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Debug, device, message, args);
|
||||
Log.LogDebug(device, message, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LogInformation method
|
||||
/// </summary>
|
||||
public static void LogInformation(this IKeyed device, Exception ex, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Information, ex, message, device, args);
|
||||
Log.LogInformation(ex, device, message, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LogInformation method
|
||||
/// </summary>
|
||||
public static void LogInformation(this IKeyed device, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Information, device, message, args);
|
||||
Log.LogInformation(device, message, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LogWarning method
|
||||
/// </summary>
|
||||
public static void LogWarning(this IKeyed device, Exception ex, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Warning, ex, message, device, args);
|
||||
Log.LogWarning(ex, device, message, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LogWarning method
|
||||
/// </summary>
|
||||
public static void LogWarning(this IKeyed device, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Warning, device, message, args);
|
||||
Log.LogWarning(device, message, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LogError method
|
||||
/// </summary>
|
||||
public static void LogError(this IKeyed device, Exception ex, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Error, ex, message, device, args);
|
||||
Log.LogError(ex, device, message, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LogError method
|
||||
/// </summary>
|
||||
public static void LogError(this IKeyed device, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Error, device, message, args);
|
||||
Log.LogError(device, message, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LogFatal method
|
||||
/// </summary>
|
||||
public static void LogFatal(this IKeyed device, Exception ex, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Fatal, ex, message, device, args);
|
||||
Log.LogFatal(ex, device, message, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LogFatal method
|
||||
/// </summary>
|
||||
public static void LogFatal(this IKeyed device, string message, params object[] args)
|
||||
{
|
||||
Log.LogMessage(LogEventLevel.Fatal, device, message, args);
|
||||
Log.LogFatal(device, message, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ using Newtonsoft.Json;
|
||||
|
||||
namespace PepperDash.Core.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// Class to persist current Debug settings across program restarts
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Represents a DebugContextCollection
|
||||
/// </summary>
|
||||
public class DebugContextCollection
|
||||
{
|
||||
/// <summary>
|
||||
@@ -39,6 +39,9 @@ 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)
|
||||
@@ -51,6 +54,9 @@ namespace PepperDash.Core.Logging
|
||||
/// </summary>
|
||||
/// <param name="contextKey"></param>
|
||||
/// <returns></returns>
|
||||
/// <summary>
|
||||
/// GetOrCreateItem method
|
||||
/// </summary>
|
||||
public DebugContextItem GetOrCreateItem(string contextKey)
|
||||
{
|
||||
if (!_items.ContainsKey(contextKey))
|
||||
@@ -65,6 +71,9 @@ 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
|
||||
@@ -89,6 +98,9 @@ namespace PepperDash.Core.Logging
|
||||
/// </summary>
|
||||
/// <param name="deviceKey"></param>
|
||||
/// <returns></returns>
|
||||
/// <summary>
|
||||
/// GetDebugSettingsForKey method
|
||||
/// </summary>
|
||||
public object GetDebugSettingsForKey(string deviceKey)
|
||||
{
|
||||
return DeviceDebugSettings[deviceKey];
|
||||
|
||||
@@ -21,6 +21,9 @@ using Serilog.Formatting.Json;
|
||||
|
||||
namespace PepperDash.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a DebugWebsocketSink
|
||||
/// </summary>
|
||||
public class DebugWebsocketSink : ILogEventSink
|
||||
{
|
||||
private HttpServer _httpsServer;
|
||||
@@ -47,6 +50,9 @@ namespace PepperDash.Core
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the IsRunning
|
||||
/// </summary>
|
||||
public bool IsRunning { get => _httpsServer?.IsListening ?? false; }
|
||||
|
||||
|
||||
@@ -105,6 +111,9 @@ namespace PepperDash.Core
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Emit method
|
||||
/// </summary>
|
||||
public void Emit(LogEvent logEvent)
|
||||
{
|
||||
if (_httpsServer == null || !_httpsServer.IsListening) return;
|
||||
@@ -116,6 +125,9 @@ namespace PepperDash.Core
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// StartServerAndSetPort method
|
||||
/// </summary>
|
||||
public void StartServerAndSetPort(int port)
|
||||
{
|
||||
Debug.Console(0, "Starting Websocket Server on port: {0}", port);
|
||||
@@ -193,6 +205,9 @@ namespace PepperDash.Core
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// StopServer method
|
||||
/// </summary>
|
||||
public void StopServer()
|
||||
{
|
||||
Debug.Console(0, "Stopping Websocket Server");
|
||||
@@ -204,6 +219,9 @@ namespace PepperDash.Core
|
||||
|
||||
public static class DebugWebsocketSinkExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// DebugWebsocketSink method
|
||||
/// </summary>
|
||||
public static LoggerConfiguration DebugWebsocketSink(
|
||||
this LoggerSinkConfiguration loggerConfiguration,
|
||||
ITextFormatter formatProvider = null)
|
||||
@@ -212,6 +230,9 @@ namespace PepperDash.Core
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a DebugClient
|
||||
/// </summary>
|
||||
public class DebugClient : WebSocketBehavior
|
||||
{
|
||||
private DateTime _connectionTime;
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace PepperDash.Core.PasswordManagement
|
||||
{
|
||||
/// <summary>
|
||||
/// A class to allow user interaction with the PasswordManager
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Represents a PasswordClient
|
||||
/// </summary>
|
||||
public class PasswordClient
|
||||
{
|
||||
/// <summary>
|
||||
@@ -59,6 +59,9 @@ 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);
|
||||
@@ -81,6 +84,9 @@ 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))
|
||||
@@ -99,6 +105,9 @@ 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);
|
||||
@@ -108,9 +117,9 @@ namespace PepperDash.Core.PasswordManagement
|
||||
ValidatePassword(PasswordToValidate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the user entered password and resets the LEDs
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// ClearPassword method
|
||||
/// </summary>
|
||||
public void ClearPassword()
|
||||
{
|
||||
PasswordToValidate = "";
|
||||
|
||||