mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-16 21:24:54 +00:00
Compare commits
206 Commits
2.0.0-alph
...
feature-2.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
afc37f5426 | ||
|
|
4ed5bb7ada | ||
|
|
4360e7f992 | ||
|
|
f926db418d | ||
|
|
0944be2a70 | ||
|
|
bacc0a4f57 | ||
|
|
1d49ea67ad | ||
|
|
35018b3572 | ||
|
|
237fff5398 | ||
|
|
b2eab21fbd | ||
|
|
f2545fb1cf | ||
|
|
27072e3475 | ||
|
|
e4755ed9df | ||
|
|
316867caf8 | ||
|
|
d8fd774324 | ||
|
|
e0058d8cfe | ||
|
|
a055d06bc6 | ||
|
|
66cb592c70 | ||
|
|
d53a5607e2 | ||
|
|
34f59f1410 | ||
|
|
261779d4c4 | ||
|
|
30d5e2b081 | ||
|
|
5516ed16c3 | ||
|
|
8108b9dfdb | ||
|
|
fb4f1482c7 | ||
|
|
54dcb5de08 | ||
|
|
4ef481375c | ||
|
|
d8a88b2a07 | ||
|
|
cc724ddf19 | ||
|
|
e29e800d9d | ||
|
|
134e8ba02e | ||
|
|
a83ba444d3 | ||
|
|
f4c5e6fbeb | ||
|
|
35d7994cc8 | ||
|
|
c3e9d654c9 | ||
|
|
f68b1e9e49 | ||
|
|
cd81b8af73 | ||
|
|
cd52c245a6 | ||
|
|
0b60f53d0e | ||
|
|
ffed2dea8a | ||
|
|
936dce2046 | ||
|
|
b33704eabe | ||
|
|
aca6fe9af5 | ||
|
|
332faaa9cc | ||
|
|
4449077a39 | ||
|
|
86ba9e0f16 | ||
|
|
db2d8a213d | ||
|
|
590e16298c | ||
|
|
1a11e9019c | ||
|
|
0e16dff90c | ||
|
|
d11827bc7b | ||
|
|
631dd2b00d | ||
|
|
639cd2abfb | ||
|
|
f04f70495f | ||
|
|
fa38e8a9a8 | ||
|
|
f351c036ed | ||
|
|
0a7da79356 | ||
|
|
82ebf45921 | ||
|
|
d0dbe986f3 | ||
|
|
aa503f3b29 | ||
|
|
90251d92df | ||
|
|
778af651d0 | ||
|
|
2e31719a84 | ||
|
|
a96fb21898 | ||
|
|
3f45372e1e | ||
|
|
60dbaf547d | ||
|
|
941e537d53 | ||
|
|
f7c5e18af8 | ||
|
|
ab73bbf979 | ||
|
|
1fb1947158 | ||
|
|
e374f7b50f | ||
|
|
7a263a644a | ||
|
|
97bd30e9c9 | ||
|
|
63c653b21f | ||
|
|
c56841d95b | ||
|
|
64d6df70b0 | ||
|
|
d970d806c9 | ||
|
|
5a9b876d80 | ||
|
|
fb60683af6 | ||
|
|
b63996b9e6 | ||
|
|
bc217a2008 | ||
|
|
fec6b0d385 | ||
|
|
f3b4c0aa02 | ||
|
|
a3351812cd | ||
|
|
71815eff17 | ||
|
|
c7f4bf1fb2 | ||
|
|
bec3ab8e73 | ||
|
|
c499d2a2eb | ||
|
|
d9721a362e | ||
|
|
5fb6f3e117 | ||
|
|
c2fb44a662 | ||
|
|
0f9bddf4dd | ||
|
|
ddc2491664 | ||
|
|
9a6209f50a | ||
|
|
49852d25e8 | ||
|
|
ba4ca20936 | ||
|
|
c50726f813 | ||
|
|
0aafe8a62e | ||
|
|
71005940ac | ||
|
|
e5e79316a6 | ||
|
|
5aa1f85df5 | ||
|
|
7bac65002d | ||
|
|
ed0141a536 | ||
|
|
25ebcdfb5d | ||
|
|
b326ccf6c3 | ||
|
|
3a56e47c48 | ||
|
|
171bd6b1ec | ||
|
|
e61fd7777a | ||
|
|
027bdd5bf4 | ||
|
|
b876b8123d | ||
|
|
6e05653c6c | ||
|
|
16d32bc720 | ||
|
|
0bef5d4b77 | ||
|
|
a3c1572a77 | ||
|
|
cc06c7bfd8 | ||
|
|
00a7b25026 | ||
|
|
edc916c9d3 | ||
|
|
c755ecb16c | ||
|
|
a8c36ba243 | ||
|
|
f630d3f410 | ||
|
|
35e0662b27 | ||
|
|
effefc939c | ||
|
|
5afdc2effa | ||
|
|
448cc273ec | ||
|
|
0a2aaa693f | ||
|
|
1ebee58ad6 | ||
|
|
3c5fe88e5a | ||
|
|
8255328be1 | ||
|
|
4bf026601f | ||
|
|
888f1b3888 | ||
|
|
19bd5723c8 | ||
|
|
e3e7add5b9 | ||
|
|
dd66de0463 | ||
|
|
3823943cd9 | ||
|
|
577e111f26 | ||
|
|
528fff569d | ||
|
|
06a6b1caa2 | ||
|
|
621d848418 | ||
|
|
2f9038a501 | ||
|
|
983b18d25a | ||
|
|
048004d441 | ||
|
|
e7e448f02c | ||
|
|
2e61d8d709 | ||
|
|
d8d2c5b340 | ||
|
|
7e736ae519 | ||
|
|
0067e11d3d | ||
|
|
7942c91f73 | ||
|
|
e1638762a1 | ||
|
|
3566400379 | ||
|
|
dde85f39a2 | ||
|
|
735433f660 | ||
|
|
734149960b | ||
|
|
cb16f2a505 | ||
|
|
a95d44e405 | ||
|
|
5820c9d282 | ||
|
|
4d19ecde00 | ||
|
|
826b7fd6d5 | ||
|
|
cb9eb5dafa | ||
|
|
eb955aa014 | ||
|
|
2d9ffca78e | ||
|
|
98f1a09c25 | ||
|
|
a11ad421f0 | ||
|
|
8878ff7ddd | ||
|
|
7e4b5f984f | ||
|
|
64ab315142 | ||
|
|
c47a93f4d0 | ||
|
|
5a55a701d6 | ||
|
|
01862ab9aa | ||
|
|
8ec6fa785e | ||
|
|
e37c675da1 | ||
|
|
3ee8cb7ea3 | ||
|
|
2b6f79b68f | ||
|
|
65369606a4 | ||
|
|
e9954b3081 | ||
|
|
bc67a4382b | ||
|
|
e1b50649fd | ||
|
|
5e69ea1947 | ||
|
|
80b8cc6385 | ||
|
|
82f78bf068 | ||
|
|
d8d27949c3 | ||
|
|
fd1b92a6c0 | ||
|
|
fa9b493431 | ||
|
|
06d806687d | ||
|
|
d8e2f8cd51 | ||
|
|
e5d5c90aa9 | ||
|
|
661f7b827a | ||
|
|
5fad706cd8 | ||
|
|
49c4d2a387 | ||
|
|
cf81431f57 | ||
|
|
8a7bcd5297 | ||
|
|
1fdaa84a62 | ||
|
|
8a374072ae | ||
|
|
5d608887a1 | ||
|
|
d2d041dbf7 | ||
|
|
b90e5b2a0d | ||
|
|
d26c5344e4 | ||
|
|
595fb3894e | ||
|
|
a7654aa77d | ||
|
|
5ccf298584 | ||
|
|
a1cc46b992 | ||
|
|
a1310f2de7 | ||
|
|
09ac964335 | ||
|
|
9acffc620d | ||
|
|
d653cf1a13 | ||
|
|
ee4ccb0d1a | ||
|
|
2faa83cd1a |
52
.github/workflows/docker.yml
vendored
52
.github/workflows/docker.yml
vendored
@@ -66,6 +66,55 @@ jobs:
|
|||||||
# Build the solutions in the docker image
|
# Build the solutions in the docker image
|
||||||
- name: Build Solution
|
- name: Build Solution
|
||||||
run: msbuild .\$($Env:SOLUTION_FILE).sln /p:Platform="Any CPU" /p:Configuration="Debug" /p:Version="${{ steps.setVersion.outputs.version }}" -m
|
run: msbuild .\$($Env:SOLUTION_FILE).sln /p:Platform="Any CPU" /p:Configuration="Debug" /p:Version="${{ steps.setVersion.outputs.version }}" -m
|
||||||
|
- name: Debug CPZ Files
|
||||||
|
shell: powershell
|
||||||
|
run: |
|
||||||
|
Write-Host "Checking for CPZ files..."
|
||||||
|
|
||||||
|
# First, let's find out the actual directory structure
|
||||||
|
Write-Host "Current directory: $(Get-Location)"
|
||||||
|
Write-Host "Directory structure:"
|
||||||
|
Get-ChildItem -Path . -Directory -Recurse -Depth 2 | ForEach-Object { Write-Host $_.FullName }
|
||||||
|
|
||||||
|
# Look for all CPZ files in the repository
|
||||||
|
Write-Host "Searching for all CPZ files in the repository:"
|
||||||
|
$cpzFiles = Get-ChildItem -Path . -Recurse -Filter "*.cpz"
|
||||||
|
if ($cpzFiles.Count -eq 0) {
|
||||||
|
Write-Host "No CPZ files found in the repository."
|
||||||
|
} else {
|
||||||
|
Write-Host "Found $($cpzFiles.Count) CPZ files:"
|
||||||
|
foreach ($file in $cpzFiles) {
|
||||||
|
Write-Host " $($file.FullName)"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create output directory if it doesn't exist
|
||||||
|
$outputDir = ".\output\build"
|
||||||
|
if (-not (Test-Path $outputDir)) {
|
||||||
|
New-Item -ItemType Directory -Path $outputDir -Force
|
||||||
|
Write-Host "Created output directory: $outputDir"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Copy all CPZ files to the output directory
|
||||||
|
foreach ($file in $cpzFiles) {
|
||||||
|
$destPath = Join-Path $outputDir $file.Name
|
||||||
|
Write-Host "Copying $($file.FullName) to $destPath"
|
||||||
|
Copy-Item -Path $file.FullName -Destination $destPath -Force
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- name: Pack Solution
|
||||||
|
run: |
|
||||||
|
dotnet pack .\$($Env:SOLUTION_FILE).sln --configuration $env:BUILD_TYPE --output ./output /p:Version="${{ steps.setVersion.outputs.version }}"
|
||||||
|
|
||||||
|
# Ensure CPZ files are included in the package
|
||||||
|
$cpzFiles = Get-ChildItem -Path . -Recurse | Where-Object { $_.Extension -eq ".cpz" }
|
||||||
|
if ($cpzFiles.Count -eq 0) {
|
||||||
|
Write-Host "WARNING: No CPZ files found!"
|
||||||
|
} else {
|
||||||
|
Write-Host "Found $($cpzFiles.Count) CPZ files"
|
||||||
|
foreach ($file in $cpzFiles) {
|
||||||
|
Write-Host "CPZ file: $($file.FullName)"
|
||||||
|
}
|
||||||
|
}
|
||||||
- name: Create tag for non-rc builds
|
- name: Create tag for non-rc builds
|
||||||
if: contains(steps.setVersion.outputs.version, 'alpha')
|
if: contains(steps.setVersion.outputs.version, 'alpha')
|
||||||
run: |
|
run: |
|
||||||
@@ -74,9 +123,6 @@ jobs:
|
|||||||
# Create the release on the source repo
|
# Create the release on the source repo
|
||||||
- name: Create Release
|
- name: Create Release
|
||||||
id: create_release
|
id: create_release
|
||||||
# if: contains(steps.setVersion.outputs.version,'-rc-') ||
|
|
||||||
# contains(steps.setVersion.outputs.version,'-hotfix-') ||
|
|
||||||
# contains(steps.setVersion.outputs.version, '-beta-')
|
|
||||||
uses: ncipollo/release-action@v1
|
uses: ncipollo/release-action@v1
|
||||||
with:
|
with:
|
||||||
artifacts: 'output\**\*.*(cpz|cplz)'
|
artifacts: 'output\**\*.*(cpz|cplz)'
|
||||||
|
|||||||
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@@ -37,6 +37,8 @@ jobs:
|
|||||||
run: nuget restore .\$($Env:SOLUTION_FILE).sln
|
run: nuget restore .\$($Env:SOLUTION_FILE).sln
|
||||||
- name: Build Solution
|
- name: Build Solution
|
||||||
run: msbuild .\$($Env:SOLUTION_FILE).sln /p:Platform="Any CPU" /p:Configuration="Debug" /p:Version="${{ steps.setVersion.outputs.version }}" -m
|
run: msbuild .\$($Env:SOLUTION_FILE).sln /p:Platform="Any CPU" /p:Configuration="Debug" /p:Version="${{ steps.setVersion.outputs.version }}" -m
|
||||||
|
- name: Pack Solution
|
||||||
|
run: dotnet pack .\$($Env:SOLUTION_FILE).sln --configuration $env:BUILD_TYPE --output ./output /p:Version="${{ steps.setVersion.outputs.version }}"
|
||||||
- name: Upload Release
|
- name: Upload Release
|
||||||
id: create_release
|
id: create_release
|
||||||
uses: ncipollo/release-action@v1
|
uses: ncipollo/release-action@v1
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -390,3 +390,5 @@ MigrationBackup/
|
|||||||
FodyWeavers.xsd
|
FodyWeavers.xsd
|
||||||
essentials-framework/Essentials Interfaces/PepperDash_Essentials_Interfaces/PepperDash_Essentials_Interfaces.csproj
|
essentials-framework/Essentials Interfaces/PepperDash_Essentials_Interfaces/PepperDash_Essentials_Interfaces.csproj
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
/._PepperDash.Essentials.sln
|
||||||
|
.vscode/settings.json
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
Provided under MIT license
|
Provided under MIT license
|
||||||
|
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
PepperDash Essentials is an open source Crestron framework that can be configured as a standalone program capable of running a wide variety of system designs and can also be utilized as a plug-in architecture to augment other Simpl# Pro and Simpl Windows programs.
|
PepperDash Essentials is an open source Crestron framework that can be configured as a standalone program capable of running a wide variety of system designs and can also be utilized as a plug-in architecture to augment other Simpl# Pro and Simpl Windows programs.
|
||||||
|
|||||||
@@ -1,6 +1,19 @@
|
|||||||
<Project>
|
<Project>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="$(PackageOutputPath)\$(AssemblyName)\*.cpz" Condition="$(ProjectType) == 'Program'">
|
<!-- Include CPZ files from multiple possible locations -->
|
||||||
|
<None Include="$(TargetDir)*.cpz" Condition="$(ProjectType) == 'Program'">
|
||||||
|
<Pack>true</Pack>
|
||||||
|
<PackagePath>build;</PackagePath>
|
||||||
|
</None>
|
||||||
|
<None Include="$(OutputPath)*.cpz" Condition="$(ProjectType) == 'Program'">
|
||||||
|
<Pack>true</Pack>
|
||||||
|
<PackagePath>build;</PackagePath>
|
||||||
|
</None>
|
||||||
|
<None Include="$(MSBuildProjectDirectory)\bin\$(Configuration)\**\*.cpz" Condition="$(ProjectType) == 'Program'">
|
||||||
|
<Pack>true</Pack>
|
||||||
|
<PackagePath>build;</PackagePath>
|
||||||
|
</None>
|
||||||
|
<None Include="$(PackageOutputPath)\build\*.cpz" Condition="$(ProjectType) == 'Program'">
|
||||||
<Pack>true</Pack>
|
<Pack>true</Pack>
|
||||||
<PackagePath>build;</PackagePath>
|
<PackagePath>build;</PackagePath>
|
||||||
</None>
|
</None>
|
||||||
@@ -10,17 +23,94 @@
|
|||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Target Name="Create CPLZ" AfterTargets="Build; AfterRebuild" Condition="$(ProjectType) == 'ProgramLibrary' And $(TargetDir) != ''">
|
<Target Name="Create CPLZ" AfterTargets="Build; AfterRebuild" Condition="$(ProjectType) == 'ProgramLibrary' And $(TargetDir) != ''">
|
||||||
<Message Text="Creating CPLZ $(TargetDir)"></Message>
|
<Message Text="Creating CPLZ $(TargetDir)" Importance="high" />
|
||||||
|
<Message Text="PackageOutputPath: $(PackageOutputPath)" Importance="high" />
|
||||||
|
<Message Text="AssemblyName: $(AssemblyName)" Importance="high" />
|
||||||
|
<Message Text="TargetName: $(TargetName)" Importance="high" />
|
||||||
|
<Message Text="Version: $(Version)" Importance="high" />
|
||||||
|
<Message Text="TargetFramework: $(TargetFramework)" Importance="high" />
|
||||||
<MakeDir Directories="$(PackageOutputPath)" Condition="!Exists($(PackageOutputPath))" />
|
<MakeDir Directories="$(PackageOutputPath)" Condition="!Exists($(PackageOutputPath))" />
|
||||||
<MakeDir Directories="$(PackageOutputPath)\$(AssemblyName)" Condition="!Exists('$(PackageOutputPath)\$(AssemblyName)')" />
|
<MakeDir Directories="$(PackageOutputPath)\$(AssemblyName)" Condition="!Exists('$(PackageOutputPath)\$(AssemblyName)')" />
|
||||||
<ZipDirectory SourceDirectory="$(TargetDir)" DestinationFile="$(PackageOutputPath)\$(AssemblyName)\$(TargetName).$(Version).$(TargetFramework).cplz" Overwrite="true"/>
|
<ZipDirectory SourceDirectory="$(TargetDir)" DestinationFile="$(PackageOutputPath)\$(AssemblyName)\$(TargetName).$(Version).$(TargetFramework).cplz" Overwrite="true"/>
|
||||||
</Target>
|
</Target>
|
||||||
<Target Name="Copy CPZ NET6" AfterTargets="SimplSharpPostProcess" Condition="($(ProjectType) == 'Program' And ( '$(TargetFramework)' == 'net6.0' ) Or ( '$(TargetFramework)' == 'net8.0' ))">
|
<Target Name="Debug Variables" BeforeTargets="Build">
|
||||||
<Message Text="Copying CPZ"></Message>
|
<Message Text="================ Debug Variables ================" Importance="high" />
|
||||||
<Move SourceFiles="$(TargetDir)$(TargetName).cpz" DestinationFiles="$(PackageOutputPath)\$(AssemblyName)\$(TargetName).$(Version).$(TargetFramework).cpz" />
|
<Message Text="ProjectType: '$(ProjectType)'" Importance="high" />
|
||||||
|
<Message Text="TargetFramework: '$(TargetFramework)'" Importance="high" />
|
||||||
|
<Message Text="TargetDir: '$(TargetDir)'" Importance="high" />
|
||||||
|
<Message Text="===============================================" Importance="high" />
|
||||||
</Target>
|
</Target>
|
||||||
<Target Name="Copy CPZ NET47" AfterTargets="SimplSharpPostProcess47" Condition="($(ProjectType) == 'Program' And ( '$(TargetFramework)' != 'net6.0' ) And ( '$(TargetFramework)' != 'net8.0' ))">
|
<Target Name="Copy CPZ NET472"
|
||||||
<Message Text="Copying CPZ"></Message>
|
AfterTargets="Build"
|
||||||
<Move SourceFiles="$(TargetDir)$(TargetName).cpz" DestinationFiles="$(PackageOutputPath)\$(AssemblyName)\$(TargetName).$(Version).$(TargetFramework).cpz" />
|
DependsOnTargets="BuildDependencies"
|
||||||
|
Condition="'$(ProjectType)' == 'Program' And '$(TargetFramework)' == 'net472'">
|
||||||
|
<Message Text="========================================" Importance="high" />
|
||||||
|
<Message Text="Starting CPZ Build Process for NET472" Importance="high" />
|
||||||
|
<Message Text="ProjectType: '$(ProjectType)'" Importance="high" />
|
||||||
|
<Message Text="TargetFramework: '$(TargetFramework)'" Importance="high" />
|
||||||
|
<Message Text="========================================" Importance="high" />
|
||||||
|
|
||||||
|
<!-- Create output directory -->
|
||||||
|
<MakeDir Directories="$(PackageOutputPath)\$(AssemblyName)"
|
||||||
|
Condition="!Exists('$(PackageOutputPath)\$(AssemblyName)')" />
|
||||||
|
|
||||||
|
<!-- Copy the CPZ file -->
|
||||||
|
<Copy SourceFiles="$(TargetDir)$(TargetName).cpz"
|
||||||
|
DestinationFiles="$(PackageOutputPath)\$(AssemblyName)\$(TargetName).$(Version).$(TargetFramework).cpz"
|
||||||
|
Condition="Exists('$(TargetDir)$(TargetName).cpz')" />
|
||||||
|
|
||||||
|
<Message Text="CPZ Build completed for NET472"
|
||||||
|
Condition="Exists('$(PackageOutputPath)\$(AssemblyName)\$(TargetName).$(Version).$(TargetFramework).cpz')"
|
||||||
|
Importance="high" />
|
||||||
|
</Target>
|
||||||
|
<Target Name="Copy CPZ NET6"
|
||||||
|
AfterTargets="Build"
|
||||||
|
DependsOnTargets="BuildDependencies"
|
||||||
|
Condition="'$(ProjectType)' == 'Program' And ('$(TargetFramework)' == 'net6.0' Or '$(TargetFramework)' == 'net8.0')">
|
||||||
|
<Message Text="========================================" Importance="high" />
|
||||||
|
<Message Text="Starting CPZ Build Process" Importance="high" />
|
||||||
|
<Message Text="ProjectType: '$(ProjectType)'" Importance="high" />
|
||||||
|
<Message Text="TargetFramework: '$(TargetFramework)'" Importance="high" />
|
||||||
|
<Message Text="MSBuildProjectDirectory: '$(MSBuildProjectDirectory)'" Importance="high" />
|
||||||
|
<Message Text="PATH: '$(PATH)'" Importance="high" />
|
||||||
|
<Message Text="========================================" Importance="high" />
|
||||||
|
|
||||||
|
<!-- Check for SimplSharp compiler -->
|
||||||
|
<PropertyGroup>
|
||||||
|
<SimplSharpCompilerPath>$(HOME)/.crestron/SimplSharpPro/SimplSharpCompiler</SimplSharpCompilerPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<Warning Text="SimplSharpCompiler not found at: $(SimplSharpCompilerPath)"
|
||||||
|
Condition="!Exists('$(SimplSharpCompilerPath)')" />
|
||||||
|
|
||||||
|
<!-- Run the SimplSharp compiler to create CPZ -->
|
||||||
|
<Exec Command=""$(SimplSharpCompilerPath)" "$(MSBuildProjectDirectory)" "$(TargetDir)""
|
||||||
|
IgnoreExitCode="false"
|
||||||
|
WorkingDirectory="$(MSBuildProjectDirectory)"
|
||||||
|
ConsoleToMSBuild="true"
|
||||||
|
Condition="Exists('$(SimplSharpCompilerPath)')">
|
||||||
|
<Output TaskParameter="ConsoleOutput" PropertyName="OutputOfExec" />
|
||||||
|
</Exec>
|
||||||
|
|
||||||
|
<Message Text="SimplSharp Output: $(OutputOfExec)" Importance="high" />
|
||||||
|
|
||||||
|
<!-- Create output directory -->
|
||||||
|
<MakeDir Directories="$(PackageOutputPath)\$(AssemblyName)"
|
||||||
|
Condition="!Exists('$(PackageOutputPath)\$(AssemblyName)')" />
|
||||||
|
|
||||||
|
<!-- Copy the CPZ file -->
|
||||||
|
<Copy SourceFiles="$(TargetDir)$(TargetName).cpz"
|
||||||
|
DestinationFiles="$(PackageOutputPath)\$(AssemblyName)\$(TargetName).$(Version).$(TargetFramework).cpz"
|
||||||
|
Condition="Exists('$(TargetDir)$(TargetName).cpz')" />
|
||||||
|
|
||||||
|
<Message Text="CPZ Build completed"
|
||||||
|
Condition="Exists('$(PackageOutputPath)\$(AssemblyName)\$(TargetName).$(Version).$(TargetFramework).cpz')"
|
||||||
|
Importance="high" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="BuildDependencies">
|
||||||
|
<MSBuild Projects="@(ProjectReference)"
|
||||||
|
Targets="Build"
|
||||||
|
BuildInParallel="true" />
|
||||||
</Target>
|
</Target>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using Crestron.SimplSharp.Reflection;
|
using System.Reflection;
|
||||||
using Crestron.SimplSharpPro;
|
using Crestron.SimplSharpPro;
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
using Crestron.SimplSharpPro.EthernetCommunication;
|
using Crestron.SimplSharpPro.EthernetCommunication;
|
||||||
@@ -12,86 +12,12 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
//using PepperDash.Essentials.Devices.Common.Cameras;
|
//using PepperDash.Essentials.Devices.Common.Cameras;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges
|
namespace PepperDash.Essentials.Core.Bridges
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Helper methods for bridges
|
|
||||||
/// </summary>
|
|
||||||
public static class BridgeHelper
|
|
||||||
{
|
|
||||||
public static void PrintJoinMap(string command)
|
|
||||||
{
|
|
||||||
var targets = command.Split(' ');
|
|
||||||
|
|
||||||
var bridgeKey = targets[0].Trim();
|
|
||||||
|
|
||||||
var bridge = DeviceManager.GetDeviceForKey(bridgeKey) as EiscApiAdvanced;
|
|
||||||
|
|
||||||
if (bridge == null)
|
|
||||||
{
|
|
||||||
Debug.Console(0, "Unable to find advanced bridge with key: '{0}'", bridgeKey);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (targets.Length > 1)
|
|
||||||
{
|
|
||||||
var deviceKey = targets[1].Trim();
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(deviceKey)) return;
|
|
||||||
bridge.PrintJoinMapForDevice(deviceKey);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bridge.PrintJoinMaps();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static void JoinmapMarkdown(string command)
|
|
||||||
{
|
|
||||||
var targets = command.Split(' ');
|
|
||||||
|
|
||||||
var bridgeKey = targets[0].Trim();
|
|
||||||
|
|
||||||
var bridge = DeviceManager.GetDeviceForKey(bridgeKey) as EiscApiAdvanced;
|
|
||||||
|
|
||||||
if (bridge == null)
|
|
||||||
{
|
|
||||||
Debug.Console(0, "Unable to find advanced bridge with key: '{0}'", bridgeKey);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (targets.Length > 1)
|
|
||||||
{
|
|
||||||
var deviceKey = targets[1].Trim();
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(deviceKey)) return;
|
|
||||||
bridge.MarkdownJoinMapForDevice(deviceKey, bridgeKey);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bridge.MarkdownForBridge(bridgeKey);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Base class for all bridge class variants
|
|
||||||
/// </summary>
|
|
||||||
public class BridgeBase : EssentialsDevice
|
|
||||||
{
|
|
||||||
public BridgeApi Api { get; protected set; }
|
|
||||||
|
|
||||||
public BridgeBase(string key) :
|
|
||||||
base(key)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Base class for bridge API variants
|
/// Base class for bridge API variants
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -148,11 +74,11 @@ namespace PepperDash.Essentials.Core.Bridges
|
|||||||
|
|
||||||
private void LinkDevices()
|
private void LinkDevices()
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Linking Devices...");
|
Debug.LogMessage(LogEventLevel.Debug, this, "Linking Devices...");
|
||||||
|
|
||||||
if (PropertiesConfig.Devices == null)
|
if (PropertiesConfig.Devices == null)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "No devices linked to this bridge");
|
Debug.LogMessage(LogEventLevel.Debug, this, "No devices linked to this bridge");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,21 +91,17 @@ namespace PepperDash.Essentials.Core.Bridges
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(1, this, "Linking Device: '{0}'", device.Key);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Linking Device: '{0}'", device.Key);
|
||||||
|
|
||||||
if (!typeof(IBridgeAdvanced).IsAssignableFrom(device.GetType().GetCType()))
|
if (device is IBridgeAdvanced bridge)
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, Debug.ErrorLogLevel.Notice,
|
bridge.LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this);
|
||||||
"{0} is not compatible with this bridge type. Please use 'eiscapi' instead, or updae the device.",
|
|
||||||
device.Key);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var bridge = device as IBridgeAdvanced;
|
Debug.LogMessage(LogEventLevel.Information, this,
|
||||||
if (bridge != null)
|
"{0} is not compatible with this bridge type. Please use 'eiscapi' instead, or updae the device.",
|
||||||
{
|
device.Key);
|
||||||
bridge.LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,20 +116,20 @@ namespace PepperDash.Essentials.Core.Bridges
|
|||||||
|
|
||||||
if (registerResult != eDeviceRegistrationUnRegistrationResponse.Success)
|
if (registerResult != eDeviceRegistrationUnRegistrationResponse.Success)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, Debug.ErrorLogLevel.Error, "Registration result: {0}", registerResult);
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Registration result: {0}", registerResult);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "EISC registration successful");
|
Debug.LogMessage(LogEventLevel.Debug, this, "EISC registration successful");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LinkRooms()
|
public void LinkRooms()
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Linking Rooms...");
|
Debug.LogMessage(LogEventLevel.Debug, this, "Linking Rooms...");
|
||||||
|
|
||||||
if (PropertiesConfig.Rooms == null)
|
if (PropertiesConfig.Rooms == null)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "No rooms linked to this bridge.");
|
Debug.LogMessage(LogEventLevel.Debug, this, "No rooms linked to this bridge.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,7 +139,7 @@ namespace PepperDash.Essentials.Core.Bridges
|
|||||||
|
|
||||||
if (rm == null)
|
if (rm == null)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, Debug.ErrorLogLevel.Notice,
|
Debug.LogMessage(LogEventLevel.Debug, this,
|
||||||
"Room {0} does not implement IBridgeAdvanced. Skipping...", room.RoomKey);
|
"Room {0} does not implement IBridgeAdvanced. Skipping...", room.RoomKey);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -239,7 +161,7 @@ namespace PepperDash.Essentials.Core.Bridges
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "Unable to add join map with key '{0}'. Key already exists in JoinMaps dictionary", deviceKey);
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Unable to add join map with key '{0}'. Key already exists in JoinMaps dictionary", deviceKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,11 +170,11 @@ namespace PepperDash.Essentials.Core.Bridges
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void PrintJoinMaps()
|
public virtual void PrintJoinMaps()
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Join Maps for EISC IPID: {0}", Eisc.ID.ToString("X"));
|
CrestronConsole.ConsoleCommandResponse("Join Maps for EISC IPID: {0}\r\n", Eisc.ID.ToString("X"));
|
||||||
|
|
||||||
foreach (var joinMap in JoinMaps)
|
foreach (var joinMap in JoinMaps)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Join map for device '{0}':", joinMap.Key);
|
CrestronConsole.ConsoleCommandResponse("Join map for device '{0}':", joinMap.Key);
|
||||||
joinMap.Value.PrintJoinMapInfo();
|
joinMap.Value.PrintJoinMapInfo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -261,11 +183,11 @@ namespace PepperDash.Essentials.Core.Bridges
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void MarkdownForBridge(string bridgeKey)
|
public virtual void MarkdownForBridge(string bridgeKey)
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Writing Joinmaps to files for EISC IPID: {0}", Eisc.ID.ToString("X"));
|
Debug.LogMessage(LogEventLevel.Information, this, "Writing Joinmaps to files for EISC IPID: {0}", Eisc.ID.ToString("X"));
|
||||||
|
|
||||||
foreach (var joinMap in JoinMaps)
|
foreach (var joinMap in JoinMaps)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Generating markdown for device '{0}':", joinMap.Key);
|
Debug.LogMessage(LogEventLevel.Information, "Generating markdown for device '{0}':", joinMap.Key);
|
||||||
joinMap.Value.MarkdownJoinMapInfo(joinMap.Key, bridgeKey);
|
joinMap.Value.MarkdownJoinMapInfo(joinMap.Key, bridgeKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -280,11 +202,11 @@ namespace PepperDash.Essentials.Core.Bridges
|
|||||||
|
|
||||||
if (joinMap == null)
|
if (joinMap == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Unable to find joinMap for device with key: '{0}'", deviceKey);
|
Debug.LogMessage(LogEventLevel.Information, this, "Unable to find joinMap for device with key: '{0}'", deviceKey);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(0, "Join map for device '{0}' on EISC '{1}':", deviceKey, Key);
|
Debug.LogMessage(LogEventLevel.Information, "Join map for device '{0}' on EISC '{1}':", deviceKey, Key);
|
||||||
joinMap.PrintJoinMapInfo();
|
joinMap.PrintJoinMapInfo();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -297,11 +219,11 @@ namespace PepperDash.Essentials.Core.Bridges
|
|||||||
|
|
||||||
if (joinMap == null)
|
if (joinMap == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Unable to find joinMap for device with key: '{0}'", deviceKey);
|
Debug.LogMessage(LogEventLevel.Information, this, "Unable to find joinMap for device with key: '{0}'", deviceKey);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(0, "Join map for device '{0}' on EISC '{1}':", deviceKey, Key);
|
Debug.LogMessage(LogEventLevel.Information, "Join map for device '{0}' on EISC '{1}':", deviceKey, Key);
|
||||||
joinMap.MarkdownJoinMapInfo(deviceKey, bridgeKey);
|
joinMap.MarkdownJoinMapInfo(deviceKey, bridgeKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,11 +244,11 @@ namespace PepperDash.Essentials.Core.Bridges
|
|||||||
var uo = Eisc.BooleanOutput[join].UserObject as Action<bool>;
|
var uo = Eisc.BooleanOutput[join].UserObject as Action<bool>;
|
||||||
if (uo != null)
|
if (uo != null)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "Executing Action: {0}", uo.ToString());
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Executing Action: {0}", uo.ToString());
|
||||||
uo(Convert.ToBoolean(state));
|
uo(Convert.ToBoolean(state));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Debug.Console(2, this, "User Action is null. Nothing to Execute");
|
Debug.LogMessage(LogEventLevel.Verbose, this, "User Action is null. Nothing to Execute");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "analog":
|
case "analog":
|
||||||
@@ -334,34 +256,34 @@ namespace PepperDash.Essentials.Core.Bridges
|
|||||||
var uo = Eisc.BooleanOutput[join].UserObject as Action<ushort>;
|
var uo = Eisc.BooleanOutput[join].UserObject as Action<ushort>;
|
||||||
if (uo != null)
|
if (uo != null)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "Executing Action: {0}", uo.ToString());
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Executing Action: {0}", uo.ToString());
|
||||||
uo(Convert.ToUInt16(state));
|
uo(Convert.ToUInt16(state));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Debug.Console(2, this, "User Action is null. Nothing to Execute"); break;
|
Debug.LogMessage(LogEventLevel.Verbose, this, "User Action is null. Nothing to Execute"); break;
|
||||||
}
|
}
|
||||||
case "serial":
|
case "serial":
|
||||||
{
|
{
|
||||||
var uo = Eisc.BooleanOutput[join].UserObject as Action<string>;
|
var uo = Eisc.BooleanOutput[join].UserObject as Action<string>;
|
||||||
if (uo != null)
|
if (uo != null)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "Executing Action: {0}", uo.ToString());
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Executing Action: {0}", uo.ToString());
|
||||||
uo(Convert.ToString(state));
|
uo(Convert.ToString(state));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Debug.Console(2, this, "User Action is null. Nothing to Execute");
|
Debug.LogMessage(LogEventLevel.Verbose, this, "User Action is null. Nothing to Execute");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
Debug.Console(2, "Unknown join type. Use digital/serial/analog");
|
Debug.LogMessage(LogEventLevel.Verbose, "Unknown join type. Use digital/serial/analog");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Error: {0}", e);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Error: {0}", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -375,12 +297,12 @@ namespace PepperDash.Essentials.Core.Bridges
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "EiscApiAdvanced change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue);
|
Debug.LogMessage(LogEventLevel.Verbose, this, "EiscApiAdvanced change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue);
|
||||||
var uo = args.Sig.UserObject;
|
var uo = args.Sig.UserObject;
|
||||||
|
|
||||||
if (uo == null) return;
|
if (uo == null) return;
|
||||||
|
|
||||||
Debug.Console(1, this, "Executing Action: {0}", uo.ToString());
|
Debug.LogMessage(LogEventLevel.Debug, this, "Executing Action: {0}", uo.ToString());
|
||||||
if (uo is Action<bool>)
|
if (uo is Action<bool>)
|
||||||
(uo as Action<bool>)(args.Sig.BoolValue);
|
(uo as Action<bool>)(args.Sig.BoolValue);
|
||||||
else if (uo is Action<ushort>)
|
else if (uo is Action<ushort>)
|
||||||
@@ -390,7 +312,7 @@ namespace PepperDash.Essentials.Core.Bridges
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "Error in Eisc_SigChange handler: {0}", e);
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Error in Eisc_SigChange handler: {0}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -448,7 +370,7 @@ namespace PepperDash.Essentials.Core.Bridges
|
|||||||
|
|
||||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Factory Attempting to create new EiscApiAdvanced Device");
|
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new EiscApiAdvanced Device");
|
||||||
|
|
||||||
var controlProperties = CommFactory.GetControlPropertiesConfig(dc);
|
var controlProperties = CommFactory.GetControlPropertiesConfig(dc);
|
||||||
|
|
||||||
@@ -478,7 +400,7 @@ namespace PepperDash.Essentials.Core.Bridges
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(controlProperties.RoomId))
|
if (string.IsNullOrEmpty(controlProperties.RoomId))
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to build VC-4 EISC Client for device {0}. Room ID is missing or empty", dc.Key);
|
Debug.LogMessage(LogEventLevel.Information, "Unable to build VC-4 EISC Client for device {0}. Room ID is missing or empty", dc.Key);
|
||||||
eisc = null;
|
eisc = null;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
66
src/PepperDash.Essentials.Core/Bridges/BridgeHelper.cs
Normal file
66
src/PepperDash.Essentials.Core/Bridges/BridgeHelper.cs
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
using PepperDash.Core;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
|
//using PepperDash.Essentials.Devices.Common.Cameras;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.Bridges
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Helper methods for bridges
|
||||||
|
/// </summary>
|
||||||
|
public static class BridgeHelper
|
||||||
|
{
|
||||||
|
public static void PrintJoinMap(string command)
|
||||||
|
{
|
||||||
|
var targets = command.Split(' ');
|
||||||
|
|
||||||
|
var bridgeKey = targets[0].Trim();
|
||||||
|
|
||||||
|
if (!(DeviceManager.GetDeviceForKey(bridgeKey) is EiscApiAdvanced bridge))
|
||||||
|
{
|
||||||
|
Debug.LogMessage(LogEventLevel.Information, "Unable to find advanced bridge with key: '{0}'", bridgeKey);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (targets.Length > 1)
|
||||||
|
{
|
||||||
|
var deviceKey = targets[1].Trim();
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(deviceKey)) return;
|
||||||
|
bridge.PrintJoinMapForDevice(deviceKey);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bridge.PrintJoinMaps();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void JoinmapMarkdown(string command)
|
||||||
|
{
|
||||||
|
var targets = command.Split(' ');
|
||||||
|
|
||||||
|
var bridgeKey = targets[0].Trim();
|
||||||
|
|
||||||
|
var bridge = DeviceManager.GetDeviceForKey(bridgeKey) as EiscApiAdvanced;
|
||||||
|
|
||||||
|
if (bridge == null)
|
||||||
|
{
|
||||||
|
Debug.LogMessage(LogEventLevel.Information, "Unable to find advanced bridge with key: '{0}'", bridgeKey);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (targets.Length > 1)
|
||||||
|
{
|
||||||
|
var deviceKey = targets[1].Trim();
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(deviceKey)) return;
|
||||||
|
bridge.MarkdownJoinMapForDevice(deviceKey, bridgeKey);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bridge.MarkdownForBridge(bridgeKey);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ using Crestron.SimplSharpPro;
|
|||||||
using Crestron.SimplSharpPro.DM;
|
using Crestron.SimplSharpPro.DM;
|
||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
@@ -49,7 +50,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
OnDataReceived(cecDevice.Received.StringValue);
|
OnDataReceived(cecDevice.Received.StringValue);
|
||||||
else if (args.EventId == CecEventIds.ErrorFeedbackEventId)
|
else if (args.EventId == CecEventIds.ErrorFeedbackEventId)
|
||||||
if(cecDevice.ErrorFeedback.BoolValue)
|
if(cecDevice.ErrorFeedback.BoolValue)
|
||||||
Debug.Console(2, this, "CEC NAK Error");
|
Debug.LogMessage(LogEventLevel.Verbose, this, "CEC NAK Error");
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnDataReceived(string s)
|
void OnDataReceived(string s)
|
||||||
@@ -59,14 +60,14 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
var bytes = Encoding.GetEncoding(28591).GetBytes(s);
|
var bytes = Encoding.GetEncoding(28591).GetBytes(s);
|
||||||
if (StreamDebugging.RxStreamDebuggingIsEnabled)
|
if (StreamDebugging.RxStreamDebuggingIsEnabled)
|
||||||
Debug.Console(0, this, "Received: '{0}'", ComTextHelper.GetEscapedText(bytes));
|
Debug.LogMessage(LogEventLevel.Information, this, "Received: '{0}'", ComTextHelper.GetEscapedText(bytes));
|
||||||
bytesHandler(this, new GenericCommMethodReceiveBytesArgs(bytes));
|
bytesHandler(this, new GenericCommMethodReceiveBytesArgs(bytes));
|
||||||
}
|
}
|
||||||
var textHandler = TextReceived;
|
var textHandler = TextReceived;
|
||||||
if (textHandler != null)
|
if (textHandler != null)
|
||||||
{
|
{
|
||||||
if (StreamDebugging.RxStreamDebuggingIsEnabled)
|
if (StreamDebugging.RxStreamDebuggingIsEnabled)
|
||||||
Debug.Console(0, this, "Received: '{0}'", s);
|
Debug.LogMessage(LogEventLevel.Information, this, "Received: '{0}'", s);
|
||||||
textHandler(this, new GenericCommMethodReceiveTextArgs(s));
|
textHandler(this, new GenericCommMethodReceiveTextArgs(s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -78,7 +79,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
if (Port == null)
|
if (Port == null)
|
||||||
return;
|
return;
|
||||||
if (StreamDebugging.TxStreamDebuggingIsEnabled)
|
if (StreamDebugging.TxStreamDebuggingIsEnabled)
|
||||||
Debug.Console(0, this, "Sending {0} characters of text: '{1}'", text.Length, text);
|
Debug.LogMessage(LogEventLevel.Information, this, "Sending {0} characters of text: '{1}'", text.Length, text);
|
||||||
Port.StreamCec.Send.StringValue = text;
|
Port.StreamCec.Send.StringValue = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +89,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
return;
|
return;
|
||||||
var text = Encoding.GetEncoding(28591).GetString(bytes, 0, bytes.Length);
|
var text = Encoding.GetEncoding(28591).GetString(bytes, 0, bytes.Length);
|
||||||
if (StreamDebugging.TxStreamDebuggingIsEnabled)
|
if (StreamDebugging.TxStreamDebuggingIsEnabled)
|
||||||
Debug.Console(0, this, "Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes));
|
Debug.LogMessage(LogEventLevel.Information, this, "Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes));
|
||||||
Port.StreamCec.Send.StringValue = text;
|
Port.StreamCec.Send.StringValue = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using Crestron.SimplSharp;
|
|||||||
using Crestron.SimplSharpPro;
|
using Crestron.SimplSharpPro;
|
||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
@@ -43,7 +44,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
if (port == null)
|
if (port == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "ERROR: Invalid com port, continuing but comms will not function");
|
Debug.LogMessage(LogEventLevel.Information, this, "ERROR: Invalid com port, continuing but comms will not function");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,7 +59,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
if (Port == null)
|
if (Port == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0,this,Debug.ErrorLogLevel.Error, "Configured com Port for this device does not exist.");
|
Debug.LogMessage(LogEventLevel.Information, this, "Configured com Port for this device does not exist.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Port.Parent is CrestronControlSystem)
|
if (Port.Parent is CrestronControlSystem)
|
||||||
@@ -66,7 +67,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
var result = Port.Register();
|
var result = Port.Register();
|
||||||
if (result != eDeviceRegistrationUnRegistrationResponse.Success)
|
if (result != eDeviceRegistrationUnRegistrationResponse.Success)
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "ERROR: Cannot register Com port: {0}", result);
|
Debug.LogMessage(LogEventLevel.Information, this, "ERROR: Cannot register Com port: {0}", result);
|
||||||
return; // false
|
return; // false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,7 +75,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
var specResult = Port.SetComPortSpec(Spec);
|
var specResult = Port.SetComPortSpec(Spec);
|
||||||
if (specResult != 0)
|
if (specResult != 0)
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "WARNING: Cannot set comspec");
|
Debug.LogMessage(LogEventLevel.Information, this, "WARNING: Cannot set comspec");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Port.SerialDataReceived += Port_SerialDataReceived;
|
Port.SerialDataReceived += Port_SerialDataReceived;
|
||||||
@@ -92,22 +93,27 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
void OnDataReceived(string s)
|
void OnDataReceived(string s)
|
||||||
{
|
{
|
||||||
|
var eventSubscribed = false;
|
||||||
|
|
||||||
var bytesHandler = BytesReceived;
|
var bytesHandler = BytesReceived;
|
||||||
if (bytesHandler != null)
|
if (bytesHandler != null)
|
||||||
{
|
{
|
||||||
var bytes = Encoding.GetEncoding(28591).GetBytes(s);
|
var bytes = Encoding.GetEncoding(28591).GetBytes(s);
|
||||||
if (StreamDebugging.RxStreamDebuggingIsEnabled)
|
if (StreamDebugging.RxStreamDebuggingIsEnabled)
|
||||||
Debug.Console(0, this, "Received: '{0}'", ComTextHelper.GetEscapedText(bytes));
|
Debug.LogMessage(LogEventLevel.Information, this, "Received: '{0}'", ComTextHelper.GetEscapedText(bytes));
|
||||||
bytesHandler(this, new GenericCommMethodReceiveBytesArgs(bytes));
|
bytesHandler(this, new GenericCommMethodReceiveBytesArgs(bytes));
|
||||||
|
eventSubscribed = true;
|
||||||
}
|
}
|
||||||
var textHandler = TextReceived;
|
var textHandler = TextReceived;
|
||||||
if (textHandler != null)
|
if (textHandler != null)
|
||||||
{
|
{
|
||||||
if (StreamDebugging.RxStreamDebuggingIsEnabled)
|
if (StreamDebugging.RxStreamDebuggingIsEnabled)
|
||||||
Debug.Console(0, this, "Received: '{0}'", s);
|
Debug.LogMessage(LogEventLevel.Information, this, "Received: '{0}'", s);
|
||||||
textHandler(this, new GenericCommMethodReceiveTextArgs(s));
|
textHandler(this, new GenericCommMethodReceiveTextArgs(s));
|
||||||
|
eventSubscribed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!eventSubscribed) Debug.LogMessage(LogEventLevel.Warning, this, "Received data but no handler is registered");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Deactivate()
|
public override bool Deactivate()
|
||||||
@@ -123,7 +129,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (StreamDebugging.TxStreamDebuggingIsEnabled)
|
if (StreamDebugging.TxStreamDebuggingIsEnabled)
|
||||||
Debug.Console(0, this, "Sending {0} characters of text: '{1}'", text.Length, text);
|
Debug.LogMessage(LogEventLevel.Information, this, "Sending {0} characters of text: '{1}'", text.Length, text);
|
||||||
Port.Send(text);
|
Port.Send(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,7 +139,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
return;
|
return;
|
||||||
var text = Encoding.GetEncoding(28591).GetString(bytes, 0, bytes.Length);
|
var text = Encoding.GetEncoding(28591).GetString(bytes, 0, bytes.Length);
|
||||||
if (StreamDebugging.TxStreamDebuggingIsEnabled)
|
if (StreamDebugging.TxStreamDebuggingIsEnabled)
|
||||||
Debug.Console(0, this, "Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes));
|
Debug.LogMessage(LogEventLevel.Information, this, "Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes));
|
||||||
|
|
||||||
Port.Send(text);
|
Port.Send(text);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,12 +23,12 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||||
{
|
{
|
||||||
if (objectType == typeof(ComPort.ComPortSpec))
|
if (objectType == typeof(ComPort.ComPortSpec?))
|
||||||
{
|
{
|
||||||
var newSer = new JsonSerializer();
|
var newSer = new JsonSerializer();
|
||||||
newSer.Converters.Add(new ComSpecPropsJsonConverter());
|
newSer.Converters.Add(new ComSpecPropsJsonConverter());
|
||||||
newSer.ObjectCreationHandling = ObjectCreationHandling.Replace;
|
newSer.ObjectCreationHandling = ObjectCreationHandling.Replace;
|
||||||
return newSer.Deserialize<ComPort.ComPortSpec>(reader);
|
return newSer.Deserialize<ComPort.ComPortSpec?>(reader);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -38,7 +38,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public override bool CanConvert(Type objectType)
|
public override bool CanConvert(Type objectType)
|
||||||
{
|
{
|
||||||
return objectType == typeof(ComPort.ComPortSpec);
|
return objectType == typeof(ComPort.ComPortSpec?);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool CanRead { get { return true; } }
|
public override bool CanRead { get { return true; } }
|
||||||
@@ -76,7 +76,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||||
{
|
{
|
||||||
//Debug.Console(2, "ReadJson type: " + objectType.Name);
|
//Debug.LogMessage(LogEventLevel.Verbose, "ReadJson type: " + objectType.Name);
|
||||||
if (objectType == typeof(ComPort.eComBaudRates))
|
if (objectType == typeof(ComPort.eComBaudRates))
|
||||||
return Enum.Parse(typeof(ComPort.eComBaudRates), "ComspecBaudRate" + reader.Value, false);
|
return Enum.Parse(typeof(ComPort.eComBaudRates), "ComspecBaudRate" + reader.Value, false);
|
||||||
else if (objectType == typeof(ComPort.eComDataBits))
|
else if (objectType == typeof(ComPort.eComDataBits))
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using Newtonsoft.Json;
|
|||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
@@ -22,12 +23,12 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
return JsonConvert.DeserializeObject<EssentialsControlPropertiesConfig>
|
return JsonConvert.DeserializeObject<EssentialsControlPropertiesConfig>
|
||||||
(deviceConfig.Properties["control"].ToString());
|
(deviceConfig.Properties["control"].ToString());
|
||||||
//Debug.Console(2, "Control TEST: {0}", JsonConvert.SerializeObject(controlConfig));
|
//Debug.LogMessage(LogEventLevel.Verbose, "Control TEST: {0}", JsonConvert.SerializeObject(controlConfig));
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
||||||
Debug.Console(0, "ERROR: [{0}] Control properties deserialize failed:\r{1}", deviceConfig.Key, e);
|
Debug.LogMessage(LogEventLevel.Information, "ERROR: [{0}] Control properties deserialize failed:\r{1}", deviceConfig.Key, e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -50,7 +51,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
switch (controlConfig.Method)
|
switch (controlConfig.Method)
|
||||||
{
|
{
|
||||||
case eControlMethod.Com:
|
case eControlMethod.Com:
|
||||||
comm = new ComPortController(deviceConfig.Key + "-com", GetComPort, controlConfig.ComParams, controlConfig);
|
comm = new ComPortController(deviceConfig.Key + "-com", GetComPort, controlConfig.ComParams.Value, controlConfig);
|
||||||
break;
|
break;
|
||||||
case eControlMethod.Cec:
|
case eControlMethod.Cec:
|
||||||
comm = new CecPortController(deviceConfig.Key + "-cec", GetCecPort, controlConfig);
|
comm = new CecPortController(deviceConfig.Key + "-cec", GetCecPort, controlConfig);
|
||||||
@@ -98,7 +99,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Cannot create communication from JSON:\r{0}\r\rException:\r{1}",
|
Debug.LogMessage(LogEventLevel.Information, "Cannot create communication from JSON:\r{0}\r\rException:\r{1}",
|
||||||
deviceConfig.Properties.ToString(), e);
|
deviceConfig.Properties.ToString(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,8 +115,8 @@ namespace PepperDash.Essentials.Core
|
|||||||
var comPar = config.ComParams;
|
var comPar = config.ComParams;
|
||||||
var dev = GetIComPortsDeviceFromManagedDevice(config.ControlPortDevKey);
|
var dev = GetIComPortsDeviceFromManagedDevice(config.ControlPortDevKey);
|
||||||
if (dev != null && config.ControlPortNumber <= dev.NumberOfComPorts)
|
if (dev != null && config.ControlPortNumber <= dev.NumberOfComPorts)
|
||||||
return dev.ComPorts[config.ControlPortNumber];
|
return dev.ComPorts[config.ControlPortNumber.Value];
|
||||||
Debug.Console(0,Debug.ErrorLogLevel.Notice, "GetComPort: Device '{0}' does not have com port {1}", config.ControlPortDevKey, config.ControlPortNumber);
|
Debug.LogMessage(LogEventLevel.Information, "GetComPort: Device '{0}' does not have com port {1}", config.ControlPortDevKey, config.ControlPortNumber);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,7 +131,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
var dev = DeviceManager.GetDeviceForKey(config.ControlPortDevKey);
|
var dev = DeviceManager.GetDeviceForKey(config.ControlPortDevKey);
|
||||||
|
|
||||||
Debug.Console(0, "GetCecPort: device '{0}' {1}", config.ControlPortDevKey, dev == null
|
Debug.LogMessage(LogEventLevel.Information, "GetCecPort: device '{0}' {1}", config.ControlPortDevKey, dev == null
|
||||||
? "is not valid, failed to get cec port"
|
? "is not valid, failed to get cec port"
|
||||||
: "found in device manager, attempting to get cec port");
|
: "found in device manager, attempting to get cec port");
|
||||||
|
|
||||||
@@ -139,7 +140,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
if (String.IsNullOrEmpty(config.ControlPortName))
|
if (String.IsNullOrEmpty(config.ControlPortName))
|
||||||
{
|
{
|
||||||
Debug.Console(0, "GetCecPort: '{0}' - Configuration missing 'ControlPortName'", config.ControlPortDevKey);
|
Debug.LogMessage(LogEventLevel.Information, "GetCecPort: '{0}' - Configuration missing 'ControlPortName'", config.ControlPortDevKey);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,7 +148,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
var inputsOutputs = dev as IRoutingInputsOutputs;
|
var inputsOutputs = dev as IRoutingInputsOutputs;
|
||||||
if (inputsOutputs == null)
|
if (inputsOutputs == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "GetCecPort: Device '{0}' does not support IRoutingInputsOutputs, failed to get CEC port called '{1}'",
|
Debug.LogMessage(LogEventLevel.Information, "GetCecPort: Device '{0}' does not support IRoutingInputsOutputs, failed to get CEC port called '{1}'",
|
||||||
config.ControlPortDevKey, config.ControlPortName);
|
config.ControlPortDevKey, config.ControlPortName);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@@ -164,13 +165,13 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "GetCecPort Exception Message: {0}", ex.Message);
|
Debug.LogMessage(LogEventLevel.Debug, "GetCecPort Exception Message: {0}", ex.Message);
|
||||||
Debug.Console(2, "GetCecPort Exception StackTrace: {0}", ex.StackTrace);
|
Debug.LogMessage(LogEventLevel.Verbose, "GetCecPort Exception StackTrace: {0}", ex.StackTrace);
|
||||||
if (ex.InnerException != null)
|
if (ex.InnerException != null)
|
||||||
Debug.Console(0, "GetCecPort Exception InnerException: {0}", ex.InnerException);
|
Debug.LogMessage(LogEventLevel.Information, "GetCecPort Exception InnerException: {0}", ex.InnerException);
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(0, "GetCecPort: Device '{0}' does not have a CEC port called '{1}'",
|
Debug.LogMessage(LogEventLevel.Information, "GetCecPort: Device '{0}' does not have a CEC port called '{1}'",
|
||||||
config.ControlPortDevKey, config.ControlPortName);
|
config.ControlPortDevKey, config.ControlPortName);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@@ -191,7 +192,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
var dev = DeviceManager.GetDeviceForKey(ComPortDevKey) as IComPorts;
|
var dev = DeviceManager.GetDeviceForKey(ComPortDevKey) as IComPorts;
|
||||||
if (dev == null)
|
if (dev == null)
|
||||||
Debug.Console(0, "ComPortConfig: Cannot find com port device '{0}'", ComPortDevKey);
|
Debug.LogMessage(LogEventLevel.Information, "ComPortConfig: Cannot find com port device '{0}'", ComPortDevKey);
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -201,19 +202,20 @@ namespace PepperDash.Essentials.Core
|
|||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class EssentialsControlPropertiesConfig :
|
public class EssentialsControlPropertiesConfig :
|
||||||
PepperDash.Core.ControlPropertiesConfig
|
ControlPropertiesConfig
|
||||||
{
|
{
|
||||||
|
|
||||||
|
[JsonProperty("comParams", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
[JsonConverter(typeof(ComSpecJsonConverter))]
|
[JsonConverter(typeof(ComSpecJsonConverter))]
|
||||||
public ComPort.ComPortSpec ComParams { get; set; }
|
public ComPort.ComPortSpec? ComParams { get; set; }
|
||||||
|
|
||||||
public string RoomId { get; set; }
|
[JsonProperty("cresnetId", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
|
public string CresnetId { get; set; }
|
||||||
public string CresnetId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Attempts to provide uint conversion of string CresnetId
|
/// Attempts to provide uint conversion of string CresnetId
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[JsonIgnore]
|
||||||
public uint CresnetIdInt
|
public uint CresnetIdInt
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -229,11 +231,13 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonProperty("infinetId", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
public string InfinetId { get; set; }
|
public string InfinetId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Attepmts to provide uiont conversion of string InifinetId
|
/// Attepmts to provide uiont conversion of string InifinetId
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[JsonIgnore]
|
||||||
public uint InfinetIdInt
|
public uint InfinetIdInt
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using Crestron.SimplSharp;
|
|||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
@@ -39,7 +40,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
public override bool CustomActivate()
|
public override bool CustomActivate()
|
||||||
{
|
{
|
||||||
Communication.Connect();
|
Communication.Connect();
|
||||||
CommunicationMonitor.StatusChange += (o, a) => { Debug.Console(2, this, "Communication monitor state: {0}", CommunicationMonitor.Status); };
|
CommunicationMonitor.StatusChange += (o, a) => { Debug.LogMessage(LogEventLevel.Verbose, this, "Communication monitor state: {0}", CommunicationMonitor.Status); };
|
||||||
CommunicationMonitor.Start();
|
CommunicationMonitor.Start();
|
||||||
|
|
||||||
CrestronConsole.AddNewConsoleCommand(SendLine, "send" + Key, "", ConsoleAccessLevelEnum.AccessOperator);
|
CrestronConsole.AddNewConsoleCommand(SendLine, "send" + Key, "", ConsoleAccessLevelEnum.AccessOperator);
|
||||||
@@ -50,7 +51,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
void SendLine(string s)
|
void SendLine(string s)
|
||||||
{
|
{
|
||||||
//if (Debug.Level == 2)
|
//if (Debug.Level == 2)
|
||||||
// Debug.Console(2, this, " Send '{0}'", ComTextHelper.GetEscapedText(s));
|
// Debug.LogMessage(LogEventLevel.Verbose, this, " Send '{0}'", ComTextHelper.GetEscapedText(s));
|
||||||
Communication.SendText(s + LineEnding);
|
Communication.SendText(s + LineEnding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,7 +76,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Factory Attempting to create new Comm Mock Device");
|
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Comm Mock Device");
|
||||||
var comm = CommFactory.CreateCommForDevice(dc);
|
var comm = CommFactory.CreateCommForDevice(dc);
|
||||||
var props = Newtonsoft.Json.JsonConvert.DeserializeObject<ConsoleCommMockDevicePropertiesConfig>(
|
var props = Newtonsoft.Json.JsonConvert.DeserializeObject<ConsoleCommMockDevicePropertiesConfig>(
|
||||||
dc.Properties.ToString());
|
dc.Properties.ToString());
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ using PepperDash.Core;
|
|||||||
using PepperDash.Essentials.Core.Bridges;
|
using PepperDash.Essentials.Core.Bridges;
|
||||||
using PepperDash.Essentials.Core.Devices;
|
using PepperDash.Essentials.Core.Devices;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
@@ -45,7 +46,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
public static IKeyed BuildDevice(DeviceConfig dc)
|
public static IKeyed BuildDevice(DeviceConfig dc)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Factory Attempting to create new Generic Comm Device");
|
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic Comm Device");
|
||||||
return new GenericComm(dc);
|
return new GenericComm(dc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +60,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "Error deserializing port config: {0}", e);
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Error deserializing port config: {0}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,16 +86,16 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CommPort == null)
|
if (CommPort == null)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Unable to link device '{0}'. CommPort is null", Key);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Unable to link device '{0}'. CommPort is null", Key);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
Debug.LogMessage(LogEventLevel.Debug, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
||||||
|
|
||||||
// this is a permanent event handler. This cannot be -= from event
|
// this is a permanent event handler. This cannot be -= from event
|
||||||
CommPort.TextReceived += (s, a) =>
|
CommPort.TextReceived += (s, a) =>
|
||||||
@@ -137,7 +138,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Factory Attempting to create new Generic Comm Device");
|
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic Comm Device");
|
||||||
return new GenericComm(dc);
|
return new GenericComm(dc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,10 @@
|
|||||||
using System;
|
using Crestron.SimplSharp.Net.Http;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Crestron.SimplSharp.Net.Http;
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Core.DebugThings;
|
using System;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
[Obsolete("Please use the builtin HttpClient class instead: https://learn.microsoft.com/en-us/dotnet/fundamentals/networking/http/httpclient-guidelines")]
|
[Obsolete("Please use the builtin HttpClient class instead: https://learn.microsoft.com/en-us/dotnet/fundamentals/networking/http/httpclient-guidelines")]
|
||||||
public class GenericHttpClient : Device, IBasicCommunication
|
public class GenericHttpClient : Device, IBasicCommunication
|
||||||
{
|
{
|
||||||
public HttpClient Client;
|
public HttpClient Client;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ using Newtonsoft.Json;
|
|||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
@@ -40,7 +41,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
return null;
|
return null;
|
||||||
if (control["method"].Value<string>() != "ir")
|
if (control["method"].Value<string>() != "ir")
|
||||||
{
|
{
|
||||||
Debug.Console(0, "IRPortHelper called with non-IR properties");
|
Debug.LogMessage(LogEventLevel.Information, "IRPortHelper called with non-IR properties");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +51,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
var portNum = control.Value<uint>("controlPortNumber");
|
var portNum = control.Value<uint>("controlPortNumber");
|
||||||
if (portDevKey == null || portNum == 0)
|
if (portDevKey == null || portNum == 0)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "WARNING: Properties is missing port device or port number");
|
Debug.LogMessage(LogEventLevel.Debug, "WARNING: Properties is missing port device or port number");
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +64,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
if (irDev == null)
|
if (irDev == null)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "[Config] Error, device with IR ports '{0}' not found", portDevKey);
|
Debug.LogMessage(LogEventLevel.Debug, "[Config] Error, device with IR ports '{0}' not found", portDevKey);
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +77,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(1, "[Config] Error, device '{0}' IR port {1} out of range",
|
Debug.LogMessage(LogEventLevel.Debug, "[Config] Error, device '{0}' IR port {1} out of range",
|
||||||
portDevKey, portNum);
|
portDevKey, portNum);
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
@@ -87,14 +88,14 @@ namespace PepperDash.Essentials.Core
|
|||||||
var irControllerKey = dc.Key + "-ir";
|
var irControllerKey = dc.Key + "-ir";
|
||||||
if (dc.Properties == null)
|
if (dc.Properties == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "[{0}] WARNING: Device config does not include properties. IR will not function.", dc.Key);
|
Debug.LogMessage(LogEventLevel.Information, "[{0}] WARNING: Device config does not include properties. IR will not function.", dc.Key);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var control = dc.Properties["control"];
|
var control = dc.Properties["control"];
|
||||||
if (control == null)
|
if (control == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0,
|
Debug.LogMessage(LogEventLevel.Information,
|
||||||
"WARNING: Device config does not include control properties. IR will not function for {0}", dc.Key);
|
"WARNING: Device config does not include control properties. IR will not function for {0}", dc.Key);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -105,13 +106,13 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
if (portDevKey == null)
|
if (portDevKey == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "WARNING: control properties is missing ir device for {0}", dc.Key);
|
Debug.LogMessage(LogEventLevel.Information, "WARNING: control properties is missing ir device for {0}", dc.Key);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (portNum == 0)
|
if (portNum == 0)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "WARNING: control properties is missing ir port number for {0}", dc.Key);
|
Debug.LogMessage(LogEventLevel.Information, "WARNING: control properties is missing ir port number for {0}", dc.Key);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,12 +124,12 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
if (irDev == null)
|
if (irDev == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "WARNING: device with IR ports '{0}' not found", portDevKey);
|
Debug.LogMessage(LogEventLevel.Information, "WARNING: device with IR ports '{0}' not found", portDevKey);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (portNum > irDev.NumberOfIROutputPorts)
|
if (portNum > irDev.NumberOfIROutputPorts)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "WARNING: device '{0}' IR port {1} out of range",
|
Debug.LogMessage(LogEventLevel.Information, "WARNING: device '{0}' IR port {1} out of range",
|
||||||
portDevKey, portNum);
|
portDevKey, portNum);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -143,7 +144,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
public static IrOutputPortController GetIrOutputPortController(DeviceConfig config)
|
public static IrOutputPortController GetIrOutputPortController(DeviceConfig config)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Attempting to create new Ir Port Controller");
|
Debug.LogMessage(LogEventLevel.Debug, "Attempting to create new Ir Port Controller");
|
||||||
|
|
||||||
if (config == null)
|
if (config == null)
|
||||||
{
|
{
|
||||||
@@ -165,7 +166,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
var irControllerKey = devConf.Key + "-ir";
|
var irControllerKey = devConf.Key + "-ir";
|
||||||
if (devConf.Properties == null)
|
if (devConf.Properties == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "[{0}] WARNING: Device config does not include properties. IR will not function.", devConf.Key);
|
Debug.LogMessage(LogEventLevel.Information, "[{0}] WARNING: Device config does not include properties. IR will not function.", devConf.Key);
|
||||||
return new IrOutputPortController(irControllerKey, null, "");
|
return new IrOutputPortController(irControllerKey, null, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,7 +174,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
if (control == null)
|
if (control == null)
|
||||||
{
|
{
|
||||||
var c = new IrOutputPortController(irControllerKey, null, "");
|
var c = new IrOutputPortController(irControllerKey, null, "");
|
||||||
Debug.Console(0, c, "WARNING: Device config does not include control properties. IR will not function");
|
Debug.LogMessage(LogEventLevel.Information, c, "WARNING: Device config does not include control properties. IR will not function");
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,14 +185,14 @@ namespace PepperDash.Essentials.Core
|
|||||||
if (portDevKey == null)
|
if (portDevKey == null)
|
||||||
{
|
{
|
||||||
var c = new IrOutputPortController(irControllerKey, null, "");
|
var c = new IrOutputPortController(irControllerKey, null, "");
|
||||||
Debug.Console(0, c, "WARNING: control properties is missing ir device");
|
Debug.LogMessage(LogEventLevel.Information, c, "WARNING: control properties is missing ir device");
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (portNum == 0)
|
if (portNum == 0)
|
||||||
{
|
{
|
||||||
var c = new IrOutputPortController(irControllerKey, null, "");
|
var c = new IrOutputPortController(irControllerKey, null, "");
|
||||||
Debug.Console(0, c, "WARNING: control properties is missing ir port number");
|
Debug.LogMessage(LogEventLevel.Information, c, "WARNING: control properties is missing ir port number");
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,7 +205,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
if (irDev == null)
|
if (irDev == null)
|
||||||
{
|
{
|
||||||
var c = new IrOutputPortController(irControllerKey, null, "");
|
var c = new IrOutputPortController(irControllerKey, null, "");
|
||||||
Debug.Console(0, c, "WARNING: device with IR ports '{0}' not found", portDevKey);
|
Debug.LogMessage(LogEventLevel.Information, c, "WARNING: device with IR ports '{0}' not found", portDevKey);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,7 +215,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
var c = new IrOutputPortController(irControllerKey, null, "");
|
var c = new IrOutputPortController(irControllerKey, null, "");
|
||||||
Debug.Console(0, c, "WARNING: device '{0}' IR port {1} out of range",
|
Debug.LogMessage(LogEventLevel.Information, c, "WARNING: device '{0}' IR port {1} out of range",
|
||||||
portDevKey, portNum);
|
portDevKey, portNum);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
using Crestron.SimplSharpPro;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.Config
|
||||||
|
{
|
||||||
|
public class AudioControlPointListItem
|
||||||
|
{
|
||||||
|
[JsonProperty("levelControls")]
|
||||||
|
public Dictionary<string, LevelControlListItem> LevelControls { get; set; } = new Dictionary<string, LevelControlListItem>();
|
||||||
|
|
||||||
|
[JsonProperty("presets")]
|
||||||
|
public Dictionary<string, PresetListItem> Presets { get; set; } = new Dictionary<string, PresetListItem>();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ using System.Linq;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
using PepperDash.Essentials.Core.Devices;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Config
|
namespace PepperDash.Essentials.Core.Config
|
||||||
{
|
{
|
||||||
@@ -23,7 +24,13 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
public Dictionary<string, Dictionary<string, SourceListItem>> SourceLists { get; set; }
|
public Dictionary<string, Dictionary<string, SourceListItem>> SourceLists { get; set; }
|
||||||
|
|
||||||
[JsonProperty("destinationLists")]
|
[JsonProperty("destinationLists")]
|
||||||
public Dictionary<string, Dictionary<string,DestinationListItem>> DestinationLists { get; set; }
|
public Dictionary<string, Dictionary<string, DestinationListItem>> DestinationLists { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("audioControlPointLists")]
|
||||||
|
public Dictionary<string, AudioControlPointListItem> AudioControlPointLists { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("cameraLists")]
|
||||||
|
public Dictionary<string, Dictionary<string, CameraListItem>> CameraLists { get; set; }
|
||||||
|
|
||||||
[JsonProperty("tieLines")]
|
[JsonProperty("tieLines")]
|
||||||
public List<TieLineConfig> TieLines { get; set; }
|
public List<TieLineConfig> TieLines { get; set; }
|
||||||
@@ -37,6 +44,8 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
Devices = new List<DeviceConfig>();
|
Devices = new List<DeviceConfig>();
|
||||||
SourceLists = new Dictionary<string, Dictionary<string, SourceListItem>>();
|
SourceLists = new Dictionary<string, Dictionary<string, SourceListItem>>();
|
||||||
DestinationLists = new Dictionary<string, Dictionary<string, DestinationListItem>>();
|
DestinationLists = new Dictionary<string, Dictionary<string, DestinationListItem>>();
|
||||||
|
AudioControlPointLists = new Dictionary<string, AudioControlPointListItem>();
|
||||||
|
CameraLists = new Dictionary<string, Dictionary<string, CameraListItem>>();
|
||||||
TieLines = new List<TieLineConfig>();
|
TieLines = new List<TieLineConfig>();
|
||||||
JoinMaps = new Dictionary<string, JObject>();
|
JoinMaps = new Dictionary<string, JObject>();
|
||||||
}
|
}
|
||||||
@@ -46,7 +55,7 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<string, SourceListItem> GetSourceListForKey(string key)
|
public Dictionary<string, SourceListItem> GetSourceListForKey(string key)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(key) || !SourceLists.ContainsKey(key))
|
if (SourceLists == null || string.IsNullOrEmpty(key) || !SourceLists.ContainsKey(key))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return SourceLists[key];
|
return SourceLists[key];
|
||||||
@@ -55,11 +64,11 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves a DestinationListItem based on the key
|
/// Retrieves a DestinationListItem based on the key
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="key">key of the item to retrieve</param>
|
/// <param name="key">key of the list to retrieve</param>
|
||||||
/// <returns>DestinationListItem if the key exists, null otherwise</returns>
|
/// <returns>DestinationList if the key exists, null otherwise</returns>
|
||||||
public Dictionary<string, DestinationListItem> GetDestinationListForKey(string key)
|
public Dictionary<string, DestinationListItem> GetDestinationListForKey(string key)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(key) || !DestinationLists.ContainsKey(key))
|
if (DestinationLists == null || string.IsNullOrEmpty(key) || !DestinationLists.ContainsKey(key))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -67,6 +76,30 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
return DestinationLists[key];
|
return DestinationLists[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves a AudioControlPointList based on the key
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">key of the list to retrieve</param>
|
||||||
|
/// <returns>AudioControlPointList if the key exists, null otherwise</returns>
|
||||||
|
public AudioControlPointListItem GetAudioControlPointListForKey(string key)
|
||||||
|
{
|
||||||
|
if (AudioControlPointLists == null || string.IsNullOrEmpty(key) || !AudioControlPointLists.ContainsKey(key))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return AudioControlPointLists[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks CameraLists for a given list and returns it if found. Otherwise, returns null
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<string, CameraListItem> GetCameraListForKey(string key)
|
||||||
|
{
|
||||||
|
if (CameraLists == null || string.IsNullOrEmpty(key) || !CameraLists.ContainsKey(key))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return CameraLists[key];
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks Devices for an item with a Key that matches and returns it if found. Otherwise, retunes null
|
/// Checks Devices for an item with a Key that matches and returns it if found. Otherwise, retunes null
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ using Newtonsoft.Json;
|
|||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Core.Config;
|
using PepperDash.Core.Config;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Config
|
namespace PepperDash.Essentials.Core.Config
|
||||||
{
|
{
|
||||||
@@ -27,7 +28,7 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
|
|
||||||
public static bool LoadConfig2()
|
public static bool LoadConfig2()
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading unmerged system/template portal configuration file.");
|
Debug.LogMessage(LogEventLevel.Information, "Loading unmerged system/template portal configuration file.");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Check for local config file first
|
// Check for local config file first
|
||||||
@@ -35,7 +36,7 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
|
|
||||||
bool localConfigFound = false;
|
bool localConfigFound = false;
|
||||||
|
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to load Local config file: '{0}'", filePath);
|
Debug.LogMessage(LogEventLevel.Information, "Attempting to load Local config file: '{0}'", filePath);
|
||||||
|
|
||||||
// Check for local config directory first
|
// Check for local config directory first
|
||||||
|
|
||||||
@@ -45,7 +46,7 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
{
|
{
|
||||||
if (configFiles.Length > 1)
|
if (configFiles.Length > 1)
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error,
|
Debug.LogMessage(LogEventLevel.Information,
|
||||||
"****Error: Multiple Local Configuration files present. Please ensure only a single file exists and reset program.****");
|
"****Error: Multiple Local Configuration files present. Please ensure only a single file exists and reset program.****");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -57,7 +58,7 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice,
|
Debug.LogMessage(LogEventLevel.Information,
|
||||||
"Local Configuration file not present.", filePath);
|
"Local Configuration file not present.", filePath);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -67,33 +68,33 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
{
|
{
|
||||||
filePath = Global.FilePathPrefix + Global.ConfigFileName;
|
filePath = Global.FilePathPrefix + Global.ConfigFileName;
|
||||||
|
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to load Portal config file: '{0}'", filePath);
|
Debug.LogMessage(LogEventLevel.Information, "Attempting to load Portal config file: '{0}'", filePath);
|
||||||
|
|
||||||
configFiles = GetConfigFiles(filePath);
|
configFiles = GetConfigFiles(filePath);
|
||||||
|
|
||||||
if (configFiles != null)
|
if (configFiles != null)
|
||||||
{
|
{
|
||||||
Debug.Console(2, "{0} config files found matching pattern", configFiles.Length);
|
Debug.LogMessage(LogEventLevel.Verbose, "{0} config files found matching pattern", configFiles.Length);
|
||||||
|
|
||||||
if (configFiles.Length > 1)
|
if (configFiles.Length > 1)
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error,
|
Debug.LogMessage(LogEventLevel.Information,
|
||||||
"****Error: Multiple Portal Configuration files present. Please ensure only a single file exists and reset program.****");
|
"****Error: Multiple Portal Configuration files present. Please ensure only a single file exists and reset program.****");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (configFiles.Length == 1)
|
else if (configFiles.Length == 1)
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Found Portal config file: '{0}'", filePath);
|
Debug.LogMessage(LogEventLevel.Information, "Found Portal config file: '{0}'", filePath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "No config file found.");
|
Debug.LogMessage(LogEventLevel.Information, "No config file found.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error,
|
Debug.LogMessage(LogEventLevel.Information,
|
||||||
"ERROR: Portal Configuration file not present. Please load file and reset program.");
|
"ERROR: Portal Configuration file not present. Please load file and reset program.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -111,13 +112,13 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
// Read the file
|
// Read the file
|
||||||
using (StreamReader fs = new StreamReader(filePath))
|
using (StreamReader fs = new StreamReader(filePath))
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading config file: '{0}'", filePath);
|
Debug.LogMessage(LogEventLevel.Information, "Loading config file: '{0}'", filePath);
|
||||||
|
|
||||||
if (localConfigFound)
|
if (localConfigFound)
|
||||||
{
|
{
|
||||||
ConfigObject = JObject.Parse(fs.ReadToEnd()).ToObject<EssentialsConfig>();
|
ConfigObject = JObject.Parse(fs.ReadToEnd()).ToObject<EssentialsConfig>();
|
||||||
|
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Successfully Loaded Local Config");
|
Debug.LogMessage(LogEventLevel.Information, "Successfully Loaded Local Config");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -139,14 +140,14 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Successfully Loaded Merged Config");
|
Debug.LogMessage(LogEventLevel.Information, "Successfully Loaded Merged Config");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "ERROR: Config load failed: \r{0}", e);
|
Debug.LogMessage(LogEventLevel.Information, "ERROR: Config load failed: \r{0}", e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -163,20 +164,20 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
|
|
||||||
if (Directory.Exists(dir))
|
if (Directory.Exists(dir))
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Searching in Directory '{0}'", dir);
|
Debug.LogMessage(LogEventLevel.Debug, "Searching in Directory '{0}'", dir);
|
||||||
// Get the directory info
|
// Get the directory info
|
||||||
var dirInfo = new DirectoryInfo(dir);
|
var dirInfo = new DirectoryInfo(dir);
|
||||||
|
|
||||||
// Get the file name
|
// Get the file name
|
||||||
var fileName = Path.GetFileName(filePath);
|
var fileName = Path.GetFileName(filePath);
|
||||||
Debug.Console(1, "For Config Files matching: '{0}'", fileName);
|
Debug.LogMessage(LogEventLevel.Debug, "For Config Files matching: '{0}'", fileName);
|
||||||
|
|
||||||
// Get the files that match from the directory
|
// Get the files that match from the directory
|
||||||
return dirInfo.GetFiles(fileName);
|
return dirInfo.GetFiles(fileName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice,
|
Debug.LogMessage(LogEventLevel.Information,
|
||||||
"Directory not found: ", dir);
|
"Directory not found: ", dir);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@@ -248,8 +249,8 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
// Line 8
|
// Line 8
|
||||||
.Append(new string('*', debugStringWidth));
|
.Append(new string('*', debugStringWidth));
|
||||||
|
|
||||||
Debug.Console(2, Debug.ErrorLogLevel.Notice, "Found Local config file: '{0}'", filePath);
|
Debug.LogMessage(LogEventLevel.Verbose, "Found Local config file: '{0}'", filePath);
|
||||||
Debug.Console(0, newDebugString.ToString());
|
Debug.LogMessage(LogEventLevel.Information, newDebugString.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ using Crestron.SimplSharp.Net.Http;
|
|||||||
using Crestron.SimplSharpPro.Diagnostics;
|
using Crestron.SimplSharpPro.Diagnostics;
|
||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Config
|
namespace PepperDash.Essentials.Core.Config
|
||||||
{
|
{
|
||||||
@@ -21,7 +22,7 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
|
|
||||||
public static void GetConfigFromServer(string url)
|
public static void GetConfigFromServer(string url)
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to get new config from '{0}'", url);
|
Debug.LogMessage(LogEventLevel.Information, "Attempting to get new config from '{0}'", url);
|
||||||
|
|
||||||
// HTTP GET
|
// HTTP GET
|
||||||
var req = new HttpClientRequest();
|
var req = new HttpClientRequest();
|
||||||
@@ -51,17 +52,17 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "Config Update Process Stopped. Failed to get config file from server: {0}", r.Code);
|
Debug.LogMessage(LogEventLevel.Information, "Config Update Process Stopped. Failed to get config file from server: {0}", r.Code);
|
||||||
OnStatusUpdate(eUpdateStatus.UpdateFailed);
|
OnStatusUpdate(eUpdateStatus.UpdateFailed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "Request for config from Server Failed: {0}", e);
|
Debug.LogMessage(LogEventLevel.Information, "Request for config from Server Failed: {0}", e);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Error Getting Config from Server: {0}", e);
|
Debug.LogMessage(LogEventLevel.Debug, "Error Getting Config from Server: {0}", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -90,7 +91,7 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Error parsing new config: {0}", e);
|
Debug.LogMessage(LogEventLevel.Debug, "Error parsing new config: {0}", e);
|
||||||
|
|
||||||
OnStatusUpdate(eUpdateStatus.UpdateFailed);
|
OnStatusUpdate(eUpdateStatus.UpdateFailed);
|
||||||
}
|
}
|
||||||
@@ -107,7 +108,7 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
|
|
||||||
if (configFiles != null)
|
if (configFiles != null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Existing config files found. Moving to Archive folder.");
|
Debug.LogMessage(LogEventLevel.Information, "Existing config files found. Moving to Archive folder.");
|
||||||
|
|
||||||
OnStatusUpdate(eUpdateStatus.ArchivingConfigs);
|
OnStatusUpdate(eUpdateStatus.ArchivingConfigs);
|
||||||
|
|
||||||
@@ -115,7 +116,7 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "No Existing config files found in '{0}'. Nothing to archive", filePath);
|
Debug.LogMessage(LogEventLevel.Information, "No Existing config files found in '{0}'. Nothing to archive", filePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,12 +141,12 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
|
|
||||||
if(archivedConfigFiles != null || archivedConfigFiles.Length > 0)
|
if(archivedConfigFiles != null || archivedConfigFiles.Length > 0)
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "{0} Existing files found in archive folder. Deleting.", archivedConfigFiles.Length);
|
Debug.LogMessage(LogEventLevel.Information, "{0} Existing files found in archive folder. Deleting.", archivedConfigFiles.Length);
|
||||||
|
|
||||||
for (int i = 0; i < archivedConfigFiles.Length; i++ )
|
for (int i = 0; i < archivedConfigFiles.Length; i++ )
|
||||||
{
|
{
|
||||||
var file = archivedConfigFiles[i];
|
var file = archivedConfigFiles[i];
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Deleting archived file: '{0}'", file.FullName);
|
Debug.LogMessage(LogEventLevel.Information, "Deleting archived file: '{0}'", file.FullName);
|
||||||
file.Delete();
|
file.Delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -155,7 +156,7 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
// Move any files from the program folder to the archive folder
|
// Move any files from the program folder to the archive folder
|
||||||
foreach (var file in files)
|
foreach (var file in files)
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Moving config file '{0}' to archive folder", file.FullName);
|
Debug.LogMessage(LogEventLevel.Information, "Moving config file '{0}' to archive folder", file.FullName);
|
||||||
|
|
||||||
// Moves the file and appends the .bak extension
|
// Moves the file and appends the .bak extension
|
||||||
var fileDest = archiveDirectoryPath + "/" + file.Name + ".bak";
|
var fileDest = archiveDirectoryPath + "/" + file.Name + ".bak";
|
||||||
@@ -164,7 +165,7 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
file.MoveTo(fileDest);
|
file.MoveTo(fileDest);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Warning, "Cannot move file to archive folder. Existing file already exists with same name: '{0}'", fileDest);
|
Debug.LogMessage(LogEventLevel.Information, "Cannot move file to archive folder. Existing file already exists with same name: '{0}'", fileDest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +180,7 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
{
|
{
|
||||||
OnStatusUpdate(eUpdateStatus.DeletingLocalConfig);
|
OnStatusUpdate(eUpdateStatus.DeletingLocalConfig);
|
||||||
Directory.Delete(folderPath);
|
Directory.Delete(folderPath);
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Local Config Found in '{0}'. Deleting.", folderPath);
|
Debug.LogMessage(LogEventLevel.Information, "Local Config Found in '{0}'. Deleting.", folderPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,7 +189,7 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
static void RestartProgram()
|
static void RestartProgram()
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to Reset Program");
|
Debug.LogMessage(LogEventLevel.Information, "Attempting to Reset Program");
|
||||||
|
|
||||||
OnStatusUpdate(eUpdateStatus.RestartingProgram);
|
OnStatusUpdate(eUpdateStatus.RestartingProgram);
|
||||||
|
|
||||||
@@ -196,7 +197,7 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
|
|
||||||
CrestronConsole.SendControlSystemCommand(string.Format("progreset -p:{0}", InitialParametersClass.ApplicationNumber), ref response);
|
CrestronConsole.SendControlSystemCommand(string.Format("progreset -p:{0}", InitialParametersClass.ApplicationNumber), ref response);
|
||||||
|
|
||||||
Debug.Console(1, "Console Response: {0}", response);
|
Debug.LogMessage(LogEventLevel.Debug, "Console Response: {0}", response);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ using Crestron.SimplSharp.CrestronIO;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Config
|
namespace PepperDash.Essentials.Core.Config
|
||||||
{
|
{
|
||||||
@@ -42,7 +43,7 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
// Replace the current properties JToken with the new one passed into this method
|
// Replace the current properties JToken with the new one passed into this method
|
||||||
deviceConfig.Properties = properties;
|
deviceConfig.Properties = properties;
|
||||||
|
|
||||||
Debug.Console(1, "Updated properties of device: '{0}'", deviceKey);
|
Debug.LogMessage(LogEventLevel.Debug, "Updated properties of device: '{0}'", deviceKey);
|
||||||
|
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
@@ -62,7 +63,7 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
{
|
{
|
||||||
ConfigReader.ConfigObject.Devices[deviceConfigIndex] = config;
|
ConfigReader.ConfigObject.Devices[deviceConfigIndex] = config;
|
||||||
|
|
||||||
Debug.Console(1, "Updated config of device: '{0}'", config.Key);
|
Debug.LogMessage(LogEventLevel.Debug, "Updated config of device: '{0}'", config.Key);
|
||||||
|
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
@@ -82,7 +83,7 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
{
|
{
|
||||||
ConfigReader.ConfigObject.Rooms[roomConfigIndex] = config;
|
ConfigReader.ConfigObject.Rooms[roomConfigIndex] = config;
|
||||||
|
|
||||||
Debug.Console(1, "Updated room of device: '{0}'", config.Key);
|
Debug.LogMessage(LogEventLevel.Debug, "Updated room of device: '{0}'", config.Key);
|
||||||
|
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
@@ -102,7 +103,7 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
|
|
||||||
WriteTimer.Reset(WriteTimeout);
|
WriteTimer.Reset(WriteTimeout);
|
||||||
|
|
||||||
Debug.Console(1, "Config File write timer has been reset.");
|
Debug.LogMessage(LogEventLevel.Debug, "Config File write timer has been reset.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -128,9 +129,9 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
if (WriteTimer != null)
|
if (WriteTimer != null)
|
||||||
WriteTimer.Stop();
|
WriteTimer.Stop();
|
||||||
|
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Writing Configuration to file");
|
Debug.LogMessage(LogEventLevel.Information, "Writing Configuration to file");
|
||||||
|
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to write config file: '{0}'", filePath);
|
Debug.LogMessage(LogEventLevel.Information, "Attempting to write config file: '{0}'", filePath);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -144,12 +145,12 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to enter FileLock");
|
Debug.LogMessage(LogEventLevel.Information, "Unable to enter FileLock");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: Config write failed: \r{0}", e);
|
Debug.LogMessage(LogEventLevel.Information, "Error: Config write failed: \r{0}", e);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,9 +31,17 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
if (string.IsNullOrEmpty(SystemUrl))
|
if (string.IsNullOrEmpty(SystemUrl))
|
||||||
return "missing url";
|
return "missing url";
|
||||||
|
|
||||||
var result = Regex.Match(SystemUrl, @"https?:\/\/.*\/systems\/(.*)\/#.*");
|
if (SystemUrl.Contains("#"))
|
||||||
string uuid = result.Groups[1].Value;
|
{
|
||||||
return uuid;
|
var result = Regex.Match(SystemUrl, @"https?:\/\/.*\/systems\/(.*)\/#.*");
|
||||||
|
string uuid = result.Groups[1].Value;
|
||||||
|
return uuid;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
var result = Regex.Match(SystemUrl, @"https?:\/\/.*\/systems\/(.*)\/.*");
|
||||||
|
string uuid = result.Groups[1].Value;
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,9 +53,17 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
if (string.IsNullOrEmpty(TemplateUrl))
|
if (string.IsNullOrEmpty(TemplateUrl))
|
||||||
return "missing template url";
|
return "missing template url";
|
||||||
|
|
||||||
var result = Regex.Match(TemplateUrl, @"https?:\/\/.*\/templates\/(.*)\/#.*");
|
if (TemplateUrl.Contains("#"))
|
||||||
string uuid = result.Groups[1].Value;
|
{
|
||||||
return uuid;
|
var result = Regex.Match(TemplateUrl, @"https?:\/\/.*\/templates\/(.*)\/#.*");
|
||||||
|
string uuid = result.Groups[1].Value;
|
||||||
|
return uuid;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
var result = Regex.Match(TemplateUrl, @"https?:\/\/.*\/system-templates\/(.*)\/system-template-versions\/(.*)\/.*");
|
||||||
|
string uuid = result.Groups[2].Value;
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,16 @@
|
|||||||
|
|
||||||
|
|
||||||
|
using Crestron.SimplSharp;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Crestron.SimplSharp.Reflection;
|
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Config
|
namespace PepperDash.Essentials.Core.Config
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the info section of a Config file
|
/// Represents the info section of a Config file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class InfoConfig
|
public class InfoConfig
|
||||||
{
|
{
|
||||||
[JsonProperty("name")]
|
[JsonProperty("name")]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using Crestron.SimplSharpPro.DeviceSupport;
|
|||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Core.JsonStandardObjects;
|
using PepperDash.Core.JsonStandardObjects;
|
||||||
using PepperDash.Essentials.Core.Bridges;
|
using PepperDash.Essentials.Core.Bridges;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
@@ -65,17 +66,17 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public override bool CustomActivate()
|
public override bool CustomActivate()
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Activating");
|
Debug.LogMessage(LogEventLevel.Information, this, "Activating");
|
||||||
if (!PreventRegistration)
|
if (!PreventRegistration)
|
||||||
{
|
{
|
||||||
//Debug.Console(1, this, " Does not require registration. Skipping");
|
//Debug.LogMessage(LogEventLevel.Debug, this, " Does not require registration. Skipping");
|
||||||
|
|
||||||
if (Hardware.Registerable && !Hardware.Registered)
|
if (Hardware.Registerable && !Hardware.Registered)
|
||||||
{
|
{
|
||||||
var response = Hardware.RegisterWithLogging(Key);
|
var response = Hardware.RegisterWithLogging(Key);
|
||||||
if (response != eDeviceRegistrationUnRegistrationResponse.Success)
|
if (response != eDeviceRegistrationUnRegistrationResponse.Success)
|
||||||
{
|
{
|
||||||
//Debug.Console(0, this, "ERROR: Cannot register Crestron device: {0}", response);
|
//Debug.LogMessage(LogEventLevel.Information, this, "ERROR: Cannot register Crestron device: {0}", response);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -141,7 +142,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
void Hardware_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args)
|
void Hardware_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "OnlineStatusChange Event. Online = {0}", args.DeviceOnLine);
|
Debug.LogMessage(LogEventLevel.Verbose, this, "OnlineStatusChange Event. Online = {0}", args.DeviceOnLine);
|
||||||
|
|
||||||
if (!Hardware.Registered)
|
if (!Hardware.Registered)
|
||||||
{
|
{
|
||||||
@@ -198,12 +199,11 @@ namespace PepperDash.Essentials.Core
|
|||||||
public static eDeviceRegistrationUnRegistrationResponse RegisterWithLogging(this GenericBase device, string key)
|
public static eDeviceRegistrationUnRegistrationResponse RegisterWithLogging(this GenericBase device, string key)
|
||||||
{
|
{
|
||||||
var result = device.Register();
|
var result = device.Register();
|
||||||
var level = result == eDeviceRegistrationUnRegistrationResponse.Success ?
|
|
||||||
Debug.ErrorLogLevel.Notice : Debug.ErrorLogLevel.Error;
|
Debug.LogMessage(LogEventLevel.Information, "Register device result: '{0}', type '{1}', result {2}", key, device, result);
|
||||||
Debug.Console(0, level, "Register device result: '{0}', type '{1}', result {2}", key, device, result);
|
|
||||||
//if (result != eDeviceRegistrationUnRegistrationResponse.Success)
|
//if (result != eDeviceRegistrationUnRegistrationResponse.Success)
|
||||||
//{
|
//{
|
||||||
// Debug.Console(0, Debug.ErrorLogLevel.Error, "Cannot register device '{0}': {1}", key, result);
|
// Debug.LogMessage(LogEventLevel.Information, "Cannot register device '{0}': {1}", key, result);
|
||||||
//}
|
//}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,16 +38,16 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public override bool CustomActivate()
|
public override bool CustomActivate()
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Activating");
|
Debug.LogMessage(LogEventLevel.Information, this, "Activating");
|
||||||
var response = Hardware.RegisterWithLogging(Key);
|
var response = Hardware.RegisterWithLogging(Key);
|
||||||
if (response != eDeviceRegistrationUnRegistrationResponse.Success)
|
if (response != eDeviceRegistrationUnRegistrationResponse.Success)
|
||||||
{
|
{
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
Debug.Console(0, this, "ERROR: Cannot register Crestron device: {0}", response);
|
Debug.LogMessage(LogEventLevel.Information, this, "ERROR: Cannot register Crestron device: {0}", response);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
=======
|
=======
|
||||||
Debug.Console(0, this, "ERROR: Cannot register Crestron device: {0}", response);
|
Debug.LogMessage(LogEventLevel.Information, this, "ERROR: Cannot register Crestron device: {0}", response);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
>>>>>>> origin/feature/ecs-342-neil
|
>>>>>>> origin/feature/ecs-342-neil
|
||||||
@@ -119,7 +119,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
var result = device.Register();
|
var result = device.Register();
|
||||||
if (result != eDeviceRegistrationUnRegistrationResponse.Success)
|
if (result != eDeviceRegistrationUnRegistrationResponse.Success)
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "Cannot register device '{0}': {1}", key, result);
|
Debug.LogMessage(LogEventLevel.Information, "Cannot register device '{0}': {1}", key, result);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ using Newtonsoft.Json;
|
|||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core.Bridges;
|
using PepperDash.Essentials.Core.Bridges;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.CrestronIO
|
namespace PepperDash.Essentials.Core.CrestronIO
|
||||||
@@ -67,7 +68,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
{
|
{
|
||||||
if (!Global.ControlSystem.SupportsDigitalInput)
|
if (!Global.ControlSystem.SupportsDigitalInput)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "GetDigitalInput: Processor does not support Digital Inputs");
|
Debug.LogMessage(LogEventLevel.Information, "GetDigitalInput: Processor does not support Digital Inputs");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ioPortDevice = Global.ControlSystem;
|
ioPortDevice = Global.ControlSystem;
|
||||||
@@ -77,20 +78,20 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
var ioPortDev = DeviceManager.GetDeviceForKey(dc.PortDeviceKey) as IDigitalInputPorts;
|
var ioPortDev = DeviceManager.GetDeviceForKey(dc.PortDeviceKey) as IDigitalInputPorts;
|
||||||
if (ioPortDev == null)
|
if (ioPortDev == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "GetDigitalInput: Device {0} is not a valid device", dc.PortDeviceKey);
|
Debug.LogMessage(LogEventLevel.Information, "GetDigitalInput: Device {0} is not a valid device", dc.PortDeviceKey);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ioPortDevice = ioPortDev;
|
ioPortDevice = ioPortDev;
|
||||||
}
|
}
|
||||||
if (ioPortDevice == null)
|
if (ioPortDevice == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "GetDigitalInput: Device '0' is not a valid IDigitalInputPorts Device", dc.PortDeviceKey);
|
Debug.LogMessage(LogEventLevel.Information, "GetDigitalInput: Device '0' is not a valid IDigitalInputPorts Device", dc.PortDeviceKey);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dc.PortNumber > ioPortDevice.NumberOfDigitalInputPorts)
|
if (dc.PortNumber > ioPortDevice.NumberOfDigitalInputPorts)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "GetDigitalInput: Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber);
|
Debug.LogMessage(LogEventLevel.Information, "GetDigitalInput: Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ioPortDevice.DigitalInputPorts[dc.PortNumber];
|
return ioPortDevice.DigitalInputPorts[dc.PortNumber];
|
||||||
@@ -117,20 +118,20 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
Debug.LogMessage(LogEventLevel.Debug, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
||||||
|
|
||||||
// Link feedback for input state
|
// Link feedback for input state
|
||||||
InputStateFeedback.LinkInputSig(trilist.BooleanInput[joinMap.InputState.JoinNumber]);
|
InputStateFeedback.LinkInputSig(trilist.BooleanInput[joinMap.InputState.JoinNumber]);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Unable to link device '{0}'. Input is null", Key);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Unable to link device '{0}'. Input is null", Key);
|
||||||
Debug.Console(1, this, "Error: {0}", e);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Error: {0}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,7 +148,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
|
|
||||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Factory Attempting to create new Generic Digital Input Device");
|
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic Digital Input Device");
|
||||||
|
|
||||||
var props = JsonConvert.DeserializeObject<IOPortConfig>(dc.Properties.ToString());
|
var props = JsonConvert.DeserializeObject<IOPortConfig>(dc.Properties.ToString());
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ using Newtonsoft.Json;
|
|||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core.Bridges;
|
using PepperDash.Essentials.Core.Bridges;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.CrestronIO
|
namespace PepperDash.Essentials.Core.CrestronIO
|
||||||
{
|
{
|
||||||
@@ -48,7 +49,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
|
|
||||||
if (RelayOutput == null)
|
if (RelayOutput == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Unable to get parent relay device for device key {0} and port {1}", config.PortDeviceKey, config.PortNumber);
|
Debug.LogMessage(LogEventLevel.Information, this, "Unable to get parent relay device for device key {0} and port {1}", config.PortDeviceKey, config.PortNumber);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +70,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
{
|
{
|
||||||
if (!Global.ControlSystem.SupportsRelay)
|
if (!Global.ControlSystem.SupportsRelay)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Processor does not support relays");
|
Debug.LogMessage(LogEventLevel.Information, "Processor does not support relays");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
relayDevice = Global.ControlSystem;
|
relayDevice = Global.ControlSystem;
|
||||||
@@ -80,7 +81,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
var essentialsDevice = DeviceManager.GetDeviceForKey(dc.PortDeviceKey);
|
var essentialsDevice = DeviceManager.GetDeviceForKey(dc.PortDeviceKey);
|
||||||
if (essentialsDevice == null)
|
if (essentialsDevice == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Device {0} was not found in Device Manager. Check configuration or for errors with device.", dc.PortDeviceKey);
|
Debug.LogMessage(LogEventLevel.Information, "Device {0} was not found in Device Manager. Check configuration or for errors with device.", dc.PortDeviceKey);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +89,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
|
|
||||||
if (relayDevice == null)
|
if (relayDevice == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Device {0} is not a valid relay parent. Please check configuration.", dc.PortDeviceKey);
|
Debug.LogMessage(LogEventLevel.Information, "Device {0} is not a valid relay parent. Please check configuration.", dc.PortDeviceKey);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +98,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
return relayDevice.RelayPorts[dc.PortNumber];
|
return relayDevice.RelayPorts[dc.PortNumber];
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(0, "Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber);
|
Debug.LogMessage(LogEventLevel.Information, "Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,16 +166,16 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RelayOutput == null)
|
if (RelayOutput == null)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Unable to link device '{0}'. Relay is null", Key);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Unable to link device '{0}'. Relay is null", Key);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
Debug.LogMessage(LogEventLevel.Debug, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
||||||
|
|
||||||
trilist.SetBoolSigAction(joinMap.Relay.JoinNumber, b =>
|
trilist.SetBoolSigAction(joinMap.Relay.JoinNumber, b =>
|
||||||
{
|
{
|
||||||
@@ -202,7 +203,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
|
|
||||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Factory Attempting to create new Generic Relay Device");
|
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic Relay Device");
|
||||||
|
|
||||||
var props = JsonConvert.DeserializeObject<IOPortConfig>(dc.Properties.ToString());
|
var props = JsonConvert.DeserializeObject<IOPortConfig>(dc.Properties.ToString());
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ using PepperDash.Essentials.Core.Bridges;
|
|||||||
|
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.CrestronIO
|
namespace PepperDash.Essentials.Core.CrestronIO
|
||||||
{
|
{
|
||||||
@@ -59,7 +60,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
|
|
||||||
InputPort.VersiportChange += InputPort_VersiportChange;
|
InputPort.VersiportChange += InputPort_VersiportChange;
|
||||||
|
|
||||||
Debug.Console(1, this, "Created GenericVersiportAnalogInputDevice on port '{0}'. DisablePullUpResistor: '{1}'", config.PortNumber, InputPort.DisablePullUpResistor);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Created GenericVersiportAnalogInputDevice on port '{0}'. DisablePullUpResistor: '{1}'", config.PortNumber, InputPort.DisablePullUpResistor);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -76,7 +77,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
|
|
||||||
void InputPort_VersiportChange(Versiport port, VersiportEventArgs args)
|
void InputPort_VersiportChange(Versiport port, VersiportEventArgs args)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Versiport change: {0}", args.Event);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Versiport change: {0}", args.Event);
|
||||||
|
|
||||||
if(args.Event == eVersiportEvent.AnalogInChange)
|
if(args.Event == eVersiportEvent.AnalogInChange)
|
||||||
InputValueFeedback.FireUpdate();
|
InputValueFeedback.FireUpdate();
|
||||||
@@ -102,12 +103,12 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
Debug.LogMessage(LogEventLevel.Debug, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
||||||
|
|
||||||
// Link feedback for input state
|
// Link feedback for input state
|
||||||
InputValueFeedback.LinkInputSig(trilist.UShortInput[joinMap.InputValue.JoinNumber]);
|
InputValueFeedback.LinkInputSig(trilist.UShortInput[joinMap.InputValue.JoinNumber]);
|
||||||
@@ -117,8 +118,8 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Unable to link device '{0}'. Input is null", Key);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Unable to link device '{0}'. Input is null", Key);
|
||||||
Debug.Console(1, this, "Error: {0}", e);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Error: {0}", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
trilist.OnlineStatusChange += (d, args) =>
|
trilist.OnlineStatusChange += (d, args) =>
|
||||||
@@ -147,7 +148,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
{
|
{
|
||||||
if (!Global.ControlSystem.SupportsVersiport)
|
if (!Global.ControlSystem.SupportsVersiport)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "GetVersiportAnalogInput: Processor does not support Versiports");
|
Debug.LogMessage(LogEventLevel.Information, "GetVersiportAnalogInput: Processor does not support Versiports");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ioPortDevice = Global.ControlSystem;
|
ioPortDevice = Global.ControlSystem;
|
||||||
@@ -157,25 +158,25 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
var ioPortDev = DeviceManager.GetDeviceForKey(dc.PortDeviceKey) as IIOPorts;
|
var ioPortDev = DeviceManager.GetDeviceForKey(dc.PortDeviceKey) as IIOPorts;
|
||||||
if (ioPortDev == null)
|
if (ioPortDev == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "GetVersiportAnalogInput: Device {0} is not a valid device", dc.PortDeviceKey);
|
Debug.LogMessage(LogEventLevel.Information, "GetVersiportAnalogInput: Device {0} is not a valid device", dc.PortDeviceKey);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ioPortDevice = ioPortDev;
|
ioPortDevice = ioPortDev;
|
||||||
}
|
}
|
||||||
if (ioPortDevice == null)
|
if (ioPortDevice == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "GetVersiportAnalogInput: Device '0' is not a valid IIOPorts Device", dc.PortDeviceKey);
|
Debug.LogMessage(LogEventLevel.Information, "GetVersiportAnalogInput: Device '0' is not a valid IIOPorts Device", dc.PortDeviceKey);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dc.PortNumber > ioPortDevice.NumberOfVersiPorts)
|
if (dc.PortNumber > ioPortDevice.NumberOfVersiPorts)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "GetVersiportAnalogInput: Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber);
|
Debug.LogMessage(LogEventLevel.Information, "GetVersiportAnalogInput: Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if(!ioPortDevice.VersiPorts[dc.PortNumber].SupportsAnalogInput)
|
if(!ioPortDevice.VersiPorts[dc.PortNumber].SupportsAnalogInput)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "GetVersiportAnalogInput: Device {0} does not support AnalogInput on port {1}", dc.PortDeviceKey, dc.PortNumber);
|
Debug.LogMessage(LogEventLevel.Information, "GetVersiportAnalogInput: Device {0} does not support AnalogInput on port {1}", dc.PortDeviceKey, dc.PortNumber);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,7 +197,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
|
|
||||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Factory Attempting to create new Generic Versiport Device");
|
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic Versiport Device");
|
||||||
|
|
||||||
var props = JsonConvert.DeserializeObject<IOPortConfig>(dc.Properties.ToString());
|
var props = JsonConvert.DeserializeObject<IOPortConfig>(dc.Properties.ToString());
|
||||||
|
|
||||||
|
|||||||
@@ -14,13 +14,14 @@ using PepperDash.Essentials.Core.Bridges;
|
|||||||
|
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.CrestronIO
|
namespace PepperDash.Essentials.Core.CrestronIO
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a generic digital input deviced tied to a versiport
|
/// Represents a generic digital input deviced tied to a versiport
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class GenericVersiportDigitalInputDevice : EssentialsBridgeableDevice, IDigitalInput
|
public class GenericVersiportDigitalInputDevice : EssentialsBridgeableDevice, IDigitalInput, IPartitionStateProvider
|
||||||
{
|
{
|
||||||
public Versiport InputPort { get; private set; }
|
public Versiport InputPort { get; private set; }
|
||||||
|
|
||||||
@@ -34,10 +35,15 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BoolFeedback PartitionPresentFeedback { get; }
|
||||||
|
|
||||||
|
public bool PartitionPresent => !InputStateFeedbackFunc();
|
||||||
|
|
||||||
public GenericVersiportDigitalInputDevice(string key, string name, Func<IOPortConfig, Versiport> postActivationFunc, IOPortConfig config) :
|
public GenericVersiportDigitalInputDevice(string key, string name, Func<IOPortConfig, Versiport> postActivationFunc, IOPortConfig config) :
|
||||||
base(key, name)
|
base(key, name)
|
||||||
{
|
{
|
||||||
InputStateFeedback = new BoolFeedback(InputStateFeedbackFunc);
|
InputStateFeedback = new BoolFeedback(InputStateFeedbackFunc);
|
||||||
|
PartitionPresentFeedback = new BoolFeedback(() => !InputStateFeedbackFunc());
|
||||||
|
|
||||||
AddPostActivationAction(() =>
|
AddPostActivationAction(() =>
|
||||||
{
|
{
|
||||||
@@ -51,9 +57,10 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
|
|
||||||
InputPort.VersiportChange += InputPort_VersiportChange;
|
InputPort.VersiportChange += InputPort_VersiportChange;
|
||||||
|
|
||||||
|
InputStateFeedback.FireUpdate();
|
||||||
|
PartitionPresentFeedback.FireUpdate();
|
||||||
|
|
||||||
|
Debug.LogMessage(LogEventLevel.Debug, this, "Created GenericVersiportDigitalInputDevice on port '{0}'. DisablePullUpResistor: '{1}'", config.PortNumber, InputPort.DisablePullUpResistor);
|
||||||
Debug.Console(1, this, "Created GenericVersiportDigitalInputDevice on port '{0}'. DisablePullUpResistor: '{1}'", config.PortNumber, InputPort.DisablePullUpResistor);
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -61,10 +68,13 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
|
|
||||||
void InputPort_VersiportChange(Versiport port, VersiportEventArgs args)
|
void InputPort_VersiportChange(Versiport port, VersiportEventArgs args)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Versiport change: {0}", args.Event);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Versiport change: {0}", args.Event);
|
||||||
|
|
||||||
if(args.Event == eVersiportEvent.DigitalInChange)
|
if(args.Event == eVersiportEvent.DigitalInChange)
|
||||||
|
{
|
||||||
InputStateFeedback.FireUpdate();
|
InputStateFeedback.FireUpdate();
|
||||||
|
PartitionPresentFeedback.FireUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -85,20 +95,20 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
Debug.LogMessage(LogEventLevel.Debug, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
||||||
|
|
||||||
// Link feedback for input state
|
// Link feedback for input state
|
||||||
InputStateFeedback.LinkInputSig(trilist.BooleanInput[joinMap.InputState.JoinNumber]);
|
InputStateFeedback.LinkInputSig(trilist.BooleanInput[joinMap.InputState.JoinNumber]);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Unable to link device '{0}'. Input is null", Key);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Unable to link device '{0}'. Input is null", Key);
|
||||||
Debug.Console(1, this, "Error: {0}", e);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Error: {0}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +124,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
{
|
{
|
||||||
if (!Global.ControlSystem.SupportsVersiport)
|
if (!Global.ControlSystem.SupportsVersiport)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "GetVersiportDigitalInput: Processor does not support Versiports");
|
Debug.LogMessage(LogEventLevel.Information, "GetVersiportDigitalInput: Processor does not support Versiports");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ioPortDevice = Global.ControlSystem;
|
ioPortDevice = Global.ControlSystem;
|
||||||
@@ -124,20 +134,20 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
var ioPortDev = DeviceManager.GetDeviceForKey(dc.PortDeviceKey) as IIOPorts;
|
var ioPortDev = DeviceManager.GetDeviceForKey(dc.PortDeviceKey) as IIOPorts;
|
||||||
if (ioPortDev == null)
|
if (ioPortDev == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "GetVersiportDigitalInput: Device {0} is not a valid device", dc.PortDeviceKey);
|
Debug.LogMessage(LogEventLevel.Information, "GetVersiportDigitalInput: Device {0} is not a valid device", dc.PortDeviceKey);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ioPortDevice = ioPortDev;
|
ioPortDevice = ioPortDev;
|
||||||
}
|
}
|
||||||
if (ioPortDevice == null)
|
if (ioPortDevice == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "GetVersiportDigitalInput: Device '0' is not a valid IIOPorts Device", dc.PortDeviceKey);
|
Debug.LogMessage(LogEventLevel.Information, "GetVersiportDigitalInput: Device '0' is not a valid IIOPorts Device", dc.PortDeviceKey);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dc.PortNumber > ioPortDevice.NumberOfVersiPorts)
|
if (dc.PortNumber > ioPortDevice.NumberOfVersiPorts)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "GetVersiportDigitalInput: Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber);
|
Debug.LogMessage(LogEventLevel.Information, "GetVersiportDigitalInput: Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ioPortDevice.VersiPorts[dc.PortNumber];
|
return ioPortDevice.VersiPorts[dc.PortNumber];
|
||||||
@@ -156,7 +166,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
|
|
||||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Factory Attempting to create new Generic Versiport Device");
|
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic Versiport Device");
|
||||||
|
|
||||||
var props = JsonConvert.DeserializeObject<IOPortConfig>(dc.Properties.ToString());
|
var props = JsonConvert.DeserializeObject<IOPortConfig>(dc.Properties.ToString());
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ using PepperDash.Essentials.Core.Bridges;
|
|||||||
|
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.CrestronIO
|
namespace PepperDash.Essentials.Core.CrestronIO
|
||||||
{
|
{
|
||||||
@@ -48,7 +49,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
|
|
||||||
if (!OutputPort.SupportsDigitalOutput)
|
if (!OutputPort.SupportsDigitalOutput)
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Device does not support configuration as a Digital Output");
|
Debug.LogMessage(LogEventLevel.Information, this, "Device does not support configuration as a Digital Output");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +64,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
|
|
||||||
void OutputPort_VersiportChange(Versiport port, VersiportEventArgs args)
|
void OutputPort_VersiportChange(Versiport port, VersiportEventArgs args)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Versiport change: {0}", args.Event);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Versiport change: {0}", args.Event);
|
||||||
|
|
||||||
if(args.Event == eVersiportEvent.DigitalOutChange)
|
if(args.Event == eVersiportEvent.DigitalOutChange)
|
||||||
OutputStateFeedback.FireUpdate();
|
OutputStateFeedback.FireUpdate();
|
||||||
@@ -77,14 +78,14 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
{
|
{
|
||||||
if (OutputPort.SupportsDigitalOutput)
|
if (OutputPort.SupportsDigitalOutput)
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Passed the Check");
|
Debug.LogMessage(LogEventLevel.Information, this, "Passed the Check");
|
||||||
|
|
||||||
OutputPort.DigitalOut = state;
|
OutputPort.DigitalOut = state;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Versiport does not support Digital Output Mode");
|
Debug.LogMessage(LogEventLevel.Information, this, "Versiport does not support Digital Output Mode");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -106,12 +107,12 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
Debug.LogMessage(LogEventLevel.Debug, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
||||||
|
|
||||||
// Link feedback for input state
|
// Link feedback for input state
|
||||||
OutputStateFeedback.LinkInputSig(trilist.BooleanInput[joinMap.OutputState.JoinNumber]);
|
OutputStateFeedback.LinkInputSig(trilist.BooleanInput[joinMap.OutputState.JoinNumber]);
|
||||||
@@ -119,8 +120,8 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Unable to link device '{0}'. Input is null", Key);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Unable to link device '{0}'. Input is null", Key);
|
||||||
Debug.Console(1, this, "Error: {0}", e);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Error: {0}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +137,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
{
|
{
|
||||||
if (!Global.ControlSystem.SupportsVersiport)
|
if (!Global.ControlSystem.SupportsVersiport)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "GetVersiportDigitalOuptut: Processor does not support Versiports");
|
Debug.LogMessage(LogEventLevel.Information, "GetVersiportDigitalOuptut: Processor does not support Versiports");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ioPortDevice = Global.ControlSystem;
|
ioPortDevice = Global.ControlSystem;
|
||||||
@@ -146,20 +147,20 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
var ioPortDev = DeviceManager.GetDeviceForKey(dc.PortDeviceKey) as IIOPorts;
|
var ioPortDev = DeviceManager.GetDeviceForKey(dc.PortDeviceKey) as IIOPorts;
|
||||||
if (ioPortDev == null)
|
if (ioPortDev == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "GetVersiportDigitalOuptut: Device {0} is not a valid device", dc.PortDeviceKey);
|
Debug.LogMessage(LogEventLevel.Information, "GetVersiportDigitalOuptut: Device {0} is not a valid device", dc.PortDeviceKey);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ioPortDevice = ioPortDev;
|
ioPortDevice = ioPortDev;
|
||||||
}
|
}
|
||||||
if (ioPortDevice == null)
|
if (ioPortDevice == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "GetVersiportDigitalOuptut: Device '0' is not a valid IOPorts Device", dc.PortDeviceKey);
|
Debug.LogMessage(LogEventLevel.Information, "GetVersiportDigitalOuptut: Device '0' is not a valid IOPorts Device", dc.PortDeviceKey);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dc.PortNumber > ioPortDevice.NumberOfVersiPorts)
|
if (dc.PortNumber > ioPortDevice.NumberOfVersiPorts)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "GetVersiportDigitalOuptut: Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber);
|
Debug.LogMessage(LogEventLevel.Information, "GetVersiportDigitalOuptut: Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber);
|
||||||
}
|
}
|
||||||
var port = ioPortDevice.VersiPorts[dc.PortNumber];
|
var port = ioPortDevice.VersiPorts[dc.PortNumber];
|
||||||
return port;
|
return port;
|
||||||
@@ -177,7 +178,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
|
|
||||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Factory Attempting to create new Generic Versiport Device");
|
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic Versiport Device");
|
||||||
|
|
||||||
var props = JsonConvert.DeserializeObject<IOPortConfig>(dc.Properties.ToString());
|
var props = JsonConvert.DeserializeObject<IOPortConfig>(dc.Properties.ToString());
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.Linq;
|
|||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.DeviceInfo
|
namespace PepperDash.Essentials.Core.DeviceInfo
|
||||||
{
|
{
|
||||||
@@ -48,7 +49,7 @@ namespace PepperDash.Essentials.Core.DeviceInfo
|
|||||||
}
|
}
|
||||||
ArpTable.Clear();
|
ArpTable.Clear();
|
||||||
|
|
||||||
Debug.Console(2, "ConsoleResponse of 'showarptable' : {0}{1}", NewLine, consoleResponse);
|
Debug.LogMessage(LogEventLevel.Verbose, "ConsoleResponse of 'showarptable' : {0}{1}", NewLine, consoleResponse);
|
||||||
|
|
||||||
var myLines =
|
var myLines =
|
||||||
consoleResponse.Split(NewLineSplitter)
|
consoleResponse.Split(NewLineSplitter)
|
||||||
@@ -68,7 +69,7 @@ namespace PepperDash.Essentials.Core.DeviceInfo
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Exception in \"RefreshArp\" : {0}", ex.Message);
|
Debug.LogMessage(LogEventLevel.Information, "Exception in \"RefreshArp\" : {0}", ex.Message);
|
||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
@@ -106,7 +107,7 @@ namespace PepperDash.Essentials.Core.DeviceInfo
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Unable to Santize Ip : {0}", ex.Message);
|
Debug.LogMessage(LogEventLevel.Information, "Unable to Santize Ip : {0}", ex.Message);
|
||||||
return ipAddressIn;
|
return ipAddressIn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,7 +127,7 @@ namespace PepperDash.Essentials.Core.DeviceInfo
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Exception Resolving Hostname from IP Address : {0}", ex.Message);
|
Debug.LogMessage(LogEventLevel.Information, "Exception Resolving Hostname from IP Address : {0}", ex.Message);
|
||||||
return ipAddress;
|
return ipAddress;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,7 +146,7 @@ namespace PepperDash.Essentials.Core.DeviceInfo
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Exception Resolving IP Address from Hostname : {0}", ex.Message);
|
Debug.LogMessage(LogEventLevel.Information, "Exception Resolving IP Address from Hostname : {0}", ex.Message);
|
||||||
return hostName;
|
return hostName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
|
||||||
|
{
|
||||||
|
public interface IEmergencyOSD
|
||||||
|
{
|
||||||
|
void ShowEmergencyMessage(string url);
|
||||||
|
void HideEmergencyMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,10 +15,22 @@ namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
|
|||||||
/// <example>
|
/// <example>
|
||||||
/// See MockDisplay for example implemntation
|
/// See MockDisplay for example implemntation
|
||||||
/// </example>
|
/// </example>
|
||||||
public interface IHasInputs<TKey, TSelector>: IKeyName
|
[Obsolete("Use IHasInputs<T> instead. Will be removed for 2.0 release")]
|
||||||
|
public interface IHasInputs<T, TSelector>: IKeyName
|
||||||
{
|
{
|
||||||
ISelectableItems<TKey> Inputs { get; }
|
ISelectableItems<T> Inputs { get; }
|
||||||
|
}
|
||||||
|
|
||||||
void SetInput(TSelector selector);
|
|
||||||
|
/// <summary>
|
||||||
|
/// Describes a device that has selectable inputs
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">the type to use as the key for each input item. Most likely an enum or string</typeparam>\
|
||||||
|
/// <example>
|
||||||
|
/// See MockDisplay for example implemntation
|
||||||
|
/// </example>
|
||||||
|
public interface IHasInputs<T> : IKeyName
|
||||||
|
{
|
||||||
|
ISelectableItems<T> Inputs { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
|
||||||
|
{
|
||||||
|
public interface IHumiditySensor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Reports the relative humidity level. Level ranging from 0 to 100 (for 0% to 100%
|
||||||
|
/// RH). EventIds: HumidityFeedbackFeedbackEventId will trigger to indicate change.
|
||||||
|
/// </summary>
|
||||||
|
IntFeedback HumidityFeedback { get; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -44,7 +44,10 @@ namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
|
|||||||
void AddDeviceMessenger(IMobileControlMessenger messenger);
|
void AddDeviceMessenger(IMobileControlMessenger messenger);
|
||||||
|
|
||||||
bool CheckForDeviceMessenger(string key);
|
bool CheckForDeviceMessenger(string key);
|
||||||
}
|
|
||||||
|
IMobileControlRoomMessenger GetRoomMessenger(string key);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Describes a mobile control messenger
|
/// Describes a mobile control messenger
|
||||||
@@ -106,4 +109,11 @@ namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
|
|||||||
Action<string,string, JToken> Action { get; }
|
Action<string,string, JToken> Action { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface IMobileControlTouchpanelController : IKeyed
|
||||||
|
{
|
||||||
|
string DefaultRoomKey { get; }
|
||||||
|
void SetAppUrl(string url);
|
||||||
|
bool UseDirectServer { get; }
|
||||||
|
bool ZoomRoomController { get; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
|
using System;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Converters;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Defines a class that has warm up and cool down
|
||||||
|
/// </summary>
|
||||||
|
public interface IProjectorScreenLiftControl
|
||||||
|
{
|
||||||
|
void Raise();
|
||||||
|
void Lower();
|
||||||
|
BoolFeedback IsInUpPosition { get; }
|
||||||
|
bool InUpPosition { get; }
|
||||||
|
event EventHandler<EventArgs> PositionChanged;
|
||||||
|
string DisplayDeviceKey { get; }
|
||||||
|
eScreenLiftControlType Type { get; } // screen/lift
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum eScreenLiftControlType
|
||||||
|
{
|
||||||
|
lift,
|
||||||
|
screen
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,6 +17,6 @@ namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
|
|||||||
Dictionary<TKey, ISelectableItem> Items { get; set; }
|
Dictionary<TKey, ISelectableItem> Items { get; set; }
|
||||||
|
|
||||||
[JsonProperty("currentItem")]
|
[JsonProperty("currentItem")]
|
||||||
string CurrentItem { get; set; }
|
TKey CurrentItem { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
|
||||||
|
{
|
||||||
|
public interface ITemperatureSensor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The values will range from -400 to +1760 (for -40° to +176° F) or -400 to +800
|
||||||
|
/// (for -40° to +80° C)in tenths of a degree.
|
||||||
|
/// </summary>
|
||||||
|
IntFeedback TemperatureFeedback { get; }
|
||||||
|
|
||||||
|
|
||||||
|
BoolFeedback TemperatureInCFeedback { get; }
|
||||||
|
|
||||||
|
void SetTemperatureFormat(bool setToC);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core
|
||||||
|
{
|
||||||
|
public abstract class AudioControlListItemBase
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Key of the parent device in the DeviceManager
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("parentDeviceKey")]
|
||||||
|
public string ParentDeviceKey { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Optional key of the item in the parent device
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("itemKey")]
|
||||||
|
public string ItemKey { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A name that will override the items's name on the UI
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("name")]
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates if the item should be included in the user accessible list
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("includeInUserList")]
|
||||||
|
public bool IncludeInUserList { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Used to specify the order of the items in the source list when displayed
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("order")]
|
||||||
|
public int Order { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
76
src/PepperDash.Essentials.Core/Devices/CameraListItem.cs
Normal file
76
src/PepperDash.Essentials.Core/Devices/CameraListItem.cs
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using PepperDash.Core;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core
|
||||||
|
{
|
||||||
|
public class CameraListItem
|
||||||
|
{
|
||||||
|
[JsonProperty("deviceKey")]
|
||||||
|
public string DeviceKey { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the source Device for this, if it exists in DeviceManager
|
||||||
|
/// </summary>
|
||||||
|
[JsonIgnore]
|
||||||
|
public Device CameraDevice
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_cameraDevice == null)
|
||||||
|
_cameraDevice = DeviceManager.GetDeviceForKey(DeviceKey) as Device;
|
||||||
|
return _cameraDevice;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Device _cameraDevice;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets either the source's Name or this AlternateName property, if
|
||||||
|
/// defined. If source doesn't exist, returns "Missing source"
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("preferredName")]
|
||||||
|
public string PreferredName
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(Name))
|
||||||
|
{
|
||||||
|
if (CameraDevice == null)
|
||||||
|
return "---";
|
||||||
|
return CameraDevice.Name;
|
||||||
|
}
|
||||||
|
return Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A name that will override the source's name on the UI
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("name")]
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Specifies and icon for the source list item
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("icon")]
|
||||||
|
public string Icon { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Alternate icon
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("altIcon", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
|
public string AltIcon { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates if the item should be included in the user facing list
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("includeInUserList")]
|
||||||
|
public bool IncludeInUserList { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Used to specify the order of the items in the source list when displayed
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("order")]
|
||||||
|
public int Order { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ using Crestron.SimplSharp;
|
|||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core.CrestronIO;
|
using PepperDash.Essentials.Core.CrestronIO;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Devices
|
namespace PepperDash.Essentials.Core.Devices
|
||||||
{
|
{
|
||||||
@@ -45,7 +46,7 @@ namespace PepperDash.Essentials.Core.Devices
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Error Getting Relays from processor:\n '{0}'", e);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Error Getting Relays from processor:\n '{0}'", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,5 +52,11 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
[JsonProperty("sinkType")]
|
[JsonProperty("sinkType")]
|
||||||
public eRoutingSignalType SinkType { get; set; }
|
public eRoutingSignalType SinkType { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("isCodecContentDestination")]
|
||||||
|
public bool isCodecContentDestination { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("isProgramAudioDestination")]
|
||||||
|
public bool isProgramAudioDestination { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,130 +1,203 @@
|
|||||||
|
using Crestron.SimplSharp;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using PepperDash.Core;
|
||||||
|
using Serilog.Events;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Reflection;
|
||||||
using Crestron.SimplSharp;
|
using System.Threading.Tasks;
|
||||||
using Crestron.SimplSharp.Reflection;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
using PepperDash.Core;
|
|
||||||
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
public class DeviceJsonApi
|
public class DeviceJsonApi
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="json"></param>
|
/// <param name="json"></param>
|
||||||
public static void DoDeviceActionWithJson(string json)
|
public static void DoDeviceActionWithJson(string json)
|
||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty(json))
|
if (String.IsNullOrEmpty(json))
|
||||||
{
|
{
|
||||||
CrestronConsole.ConsoleCommandResponse(
|
CrestronConsole.ConsoleCommandResponse(
|
||||||
"Please provide a JSON object matching the format {\"deviceKey\":\"myDevice\", \"methodName\":\"someMethod\", \"params\": [\"param1\", true]}.\r\nIf the method has no parameters, the \"params\" object may be omitted.");
|
"Please provide a JSON object matching the format {\"deviceKey\":\"myDevice\", \"methodName\":\"someMethod\", \"params\": [\"param1\", true]}.\r\nIf the method has no parameters, the \"params\" object may be omitted.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var action = JsonConvert.DeserializeObject<DeviceActionWrapper>(json);
|
var action = JsonConvert.DeserializeObject<DeviceActionWrapper>(json);
|
||||||
|
|
||||||
DoDeviceAction(action);
|
DoDeviceAction(action);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
CrestronConsole.ConsoleCommandResponse("Incorrect format for JSON. Please check that the format matches {\"deviceKey\":\"myDevice\", \"methodName\":\"someMethod\", \"params\": [\"param1\", true]}");
|
CrestronConsole.ConsoleCommandResponse("Incorrect format for JSON. Please check that the format matches {\"deviceKey\":\"myDevice\", \"methodName\":\"someMethod\", \"params\": [\"param1\", true]}");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="action"></param>
|
/// <param name="action"></param>
|
||||||
public static void DoDeviceAction(DeviceActionWrapper action)
|
public static void DoDeviceAction(DeviceActionWrapper action)
|
||||||
{
|
{
|
||||||
var key = action.DeviceKey;
|
var key = action.DeviceKey;
|
||||||
var obj = FindObjectOnPath(key);
|
var obj = FindObjectOnPath(key);
|
||||||
if (obj == null)
|
if (obj == null)
|
||||||
{
|
{
|
||||||
CrestronConsole.ConsoleCommandResponse("Unable to find object at path {0}", key);
|
CrestronConsole.ConsoleCommandResponse("Unable to find object at path {0}", key);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action.Params == null)
|
if (action.Params == null)
|
||||||
{
|
{
|
||||||
//no params, so setting action.Params to empty array
|
//no params, so setting action.Params to empty array
|
||||||
action.Params = new object[0];
|
action.Params = new object[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
CType t = obj.GetType();
|
Type t = obj.GetType();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var methods = t.GetMethods().Where(m => m.Name == action.MethodName).ToList();
|
var methods = t.GetMethods().Where(m => m.Name == action.MethodName).ToList();
|
||||||
|
|
||||||
var method = methods.Count == 1 ? methods[0] : methods.FirstOrDefault(m => m.GetParameters().Length == action.Params.Length);
|
var method = methods.Count == 1 ? methods[0] : methods.FirstOrDefault(m => m.GetParameters().Length == action.Params.Length);
|
||||||
|
|
||||||
if (method == null)
|
if (method == null)
|
||||||
{
|
{
|
||||||
CrestronConsole.ConsoleCommandResponse(
|
CrestronConsole.ConsoleCommandResponse(
|
||||||
"Unable to find method with name {0} and that matches parameters {1}", action.MethodName,
|
"Unable to find method with name {0} and that matches parameters {1}", action.MethodName,
|
||||||
action.Params);
|
action.Params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var mParams = method.GetParameters();
|
var mParams = method.GetParameters();
|
||||||
|
|
||||||
var convertedParams = mParams
|
var convertedParams = mParams
|
||||||
.Select((p, i) => ConvertType(action.Params[i], p.ParameterType))
|
.Select((p, i) => ConvertType(action.Params[i], p.ParameterType))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
method.Invoke(obj, convertedParams);
|
|
||||||
|
|
||||||
CrestronConsole.ConsoleCommandResponse("Method {0} successfully called on device {1}", method.Name,
|
Task.Run(() =>
|
||||||
action.DeviceKey);
|
{
|
||||||
}
|
try
|
||||||
catch (Exception ex)
|
{
|
||||||
{
|
Debug.LogMessage(LogEventLevel.Verbose, "Calling method {methodName} on device {deviceKey}", null, method.Name, action.DeviceKey);
|
||||||
CrestronConsole.ConsoleCommandResponse("Unable to call method with name {0}. {1}", action.MethodName,
|
method.Invoke(obj, convertedParams);
|
||||||
ex.Message);}
|
}
|
||||||
}
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogMessage(e, "Error invoking method {methodName} on device {deviceKey}", null, method.Name, action.DeviceKey);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
private static object ConvertType(object value, Type conversionType)
|
CrestronConsole.ConsoleCommandResponse("Method {0} successfully called on device {1}", method.Name,
|
||||||
{
|
action.DeviceKey);
|
||||||
if (!conversionType.IsEnum)
|
}
|
||||||
{
|
catch (Exception ex)
|
||||||
return Convert.ChangeType(value, conversionType, System.Globalization.CultureInfo.InvariantCulture);
|
{
|
||||||
}
|
CrestronConsole.ConsoleCommandResponse("Unable to call method with name {0}. {1}", action.MethodName,
|
||||||
|
ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var stringValue = Convert.ToString(value);
|
public static async Task DoDeviceActionAsync(DeviceActionWrapper action)
|
||||||
|
{
|
||||||
|
var key = action.DeviceKey;
|
||||||
|
var obj = FindObjectOnPath(key);
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
Debug.LogMessage(LogEventLevel.Warning, "Unable to find object at path {deviceKey}", null, key);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(stringValue))
|
if (action.Params == null)
|
||||||
{
|
{
|
||||||
throw new InvalidCastException(
|
//no params, so setting action.Params to empty array
|
||||||
String.Format("{0} cannot be converted to a string prior to conversion to enum"));
|
action.Params = new object[0];
|
||||||
}
|
}
|
||||||
return Enum.Parse(conversionType, stringValue, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
Type t = obj.GetType();
|
||||||
/// Gets the properties on a device
|
try
|
||||||
/// </summary>
|
{
|
||||||
/// <param name="key"></param>
|
var methods = t.GetMethods().Where(m => m.Name == action.MethodName).ToList();
|
||||||
/// <returns></returns>
|
|
||||||
public static string GetProperties(string deviceObjectPath)
|
|
||||||
{
|
|
||||||
var obj = FindObjectOnPath(deviceObjectPath);
|
|
||||||
if (obj == null)
|
|
||||||
return "{ \"error\":\"No Device\"}";
|
|
||||||
|
|
||||||
CType t = obj.GetType();
|
var method = methods.Count == 1 ? methods[0] : methods.FirstOrDefault(m => m.GetParameters().Length == action.Params.Length);
|
||||||
// get the properties and set them into a new collection of NameType wrappers
|
|
||||||
var props = t.GetProperties().Select(p => new PropertyNameType(p, obj));
|
if (method == null)
|
||||||
return JsonConvert.SerializeObject(props, Formatting.Indented);
|
{
|
||||||
}
|
Debug.LogMessage(LogEventLevel.Warning,
|
||||||
|
"Unable to find method with name {methodName} and that matches parameters {@parameters}", null, action.MethodName,
|
||||||
|
action.Params);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var mParams = method.GetParameters();
|
||||||
|
|
||||||
|
var convertedParams = mParams
|
||||||
|
.Select((p, i) => ConvertType(action.Params[i], p.ParameterType))
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Debug.LogMessage(LogEventLevel.Verbose, "Calling method {methodName} on device {deviceKey} with {@params}", null, method.Name, action.DeviceKey, action.Params);
|
||||||
|
var result = method.Invoke(obj, convertedParams);
|
||||||
|
|
||||||
|
// If the method returns a Task, await it
|
||||||
|
if (result is Task task)
|
||||||
|
{
|
||||||
|
await task;
|
||||||
|
}
|
||||||
|
// If the method returns a Task<T>, await it
|
||||||
|
else if (result != null && result.GetType().IsGenericType && result.GetType().GetGenericTypeDefinition() == typeof(Task<>))
|
||||||
|
{
|
||||||
|
await (Task)result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogMessage(e, "Error invoking method {methodName} on device {deviceKey}", null, method.Name, action.DeviceKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Debug.LogMessage(ex, "Unable to call method with name {methodName} with {@parameters}", null, action.MethodName, action.Params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static object ConvertType(object value, Type conversionType)
|
||||||
|
{
|
||||||
|
if (!conversionType.IsEnum)
|
||||||
|
{
|
||||||
|
return Convert.ChangeType(value, conversionType, System.Globalization.CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
|
|
||||||
|
var stringValue = Convert.ToString(value);
|
||||||
|
|
||||||
|
if (String.IsNullOrEmpty(stringValue))
|
||||||
|
{
|
||||||
|
throw new InvalidCastException(
|
||||||
|
String.Format("{0} cannot be converted to a string prior to conversion to enum"));
|
||||||
|
}
|
||||||
|
return Enum.Parse(conversionType, stringValue, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the properties on a device
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetProperties(string deviceObjectPath)
|
||||||
|
{
|
||||||
|
var obj = FindObjectOnPath(deviceObjectPath);
|
||||||
|
if (obj == null)
|
||||||
|
return "{ \"error\":\"No Device\"}";
|
||||||
|
|
||||||
|
Type t = obj.GetType();
|
||||||
|
// get the properties and set them into a new collection of NameType wrappers
|
||||||
|
var props = t.GetProperties().Select(p => new PropertyNameType(p, obj));
|
||||||
|
return JsonConvert.SerializeObject(props, Formatting.Indented);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a property from a device path by name
|
/// Gets a property from a device path by name
|
||||||
@@ -135,10 +208,10 @@ namespace PepperDash.Essentials.Core
|
|||||||
public static object GetPropertyByName(string deviceObjectPath, string propertyName)
|
public static object GetPropertyByName(string deviceObjectPath, string propertyName)
|
||||||
{
|
{
|
||||||
var dev = FindObjectOnPath(deviceObjectPath);
|
var dev = FindObjectOnPath(deviceObjectPath);
|
||||||
if(dev == null)
|
if (dev == null)
|
||||||
return "{ \"error\":\"No Device\"}";
|
return "{ \"error\":\"No Device\"}";
|
||||||
|
|
||||||
object prop = dev.GetType().GetCType().GetProperty(propertyName).GetValue(dev, null);
|
object prop = dev.GetType().GetProperty(propertyName).GetValue(dev, null);
|
||||||
|
|
||||||
// var prop = t.GetProperty(propertyName);
|
// var prop = t.GetProperty(propertyName);
|
||||||
if (prop != null)
|
if (prop != null)
|
||||||
@@ -147,131 +220,131 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Unable to find Property: {0} on Device with path: {1}", propertyName, deviceObjectPath);
|
Debug.LogMessage(LogEventLevel.Debug, "Unable to find Property: {0} on Device with path: {1}", propertyName, deviceObjectPath);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the methods on a device
|
/// Gets the methods on a device
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="key"></param>
|
/// <param name="key"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static string GetMethods(string deviceObjectPath)
|
public static string GetMethods(string deviceObjectPath)
|
||||||
{
|
{
|
||||||
var obj = FindObjectOnPath(deviceObjectPath);
|
var obj = FindObjectOnPath(deviceObjectPath);
|
||||||
if (obj == null)
|
if (obj == null)
|
||||||
return "{ \"error\":\"No Device\"}";
|
return "{ \"error\":\"No Device\"}";
|
||||||
|
|
||||||
// Package up method names using helper objects
|
// Package up method names using helper objects
|
||||||
CType t = obj.GetType();
|
Type t = obj.GetType();
|
||||||
var methods = t.GetMethods()
|
var methods = t.GetMethods()
|
||||||
.Where(m => !m.IsSpecialName)
|
.Where(m => !m.IsSpecialName)
|
||||||
.Select(p => new MethodNameParams(p));
|
.Select(p => new MethodNameParams(p));
|
||||||
return JsonConvert.SerializeObject(methods, Formatting.Indented);
|
return JsonConvert.SerializeObject(methods, Formatting.Indented);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetApiMethods(string deviceObjectPath)
|
public static string GetApiMethods(string deviceObjectPath)
|
||||||
{
|
{
|
||||||
var obj = FindObjectOnPath(deviceObjectPath);
|
var obj = FindObjectOnPath(deviceObjectPath);
|
||||||
if (obj == null)
|
if (obj == null)
|
||||||
return "{ \"error\":\"No Device\"}";
|
return "{ \"error\":\"No Device\"}";
|
||||||
|
|
||||||
// Package up method names using helper objects
|
// Package up method names using helper objects
|
||||||
CType t = obj.GetType();
|
Type t = obj.GetType();
|
||||||
var methods = t.GetMethods()
|
var methods = t.GetMethods()
|
||||||
.Where(m => !m.IsSpecialName)
|
.Where(m => !m.IsSpecialName)
|
||||||
.Where(m => m.GetCustomAttributes(typeof(ApiAttribute), true).Any())
|
.Where(m => m.GetCustomAttributes(typeof(ApiAttribute), true).Any())
|
||||||
.Select(p => new MethodNameParams(p));
|
.Select(p => new MethodNameParams(p));
|
||||||
return JsonConvert.SerializeObject(methods, Formatting.Indented);
|
return JsonConvert.SerializeObject(methods, Formatting.Indented);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Walks down a dotted object path, starting with a Device, and returns the object
|
/// Walks down a dotted object path, starting with a Device, and returns the object
|
||||||
/// at the end of the path
|
/// at the end of the path
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static object FindObjectOnPath(string deviceObjectPath)
|
public static object FindObjectOnPath(string deviceObjectPath)
|
||||||
{
|
{
|
||||||
var path = deviceObjectPath.Split('.');
|
var path = deviceObjectPath.Split('.');
|
||||||
|
|
||||||
var dev = DeviceManager.GetDeviceForKey(path[0]);
|
var dev = DeviceManager.GetDeviceForKey(path[0]);
|
||||||
if (dev == null)
|
if (dev == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Device {0} not found", path[0]);
|
Debug.LogMessage(LogEventLevel.Information, "Device {0} not found", path[0]);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// loop through any dotted properties
|
// loop through any dotted properties
|
||||||
object obj = dev;
|
object obj = dev;
|
||||||
if (path.Length > 1)
|
if (path.Length > 1)
|
||||||
{
|
{
|
||||||
for (int i = 1; i < path.Length; i++)
|
for (int i = 1; i < path.Length; i++)
|
||||||
{
|
{
|
||||||
var objName = path[i];
|
var objName = path[i];
|
||||||
string indexStr = null;
|
string indexStr = null;
|
||||||
var indexOpen = objName.IndexOf('[');
|
var indexOpen = objName.IndexOf('[');
|
||||||
if (indexOpen != -1)
|
if (indexOpen != -1)
|
||||||
{
|
{
|
||||||
var indexClose = objName.IndexOf(']');
|
var indexClose = objName.IndexOf(']');
|
||||||
if (indexClose == -1)
|
if (indexClose == -1)
|
||||||
{
|
{
|
||||||
Debug.Console(0, dev, "ERROR Unmatched index brackets");
|
Debug.LogMessage(LogEventLevel.Information, dev, "ERROR Unmatched index brackets");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// Get the index and strip quotes if any
|
// Get the index and strip quotes if any
|
||||||
indexStr = objName.Substring(indexOpen + 1, indexClose - indexOpen - 1).Replace("\"", "");
|
indexStr = objName.Substring(indexOpen + 1, indexClose - indexOpen - 1).Replace("\"", "");
|
||||||
objName = objName.Substring(0, indexOpen);
|
objName = objName.Substring(0, indexOpen);
|
||||||
Debug.Console(0, dev, " Checking for collection '{0}', index '{1}'", objName, indexStr);
|
Debug.LogMessage(LogEventLevel.Information, dev, " Checking for collection '{0}', index '{1}'", objName, indexStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
CType oType = obj.GetType();
|
Type oType = obj.GetType();
|
||||||
var prop = oType.GetProperty(objName);
|
var prop = oType.GetProperty(objName);
|
||||||
if (prop == null)
|
if (prop == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, dev, "Property {0} not found on {1}", objName, path[i - 1]);
|
Debug.LogMessage(LogEventLevel.Information, dev, "Property {0} not found on {1}", objName, path[i - 1]);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// if there's an index, try to get the property
|
// if there's an index, try to get the property
|
||||||
if (indexStr != null)
|
if (indexStr != null)
|
||||||
{
|
{
|
||||||
if (!typeof(ICollection).IsAssignableFrom(prop.PropertyType))
|
if (!typeof(ICollection).IsAssignableFrom(prop.PropertyType))
|
||||||
{
|
{
|
||||||
Debug.Console(0, dev, "Property {0} is not collection", objName);
|
Debug.LogMessage(LogEventLevel.Information, dev, "Property {0} is not collection", objName);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var collection = prop.GetValue(obj, null) as ICollection;
|
var collection = prop.GetValue(obj, null) as ICollection;
|
||||||
// Get the indexed items "property"
|
// Get the indexed items "property"
|
||||||
var indexedPropInfo = prop.PropertyType.GetProperty("Item");
|
var indexedPropInfo = prop.PropertyType.GetProperty("Item");
|
||||||
// These are the parameters for the indexing. Only care about one
|
// These are the parameters for the indexing. Only care about one
|
||||||
var indexParams = indexedPropInfo.GetIndexParameters();
|
var indexParams = indexedPropInfo.GetIndexParameters();
|
||||||
if (indexParams.Length > 0)
|
if (indexParams.Length > 0)
|
||||||
{
|
{
|
||||||
Debug.Console(0, " Indexed, param type: {0}", indexParams[0].ParameterType.Name);
|
Debug.LogMessage(LogEventLevel.Information, " Indexed, param type: {0}", indexParams[0].ParameterType.Name);
|
||||||
var properParam = Convert.ChangeType(indexStr, indexParams[0].ParameterType,
|
var properParam = Convert.ChangeType(indexStr, indexParams[0].ParameterType,
|
||||||
System.Globalization.CultureInfo.InvariantCulture);
|
System.Globalization.CultureInfo.InvariantCulture);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
obj = indexedPropInfo.GetValue(collection, new object[] { properParam });
|
obj = indexedPropInfo.GetValue(collection, new object[] { properParam });
|
||||||
}
|
}
|
||||||
// if the index is bad, catch it here.
|
// if the index is bad, catch it here.
|
||||||
catch (Crestron.SimplSharp.Reflection.TargetInvocationException e)
|
catch (TargetInvocationException e)
|
||||||
{
|
{
|
||||||
if (e.InnerException is ArgumentOutOfRangeException)
|
if (e.InnerException is ArgumentOutOfRangeException)
|
||||||
Debug.Console(0, " Index Out of range");
|
Debug.LogMessage(LogEventLevel.Information, " Index Out of range");
|
||||||
else if (e.InnerException is KeyNotFoundException)
|
else if (e.InnerException is KeyNotFoundException)
|
||||||
Debug.Console(0, " Key not found");
|
Debug.LogMessage(LogEventLevel.Information, " Key not found");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
obj = prop.GetValue(obj, null);
|
obj = prop.GetValue(obj, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets a property on an object.
|
/// Sets a property on an object.
|
||||||
@@ -286,7 +359,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
//if (obj == null)
|
//if (obj == null)
|
||||||
// return "{\"error\":\"No object found\"}";
|
// return "{\"error\":\"No object found\"}";
|
||||||
|
|
||||||
//CType t = obj.GetType();
|
//Type t = obj.GetType();
|
||||||
|
|
||||||
|
|
||||||
//// get the properties and set them into a new collection of NameType wrappers
|
//// get the properties and set them into a new collection of NameType wrappers
|
||||||
@@ -295,77 +368,84 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DeviceActionWrapper
|
public class DeviceActionWrapper
|
||||||
{
|
{
|
||||||
public string DeviceKey { get; set; }
|
public string DeviceKey { get; set; }
|
||||||
public string MethodName { get; set; }
|
public string MethodName { get; set; }
|
||||||
public object[] Params { get; set; }
|
public object[] Params { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PropertyNameType
|
public class PropertyNameType
|
||||||
{
|
{
|
||||||
object Parent;
|
private object Parent;
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public PropertyInfo PropInfo { get; private set; }
|
public PropertyInfo PropInfo { get; private set; }
|
||||||
public string Name { get { return PropInfo.Name; } }
|
public string Name { get { return PropInfo.Name; } }
|
||||||
public string Type { get { return PropInfo.PropertyType.Name; } }
|
public string Type { get { return PropInfo.PropertyType.Name; } }
|
||||||
public string Value { get
|
public string Value
|
||||||
{
|
{
|
||||||
if (PropInfo.CanRead)
|
get
|
||||||
{
|
{
|
||||||
try
|
if (PropInfo.CanRead)
|
||||||
{
|
{
|
||||||
return PropInfo.GetValue(Parent, null).ToString();
|
try
|
||||||
|
{
|
||||||
|
return PropInfo.GetValue(Parent, null).ToString();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception)
|
else
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
return null;
|
|
||||||
} }
|
|
||||||
|
|
||||||
public bool CanRead { get { return PropInfo.CanRead; } }
|
public bool CanRead { get { return PropInfo.CanRead; } }
|
||||||
public bool CanWrite { get { return PropInfo.CanWrite; } }
|
public bool CanWrite { get { return PropInfo.CanWrite; } }
|
||||||
|
|
||||||
|
|
||||||
public PropertyNameType(PropertyInfo info, object parent)
|
public PropertyNameType(PropertyInfo info, object parent)
|
||||||
{
|
{
|
||||||
PropInfo = info;
|
PropInfo = info;
|
||||||
Parent = parent;
|
Parent = parent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MethodNameParams
|
public class MethodNameParams
|
||||||
{
|
{
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public MethodInfo MethodInfo { get; private set; }
|
public MethodInfo MethodInfo { get; private set; }
|
||||||
|
|
||||||
public string Name { get { return MethodInfo.Name; } }
|
public string Name { get { return MethodInfo.Name; } }
|
||||||
public IEnumerable<NameType> Params { get {
|
public IEnumerable<NameType> Params
|
||||||
return MethodInfo.GetParameters().Select(p =>
|
{
|
||||||
new NameType { Name = p.Name, Type = p.ParameterType.Name });
|
get
|
||||||
} }
|
{
|
||||||
|
return MethodInfo.GetParameters().Select(p =>
|
||||||
|
new NameType { Name = p.Name, Type = p.ParameterType.Name });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public MethodNameParams(MethodInfo info)
|
public MethodNameParams(MethodInfo info)
|
||||||
{
|
{
|
||||||
MethodInfo = info;
|
MethodInfo = info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class NameType
|
public class NameType
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string Type { get; set; }
|
public string Type { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[AttributeUsage(AttributeTargets.All)]
|
[AttributeUsage(AttributeTargets.All)]
|
||||||
public class ApiAttribute : CAttribute
|
public class ApiAttribute : Attribute
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,49 +1,50 @@
|
|||||||
using System;
|
using Crestron.SimplSharp;
|
||||||
|
using Crestron.SimplSharpPro;
|
||||||
|
using PepperDash.Core;
|
||||||
|
using Serilog.Events;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Crestron.SimplSharpPro;
|
|
||||||
|
|
||||||
using PepperDash.Core;
|
|
||||||
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
public static class DeviceManager
|
public static class DeviceManager
|
||||||
{
|
{
|
||||||
public static event EventHandler<EventArgs> AllDevicesActivated;
|
public static event EventHandler<EventArgs> AllDevicesActivated;
|
||||||
public static event EventHandler<EventArgs> AllDevicesRegistered;
|
public static event EventHandler<EventArgs> AllDevicesRegistered;
|
||||||
|
public static event EventHandler<EventArgs> AllDevicesInitialized;
|
||||||
|
|
||||||
private static readonly CCriticalSection DeviceCriticalSection = new CCriticalSection();
|
private static readonly CCriticalSection DeviceCriticalSection = new CCriticalSection();
|
||||||
private static readonly CEvent AllowAddDevicesCEvent = new CEvent(false, true);
|
private static readonly CEvent AllowAddDevicesCEvent = new CEvent(false, true);
|
||||||
//public static List<Device> Devices { get { return _Devices; } }
|
|
||||||
//static List<Device> _Devices = new List<Device>();
|
|
||||||
|
|
||||||
static readonly Dictionary<string, IKeyed> Devices = new Dictionary<string, IKeyed>(StringComparer.OrdinalIgnoreCase);
|
//public static List<Device> Devices { get { return _Devices; } }
|
||||||
|
//static List<Device> _Devices = new List<Device>();
|
||||||
|
|
||||||
/// <summary>
|
private static readonly Dictionary<string, IKeyed> Devices = new Dictionary<string, IKeyed>(StringComparer.OrdinalIgnoreCase);
|
||||||
/// Returns a copy of all the devices in a list
|
|
||||||
/// </summary>
|
|
||||||
public static List<IKeyed> AllDevices { get { return new List<IKeyed>(Devices.Values); } }
|
|
||||||
|
|
||||||
public static bool AddDeviceEnabled;
|
/// <summary>
|
||||||
|
/// Returns a copy of all the devices in a list
|
||||||
|
/// </summary>
|
||||||
|
public static List<IKeyed> AllDevices { get { return new List<IKeyed>(Devices.Values); } }
|
||||||
|
|
||||||
public static void Initialize(CrestronControlSystem cs)
|
public static bool AddDeviceEnabled;
|
||||||
{
|
|
||||||
AddDeviceEnabled = true;
|
public static void Initialize(CrestronControlSystem cs)
|
||||||
CrestronConsole.AddNewConsoleCommand(ListDeviceCommStatuses, "devcommstatus", "Lists the communication status of all devices",
|
{
|
||||||
ConsoleAccessLevelEnum.AccessOperator);
|
AddDeviceEnabled = true;
|
||||||
CrestronConsole.AddNewConsoleCommand(ListDeviceFeedbacks, "devfb", "Lists current feedbacks",
|
CrestronConsole.AddNewConsoleCommand(ListDeviceCommStatuses, "devcommstatus", "Lists the communication status of all devices",
|
||||||
ConsoleAccessLevelEnum.AccessOperator);
|
ConsoleAccessLevelEnum.AccessOperator);
|
||||||
CrestronConsole.AddNewConsoleCommand(ListDevices, "devlist", "Lists current managed devices",
|
CrestronConsole.AddNewConsoleCommand(ListDeviceFeedbacks, "devfb", "Lists current feedbacks",
|
||||||
ConsoleAccessLevelEnum.AccessOperator);
|
ConsoleAccessLevelEnum.AccessOperator);
|
||||||
CrestronConsole.AddNewConsoleCommand(DeviceJsonApi.DoDeviceActionWithJson, "devjson", "",
|
CrestronConsole.AddNewConsoleCommand(ListDevices, "devlist", "Lists current managed devices",
|
||||||
ConsoleAccessLevelEnum.AccessOperator);
|
ConsoleAccessLevelEnum.AccessOperator);
|
||||||
CrestronConsole.AddNewConsoleCommand(s => CrestronConsole.ConsoleCommandResponse(DeviceJsonApi.GetProperties(s)), "devprops", "", ConsoleAccessLevelEnum.AccessOperator);
|
CrestronConsole.AddNewConsoleCommand(DeviceJsonApi.DoDeviceActionWithJson, "devjson", "",
|
||||||
CrestronConsole.AddNewConsoleCommand(s => CrestronConsole.ConsoleCommandResponse(DeviceJsonApi.GetMethods(s)), "devmethods", "", ConsoleAccessLevelEnum.AccessOperator);
|
ConsoleAccessLevelEnum.AccessOperator);
|
||||||
CrestronConsole.AddNewConsoleCommand(s => CrestronConsole.ConsoleCommandResponse(DeviceJsonApi.GetApiMethods(s)), "apimethods", "", ConsoleAccessLevelEnum.AccessOperator);
|
CrestronConsole.AddNewConsoleCommand(s => CrestronConsole.ConsoleCommandResponse(DeviceJsonApi.GetProperties(s)), "devprops", "", ConsoleAccessLevelEnum.AccessOperator);
|
||||||
|
CrestronConsole.AddNewConsoleCommand(s => CrestronConsole.ConsoleCommandResponse(DeviceJsonApi.GetMethods(s)), "devmethods", "", ConsoleAccessLevelEnum.AccessOperator);
|
||||||
|
CrestronConsole.AddNewConsoleCommand(s => CrestronConsole.ConsoleCommandResponse(DeviceJsonApi.GetApiMethods(s)), "apimethods", "", ConsoleAccessLevelEnum.AccessOperator);
|
||||||
CrestronConsole.AddNewConsoleCommand(SimulateComReceiveOnDevice, "devsimreceive",
|
CrestronConsole.AddNewConsoleCommand(SimulateComReceiveOnDevice, "devsimreceive",
|
||||||
"Simulates incoming data on a com device", ConsoleAccessLevelEnum.AccessOperator);
|
"Simulates incoming data on a com device", ConsoleAccessLevelEnum.AccessOperator);
|
||||||
|
|
||||||
@@ -51,77 +52,89 @@ namespace PepperDash.Essentials.Core
|
|||||||
CrestronConsole.AddNewConsoleCommand(s => DisableAllDeviceStreamDebugging(), "disableallstreamdebug", "disables stream debugging on all devices", ConsoleAccessLevelEnum.AccessOperator);
|
CrestronConsole.AddNewConsoleCommand(s => DisableAllDeviceStreamDebugging(), "disableallstreamdebug", "disables stream debugging on all devices", ConsoleAccessLevelEnum.AccessOperator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Calls activate steps on all Device class items
|
/// Calls activate steps on all Device class items
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void ActivateAll()
|
public static void ActivateAll()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OnAllDevicesRegistered();
|
OnAllDevicesRegistered();
|
||||||
|
|
||||||
DeviceCriticalSection.Enter();
|
DeviceCriticalSection.Enter();
|
||||||
AddDeviceEnabled = false;
|
AddDeviceEnabled = false;
|
||||||
// PreActivate all devices
|
// PreActivate all devices
|
||||||
Debug.Console(0,"****PreActivation starting...****");
|
Debug.LogMessage(LogEventLevel.Information, "****PreActivation starting...****");
|
||||||
foreach (var d in Devices.Values)
|
foreach (var d in Devices.Values)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (d is Device)
|
if (d is Device)
|
||||||
(d as Device).PreActivate();
|
(d as Device).PreActivate();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(0, d, "ERROR: Device {1} PreActivation failure: {0}", e.Message, d.Key);
|
Debug.LogMessage(LogEventLevel.Information, d, "ERROR: Device {1} PreActivation failure: {0}", e.Message, d.Key);
|
||||||
Debug.Console(1, d, "Stack Trace: {0}", e.StackTrace);
|
Debug.LogMessage(LogEventLevel.Debug, d, "Stack Trace: {0}", e.StackTrace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Debug.Console(0, "****PreActivation complete****");
|
Debug.LogMessage(LogEventLevel.Information, "****PreActivation complete****");
|
||||||
Debug.Console(0, "****Activation starting...****");
|
Debug.LogMessage(LogEventLevel.Information, "****Activation starting...****");
|
||||||
|
|
||||||
// Activate all devices
|
// Activate all devices
|
||||||
foreach (var d in Devices.Values)
|
foreach (var d in Devices.Values)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (d is Device)
|
if (d is Device)
|
||||||
(d as Device).Activate();
|
(d as Device).Activate();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(0, d, "ERROR: Device {1} Activation failure: {0}", e.Message, d.Key);
|
Debug.LogMessage(LogEventLevel.Information, d, "ERROR: Device {1} Activation failure: {0}", e.Message, d.Key);
|
||||||
Debug.Console(1, d, "Stack Trace: {0}", e.StackTrace);
|
Debug.LogMessage(LogEventLevel.Debug, d, "Stack Trace: {0}", e.StackTrace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(0, "****Activation complete****");
|
Debug.LogMessage(LogEventLevel.Information, "****Activation complete****");
|
||||||
Debug.Console(0, "****PostActivation starting...****");
|
Debug.LogMessage(LogEventLevel.Information, "****PostActivation starting...****");
|
||||||
|
|
||||||
// PostActivate all devices
|
// PostActivate all devices
|
||||||
foreach (var d in Devices.Values)
|
foreach (var d in Devices.Values)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (d is Device)
|
if (d is Device)
|
||||||
(d as Device).PostActivate();
|
(d as Device).PostActivate();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(0, d, "ERROR: Device {1} PostActivation failure: {0}", e.Message, d.Key);
|
Debug.LogMessage(LogEventLevel.Information, d, "ERROR: Device {1} PostActivation failure: {0}", e.Message, d.Key);
|
||||||
Debug.Console(1, d, "Stack Trace: {0}", e.StackTrace);
|
Debug.LogMessage(LogEventLevel.Debug, d, "Stack Trace: {0}", e.StackTrace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(0, "****PostActivation complete****");
|
Debug.LogMessage(LogEventLevel.Information, "****PostActivation complete****");
|
||||||
|
|
||||||
OnAllDevicesActivated();
|
OnAllDevicesActivated();
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
DeviceCriticalSection.Leave();
|
DeviceCriticalSection.Leave();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void DeviceManager_Initialized(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var allInitialized = Devices.Values.OfType<EssentialsDevice>().All(d => d.IsInitialized);
|
||||||
|
|
||||||
|
if (allInitialized)
|
||||||
|
{
|
||||||
|
Debug.LogMessage(LogEventLevel.Information, "****All Devices Initalized****");
|
||||||
|
|
||||||
|
OnAllDevicesInitialized();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void OnAllDevicesActivated()
|
private static void OnAllDevicesActivated()
|
||||||
{
|
{
|
||||||
@@ -141,215 +154,224 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
private static void OnAllDevicesInitialized()
|
||||||
/// Calls activate on all Device class items
|
{
|
||||||
/// </summary>
|
var handler = AllDevicesInitialized;
|
||||||
public static void DeactivateAll()
|
if (handler != null)
|
||||||
{
|
{
|
||||||
try
|
handler(null, new EventArgs());
|
||||||
{
|
}
|
||||||
DeviceCriticalSection.Enter();
|
}
|
||||||
foreach (var d in Devices.Values.OfType<Device>())
|
|
||||||
{
|
|
||||||
d.Deactivate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
DeviceCriticalSection.Leave();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//static void ListMethods(string devKey)
|
/// <summary>
|
||||||
//{
|
/// Calls activate on all Device class items
|
||||||
// var dev = GetDeviceForKey(devKey);
|
/// </summary>
|
||||||
// if(dev != null)
|
public static void DeactivateAll()
|
||||||
// {
|
{
|
||||||
// var type = dev.GetType().GetCType();
|
try
|
||||||
// var methods = type.GetMethods(BindingFlags.Public|BindingFlags.Instance);
|
{
|
||||||
// var sb = new StringBuilder();
|
DeviceCriticalSection.Enter();
|
||||||
// sb.AppendLine(string.Format("{2} methods on [{0}] ({1}):", dev.Key, type.Name, methods.Length));
|
foreach (var d in Devices.Values.OfType<Device>())
|
||||||
// foreach (var m in methods)
|
{
|
||||||
// {
|
d.Deactivate();
|
||||||
// sb.Append(string.Format("{0}(", m.Name));
|
}
|
||||||
// var pars = m.GetParameters();
|
}
|
||||||
// foreach (var p in pars)
|
finally
|
||||||
// sb.Append(string.Format("({1}){0} ", p.Name, p.ParameterType.Name));
|
{
|
||||||
// sb.AppendLine(")");
|
DeviceCriticalSection.Leave();
|
||||||
// }
|
}
|
||||||
// CrestronConsole.ConsoleCommandResponse(sb.ToString());
|
}
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
private static void ListDevices(string s)
|
//static void ListMethods(string devKey)
|
||||||
{
|
//{
|
||||||
Debug.Console(0, "{0} Devices registered with Device Manager:", Devices.Count);
|
// var dev = GetDeviceForKey(devKey);
|
||||||
var sorted = Devices.Values.ToList();
|
// if(dev != null)
|
||||||
sorted.Sort((a, b) => a.Key.CompareTo(b.Key));
|
// {
|
||||||
|
// var type = dev.GetType().GetType();
|
||||||
|
// var methods = type.GetMethods(BindingFlags.Public|BindingFlags.Instance);
|
||||||
|
// var sb = new StringBuilder();
|
||||||
|
// sb.AppendLine(string.Format("{2} methods on [{0}] ({1}):", dev.Key, type.Name, methods.Length));
|
||||||
|
// foreach (var m in methods)
|
||||||
|
// {
|
||||||
|
// sb.Append(string.Format("{0}(", m.Name));
|
||||||
|
// var pars = m.GetParameters();
|
||||||
|
// foreach (var p in pars)
|
||||||
|
// sb.Append(string.Format("({1}){0} ", p.Name, p.ParameterType.Name));
|
||||||
|
// sb.AppendLine(")");
|
||||||
|
// }
|
||||||
|
// CrestronConsole.ConsoleCommandResponse(sb.ToString());
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
foreach (var d in sorted)
|
private static void ListDevices(string s)
|
||||||
{
|
{
|
||||||
var name = d is IKeyName ? (d as IKeyName).Name : "---";
|
Debug.LogMessage(LogEventLevel.Information, "{0} Devices registered with Device Manager:", Devices.Count);
|
||||||
Debug.Console(0, " [{0}] {1}", d.Key, name);
|
var sorted = Devices.Values.ToList();
|
||||||
}
|
sorted.Sort((a, b) => a.Key.CompareTo(b.Key));
|
||||||
}
|
|
||||||
|
|
||||||
private static void ListDeviceFeedbacks(string devKey)
|
foreach (var d in sorted)
|
||||||
{
|
{
|
||||||
var dev = GetDeviceForKey(devKey);
|
var name = d is IKeyName ? (d as IKeyName).Name : "---";
|
||||||
if (dev == null)
|
Debug.LogMessage(LogEventLevel.Information, " [{0}] {1}", d.Key, name);
|
||||||
{
|
}
|
||||||
Debug.Console(0, "Device '{0}' not found", devKey);
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
var statusDev = dev as IHasFeedback;
|
|
||||||
if (statusDev == null)
|
|
||||||
{
|
|
||||||
Debug.Console(0, "Device '{0}' does not have visible feedbacks", devKey);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
statusDev.DumpFeedbacksToConsole(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
//static void ListDeviceCommands(string devKey)
|
private static void ListDeviceFeedbacks(string devKey)
|
||||||
|
{
|
||||||
|
var dev = GetDeviceForKey(devKey);
|
||||||
|
if (dev == null)
|
||||||
|
{
|
||||||
|
Debug.LogMessage(LogEventLevel.Information, "Device '{0}' not found", devKey);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!(dev is IHasFeedback statusDev))
|
||||||
|
{
|
||||||
|
Debug.LogMessage(LogEventLevel.Information, "Device '{0}' does not have visible feedbacks", devKey);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
statusDev.DumpFeedbacksToConsole(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
//static void ListDeviceCommands(string devKey)
|
||||||
//{
|
//{
|
||||||
// var dev = GetDeviceForKey(devKey);
|
// var dev = GetDeviceForKey(devKey);
|
||||||
// if (dev == null)
|
// if (dev == null)
|
||||||
// {
|
// {
|
||||||
// Debug.Console(0, "Device '{0}' not found", devKey);
|
// Debug.LogMessage(LogEventLevel.Information, "Device '{0}' not found", devKey);
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
// Debug.Console(0, "This needs to be reworked. Stay tuned.", devKey);
|
// Debug.LogMessage(LogEventLevel.Information, "This needs to be reworked. Stay tuned.", devKey);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
private static void ListDeviceCommStatuses(string input)
|
private static void ListDeviceCommStatuses(string input)
|
||||||
{
|
{
|
||||||
var sb = new StringBuilder();
|
|
||||||
foreach (var dev in Devices.Values.OfType<ICommunicationMonitor>())
|
foreach (var dev in Devices.Values.OfType<ICommunicationMonitor>())
|
||||||
{
|
{
|
||||||
sb.Append(string.Format("{0}: {1}\r", dev,
|
CrestronConsole.ConsoleCommandResponse($"{dev}: {dev.CommunicationMonitor.Status}{Environment.NewLine}");
|
||||||
dev.CommunicationMonitor.Status));
|
}
|
||||||
}
|
}
|
||||||
CrestronConsole.ConsoleCommandResponse(sb.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//static void DoDeviceCommand(string command)
|
//static void DoDeviceCommand(string command)
|
||||||
//{
|
//{
|
||||||
// Debug.Console(0, "Not yet implemented. Stay tuned");
|
// Debug.LogMessage(LogEventLevel.Information, "Not yet implemented. Stay tuned");
|
||||||
//}
|
//}
|
||||||
|
|
||||||
public static void AddDevice(IKeyed newDev)
|
public static void AddDevice(IKeyed newDev)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!DeviceCriticalSection.TryEnter())
|
if (!DeviceCriticalSection.TryEnter())
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "Currently unable to add devices to Device Manager. Please try again");
|
Debug.LogMessage(LogEventLevel.Information, "Currently unable to add devices to Device Manager. Please try again");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Check for device with same key
|
// Check for device with same key
|
||||||
//var existingDevice = _Devices.FirstOrDefault(d => d.Key.Equals(newDev.Key, StringComparison.OrdinalIgnoreCase));
|
//var existingDevice = _Devices.FirstOrDefault(d => d.Key.Equals(newDev.Key, StringComparison.OrdinalIgnoreCase));
|
||||||
////// If it exists, remove or warn??
|
////// If it exists, remove or warn??
|
||||||
//if (existingDevice != null)
|
//if (existingDevice != null)
|
||||||
|
|
||||||
if (!AddDeviceEnabled)
|
if (!AddDeviceEnabled)
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "All devices have been activated. Adding new devices is not allowed.");
|
Debug.LogMessage(LogEventLevel.Information, "All devices have been activated. Adding new devices is not allowed.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Devices.ContainsKey(newDev.Key))
|
if (Devices.ContainsKey(newDev.Key))
|
||||||
{
|
{
|
||||||
Debug.Console(0, newDev, "WARNING: A device with this key already exists. Not added to manager");
|
Debug.LogMessage(LogEventLevel.Information, newDev, "WARNING: A device with this key already exists. Not added to manager");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Devices.Add(newDev.Key, newDev);
|
Devices.Add(newDev.Key, newDev);
|
||||||
//if (!(_Devices.Contains(newDev)))
|
//if (!(_Devices.Contains(newDev)))
|
||||||
// _Devices.Add(newDev);
|
// _Devices.Add(newDev);
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
DeviceCriticalSection.Leave();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void AddDevice(IEnumerable<IKeyed> devicesToAdd)
|
if (newDev is EssentialsDevice essentialsDev)
|
||||||
{
|
essentialsDev.Initialized += DeviceManager_Initialized;
|
||||||
try
|
}
|
||||||
{
|
finally
|
||||||
if (!DeviceCriticalSection.TryEnter())
|
{
|
||||||
{
|
DeviceCriticalSection.Leave();
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error,
|
}
|
||||||
"Currently unable to add devices to Device Manager. Please try again");
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!AddDeviceEnabled)
|
|
||||||
{
|
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error,
|
|
||||||
"All devices have been activated. Adding new devices is not allowed.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var dev in devicesToAdd)
|
public static void AddDevice(IEnumerable<IKeyed> devicesToAdd)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Devices.Add(dev.Key, dev);
|
if (!DeviceCriticalSection.TryEnter())
|
||||||
}
|
{
|
||||||
catch (ArgumentException ex)
|
Debug.LogMessage(LogEventLevel.Information,
|
||||||
{
|
"Currently unable to add devices to Device Manager. Please try again");
|
||||||
Debug.Console(0, "Error adding device with key {0} to Device Manager: {1}\r\nStack Trace: {2}",
|
return;
|
||||||
dev.Key, ex.Message, ex.StackTrace);
|
}
|
||||||
}
|
if (!AddDeviceEnabled)
|
||||||
}
|
{
|
||||||
}
|
Debug.LogMessage(LogEventLevel.Information,
|
||||||
finally
|
"All devices have been activated. Adding new devices is not allowed.");
|
||||||
{
|
return;
|
||||||
DeviceCriticalSection.Leave();
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void RemoveDevice(IKeyed newDev)
|
foreach (var dev in devicesToAdd)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Devices.Add(dev.Key, dev);
|
||||||
|
}
|
||||||
|
catch (ArgumentException ex)
|
||||||
|
{
|
||||||
|
Debug.LogMessage(LogEventLevel.Information, "Error adding device with key {0} to Device Manager: {1}\r\nStack Trace: {2}",
|
||||||
|
dev.Key, ex.Message, ex.StackTrace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
DeviceCriticalSection.Leave();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void RemoveDevice(IKeyed newDev)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
DeviceCriticalSection.Enter();
|
DeviceCriticalSection.Enter();
|
||||||
if (newDev == null)
|
if (newDev == null)
|
||||||
return;
|
return;
|
||||||
if (Devices.ContainsKey(newDev.Key))
|
if (Devices.ContainsKey(newDev.Key))
|
||||||
Devices.Remove(newDev.Key);
|
Devices.Remove(newDev.Key);
|
||||||
//if (_Devices.Contains(newDev))
|
//if (_Devices.Contains(newDev))
|
||||||
// _Devices.Remove(newDev);
|
// _Devices.Remove(newDev);
|
||||||
else
|
else
|
||||||
Debug.Console(0, "Device manager: Device '{0}' does not exist in manager. Cannot remove", newDev.Key);
|
Debug.LogMessage(LogEventLevel.Information, "Device manager: Device '{0}' does not exist in manager. Cannot remove", newDev.Key);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
DeviceCriticalSection.Leave();
|
DeviceCriticalSection.Leave();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<string> GetDeviceKeys()
|
public static IEnumerable<string> GetDeviceKeys()
|
||||||
{
|
{
|
||||||
//return _Devices.Select(d => d.Key).ToList();
|
//return _Devices.Select(d => d.Key).ToList();
|
||||||
return Devices.Keys;
|
return Devices.Keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<IKeyed> GetDevices()
|
public static IEnumerable<IKeyed> GetDevices()
|
||||||
{
|
{
|
||||||
//return _Devices.Select(d => d.Key).ToList();
|
//return _Devices.Select(d => d.Key).ToList();
|
||||||
return Devices.Values;
|
return Devices.Values;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IKeyed GetDeviceForKey(string key)
|
public static IKeyed GetDeviceForKey(string key)
|
||||||
{
|
{
|
||||||
//return _Devices.FirstOrDefault(d => d.Key.Equals(key, StringComparison.OrdinalIgnoreCase));
|
//return _Devices.FirstOrDefault(d => d.Key.Equals(key, StringComparison.OrdinalIgnoreCase));
|
||||||
if (key != null && Devices.ContainsKey(key))
|
if (key != null && Devices.ContainsKey(key))
|
||||||
return Devices[key];
|
return Devices[key];
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Console handler that simulates com port data receive
|
/// Console handler that simulates com port data receive
|
||||||
@@ -364,10 +386,9 @@ namespace PepperDash.Essentials.Core
|
|||||||
CrestronConsole.ConsoleCommandResponse(" Format: devsimreceive:P <device key> <string to send>");
|
CrestronConsole.ConsoleCommandResponse(" Format: devsimreceive:P <device key> <string to send>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Debug.Console(2, "**** {0} - {1} ****", match.Groups[1].Value, match.Groups[2].Value);
|
//Debug.LogMessage(LogEventLevel.Verbose, "**** {0} - {1} ****", match.Groups[1].Value, match.Groups[2].Value);
|
||||||
|
|
||||||
var com = GetDeviceForKey(match.Groups[1].Value) as ComPortController;
|
if (!(GetDeviceForKey(match.Groups[1].Value) is ComPortController com))
|
||||||
if (com == null)
|
|
||||||
{
|
{
|
||||||
CrestronConsole.ConsoleCommandResponse("'{0}' is not a comm port device", match.Groups[1].Value);
|
CrestronConsole.ConsoleCommandResponse("'{0}' is not a comm port device", match.Groups[1].Value);
|
||||||
return;
|
return;
|
||||||
@@ -422,16 +443,15 @@ namespace PepperDash.Essentials.Core
|
|||||||
var deviceKey = args[0];
|
var deviceKey = args[0];
|
||||||
var setting = args[1];
|
var setting = args[1];
|
||||||
|
|
||||||
var timeout= String.Empty;
|
var timeout = String.Empty;
|
||||||
|
|
||||||
if (args.Length >= 3)
|
if (args.Length >= 3)
|
||||||
{
|
{
|
||||||
timeout = args[2];
|
timeout = args[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
var device = GetDeviceForKey(deviceKey) as IStreamDebugging;
|
|
||||||
|
|
||||||
if (device == null)
|
if (!(GetDeviceForKey(deviceKey) is IStreamDebugging device))
|
||||||
{
|
{
|
||||||
CrestronConsole.ConsoleCommandResponse("Unable to get device with key: {0}", deviceKey);
|
CrestronConsole.ConsoleCommandResponse("Unable to get device with key: {0}", deviceKey);
|
||||||
return;
|
return;
|
||||||
@@ -478,13 +498,11 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
foreach (var device in AllDevices)
|
foreach (var device in AllDevices)
|
||||||
{
|
{
|
||||||
var streamDevice = device as IStreamDebugging;
|
if (device is IStreamDebugging streamDevice)
|
||||||
|
|
||||||
if (streamDevice != null)
|
|
||||||
{
|
{
|
||||||
streamDevice.StreamDebugging.SetDebuggingWithDefaultTimeout(eStreamDebuggingSetting.Off);
|
streamDevice.StreamDebugging.SetDebuggingWithDefaultTimeout(eStreamDebuggingSetting.Off);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,10 +3,11 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using Crestron.SimplSharp.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
@@ -16,6 +17,24 @@ namespace PepperDash.Essentials.Core
|
|||||||
[Description("The base Essentials Device Class")]
|
[Description("The base Essentials Device Class")]
|
||||||
public abstract class EssentialsDevice : Device
|
public abstract class EssentialsDevice : Device
|
||||||
{
|
{
|
||||||
|
public event EventHandler Initialized;
|
||||||
|
|
||||||
|
private bool _isInitialized;
|
||||||
|
public bool IsInitialized {
|
||||||
|
get { return _isInitialized; }
|
||||||
|
private set
|
||||||
|
{
|
||||||
|
if (_isInitialized == value) return;
|
||||||
|
|
||||||
|
_isInitialized = value;
|
||||||
|
|
||||||
|
if (_isInitialized)
|
||||||
|
{
|
||||||
|
Initialized?.Invoke(this, new EventArgs());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected EssentialsDevice(string key)
|
protected EssentialsDevice(string key)
|
||||||
: base(key)
|
: base(key)
|
||||||
{
|
{
|
||||||
@@ -40,11 +59,13 @@ namespace PepperDash.Essentials.Core
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Initialize();
|
Initialize();
|
||||||
|
|
||||||
|
IsInitialized = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Exception initializing device: {0}", ex.Message);
|
Debug.LogMessage(LogEventLevel.Error, this, "Exception initializing device: {0}", ex.Message);
|
||||||
Debug.Console(1, this, Debug.ErrorLogLevel.Error, "Stack Trace: {0}", ex.StackTrace);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Stack Trace: {0}", ex.StackTrace);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -71,7 +92,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
public DescriptionAttribute(string description)
|
public DescriptionAttribute(string description)
|
||||||
{
|
{
|
||||||
//Debug.Console(2, "Setting Description: {0}", description);
|
//Debug.LogMessage(LogEventLevel.Verbose, "Setting Description: {0}", description);
|
||||||
_Description = description;
|
_Description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +109,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
public ConfigSnippetAttribute(string configSnippet)
|
public ConfigSnippetAttribute(string configSnippet)
|
||||||
{
|
{
|
||||||
//Debug.Console(2, "Setting Config Snippet {0}", configSnippet);
|
//Debug.LogMessage(LogEventLevel.Verbose, "Setting Config Snippet {0}", configSnippet);
|
||||||
_ConfigSnippet = configSnippet;
|
_ConfigSnippet = configSnippet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,7 +138,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
foreach (var typeName in TypeNames)
|
foreach (var typeName in TypeNames)
|
||||||
{
|
{
|
||||||
//Debug.Console(2, "Getting Description Attribute from class: '{0}'", typeof(T).FullName);
|
//Debug.LogMessage(LogEventLevel.Verbose, "Getting Description Attribute from class: '{0}'", typeof(T).FullName);
|
||||||
var descriptionAttribute = typeof(T).GetCustomAttributes(typeof(DescriptionAttribute), true) as DescriptionAttribute[];
|
var descriptionAttribute = typeof(T).GetCustomAttributes(typeof(DescriptionAttribute), true) as DescriptionAttribute[];
|
||||||
string description = descriptionAttribute[0].Description;
|
string description = descriptionAttribute[0].Description;
|
||||||
var snippetAttribute = typeof(T).GetCustomAttributes(typeof(ConfigSnippetAttribute), true) as ConfigSnippetAttribute[];
|
var snippetAttribute = typeof(T).GetCustomAttributes(typeof(ConfigSnippetAttribute), true) as ConfigSnippetAttribute[];
|
||||||
@@ -151,7 +172,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
foreach (var typeName in TypeNames)
|
foreach (var typeName in TypeNames)
|
||||||
{
|
{
|
||||||
//Debug.Console(2, "Getting Description Attribute from class: '{0}'", typeof(T).FullName);
|
//Debug.LogMessage(LogEventLevel.Verbose, "Getting Description Attribute from class: '{0}'", typeof(T).FullName);
|
||||||
var descriptionAttribute = typeof(T).GetCustomAttributes(typeof(DescriptionAttribute), true) as DescriptionAttribute[];
|
var descriptionAttribute = typeof(T).GetCustomAttributes(typeof(DescriptionAttribute), true) as DescriptionAttribute[];
|
||||||
string description = descriptionAttribute[0].Description;
|
string description = descriptionAttribute[0].Description;
|
||||||
var snippetAttribute = typeof(T).GetCustomAttributes(typeof(ConfigSnippetAttribute), true) as ConfigSnippetAttribute[];
|
var snippetAttribute = typeof(T).GetCustomAttributes(typeof(ConfigSnippetAttribute), true) as ConfigSnippetAttribute[];
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ using PepperDash.Core;
|
|||||||
using PepperDash.Essentials.Core.Bridges;
|
using PepperDash.Essentials.Core.Bridges;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
using PepperDash.Essentials.Core.Bridges.JoinMaps;
|
using PepperDash.Essentials.Core.Bridges.JoinMaps;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Devices
|
namespace PepperDash.Essentials.Core.Devices
|
||||||
{
|
{
|
||||||
@@ -29,7 +30,7 @@ namespace PepperDash.Essentials.Core.Devices
|
|||||||
_port = irPort;
|
_port = irPort;
|
||||||
if (_port == null)
|
if (_port == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, Debug.ErrorLogLevel.Error, "IR Port is null, device will not function");
|
Debug.LogMessage(LogEventLevel.Information, this, "IR Port is null, device will not function");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DeviceManager.AddDevice(_port);
|
DeviceManager.AddDevice(_port);
|
||||||
@@ -75,12 +76,12 @@ namespace PepperDash.Essentials.Core.Devices
|
|||||||
|
|
||||||
if (_port.UseBridgeJoinMap)
|
if (_port.UseBridgeJoinMap)
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Using new IR bridge join map");
|
Debug.LogMessage(LogEventLevel.Information, this, "Using new IR bridge join map");
|
||||||
|
|
||||||
var bridgeJoins = joinMap.Joins.Where((kv) => _port.IrFileCommands.Any(cmd => cmd == kv.Key)).ToDictionary(kv => kv.Key);
|
var bridgeJoins = joinMap.Joins.Where((kv) => _port.IrFileCommands.Any(cmd => cmd == kv.Key)).ToDictionary(kv => kv.Key);
|
||||||
if (bridgeJoins == null)
|
if (bridgeJoins == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Failed to link new IR bridge join map");
|
Debug.LogMessage(LogEventLevel.Information, this, "Failed to link new IR bridge join map");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +94,7 @@ namespace PepperDash.Essentials.Core.Devices
|
|||||||
var joinDataValue = bridgeJoin.Value.Value;
|
var joinDataValue = bridgeJoin.Value.Value;
|
||||||
var joinNumber = bridgeJoin.Value.Value.JoinNumber;
|
var joinNumber = bridgeJoin.Value.Value.JoinNumber;
|
||||||
|
|
||||||
Debug.Console(2, this, @"bridgeJoin: Key-'{0}'
|
Debug.LogMessage(LogEventLevel.Verbose, this, @"bridgeJoin: Key-'{0}'
|
||||||
Value.Key-'{1}'
|
Value.Key-'{1}'
|
||||||
Value.JoinNumber-'{2}'
|
Value.JoinNumber-'{2}'
|
||||||
Value.Metadata.Description-'{3}'",
|
Value.Metadata.Description-'{3}'",
|
||||||
@@ -110,7 +111,7 @@ Value.Metadata.Description-'{3}'",
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Using legacy IR join mapping based on available IR commands");
|
Debug.LogMessage(LogEventLevel.Information, this, "Using legacy IR join mapping based on available IR commands");
|
||||||
|
|
||||||
joinMap.Joins.Clear();
|
joinMap.Joins.Clear();
|
||||||
|
|
||||||
@@ -141,7 +142,7 @@ Value.Metadata.Description-'{3}'",
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +164,7 @@ Value.Metadata.Description-'{3}'",
|
|||||||
|
|
||||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Factory Attempting to create new Generic IR Controller Device");
|
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic IR Controller Device");
|
||||||
|
|
||||||
var irPort = IRPortHelper.GetIrOutputPortController(dc);
|
var irPort = IRPortHelper.GetIrOutputPortController(dc);
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using System.Text;
|
|||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Devices
|
namespace PepperDash.Essentials.Core.Devices
|
||||||
@@ -25,7 +26,7 @@ namespace PepperDash.Essentials.Core.Devices
|
|||||||
// ------------------------------------------------------DELETE THIS
|
// ------------------------------------------------------DELETE THIS
|
||||||
CommunicationMonitor.StatusChange += (o, a) =>
|
CommunicationMonitor.StatusChange += (o, a) =>
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "Communication monitor status change: {0}", a.Status);
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Communication monitor status change: {0}", a.Status);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
|
||||||
{
|
|
||||||
public interface IHasDspPresets
|
|
||||||
{
|
|
||||||
List<IDspPreset> Presets { get; }
|
|
||||||
|
|
||||||
void RecallPreset(IDspPreset preset);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface IDspPreset
|
|
||||||
{
|
|
||||||
string Name { get; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
12
src/PepperDash.Essentials.Core/Devices/IDspPresets.cs
Normal file
12
src/PepperDash.Essentials.Core/Devices/IDspPresets.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using PepperDash.Core;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core
|
||||||
|
{
|
||||||
|
public interface IDspPresets
|
||||||
|
{
|
||||||
|
Dictionary<string, IKeyName> Presets { get; }
|
||||||
|
|
||||||
|
void RecallPreset(string key);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
|
||||||
using Crestron.SimplSharp.Reflection;
|
|
||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
@@ -22,14 +21,14 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
public static void DumpFeedbacksToConsole(this IHasFeedback source, bool getCurrentStates)
|
public static void DumpFeedbacksToConsole(this IHasFeedback source, bool getCurrentStates)
|
||||||
{
|
{
|
||||||
CType t = source.GetType();
|
Type t = source.GetType();
|
||||||
// get the properties and set them into a new collection of NameType wrappers
|
// get the properties and set them into a new collection of NameType wrappers
|
||||||
var props = t.GetProperties().Select(p => new PropertyNameType(p, t));
|
var props = t.GetProperties().Select(p => new PropertyNameType(p, t));
|
||||||
|
|
||||||
var feedbacks = source.Feedbacks;
|
var feedbacks = source.Feedbacks;
|
||||||
if (feedbacks != null)
|
if (feedbacks != null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, source, "\n\nAvailable feedbacks:");
|
Debug.LogMessage(LogEventLevel.Information, source, "\n\nAvailable feedbacks:");
|
||||||
foreach (var f in feedbacks)
|
foreach (var f in feedbacks)
|
||||||
{
|
{
|
||||||
string val = "";
|
string val = "";
|
||||||
@@ -52,12 +51,12 @@ namespace PepperDash.Essentials.Core
|
|||||||
type = "string";
|
type = "string";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Debug.Console(0, "{0,-12} {1, -25} {2}", type,
|
Debug.LogMessage(LogEventLevel.Information, "{0,-12} {1, -25} {2}", type,
|
||||||
(string.IsNullOrEmpty(f.Key) ? "-no key-" : f.Key), val);
|
(string.IsNullOrEmpty(f.Key) ? "-no key-" : f.Key), val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Debug.Console(0, source, "No available outputs:");
|
Debug.LogMessage(LogEventLevel.Information, source, "No available outputs:");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
@@ -84,14 +85,14 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
if (handler != null)
|
if (handler != null)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Device Usage Ended for: {0} at {1}. In use for {2} minutes.", Parent.Name, UsageEndTime, timeUsed.Minutes);
|
Debug.LogMessage(LogEventLevel.Debug, "Device Usage Ended for: {0} at {1}. In use for {2} minutes.", Parent.Name, UsageEndTime, timeUsed.Minutes);
|
||||||
handler(this, new DeviceUsageEventArgs() { UsageEndTime = UsageEndTime, MinutesUsed = timeUsed.Minutes });
|
handler(this, new DeviceUsageEventArgs() { UsageEndTime = UsageEndTime, MinutesUsed = timeUsed.Minutes });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Error ending device usage: {0}", e);
|
Debug.LogMessage(LogEventLevel.Debug, "Error ending device usage: {0}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,24 @@ namespace PepperDash.Essentials.Core
|
|||||||
IntFeedback VolumeLevelFeedback { get; }
|
IntFeedback VolumeLevelFeedback { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds the ability to display a raw volume level and the units of that level
|
||||||
|
/// </summary>
|
||||||
|
public interface IBasicVolumeWithFeedbackAdvanced : IBasicVolumeWithFeedback
|
||||||
|
{
|
||||||
|
int RawVolumeLevel { get; }
|
||||||
|
|
||||||
|
eVolumeLevelUnits Units { get; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum eVolumeLevelUnits
|
||||||
|
{
|
||||||
|
Decibels,
|
||||||
|
Percent,
|
||||||
|
Relative,
|
||||||
|
Absolute
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A class that implements this contains a reference to a current IBasicVolumeControls device.
|
/// A class that implements this contains a reference to a current IBasicVolumeControls device.
|
||||||
/// The class may have multiple IBasicVolumeControls.
|
/// The class may have multiple IBasicVolumeControls.
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ using PepperDash.Essentials.Core.Config;
|
|||||||
|
|
||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
@@ -46,7 +47,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
IrPort = port;
|
IrPort = port;
|
||||||
if (port == null)
|
if (port == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "WARNING No valid IR Port assigned to controller. IR will not function");
|
Debug.LogMessage(LogEventLevel.Information, this, "WARNING No valid IR Port assigned to controller. IR will not function");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LoadDriver(irDriverFilepath);
|
LoadDriver(irDriverFilepath);
|
||||||
@@ -64,12 +65,12 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
if (IrPort == null)
|
if (IrPort == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "WARNING No valid IR Port assigned to controller. IR will not function");
|
Debug.LogMessage(LogEventLevel.Information, this, "WARNING No valid IR Port assigned to controller. IR will not function");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var filePath = Global.FilePathPrefix + "ir" + Global.DirectorySeparator + config.Properties["control"]["irFile"].Value<string>();
|
var filePath = Global.FilePathPrefix + "ir" + Global.DirectorySeparator + config.Properties["control"]["irFile"].Value<string>();
|
||||||
Debug.Console(1, "*************Attempting to load IR file: {0}***************", filePath);
|
Debug.LogMessage(LogEventLevel.Debug, "*************Attempting to load IR file: {0}***************", filePath);
|
||||||
|
|
||||||
LoadDriver(filePath);
|
LoadDriver(filePath);
|
||||||
|
|
||||||
@@ -79,10 +80,10 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
public void PrintAvailableCommands()
|
public void PrintAvailableCommands()
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "Available IR Commands in IR File {0}", IrPortUid);
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Available IR Commands in IR File {0}", IrPortUid);
|
||||||
foreach (var cmd in IrPort.AvailableIRCmds())
|
foreach (var cmd in IrPort.AvailableIRCmds())
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "{0}", cmd);
|
Debug.LogMessage(LogEventLevel.Verbose, this, "{0}", cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +94,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// <param name="path"></param>
|
/// <param name="path"></param>
|
||||||
public void LoadDriver(string path)
|
public void LoadDriver(string path)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "***Loading IR File***");
|
Debug.LogMessage(LogEventLevel.Verbose, this, "***Loading IR File***");
|
||||||
if (string.IsNullOrEmpty(path)) path = DriverFilepath;
|
if (string.IsNullOrEmpty(path)) path = DriverFilepath;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -108,7 +109,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
DriverIsLoaded = false;
|
DriverIsLoaded = false;
|
||||||
var message = string.Format("WARNING IR Driver '{0}' failed to load", path);
|
var message = string.Format("WARNING IR Driver '{0}' failed to load", path);
|
||||||
Debug.Console(0, this, Debug.ErrorLogLevel.Error, message);
|
Debug.LogMessage(LogEventLevel.Information, this, message);
|
||||||
DriverLoaded.FireUpdate();
|
DriverLoaded.FireUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -119,15 +120,15 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void PressRelease(string command, bool state)
|
public virtual void PressRelease(string command, bool state)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "IR:'{0}'={1}", command, state);
|
Debug.LogMessage(LogEventLevel.Verbose, this, "IR:'{0}'={1}", command, state);
|
||||||
if (IrPort == null)
|
if (IrPort == null)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "WARNING No IR Port assigned to controller");
|
Debug.LogMessage(LogEventLevel.Verbose, this, "WARNING No IR Port assigned to controller");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!DriverIsLoaded)
|
if (!DriverIsLoaded)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "WARNING IR driver is not loaded");
|
Debug.LogMessage(LogEventLevel.Verbose, this, "WARNING IR driver is not loaded");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (state)
|
if (state)
|
||||||
@@ -148,12 +149,12 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
if (IrPort == null)
|
if (IrPort == null)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "WARNING No IR Port assigned to controller");
|
Debug.LogMessage(LogEventLevel.Verbose, this, "WARNING No IR Port assigned to controller");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!DriverIsLoaded)
|
if (!DriverIsLoaded)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "WARNING IR driver is not loaded");
|
Debug.LogMessage(LogEventLevel.Verbose, this, "WARNING IR driver is not loaded");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (IrPort.IsIRCommandAvailable(IrPortUid, command))
|
if (IrPort.IsIRCommandAvailable(IrPortUid, command))
|
||||||
@@ -167,7 +168,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected void NoIrCommandError(string command)
|
protected void NoIrCommandError(string command)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "Device {0}: IR Driver {1} does not contain command {2}",
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Device {0}: IR Driver {1} does not contain command {2}",
|
||||||
Key, IrPort.IRDriverFileNameByIRDriverId(IrPortUid), command);
|
Key, IrPort.IRDriverFileNameByIRDriverId(IrPortUid), command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using PepperDash.Core;
|
||||||
|
using PepperDash.Essentials.Core.Devices;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core
|
||||||
|
{
|
||||||
|
public class LevelControlListItem : AudioControlListItemBase
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public IBasicVolumeWithFeedback LevelControl
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_levelControl == null)
|
||||||
|
_levelControl = DeviceManager.GetDeviceForKey(ParentDeviceKey) as IBasicVolumeWithFeedback;
|
||||||
|
return _levelControl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IBasicVolumeWithFeedback _levelControl;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the name from the device if it implements IKeyName or else returns the Name property
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("preferredName")]
|
||||||
|
public string PreferredName
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(Name)) return Name;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (LevelControl is IKeyName namedLevelControl)
|
||||||
|
{
|
||||||
|
if (namedLevelControl == null)
|
||||||
|
return "---";
|
||||||
|
return namedLevelControl.Name;
|
||||||
|
}
|
||||||
|
else return "---";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The key of the device in the DeviceManager for control
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("deviceKey")]
|
||||||
|
public string DeviceKey
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if(string.IsNullOrEmpty(ItemKey)) return ParentDeviceKey;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return DeviceManager.AllDevices.
|
||||||
|
Where(d => d.Key.Contains(ParentDeviceKey) && d.Key.Contains(ItemKey)).FirstOrDefault()?.Key ?? $"{ParentDeviceKey}--{ItemKey}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates if the item is a level, mute , or both
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("type")]
|
||||||
|
[JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
|
||||||
|
public eLevelControlType Type { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum eLevelControlType
|
||||||
|
{
|
||||||
|
Level = 1,
|
||||||
|
Mute = 2,
|
||||||
|
LevelAndMute = Level | Mute,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,8 +5,8 @@ using Crestron.SimplSharpPro;
|
|||||||
|
|
||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
using PepperDash.Essentials.Core.Routing;
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Devices
|
namespace PepperDash.Essentials.Core.Devices
|
||||||
{
|
{
|
||||||
@@ -73,7 +73,7 @@ namespace PepperDash.Essentials.Core.Devices
|
|||||||
|
|
||||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Factory Attempting to create new InRoomPc Device");
|
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new InRoomPc Device");
|
||||||
return new InRoomPc(dc.Key, dc.Name);
|
return new InRoomPc(dc.Key, dc.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ using Crestron.SimplSharpPro;
|
|||||||
|
|
||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
using PepperDash.Essentials.Core.Routing;
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Devices
|
namespace PepperDash.Essentials.Core.Devices
|
||||||
{
|
{
|
||||||
@@ -69,12 +69,12 @@ namespace PepperDash.Essentials.Core.Devices
|
|||||||
{
|
{
|
||||||
public LaptopFactory()
|
public LaptopFactory()
|
||||||
{
|
{
|
||||||
TypeNames = new List<string>() { "laptop" };
|
TypeNames = new List<string>() { "deprecated" };
|
||||||
}
|
}
|
||||||
|
|
||||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Factory Attempting to create new Laptop Device");
|
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Laptop Device");
|
||||||
return new Core.Devices.Laptop(dc.Key, dc.Name);
|
return new Core.Devices.Laptop(dc.Key, dc.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
45
src/PepperDash.Essentials.Core/Devices/PresetListItem.cs
Normal file
45
src/PepperDash.Essentials.Core/Devices/PresetListItem.cs
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using PepperDash.Core;
|
||||||
|
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core
|
||||||
|
{
|
||||||
|
public class PresetListItem : AudioControlListItemBase
|
||||||
|
{
|
||||||
|
[JsonIgnore]
|
||||||
|
public IKeyName Preset
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_preset == null)
|
||||||
|
{
|
||||||
|
var parent = DeviceManager.GetDeviceForKey(ParentDeviceKey) as IDspPresets;
|
||||||
|
if (parent == null || !parent.Presets.ContainsKey(ItemKey))
|
||||||
|
return null;
|
||||||
|
_preset = parent.Presets[ItemKey];
|
||||||
|
}
|
||||||
|
return _preset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private IKeyName _preset;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the name from the device if it implements IKeyName or else returns the Name property
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("preferredName")]
|
||||||
|
public string PreferredName
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(Name)) return Name;
|
||||||
|
|
||||||
|
else return Preset.Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,128 +1,121 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Crestron.SimplSharp.CrestronIO;
|
|
||||||
using Crestron.SimplSharpPro;
|
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Converters;
|
using Newtonsoft.Json.Converters;
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public enum eSourceListItemType
|
public enum eSourceListItemType
|
||||||
{
|
{
|
||||||
Route, Off, Other, SomethingAwesomerThanThese
|
Route, Off, Other, SomethingAwesomerThanThese
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents an item in a source list - can be deserialized into.
|
/// Represents an item in a source list - can be deserialized into.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SourceListItem
|
public class SourceListItem
|
||||||
{
|
{
|
||||||
[JsonProperty("sourceKey")]
|
[JsonProperty("sourceKey")]
|
||||||
public string SourceKey { get; set; }
|
public string SourceKey { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the source Device for this, if it exists in DeviceManager
|
/// Returns the source Device for this, if it exists in DeviceManager
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public Device SourceDevice
|
public Device SourceDevice
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_SourceDevice == null)
|
if (_SourceDevice == null)
|
||||||
_SourceDevice = DeviceManager.GetDeviceForKey(SourceKey) as Device;
|
_SourceDevice = DeviceManager.GetDeviceForKey(SourceKey) as Device;
|
||||||
return _SourceDevice;
|
return _SourceDevice;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Device _SourceDevice;
|
|
||||||
|
|
||||||
/// <summary>
|
private Device _SourceDevice;
|
||||||
/// Gets either the source's Name or this AlternateName property, if
|
|
||||||
/// defined. If source doesn't exist, returns "Missing source"
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty("preferredName")]
|
|
||||||
public string PreferredName
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(Name))
|
|
||||||
{
|
|
||||||
if (SourceDevice == null)
|
|
||||||
return "---";
|
|
||||||
return SourceDevice.Name;
|
|
||||||
}
|
|
||||||
return Name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A name that will override the source's name on the UI
|
/// Gets either the source's Name or this AlternateName property, if
|
||||||
/// </summary>
|
/// defined. If source doesn't exist, returns "Missing source"
|
||||||
[JsonProperty("name")]
|
/// </summary>
|
||||||
public string Name { get; set; }
|
[JsonProperty("preferredName")]
|
||||||
|
public string PreferredName
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(Name))
|
||||||
|
{
|
||||||
|
if (SourceDevice == null)
|
||||||
|
return "---";
|
||||||
|
return SourceDevice.Name;
|
||||||
|
}
|
||||||
|
return Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A name that will override the source's name on the UI
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("name")]
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specifies and icon for the source list item
|
/// Specifies and icon for the source list item
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("icon")]
|
[JsonProperty("icon")]
|
||||||
public string Icon { get; set; }
|
public string Icon { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Alternate icon
|
/// Alternate icon
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("altIcon")]
|
[JsonProperty("altIcon")]
|
||||||
public string AltIcon { get; set; }
|
public string AltIcon { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates if the item should be included in the source list
|
/// Indicates if the item should be included in the source list
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("includeInSourceList")]
|
[JsonProperty("includeInSourceList")]
|
||||||
public bool IncludeInSourceList { get; set; }
|
public bool IncludeInSourceList { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used to specify the order of the items in the source list when displayed
|
/// Used to specify the order of the items in the source list when displayed
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("order")]
|
[JsonProperty("order")]
|
||||||
public int Order { get; set; }
|
public int Order { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The key of the device for volume control
|
/// The key of the device for volume control
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("volumeControlKey")]
|
[JsonProperty("volumeControlKey")]
|
||||||
public string VolumeControlKey { get; set; }
|
public string VolumeControlKey { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The type of source list item
|
/// The type of source list item
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("type")]
|
[JsonProperty("type")]
|
||||||
[JsonConverter(typeof(StringEnumConverter))]
|
[JsonConverter(typeof(StringEnumConverter))]
|
||||||
public eSourceListItemType Type { get; set; }
|
public eSourceListItemType Type { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The list of routes to execute for this source list item
|
/// The list of routes to execute for this source list item
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("routeList")]
|
[JsonProperty("routeList")]
|
||||||
public List<SourceRouteListItem> RouteList { get; set; }
|
public List<SourceRouteListItem> RouteList { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates if this source should be disabled for sharing to the far end call participants via codec content
|
/// Indicates if this source should be disabled for sharing to the far end call participants via codec content
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("disableCodecSharing")]
|
[JsonProperty("disableCodecSharing")]
|
||||||
public bool DisableCodecSharing { get; set; }
|
public bool DisableCodecSharing { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates if this source should be disabled for routing to a shared output
|
/// Indicates if this source should be disabled for routing to a shared output
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("disableRoutedSharing")]
|
[JsonProperty("disableRoutedSharing")]
|
||||||
public bool DisableRoutedSharing { get; set; }
|
public bool DisableRoutedSharing { get; set; }
|
||||||
|
|
||||||
[JsonProperty("destinations")]
|
[JsonProperty("destinations")]
|
||||||
public List<eSourceListItemDestinationTypes> Destinations { get; set; }
|
public List<eSourceListItemDestinationTypes> Destinations { get; set; }
|
||||||
@@ -144,25 +137,46 @@ namespace PepperDash.Essentials.Core
|
|||||||
[JsonProperty("isAudioSource")]
|
[JsonProperty("isAudioSource")]
|
||||||
public bool IsAudioSource { get; set; }
|
public bool IsAudioSource { get; set; }
|
||||||
|
|
||||||
public SourceListItem()
|
/// <summary>
|
||||||
{
|
/// Hide source on UI when Avanced Sharing is enabled
|
||||||
Icon = "Blank";
|
/// </summary>
|
||||||
}
|
[JsonProperty("disableAdvancedRouting")]
|
||||||
|
public bool DisableAdvancedRouting { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Hide source on UI when Simpl Sharing is enabled
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("disableSimpleRouting")]
|
||||||
|
public bool DisableSimpleRouting { get; set; }
|
||||||
|
|
||||||
}
|
public SourceListItem()
|
||||||
|
{
|
||||||
|
Icon = "Blank";
|
||||||
|
}
|
||||||
|
|
||||||
public class SourceRouteListItem
|
public override string ToString()
|
||||||
{
|
{
|
||||||
[JsonProperty("sourceKey")]
|
return $"{SourceKey}:{Name}";
|
||||||
public string SourceKey { get; set; }
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[JsonProperty("destinationKey")]
|
public class SourceRouteListItem
|
||||||
public string DestinationKey { get; set; }
|
{
|
||||||
|
[JsonProperty("sourceKey")]
|
||||||
|
public string SourceKey { get; set; }
|
||||||
|
|
||||||
[JsonProperty("type")]
|
[JsonProperty("sourcePortKey")]
|
||||||
public eRoutingSignalType Type { get; set; }
|
public string SourcePortKey { get; set; }
|
||||||
}
|
|
||||||
|
[JsonProperty("destinationKey")]
|
||||||
|
public string DestinationKey { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("destinationPortKey")]
|
||||||
|
public string DestinationPortKey { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("type")]
|
||||||
|
public eRoutingSignalType Type { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines the valid destination types for SourceListItems in a room
|
/// Defines the valid destination types for SourceListItems in a room
|
||||||
@@ -172,7 +186,12 @@ namespace PepperDash.Essentials.Core
|
|||||||
defaultDisplay,
|
defaultDisplay,
|
||||||
leftDisplay,
|
leftDisplay,
|
||||||
rightDisplay,
|
rightDisplay,
|
||||||
|
centerDisplay,
|
||||||
programAudio,
|
programAudio,
|
||||||
codecContent
|
codecContent,
|
||||||
|
frontLeftDisplay,
|
||||||
|
frontRightDisplay,
|
||||||
|
rearLeftDisplay,
|
||||||
|
rearRightDisplay,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,7 @@ using PepperDash.Core;
|
|||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
using PepperDash.Essentials.Core.Bridges;
|
using PepperDash.Essentials.Core.Bridges;
|
||||||
using PepperDash.Essentials.Core.Routing;
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
@@ -43,8 +43,8 @@ namespace PepperDash.Essentials.Core
|
|||||||
IrPort = new IrOutputPortController(key + "-ir", port, irDriverFilepath);
|
IrPort = new IrOutputPortController(key + "-ir", port, irDriverFilepath);
|
||||||
DeviceManager.AddDevice(IrPort);
|
DeviceManager.AddDevice(IrPort);
|
||||||
|
|
||||||
IsWarmingUpFeedback.OutputChange += (o, a) => Debug.Console(2, this, "Warming up={0}", _IsWarmingUp);
|
IsWarmingUpFeedback.OutputChange += (o, a) => Debug.LogMessage(LogEventLevel.Verbose, this, "Warming up={0}", _IsWarmingUp);
|
||||||
IsCoolingDownFeedback.OutputChange += (o, a) => Debug.Console(2, this, "Cooling down={0}", _IsCoolingDown);
|
IsCoolingDownFeedback.OutputChange += (o, a) => Debug.LogMessage(LogEventLevel.Verbose, this, "Cooling down={0}", _IsCoolingDown);
|
||||||
|
|
||||||
InputPorts.AddRange(new RoutingPortCollection<RoutingInputPort>
|
InputPorts.AddRange(new RoutingPortCollection<RoutingInputPort>
|
||||||
{
|
{
|
||||||
@@ -170,7 +170,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// <param name="inputSelector">A delegate containing the input selector method to call</param>
|
/// <param name="inputSelector">A delegate containing the input selector method to call</param>
|
||||||
public override void ExecuteSwitch(object inputSelector)
|
public override void ExecuteSwitch(object inputSelector)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "Switching to input '{0}'", (inputSelector as Action).ToString());
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Switching to input '{0}'", (inputSelector as Action).ToString());
|
||||||
|
|
||||||
Action finishSwitch = () =>
|
Action finishSwitch = () =>
|
||||||
{
|
{
|
||||||
@@ -213,7 +213,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Factory Attempting to create new BasicIrDisplay Device");
|
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new BasicIrDisplay Device");
|
||||||
var ir = IRPortHelper.GetIrPort(dc.Properties);
|
var ir = IRPortHelper.GetIrPort(dc.Properties);
|
||||||
if (ir != null)
|
if (ir != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,24 +1,23 @@
|
|||||||
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
using Crestron.SimplSharpPro.DM;
|
|
||||||
using Crestron.SimplSharpPro.DM.Endpoints;
|
|
||||||
using Crestron.SimplSharpPro.DM.Endpoints.Transmitters;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core.Bridges;
|
using PepperDash.Essentials.Core.Bridges;
|
||||||
|
using Serilog.Events;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
[Obsolete("Please use PepperDash.Essentials.Devices.Common, this will be removed in 2.1")]
|
[Obsolete("Please use PepperDash.Essentials.Devices.Common, this will be removed in 2.1")]
|
||||||
public abstract class DisplayBase : EssentialsDevice, IHasFeedback, IRoutingSinkWithSwitching, IHasPowerControl, IWarmingCooling, IUsageTracking
|
public abstract class DisplayBase : EssentialsDevice, IHasFeedback, IRoutingSinkWithSwitching, IHasPowerControl, IWarmingCooling, IUsageTracking
|
||||||
{
|
{
|
||||||
public event SourceInfoChangeHandler CurrentSourceChange;
|
public event SourceInfoChangeHandler CurrentSourceChange;
|
||||||
|
public event InputChangedEventHandler InputChanged;
|
||||||
|
|
||||||
public string CurrentSourceInfoKey { get; set; }
|
public string CurrentSourceInfoKey { get; set; }
|
||||||
public SourceListItem CurrentSourceInfo
|
public SourceListItem CurrentSourceInfo
|
||||||
@@ -95,7 +94,9 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void ExecuteSwitch(object selector);
|
public RoutingInputPort CurrentInputPort => throw new NotImplementedException();
|
||||||
|
|
||||||
|
public abstract void ExecuteSwitch(object selector);
|
||||||
|
|
||||||
protected void LinkDisplayToApi(DisplayBase displayDevice, BasicTriList trilist, uint joinStart, string joinMapKey,
|
protected void LinkDisplayToApi(DisplayBase displayDevice, BasicTriList trilist, uint joinStart, string joinMapKey,
|
||||||
EiscApiAdvanced bridge)
|
EiscApiAdvanced bridge)
|
||||||
@@ -113,7 +114,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0,this,"Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
Debug.LogMessage(LogEventLevel.Information,this,"Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
||||||
}
|
}
|
||||||
|
|
||||||
LinkDisplayToApi(displayDevice, trilist, joinMap);
|
LinkDisplayToApi(displayDevice, trilist, joinMap);
|
||||||
@@ -121,8 +122,8 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
protected void LinkDisplayToApi(DisplayBase displayDevice, BasicTriList trilist, DisplayControllerJoinMap joinMap)
|
protected void LinkDisplayToApi(DisplayBase displayDevice, BasicTriList trilist, DisplayControllerJoinMap joinMap)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
Debug.LogMessage(LogEventLevel.Debug, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
||||||
Debug.Console(0, "Linking to Display: {0}", displayDevice.Name);
|
Debug.LogMessage(LogEventLevel.Information, "Linking to Display: {0}", displayDevice.Name);
|
||||||
|
|
||||||
trilist.StringInput[joinMap.Name.JoinNumber].StringValue = displayDevice.Name;
|
trilist.StringInput[joinMap.Name.JoinNumber].StringValue = displayDevice.Name;
|
||||||
|
|
||||||
@@ -144,7 +145,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
trilist.SetBool(joinMap.IsTwoWayDisplay.JoinNumber, true);
|
trilist.SetBool(joinMap.IsTwoWayDisplay.JoinNumber, true);
|
||||||
|
|
||||||
twoWayDisplay.CurrentInputFeedback.OutputChange += (o, a) => Debug.Console(0, "CurrentInputFeedback_OutputChange {0}", a.StringValue);
|
twoWayDisplay.CurrentInputFeedback.OutputChange += (o, a) => Debug.LogMessage(LogEventLevel.Information, "CurrentInputFeedback_OutputChange {0}", a.StringValue);
|
||||||
|
|
||||||
|
|
||||||
inputNumberFeedback.LinkInputSig(trilist.UShortInput[joinMap.InputSelect.JoinNumber]);
|
inputNumberFeedback.LinkInputSig(trilist.UShortInput[joinMap.InputSelect.JoinNumber]);
|
||||||
@@ -198,16 +199,16 @@ namespace PepperDash.Essentials.Core
|
|||||||
var tempKey = inputKeys.ElementAt(i);
|
var tempKey = inputKeys.ElementAt(i);
|
||||||
trilist.SetSigTrueAction((ushort)(joinMap.InputSelectOffset.JoinNumber + i),
|
trilist.SetSigTrueAction((ushort)(joinMap.InputSelectOffset.JoinNumber + i),
|
||||||
() => displayDevice.ExecuteSwitch(displayDevice.InputPorts[tempKey].Selector));
|
() => displayDevice.ExecuteSwitch(displayDevice.InputPorts[tempKey].Selector));
|
||||||
Debug.Console(2, displayDevice, "Setting Input Select Action on Digital Join {0} to Input: {1}",
|
Debug.LogMessage(LogEventLevel.Verbose, displayDevice, "Setting Input Select Action on Digital Join {0} to Input: {1}",
|
||||||
joinMap.InputSelectOffset.JoinNumber + i, displayDevice.InputPorts[tempKey].Key.ToString());
|
joinMap.InputSelectOffset.JoinNumber + i, displayDevice.InputPorts[tempKey].Key.ToString());
|
||||||
trilist.StringInput[(ushort)(joinMap.InputNamesOffset.JoinNumber + i)].StringValue = displayDevice.InputPorts[i].Key.ToString();
|
trilist.StringInput[(ushort)(joinMap.InputNamesOffset.JoinNumber + i)].StringValue = displayDevice.InputPorts[i].Key.ToString();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Debug.Console(0, displayDevice, Debug.ErrorLogLevel.Warning, "Device has {0} inputs. The Join Map allows up to {1} inputs. Discarding inputs {2} - {3} from bridge.",
|
Debug.LogMessage(LogEventLevel.Information, displayDevice, "Device has {0} inputs. The Join Map allows up to {1} inputs. Discarding inputs {2} - {3} from bridge.",
|
||||||
displayDevice.InputPorts.Count, joinMap.InputNamesOffset.JoinSpan, i + 1, displayDevice.InputPorts.Count);
|
displayDevice.InputPorts.Count, joinMap.InputNamesOffset.JoinSpan, i + 1, displayDevice.InputPorts.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(2, displayDevice, "Setting Input Select Action on Analog Join {0}", joinMap.InputSelect);
|
Debug.LogMessage(LogEventLevel.Verbose, displayDevice, "Setting Input Select Action on Analog Join {0}", joinMap.InputSelect);
|
||||||
trilist.SetUShortSigAction(joinMap.InputSelect.JoinNumber, (a) =>
|
trilist.SetUShortSigAction(joinMap.InputSelect.JoinNumber, (a) =>
|
||||||
{
|
{
|
||||||
if (a == 0)
|
if (a == 0)
|
||||||
@@ -265,16 +266,16 @@ namespace PepperDash.Essentials.Core
|
|||||||
abstract protected Func<bool> PowerIsOnFeedbackFunc { get; }
|
abstract protected Func<bool> PowerIsOnFeedbackFunc { get; }
|
||||||
|
|
||||||
|
|
||||||
public static MockDisplay DefaultDisplay
|
// public static MockDisplay DefaultDisplay
|
||||||
{
|
// {
|
||||||
get
|
// get
|
||||||
{
|
// {
|
||||||
if (_DefaultDisplay == null)
|
// if (_DefaultDisplay == null)
|
||||||
_DefaultDisplay = new MockDisplay("default", "Default Display");
|
// _DefaultDisplay = new MockDisplay("default", "Default Display");
|
||||||
return _DefaultDisplay;
|
// return _DefaultDisplay;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
static MockDisplay _DefaultDisplay;
|
//static MockDisplay _DefaultDisplay;
|
||||||
|
|
||||||
public TwoWayDisplayBase(string key, string name)
|
public TwoWayDisplayBase(string key, string name)
|
||||||
: base(key, name)
|
: base(key, name)
|
||||||
|
|||||||
@@ -1,237 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Crestron.SimplSharpPro;
|
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
|
||||||
using Crestron.SimplSharpPro.DM;
|
|
||||||
using Crestron.SimplSharpPro.DM.Endpoints;
|
|
||||||
using Crestron.SimplSharpPro.DM.Endpoints.Transmitters;
|
|
||||||
|
|
||||||
using PepperDash.Core;
|
|
||||||
using PepperDash.Essentials.Core.Bridges;
|
|
||||||
using PepperDash.Essentials.Core.Routing;
|
|
||||||
using PepperDash.Essentials.Core.Config;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
|
||||||
{
|
|
||||||
[Obsolete("Please use PepperDash.Essentials.Devices.Common, this will be removed in 2.1")]
|
|
||||||
public class MockDisplay : TwoWayDisplayBase, IBasicVolumeWithFeedback, IBridgeAdvanced
|
|
||||||
|
|
||||||
{
|
|
||||||
public RoutingInputPort HdmiIn1 { get; private set; }
|
|
||||||
public RoutingInputPort HdmiIn2 { get; private set; }
|
|
||||||
public RoutingInputPort HdmiIn3 { get; private set; }
|
|
||||||
public RoutingInputPort ComponentIn1 { get; private set; }
|
|
||||||
public RoutingInputPort VgaIn1 { get; private set; }
|
|
||||||
|
|
||||||
bool _PowerIsOn;
|
|
||||||
bool _IsWarmingUp;
|
|
||||||
bool _IsCoolingDown;
|
|
||||||
|
|
||||||
protected override Func<bool> PowerIsOnFeedbackFunc
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return () =>
|
|
||||||
{
|
|
||||||
Debug.Console(2, this, "*************************************************** Display Power is {0}", _PowerIsOn ? "on" : "off");
|
|
||||||
return _PowerIsOn;
|
|
||||||
};
|
|
||||||
} }
|
|
||||||
protected override Func<bool> IsCoolingDownFeedbackFunc
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return () =>
|
|
||||||
{
|
|
||||||
Debug.Console(2, this, "*************************************************** {0}", _IsCoolingDown ? "Display is cooling down" : "Display has finished cooling down");
|
|
||||||
return _IsCoolingDown;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
protected override Func<bool> IsWarmingUpFeedbackFunc
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return () =>
|
|
||||||
{
|
|
||||||
Debug.Console(2, this, "*************************************************** {0}", _IsWarmingUp ? "Display is warming up" : "Display has finished warming up");
|
|
||||||
return _IsWarmingUp;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
protected override Func<string> CurrentInputFeedbackFunc { get { return () => "Not Implemented"; } }
|
|
||||||
|
|
||||||
int VolumeHeldRepeatInterval = 200;
|
|
||||||
ushort VolumeInterval = 655;
|
|
||||||
ushort _FakeVolumeLevel = 31768;
|
|
||||||
bool _IsMuted;
|
|
||||||
|
|
||||||
public MockDisplay(string key, string name)
|
|
||||||
: base(key, name)
|
|
||||||
{
|
|
||||||
HdmiIn1 = new RoutingInputPort(RoutingPortNames.HdmiIn1, eRoutingSignalType.Audio | eRoutingSignalType.Video,
|
|
||||||
eRoutingPortConnectionType.Hdmi, null, this);
|
|
||||||
HdmiIn2 = new RoutingInputPort(RoutingPortNames.HdmiIn2, eRoutingSignalType.Audio | eRoutingSignalType.Video,
|
|
||||||
eRoutingPortConnectionType.Hdmi, null, this);
|
|
||||||
HdmiIn3 = new RoutingInputPort(RoutingPortNames.HdmiIn3, eRoutingSignalType.Audio | eRoutingSignalType.Video,
|
|
||||||
eRoutingPortConnectionType.Hdmi, null, this);
|
|
||||||
ComponentIn1 = new RoutingInputPort(RoutingPortNames.ComponentIn, eRoutingSignalType.Video,
|
|
||||||
eRoutingPortConnectionType.Component, null, this);
|
|
||||||
VgaIn1 = new RoutingInputPort(RoutingPortNames.VgaIn, eRoutingSignalType.Video,
|
|
||||||
eRoutingPortConnectionType.Composite, null, this);
|
|
||||||
InputPorts.AddRange(new[] { HdmiIn1, HdmiIn2, HdmiIn3, ComponentIn1, VgaIn1 });
|
|
||||||
|
|
||||||
VolumeLevelFeedback = new IntFeedback(() => { return _FakeVolumeLevel; });
|
|
||||||
MuteFeedback = new BoolFeedback("MuteOn", () => _IsMuted);
|
|
||||||
|
|
||||||
WarmupTime = 10000;
|
|
||||||
CooldownTime = 10000;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void PowerOn()
|
|
||||||
{
|
|
||||||
if (!PowerIsOnFeedback.BoolValue && !_IsWarmingUp && !_IsCoolingDown)
|
|
||||||
{
|
|
||||||
_IsWarmingUp = true;
|
|
||||||
IsWarmingUpFeedback.InvokeFireUpdate();
|
|
||||||
// Fake power-up cycle
|
|
||||||
WarmupTimer = new CTimer(o =>
|
|
||||||
{
|
|
||||||
_IsWarmingUp = false;
|
|
||||||
_PowerIsOn = true;
|
|
||||||
IsWarmingUpFeedback.InvokeFireUpdate();
|
|
||||||
PowerIsOnFeedback.InvokeFireUpdate();
|
|
||||||
}, WarmupTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void PowerOff()
|
|
||||||
{
|
|
||||||
// If a display has unreliable-power off feedback, just override this and
|
|
||||||
// remove this check.
|
|
||||||
if (PowerIsOnFeedback.BoolValue && !_IsWarmingUp && !_IsCoolingDown)
|
|
||||||
{
|
|
||||||
_IsCoolingDown = true;
|
|
||||||
IsCoolingDownFeedback.InvokeFireUpdate();
|
|
||||||
// Fake cool-down cycle
|
|
||||||
CooldownTimer = new CTimer(o =>
|
|
||||||
{
|
|
||||||
Debug.Console(2, this, "Cooldown timer ending");
|
|
||||||
_IsCoolingDown = false;
|
|
||||||
IsCoolingDownFeedback.InvokeFireUpdate();
|
|
||||||
_PowerIsOn = false;
|
|
||||||
PowerIsOnFeedback.InvokeFireUpdate();
|
|
||||||
}, CooldownTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void PowerToggle()
|
|
||||||
{
|
|
||||||
if (PowerIsOnFeedback.BoolValue && !IsWarmingUpFeedback.BoolValue)
|
|
||||||
PowerOff();
|
|
||||||
else if (!PowerIsOnFeedback.BoolValue && !IsCoolingDownFeedback.BoolValue)
|
|
||||||
PowerOn();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void ExecuteSwitch(object selector)
|
|
||||||
{
|
|
||||||
Debug.Console(2, this, "ExecuteSwitch: {0}", selector);
|
|
||||||
|
|
||||||
if (!_PowerIsOn)
|
|
||||||
{
|
|
||||||
PowerOn();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region IBasicVolumeWithFeedback Members
|
|
||||||
|
|
||||||
public IntFeedback VolumeLevelFeedback { get; private set; }
|
|
||||||
|
|
||||||
public void SetVolume(ushort level)
|
|
||||||
{
|
|
||||||
_FakeVolumeLevel = level;
|
|
||||||
VolumeLevelFeedback.InvokeFireUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void MuteOn()
|
|
||||||
{
|
|
||||||
_IsMuted = true;
|
|
||||||
MuteFeedback.InvokeFireUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void MuteOff()
|
|
||||||
{
|
|
||||||
_IsMuted = false;
|
|
||||||
MuteFeedback.InvokeFireUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public BoolFeedback MuteFeedback { get; private set; }
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region IBasicVolumeControls Members
|
|
||||||
|
|
||||||
public void VolumeUp(bool pressRelease)
|
|
||||||
{
|
|
||||||
//while (pressRelease)
|
|
||||||
//{
|
|
||||||
Debug.Console(2, this, "Volume Down {0}", pressRelease);
|
|
||||||
if (pressRelease)
|
|
||||||
{
|
|
||||||
var newLevel = _FakeVolumeLevel + VolumeInterval;
|
|
||||||
SetVolume((ushort)newLevel);
|
|
||||||
CrestronEnvironment.Sleep(VolumeHeldRepeatInterval);
|
|
||||||
}
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void VolumeDown(bool pressRelease)
|
|
||||||
{
|
|
||||||
//while (pressRelease)
|
|
||||||
//{
|
|
||||||
Debug.Console(2, this, "Volume Up {0}", pressRelease);
|
|
||||||
if (pressRelease)
|
|
||||||
{
|
|
||||||
var newLevel = _FakeVolumeLevel - VolumeInterval;
|
|
||||||
SetVolume((ushort)newLevel);
|
|
||||||
CrestronEnvironment.Sleep(VolumeHeldRepeatInterval);
|
|
||||||
}
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void MuteToggle()
|
|
||||||
{
|
|
||||||
_IsMuted = !_IsMuted;
|
|
||||||
MuteFeedback.InvokeFireUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
|
|
||||||
{
|
|
||||||
LinkDisplayToApi(this, trilist, joinStart, joinMapKey, bridge);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[Obsolete("Please use PepperDash.Essentials.Devices.Common, this will be removed in 2.1")]
|
|
||||||
public class MockDisplayFactory : EssentialsDeviceFactory<MockDisplay>
|
|
||||||
{
|
|
||||||
public MockDisplayFactory()
|
|
||||||
{
|
|
||||||
TypeNames = new List<string>() { "mockdisplay" };
|
|
||||||
}
|
|
||||||
|
|
||||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
|
||||||
{
|
|
||||||
Debug.Console(1, "Factory Attempting to create new Mock Display Device");
|
|
||||||
return new MockDisplay(dc.Key, dc.Name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
|
|
||||||
|
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using Crestron.SimplSharp.Reflection;
|
using System.Reflection;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
|
using Serilog.Events;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -13,13 +14,13 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
public class DeviceFactoryWrapper
|
public class DeviceFactoryWrapper
|
||||||
{
|
{
|
||||||
public CType CType { get; set; }
|
public Type Type { get; set; }
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
public Func<DeviceConfig, IKeyed> FactoryMethod { get; set; }
|
public Func<DeviceConfig, IKeyed> FactoryMethod { get; set; }
|
||||||
|
|
||||||
public DeviceFactoryWrapper()
|
public DeviceFactoryWrapper()
|
||||||
{
|
{
|
||||||
CType = null;
|
Type = null;
|
||||||
Description = "Not Available";
|
Description = "Not Available";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -39,12 +40,12 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var factory = (IDeviceFactory)Crestron.SimplSharp.Reflection.Activator.CreateInstance(type);
|
var factory = (IDeviceFactory)Activator.CreateInstance(type);
|
||||||
factory.LoadTypeFactories();
|
factory.LoadTypeFactories();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to load type: '{1}' DeviceFactory: {0}", e, type.Name);
|
Debug.LogMessage(LogEventLevel.Information, "Unable to load type: '{1}' DeviceFactory: {0}", e, type.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,21 +65,21 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static void AddFactoryForType(string typeName, Func<DeviceConfig, IKeyed> method)
|
public static void AddFactoryForType(string typeName, Func<DeviceConfig, IKeyed> method)
|
||||||
{
|
{
|
||||||
//Debug.Console(1, Debug.ErrorLogLevel.Notice, "Adding factory method for type '{0}'", typeName);
|
//Debug.LogMessage(LogEventLevel.Debug, "Adding factory method for type '{0}'", typeName);
|
||||||
DeviceFactory.FactoryMethods.Add(typeName, new DeviceFactoryWrapper() { FactoryMethod = method});
|
DeviceFactory.FactoryMethods.Add(typeName, new DeviceFactoryWrapper() { FactoryMethod = method});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AddFactoryForType(string typeName, string description, CType cType, Func<DeviceConfig, IKeyed> method)
|
public static void AddFactoryForType(string typeName, string description, Type Type, Func<DeviceConfig, IKeyed> method)
|
||||||
{
|
{
|
||||||
//Debug.Console(1, Debug.ErrorLogLevel.Notice, "Adding factory method for type '{0}'", typeName);
|
//Debug.LogMessage(LogEventLevel.Debug, "Adding factory method for type '{0}'", typeName);
|
||||||
|
|
||||||
if(FactoryMethods.ContainsKey(typeName))
|
if(FactoryMethods.ContainsKey(typeName))
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to add type: '{0}'. Already exists in DeviceFactory", typeName);
|
Debug.LogMessage(LogEventLevel.Information, "Unable to add type: '{0}'. Already exists in DeviceFactory", typeName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var wrapper = new DeviceFactoryWrapper() { CType = cType, Description = description, FactoryMethod = method };
|
var wrapper = new DeviceFactoryWrapper() { Type = Type, Description = description, FactoryMethod = method };
|
||||||
DeviceFactory.FactoryMethods.Add(typeName, wrapper);
|
DeviceFactory.FactoryMethods.Add(typeName, wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +105,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
if (secretProvider == null) return null;
|
if (secretProvider == null) return null;
|
||||||
var secret = secretProvider.GetSecret(data.Key);
|
var secret = secretProvider.GetSecret(data.Key);
|
||||||
if (secret != null) return (string) secret.Value;
|
if (secret != null) return (string) secret.Value;
|
||||||
Debug.Console(1,
|
Debug.LogMessage(LogEventLevel.Debug,
|
||||||
"Unable to retrieve secret {0}{1} - Make sure you've added it to the secrets provider",
|
"Unable to retrieve secret {0}{1} - Make sure you've added it to the secrets provider",
|
||||||
data.Provider, data.Key);
|
data.Provider, data.Key);
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
@@ -121,7 +122,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading '{0}' from Essentials Core", dc.Type);
|
Debug.LogMessage(LogEventLevel.Information, "Loading '{0}' from Essentials Core", dc.Type);
|
||||||
|
|
||||||
var localDc = new DeviceConfig(dc);
|
var localDc = new DeviceConfig(dc);
|
||||||
|
|
||||||
@@ -142,24 +143,13 @@ namespace PepperDash.Essentials.Core
|
|||||||
CheckForSecrets(jProp);
|
CheckForSecrets(jProp);
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(2, "typeName = {0}", typeName);
|
Debug.LogMessage(LogEventLevel.Verbose, "typeName = {0}", typeName);
|
||||||
// Check for types that have been added by plugin dlls.
|
// Check for types that have been added by plugin dlls.
|
||||||
return !FactoryMethods.ContainsKey(typeName) ? null : FactoryMethods[typeName].FactoryMethod(localDc);
|
return !FactoryMethods.ContainsKey(typeName) ? null : FactoryMethods[typeName].FactoryMethod(localDc);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "Exception occurred while creating device {0}: {1}", dc.Key, ex.Message);
|
Debug.LogMessage(ex, "Exception occurred while creating device {0}: {1}", null, dc.Key, ex.Message);
|
||||||
|
|
||||||
Debug.Console(2, "{0}", ex.StackTrace);
|
|
||||||
|
|
||||||
if (ex.InnerException == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "Inner exception while creating device {0}: {1}", dc.Key,
|
|
||||||
ex.InnerException.Message);
|
|
||||||
Debug.Console(2, "{0}", ex.InnerException.StackTrace);
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -179,17 +169,17 @@ namespace PepperDash.Essentials.Core
|
|||||||
foreach (var type in types.OrderBy(t => t.Key))
|
foreach (var type in types.OrderBy(t => t.Key))
|
||||||
{
|
{
|
||||||
var description = type.Value.Description;
|
var description = type.Value.Description;
|
||||||
var cType = "Not Specified by Plugin";
|
var Type = "Not Specified by Plugin";
|
||||||
|
|
||||||
if (type.Value.CType != null)
|
if (type.Value.Type != null)
|
||||||
{
|
{
|
||||||
cType = type.Value.CType.FullName;
|
Type = type.Value.Type.FullName;
|
||||||
}
|
}
|
||||||
|
|
||||||
CrestronConsole.ConsoleCommandResponse(
|
CrestronConsole.ConsoleCommandResponse(
|
||||||
@"Type: '{0}'
|
@"Type: '{0}'
|
||||||
CType: '{1}'
|
Type: '{1}'
|
||||||
Description: {2}{3}", type.Key, cType, description, CrestronEnvironment.NewLine);
|
Description: {2}{3}", type.Key, Type, description, CrestronEnvironment.NewLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,4 @@
|
|||||||
using System;
|
namespace PepperDash.Essentials.Core
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Crestron.SimplSharp.Reflection;
|
|
||||||
|
|
||||||
using PepperDash.Core;
|
|
||||||
using PepperDash.Essentials.Core.Config;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines a class that is capable of loading device types
|
/// Defines a class that is capable of loading device types
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
|
|
||||||
using Crestron.SimplSharp.Reflection;
|
using System.Reflection;
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
|
using Serilog.Events;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -26,12 +25,12 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var factory = (IProcessorExtensionDeviceFactory)Crestron.SimplSharp.Reflection.Activator.CreateInstance(extension);
|
var factory = (IProcessorExtensionDeviceFactory)Activator.CreateInstance(extension);
|
||||||
factory.LoadFactories();
|
factory.LoadFactories();
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to load extension device: '{1}' ProcessorExtensionDeviceFactory: {0}", e, extension.Name);
|
Debug.LogMessage(LogEventLevel.Information, "Unable to load extension device: '{1}' ProcessorExtensionDeviceFactory: {0}", e, extension.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -52,21 +51,21 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static void AddFactoryForType(string extensionName, Func<DeviceConfig, IKeyed> method)
|
public static void AddFactoryForType(string extensionName, Func<DeviceConfig, IKeyed> method)
|
||||||
{
|
{
|
||||||
//Debug.Console(1, Debug.ErrorLogLevel.Notice, "Adding factory method for type '{0}'", typeName);
|
//Debug.LogMessage(LogEventLevel.Debug, "Adding factory method for type '{0}'", typeName);
|
||||||
ProcessorExtensionDeviceFactory.ProcessorExtensionFactoryMethods.Add(extensionName, new DeviceFactoryWrapper() { FactoryMethod = method });
|
ProcessorExtensionDeviceFactory.ProcessorExtensionFactoryMethods.Add(extensionName, new DeviceFactoryWrapper() { FactoryMethod = method });
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AddFactoryForType(string extensionName, string description, CType cType, Func<DeviceConfig, IKeyed> method)
|
public static void AddFactoryForType(string extensionName, string description, Type Type, Func<DeviceConfig, IKeyed> method)
|
||||||
{
|
{
|
||||||
//Debug.Console(1, Debug.ErrorLogLevel.Notice, "Adding factory method for type '{0}'", typeName);
|
//Debug.LogMessage(LogEventLevel.Debug, "Adding factory method for type '{0}'", typeName);
|
||||||
|
|
||||||
if (ProcessorExtensionFactoryMethods.ContainsKey(extensionName))
|
if (ProcessorExtensionFactoryMethods.ContainsKey(extensionName))
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to add extension device: '{0}'. Already exists in ProcessorExtensionDeviceFactory", extensionName);
|
Debug.LogMessage(LogEventLevel.Information, "Unable to add extension device: '{0}'. Already exists in ProcessorExtensionDeviceFactory", extensionName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var wrapper = new DeviceFactoryWrapper() { CType = cType, Description = description, FactoryMethod = method };
|
var wrapper = new DeviceFactoryWrapper() { Type = Type, Description = description, FactoryMethod = method };
|
||||||
ProcessorExtensionDeviceFactory.ProcessorExtensionFactoryMethods.Add(extensionName, wrapper);
|
ProcessorExtensionDeviceFactory.ProcessorExtensionFactoryMethods.Add(extensionName, wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +91,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
if (secretProvider == null) return null;
|
if (secretProvider == null) return null;
|
||||||
var secret = secretProvider.GetSecret(data.Key);
|
var secret = secretProvider.GetSecret(data.Key);
|
||||||
if (secret != null) return (string)secret.Value;
|
if (secret != null) return (string)secret.Value;
|
||||||
Debug.Console(1,
|
Debug.LogMessage(LogEventLevel.Debug,
|
||||||
"Unable to retrieve secret {0}{1} - Make sure you've added it to the secrets provider",
|
"Unable to retrieve secret {0}{1} - Make sure you've added it to the secrets provider",
|
||||||
data.Provider, data.Key);
|
data.Provider, data.Key);
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
@@ -108,7 +107,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading '{0}' from Essentials Core", dc.Type);
|
Debug.LogMessage(LogEventLevel.Information, "Loading '{0}' from Essentials Core", dc.Type);
|
||||||
|
|
||||||
var localDc = new DeviceConfig(dc);
|
var localDc = new DeviceConfig(dc);
|
||||||
|
|
||||||
@@ -128,24 +127,24 @@ namespace PepperDash.Essentials.Core
|
|||||||
CheckForSecrets(jProp);
|
CheckForSecrets(jProp);
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(2, "typeName = {0}", typeName);
|
Debug.LogMessage(LogEventLevel.Verbose, "typeName = {0}", typeName);
|
||||||
// Check for types that have been added by plugin dlls.
|
// Check for types that have been added by plugin dlls.
|
||||||
return !ProcessorExtensionFactoryMethods.ContainsKey(typeName) ? null : ProcessorExtensionFactoryMethods[typeName].FactoryMethod(localDc);
|
return !ProcessorExtensionFactoryMethods.ContainsKey(typeName) ? null : ProcessorExtensionFactoryMethods[typeName].FactoryMethod(localDc);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "Exception occurred while creating device {0}: {1}", dc.Key, ex.Message);
|
Debug.LogMessage(LogEventLevel.Information, "Exception occurred while creating device {0}: {1}", dc.Key, ex.Message);
|
||||||
|
|
||||||
Debug.Console(2, "{0}", ex.StackTrace);
|
Debug.LogMessage(LogEventLevel.Verbose, "{0}", ex.StackTrace);
|
||||||
|
|
||||||
if (ex.InnerException == null)
|
if (ex.InnerException == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "Inner exception while creating device {0}: {1}", dc.Key,
|
Debug.LogMessage(LogEventLevel.Information, "Inner exception while creating device {0}: {1}", dc.Key,
|
||||||
ex.InnerException.Message);
|
ex.InnerException.Message);
|
||||||
Debug.Console(2, "{0}", ex.InnerException.StackTrace);
|
Debug.LogMessage(LogEventLevel.Verbose, "{0}", ex.InnerException.StackTrace);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using Crestron.SimplSharp;
|
|||||||
using Crestron.SimplSharp.CrestronIO;
|
using Crestron.SimplSharp.CrestronIO;
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using Crestron.SimplSharpPro.CrestronThread;
|
using Crestron.SimplSharpPro.CrestronThread;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
@@ -26,7 +27,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
string fullFilePath = Global.FilePathPrefix + fileName;
|
string fullFilePath = Global.FilePathPrefix + fileName;
|
||||||
DirectoryInfo dirInfo = new DirectoryInfo(Path.GetDirectoryName(fullFilePath));
|
DirectoryInfo dirInfo = new DirectoryInfo(Path.GetDirectoryName(fullFilePath));
|
||||||
var files = dirInfo.GetFiles(Path.GetFileName(fullFilePath));
|
var files = dirInfo.GetFiles(Path.GetFileName(fullFilePath));
|
||||||
Debug.Console(0, "FileIO found: {0}, {1}", files.Count(), fullFilePath);
|
Debug.LogMessage(LogEventLevel.Information, "FileIO found: {0}, {1}", files.Count(), fullFilePath);
|
||||||
if (files.Count() > 0)
|
if (files.Count() > 0)
|
||||||
{
|
{
|
||||||
return files;
|
return files;
|
||||||
@@ -42,7 +43,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
string fullFilePath = Global.FilePathPrefix + fileName;
|
string fullFilePath = Global.FilePathPrefix + fileName;
|
||||||
DirectoryInfo dirInfo = new DirectoryInfo(Path.GetDirectoryName(fullFilePath));
|
DirectoryInfo dirInfo = new DirectoryInfo(Path.GetDirectoryName(fullFilePath));
|
||||||
var files = dirInfo.GetFiles(Path.GetFileName(fullFilePath));
|
var files = dirInfo.GetFiles(Path.GetFileName(fullFilePath));
|
||||||
Debug.Console(0, "FileIO found: {0}, {1}", files.Count(), fullFilePath);
|
Debug.LogMessage(LogEventLevel.Information, "FileIO found: {0}, {1}", files.Count(), fullFilePath);
|
||||||
if (files.Count() > 0)
|
if (files.Count() > 0)
|
||||||
{
|
{
|
||||||
return files.FirstOrDefault();
|
return files.FirstOrDefault();
|
||||||
@@ -67,7 +68,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: FileIO read failed: \r{0}", e);
|
Debug.LogMessage(LogEventLevel.Information, "Error: FileIO read failed: \r{0}", e);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -84,7 +85,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
if (fileLock.TryEnter())
|
if (fileLock.TryEnter())
|
||||||
{
|
{
|
||||||
DirectoryInfo dirInfo = new DirectoryInfo(file.DirectoryName);
|
DirectoryInfo dirInfo = new DirectoryInfo(file.DirectoryName);
|
||||||
Debug.Console(2, "FileIO Getting Data {0}", file.FullName);
|
Debug.LogMessage(LogEventLevel.Verbose, "FileIO Getting Data {0}", file.FullName);
|
||||||
|
|
||||||
if (File.Exists(file.FullName))
|
if (File.Exists(file.FullName))
|
||||||
{
|
{
|
||||||
@@ -95,20 +96,20 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(2, "File {0} does not exsist", file.FullName);
|
Debug.LogMessage(LogEventLevel.Verbose, "File {0} does not exsist", file.FullName);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "FileIO Unable to enter FileLock");
|
Debug.LogMessage(LogEventLevel.Information, "FileIO Unable to enter FileLock");
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: FileIO read failed: \r{0}", e);
|
Debug.LogMessage(LogEventLevel.Information, "Error: FileIO read failed: \r{0}", e);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
@@ -128,7 +129,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: FileIO read failed: \r{0}", e);
|
Debug.LogMessage(LogEventLevel.Information, "Error: FileIO read failed: \r{0}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,7 +141,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: FileIO read failed: \r{0}", e);
|
Debug.LogMessage(LogEventLevel.Information, "Error: FileIO read failed: \r{0}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,7 +153,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
if (fileLock.TryEnter())
|
if (fileLock.TryEnter())
|
||||||
{
|
{
|
||||||
DirectoryInfo dirInfo = new DirectoryInfo(file.Name);
|
DirectoryInfo dirInfo = new DirectoryInfo(file.Name);
|
||||||
Debug.Console(2, "FileIO Getting Data {0}", file.FullName);
|
Debug.LogMessage(LogEventLevel.Verbose, "FileIO Getting Data {0}", file.FullName);
|
||||||
|
|
||||||
|
|
||||||
if (File.Exists(file.FullName))
|
if (File.Exists(file.FullName))
|
||||||
@@ -164,20 +165,20 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(2, "File {0} Does not exsist", file.FullName);
|
Debug.LogMessage(LogEventLevel.Verbose, "File {0} Does not exsist", file.FullName);
|
||||||
data = "";
|
data = "";
|
||||||
}
|
}
|
||||||
GotFileEvent.Invoke(null, new FileEventArgs(data));
|
GotFileEvent.Invoke(null, new FileEventArgs(data));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "FileIO Unable to enter FileLock");
|
Debug.LogMessage(LogEventLevel.Information, "FileIO Unable to enter FileLock");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: FileIO read failed: \r{0}", e);
|
Debug.LogMessage(LogEventLevel.Information, "Error: FileIO read failed: \r{0}", e);
|
||||||
data = "";
|
data = "";
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
@@ -207,13 +208,13 @@ namespace PepperDash.Essentials.Core
|
|||||||
_WriteFileThread = new Thread((O) => _WriteFileMethod(data, Global.FilePathPrefix + "/" + filePath), null, Thread.eThreadStartOptions.CreateSuspended);
|
_WriteFileThread = new Thread((O) => _WriteFileMethod(data, Global.FilePathPrefix + "/" + filePath), null, Thread.eThreadStartOptions.CreateSuspended);
|
||||||
_WriteFileThread.Priority = Thread.eThreadPriority.LowestPriority;
|
_WriteFileThread.Priority = Thread.eThreadPriority.LowestPriority;
|
||||||
_WriteFileThread.Start();
|
_WriteFileThread.Start();
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "New WriteFile Thread");
|
Debug.LogMessage(LogEventLevel.Information, "New WriteFile Thread");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static object _WriteFileMethod(string data, string filePath)
|
static object _WriteFileMethod(string data, string filePath)
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to write file: '{0}'", filePath);
|
Debug.LogMessage(LogEventLevel.Information, "Attempting to write file: '{0}'", filePath);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -229,13 +230,13 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "FileIO Unable to enter FileLock");
|
Debug.LogMessage(LogEventLevel.Information, "FileIO Unable to enter FileLock");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: FileIO write failed: \r{0}", e);
|
Debug.LogMessage(LogEventLevel.Error, "Error: FileIO write failed: \r{0}", e);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -259,7 +260,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
var file = FileIO.GetFile("\\user\\*FileIOTest*");
|
var file = FileIO.GetFile("\\user\\*FileIOTest*");
|
||||||
|
|
||||||
var readData = FileIO.ReadDataFromFile(file);
|
var readData = FileIO.ReadDataFromFile(file);
|
||||||
Debug.Console(0, "Returned {0}", readData);
|
Debug.LogMessage(LogEventLevel.Information, "Returned {0}", readData);
|
||||||
File.Delete(file.FullName);
|
File.Delete(file.FullName);
|
||||||
if (testData == readData)
|
if (testData == readData)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using Crestron.SimplSharp.CrestronIO;
|
using Crestron.SimplSharp.CrestronIO;
|
||||||
using Crestron.SimplSharp.CrestronXml;
|
using Crestron.SimplSharp.CrestronXml;
|
||||||
@@ -13,6 +9,11 @@ using Crestron.SimplSharpPro.Fusion;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
|
using Serilog.Events;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Fusion
|
namespace PepperDash.Essentials.Core.Fusion
|
||||||
{
|
{
|
||||||
@@ -128,7 +129,7 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
|
|
||||||
if (File.Exists(oldGuidFilePath))
|
if (File.Exists(oldGuidFilePath))
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Migrating from old Fusion GUID file to new Fusion GUID File");
|
Debug.LogMessage(LogEventLevel.Information, this, "Migrating from old Fusion GUID file to new Fusion GUID File");
|
||||||
|
|
||||||
File.Copy(oldGuidFilePath, guidFilePath);
|
File.Copy(oldGuidFilePath, guidFilePath);
|
||||||
|
|
||||||
@@ -172,7 +173,7 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Error Building Fusion System Controller: {0}", e);
|
Debug.LogMessage(LogEventLevel.Information, this, "Error Building Fusion System Controller: {0}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,7 +232,7 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(filePath))
|
if (string.IsNullOrEmpty(filePath))
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Error writing guid file. No path specified.");
|
Debug.LogMessage(LogEventLevel.Information, this, "Error writing guid file. No path specified.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,7 +247,7 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
|
|
||||||
fileLock.Enter();
|
fileLock.Enter();
|
||||||
|
|
||||||
Debug.Console(1, this, "Writing GUIDs to file");
|
Debug.LogMessage(LogEventLevel.Debug, this, "Writing GUIDs to file");
|
||||||
|
|
||||||
_guiDs = FusionOccSensor == null
|
_guiDs = FusionOccSensor == null
|
||||||
? new FusionRoomGuids(Room.Name, _ipId, RoomGuid, FusionStaticAssets)
|
? new FusionRoomGuids(Room.Name, _ipId, RoomGuid, FusionStaticAssets)
|
||||||
@@ -260,11 +261,11 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
sw.Flush();
|
sw.Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(1, this, "Guids successfully written to file '{0}'", filePath);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Guids successfully written to file '{0}'", filePath);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Error writing guid file: {0}", e);
|
Debug.LogMessage(LogEventLevel.Information, this, "Error writing guid file: {0}", e);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -283,7 +284,7 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(filePath))
|
if (string.IsNullOrEmpty(filePath))
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Error reading guid file. No path specified.");
|
Debug.LogMessage(LogEventLevel.Information, this, "Error reading guid file. No path specified.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,20 +310,20 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
FusionStaticAssets = _guiDs.StaticAssets;
|
FusionStaticAssets = _guiDs.StaticAssets;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Fusion Guids successfully read from file: {0}",
|
Debug.LogMessage(LogEventLevel.Information, this, "Fusion Guids successfully read from file: {0}",
|
||||||
filePath);
|
filePath);
|
||||||
|
|
||||||
Debug.Console(1, this, "\r\n********************\r\n\tRoom Name: {0}\r\n\tIPID: {1:X}\r\n\tRoomGuid: {2}\r\n*******************", Room.Name, _ipId, RoomGuid);
|
Debug.LogMessage(LogEventLevel.Debug, this, "\r\n********************\r\n\tRoom Name: {0}\r\n\tIPID: {1:X}\r\n\tRoomGuid: {2}\r\n*******************", Room.Name, _ipId, RoomGuid);
|
||||||
|
|
||||||
foreach (var item in FusionStaticAssets)
|
foreach (var item in FusionStaticAssets)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "\nAsset Name: {0}\nAsset No: {1}\n Guid: {2}", item.Value.Name,
|
Debug.LogMessage(LogEventLevel.Debug, this, "\nAsset Name: {0}\nAsset No: {1}\n Guid: {2}", item.Value.Name,
|
||||||
item.Value.SlotNumber, item.Value.InstanceId);
|
item.Value.SlotNumber, item.Value.InstanceId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Error reading guid file: {0}", e);
|
Debug.LogMessage(LogEventLevel.Information, this, "Error reading guid file: {0}", e);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -335,7 +336,7 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
|
|
||||||
protected virtual void CreateSymbolAndBasicSigs(uint ipId)
|
protected virtual void CreateSymbolAndBasicSigs(uint ipId)
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Creating Fusion Room symbol with GUID: {0} and IP-ID {1:X2}", RoomGuid, ipId);
|
Debug.LogMessage(LogEventLevel.Information, this, "Creating Fusion Room symbol with GUID: {0} and IP-ID {1:X2}", RoomGuid, ipId);
|
||||||
|
|
||||||
FusionRoom = new FusionRoom(ipId, Global.ControlSystem, Room.Name, RoomGuid);
|
FusionRoom = new FusionRoom(ipId, Global.ControlSystem, Room.Name, RoomGuid);
|
||||||
FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.Use();
|
FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.Use();
|
||||||
@@ -554,7 +555,7 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
"</Parameters>\n" +
|
"</Parameters>\n" +
|
||||||
"</RequestAction>\n";
|
"</RequestAction>\n";
|
||||||
|
|
||||||
Debug.Console(2, this, "Sending Fusion ActionRequest: \n{0}", actionRequest);
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Sending Fusion ActionRequest: \n{0}", actionRequest);
|
||||||
|
|
||||||
FusionRoom.ExtenderFusionRoomDataReservedSigs.ActionQuery.StringValue = actionRequest;
|
FusionRoom.ExtenderFusionRoomDataReservedSigs.ActionQuery.StringValue = actionRequest;
|
||||||
|
|
||||||
@@ -605,7 +606,7 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
"<RequestSchedule><RequestID>FullSchedleRequest</RequestID><RoomID>{0}</RoomID><Start>{1}</Start><HourSpan>24</HourSpan></RequestSchedule>",
|
"<RequestSchedule><RequestID>FullSchedleRequest</RequestID><RoomID>{0}</RoomID><Start>{1}</Start><HourSpan>24</HourSpan></RequestSchedule>",
|
||||||
RoomGuid, currentTime);
|
RoomGuid, currentTime);
|
||||||
|
|
||||||
Debug.Console(2, this, "Sending Fusion ScheduleQuery: \n{0}", requestTest);
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Sending Fusion ScheduleQuery: \n{0}", requestTest);
|
||||||
|
|
||||||
FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.ScheduleQuery.StringValue = requestTest;
|
FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.ScheduleQuery.StringValue = requestTest;
|
||||||
|
|
||||||
@@ -633,7 +634,7 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Error parsing console command: {0}", e);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Error parsing console command: {0}", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
ModifyMeetingEndTime(requestId, extendMinutes);
|
ModifyMeetingEndTime(requestId, extendMinutes);
|
||||||
@@ -648,7 +649,7 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
{
|
{
|
||||||
if (_currentMeeting == null)
|
if (_currentMeeting == null)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "No meeting in progress. Unable to modify end time.");
|
Debug.LogMessage(LogEventLevel.Debug, this, "No meeting in progress. Unable to modify end time.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -667,13 +668,13 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
"<RequestAction><RequestID>{0}</RequestID><RoomID>{1}</RoomID><ActionID>MeetingChange</ActionID><Parameters><Parameter ID = 'MeetingID' Value = '{2}' /><Parameter ID = 'EndTime' Value = '{3}' /></Parameters></RequestAction>"
|
"<RequestAction><RequestID>{0}</RequestID><RoomID>{1}</RoomID><ActionID>MeetingChange</ActionID><Parameters><Parameter ID = 'MeetingID' Value = '{2}' /><Parameter ID = 'EndTime' Value = '{3}' /></Parameters></RequestAction>"
|
||||||
, requestId, RoomGuid, _currentMeeting.MeetingID, extendMinutes);
|
, requestId, RoomGuid, _currentMeeting.MeetingID, extendMinutes);
|
||||||
|
|
||||||
Debug.Console(1, this, "Sending MeetingChange Request: \n{0}", requestTest);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Sending MeetingChange Request: \n{0}", requestTest);
|
||||||
|
|
||||||
FusionRoom.ExtenderFusionRoomDataReservedSigs.ActionQuery.StringValue = requestTest;
|
FusionRoom.ExtenderFusionRoomDataReservedSigs.ActionQuery.StringValue = requestTest;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Invalid time specified");
|
Debug.LogMessage(LogEventLevel.Debug, this, "Invalid time specified");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -716,11 +717,11 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
"</Event>" +
|
"</Event>" +
|
||||||
"</CreateSchedule>";
|
"</CreateSchedule>";
|
||||||
|
|
||||||
Debug.Console(2, this, "Sending CreateMeeting Request: \n{0}", createMeetingRequest);
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Sending CreateMeeting Request: \n{0}", createMeetingRequest);
|
||||||
|
|
||||||
FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.CreateMeeting.StringValue = createMeetingRequest;
|
FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.CreateMeeting.StringValue = createMeetingRequest;
|
||||||
|
|
||||||
//Debug.Console(1, this, "Sending CreateMeeting Request: \n{0}", command);
|
//Debug.LogMessage(LogEventLevel.Debug, this, "Sending CreateMeeting Request: \n{0}", command);
|
||||||
|
|
||||||
//FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.CreateMeeting.StringValue = command;
|
//FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.CreateMeeting.StringValue = command;
|
||||||
}
|
}
|
||||||
@@ -733,7 +734,7 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
protected void ExtenderFusionRoomDataReservedSigs_DeviceExtenderSigChange(DeviceExtender currentDeviceExtender,
|
protected void ExtenderFusionRoomDataReservedSigs_DeviceExtenderSigChange(DeviceExtender currentDeviceExtender,
|
||||||
SigEventArgs args)
|
SigEventArgs args)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "Event: {0}\n Sig: {1}\nFusionResponse:\n{2}", args.Event, args.Sig.Name,
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Event: {0}\n Sig: {1}\nFusionResponse:\n{2}", args.Event, args.Sig.Name,
|
||||||
args.Sig.StringValue);
|
args.Sig.StringValue);
|
||||||
|
|
||||||
|
|
||||||
@@ -802,7 +803,7 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Error parsing ActionQueryResponse: {0}", e);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Error parsing ActionQueryResponse: {0}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (args.Sig == FusionRoom.ExtenderFusionRoomDataReservedSigs.LocalDateTimeQueryResponse)
|
else if (args.Sig == FusionRoom.ExtenderFusionRoomDataReservedSigs.LocalDateTimeQueryResponse)
|
||||||
@@ -825,20 +826,20 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
|
|
||||||
var currentTime = DateTime.Parse(tempLocalDateTime);
|
var currentTime = DateTime.Parse(tempLocalDateTime);
|
||||||
|
|
||||||
Debug.Console(1, this, "DateTime from Fusion Server: {0}", currentTime);
|
Debug.LogMessage(LogEventLevel.Debug, this, "DateTime from Fusion Server: {0}", currentTime);
|
||||||
|
|
||||||
// Parse time and date from response and insert values
|
// Parse time and date from response and insert values
|
||||||
CrestronEnvironment.SetTimeAndDate((ushort) currentTime.Hour, (ushort) currentTime.Minute,
|
CrestronEnvironment.SetTimeAndDate((ushort) currentTime.Hour, (ushort) currentTime.Minute,
|
||||||
(ushort) currentTime.Second, (ushort) currentTime.Month, (ushort) currentTime.Day,
|
(ushort) currentTime.Second, (ushort) currentTime.Month, (ushort) currentTime.Day,
|
||||||
(ushort) currentTime.Year);
|
(ushort) currentTime.Year);
|
||||||
|
|
||||||
Debug.Console(1, this, "Processor time set to {0}", CrestronEnvironment.GetLocalTime());
|
Debug.LogMessage(LogEventLevel.Debug, this, "Processor time set to {0}", CrestronEnvironment.GetLocalTime());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Error parsing LocalDateTimeQueryResponse: {0}", e);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Error parsing LocalDateTimeQueryResponse: {0}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (args.Sig == FusionRoom.ExtenderFusionRoomDataReservedSigs.RoomConfigResponse)
|
else if (args.Sig == FusionRoom.ExtenderFusionRoomDataReservedSigs.RoomConfigResponse)
|
||||||
@@ -847,7 +848,7 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
|
|
||||||
var roomConfigResponseArgs = args.Sig.StringValue.Replace("&", "and");
|
var roomConfigResponseArgs = args.Sig.StringValue.Replace("&", "and");
|
||||||
|
|
||||||
Debug.Console(2, this, "Fusion Response: \n {0}", roomConfigResponseArgs);
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Fusion Response: \n {0}", roomConfigResponseArgs);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -912,7 +913,7 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Error parsing Custom Properties response: {0}", e);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Error parsing Custom Properties response: {0}", e);
|
||||||
}
|
}
|
||||||
//PrintRoomInfo();
|
//PrintRoomInfo();
|
||||||
//getRoomInfoBusy = false;
|
//getRoomInfoBusy = false;
|
||||||
@@ -928,7 +929,7 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
protected void FusionRoomSchedule_DeviceExtenderSigChange(DeviceExtender currentDeviceExtender,
|
protected void FusionRoomSchedule_DeviceExtenderSigChange(DeviceExtender currentDeviceExtender,
|
||||||
SigEventArgs args)
|
SigEventArgs args)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "Scehdule Response Event: {0}\n Sig: {1}\nFusionResponse:\n{2}", args.Event,
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Scehdule Response Event: {0}\n Sig: {1}\nFusionResponse:\n{2}", args.Event,
|
||||||
args.Sig.Name, args.Sig.StringValue);
|
args.Sig.Name, args.Sig.StringValue);
|
||||||
|
|
||||||
|
|
||||||
@@ -980,7 +981,7 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
}
|
}
|
||||||
else if (element.Name == "Event")
|
else if (element.Name == "Event")
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "Event Found:\n{0}", element.OuterXml);
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Event Found:\n{0}", element.OuterXml);
|
||||||
|
|
||||||
var reader = new XmlReader(element.OuterXml);
|
var reader = new XmlReader(element.OuterXml);
|
||||||
|
|
||||||
@@ -1024,12 +1025,12 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Error parsing ScheduleResponse: {0}", e);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Error parsing ScheduleResponse: {0}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (args.Sig == FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.CreateResponse)
|
else if (args.Sig == FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.CreateResponse)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "Create Meeting Response Event: {0}\n Sig: {1}\nFusionResponse:\n{2}", args.Event,
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Create Meeting Response Event: {0}\n Sig: {1}\nFusionResponse:\n{2}", args.Event,
|
||||||
args.Sig.Name, args.Sig.StringValue);
|
args.Sig.Name, args.Sig.StringValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1043,16 +1044,16 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
{
|
{
|
||||||
if (_currentSchedule.Meetings.Count > 0)
|
if (_currentSchedule.Meetings.Count > 0)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Today's Schedule for '{0}'\n", Room.Name);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Today's Schedule for '{0}'\n", Room.Name);
|
||||||
|
|
||||||
foreach (var e in _currentSchedule.Meetings)
|
foreach (var e in _currentSchedule.Meetings)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Subject: {0}", e.Subject);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Subject: {0}", e.Subject);
|
||||||
Debug.Console(1, this, "Organizer: {0}", e.Organizer);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Organizer: {0}", e.Organizer);
|
||||||
Debug.Console(1, this, "MeetingID: {0}", e.MeetingID);
|
Debug.LogMessage(LogEventLevel.Debug, this, "MeetingID: {0}", e.MeetingID);
|
||||||
Debug.Console(1, this, "Start Time: {0}", e.dtStart);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Start Time: {0}", e.dtStart);
|
||||||
Debug.Console(1, this, "End Time: {0}", e.dtEnd);
|
Debug.LogMessage(LogEventLevel.Debug, this, "End Time: {0}", e.dtEnd);
|
||||||
Debug.Console(1, this, "Duration: {0}\n", e.DurationInMinutes);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Duration: {0}\n", e.DurationInMinutes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1110,7 +1111,7 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "WARNING: Config source list '{0}' not found for room '{1}'",
|
Debug.LogMessage(LogEventLevel.Debug, this, "WARNING: Config source list '{0}' not found for room '{1}'",
|
||||||
Room.SourceListKey, Room.Key);
|
Room.SourceListKey, Room.Key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1144,18 +1145,18 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
e.UsageEndTime.ToString("yyyy-MM-dd"), e.UsageEndTime.ToString("HH:mm:ss"),
|
e.UsageEndTime.ToString("yyyy-MM-dd"), e.UsageEndTime.ToString("HH:mm:ss"),
|
||||||
@group, deviceTracker.Parent.Name, e.MinutesUsed, "-", currentMeetingId);
|
@group, deviceTracker.Parent.Name, e.MinutesUsed, "-", currentMeetingId);
|
||||||
|
|
||||||
Debug.Console(1, this, "Device usage for: {0} ended at {1}. In use for {2} minutes",
|
Debug.LogMessage(LogEventLevel.Debug, this, "Device usage for: {0} ended at {1}. In use for {2} minutes",
|
||||||
deviceTracker.Parent.Name, e.UsageEndTime, e.MinutesUsed);
|
deviceTracker.Parent.Name, e.UsageEndTime, e.MinutesUsed);
|
||||||
|
|
||||||
FusionRoom.DeviceUsage.InputSig.StringValue = deviceUsage;
|
FusionRoom.DeviceUsage.InputSig.StringValue = deviceUsage;
|
||||||
|
|
||||||
Debug.Console(1, this, "Device usage string: {0}", deviceUsage);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Device usage string: {0}", deviceUsage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void TryAddRouteActionSigs(string attrName, uint attrNum, string routeKey, Device pSrc)
|
protected void TryAddRouteActionSigs(string attrName, uint attrNum, string routeKey, Device pSrc)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "Creating attribute '{0}' with join {1} for source {2}",
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Creating attribute '{0}' with join {1} for source {2}",
|
||||||
attrName, attrNum, pSrc.Key);
|
attrName, attrNum, pSrc.Key);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -1176,7 +1177,7 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "Error creating Fusion signal {0} {1} for device '{2}'. THIS NEEDS REWORKING",
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Error creating Fusion signal {0} {1} for device '{2}'. THIS NEEDS REWORKING",
|
||||||
attrNum, attrName, pSrc.Key);
|
attrNum, attrName, pSrc.Key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1205,7 +1206,7 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
//var keyNum = ExtractNumberFromKey(dev.Key);
|
//var keyNum = ExtractNumberFromKey(dev.Key);
|
||||||
//if (keyNum == -1)
|
//if (keyNum == -1)
|
||||||
//{
|
//{
|
||||||
// Debug.Console(1, this, "WARNING: Cannot link device '{0}' to numbered Fusion monitoring attributes",
|
// Debug.LogMessage(LogEventLevel.Debug, this, "WARNING: Cannot link device '{0}' to numbered Fusion monitoring attributes",
|
||||||
// dev.Key);
|
// dev.Key);
|
||||||
// continue;
|
// continue;
|
||||||
//}
|
//}
|
||||||
@@ -1277,7 +1278,7 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
sigD.InputSig.BoolValue = smd.CommunicationMonitor.Status == MonitorStatus.IsOk;
|
sigD.InputSig.BoolValue = smd.CommunicationMonitor.Status == MonitorStatus.IsOk;
|
||||||
smd.CommunicationMonitor.StatusChange +=
|
smd.CommunicationMonitor.StatusChange +=
|
||||||
(o, a) => { sigD.InputSig.BoolValue = a.Status == MonitorStatus.IsOk; };
|
(o, a) => { sigD.InputSig.BoolValue = a.Status == MonitorStatus.IsOk; };
|
||||||
Debug.Console(0, this, "Linking '{0}' communication monitor to Fusion '{1}'", dev.Key, attrName);
|
Debug.LogMessage(LogEventLevel.Information, this, "Linking '{0}' communication monitor to Fusion '{1}'", dev.Key, attrName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1306,7 +1307,7 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
var defaultDisplay = hasDefaultDisplay.DefaultDisplay as DisplayBase;
|
var defaultDisplay = hasDefaultDisplay.DefaultDisplay as DisplayBase;
|
||||||
if (defaultDisplay == null)
|
if (defaultDisplay == null)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Cannot link null display to Fusion because default display is null");
|
Debug.LogMessage(LogEventLevel.Debug, this, "Cannot link null display to Fusion because default display is null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1374,7 +1375,7 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Error setting up display in Fusion: {0}", e);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Error setting up display in Fusion: {0}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1467,7 +1468,7 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
if (md != null)
|
if (md != null)
|
||||||
{
|
{
|
||||||
_errorMessageRollUp.AddMonitor(md.CommunicationMonitor);
|
_errorMessageRollUp.AddMonitor(md.CommunicationMonitor);
|
||||||
Debug.Console(2, this, "Adding '{0}' to room's overall error monitor",
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Adding '{0}' to room's overall error monitor",
|
||||||
md.CommunicationMonitor.Parent.Key);
|
md.CommunicationMonitor.Parent.Key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1704,19 +1705,19 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Adding Fusion Static Asset '{0}' to slot {1} with GUID: '{2}'", name, number, instanceId);
|
Debug.LogMessage(LogEventLevel.Information, "Adding Fusion Static Asset '{0}' to slot {1} with GUID: '{2}'", name, number, instanceId);
|
||||||
|
|
||||||
fr.AddAsset(eAssetType.StaticAsset, number, name, type, instanceId);
|
fr.AddAsset(eAssetType.StaticAsset, number, name, type, instanceId);
|
||||||
return fr.UserConfigurableAssetDetails[number].Asset as FusionStaticAsset;
|
return fr.UserConfigurableAssetDetails[number].Asset as FusionStaticAsset;
|
||||||
}
|
}
|
||||||
catch (InvalidOperationException ex)
|
catch (InvalidOperationException ex)
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Error creating Static Asset for device: '{0}'. Check that multiple devices don't have missing or duplicate uid properties in configuration. /r/nError: {1}", name, ex);
|
Debug.LogMessage(LogEventLevel.Information, "Error creating Static Asset for device: '{0}'. Check that multiple devices don't have missing or duplicate uid properties in configuration. /r/nError: {1}", name, ex);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(2, Debug.ErrorLogLevel.Error, "Error creating Static Asset: {0}", e);
|
Debug.LogMessage(LogEventLevel.Verbose, "Error creating Static Asset: {0}", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1726,7 +1727,7 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Adding Fusion Occupancy Sensor Asset '{0}' to slot {1} with GUID: '{2}'", name, number,
|
Debug.LogMessage(LogEventLevel.Information, "Adding Fusion Occupancy Sensor Asset '{0}' to slot {1} with GUID: '{2}'", name, number,
|
||||||
instanceId);
|
instanceId);
|
||||||
|
|
||||||
fr.AddAsset(eAssetType.OccupancySensor, number, name, type, instanceId);
|
fr.AddAsset(eAssetType.OccupancySensor, number, name, type, instanceId);
|
||||||
@@ -1734,12 +1735,12 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
}
|
}
|
||||||
catch (InvalidOperationException ex)
|
catch (InvalidOperationException ex)
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Error creating Static Asset for device: '{0}'. Check that multiple devices don't have missing or duplicate uid properties in configuration. Error: {1}", name, ex);
|
Debug.LogMessage(LogEventLevel.Information, "Error creating Static Asset for device: '{0}'. Check that multiple devices don't have missing or duplicate uid properties in configuration. Error: {1}", name, ex);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(2, Debug.ErrorLogLevel.Error, "Error creating Static Asset: {0}", e);
|
Debug.LogMessage(LogEventLevel.Error, "Error creating Static Asset: {0}", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ using PepperDash.Core;
|
|||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
using PepperDash.Essentials.Core.Devices;
|
using PepperDash.Essentials.Core.Devices;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Fusion
|
namespace PepperDash.Essentials.Core.Fusion
|
||||||
{
|
{
|
||||||
@@ -38,7 +39,7 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
|
|
||||||
if (device is RoomOnToDefaultSourceWhenOccupied)
|
if (device is RoomOnToDefaultSourceWhenOccupied)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Mapping Room on via Occupancy values from Fusion");
|
Debug.LogMessage(LogEventLevel.Debug, "Mapping Room on via Occupancy values from Fusion");
|
||||||
|
|
||||||
var devProps = JsonConvert.DeserializeObject<RoomOnToDefaultSourceWhenOccupiedConfig>(deviceConfig.Properties.ToString());
|
var devProps = JsonConvert.DeserializeObject<RoomOnToDefaultSourceWhenOccupiedConfig>(deviceConfig.Properties.ToString());
|
||||||
|
|
||||||
@@ -89,18 +90,18 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
// Set the room name
|
// Set the room name
|
||||||
if (!string.IsNullOrEmpty(roomInfo.Name))
|
if (!string.IsNullOrEmpty(roomInfo.Name))
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Current Room Name: {0}. New Room Name: {1}", deviceConfig.Name, roomInfo.Name);
|
Debug.LogMessage(LogEventLevel.Debug, "Current Room Name: {0}. New Room Name: {1}", deviceConfig.Name, roomInfo.Name);
|
||||||
// Set the name in config
|
// Set the name in config
|
||||||
deviceConfig.Name = roomInfo.Name;
|
deviceConfig.Name = roomInfo.Name;
|
||||||
|
|
||||||
Debug.Console(1, "Room Name Successfully Changed.");
|
Debug.LogMessage(LogEventLevel.Debug, "Room Name Successfully Changed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the help message
|
// Set the help message
|
||||||
var helpMessage = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("RoomHelpMessage"));
|
var helpMessage = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("RoomHelpMessage"));
|
||||||
if (helpMessage != null)
|
if (helpMessage != null)
|
||||||
{
|
{
|
||||||
//Debug.Console(1, "Current Help Message: {0}. New Help Message: {1}", deviceConfig.Properties["help"]["message"].Value<string>(ToString()), helpMessage.CustomFieldValue);
|
//Debug.LogMessage(LogEventLevel.Debug, "Current Help Message: {0}. New Help Message: {1}", deviceConfig.Properties["help"]["message"].Value<string>(ToString()), helpMessage.CustomFieldValue);
|
||||||
deviceConfig.Properties["helpMessage"] = (string)helpMessage.CustomFieldValue;
|
deviceConfig.Properties["helpMessage"] = (string)helpMessage.CustomFieldValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -113,7 +114,7 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "FusionCustomPropetiesBridge: Error mapping properties: {0}", e);
|
Debug.LogMessage(LogEventLevel.Debug, "FusionCustomPropetiesBridge: Error mapping properties: {0}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Fusion
|
namespace PepperDash.Essentials.Core.Fusion
|
||||||
{
|
{
|
||||||
@@ -45,7 +46,7 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
programs[i] = item;
|
programs[i] = item;
|
||||||
Debug.Console(1, "Program {0}: {1}", i, item.Name);
|
Debug.LogMessage(LogEventLevel.Debug, "Program {0}: {1}", i, item.Name);
|
||||||
}
|
}
|
||||||
return programs;
|
return programs;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using Crestron.SimplSharp;
|
|||||||
using Crestron.SimplSharpPro.Fusion;
|
using Crestron.SimplSharpPro.Fusion;
|
||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Fusion
|
namespace PepperDash.Essentials.Core.Fusion
|
||||||
{
|
{
|
||||||
@@ -74,7 +75,7 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
{
|
{
|
||||||
var slotNum = GetNextAvailableAssetNumber(room);
|
var slotNum = GetNextAvailableAssetNumber(room);
|
||||||
|
|
||||||
Debug.Console(2, "Adding Fusion Asset: {0} of Type: {1} at Slot Number: {2} with GUID: {3}", assetName, type, slotNum, instanceId);
|
Debug.LogMessage(LogEventLevel.Verbose, "Adding Fusion Asset: {0} of Type: {1} at Slot Number: {2} with GUID: {3}", assetName, type, slotNum, instanceId);
|
||||||
|
|
||||||
var tempAsset = new FusionAsset(slotNum, assetName, type, instanceId);
|
var tempAsset = new FusionAsset(slotNum, assetName, type, instanceId);
|
||||||
|
|
||||||
@@ -105,7 +106,7 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
else
|
else
|
||||||
slotNum = slotNum + 1;
|
slotNum = slotNum + 1;
|
||||||
|
|
||||||
Debug.Console(2, "#Next available fusion asset number is: {0}", slotNum);
|
Debug.LogMessage(LogEventLevel.Verbose, "#Next available fusion asset number is: {0}", slotNum);
|
||||||
|
|
||||||
return slotNum;
|
return slotNum;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ using PepperDash.Essentials.License;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using Newtonsoft.Json.Schema;
|
using Newtonsoft.Json.Schema;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
@@ -136,6 +137,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
public static void SetFilePathPrefix(string prefix)
|
public static void SetFilePathPrefix(string prefix)
|
||||||
{
|
{
|
||||||
FilePathPrefix = prefix;
|
FilePathPrefix = prefix;
|
||||||
|
Debug.LogMessage(LogEventLevel.Information, "File Path Prefix set to '{0}'", FilePathPrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
static string _AssemblyVersion;
|
static string _AssemblyVersion;
|
||||||
@@ -169,28 +171,28 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
if (Regex.Match(AssemblyVersion, @"^(\d*).(\d*).(\d*).*").Groups[1].Value == "0")
|
if (Regex.Match(AssemblyVersion, @"^(\d*).(\d*).(\d*).*").Groups[1].Value == "0")
|
||||||
{
|
{
|
||||||
Debug.Console(2, "Running Local Build. Bypassing Dependency Check.");
|
Debug.LogMessage(LogEventLevel.Verbose, "Running Local Build. Bypassing Dependency Check.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (developmentVersions == null)
|
if (developmentVersions == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0,
|
Debug.LogMessage(LogEventLevel.Information,
|
||||||
"Development Plugin does not specify a list of versions. Loading plugin may not work as expected. Checking Minumum version");
|
"Development Plugin does not specify a list of versions. Loading plugin may not work as expected. Checking Minumum version");
|
||||||
return IsRunningMinimumVersionOrHigher(minimumVersion);
|
return IsRunningMinimumVersionOrHigher(minimumVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(2, "Comparing running version '{0}' to minimum versions '{1}'", AssemblyVersion, developmentVersions);
|
Debug.LogMessage(LogEventLevel.Verbose, "Comparing running version '{0}' to minimum versions '{1}'", AssemblyVersion, developmentVersions);
|
||||||
|
|
||||||
var versionMatch = developmentVersions.FirstOrDefault(x => x == AssemblyVersion);
|
var versionMatch = developmentVersions.FirstOrDefault(x => x == AssemblyVersion);
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(versionMatch))
|
if (String.IsNullOrEmpty(versionMatch))
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Essentials Build does not match any builds required for plugin load. Bypassing Plugin Load.");
|
Debug.LogMessage(LogEventLevel.Information, "Essentials Build does not match any builds required for plugin load. Bypassing Plugin Load.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(2, "Essentials Build {0} matches list of development builds", AssemblyVersion);
|
Debug.LogMessage(LogEventLevel.Verbose, "Essentials Build {0} matches list of development builds", AssemblyVersion);
|
||||||
return IsRunningMinimumVersionOrHigher(minimumVersion);
|
return IsRunningMinimumVersionOrHigher(minimumVersion);
|
||||||
|
|
||||||
|
|
||||||
@@ -204,11 +206,11 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// <returns>Returns true if the running version meets or exceeds the minimum specified version</returns>
|
/// <returns>Returns true if the running version meets or exceeds the minimum specified version</returns>
|
||||||
public static bool IsRunningMinimumVersionOrHigher(string minimumVersion)
|
public static bool IsRunningMinimumVersionOrHigher(string minimumVersion)
|
||||||
{
|
{
|
||||||
Debug.Console(2, "Comparing running version '{0}' to minimum version '{1}'", AssemblyVersion, minimumVersion);
|
Debug.LogMessage(LogEventLevel.Verbose, "Comparing running version '{0}' to minimum version '{1}'", AssemblyVersion, minimumVersion);
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(minimumVersion))
|
if (String.IsNullOrEmpty(minimumVersion))
|
||||||
{
|
{
|
||||||
Debug.Console(0,"Plugin does not specify a minimum version. Loading plugin may not work as expected. Proceeding with loading plugin");
|
Debug.LogMessage(LogEventLevel.Information,"Plugin does not specify a minimum version. Loading plugin may not work as expected. Proceeding with loading plugin");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,7 +229,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
Debug.Console(2, "unable to parse minimum version {0}. Bypassing plugin load.", minimumVersion);
|
Debug.LogMessage(LogEventLevel.Verbose, "unable to parse minimum version {0}. Bypassing plugin load.", minimumVersion);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,7 +240,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
return runtimeVer.CompareTo(minimumVer) >= 0;
|
return runtimeVer.CompareTo(minimumVer) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(2, "Running Local Build. Bypassing Dependency Check.");
|
Debug.LogMessage(LogEventLevel.Verbose, "Running Local Build. Bypassing Dependency Check.");
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using Crestron.SimplSharp.Scheduler;
|
|||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core.Fusion;
|
using PepperDash.Essentials.Core.Fusion;
|
||||||
using PepperDash.Essentials.Room.Config;
|
using PepperDash.Essentials.Room.Config;
|
||||||
|
using Serilog.Events;
|
||||||
using Activator = System.Activator;
|
using Activator = System.Activator;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
@@ -21,13 +22,29 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
static Scheduler()
|
static Scheduler()
|
||||||
{
|
{
|
||||||
|
CrestronConsole.AddNewConsoleCommand(DeleteEventGroup, "DeleteEventGroup", "Deletes the event group by key", ConsoleAccessLevelEnum.AccessOperator);
|
||||||
|
|
||||||
CrestronConsole.AddNewConsoleCommand(ClearEventsFromGroup, "ClearAllEvents", "Clears all scheduled events for this group", ConsoleAccessLevelEnum.AccessOperator);
|
CrestronConsole.AddNewConsoleCommand(ClearEventsFromGroup, "ClearAllEvents", "Clears all scheduled events for this group", ConsoleAccessLevelEnum.AccessOperator);
|
||||||
|
|
||||||
CrestronConsole.AddNewConsoleCommand(ListAllEventGroups, "ListAllEventGroups", "Lists all the event groups by key", ConsoleAccessLevelEnum.AccessOperator);
|
CrestronConsole.AddNewConsoleCommand(ListAllEventGroups, "ListAllEventGroups", "Lists all the event groups by key", ConsoleAccessLevelEnum.AccessOperator);
|
||||||
|
|
||||||
CrestronConsole.AddNewConsoleCommand(ListAllEventsForGroup, "ListEventsForGroup",
|
CrestronConsole.AddNewConsoleCommand(ListAllEventsForGroup, "ListEventsForGroup",
|
||||||
"Lists all events for the given group", ConsoleAccessLevelEnum.AccessOperator);
|
"Lists all events for the given group", ConsoleAccessLevelEnum.AccessOperator);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void DeleteEventGroup(string groupName)
|
||||||
|
{
|
||||||
|
if (EventGroups.ContainsKey(groupName))
|
||||||
|
{
|
||||||
|
var group = EventGroups[groupName];
|
||||||
|
|
||||||
|
EventGroups.Remove(groupName);
|
||||||
|
|
||||||
|
group.Dispose();
|
||||||
|
|
||||||
|
group = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -38,8 +55,8 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
if (!EventGroups.ContainsKey(groupName))
|
if (!EventGroups.ContainsKey(groupName))
|
||||||
{
|
{
|
||||||
Debug.Console(0,
|
Debug.LogMessage(LogEventLevel.Information,
|
||||||
"[Scheduler]: Unable to delete events from group '{0}'. Group not found in EventGroups dictionary.",
|
"[Scheduler]: Unable to delete events from group '{0}'. Group not found in EventGroups dictionary.", null,
|
||||||
groupName);
|
groupName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -50,47 +67,47 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
group.ClearAllEvents();
|
group.ClearAllEvents();
|
||||||
|
|
||||||
Debug.Console(0, "[Scheduler]: All events deleted from group '{0}'", groupName);
|
Debug.LogMessage(LogEventLevel.Information, "[Scheduler]: All events deleted from group '{0}'", null, groupName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Debug.Console(0,
|
Debug.LogMessage(LogEventLevel.Information,
|
||||||
"[Scheduler]: Unable to delete events from group '{0}'. Group not found in EventGroups dictionary.",
|
"[Scheduler]: Unable to delete events from group '{0}'. Group not found in EventGroups dictionary.", null,
|
||||||
groupName);
|
groupName);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ListAllEventGroups(string command)
|
static void ListAllEventGroups(string command)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Event Groups:");
|
CrestronConsole.ConsoleCommandResponse("Event Groups:");
|
||||||
foreach (var group in EventGroups)
|
foreach (var group in EventGroups)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "{0}", group.Key);
|
CrestronConsole.ConsoleCommandResponse($"{group.Key}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ListAllEventsForGroup(string args)
|
static void ListAllEventsForGroup(string args)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Getting events for group {0}...", args);
|
Debug.LogMessage(LogEventLevel.Information, "Getting events for group {0}...", null, args);
|
||||||
|
|
||||||
ScheduledEventGroup group;
|
ScheduledEventGroup group;
|
||||||
|
|
||||||
if (!EventGroups.TryGetValue(args, out group))
|
if (!EventGroups.TryGetValue(args, out group))
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Unabled to get event group for key {0}", args);
|
Debug.LogMessage(LogEventLevel.Information, "Unabled to get event group for key {0}", null, args);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var evt in group.ScheduledEvents)
|
foreach (var evt in group.ScheduledEvents)
|
||||||
{
|
{
|
||||||
Debug.Console(0,
|
CrestronConsole.ConsoleCommandResponse(
|
||||||
@"
|
$@"
|
||||||
****Event key {0}****
|
****Event key {evt.Key}****
|
||||||
Event date/time: {1}
|
Event state: {evt.Value.EventState}
|
||||||
Persistent: {2}
|
Event date/time: {evt.Value.DateAndTime}
|
||||||
Acknowlegable: {3}
|
Persistent: {evt.Value.Persistent}
|
||||||
Recurrence: {4}
|
Acknowlegable: {evt.Value.Acknowledgeable}
|
||||||
Recurrence Days: {5}
|
Recurrence: {evt.Value.Recurrence.Recurrence}
|
||||||
********************", evt.Key, evt.Value.DateAndTime, evt.Value.Persistent, evt.Value.Acknowledgeable,
|
Recurrence Days: {evt.Value.Recurrence.RecurrenceDays}
|
||||||
evt.Value.Recurrence.Recurrence, evt.Value.Recurrence.RecurrenceDays);
|
********************");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,8 +154,7 @@ Recurrence Days: {5}
|
|||||||
|
|
||||||
var dayOfWeek = eventTime.DayOfWeek;
|
var dayOfWeek = eventTime.DayOfWeek;
|
||||||
|
|
||||||
Debug.Console(1, "[Scheduler]: eventTime day of week is: {0}", dayOfWeek);
|
Debug.LogMessage(LogEventLevel.Debug, "[Scheduler]: eventTime day of week is: {0}",null, dayOfWeek);
|
||||||
|
|
||||||
switch (dayOfWeek)
|
switch (dayOfWeek)
|
||||||
{
|
{
|
||||||
case DayOfWeek.Sunday:
|
case DayOfWeek.Sunday:
|
||||||
@@ -185,7 +201,7 @@ Recurrence Days: {5}
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(1, "[Scheduler]: eventTime day of week matches recurrence days: {0}", isMatch);
|
Debug.LogMessage(LogEventLevel.Debug, "[Scheduler]: eventTime day of week matches recurrence days: {0}", isMatch);
|
||||||
|
|
||||||
return isMatch;
|
return isMatch;
|
||||||
}
|
}
|
||||||
@@ -202,53 +218,64 @@ Recurrence Days: {5}
|
|||||||
|
|
||||||
public static void CreateEventFromConfig(ScheduledEventConfig config, ScheduledEventGroup group, ScheduledEvent.UserEventCallBack handler)
|
public static void CreateEventFromConfig(ScheduledEventConfig config, ScheduledEventGroup group, ScheduledEvent.UserEventCallBack handler)
|
||||||
{
|
{
|
||||||
if (group == null)
|
try
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Unable to create event. Group is null");
|
if (group == null)
|
||||||
return;
|
{
|
||||||
|
Debug.LogMessage(LogEventLevel.Information, "Unable to create event. Group is null", null, null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var scheduledEvent = new ScheduledEvent(config.Key, group)
|
||||||
|
{
|
||||||
|
Acknowledgeable = config.Acknowledgeable,
|
||||||
|
Persistent = config.Persistent
|
||||||
|
};
|
||||||
|
|
||||||
|
scheduledEvent.UserCallBack += handler;
|
||||||
|
|
||||||
|
scheduledEvent.DateAndTime.SetFirstDayOfWeek(ScheduledEventCommon.eFirstDayOfWeek.Sunday);
|
||||||
|
|
||||||
|
var eventTime = DateTime.Parse(config.Time);
|
||||||
|
|
||||||
|
if (DateTime.Now > eventTime)
|
||||||
|
{
|
||||||
|
eventTime = eventTime.AddDays(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.LogMessage(LogEventLevel.Verbose, "[Scheduler] Current Date day of week: {0} recurrence days: {1}", null, eventTime.DayOfWeek,
|
||||||
|
config.Days);
|
||||||
|
|
||||||
|
var dayOfWeekConverted = ConvertDayOfWeek(eventTime);
|
||||||
|
|
||||||
|
Debug.LogMessage(LogEventLevel.Debug, "[Scheduler] eventTime Day: {0}", null, dayOfWeekConverted);
|
||||||
|
|
||||||
|
while (!dayOfWeekConverted.IsFlagSet(config.Days))
|
||||||
|
{
|
||||||
|
eventTime = eventTime.AddDays(1);
|
||||||
|
|
||||||
|
dayOfWeekConverted = ConvertDayOfWeek(eventTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
scheduledEvent.DateAndTime.SetAbsoluteEventTime(eventTime);
|
||||||
|
|
||||||
|
scheduledEvent.Recurrence.Weekly(config.Days);
|
||||||
|
|
||||||
|
Debug.LogMessage(LogEventLevel.Verbose, $"[Scheduler] Event State: {scheduledEvent.EventState}", null, null);
|
||||||
|
|
||||||
|
if (config.Enable && scheduledEvent.EventState != ScheduledEventCommon.eEventState.Enabled)
|
||||||
|
{
|
||||||
|
scheduledEvent.Enable();
|
||||||
|
}
|
||||||
|
else if (!config.Enable && scheduledEvent.EventState != ScheduledEventCommon.eEventState.Disabled)
|
||||||
|
{
|
||||||
|
scheduledEvent.Disable();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
var scheduledEvent = new ScheduledEvent(config.Key, group)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Acknowledgeable = config.Acknowledgeable,
|
|
||||||
Persistent = config.Persistent
|
|
||||||
};
|
|
||||||
|
|
||||||
scheduledEvent.UserCallBack += handler;
|
Debug.LogMessage(LogEventLevel.Error, "Error creating scheduled event: {0}", null, e);
|
||||||
|
|
||||||
scheduledEvent.DateAndTime.SetFirstDayOfWeek(ScheduledEventCommon.eFirstDayOfWeek.Sunday);
|
|
||||||
|
|
||||||
var eventTime = DateTime.Parse(config.Time);
|
|
||||||
|
|
||||||
if (DateTime.Now > eventTime)
|
|
||||||
{
|
|
||||||
eventTime = eventTime.AddDays(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
Debug.Console(2, "[Scheduler] Current Date day of week: {0} recurrence days: {1}", eventTime.DayOfWeek,
|
|
||||||
config.Days);
|
|
||||||
|
|
||||||
var dayOfWeekConverted = ConvertDayOfWeek(eventTime);
|
|
||||||
|
|
||||||
Debug.Console(1, "[Scheduler] eventTime Day: {0}", dayOfWeekConverted);
|
|
||||||
|
|
||||||
while (!dayOfWeekConverted.IsFlagSet(config.Days))
|
|
||||||
{
|
|
||||||
eventTime = eventTime.AddDays(1);
|
|
||||||
|
|
||||||
dayOfWeekConverted = ConvertDayOfWeek(eventTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
scheduledEvent.DateAndTime.SetAbsoluteEventTime(eventTime);
|
|
||||||
|
|
||||||
scheduledEvent.Recurrence.Weekly(config.Days);
|
|
||||||
|
|
||||||
if (config.Enable)
|
|
||||||
{
|
|
||||||
scheduledEvent.Enable();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
scheduledEvent.Disable();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ using System.Collections.Generic;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Crestron.SimplSharp.Reflection;
|
using System.Reflection;
|
||||||
using Crestron.SimplSharp.CrestronIO;
|
using Crestron.SimplSharp.CrestronIO;
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
|
|
||||||
@@ -13,6 +13,7 @@ using PepperDash.Core;
|
|||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
@@ -57,11 +58,11 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
if (!ConfigReader.ConfigObject.JoinMaps.ContainsKey(joinMapKey))
|
if (!ConfigReader.ConfigObject.JoinMaps.ContainsKey(joinMapKey))
|
||||||
{
|
{
|
||||||
Debug.Console(2, "No Join Map found in config with key: '{0}'", joinMapKey);
|
Debug.LogMessage(LogEventLevel.Verbose, "No Join Map found in config with key: '{0}'", joinMapKey);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(2, "Attempting to load custom join map with key: {0}", joinMapKey);
|
Debug.LogMessage(LogEventLevel.Verbose, "Attempting to load custom join map with key: {0}", joinMapKey);
|
||||||
|
|
||||||
var joinMapJToken = ConfigReader.ConfigObject.JoinMaps[joinMapKey];
|
var joinMapJToken = ConfigReader.ConfigObject.JoinMaps[joinMapKey];
|
||||||
|
|
||||||
@@ -74,7 +75,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(2, "Error getting join map for key: '{0}'. Error: {1}", joinMapKey, e);
|
Debug.LogMessage(LogEventLevel.Verbose, "Error getting join map for key: '{0}'. Error: {1}", joinMapKey, e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,19 +109,20 @@ namespace PepperDash.Essentials.Core
|
|||||||
protected void AddJoins(Type type)
|
protected void AddJoins(Type type)
|
||||||
{
|
{
|
||||||
var fields =
|
var fields =
|
||||||
type.GetCType()
|
type.GetFields(BindingFlags.Public | BindingFlags.Instance)
|
||||||
.GetFields(BindingFlags.Public | BindingFlags.Instance)
|
.Where(f => f.IsDefined(typeof (JoinNameAttribute), true)).ToList();
|
||||||
.Where(f => f.IsDefined(typeof (JoinNameAttribute), true));
|
|
||||||
|
Debug.LogMessage(LogEventLevel.Debug, "Got {fields} with JoinNameAttribute", fields.Count);
|
||||||
|
|
||||||
foreach (var field in fields)
|
foreach (var field in fields)
|
||||||
{
|
{
|
||||||
var childClass = Convert.ChangeType(this, type, null);
|
var childClass = Convert.ChangeType(this, type, null);
|
||||||
|
|
||||||
var value = field.GetValue(childClass) as JoinDataComplete; //this here is JoinMapBaseAdvanced, not the child class. JoinMapBaseAdvanced has no fields.
|
//this here is JoinMapBaseAdvanced, not the child class. JoinMapBaseAdvanced has no fields.
|
||||||
|
|
||||||
if (value == null)
|
if (!(field.GetValue(childClass) is JoinDataComplete value))
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Unable to cast base class to {0}", type.Name);
|
Debug.LogMessage(LogEventLevel.Information, "Unable to cast base class to {0}", type.Name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +130,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
var joinName = value.GetNameAttribute(field);
|
var joinName = value.GetNameAttribute(field);
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(joinName)) continue;
|
if (string.IsNullOrEmpty(joinName)) continue;
|
||||||
|
|
||||||
Joins.Add(joinName, value);
|
Joins.Add(joinName, value);
|
||||||
}
|
}
|
||||||
@@ -154,29 +156,37 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
|
|
||||||
// Get the joins of each type and print them
|
var lineEnding = "\r\n";
|
||||||
sb.AppendLine(String.Format("# {0}", GetType().Name));
|
|
||||||
sb.AppendLine();
|
|
||||||
sb.AppendLine("## Digitals");
|
|
||||||
sb.AppendLine();
|
|
||||||
// Get the joins of each type and print them
|
|
||||||
var digitals =
|
|
||||||
Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Digital) == eJoinType.Digital)
|
|
||||||
.ToDictionary(j => j.Key, j => j.Value);
|
|
||||||
var digitalSb = AppendJoinList(GetSortedJoins(digitals));
|
|
||||||
digitalSb.AppendLine("## Analogs");
|
|
||||||
digitalSb.AppendLine();
|
|
||||||
|
|
||||||
var analogs =
|
var digitals =
|
||||||
Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Analog) == eJoinType.Analog)
|
Joins.Where(j => j.Value.Metadata.JoinType.HasFlag(eJoinType.Digital))
|
||||||
|
.ToDictionary(j => j.Key, j => j.Value);
|
||||||
|
|
||||||
|
var analogs = Joins.Where(j => j.Value.Metadata.JoinType.HasFlag(eJoinType.Analog))
|
||||||
.ToDictionary(j => j.Key, j => j.Value);
|
.ToDictionary(j => j.Key, j => j.Value);
|
||||||
var analogSb = AppendJoinList(GetSortedJoins(analogs));
|
|
||||||
analogSb.AppendLine("## Serials");
|
|
||||||
analogSb.AppendLine();
|
|
||||||
|
|
||||||
var serials =
|
var serials =
|
||||||
Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Serial) == eJoinType.Serial)
|
Joins.Where(j => j.Value.Metadata.JoinType.HasFlag(eJoinType.Serial))
|
||||||
.ToDictionary(j => j.Key, j => j.Value);
|
.ToDictionary(j => j.Key, j => j.Value);
|
||||||
|
|
||||||
|
Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, "Digital join count {digitalCount} Analog join count {analogCount} Serial join count {serialCount}", null, digitals.Count, analogs.Count, serials.Count);
|
||||||
|
|
||||||
|
// Get the joins of each type and print them
|
||||||
|
sb.Append($"# {GetType().Name}\r\n");
|
||||||
|
sb.Append(lineEnding);
|
||||||
|
sb.Append($"## Digitals{lineEnding}");
|
||||||
|
sb.Append(lineEnding);
|
||||||
|
// Get the joins of each type and print them
|
||||||
|
|
||||||
|
var digitalSb = AppendJoinList(GetSortedJoins(digitals));
|
||||||
|
digitalSb.Append($"## Analogs{lineEnding}");
|
||||||
|
digitalSb.Append(lineEnding);
|
||||||
|
|
||||||
|
var analogSb = AppendJoinList(GetSortedJoins(analogs));
|
||||||
|
analogSb.Append($"## Serials{lineEnding}");
|
||||||
|
analogSb.Append(lineEnding);
|
||||||
|
|
||||||
|
|
||||||
var serialSb = AppendJoinList(GetSortedJoins(serials));
|
var serialSb = AppendJoinList(GetSortedJoins(serials));
|
||||||
|
|
||||||
sb.EnsureCapacity(sb.Length + digitalSb.Length + analogSb.Length + serialSb.Length);
|
sb.EnsureCapacity(sb.Length + digitalSb.Length + analogSb.Length + serialSb.Length);
|
||||||
@@ -201,7 +211,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
private static void WriteJoinmapMarkdown(StringBuilder stringBuilder, string pluginType, string bridgeKey, string deviceKey)
|
private static void WriteJoinmapMarkdown(StringBuilder stringBuilder, string pluginType, string bridgeKey, string deviceKey)
|
||||||
{
|
{
|
||||||
var fileName = String.Format("{0}{1}{2}__{3}__{4}.md", Global.FilePathPrefix, "joinMaps/", pluginType, bridgeKey, deviceKey);
|
var fileName = string.Format("{0}{1}{2}__{3}__{4}.md", Global.FilePathPrefix, "joinMaps/", pluginType, bridgeKey, deviceKey);
|
||||||
|
|
||||||
using (var sw = new StreamWriter(fileName))
|
using (var sw = new StreamWriter(fileName))
|
||||||
{
|
{
|
||||||
@@ -229,7 +239,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
static StringBuilder AppendJoinList(List<KeyValuePair<string, JoinDataComplete>> joins)
|
static StringBuilder AppendJoinList(List<KeyValuePair<string, JoinDataComplete>> joins)
|
||||||
{
|
{
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
const string stringFormatter = "| {0} | {1} | {2} | {3} | {4} |";
|
const string stringFormatter = "| {0} | {1} | {2} | {3} | {4} |\r\n";
|
||||||
const int joinNumberLen = 11;
|
const int joinNumberLen = 11;
|
||||||
const int joinSpanLen = 9;
|
const int joinSpanLen = 9;
|
||||||
const int typeLen = 19;
|
const int typeLen = 19;
|
||||||
@@ -237,25 +247,25 @@ namespace PepperDash.Essentials.Core
|
|||||||
var descriptionLen = (from @join in joins select @join.Value into j select j.Metadata.Description.Length).Concat(new[] {11}).Max();
|
var descriptionLen = (from @join in joins select @join.Value into j select j.Metadata.Description.Length).Concat(new[] {11}).Max();
|
||||||
|
|
||||||
//build header
|
//build header
|
||||||
sb.AppendLine(String.Format(stringFormatter,
|
sb.Append(string.Format(stringFormatter,
|
||||||
String.Format("Join Number").PadRight(joinNumberLen, ' '),
|
string.Format("Join Number").PadRight(joinNumberLen, ' '),
|
||||||
String.Format("Join Span").PadRight(joinSpanLen, ' '),
|
string.Format("Join Span").PadRight(joinSpanLen, ' '),
|
||||||
String.Format("Description").PadRight(descriptionLen, ' '),
|
string.Format("Description").PadRight(descriptionLen, ' '),
|
||||||
String.Format("Type").PadRight(typeLen, ' '),
|
string.Format("Type").PadRight(typeLen, ' '),
|
||||||
String.Format("Capabilities").PadRight(capabilitiesLen, ' ')));
|
string.Format("Capabilities").PadRight(capabilitiesLen, ' ')));
|
||||||
//build table seperator
|
//build table seperator
|
||||||
sb.AppendLine(String.Format(stringFormatter,
|
sb.Append(string.Format(stringFormatter,
|
||||||
new String('-', joinNumberLen),
|
new string('-', joinNumberLen),
|
||||||
new String('-', joinSpanLen),
|
new string('-', joinSpanLen),
|
||||||
new String('-', descriptionLen),
|
new string('-', descriptionLen),
|
||||||
new String('-', typeLen),
|
new string('-', typeLen),
|
||||||
new String('-', capabilitiesLen)));
|
new string('-', capabilitiesLen)));
|
||||||
|
|
||||||
foreach (var join in joins)
|
foreach (var join in joins)
|
||||||
{
|
{
|
||||||
sb.AppendLine(join.Value.GetMarkdownFormattedData(stringFormatter, descriptionLen));
|
sb.Append(join.Value.GetMarkdownFormattedData(stringFormatter, descriptionLen));
|
||||||
}
|
}
|
||||||
sb.AppendLine();
|
sb.Append("\r\n");
|
||||||
return sb;
|
return sb;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,7 +281,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
if (!Joins.TryGetValue(customJoinData.Key, out join))
|
if (!Joins.TryGetValue(customJoinData.Key, out join))
|
||||||
{
|
{
|
||||||
Debug.Console(2, "No matching key found in join map for: '{0}'", customJoinData.Key);
|
Debug.LogMessage(LogEventLevel.Verbose, "No matching key found in join map for: '{0}'", customJoinData.Key);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,10 +420,10 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
|
|
||||||
//Fixed Width Headers
|
//Fixed Width Headers
|
||||||
var joinNumberLen = String.Format("Join Number").Length;
|
var joinNumberLen = string.Format("Join Number").Length;
|
||||||
var joinSpanLen = String.Format("Join Span").Length;
|
var joinSpanLen = string.Format("Join Span").Length;
|
||||||
var typeLen = String.Format("AnalogDigitalSerial").Length;
|
var typeLen = string.Format("AnalogDigitalSerial").Length;
|
||||||
var capabilitiesLen = String.Format("ToFromFusion").Length;
|
var capabilitiesLen = string.Format("ToFromFusion").Length;
|
||||||
|
|
||||||
//Track which one failed, if it did
|
//Track which one failed, if it did
|
||||||
const string placeholder = "unknown";
|
const string placeholder = "unknown";
|
||||||
@@ -429,13 +439,13 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
dataArray["joinNumber"] = String.Format("{0}", JoinNumber.ToString(CultureInfo.InvariantCulture).ReplaceIfNullOrEmpty(placeholder)).PadRight(joinNumberLen, ' ');
|
dataArray["joinNumber"] = string.Format("{0}", JoinNumber.ToString(CultureInfo.InvariantCulture).ReplaceIfNullOrEmpty(placeholder)).PadRight(joinNumberLen, ' ');
|
||||||
dataArray["joinSpan"] = String.Format("{0}", JoinSpan.ToString(CultureInfo.InvariantCulture).ReplaceIfNullOrEmpty(placeholder)).PadRight(joinSpanLen, ' ');
|
dataArray["joinSpan"] = string.Format("{0}", JoinSpan.ToString(CultureInfo.InvariantCulture).ReplaceIfNullOrEmpty(placeholder)).PadRight(joinSpanLen, ' ');
|
||||||
dataArray["description"] = String.Format("{0}", Metadata.Description.ReplaceIfNullOrEmpty(placeholder)).PadRight(descriptionLen, ' ');
|
dataArray["description"] = string.Format("{0}", Metadata.Description.ReplaceIfNullOrEmpty(placeholder)).PadRight(descriptionLen, ' ');
|
||||||
dataArray["joinType"] = String.Format("{0}", Metadata.JoinType.ToString().ReplaceIfNullOrEmpty(placeholder)).PadRight(typeLen, ' ');
|
dataArray["joinType"] = string.Format("{0}", Metadata.JoinType.ToString().ReplaceIfNullOrEmpty(placeholder)).PadRight(typeLen, ' ');
|
||||||
dataArray["capabilities"] = String.Format("{0}", Metadata.JoinCapabilities.ToString().ReplaceIfNullOrEmpty(placeholder)).PadRight(capabilitiesLen, ' ');
|
dataArray["capabilities"] = string.Format("{0}", Metadata.JoinCapabilities.ToString().ReplaceIfNullOrEmpty(placeholder)).PadRight(capabilitiesLen, ' ');
|
||||||
|
|
||||||
return String.Format(stringFormatter,
|
return string.Format(stringFormatter,
|
||||||
dataArray["joinNumber"],
|
dataArray["joinNumber"],
|
||||||
dataArray["joinSpan"],
|
dataArray["joinSpan"],
|
||||||
dataArray["description"],
|
dataArray["description"],
|
||||||
@@ -453,8 +463,8 @@ namespace PepperDash.Essentials.Core
|
|||||||
errorKey = item.Key;
|
errorKey = item.Key;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Debug.Console(0, "Unable to decode join metadata {1}- {0}", e.Message, !String.IsNullOrEmpty(errorKey) ? (' ' + errorKey) : String.Empty);
|
Debug.LogMessage(LogEventLevel.Information, "Unable to decode join metadata {1}- {0}", e.Message, !string.IsNullOrEmpty(errorKey) ? (' ' + errorKey) : string.Empty);
|
||||||
return String.Format(stringFormatter,
|
return string.Format(stringFormatter,
|
||||||
dataArray["joinNumber"],
|
dataArray["joinNumber"],
|
||||||
dataArray["joinSpan"],
|
dataArray["joinSpan"],
|
||||||
dataArray["description"],
|
dataArray["description"],
|
||||||
@@ -500,12 +510,12 @@ namespace PepperDash.Essentials.Core
|
|||||||
public string GetNameAttribute(MemberInfo memberInfo)
|
public string GetNameAttribute(MemberInfo memberInfo)
|
||||||
{
|
{
|
||||||
var name = string.Empty;
|
var name = string.Empty;
|
||||||
var attribute = (JoinNameAttribute)CAttribute.GetCustomAttribute(memberInfo, typeof(JoinNameAttribute));
|
var attribute = (JoinNameAttribute)Attribute.GetCustomAttribute(memberInfo, typeof(JoinNameAttribute));
|
||||||
|
|
||||||
if (attribute == null) return name;
|
if (attribute == null) return name;
|
||||||
|
|
||||||
name = attribute.Name;
|
name = attribute.Name;
|
||||||
Debug.Console(2, "JoinName Attribute value: {0}", name);
|
Debug.LogMessage(LogEventLevel.Verbose, "JoinName Attribute value: {0}", name);
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -513,13 +523,13 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
|
|
||||||
[AttributeUsage(AttributeTargets.All)]
|
[AttributeUsage(AttributeTargets.All)]
|
||||||
public class JoinNameAttribute : CAttribute
|
public class JoinNameAttribute : Attribute
|
||||||
{
|
{
|
||||||
private string _Name;
|
private string _Name;
|
||||||
|
|
||||||
public JoinNameAttribute(string name)
|
public JoinNameAttribute(string name)
|
||||||
{
|
{
|
||||||
Debug.Console(2, "Setting Attribute Name: {0}", name);
|
Debug.LogMessage(LogEventLevel.Verbose, "Setting Attribute Name: {0}",null, name);
|
||||||
_Name = name;
|
_Name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using Crestron.SimplSharp.CrestronDataStore;
|
|||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.License
|
namespace PepperDash.Essentials.License
|
||||||
@@ -69,7 +70,7 @@ namespace PepperDash.Essentials.License
|
|||||||
{
|
{
|
||||||
IsValid = isValid;
|
IsValid = isValid;
|
||||||
CrestronDataStoreStatic.SetGlobalBoolValue("MockLicense", isValid);
|
CrestronDataStoreStatic.SetGlobalBoolValue("MockLicense", isValid);
|
||||||
Debug.Console(0, "Mock License is{0} valid", IsValid ? "" : " not");
|
Debug.LogMessage(LogEventLevel.Information, "Mock License is{0} valid", IsValid ? "" : " not");
|
||||||
LicenseIsValid.FireUpdate();
|
LicenseIsValid.FireUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ using Crestron.SimplSharpPro.DeviceSupport;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core.Bridges;
|
using PepperDash.Essentials.Core.Bridges;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Lighting
|
namespace PepperDash.Essentials.Core.Lighting
|
||||||
{
|
{
|
||||||
@@ -41,7 +42,7 @@ namespace PepperDash.Essentials.Core.Lighting
|
|||||||
|
|
||||||
public void SimulateSceneSelect(string sceneName)
|
public void SimulateSceneSelect(string sceneName)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Simulating selection of scene '{0}'", sceneName);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Simulating selection of scene '{0}'", sceneName);
|
||||||
|
|
||||||
var scene = LightingScenes.FirstOrDefault(s => s.Name.Equals(sceneName));
|
var scene = LightingScenes.FirstOrDefault(s => s.Name.Equals(sceneName));
|
||||||
|
|
||||||
@@ -89,7 +90,7 @@ namespace PepperDash.Essentials.Core.Lighting
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return LinkLightingToApi(lightingDevice, trilist, joinMap);
|
return LinkLightingToApi(lightingDevice, trilist, joinMap);
|
||||||
@@ -97,9 +98,9 @@ namespace PepperDash.Essentials.Core.Lighting
|
|||||||
|
|
||||||
protected GenericLightingJoinMap LinkLightingToApi(LightingBase lightingDevice, BasicTriList trilist, GenericLightingJoinMap joinMap)
|
protected GenericLightingJoinMap LinkLightingToApi(LightingBase lightingDevice, BasicTriList trilist, GenericLightingJoinMap joinMap)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
Debug.LogMessage(LogEventLevel.Debug, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
||||||
|
|
||||||
Debug.Console(0, "Linking to Lighting Type {0}", lightingDevice.GetType().Name.ToString());
|
Debug.LogMessage(LogEventLevel.Information, "Linking to Lighting Type {0}", lightingDevice.GetType().Name.ToString());
|
||||||
|
|
||||||
// GenericLighitng Actions & FeedBack
|
// GenericLighitng Actions & FeedBack
|
||||||
trilist.SetUShortSigAction(joinMap.SelectScene.JoinNumber, u => lightingDevice.SelectScene(lightingDevice.LightingScenes[u]));
|
trilist.SetUShortSigAction(joinMap.SelectScene.JoinNumber, u => lightingDevice.SelectScene(lightingDevice.LightingScenes[u]));
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using PepperDash.Core;
|
|||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
using PepperDash.Essentials.Core.CrestronIO;
|
using PepperDash.Essentials.Core.CrestronIO;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Privacy
|
namespace PepperDash.Essentials.Core.Privacy
|
||||||
@@ -79,14 +80,14 @@ namespace PepperDash.Essentials.Core.Privacy
|
|||||||
if (greenLed != null)
|
if (greenLed != null)
|
||||||
GreenLedRelay = greenLed;
|
GreenLedRelay = greenLed;
|
||||||
else
|
else
|
||||||
Debug.Console(0, this, "Unable to add Green LED device");
|
Debug.LogMessage(LogEventLevel.Information, this, "Unable to add Green LED device");
|
||||||
|
|
||||||
var redLed = DeviceManager.GetDeviceForKey(Config.RedLedRelay.DeviceKey) as GenericRelayDevice;
|
var redLed = DeviceManager.GetDeviceForKey(Config.RedLedRelay.DeviceKey) as GenericRelayDevice;
|
||||||
|
|
||||||
if (redLed != null)
|
if (redLed != null)
|
||||||
RedLedRelay = redLed;
|
RedLedRelay = redLed;
|
||||||
else
|
else
|
||||||
Debug.Console(0, this, "Unable to add Red LED device");
|
Debug.LogMessage(LogEventLevel.Information, this, "Unable to add Red LED device");
|
||||||
|
|
||||||
AddPostActivationAction(() => {
|
AddPostActivationAction(() => {
|
||||||
PrivacyDevice.PrivacyModeIsOnFeedback.OutputChange -= PrivacyModeIsOnFeedback_OutputChange;
|
PrivacyDevice.PrivacyModeIsOnFeedback.OutputChange -= PrivacyModeIsOnFeedback_OutputChange;
|
||||||
@@ -114,7 +115,7 @@ namespace PepperDash.Essentials.Core.Privacy
|
|||||||
|
|
||||||
void PrivacyModeIsOnFeedback_OutputChange(object sender, EventArgs e)
|
void PrivacyModeIsOnFeedback_OutputChange(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Privacy mode change: {0}", sender as BoolFeedback);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Privacy mode change: {0}", sender as BoolFeedback);
|
||||||
CheckPrivacyMode();
|
CheckPrivacyMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,7 +245,7 @@ namespace PepperDash.Essentials.Core.Privacy
|
|||||||
|
|
||||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Factory Attempting to create new MIcrophonePrivacyController Device");
|
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new MIcrophonePrivacyController Device");
|
||||||
var props = Newtonsoft.Json.JsonConvert.DeserializeObject<Core.Privacy.MicrophonePrivacyControllerConfig>(dc.Properties.ToString());
|
var props = Newtonsoft.Json.JsonConvert.DeserializeObject<Core.Privacy.MicrophonePrivacyControllerConfig>(dc.Properties.ToString());
|
||||||
|
|
||||||
return new Core.Privacy.MicrophonePrivacyController(dc.Key, props);
|
return new Core.Privacy.MicrophonePrivacyController(dc.Key, props);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ using Crestron.SimplSharpPro.DeviceSupport;
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
@@ -232,7 +233,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
StartErrorTimers();
|
StartErrorTimers();
|
||||||
if (Client.IsConnected)
|
if (Client.IsConnected)
|
||||||
{
|
{
|
||||||
//Debug.Console(2, this, "Polling");
|
//Debug.LogMessage(LogEventLevel.Verbose, this, "Polling");
|
||||||
if(PollAction != null)
|
if(PollAction != null)
|
||||||
PollAction.Invoke();
|
PollAction.Invoke();
|
||||||
else
|
else
|
||||||
@@ -240,7 +241,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "Comm not connected");
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Comm not connected");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ using PepperDash.Core;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Converters;
|
using Newtonsoft.Json.Converters;
|
||||||
using PepperDash.Essentials.Core.Bridges;
|
using PepperDash.Essentials.Core.Bridges;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Monitoring
|
namespace PepperDash.Essentials.Core.Monitoring
|
||||||
{
|
{
|
||||||
@@ -61,7 +62,7 @@ namespace PepperDash.Essentials.Core.Monitoring
|
|||||||
public SystemMonitorController(string key)
|
public SystemMonitorController(string key)
|
||||||
: base(key)
|
: base(key)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "Adding SystemMonitorController.");
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Adding SystemMonitorController.");
|
||||||
|
|
||||||
SystemMonitor.ProgramInitialization.ProgramInitializationUnderUserControl = true;
|
SystemMonitor.ProgramInitialization.ProgramInitializationUnderUserControl = true;
|
||||||
|
|
||||||
@@ -109,7 +110,7 @@ namespace PepperDash.Essentials.Core.Monitoring
|
|||||||
_uptimePollTimer = null;
|
_uptimePollTimer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PollUptime(object obj)
|
public void PollUptime(object obj)
|
||||||
{
|
{
|
||||||
var consoleResponse = string.Empty;
|
var consoleResponse = string.Empty;
|
||||||
|
|
||||||
@@ -141,19 +142,22 @@ namespace PepperDash.Essentials.Core.Monitoring
|
|||||||
_uptime = uptimeRaw.Substring(forIndex + 4);
|
_uptime = uptimeRaw.Substring(forIndex + 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ProcessorReboot()
|
public static void ProcessorReboot()
|
||||||
{
|
{
|
||||||
if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Server) return;
|
if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Server) return;
|
||||||
|
Debug.LogMessage(LogEventLevel.Information, "Rebooting...");
|
||||||
|
|
||||||
var response = string.Empty;
|
|
||||||
|
var response = string.Empty;
|
||||||
CrestronConsole.SendControlSystemCommand("reboot", ref response);
|
CrestronConsole.SendControlSystemCommand("reboot", ref response);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ProgramReset(uint index)
|
public static void ProgramReset(uint index)
|
||||||
{
|
{
|
||||||
if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Server) return;
|
if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Server) return;
|
||||||
|
Debug.LogMessage(LogEventLevel.Information, "Resetting Program {0}...", index);
|
||||||
|
|
||||||
if (index <= 0 || index > 10) return;
|
if (index <= 0 || index > 10) return;
|
||||||
|
|
||||||
var cmd = string.Format("progreset -p:{0}", index);
|
var cmd = string.Format("progreset -p:{0}", index);
|
||||||
|
|
||||||
@@ -175,11 +179,11 @@ namespace PepperDash.Essentials.Core.Monitoring
|
|||||||
{
|
{
|
||||||
EthernetStatusFeedbackCollection = new Dictionary<short, EthernetStatusFeedbacks>();
|
EthernetStatusFeedbackCollection = new Dictionary<short, EthernetStatusFeedbacks>();
|
||||||
|
|
||||||
Debug.Console(2, "Creating {0} EthernetStatusFeedbacks", InitialParametersClass.NumberOfEthernetInterfaces);
|
Debug.LogMessage(LogEventLevel.Verbose, "Creating {0} EthernetStatusFeedbacks", InitialParametersClass.NumberOfEthernetInterfaces);
|
||||||
|
|
||||||
for (short i = 0; i < InitialParametersClass.NumberOfEthernetInterfaces; i++)
|
for (short i = 0; i < InitialParametersClass.NumberOfEthernetInterfaces; i++)
|
||||||
{
|
{
|
||||||
Debug.Console(2, "Creating EthernetStatusFeedback for Interface {0}", i);
|
Debug.LogMessage(LogEventLevel.Verbose, "Creating EthernetStatusFeedback for Interface {0}", i);
|
||||||
var ethernetInterface = new EthernetStatusFeedbacks(i);
|
var ethernetInterface = new EthernetStatusFeedbacks(i);
|
||||||
EthernetStatusFeedbackCollection.Add(i, ethernetInterface);
|
EthernetStatusFeedbackCollection.Add(i, ethernetInterface);
|
||||||
}
|
}
|
||||||
@@ -260,11 +264,11 @@ namespace PepperDash.Essentials.Core.Monitoring
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
Debug.LogMessage(LogEventLevel.Debug, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
||||||
Debug.Console(2, this, "Linking API starting at join: {0}", joinStart);
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Linking API starting at join: {0}", joinStart);
|
||||||
|
|
||||||
TimeZoneFeedback.LinkInputSig(trilist.UShortInput[joinMap.TimeZone.JoinNumber]);
|
TimeZoneFeedback.LinkInputSig(trilist.UShortInput[joinMap.TimeZone.JoinNumber]);
|
||||||
TimeZoneTextFeedback.LinkInputSig(trilist.StringInput[joinMap.TimeZoneName.JoinNumber]);
|
TimeZoneTextFeedback.LinkInputSig(trilist.StringInput[joinMap.TimeZoneName.JoinNumber]);
|
||||||
@@ -366,8 +370,8 @@ namespace PepperDash.Essentials.Core.Monitoring
|
|||||||
/// <param name="args"></param>
|
/// <param name="args"></param>
|
||||||
private void SystemMonitor_ProgramChange(Program sender, ProgramEventArgs args)
|
private void SystemMonitor_ProgramChange(Program sender, ProgramEventArgs args)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "Program Change Detected for slot: {0}", sender.Number);
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Program Change Detected for slot: {0}", sender.Number);
|
||||||
Debug.Console(2, this, "Event Type: {0}", args.EventType);
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Event Type: {0}", args.EventType);
|
||||||
|
|
||||||
var program = ProgramStatusFeedbackCollection[sender.Number];
|
var program = ProgramStatusFeedbackCollection[sender.Number];
|
||||||
|
|
||||||
@@ -400,7 +404,7 @@ namespace PepperDash.Essentials.Core.Monitoring
|
|||||||
/// <param name="args"></param>
|
/// <param name="args"></param>
|
||||||
private void TimeZoneInformation_TimeZoneChange(TimeZoneEventArgs args)
|
private void TimeZoneInformation_TimeZoneChange(TimeZoneEventArgs args)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "Time Zone Change Detected.");
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Time Zone Change Detected.");
|
||||||
TimeZoneFeedback.FireUpdate();
|
TimeZoneFeedback.FireUpdate();
|
||||||
TimeZoneTextFeedback.FireUpdate();
|
TimeZoneTextFeedback.FireUpdate();
|
||||||
|
|
||||||
@@ -425,28 +429,28 @@ namespace PepperDash.Essentials.Core.Monitoring
|
|||||||
|
|
||||||
public EthernetStatusFeedbacks(short adapterIndex)
|
public EthernetStatusFeedbacks(short adapterIndex)
|
||||||
{
|
{
|
||||||
Debug.Console(2, "Ethernet Information for interface {0}", adapterIndex);
|
Debug.LogMessage(LogEventLevel.Verbose, "Ethernet Information for interface {0}", adapterIndex);
|
||||||
Debug.Console(2, "Adapter Index: {1} Hostname: {0}", CrestronEthernetHelper.GetEthernetParameter(
|
Debug.LogMessage(LogEventLevel.Verbose, "Adapter Index: {1} Hostname: {0}", CrestronEthernetHelper.GetEthernetParameter(
|
||||||
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME, adapterIndex), adapterIndex);
|
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME, adapterIndex), adapterIndex);
|
||||||
Debug.Console(2, "Adapter Index: {1} Current IP Address: {0}", CrestronEthernetHelper.GetEthernetParameter(
|
Debug.LogMessage(LogEventLevel.Verbose, "Adapter Index: {1} Current IP Address: {0}", CrestronEthernetHelper.GetEthernetParameter(
|
||||||
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, adapterIndex), adapterIndex);
|
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, adapterIndex), adapterIndex);
|
||||||
Debug.Console(2, "Adapter Index: {1} Current Subnet Mask: {0}", CrestronEthernetHelper.GetEthernetParameter(
|
Debug.LogMessage(LogEventLevel.Verbose, "Adapter Index: {1} Current Subnet Mask: {0}", CrestronEthernetHelper.GetEthernetParameter(
|
||||||
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, adapterIndex), adapterIndex);
|
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, adapterIndex), adapterIndex);
|
||||||
Debug.Console(2, "Adapter Index: {1} Current Router: {0}", CrestronEthernetHelper.GetEthernetParameter(
|
Debug.LogMessage(LogEventLevel.Verbose, "Adapter Index: {1} Current Router: {0}", CrestronEthernetHelper.GetEthernetParameter(
|
||||||
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_ROUTER, adapterIndex), adapterIndex);
|
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_ROUTER, adapterIndex), adapterIndex);
|
||||||
Debug.Console(2, "Adapter Index: {1} Static IP Address: {0}", CrestronEthernetHelper.GetEthernetParameter(
|
Debug.LogMessage(LogEventLevel.Verbose, "Adapter Index: {1} Static IP Address: {0}", CrestronEthernetHelper.GetEthernetParameter(
|
||||||
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_STATIC_IPADDRESS, adapterIndex), adapterIndex);
|
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_STATIC_IPADDRESS, adapterIndex), adapterIndex);
|
||||||
Debug.Console(2, "Adapter Index: {1} Static Subnet Mask: {0}", CrestronEthernetHelper.GetEthernetParameter(
|
Debug.LogMessage(LogEventLevel.Verbose, "Adapter Index: {1} Static Subnet Mask: {0}", CrestronEthernetHelper.GetEthernetParameter(
|
||||||
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_STATIC_IPMASK, adapterIndex), adapterIndex);
|
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_STATIC_IPMASK, adapterIndex), adapterIndex);
|
||||||
Debug.Console(2, "Adapter Index: {1} Static Router: {0}", CrestronEthernetHelper.GetEthernetParameter(
|
Debug.LogMessage(LogEventLevel.Verbose, "Adapter Index: {1} Static Router: {0}", CrestronEthernetHelper.GetEthernetParameter(
|
||||||
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_STATIC_ROUTER, adapterIndex), adapterIndex);
|
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_STATIC_ROUTER, adapterIndex), adapterIndex);
|
||||||
Debug.Console(2, "Adapter Index: {1} DNS Servers: {0}", CrestronEthernetHelper.GetEthernetParameter(
|
Debug.LogMessage(LogEventLevel.Verbose, "Adapter Index: {1} DNS Servers: {0}", CrestronEthernetHelper.GetEthernetParameter(
|
||||||
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DNS_SERVER, adapterIndex), adapterIndex);
|
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DNS_SERVER, adapterIndex), adapterIndex);
|
||||||
Debug.Console(2, "Adapter Index: {1} DHCP State: {0}", CrestronEthernetHelper.GetEthernetParameter(
|
Debug.LogMessage(LogEventLevel.Verbose, "Adapter Index: {1} DHCP State: {0}", CrestronEthernetHelper.GetEthernetParameter(
|
||||||
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_DHCP_STATE, adapterIndex), adapterIndex);
|
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_DHCP_STATE, adapterIndex), adapterIndex);
|
||||||
Debug.Console(2, "Adapter Index: {1} Domain Name: {0}", CrestronEthernetHelper.GetEthernetParameter(
|
Debug.LogMessage(LogEventLevel.Verbose, "Adapter Index: {1} Domain Name: {0}", CrestronEthernetHelper.GetEthernetParameter(
|
||||||
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DOMAIN_NAME, adapterIndex), adapterIndex);
|
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DOMAIN_NAME, adapterIndex), adapterIndex);
|
||||||
Debug.Console(2, "Adapter Index: {1} MAC Address: {0}", CrestronEthernetHelper.GetEthernetParameter(
|
Debug.LogMessage(LogEventLevel.Verbose, "Adapter Index: {1} MAC Address: {0}", CrestronEthernetHelper.GetEthernetParameter(
|
||||||
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS, adapterIndex), adapterIndex);
|
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS, adapterIndex), adapterIndex);
|
||||||
HostNameFeedback =
|
HostNameFeedback =
|
||||||
new StringFeedback(
|
new StringFeedback(
|
||||||
@@ -585,13 +589,13 @@ namespace PepperDash.Essentials.Core.Monitoring
|
|||||||
|
|
||||||
private void GetProgramInfo(object o)
|
private void GetProgramInfo(object o)
|
||||||
{
|
{
|
||||||
Debug.Console(2, "Attempting to get program info for slot: {0}", Program.Number);
|
Debug.LogMessage(LogEventLevel.Verbose, "Attempting to get program info for slot: {0}", Program.Number);
|
||||||
|
|
||||||
string response = null;
|
string response = null;
|
||||||
|
|
||||||
if (Program.RegistrationState == eProgramRegistrationState.Unregister || Program.OperatingState == eProgramOperatingState.Stop)
|
if (Program.RegistrationState == eProgramRegistrationState.Unregister || Program.OperatingState == eProgramOperatingState.Stop)
|
||||||
{
|
{
|
||||||
Debug.Console(2, "Program {0} not registered. Setting default values for program information.",
|
Debug.LogMessage(LogEventLevel.Verbose, "Program {0} not registered. Setting default values for program information.",
|
||||||
Program.Number);
|
Program.Number);
|
||||||
|
|
||||||
ProgramInfo = new ProgramInfo(Program.Number)
|
ProgramInfo = new ProgramInfo(Program.Number)
|
||||||
@@ -608,14 +612,14 @@ namespace PepperDash.Essentials.Core.Monitoring
|
|||||||
|
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
Debug.Console(2, "Progcomments Attempt Unsuccessful for slot: {0}", Program.Number);
|
Debug.LogMessage(LogEventLevel.Verbose, "Progcomments Attempt Unsuccessful for slot: {0}", Program.Number);
|
||||||
UpdateFeedbacks();
|
UpdateFeedbacks();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.ToLower().Contains("bad or incomplete"))
|
if (response.ToLower().Contains("bad or incomplete"))
|
||||||
{
|
{
|
||||||
Debug.Console(2,
|
Debug.LogMessage(LogEventLevel.Verbose,
|
||||||
"Program in slot {0} not running. Setting default ProgramInfo for slot: {0}",
|
"Program in slot {0} not running. Setting default ProgramInfo for slot: {0}",
|
||||||
Program.Number);
|
Program.Number);
|
||||||
|
|
||||||
@@ -665,7 +669,7 @@ namespace PepperDash.Essentials.Core.Monitoring
|
|||||||
ProgramInfo.Environment = ParseConsoleData(response, "Source Env", ": ", "\n");
|
ProgramInfo.Environment = ParseConsoleData(response, "Source Env", ": ", "\n");
|
||||||
ProgramInfo.Programmer = ParseConsoleData(response, "Programmer", ": ", "\n");
|
ProgramInfo.Programmer = ParseConsoleData(response, "Programmer", ": ", "\n");
|
||||||
}
|
}
|
||||||
Debug.Console(2, "Program info for slot {0} successfully updated", Program.Number);
|
Debug.LogMessage(LogEventLevel.Verbose, "Program info for slot {0} successfully updated", Program.Number);
|
||||||
|
|
||||||
UpdateFeedbacks();
|
UpdateFeedbacks();
|
||||||
}
|
}
|
||||||
@@ -684,7 +688,7 @@ namespace PepperDash.Essentials.Core.Monitoring
|
|||||||
|
|
||||||
public void OnProgramInfoChanged()
|
public void OnProgramInfoChanged()
|
||||||
{
|
{
|
||||||
//Debug.Console(1, "Firing ProgramInfoChanged for slot: {0}", Program.Number);
|
//Debug.LogMessage(LogEventLevel.Debug, "Firing ProgramInfoChanged for slot: {0}", Program.Number);
|
||||||
var handler = ProgramInfoChanged;
|
var handler = ProgramInfoChanged;
|
||||||
if (handler != null)
|
if (handler != null)
|
||||||
{
|
{
|
||||||
@@ -698,19 +702,25 @@ namespace PepperDash.Essentials.Core.Monitoring
|
|||||||
|
|
||||||
if (data.Length <= 0) return outputData;
|
if (data.Length <= 0) return outputData;
|
||||||
|
|
||||||
|
if (!data.Contains(line))
|
||||||
|
{
|
||||||
|
return outputData;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//Debug.Console(2, "ParseConsoleData Data: {0}, Line {1}, startStirng {2}, endString {3}", data, line, startString, endString);
|
//Debug.LogMessage(LogEventLevel.Verbose, "ParseConsoleData Data: {0}, Line {1}, startStirng {2}, endString {3}", data, line, startString, endString);
|
||||||
var linePosition = data.IndexOf(line, StringComparison.Ordinal);
|
var linePosition = data.IndexOf(line, StringComparison.Ordinal);
|
||||||
var startPosition = data.IndexOf(startString, linePosition, StringComparison.Ordinal) +
|
var startPosition = data.IndexOf(startString, linePosition, StringComparison.Ordinal) +
|
||||||
startString.Length;
|
startString.Length;
|
||||||
var endPosition = data.IndexOf(endString, startPosition, StringComparison.Ordinal);
|
var endPosition = data.IndexOf(endString, startPosition, StringComparison.Ordinal);
|
||||||
outputData = data.Substring(startPosition, endPosition - startPosition).Trim();
|
outputData = data.Substring(startPosition, endPosition - startPosition).Trim();
|
||||||
//Debug.Console(2, "ParseConsoleData Return: {0}", outputData);
|
//Debug.LogMessage(LogEventLevel.Verbose, "ParseConsoleData Return: {0}", outputData);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Error Parsing Console Data:\r{0}", e);
|
Debug.LogMessage(LogEventLevel.Error, "Error Parsing Console Data: {0}", e);
|
||||||
|
Debug.LogMessage(LogEventLevel.Verbose, "Stack Trace: {stackTrace}", e.StackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
return outputData;
|
return outputData;
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
using System;
|
using PepperDash.Core;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
@@ -17,9 +14,36 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
private IPartitionStateProvider _partitionSensor;
|
private IPartitionStateProvider _partitionSensor;
|
||||||
|
|
||||||
private bool isInAutoMode;
|
public bool IsInAutoMode { get; private set; }
|
||||||
|
|
||||||
private bool partitionPresent;
|
private bool _partitionPresent;
|
||||||
|
|
||||||
|
public bool PartitionPresent
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (IsInAutoMode)
|
||||||
|
{
|
||||||
|
return _partitionSensor.PartitionPresentFeedback.BoolValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _partitionPresent;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_partitionPresent == value)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_partitionPresent = value;
|
||||||
|
|
||||||
|
if (PartitionPresentFeedback != null)
|
||||||
|
{
|
||||||
|
PartitionPresentFeedback.FireUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public EssentialsPartitionController(string key, string name, IPartitionStateProvider sensor, bool defaultToManualMode, List<string> adjacentRoomKeys)
|
public EssentialsPartitionController(string key, string name, IPartitionStateProvider sensor, bool defaultToManualMode, List<string> adjacentRoomKeys)
|
||||||
{
|
{
|
||||||
@@ -50,11 +74,11 @@ namespace PepperDash.Essentials.Core
|
|||||||
PartitionPresentFeedback.FireUpdate();
|
PartitionPresentFeedback.FireUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartitionPresentFeedback_OutputChange(object sender, FeedbackEventArgs e)
|
private void PartitionPresentFeedback_OutputChange(object sender, FeedbackEventArgs e)
|
||||||
{
|
{
|
||||||
if (isInAutoMode)
|
if (IsInAutoMode)
|
||||||
{
|
{
|
||||||
PartitionPresentFeedback.FireUpdate();
|
PartitionPresent = e.BoolValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +88,9 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
public void SetAutoMode()
|
public void SetAutoMode()
|
||||||
{
|
{
|
||||||
isInAutoMode = true;
|
Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, $"Setting {Key} to Auto Mode", this);
|
||||||
|
|
||||||
|
IsInAutoMode = true;
|
||||||
if (PartitionPresentFeedback != null)
|
if (PartitionPresentFeedback != null)
|
||||||
{
|
{
|
||||||
PartitionPresentFeedback.SetValueFunc(() => _partitionSensor.PartitionPresentFeedback.BoolValue);
|
PartitionPresentFeedback.SetValueFunc(() => _partitionSensor.PartitionPresentFeedback.BoolValue);
|
||||||
@@ -76,52 +102,64 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
if (_partitionSensor != null)
|
if (_partitionSensor != null)
|
||||||
{
|
{
|
||||||
|
_partitionSensor.PartitionPresentFeedback.OutputChange -= PartitionPresentFeedback_OutputChange;
|
||||||
_partitionSensor.PartitionPresentFeedback.OutputChange += PartitionPresentFeedback_OutputChange;
|
_partitionSensor.PartitionPresentFeedback.OutputChange += PartitionPresentFeedback_OutputChange;
|
||||||
|
PartitionPresent = _partitionSensor.PartitionPresentFeedback.BoolValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PartitionPresentFeedback.FireUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetManualMode()
|
public void SetManualMode()
|
||||||
{
|
{
|
||||||
isInAutoMode = false;
|
Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, $"Setting {Key} to Manual Mode", this);
|
||||||
|
|
||||||
|
IsInAutoMode = false;
|
||||||
if (PartitionPresentFeedback != null)
|
if (PartitionPresentFeedback != null)
|
||||||
{
|
{
|
||||||
PartitionPresentFeedback.SetValueFunc(() => partitionPresent);
|
PartitionPresentFeedback.SetValueFunc(() => _partitionPresent);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PartitionPresentFeedback = new BoolFeedback(() => partitionPresent);
|
PartitionPresentFeedback = new BoolFeedback(() => _partitionPresent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_partitionSensor != null)
|
if (_partitionSensor != null)
|
||||||
{
|
{
|
||||||
_partitionSensor.PartitionPresentFeedback.OutputChange -= PartitionPresentFeedback_OutputChange;
|
_partitionSensor.PartitionPresentFeedback.OutputChange -= PartitionPresentFeedback_OutputChange;
|
||||||
|
PartitionPresent = _partitionSensor.PartitionPresentFeedback.BoolValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PartitionPresentFeedback.FireUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void SetPartitionStatePresent()
|
public void SetPartitionStatePresent()
|
||||||
{
|
{
|
||||||
if (!isInAutoMode)
|
if (!IsInAutoMode)
|
||||||
{
|
{
|
||||||
partitionPresent = true;
|
PartitionPresent = true;
|
||||||
PartitionPresentFeedback.FireUpdate();
|
PartitionPresentFeedback.FireUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPartitionStateNotPresent()
|
public void SetPartitionStateNotPresent()
|
||||||
{
|
{
|
||||||
if (!isInAutoMode)
|
if (!IsInAutoMode)
|
||||||
{
|
{
|
||||||
partitionPresent = false;
|
PartitionPresent = false;
|
||||||
PartitionPresentFeedback.FireUpdate();
|
PartitionPresentFeedback.FireUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ToggglePartitionState()
|
public void ToggglePartitionState()
|
||||||
{
|
{
|
||||||
if (!isInAutoMode)
|
Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, $"Toggling Partition State for {Key}", this);
|
||||||
|
Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, $"IsInAutoMode: {IsInAutoMode}", this);
|
||||||
|
|
||||||
|
if (!IsInAutoMode)
|
||||||
{
|
{
|
||||||
partitionPresent = !partitionPresent;
|
PartitionPresent = !PartitionPresent;
|
||||||
PartitionPresentFeedback.FireUpdate();
|
PartitionPresentFeedback.FireUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
using Newtonsoft.Json;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
@@ -13,7 +9,11 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IPartitionStateProvider : IKeyName
|
public interface IPartitionStateProvider : IKeyName
|
||||||
{
|
{
|
||||||
|
[JsonIgnore]
|
||||||
BoolFeedback PartitionPresentFeedback { get; }
|
BoolFeedback PartitionPresentFeedback { get; }
|
||||||
|
|
||||||
|
[JsonProperty("partitionPresent")]
|
||||||
|
bool PartitionPresent { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -21,8 +21,12 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IPartitionController : IPartitionStateProvider
|
public interface IPartitionController : IPartitionStateProvider
|
||||||
{
|
{
|
||||||
|
[JsonProperty("adjacentRoomKeys")]
|
||||||
List<string> AdjacentRoomKeys { get; }
|
List<string> AdjacentRoomKeys { get; }
|
||||||
|
|
||||||
|
[JsonProperty("isInAutoMode")]
|
||||||
|
bool IsInAutoMode { get; }
|
||||||
|
|
||||||
void SetPartitionStatePresent();
|
void SetPartitionStatePresent();
|
||||||
|
|
||||||
void SetPartitionStateNotPresent();
|
void SetPartitionStateNotPresent();
|
||||||
|
|||||||
@@ -11,6 +11,9 @@
|
|||||||
<RootNamespace>PepperDash.Essentials.Core</RootNamespace>
|
<RootNamespace>PepperDash.Essentials.Core</RootNamespace>
|
||||||
<Title>PepperDash Essentials Core</Title>
|
<Title>PepperDash Essentials Core</Title>
|
||||||
<PackageId>PepperDash.Essentials.Core</PackageId>
|
<PackageId>PepperDash.Essentials.Core</PackageId>
|
||||||
|
<InformationalVersion>$(Version)</InformationalVersion>
|
||||||
|
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
|
||||||
|
<Version>2.0.0-local</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
@@ -22,8 +25,8 @@
|
|||||||
<DebugType>pdbonly</DebugType>
|
<DebugType>pdbonly</DebugType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Crestron.SimplSharp.SDK.ProgramLibrary" Version="2.20.42" />
|
<PackageReference Include="Crestron.SimplSharp.SDK.ProgramLibrary" Version="2.20.66" />
|
||||||
<PackageReference Include="PepperDashCore" Version="2.0.0-alpha-393" />
|
<PackageReference Include="PepperDashCore" Version="2.0.0-alpha-451" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="Crestron\CrestronGenericBaseDevice.cs.orig" />
|
<None Include="Crestron\CrestronGenericBaseDevice.cs.orig" />
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using Crestron.SimplSharp.CrestronIO;
|
using Crestron.SimplSharp.CrestronIO;
|
||||||
using Crestron.SimplSharp.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
|
using Serilog.Events;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace PepperDash.Essentials
|
namespace PepperDash.Essentials
|
||||||
{
|
{
|
||||||
@@ -26,24 +27,31 @@ namespace PepperDash.Essentials
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
static List<LoadedAssembly> LoadedPluginFolderAssemblies;
|
static List<LoadedAssembly> LoadedPluginFolderAssemblies;
|
||||||
|
|
||||||
|
public static LoadedAssembly EssentialsAssembly { get; private set; }
|
||||||
|
|
||||||
|
public static LoadedAssembly PepperDashCoreAssembly { get; private set; }
|
||||||
|
|
||||||
|
public static List<LoadedAssembly> EssentialsPluginAssemblies { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The directory to look in for .cplz plugin packages
|
/// The directory to look in for .cplz plugin packages
|
||||||
/// </summary>
|
/// </summary>
|
||||||
static string _pluginDirectory = Global.FilePathPrefix + "plugins";
|
static string _pluginDirectory => Global.FilePathPrefix + "plugins";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The directory where plugins will be moved to and loaded from
|
/// The directory where plugins will be moved to and loaded from
|
||||||
/// </summary>
|
/// </summary>
|
||||||
static string _loadedPluginsDirectoryPath = _pluginDirectory + Global.DirectorySeparator + "loadedAssemblies";
|
static string _loadedPluginsDirectoryPath => _pluginDirectory + Global.DirectorySeparator + "loadedAssemblies";
|
||||||
|
|
||||||
// The temp directory where .cplz archives will be unzipped to
|
// The temp directory where .cplz archives will be unzipped to
|
||||||
static string _tempDirectory = _pluginDirectory + Global.DirectorySeparator + "temp";
|
static string _tempDirectory => _pluginDirectory + Global.DirectorySeparator + "temp";
|
||||||
|
|
||||||
|
|
||||||
static PluginLoader()
|
static PluginLoader()
|
||||||
{
|
{
|
||||||
LoadedAssemblies = new List<LoadedAssembly>();
|
LoadedAssemblies = new List<LoadedAssembly>();
|
||||||
LoadedPluginFolderAssemblies = new List<LoadedAssembly>();
|
LoadedPluginFolderAssemblies = new List<LoadedAssembly>();
|
||||||
|
EssentialsPluginAssemblies = new List<LoadedAssembly>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -51,14 +59,14 @@ namespace PepperDash.Essentials
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void AddProgramAssemblies()
|
public static void AddProgramAssemblies()
|
||||||
{
|
{
|
||||||
Debug.Console(2, "Getting Assemblies loaded with Essentials");
|
Debug.LogMessage(LogEventLevel.Verbose, "Getting Assemblies loaded with Essentials");
|
||||||
// Get the loaded assembly filenames
|
// Get the loaded assembly filenames
|
||||||
var appDi = new DirectoryInfo(Global.ApplicationDirectoryPathPrefix);
|
var appDi = new DirectoryInfo(Global.ApplicationDirectoryPathPrefix);
|
||||||
var assemblyFiles = appDi.GetFiles("*.dll");
|
var assemblyFiles = appDi.GetFiles("*.dll");
|
||||||
|
|
||||||
Debug.Console(2, "Found {0} Assemblies", assemblyFiles.Length);
|
Debug.LogMessage(LogEventLevel.Verbose, "Found {0} Assemblies", assemblyFiles.Length);
|
||||||
|
|
||||||
foreach (var fi in assemblyFiles)
|
foreach (var fi in assemblyFiles.Where(fi => fi.Name.Contains("Essentials") || fi.Name.Contains("PepperDash")))
|
||||||
{
|
{
|
||||||
string version = string.Empty;
|
string version = string.Empty;
|
||||||
Assembly assembly = null;
|
Assembly assembly = null;
|
||||||
@@ -68,6 +76,7 @@ namespace PepperDash.Essentials
|
|||||||
case ("PepperDashEssentials.dll"):
|
case ("PepperDashEssentials.dll"):
|
||||||
{
|
{
|
||||||
version = Global.AssemblyVersion;
|
version = Global.AssemblyVersion;
|
||||||
|
EssentialsAssembly = new LoadedAssembly(fi.Name, version, assembly);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ("PepperDash_Essentials_Core.dll"):
|
case ("PepperDash_Essentials_Core.dll"):
|
||||||
@@ -80,9 +89,12 @@ namespace PepperDash.Essentials
|
|||||||
version = Global.AssemblyVersion;
|
version = Global.AssemblyVersion;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ("PepperDash_Core.dll"):
|
case ("PepperDashCore.dll"):
|
||||||
{
|
{
|
||||||
version = PepperDash.Core.Debug.PepperDashCoreVersion;
|
Debug.LogMessage(LogEventLevel.Verbose, "Found PepperDash_Core.dll");
|
||||||
|
version = Debug.PepperDashCoreVersion;
|
||||||
|
Debug.LogMessage(LogEventLevel.Verbose, "PepperDash_Core Version: {0}", version);
|
||||||
|
PepperDashCoreAssembly = new LoadedAssembly(fi.Name, version, assembly);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,11 +104,11 @@ namespace PepperDash.Essentials
|
|||||||
|
|
||||||
if (Debug.Level > 1)
|
if (Debug.Level > 1)
|
||||||
{
|
{
|
||||||
Debug.Console(2, "Loaded Assemblies:");
|
Debug.LogMessage(LogEventLevel.Verbose, "Loaded Assemblies:");
|
||||||
|
|
||||||
foreach (var assembly in LoadedAssemblies)
|
foreach (var assembly in LoadedAssemblies)
|
||||||
{
|
{
|
||||||
Debug.Console(2, "Assembly: {0}", assembly.Name);
|
Debug.LogMessage(LogEventLevel.Verbose, "Assembly: {0}", assembly.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -118,24 +130,31 @@ namespace PepperDash.Essentials
|
|||||||
/// <param name="fileName"></param>
|
/// <param name="fileName"></param>
|
||||||
static LoadedAssembly LoadAssembly(string filePath)
|
static LoadedAssembly LoadAssembly(string filePath)
|
||||||
{
|
{
|
||||||
//Debug.Console(2, "Attempting to load {0}", filePath);
|
try
|
||||||
var assembly = Assembly.LoadFrom(filePath);
|
|
||||||
if (assembly != null)
|
|
||||||
{
|
{
|
||||||
var assyVersion = GetAssemblyVersion(assembly);
|
//Debug.LogMessage(LogEventLevel.Verbose, "Attempting to load {0}", filePath);
|
||||||
|
var assembly = Assembly.LoadFrom(filePath);
|
||||||
|
if (assembly != null)
|
||||||
|
{
|
||||||
|
var assyVersion = GetAssemblyVersion(assembly);
|
||||||
|
|
||||||
var loadedAssembly = new LoadedAssembly(assembly.GetName().Name, assyVersion, assembly);
|
var loadedAssembly = new LoadedAssembly(assembly.GetName().Name, assyVersion, assembly);
|
||||||
LoadedAssemblies.Add(loadedAssembly);
|
LoadedAssemblies.Add(loadedAssembly);
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loaded assembly '{0}', version {1}", loadedAssembly.Name, loadedAssembly.Version);
|
Debug.LogMessage(LogEventLevel.Information, "Loaded assembly '{0}', version {1}", loadedAssembly.Name, loadedAssembly.Version);
|
||||||
return loadedAssembly;
|
return loadedAssembly;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
Debug.LogMessage(LogEventLevel.Information, "Unable to load assembly: '{0}'", filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
} catch(Exception ex)
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Unable to load assembly: '{0}'", filePath);
|
Debug.LogMessage(ex, "Error loading assembly from {path}", null, filePath);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -143,7 +162,7 @@ namespace PepperDash.Essentials
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="assembly"></param>
|
/// <param name="assembly"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
static string GetAssemblyVersion(Assembly assembly)
|
public static string GetAssemblyVersion(Assembly assembly)
|
||||||
{
|
{
|
||||||
var ver = assembly.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false);
|
var ver = assembly.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false);
|
||||||
if (ver != null && ver.Length > 0)
|
if (ver != null && ver.Length > 0)
|
||||||
@@ -168,17 +187,17 @@ namespace PepperDash.Essentials
|
|||||||
/// <returns>True if file already matches loaded assembly file.</returns>
|
/// <returns>True if file already matches loaded assembly file.</returns>
|
||||||
public static bool CheckIfAssemblyLoaded(string name)
|
public static bool CheckIfAssemblyLoaded(string name)
|
||||||
{
|
{
|
||||||
Debug.Console(2, "Checking if assembly: {0} is loaded...", name);
|
Debug.LogMessage(LogEventLevel.Verbose, "Checking if assembly: {0} is loaded...", name);
|
||||||
var loadedAssembly = LoadedAssemblies.FirstOrDefault(s => s.Name.Equals(name));
|
var loadedAssembly = LoadedAssemblies.FirstOrDefault(s => s.Name.Equals(name));
|
||||||
|
|
||||||
if (loadedAssembly != null)
|
if (loadedAssembly != null)
|
||||||
{
|
{
|
||||||
Debug.Console(2, "Assembly already loaded.");
|
Debug.LogMessage(LogEventLevel.Verbose, "Assembly already loaded.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(2, "Assembly not loaded.");
|
Debug.LogMessage(LogEventLevel.Verbose, "Assembly not loaded.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -189,19 +208,26 @@ namespace PepperDash.Essentials
|
|||||||
/// <param name="command"></param>
|
/// <param name="command"></param>
|
||||||
public static void ReportAssemblyVersions(string command)
|
public static void ReportAssemblyVersions(string command)
|
||||||
{
|
{
|
||||||
|
CrestronConsole.ConsoleCommandResponse("Essentials Version: {0}" + CrestronEnvironment.NewLine, Global.AssemblyVersion);
|
||||||
CrestronConsole.ConsoleCommandResponse("Loaded Assemblies:" + CrestronEnvironment.NewLine);
|
CrestronConsole.ConsoleCommandResponse("PepperDash Core Version: {0}" + CrestronEnvironment.NewLine, PepperDashCoreAssembly.Version);
|
||||||
foreach (var assembly in LoadedAssemblies)
|
CrestronConsole.ConsoleCommandResponse("Essentials Plugin Versions:" + CrestronEnvironment.NewLine);
|
||||||
|
foreach (var assembly in EssentialsPluginAssemblies)
|
||||||
{
|
{
|
||||||
CrestronConsole.ConsoleCommandResponse("{0} Version: {1}" + CrestronEnvironment.NewLine, assembly.Name, assembly.Version);
|
CrestronConsole.ConsoleCommandResponse("{0} Version: {1}" + CrestronEnvironment.NewLine, assembly.Name, assembly.Version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//CrestronConsole.ConsoleCommandResponse("Loaded Assemblies:" + CrestronEnvironment.NewLine);
|
||||||
|
//foreach (var assembly in LoadedAssemblies)
|
||||||
|
//{
|
||||||
|
// CrestronConsole.ConsoleCommandResponse("{0} Version: {1}" + CrestronEnvironment.NewLine, assembly.Name, assembly.Version);
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Moves any .dll assemblies not already loaded from the plugins folder to loadedPlugins folder
|
/// Moves any .dll assemblies not already loaded from the plugins folder to loadedPlugins folder
|
||||||
/// </summary>
|
/// </summary>
|
||||||
static void MoveDllAssemblies()
|
static void MoveDllAssemblies()
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Looking for .dll assemblies from plugins folder...");
|
Debug.LogMessage(LogEventLevel.Information, "Looking for .dll assemblies from plugins folder...");
|
||||||
|
|
||||||
var pluginDi = new DirectoryInfo(_pluginDirectory);
|
var pluginDi = new DirectoryInfo(_pluginDirectory);
|
||||||
var pluginFiles = pluginDi.GetFiles("*.dll");
|
var pluginFiles = pluginDi.GetFiles("*.dll");
|
||||||
@@ -218,7 +244,7 @@ namespace PepperDash.Essentials
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Found .dll: {0}", pluginFile.Name);
|
Debug.LogMessage(LogEventLevel.Information, "Found .dll: {0}", pluginFile.Name);
|
||||||
|
|
||||||
if (!CheckIfAssemblyLoaded(pluginFile.Name))
|
if (!CheckIfAssemblyLoaded(pluginFile.Name))
|
||||||
{
|
{
|
||||||
@@ -229,27 +255,27 @@ namespace PepperDash.Essentials
|
|||||||
// Check if there is a previous file in the loadedPlugins directory and delete
|
// Check if there is a previous file in the loadedPlugins directory and delete
|
||||||
if (File.Exists(filePath))
|
if (File.Exists(filePath))
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Found existing file in loadedPlugins: {0} Deleting and moving new file to replace it", filePath);
|
Debug.LogMessage(LogEventLevel.Information, "Found existing file in loadedPlugins: {0} Deleting and moving new file to replace it", filePath);
|
||||||
File.Delete(filePath);
|
File.Delete(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the file
|
// Move the file
|
||||||
File.Move(pluginFile.FullName, filePath);
|
File.Move(pluginFile.FullName, filePath);
|
||||||
Debug.Console(2, "Moved {0} to {1}", pluginFile.FullName, filePath);
|
Debug.LogMessage(LogEventLevel.Verbose, "Moved {0} to {1}", pluginFile.FullName, filePath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Skipping assembly: {0}. There is already an assembly with that name loaded.", pluginFile.FullName);
|
Debug.LogMessage(LogEventLevel.Information, "Skipping assembly: {0}. There is already an assembly with that name loaded.", pluginFile.FullName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(2, "Error with plugin file {0} . Exception: {1}", pluginFile.FullName, e);
|
Debug.LogMessage(LogEventLevel.Verbose, "Error with plugin file {0} . Exception: {1}", pluginFile.FullName, e);
|
||||||
continue; //catching any load issues and continuing. There will be exceptions loading Crestron .dlls from the cplz Probably should do something different here
|
continue; //catching any load issues and continuing. There will be exceptions loading Crestron .dlls from the cplz Probably should do something different here
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(0, "Done with .dll assemblies");
|
Debug.LogMessage(LogEventLevel.Information, "Done with .dll assemblies");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -257,7 +283,7 @@ namespace PepperDash.Essentials
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
static void UnzipAndMoveCplzArchives()
|
static void UnzipAndMoveCplzArchives()
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Looking for .cplz archives from plugins folder...");
|
Debug.LogMessage(LogEventLevel.Information, "Looking for .cplz archives from plugins folder...");
|
||||||
var di = new DirectoryInfo(_pluginDirectory);
|
var di = new DirectoryInfo(_pluginDirectory);
|
||||||
var zFiles = di.GetFiles("*.cplz");
|
var zFiles = di.GetFiles("*.cplz");
|
||||||
|
|
||||||
@@ -274,9 +300,9 @@ namespace PepperDash.Essentials
|
|||||||
Directory.CreateDirectory(_tempDirectory);
|
Directory.CreateDirectory(_tempDirectory);
|
||||||
var tempDi = new DirectoryInfo(_tempDirectory);
|
var tempDi = new DirectoryInfo(_tempDirectory);
|
||||||
|
|
||||||
Debug.Console(0, "Found cplz: {0}. Unzipping into temp plugins directory", zfi.Name);
|
Debug.LogMessage(LogEventLevel.Information, "Found cplz: {0}. Unzipping into temp plugins directory", zfi.Name);
|
||||||
var result = CrestronZIP.Unzip(zfi.FullName, tempDi.FullName);
|
var result = CrestronZIP.Unzip(zfi.FullName, tempDi.FullName);
|
||||||
Debug.Console(0, "UnZip Result: {0}", result.ToString());
|
Debug.LogMessage(LogEventLevel.Information, "UnZip Result: {0}", result.ToString());
|
||||||
|
|
||||||
var tempFiles = tempDi.GetFiles("*.dll");
|
var tempFiles = tempDi.GetFiles("*.dll");
|
||||||
foreach (var tempFile in tempFiles)
|
foreach (var tempFile in tempFiles)
|
||||||
@@ -292,22 +318,22 @@ namespace PepperDash.Essentials
|
|||||||
// Check if there is a previous file in the loadedPlugins directory and delete
|
// Check if there is a previous file in the loadedPlugins directory and delete
|
||||||
if (File.Exists(filePath))
|
if (File.Exists(filePath))
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Found existing file in loadedPlugins: {0} Deleting and moving new file to replace it", filePath);
|
Debug.LogMessage(LogEventLevel.Information, "Found existing file in loadedPlugins: {0} Deleting and moving new file to replace it", filePath);
|
||||||
File.Delete(filePath);
|
File.Delete(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the file
|
// Move the file
|
||||||
File.Move(tempFile.FullName, filePath);
|
File.Move(tempFile.FullName, filePath);
|
||||||
Debug.Console(2, "Moved {0} to {1}", tempFile.FullName, filePath);
|
Debug.LogMessage(LogEventLevel.Verbose, "Moved {0} to {1}", tempFile.FullName, filePath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Skipping assembly: {0}. There is already an assembly with that name loaded.", tempFile.FullName);
|
Debug.LogMessage(LogEventLevel.Information, "Skipping assembly: {0}. There is already an assembly with that name loaded.", tempFile.FullName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(2, "Assembly {0} is not a custom assembly. Exception: {1}", tempFile.FullName, e);
|
Debug.LogMessage(LogEventLevel.Verbose, "Assembly {0} is not a custom assembly. Exception: {1}", tempFile.FullName, e);
|
||||||
continue; //catching any load issues and continuing. There will be exceptions loading Crestron .dlls from the cplz Probably should do something different here
|
continue; //catching any load issues and continuing. There will be exceptions loading Crestron .dlls from the cplz Probably should do something different here
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -317,7 +343,7 @@ namespace PepperDash.Essentials
|
|||||||
zfi.Delete();
|
zfi.Delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(0, "Done with .cplz archives");
|
Debug.LogMessage(LogEventLevel.Information, "Done with .cplz archives");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -325,11 +351,11 @@ namespace PepperDash.Essentials
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
static void LoadPluginAssemblies()
|
static void LoadPluginAssemblies()
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Loading assemblies from loadedPlugins folder...");
|
Debug.LogMessage(LogEventLevel.Information, "Loading assemblies from loadedPlugins folder...");
|
||||||
var pluginDi = new DirectoryInfo(_loadedPluginsDirectoryPath);
|
var pluginDi = new DirectoryInfo(_loadedPluginsDirectoryPath);
|
||||||
var pluginFiles = pluginDi.GetFiles("*.dll");
|
var pluginFiles = pluginDi.GetFiles("*.dll");
|
||||||
|
|
||||||
Debug.Console(2, "Found {0} plugin assemblies to load", pluginFiles.Length);
|
Debug.LogMessage(LogEventLevel.Verbose, "Found {0} plugin assemblies to load", pluginFiles.Length);
|
||||||
|
|
||||||
foreach (var pluginFile in pluginFiles)
|
foreach (var pluginFile in pluginFiles)
|
||||||
{
|
{
|
||||||
@@ -338,7 +364,7 @@ namespace PepperDash.Essentials
|
|||||||
LoadedPluginFolderAssemblies.Add(loadedAssembly);
|
LoadedPluginFolderAssemblies.Add(loadedAssembly);
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(0, "All Plugins Loaded.");
|
Debug.LogMessage(LogEventLevel.Information, "All Plugins Loaded.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -346,24 +372,24 @@ namespace PepperDash.Essentials
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
static void LoadCustomPluginTypes()
|
static void LoadCustomPluginTypes()
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Loading Custom Plugin Types...");
|
Debug.LogMessage(LogEventLevel.Information, "Loading Custom Plugin Types...");
|
||||||
foreach (var loadedAssembly in LoadedPluginFolderAssemblies)
|
foreach (var loadedAssembly in LoadedPluginFolderAssemblies)
|
||||||
{
|
{
|
||||||
// iteratate this assembly's classes, looking for "LoadPlugin()" methods
|
// iteratate this assembly's classes, looking for "LoadPlugin()" methods
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var assy = loadedAssembly.Assembly;
|
var assy = loadedAssembly.Assembly;
|
||||||
CType[] types = {};
|
Type[] types = {};
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
types = assy.GetTypes();
|
types = assy.GetTypes();
|
||||||
Debug.Console(1, $"Got types for assembly {assy.GetName().Name}");
|
Debug.LogMessage(LogEventLevel.Debug, $"Got types for assembly {assy.GetName().Name}");
|
||||||
}
|
}
|
||||||
catch (TypeLoadException e)
|
catch (TypeLoadException e)
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Warning, "Unable to get types for assembly {0}: {1}",
|
Debug.LogMessage(LogEventLevel.Error, "Unable to get types for assembly {0}: {1}",
|
||||||
loadedAssembly.Name, e.Message);
|
loadedAssembly.Name, e.Message);
|
||||||
Debug.Console(2, e.StackTrace);
|
Debug.LogMessage(LogEventLevel.Verbose, e.StackTrace);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -371,34 +397,20 @@ namespace PepperDash.Essentials
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//Debug.Console(0, $"Checking if type {type.Name} is IPluginDeviceFactory");
|
|
||||||
|
|
||||||
//Debug.Console(0, $"{type.Name} is plugin factory: {typeof(IPluginDeviceFactory).IsAssignableFrom(type) && !type.IsAbstract}");
|
|
||||||
|
|
||||||
if (typeof (IPluginDeviceFactory).IsAssignableFrom(type) && !type.IsAbstract)
|
if (typeof (IPluginDeviceFactory).IsAssignableFrom(type) && !type.IsAbstract)
|
||||||
{
|
{
|
||||||
var plugin =
|
var plugin =
|
||||||
(IPluginDeviceFactory) Crestron.SimplSharp.Reflection.Activator.CreateInstance(type);
|
(IPluginDeviceFactory)Activator.CreateInstance(type);
|
||||||
LoadCustomPlugin(plugin, loadedAssembly);
|
LoadCustomPlugin(plugin, loadedAssembly);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
var methods = type.GetMethods(BindingFlags.Public | BindingFlags.Static);
|
|
||||||
var loadPlugin = methods.FirstOrDefault(m => m.Name.Equals("LoadPlugin"));
|
|
||||||
if (loadPlugin != null)
|
|
||||||
{
|
|
||||||
LoadCustomLegacyPlugin(type, loadPlugin, loadedAssembly);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (NotSupportedException e)
|
catch (NotSupportedException)
|
||||||
{
|
{
|
||||||
//this happens for dlls that aren't PD dlls, like ports of Mono classes into S#. Swallowing.
|
//this happens for dlls that aren't PD dlls, like ports of Mono classes into S#. Swallowing.
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(2, "Load Plugin not found. {0}.{2} is not a plugin factory. Exception: {1}",
|
Debug.LogMessage(LogEventLevel.Error, "Load Plugin not found. {0}.{2} is not a plugin factory. Exception: {1}",
|
||||||
loadedAssembly.Name, e.Message, type.Name);
|
loadedAssembly.Name, e.Message, type.Name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -407,15 +419,15 @@ namespace PepperDash.Essentials
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Warning, "Error Loading assembly {0}: {1}",
|
Debug.LogMessage(LogEventLevel.Information, "Error Loading assembly {0}: {1}",
|
||||||
loadedAssembly.Name, e.Message);
|
loadedAssembly.Name, e.Message);
|
||||||
Debug.Console(2, "{0}", e.StackTrace);
|
Debug.LogMessage(LogEventLevel.Verbose, "{0}", e.StackTrace);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// plugin dll will be loaded. Any classes in plugin should have a static constructor
|
// plugin dll will be loaded. Any classes in plugin should have a static constructor
|
||||||
// that registers that class with the Core.DeviceFactory
|
// that registers that class with the Core.DeviceFactory
|
||||||
Debug.Console(0, "Done Loading Custom Plugin Types.");
|
Debug.LogMessage(LogEventLevel.Information, "Done Loading Custom Plugin Types.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -433,18 +445,21 @@ namespace PepperDash.Essentials
|
|||||||
|
|
||||||
if (!passed)
|
if (!passed)
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error,
|
Debug.LogMessage(LogEventLevel.Information,
|
||||||
"\r\n********************\r\n\tPlugin indicates minimum Essentials version {0}. Dependency check failed. Skipping Plugin {1}\r\n********************",
|
"\r\n********************\r\n\tPlugin indicates minimum Essentials version {0}. Dependency check failed. Skipping Plugin {1}\r\n********************",
|
||||||
plugin.MinimumEssentialsFrameworkVersion, loadedAssembly.Name);
|
plugin.MinimumEssentialsFrameworkVersion, loadedAssembly.Name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Passed plugin passed dependency check (required version {0})", plugin.MinimumEssentialsFrameworkVersion);
|
Debug.LogMessage(LogEventLevel.Information, "Passed plugin passed dependency check (required version {0})", plugin.MinimumEssentialsFrameworkVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading plugin: {0}", loadedAssembly.Name);
|
Debug.LogMessage(LogEventLevel.Information, "Loading plugin: {0}", loadedAssembly.Name);
|
||||||
plugin.LoadTypeFactories();
|
plugin.LoadTypeFactories();
|
||||||
|
|
||||||
|
if(!EssentialsPluginAssemblies.Contains(loadedAssembly))
|
||||||
|
EssentialsPluginAssemblies.Add(loadedAssembly);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -452,16 +467,16 @@ namespace PepperDash.Essentials
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="type"></param>
|
/// <param name="type"></param>
|
||||||
/// <param name="loadPlugin"></param>
|
/// <param name="loadPlugin"></param>
|
||||||
static void LoadCustomLegacyPlugin(CType type, MethodInfo loadPlugin, LoadedAssembly loadedAssembly)
|
static void LoadCustomLegacyPlugin(Type type, MethodInfo loadPlugin, LoadedAssembly loadedAssembly)
|
||||||
{
|
{
|
||||||
Debug.Console(2, "LoadPlugin method found in {0}", type.Name);
|
Debug.LogMessage(LogEventLevel.Verbose, "LoadPlugin method found in {0}", type.Name);
|
||||||
|
|
||||||
var fields = type.GetFields(BindingFlags.Public | BindingFlags.Static);
|
var fields = type.GetFields(BindingFlags.Public | BindingFlags.Static);
|
||||||
|
|
||||||
var minimumVersion = fields.FirstOrDefault(p => p.Name.Equals("MinimumEssentialsFrameworkVersion"));
|
var minimumVersion = fields.FirstOrDefault(p => p.Name.Equals("MinimumEssentialsFrameworkVersion"));
|
||||||
if (minimumVersion != null)
|
if (minimumVersion != null)
|
||||||
{
|
{
|
||||||
Debug.Console(2, "MinimumEssentialsFrameworkVersion found");
|
Debug.LogMessage(LogEventLevel.Verbose, "MinimumEssentialsFrameworkVersion found");
|
||||||
|
|
||||||
var minimumVersionString = minimumVersion.GetValue(null) as string;
|
var minimumVersionString = minimumVersion.GetValue(null) as string;
|
||||||
|
|
||||||
@@ -471,25 +486,25 @@ namespace PepperDash.Essentials
|
|||||||
|
|
||||||
if (!passed)
|
if (!passed)
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "Plugin indicates minimum Essentials version {0}. Dependency check failed. Skipping Plugin", minimumVersionString);
|
Debug.LogMessage(LogEventLevel.Information, "Plugin indicates minimum Essentials version {0}. Dependency check failed. Skipping Plugin", minimumVersionString);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Passed plugin passed dependency check (required version {0})", minimumVersionString);
|
Debug.LogMessage(LogEventLevel.Information, "Passed plugin passed dependency check (required version {0})", minimumVersionString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Warning, "MinimumEssentialsFrameworkVersion found but not set. Loading plugin, but your mileage may vary.");
|
Debug.LogMessage(LogEventLevel.Information, "MinimumEssentialsFrameworkVersion found but not set. Loading plugin, but your mileage may vary.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Warning, "MinimumEssentialsFrameworkVersion not found. Loading plugin, but your mileage may vary.");
|
Debug.LogMessage(LogEventLevel.Information, "MinimumEssentialsFrameworkVersion not found. Loading plugin, but your mileage may vary.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading legacy plugin: {0}", loadedAssembly.Name);
|
Debug.LogMessage(LogEventLevel.Information, "Loading legacy plugin: {0}", loadedAssembly.Name);
|
||||||
loadPlugin.Invoke(null, null);
|
loadPlugin.Invoke(null, null);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -499,9 +514,11 @@ namespace PepperDash.Essentials
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void LoadPlugins()
|
public static void LoadPlugins()
|
||||||
{
|
{
|
||||||
|
Debug.LogMessage(LogEventLevel.Information, "Attempting to Load Plugins from {_pluginDirectory}", _pluginDirectory);
|
||||||
|
|
||||||
if (Directory.Exists(_pluginDirectory))
|
if (Directory.Exists(_pluginDirectory))
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Plugins directory found, checking for plugins");
|
Debug.LogMessage(LogEventLevel.Information, "Plugins directory found, checking for plugins");
|
||||||
|
|
||||||
// Deal with any .dll files
|
// Deal with any .dll files
|
||||||
MoveDllAssemblies();
|
MoveDllAssemblies();
|
||||||
@@ -527,8 +544,11 @@ namespace PepperDash.Essentials
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class LoadedAssembly
|
public class LoadedAssembly
|
||||||
{
|
{
|
||||||
|
[JsonProperty("name")]
|
||||||
public string Name { get; private set; }
|
public string Name { get; private set; }
|
||||||
|
[JsonProperty("version")]
|
||||||
public string Version { get; private set; }
|
public string Version { get; private set; }
|
||||||
|
[JsonIgnore]
|
||||||
public Assembly Assembly { get; private set; }
|
public Assembly Assembly { get; private set; }
|
||||||
|
|
||||||
public LoadedAssembly(string name, string version, Assembly assembly)
|
public LoadedAssembly(string name, string version, Assembly assembly)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ using PepperDash.Core;
|
|||||||
|
|
||||||
//using SSMono.IO;
|
//using SSMono.IO;
|
||||||
using PepperDash.Core.WebApi.Presets;
|
using PepperDash.Core.WebApi.Presets;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Presets
|
namespace PepperDash.Essentials.Core.Presets
|
||||||
{
|
{
|
||||||
@@ -62,7 +63,7 @@ namespace PepperDash.Essentials.Core.Presets
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
Debug.Console(0, "DevicePresets '{0}', not attached to INumericKeypad device. Ignoring", key);
|
Debug.LogMessage(LogEventLevel.Information, "DevicePresets '{0}', not attached to INumericKeypad device. Ignoring", key);
|
||||||
_dialFunctions = null;
|
_dialFunctions = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -112,7 +113,7 @@ namespace PepperDash.Essentials.Core.Presets
|
|||||||
{
|
{
|
||||||
_filePath = ListPathPrefix + path;
|
_filePath = ListPathPrefix + path;
|
||||||
|
|
||||||
Debug.Console(2, this, "Setting presets file path to {0}", _filePath);
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Setting presets file path to {0}", _filePath);
|
||||||
LoadChannels();
|
LoadChannels();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,17 +123,19 @@ namespace PepperDash.Essentials.Core.Presets
|
|||||||
{
|
{
|
||||||
_fileOps.Enter();
|
_fileOps.Enter();
|
||||||
|
|
||||||
Debug.Console(2, this, "Loading presets from {0}", _filePath);
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Loading presets from {0}", _filePath);
|
||||||
PresetsAreLoaded = false;
|
PresetsAreLoaded = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var pl = JsonConvert.DeserializeObject<PresetsList>(File.ReadToEnd(_filePath, Encoding.ASCII));
|
var pl = JsonConvert.DeserializeObject<PresetsList>(File.ReadToEnd(_filePath, Encoding.ASCII));
|
||||||
Name = pl.Name;
|
Name = pl.Name;
|
||||||
PresetsList = pl.Channels;
|
PresetsList = pl.Channels;
|
||||||
|
|
||||||
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Loaded {0} presets", PresetsList.Count);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this,
|
Debug.LogMessage(LogEventLevel.Verbose, this,
|
||||||
"LoadChannels: Error reading presets file. These presets will be empty:\r '{0}'\r Error:{1}",
|
"LoadChannels: Error reading presets file. These presets will be empty:\r '{0}'\r Error:{1}",
|
||||||
_filePath, e.Message);
|
_filePath, e.Message);
|
||||||
// Just save a default empty list
|
// Just save a default empty list
|
||||||
@@ -168,7 +171,7 @@ namespace PepperDash.Essentials.Core.Presets
|
|||||||
}
|
}
|
||||||
if (_dialFunctions == null)
|
if (_dialFunctions == null)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "DevicePresets '{0}', not attached to keypad device. Ignoring channel", Key);
|
Debug.LogMessage(LogEventLevel.Debug, "DevicePresets '{0}', not attached to keypad device. Ignoring channel", Key);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using Crestron.SimplSharpPro;
|
|||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Presets
|
namespace PepperDash.Essentials.Core.Presets
|
||||||
@@ -41,7 +42,7 @@ namespace PepperDash.Essentials.Core.Presets
|
|||||||
var chan = View.ShowNumbers ? Channel.Channel : "";
|
var chan = View.ShowNumbers ? Channel.Channel : "";
|
||||||
Owner.StringInputSig(Index, 2).StringValue = chan;
|
Owner.StringInputSig(Index, 2).StringValue = chan;
|
||||||
var url = View.Model.ImagesLocalHostPrefix + View.Model.ImagesPathPrefix + Channel.IconUrl;
|
var url = View.Model.ImagesLocalHostPrefix + View.Model.ImagesPathPrefix + Channel.IconUrl;
|
||||||
Debug.Console(2, "icon url={0}", url);
|
Debug.LogMessage(LogEventLevel.Verbose, "icon url={0}", url);
|
||||||
var icon = View.ShowIcon ? url : "";
|
var icon = View.ShowIcon ? url : "";
|
||||||
Owner.StringInputSig(Index, 3).StringValue = icon;
|
Owner.StringInputSig(Index, 3).StringValue = icon;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System.Collections.Concurrent;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
|
using Serilog.Events;
|
||||||
using Thread = Crestron.SimplSharpPro.CrestronThread.Thread;
|
using Thread = Crestron.SimplSharpPro.CrestronThread.Thread;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Queues
|
namespace PepperDash.Essentials.Core.Queues
|
||||||
@@ -179,7 +180,7 @@ namespace PepperDash.Essentials.Core.Queues
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//Debug.Console(2, this, "Processing queue item: '{0}'", item.ToString());
|
//Debug.LogMessage(LogEventLevel.Verbose, this, "Processing queue item: '{0}'", item.ToString());
|
||||||
item.Dispatch();
|
item.Dispatch();
|
||||||
|
|
||||||
if (_delayEnabled)
|
if (_delayEnabled)
|
||||||
@@ -191,13 +192,13 @@ namespace PepperDash.Essentials.Core.Queues
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Caught an exception in the Queue: {1}:{0}", ex.Message, ex);
|
Debug.LogMessage(LogEventLevel.Information, this, "Caught an exception in the Queue: {1}:{0}", ex.Message, ex);
|
||||||
Debug.Console(2, this, Debug.ErrorLogLevel.Error, "Stack Trace: {0}", ex.StackTrace);
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Stack Trace: {0}", ex.StackTrace);
|
||||||
|
|
||||||
if (ex.InnerException != null)
|
if (ex.InnerException != null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, Debug.ErrorLogLevel.Error, "---\r\n{0}", ex.InnerException.Message);
|
Debug.LogMessage(LogEventLevel.Information, this, "---\r\n{0}", ex.InnerException.Message);
|
||||||
Debug.Console(2, this, Debug.ErrorLogLevel.Error, "Stack Trace: {0}", ex.InnerException.StackTrace);
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Stack Trace: {0}", ex.InnerException.StackTrace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -211,7 +212,7 @@ namespace PepperDash.Essentials.Core.Queues
|
|||||||
{
|
{
|
||||||
if (Disposed)
|
if (Disposed)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Queue has been disposed. Enqueuing messages not allowed while program is stopping.");
|
Debug.LogMessage(LogEventLevel.Debug, this, "Queue has been disposed. Enqueuing messages not allowed while program is stopping.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,7 +244,7 @@ namespace PepperDash.Essentials.Core.Queues
|
|||||||
{
|
{
|
||||||
using (_waitHandle)
|
using (_waitHandle)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "Disposing...");
|
Debug.LogMessage(LogEventLevel.Verbose, this, "Disposing...");
|
||||||
_queue.Enqueue(null);
|
_queue.Enqueue(null);
|
||||||
_waitHandle.Set();
|
_waitHandle.Set();
|
||||||
_worker.Join();
|
_worker.Join();
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static double Scale(double input, double inMin, double inMax, double outMin, double outMax)
|
public static double Scale(double input, double inMin, double inMax, double outMin, double outMax)
|
||||||
{
|
{
|
||||||
//Debug.Console(2, this, "Scaling (double) input '{0}' with min '{1}'/max '{2}' to output range min '{3}'/max '{4}'", input, inMin, inMax, outMin, outMax);
|
//Debug.LogMessage(LogEventLevel.Verbose, this, "Scaling (double) input '{0}' with min '{1}'/max '{2}' to output range min '{3}'/max '{4}'", input, inMin, inMax, outMin, outMax);
|
||||||
|
|
||||||
double inputRange = inMax - inMin;
|
double inputRange = inMax - inMin;
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
var output = (((input - inMin) * outputRange) / inputRange) + outMin;
|
var output = (((input - inMin) * outputRange) / inputRange) + outMin;
|
||||||
|
|
||||||
// Debug.Console(2, this, "Scaled output '{0}'", output);
|
// Debug.LogMessage(LogEventLevel.Verbose, this, "Scaled output '{0}'", output);
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using Crestron.SimplSharp;
|
|||||||
using Crestron.SimplSharpPro;
|
using Crestron.SimplSharpPro;
|
||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
@@ -33,7 +34,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
RepeatDelay = repeatDelay;
|
RepeatDelay = repeatDelay;
|
||||||
RepeatTime = repeatTime;
|
RepeatTime = repeatTime;
|
||||||
if (SignedMode && (MinValue < -32768 || MaxValue > 32767))
|
if (SignedMode && (MinValue < -32768 || MaxValue > 32767))
|
||||||
Debug.Console(1, "UshortSigIncrementer has signed values that exceed range of -32768, 32767");
|
Debug.LogMessage(LogEventLevel.Debug, "UshortSigIncrementer has signed values that exceed range of -32768, 32767");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StartUp()
|
public void StartUp()
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ using PepperDash.Core;
|
|||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
using PepperDash.Essentials.Core.Devices;
|
using PepperDash.Essentials.Core.Devices;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
@@ -63,14 +64,14 @@ namespace PepperDash.Essentials.Core
|
|||||||
Room.RoomOccupancyIsSet += new EventHandler<EventArgs>(RoomOccupancyIsSet);
|
Room.RoomOccupancyIsSet += new EventHandler<EventArgs>(RoomOccupancyIsSet);
|
||||||
|
|
||||||
else
|
else
|
||||||
Debug.Console(1, this, "Room has no RoomOccupancy object set");
|
Debug.LogMessage(LogEventLevel.Debug, this, "Room has no RoomOccupancy object set");
|
||||||
|
|
||||||
var fusionRoomKey = PropertiesConfig.RoomKey + "-fusion";
|
var fusionRoomKey = PropertiesConfig.RoomKey + "-fusion";
|
||||||
|
|
||||||
FusionRoom = DeviceManager.GetDeviceForKey(fusionRoomKey) as Core.Fusion.EssentialsHuddleSpaceFusionSystemControllerBase;
|
FusionRoom = DeviceManager.GetDeviceForKey(fusionRoomKey) as Core.Fusion.EssentialsHuddleSpaceFusionSystemControllerBase;
|
||||||
|
|
||||||
if (FusionRoom == null)
|
if (FusionRoom == null)
|
||||||
Debug.Console(1, this, "Unable to get Fusion Room from Device Manager with key: {0}", fusionRoomKey);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Unable to get Fusion Room from Device Manager with key: {0}", fusionRoomKey);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,14 +97,14 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
if (FeatureEnabledTime != null)
|
if (FeatureEnabledTime != null)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Enabled Time: {0}", FeatureEnabledTime.ToString());
|
Debug.LogMessage(LogEventLevel.Debug, this, "Enabled Time: {0}", FeatureEnabledTime.ToString());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Debug.Console(1, this, "Unable to parse {0} to DateTime", PropertiesConfig.OccupancyStartTime);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Unable to parse {0} to DateTime", PropertiesConfig.OccupancyStartTime);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Unable to parse OccupancyStartTime property: {0} \n Error: {1}", PropertiesConfig.OccupancyStartTime, e);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Unable to parse OccupancyStartTime property: {0} \n Error: {1}", PropertiesConfig.OccupancyStartTime, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -112,14 +113,14 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
if (FeatureDisabledTime != null)
|
if (FeatureDisabledTime != null)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Disabled Time: {0}", FeatureDisabledTime.ToString());
|
Debug.LogMessage(LogEventLevel.Debug, this, "Disabled Time: {0}", FeatureDisabledTime.ToString());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Debug.Console(1, this, "Unable to parse {0} to DateTime", PropertiesConfig.OccupancyEndTime);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Unable to parse {0} to DateTime", PropertiesConfig.OccupancyEndTime);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Unable to parse a DateTime config value \n Error: {1}", e);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Unable to parse a DateTime config value \n Error: {1}", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PropertiesConfig.EnableRoomOnWhenOccupied)
|
if (!PropertiesConfig.EnableRoomOnWhenOccupied)
|
||||||
@@ -138,7 +139,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
FeatureEnabled = CheckIfFeatureShouldBeEnabled();
|
FeatureEnabled = CheckIfFeatureShouldBeEnabled();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Debug.Console(1, this, "Unable to get room from Device Manager with key: {0}", PropertiesConfig.RoomKey);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Unable to get room from Device Manager with key: {0}", PropertiesConfig.RoomKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -165,13 +166,13 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
Room.RoomOccupancy.RoomIsOccupiedFeedback.OutputChange -= RoomIsOccupiedFeedback_OutputChange;
|
Room.RoomOccupancy.RoomIsOccupiedFeedback.OutputChange -= RoomIsOccupiedFeedback_OutputChange;
|
||||||
Room.RoomOccupancy.RoomIsOccupiedFeedback.OutputChange += new EventHandler<FeedbackEventArgs>(RoomIsOccupiedFeedback_OutputChange);
|
Room.RoomOccupancy.RoomIsOccupiedFeedback.OutputChange += new EventHandler<FeedbackEventArgs>(RoomIsOccupiedFeedback_OutputChange);
|
||||||
Debug.Console(1, this, "Subscribed to RoomOccupancy status from: '{0}'", Room.Key);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Subscribed to RoomOccupancy status from: '{0}'", Room.Key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeatureEventGroup_UserGroupCallBack(ScheduledEvent SchEvent, ScheduledEventCommon.eCallbackReason type)
|
void FeatureEventGroup_UserGroupCallBack(ScheduledEvent SchEvent, ScheduledEventCommon.eCallbackReason type)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "{0}:{1} @ {2}", SchEvent.Name, type, DateTime.Now);
|
Debug.LogMessage(LogEventLevel.Debug, this, "{0}:{1} @ {2}", SchEvent.Name, type, DateTime.Now);
|
||||||
|
|
||||||
if (type == ScheduledEventCommon.eCallbackReason.NormalExpiration)
|
if (type == ScheduledEventCommon.eCallbackReason.NormalExpiration)
|
||||||
{
|
{
|
||||||
@@ -183,13 +184,13 @@ namespace PepperDash.Essentials.Core
|
|||||||
if (PropertiesConfig.EnableRoomOnWhenOccupied)
|
if (PropertiesConfig.EnableRoomOnWhenOccupied)
|
||||||
FeatureEnabled = true;
|
FeatureEnabled = true;
|
||||||
|
|
||||||
Debug.Console(1, this, "*****Feature Enabled by event.*****");
|
Debug.LogMessage(LogEventLevel.Debug, this, "*****Feature Enabled by event.*****");
|
||||||
}
|
}
|
||||||
else if (SchEvent.Name == FeatureDisableEventName)
|
else if (SchEvent.Name == FeatureDisableEventName)
|
||||||
{
|
{
|
||||||
FeatureEnabled = false;
|
FeatureEnabled = false;
|
||||||
|
|
||||||
Debug.Console(1, this, "*****Feature Disabled by event.*****");
|
Debug.LogMessage(LogEventLevel.Debug, this, "*****Feature Disabled by event.*****");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -204,7 +205,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
if(PropertiesConfig.EnableRoomOnWhenOccupied)
|
if(PropertiesConfig.EnableRoomOnWhenOccupied)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Current Time: {0} \n FeatureEnabledTime: {1} \n FeatureDisabledTime: {2}", DateTime.Now, FeatureEnabledTime, FeatureDisabledTime);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Current Time: {0} \n FeatureEnabledTime: {1} \n FeatureDisabledTime: {2}", DateTime.Now, FeatureEnabledTime, FeatureDisabledTime);
|
||||||
|
|
||||||
if (DateTime.Now.TimeOfDay.CompareTo(FeatureEnabledTime.TimeOfDay) >= 0 && FeatureDisabledTime.TimeOfDay.CompareTo(DateTime.Now.TimeOfDay) > 0)
|
if (DateTime.Now.TimeOfDay.CompareTo(FeatureEnabledTime.TimeOfDay) >= 0 && FeatureDisabledTime.TimeOfDay.CompareTo(DateTime.Now.TimeOfDay) > 0)
|
||||||
{
|
{
|
||||||
@@ -216,9 +217,9 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(enabled)
|
if(enabled)
|
||||||
Debug.Console(1, this, "*****Feature Enabled*****");
|
Debug.LogMessage(LogEventLevel.Debug, this, "*****Feature Enabled*****");
|
||||||
else
|
else
|
||||||
Debug.Console(1, this, "*****Feature Disabled*****");
|
Debug.LogMessage(LogEventLevel.Debug, this, "*****Feature Disabled*****");
|
||||||
|
|
||||||
return enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
@@ -230,7 +231,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
void RoomIsOccupiedFeedback_OutputChange(object sender, FeedbackEventArgs e)
|
void RoomIsOccupiedFeedback_OutputChange(object sender, FeedbackEventArgs e)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "RoomIsOccupiedFeeback.OutputChange event fired. e.BoolValue: {0}", e.BoolValue);
|
Debug.LogMessage(LogEventLevel.Debug, this, "RoomIsOccupiedFeeback.OutputChange event fired. e.BoolValue: {0}", e.BoolValue);
|
||||||
if(e.BoolValue)
|
if(e.BoolValue)
|
||||||
{
|
{
|
||||||
// Occupancy detected
|
// Occupancy detected
|
||||||
@@ -242,7 +243,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
if (essentialsRoom != null) {
|
if (essentialsRoom != null) {
|
||||||
if (!essentialsRoom.OnFeedback.BoolValue)
|
if (!essentialsRoom.OnFeedback.BoolValue)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Powering Room on to default source");
|
Debug.LogMessage(LogEventLevel.Debug, this, "Powering Room on to default source");
|
||||||
|
|
||||||
var defaultRouteRoom = Room as IRunDefaultPresentRoute;
|
var defaultRouteRoom = Room as IRunDefaultPresentRoute;
|
||||||
|
|
||||||
@@ -260,7 +261,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
void CreateEvent(ScheduledEvent schEvent, string name)
|
void CreateEvent(ScheduledEvent schEvent, string name)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Adding Event: '{0}'", name);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Adding Event: '{0}'", name);
|
||||||
// Create the event
|
// Create the event
|
||||||
if (schEvent == null)
|
if (schEvent == null)
|
||||||
schEvent = new ScheduledEvent(name, FeatureEventGroup);
|
schEvent = new ScheduledEvent(name, FeatureEventGroup);
|
||||||
@@ -290,19 +291,19 @@ namespace PepperDash.Essentials.Core
|
|||||||
else
|
else
|
||||||
eventTime = FeatureEnabledTime;
|
eventTime = FeatureEnabledTime;
|
||||||
|
|
||||||
Debug.Console(1, this, "eventTime (before recurrence check): {0}", eventTime);
|
Debug.LogMessage(LogEventLevel.Debug, this, "eventTime (before recurrence check): {0}", eventTime);
|
||||||
|
|
||||||
// Check day of week against recurrence days and move date ahead as necessary to avoid throwing an exception by trying to set the event
|
// Check day of week against recurrence days and move date ahead as necessary to avoid throwing an exception by trying to set the event
|
||||||
// start date on a day of the week that doesn't match teh recurrence values
|
// start date on a day of the week that doesn't match teh recurrence values
|
||||||
while(!SchedulerUtilities.CheckIfDayOfWeekMatchesRecurrenceDays(eventTime, eventRecurrennce))
|
while(!SchedulerUtilities.CheckIfDayOfWeekMatchesRecurrenceDays(eventTime, eventRecurrennce))
|
||||||
{
|
{
|
||||||
eventTime = eventTime.AddDays(1);
|
eventTime = eventTime.AddDays(1);
|
||||||
Debug.Console(1, this, "eventTime does not fall on a recurrence weekday. eventTime: {0}", eventTime);
|
Debug.LogMessage(LogEventLevel.Debug, this, "eventTime does not fall on a recurrence weekday. eventTime: {0}", eventTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
schEvent.DateAndTime.SetAbsoluteEventTime(eventTime);
|
schEvent.DateAndTime.SetAbsoluteEventTime(eventTime);
|
||||||
|
|
||||||
Debug.Console(1, this, "Event '{0}' Absolute time set to {1}", schEvent.Name, schEvent.DateAndTime.ToString());
|
Debug.LogMessage(LogEventLevel.Debug, this, "Event '{0}' Absolute time set to {1}", schEvent.Name, schEvent.DateAndTime.ToString());
|
||||||
|
|
||||||
//CalculateAndSetAcknowledgeExpirationTimeout(schEvent, FeatureEnabledTime, FeatureDisabledTime);
|
//CalculateAndSetAcknowledgeExpirationTimeout(schEvent, FeatureEnabledTime, FeatureDisabledTime);
|
||||||
|
|
||||||
@@ -319,7 +320,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
else
|
else
|
||||||
schEvent.DateAndTime.SetAbsoluteEventTime(FeatureDisabledTime);
|
schEvent.DateAndTime.SetAbsoluteEventTime(FeatureDisabledTime);
|
||||||
|
|
||||||
Debug.Console(1, this, "Event '{0}' Absolute time set to {1}", schEvent.Name, schEvent.DateAndTime.ToString());
|
Debug.LogMessage(LogEventLevel.Debug, this, "Event '{0}' Absolute time set to {1}", schEvent.Name, schEvent.DateAndTime.ToString());
|
||||||
|
|
||||||
CalculateAndSetAcknowledgeExpirationTimeout(schEvent, FeatureDisabledTime, FeatureEnabledTime);
|
CalculateAndSetAcknowledgeExpirationTimeout(schEvent, FeatureDisabledTime, FeatureEnabledTime);
|
||||||
|
|
||||||
@@ -329,10 +330,10 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
void CalculateAndSetAcknowledgeExpirationTimeout(ScheduledEvent schEvent, DateTime time1, DateTime time2)
|
void CalculateAndSetAcknowledgeExpirationTimeout(ScheduledEvent schEvent, DateTime time1, DateTime time2)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "time1.Hour = {0}", time1.Hour);
|
Debug.LogMessage(LogEventLevel.Debug, this, "time1.Hour = {0}", time1.Hour);
|
||||||
Debug.Console(1, this, "time2.Hour = {0}", time2.Hour);
|
Debug.LogMessage(LogEventLevel.Debug, this, "time2.Hour = {0}", time2.Hour);
|
||||||
Debug.Console(1, this, "time1.Minute = {0}", time1.Minute);
|
Debug.LogMessage(LogEventLevel.Debug, this, "time1.Minute = {0}", time1.Minute);
|
||||||
Debug.Console(1, this, "time2.Minute = {0}", time2.Minute);
|
Debug.LogMessage(LogEventLevel.Debug, this, "time2.Minute = {0}", time2.Minute);
|
||||||
|
|
||||||
// Calculate the Acknowledge Expiration timer to be the time between the enable and dispable events, less one minute
|
// Calculate the Acknowledge Expiration timer to be the time between the enable and dispable events, less one minute
|
||||||
var ackHours = time2.Hour - time1.Hour;
|
var ackHours = time2.Hour - time1.Hour;
|
||||||
@@ -340,14 +341,14 @@ namespace PepperDash.Essentials.Core
|
|||||||
ackHours = ackHours + 24;
|
ackHours = ackHours + 24;
|
||||||
var ackMinutes = time2.Minute - time1.Minute;
|
var ackMinutes = time2.Minute - time1.Minute;
|
||||||
|
|
||||||
Debug.Console(1, this, "ackHours = {0}, ackMinutes = {1}", ackHours, ackMinutes);
|
Debug.LogMessage(LogEventLevel.Debug, this, "ackHours = {0}, ackMinutes = {1}", ackHours, ackMinutes);
|
||||||
|
|
||||||
var ackTotalMinutes = ((ackHours * 60) + ackMinutes) - 1;
|
var ackTotalMinutes = ((ackHours * 60) + ackMinutes) - 1;
|
||||||
|
|
||||||
var ackExpHour = ackTotalMinutes / 60;
|
var ackExpHour = ackTotalMinutes / 60;
|
||||||
var ackExpMinutes = ackTotalMinutes % 60;
|
var ackExpMinutes = ackTotalMinutes % 60;
|
||||||
|
|
||||||
Debug.Console(1, this, "Acknowledge Expiration Timeout: {0} hours, {1} minutes", ackExpHour, ackExpMinutes);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Acknowledge Expiration Timeout: {0} hours, {1} minutes", ackExpHour, ackExpMinutes);
|
||||||
|
|
||||||
schEvent.AcknowledgeExpirationTimeout.Hour = (ushort)(ackHours);
|
schEvent.AcknowledgeExpirationTimeout.Hour = (ushort)(ackHours);
|
||||||
schEvent.AcknowledgeExpirationTimeout.Minute = (ushort)(ackExpMinutes);
|
schEvent.AcknowledgeExpirationTimeout.Minute = (ushort)(ackExpMinutes);
|
||||||
@@ -401,12 +402,12 @@ namespace PepperDash.Essentials.Core
|
|||||||
// Check if existing event has same time and recurrence as config values
|
// Check if existing event has same time and recurrence as config values
|
||||||
|
|
||||||
FeatureEnableEvent = FeatureEventGroup.ScheduledEvents[FeatureEnableEventName];
|
FeatureEnableEvent = FeatureEventGroup.ScheduledEvents[FeatureEnableEventName];
|
||||||
Debug.Console(1, this, "Enable event already found in group");
|
Debug.LogMessage(LogEventLevel.Debug, this, "Enable event already found in group");
|
||||||
|
|
||||||
// Check config times and days against DateAndTime of existing event. If different, delete existing event and create new event
|
// Check config times and days against DateAndTime of existing event. If different, delete existing event and create new event
|
||||||
if(!CheckExistingEventTimeForMatch(FeatureEnableEvent, FeatureEnabledTime) || !CheckExistingEventRecurrenceForMatch(FeatureEnableEvent, CalculateDaysOfWeekRecurrence()))
|
if(!CheckExistingEventTimeForMatch(FeatureEnableEvent, FeatureEnabledTime) || !CheckExistingEventRecurrenceForMatch(FeatureEnableEvent, CalculateDaysOfWeekRecurrence()))
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Existing event does not match new config properties. Deleting exisiting event: '{0}'", FeatureEnableEvent.Name);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Existing event does not match new config properties. Deleting exisiting event: '{0}'", FeatureEnableEvent.Name);
|
||||||
FeatureEventGroup.DeleteEvent(FeatureEnableEvent);
|
FeatureEventGroup.DeleteEvent(FeatureEnableEvent);
|
||||||
|
|
||||||
FeatureEnableEvent = null;
|
FeatureEnableEvent = null;
|
||||||
@@ -429,12 +430,12 @@ namespace PepperDash.Essentials.Core
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
FeatureDisableEvent = FeatureEventGroup.ScheduledEvents[FeatureDisableEventName];
|
FeatureDisableEvent = FeatureEventGroup.ScheduledEvents[FeatureDisableEventName];
|
||||||
Debug.Console(1, this, "Disable event already found in group");
|
Debug.LogMessage(LogEventLevel.Debug, this, "Disable event already found in group");
|
||||||
|
|
||||||
// Check config times against DateAndTime of existing event. If different, delete existing event and create new event
|
// Check config times against DateAndTime of existing event. If different, delete existing event and create new event
|
||||||
if(!CheckExistingEventTimeForMatch(FeatureDisableEvent, FeatureDisabledTime))
|
if(!CheckExistingEventTimeForMatch(FeatureDisableEvent, FeatureDisabledTime))
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Existing event does not match new config properties. Deleting exisiting event: '{0}'", FeatureDisableEvent.Name);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Existing event does not match new config properties. Deleting exisiting event: '{0}'", FeatureDisableEvent.Name);
|
||||||
|
|
||||||
FeatureEventGroup.DeleteEvent(FeatureDisableEvent);
|
FeatureEventGroup.DeleteEvent(FeatureDisableEvent);
|
||||||
|
|
||||||
@@ -484,7 +485,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
if(PropertiesConfig.EnableRoomOnWhenOccupied)
|
if(PropertiesConfig.EnableRoomOnWhenOccupied)
|
||||||
FeatureEnabled = true;
|
FeatureEnabled = true;
|
||||||
|
|
||||||
Debug.Console(1, this, "RoomOnToDefaultSourceWhenOccupied Feature Enabled.");
|
Debug.LogMessage(LogEventLevel.Debug, this, "RoomOnToDefaultSourceWhenOccupied Feature Enabled.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -499,7 +500,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
FeatureEnabled = false;
|
FeatureEnabled = false;
|
||||||
|
|
||||||
Debug.Console(1, this, "RoomOnToDefaultSourceWhenOccupied Feature Disabled.");
|
Debug.LogMessage(LogEventLevel.Debug, this, "RoomOnToDefaultSourceWhenOccupied Feature Disabled.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -549,7 +550,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Factory Attempting to create new RoomOnToDefaultSourceWhenOccupied Device");
|
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new RoomOnToDefaultSourceWhenOccupied Device");
|
||||||
return new RoomOnToDefaultSourceWhenOccupied(dc);
|
return new RoomOnToDefaultSourceWhenOccupied(dc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
using System;
|
using Crestron.SimplSharp;
|
||||||
|
using PepperDash.Core;
|
||||||
|
using PepperDash.Core.Logging;
|
||||||
|
using Serilog.Events;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Threading;
|
||||||
using Crestron.SimplSharp;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using PepperDash.Core;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
@@ -16,12 +18,40 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
private List<IEssentialsRoom> _rooms;
|
private List<IEssentialsRoom> _rooms;
|
||||||
|
|
||||||
private bool isInAutoMode;
|
public List<IKeyName> Rooms
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _rooms.Cast<IKeyName>().ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool _isInAutoMode;
|
||||||
|
|
||||||
|
public bool IsInAutoMode
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _isInAutoMode;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == _isInAutoMode)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_isInAutoMode = value;
|
||||||
|
IsInAutoModeFeedback.FireUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private CTimer _scenarioChangeDebounceTimer;
|
private CTimer _scenarioChangeDebounceTimer;
|
||||||
|
|
||||||
private int _scenarioChangeDebounceTimeSeconds = 10; // default to 10s
|
private int _scenarioChangeDebounceTimeSeconds = 10; // default to 10s
|
||||||
|
|
||||||
|
private Mutex _scenarioChange = new Mutex();
|
||||||
|
|
||||||
public EssentialsRoomCombiner(string key, EssentialsRoomCombinerPropertiesConfig props)
|
public EssentialsRoomCombiner(string key, EssentialsRoomCombinerPropertiesConfig props)
|
||||||
: base(key)
|
: base(key)
|
||||||
{
|
{
|
||||||
@@ -35,14 +65,14 @@ namespace PepperDash.Essentials.Core
|
|||||||
_scenarioChangeDebounceTimeSeconds = _propertiesConfig.ScenarioChangeDebounceTimeSeconds;
|
_scenarioChangeDebounceTimeSeconds = _propertiesConfig.ScenarioChangeDebounceTimeSeconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
IsInAutoModeFeedback = new BoolFeedback(() => isInAutoMode);
|
IsInAutoModeFeedback = new BoolFeedback(() => _isInAutoMode);
|
||||||
|
|
||||||
// default to auto mode
|
// default to auto mode
|
||||||
isInAutoMode = true;
|
IsInAutoMode = true;
|
||||||
|
|
||||||
if (_propertiesConfig.defaultToManualMode)
|
if (_propertiesConfig.defaultToManualMode)
|
||||||
{
|
{
|
||||||
isInAutoMode = false;
|
IsInAutoMode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
IsInAutoModeFeedback.FireUpdate();
|
IsInAutoModeFeedback.FireUpdate();
|
||||||
@@ -54,8 +84,16 @@ namespace PepperDash.Essentials.Core
|
|||||||
SetupPartitionStateProviders();
|
SetupPartitionStateProviders();
|
||||||
|
|
||||||
SetRooms();
|
SetRooms();
|
||||||
|
});
|
||||||
|
|
||||||
if (isInAutoMode)
|
|
||||||
|
// Subscribe to the AllDevicesInitialized event
|
||||||
|
// We need to wait until all devices are initialized in case
|
||||||
|
// any actions are dependent on 3rd party devices already being
|
||||||
|
// connected and initialized
|
||||||
|
DeviceManager.AllDevicesInitialized += (o, a) =>
|
||||||
|
{
|
||||||
|
if (IsInAutoMode)
|
||||||
{
|
{
|
||||||
DetermineRoomCombinationScenario();
|
DetermineRoomCombinationScenario();
|
||||||
}
|
}
|
||||||
@@ -63,10 +101,10 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
SetRoomCombinationScenario(_propertiesConfig.defaultScenarioKey);
|
SetRoomCombinationScenario(_propertiesConfig.defaultScenarioKey);
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateScenarios()
|
private void CreateScenarios()
|
||||||
{
|
{
|
||||||
foreach (var scenarioConfig in _propertiesConfig.Scenarios)
|
foreach (var scenarioConfig in _propertiesConfig.Scenarios)
|
||||||
{
|
{
|
||||||
@@ -75,21 +113,29 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetRooms()
|
private void SetRooms()
|
||||||
{
|
{
|
||||||
_rooms = new List<IEssentialsRoom>();
|
_rooms = new List<IEssentialsRoom>();
|
||||||
|
|
||||||
foreach (var roomKey in _propertiesConfig.RoomKeys)
|
foreach (var roomKey in _propertiesConfig.RoomKeys)
|
||||||
{
|
{
|
||||||
var room = DeviceManager.GetDeviceForKey(roomKey) as IEssentialsRoom;
|
var room = DeviceManager.GetDeviceForKey(roomKey);
|
||||||
if (room != null)
|
|
||||||
|
if (DeviceManager.GetDeviceForKey(roomKey) is IEssentialsRoom essentialsRoom)
|
||||||
{
|
{
|
||||||
_rooms.Add(room);
|
_rooms.Add(essentialsRoom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var rooms = DeviceManager.AllDevices.OfType<IEssentialsRoom>().Cast<Device>();
|
||||||
|
|
||||||
|
foreach (var room in rooms)
|
||||||
|
{
|
||||||
|
room.Deactivate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupPartitionStateProviders()
|
private void SetupPartitionStateProviders()
|
||||||
{
|
{
|
||||||
foreach (var pConfig in _propertiesConfig.Partitions)
|
foreach (var pConfig in _propertiesConfig.Partitions)
|
||||||
{
|
{
|
||||||
@@ -103,14 +149,18 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartitionPresentFeedback_OutputChange(object sender, FeedbackEventArgs e)
|
private void PartitionPresentFeedback_OutputChange(object sender, FeedbackEventArgs e)
|
||||||
{
|
{
|
||||||
StartDebounceTimer();
|
StartDebounceTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartDebounceTimer()
|
private void StartDebounceTimer()
|
||||||
{
|
{
|
||||||
var time = _scenarioChangeDebounceTimeSeconds * 1000;
|
// default to 500ms for manual mode
|
||||||
|
var time = 500;
|
||||||
|
|
||||||
|
// if in auto mode, debounce the scenario change
|
||||||
|
if (IsInAutoMode) time = _scenarioChangeDebounceTimeSeconds * 1000;
|
||||||
|
|
||||||
if (_scenarioChangeDebounceTimer == null)
|
if (_scenarioChangeDebounceTimer == null)
|
||||||
{
|
{
|
||||||
@@ -125,7 +175,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines the current room combination scenario based on the state of the partition sensors
|
/// Determines the current room combination scenario based on the state of the partition sensors
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void DetermineRoomCombinationScenario()
|
private void DetermineRoomCombinationScenario()
|
||||||
{
|
{
|
||||||
if (_scenarioChangeDebounceTimer != null)
|
if (_scenarioChangeDebounceTimer != null)
|
||||||
{
|
{
|
||||||
@@ -133,14 +183,20 @@ namespace PepperDash.Essentials.Core
|
|||||||
_scenarioChangeDebounceTimer = null;
|
_scenarioChangeDebounceTimer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.LogInformation("Determining Combination Scenario");
|
||||||
|
|
||||||
var currentScenario = RoomCombinationScenarios.FirstOrDefault((s) =>
|
var currentScenario = RoomCombinationScenarios.FirstOrDefault((s) =>
|
||||||
{
|
{
|
||||||
|
this.LogDebug("Checking scenario {scenarioKey}", s.Key);
|
||||||
// iterate the partition states
|
// iterate the partition states
|
||||||
foreach (var partitionState in s.PartitionStates)
|
foreach (var partitionState in s.PartitionStates)
|
||||||
{
|
{
|
||||||
|
this.LogDebug("checking PartitionState {partitionStateKey}", partitionState.PartitionKey);
|
||||||
// get the partition by key
|
// get the partition by key
|
||||||
var partition = Partitions.FirstOrDefault((p) => p.Key.Equals(partitionState.PartitionKey));
|
var partition = Partitions.FirstOrDefault((p) => p.Key.Equals(partitionState.PartitionKey));
|
||||||
|
|
||||||
|
this.LogDebug("Expected State: {partitionPresent} Actual State: {partitionState}", partitionState.PartitionPresent, partition.PartitionPresentFeedback.BoolValue);
|
||||||
|
|
||||||
if (partition != null && partitionState.PartitionPresent != partition.PartitionPresentFeedback.BoolValue)
|
if (partition != null && partitionState.PartitionPresent != partition.PartitionPresentFeedback.BoolValue)
|
||||||
{
|
{
|
||||||
// the partition can't be found or the state doesn't match
|
// the partition can't be found or the state doesn't match
|
||||||
@@ -153,10 +209,41 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
if (currentScenario != null)
|
if (currentScenario != null)
|
||||||
{
|
{
|
||||||
CurrentScenario = currentScenario;
|
this.LogInformation("Found combination Scenario {scenarioKey}", currentScenario.Key);
|
||||||
|
ChangeScenario(currentScenario);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task ChangeScenario(IRoomCombinationScenario newScenario)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
if (newScenario == _currentScenario)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deactivate the old scenario first
|
||||||
|
if (_currentScenario != null)
|
||||||
|
{
|
||||||
|
Debug.LogMessage(LogEventLevel.Information, "Deactivating scenario {currentScenario}", this, _currentScenario.Name);
|
||||||
|
await _currentScenario.Deactivate();
|
||||||
|
}
|
||||||
|
|
||||||
|
_currentScenario = newScenario;
|
||||||
|
|
||||||
|
// Activate the new scenario
|
||||||
|
if (_currentScenario != null)
|
||||||
|
{
|
||||||
|
Debug.LogMessage(LogEventLevel.Debug, $"Current Scenario: {_currentScenario.Name}", this);
|
||||||
|
await _currentScenario.Activate();
|
||||||
|
}
|
||||||
|
|
||||||
|
RoomCombinationScenarioChanged?.Invoke(this, new EventArgs());
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#region IEssentialsRoomCombiner Members
|
#region IEssentialsRoomCombiner Members
|
||||||
|
|
||||||
public event EventHandler<EventArgs> RoomCombinationScenarioChanged;
|
public event EventHandler<EventArgs> RoomCombinationScenarioChanged;
|
||||||
@@ -167,53 +254,42 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
return _currentScenario;
|
return _currentScenario;
|
||||||
}
|
}
|
||||||
private set
|
|
||||||
{
|
|
||||||
if (value != _currentScenario)
|
|
||||||
{
|
|
||||||
// Deactivate the old scenario first
|
|
||||||
if (_currentScenario != null)
|
|
||||||
{
|
|
||||||
_currentScenario.Deactivate();
|
|
||||||
}
|
|
||||||
|
|
||||||
_currentScenario = value;
|
|
||||||
|
|
||||||
// Activate the new scenario
|
|
||||||
if (_currentScenario != null)
|
|
||||||
{
|
|
||||||
_currentScenario.Activate();
|
|
||||||
|
|
||||||
Debug.Console(1, this, "Current Scenario: {0}", _currentScenario.Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
var handler = RoomCombinationScenarioChanged;
|
|
||||||
if (handler != null)
|
|
||||||
{
|
|
||||||
handler(this, new EventArgs());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BoolFeedback IsInAutoModeFeedback { get; private set; }
|
public BoolFeedback IsInAutoModeFeedback { get; private set; }
|
||||||
|
|
||||||
public void SetAutoMode()
|
public void SetAutoMode()
|
||||||
{
|
{
|
||||||
isInAutoMode = true;
|
IsInAutoMode = true;
|
||||||
IsInAutoModeFeedback.FireUpdate();
|
|
||||||
|
foreach (var partition in Partitions)
|
||||||
|
{
|
||||||
|
partition.SetAutoMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
DetermineRoomCombinationScenario();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetManualMode()
|
public void SetManualMode()
|
||||||
{
|
{
|
||||||
isInAutoMode = false;
|
IsInAutoMode = false;
|
||||||
IsInAutoModeFeedback.FireUpdate();
|
|
||||||
|
foreach (var partition in Partitions)
|
||||||
|
{
|
||||||
|
partition.SetManualMode();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ToggleMode()
|
public void ToggleMode()
|
||||||
{
|
{
|
||||||
isInAutoMode = !isInAutoMode;
|
if (IsInAutoMode)
|
||||||
IsInAutoModeFeedback.FireUpdate();
|
{
|
||||||
|
SetManualMode();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetAutoMode();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<IRoomCombinationScenario> RoomCombinationScenarios { get; private set; }
|
public List<IRoomCombinationScenario> RoomCombinationScenarios { get; private set; }
|
||||||
@@ -222,7 +298,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
public void TogglePartitionState(string partitionKey)
|
public void TogglePartitionState(string partitionKey)
|
||||||
{
|
{
|
||||||
var partition = Partitions.FirstOrDefault((p) => p.Key.Equals(partitionKey)) as IPartitionController;
|
var partition = Partitions.FirstOrDefault((p) => p.Key.Equals(partitionKey));
|
||||||
|
|
||||||
if (partition != null)
|
if (partition != null)
|
||||||
{
|
{
|
||||||
@@ -232,9 +308,9 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
public void SetRoomCombinationScenario(string scenarioKey)
|
public void SetRoomCombinationScenario(string scenarioKey)
|
||||||
{
|
{
|
||||||
if (isInAutoMode)
|
if (IsInAutoMode)
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Cannot set room combination scenario when in auto mode. Set to auto mode first.");
|
Debug.LogMessage(LogEventLevel.Information, this, "Cannot set room combination scenario when in auto mode. Set to auto mode first.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,7 +321,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
// Set the parition states from the scenario manually
|
// Set the parition states from the scenario manually
|
||||||
if (scenario != null)
|
if (scenario != null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Manually setting scenario to '{0}'", scenario.Key);
|
Debug.LogMessage(LogEventLevel.Information, this, "Manually setting scenario to '{0}'", scenario.Key);
|
||||||
foreach (var partitionState in scenario.PartitionStates)
|
foreach (var partitionState in scenario.PartitionStates)
|
||||||
{
|
{
|
||||||
var partition = Partitions.FirstOrDefault((p) => p.Key.Equals(partitionState.PartitionKey));
|
var partition = Partitions.FirstOrDefault((p) => p.Key.Equals(partitionState.PartitionKey));
|
||||||
@@ -254,24 +330,24 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
if (partitionState.PartitionPresent)
|
if (partitionState.PartitionPresent)
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Manually setting state to Present for: '{0}'", partition.Key);
|
Debug.LogMessage(LogEventLevel.Information, this, "Manually setting state to Present for: '{0}'", partition.Key);
|
||||||
partition.SetPartitionStatePresent();
|
partition.SetPartitionStatePresent();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Manually setting state to Not Present for: '{0}'", partition.Key);
|
Debug.LogMessage(LogEventLevel.Information, this, "Manually setting state to Not Present for: '{0}'", partition.Key);
|
||||||
partition.SetPartitionStateNotPresent();
|
partition.SetPartitionStateNotPresent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Unable to find partition with key: '{0}'", partitionState.PartitionKey);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Unable to find partition with key: '{0}'", partitionState.PartitionKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Unable to find scenario with key: '{0}'", scenarioKey);
|
Debug.LogMessage(LogEventLevel.Debug, this, "Unable to find scenario with key: '{0}'", scenarioKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,7 +363,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
public override EssentialsDevice BuildDevice(PepperDash.Essentials.Core.Config.DeviceConfig dc)
|
public override EssentialsDevice BuildDevice(PepperDash.Essentials.Core.Config.DeviceConfig dc)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Factory Attempting to create new EssentialsRoomCombiner Device");
|
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new EssentialsRoomCombiner Device");
|
||||||
|
|
||||||
var props = dc.Properties.ToObject<EssentialsRoomCombinerPropertiesConfig>();
|
var props = dc.Properties.ToObject<EssentialsRoomCombinerPropertiesConfig>();
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Threading.Tasks;
|
||||||
using System.Text;
|
using Newtonsoft.Json;
|
||||||
using Crestron.SimplSharp;
|
|
||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
@@ -21,13 +19,21 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The current room combination scenario
|
/// The current room combination scenario
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[JsonProperty("currentScenario")]
|
||||||
IRoomCombinationScenario CurrentScenario { get; }
|
IRoomCombinationScenario CurrentScenario { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// When true, indicates the current mode is auto mode
|
/// When true, indicates the current mode is auto mode
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[JsonIgnore]
|
||||||
BoolFeedback IsInAutoModeFeedback {get;}
|
BoolFeedback IsInAutoModeFeedback {get;}
|
||||||
|
|
||||||
|
[JsonProperty("isInAutoMode")]
|
||||||
|
bool IsInAutoMode { get; }
|
||||||
|
|
||||||
|
[JsonProperty("rooms")]
|
||||||
|
List<IKeyName> Rooms { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets auto mode
|
/// Sets auto mode
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -46,11 +52,13 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The available room combinatino scenarios
|
/// The available room combinatino scenarios
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[JsonProperty("roomCombinationScenarios")]
|
||||||
List<IRoomCombinationScenario> RoomCombinationScenarios { get; }
|
List<IRoomCombinationScenario> RoomCombinationScenarios { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The partition
|
/// The partition
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[JsonProperty("partitions")]
|
||||||
List<IPartitionController> Partitions { get; }
|
List<IPartitionController> Partitions { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -71,26 +79,32 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// When true, indicates that this room combination scenario is active
|
/// When true, indicates that this room combination scenario is active
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[JsonIgnore]
|
||||||
BoolFeedback IsActiveFeedback { get; }
|
BoolFeedback IsActiveFeedback { get; }
|
||||||
|
|
||||||
|
[JsonProperty("isActive")]
|
||||||
|
bool IsActive { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Activates this room combination scenario
|
/// Activates this room combination scenario
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void Activate();
|
Task Activate();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deactivates this room combination scenario
|
/// Deactivates this room combination scenario
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void Deactivate();
|
Task Deactivate();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The state of the partitions that would activate this scenario
|
/// The state of the partitions that would activate this scenario
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[JsonProperty("partitionStates")]
|
||||||
List<PartitionState> PartitionStates { get; }
|
List<PartitionState> PartitionStates { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The mapping of UIs by key to rooms by key
|
/// The mapping of UIs by key to rooms by key
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[JsonProperty("uiMap")]
|
||||||
Dictionary<string, string> UiMap { get; set; }
|
Dictionary<string, string> UiMap { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,34 +1,50 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
|
using PepperDash.Core.Logging;
|
||||||
using Newtonsoft.Json;
|
using Serilog.Events;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a room combination scenario
|
/// Represents a room combination scenario
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class RoomCombinationScenario: IRoomCombinationScenario
|
public class RoomCombinationScenario : IRoomCombinationScenario, IKeyName
|
||||||
{
|
{
|
||||||
private RoomCombinationScenarioConfig _config;
|
private RoomCombinationScenarioConfig _config;
|
||||||
|
|
||||||
|
[JsonProperty("key")]
|
||||||
public string Key { get; set; }
|
public string Key { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("name")]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("partitionStates")]
|
||||||
public List<PartitionState> PartitionStates { get; private set; }
|
public List<PartitionState> PartitionStates { get; private set; }
|
||||||
|
|
||||||
|
[JsonProperty("uiMap")]
|
||||||
public Dictionary<string, string> UiMap { get; set; }
|
public Dictionary<string, string> UiMap { get; set; }
|
||||||
|
|
||||||
private bool _isActive;
|
private bool _isActive;
|
||||||
|
|
||||||
|
[JsonProperty("isActive")]
|
||||||
|
public bool IsActive
|
||||||
|
{
|
||||||
|
get { return _isActive; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == _isActive)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_isActive = value;
|
||||||
|
IsActiveFeedback.FireUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public BoolFeedback IsActiveFeedback { get; private set; }
|
public BoolFeedback IsActiveFeedback { get; private set; }
|
||||||
|
|
||||||
private List<DeviceActionWrapper> activationActions;
|
private List<DeviceActionWrapper> activationActions;
|
||||||
@@ -54,36 +70,40 @@ namespace PepperDash.Essentials.Core
|
|||||||
IsActiveFeedback = new BoolFeedback(() => _isActive);
|
IsActiveFeedback = new BoolFeedback(() => _isActive);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Activate()
|
public async Task Activate()
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Activating Scenario: '{0}' with {1} action(s) defined", Name, activationActions.Count);
|
this.LogInformation("Activating Scenario {name} with {activationActionCount} action(s) defined", Name, activationActions.Count);
|
||||||
|
|
||||||
|
List<Task> tasks = new List<Task>();
|
||||||
|
|
||||||
if (activationActions != null)
|
if (activationActions != null)
|
||||||
{
|
{
|
||||||
foreach (var action in activationActions)
|
foreach (var action in activationActions)
|
||||||
{
|
{
|
||||||
DeviceJsonApi.DoDeviceAction(action);
|
this.LogInformation("Running Activation action {@action}", action);
|
||||||
|
await DeviceJsonApi.DoDeviceActionAsync(action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_isActive = true;
|
IsActive = true;
|
||||||
IsActiveFeedback.FireUpdate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Deactivate()
|
public async Task Deactivate()
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Deactivating Scenario: '{0}' with {1} action(s) defined", Name, deactivationActions.Count);
|
this.LogInformation("Deactivating Scenario {name} with {deactivationActionCount} action(s) defined", Name, deactivationActions.Count);
|
||||||
|
|
||||||
|
List<Task> tasks = new List<Task>();
|
||||||
|
|
||||||
if (deactivationActions != null)
|
if (deactivationActions != null)
|
||||||
{
|
{
|
||||||
foreach (var action in deactivationActions)
|
foreach (var action in deactivationActions)
|
||||||
{
|
{
|
||||||
DeviceJsonApi.DoDeviceAction(action);
|
this.LogInformation("Running deactivation action {actionDeviceKey}:{actionMethod}", action.DeviceKey, action.MethodName);
|
||||||
|
await DeviceJsonApi.DoDeviceActionAsync(action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_isActive = false;
|
IsActive = false;
|
||||||
IsActiveFeedback.FireUpdate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using Newtonsoft.Json;
|
|||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
using PepperDash.Essentials.Core.Privacy;
|
using PepperDash.Essentials.Core.Privacy;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Room.Config
|
namespace PepperDash.Essentials.Room.Config
|
||||||
{
|
{
|
||||||
@@ -23,6 +24,7 @@ namespace PepperDash.Essentials.Room.Config
|
|||||||
//switch on emergency type here. Right now only contact and shutdown
|
//switch on emergency type here. Right now only contact and shutdown
|
||||||
var e = new EssentialsRoomEmergencyContactClosure(room.Key + "-emergency", props.Emergency, room);
|
var e = new EssentialsRoomEmergencyContactClosure(room.Key + "-emergency", props.Emergency, room);
|
||||||
DeviceManager.AddDevice(e);
|
DeviceManager.AddDevice(e);
|
||||||
|
return e;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -39,7 +41,7 @@ namespace PepperDash.Essentials.Room.Config
|
|||||||
var microphonePrivacy = props.MicrophonePrivacy;
|
var microphonePrivacy = props.MicrophonePrivacy;
|
||||||
if (microphonePrivacy == null)
|
if (microphonePrivacy == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Cannot create microphone privacy with null properties");
|
Debug.LogMessage(LogEventLevel.Information, "Cannot create microphone privacy with null properties");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// Get the MicrophonePrivacy device from the device manager
|
// Get the MicrophonePrivacy device from the device manager
|
||||||
@@ -47,7 +49,7 @@ namespace PepperDash.Essentials.Room.Config
|
|||||||
// Set this room as the IPrivacy device
|
// Set this room as the IPrivacy device
|
||||||
if (mP == null)
|
if (mP == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "ERROR: Selected device {0} is not MicrophonePrivacyController", props.MicrophonePrivacy.DeviceKey);
|
Debug.LogMessage(LogEventLevel.Information, "ERROR: Selected device {0} is not MicrophonePrivacyController", props.MicrophonePrivacy.DeviceKey);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
mP.SetPrivacyDevice(room);
|
mP.SetPrivacyDevice(room);
|
||||||
@@ -56,7 +58,7 @@ namespace PepperDash.Essentials.Room.Config
|
|||||||
|
|
||||||
if (behaviour == null)
|
if (behaviour == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "WARNING: No behaviour defined for MicrophonePrivacyController");
|
Debug.LogMessage(LogEventLevel.Information, "WARNING: No behaviour defined for MicrophonePrivacyController");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (behaviour == "trackroomstate")
|
if (behaviour == "trackroomstate")
|
||||||
@@ -197,6 +199,12 @@ namespace PepperDash.Essentials.Room.Config
|
|||||||
public string SourceListKey { get; set; }
|
public string SourceListKey { get; set; }
|
||||||
[JsonProperty("destinationListKey")]
|
[JsonProperty("destinationListKey")]
|
||||||
public string DestinationListKey { get; set; }
|
public string DestinationListKey { get; set; }
|
||||||
|
[JsonProperty("audioControlPointListKey")]
|
||||||
|
public string AudioControlPointListKey { get; set; }
|
||||||
|
[JsonProperty("cameraListKey")]
|
||||||
|
public string CameraListKey { get; set; }
|
||||||
|
|
||||||
|
|
||||||
[JsonProperty("defaultSourceItem")]
|
[JsonProperty("defaultSourceItem")]
|
||||||
public string DefaultSourceItem { get; set; }
|
public string DefaultSourceItem { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -209,6 +217,10 @@ namespace PepperDash.Essentials.Room.Config
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("userCanChangeShareMode")]
|
[JsonProperty("userCanChangeShareMode")]
|
||||||
public bool UserCanChangeShareMode { get; set; }
|
public bool UserCanChangeShareMode { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
[JsonProperty("matrixRoutingKey", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
|
public string MatrixRoutingKey { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class EssentialsConferenceRoomPropertiesConfig : EssentialsAvRoomPropertiesConfig
|
public class EssentialsConferenceRoomPropertiesConfig : EssentialsAvRoomPropertiesConfig
|
||||||
@@ -217,6 +229,7 @@ namespace PepperDash.Essentials.Room.Config
|
|||||||
public string VideoCodecKey { get; set; }
|
public string VideoCodecKey { get; set; }
|
||||||
[JsonProperty("audioCodecKey")]
|
[JsonProperty("audioCodecKey")]
|
||||||
public string AudioCodecKey { get; set; }
|
public string AudioCodecKey { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class EssentialsEnvironmentPropertiesConfig
|
public class EssentialsEnvironmentPropertiesConfig
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
public class EssentialsRoomEmergencyTriggerConfig
|
public class EssentialsRoomEmergencyTriggerConfig
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// contact,
|
/// contact,versiport
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Type { get; set; }
|
public string Type { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -4,12 +4,16 @@ using PepperDash.Essentials.Room.Config;
|
|||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
public class EssentialsRoomEmergencyContactClosure : EssentialsRoomEmergencyBase
|
public class EssentialsRoomEmergencyContactClosure : EssentialsRoomEmergencyBase, IEssentialsRoomEmergency
|
||||||
{
|
{
|
||||||
|
public event EventHandler<EventArgs> EmergencyStateChange;
|
||||||
|
|
||||||
IEssentialsRoom Room;
|
IEssentialsRoom Room;
|
||||||
string Behavior;
|
string Behavior;
|
||||||
bool TriggerOnClose;
|
bool TriggerOnClose;
|
||||||
|
|
||||||
|
public bool InEmergency { get; private set; }
|
||||||
|
|
||||||
public EssentialsRoomEmergencyContactClosure(string key, EssentialsRoomEmergencyConfig config, IEssentialsRoom room) :
|
public EssentialsRoomEmergencyContactClosure(string key, EssentialsRoomEmergencyConfig config, IEssentialsRoom room) :
|
||||||
base(key)
|
base(key)
|
||||||
{
|
{
|
||||||
@@ -25,14 +29,49 @@ namespace PepperDash.Essentials.Core
|
|||||||
cs.DigitalInputPorts[portNum].StateChange += EsentialsRoomEmergencyContactClosure_StateChange;
|
cs.DigitalInputPorts[portNum].StateChange += EsentialsRoomEmergencyContactClosure_StateChange;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (config.Trigger.Type.Equals("versiport", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
var portNum = (uint)config.Trigger.Number;
|
||||||
|
if (portNum <= cs.NumberOfVersiPorts)
|
||||||
|
{
|
||||||
|
cs.VersiPorts[portNum].Register();
|
||||||
|
cs.VersiPorts[portNum].SetVersiportConfiguration(eVersiportConfiguration.DigitalInput);
|
||||||
|
cs.VersiPorts[portNum].DisablePullUpResistor = true;
|
||||||
|
cs.VersiPorts[portNum].VersiportChange += EssentialsRoomEmergencyContactClosure_VersiportChange;
|
||||||
|
}
|
||||||
|
}
|
||||||
Behavior = config.Behavior;
|
Behavior = config.Behavior;
|
||||||
TriggerOnClose = config.Trigger.TriggerOnClose;
|
TriggerOnClose = config.Trigger.TriggerOnClose;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void EssentialsRoomEmergencyContactClosure_VersiportChange(Versiport port, VersiportEventArgs args)
|
||||||
|
{
|
||||||
|
if (args.Event == eVersiportEvent.DigitalInChange)
|
||||||
|
{
|
||||||
|
ContactClosure_StateChange(port.DigitalIn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void EsentialsRoomEmergencyContactClosure_StateChange(DigitalInput digitalInput, DigitalInputEventArgs args)
|
void EsentialsRoomEmergencyContactClosure_StateChange(DigitalInput digitalInput, DigitalInputEventArgs args)
|
||||||
{
|
{
|
||||||
if (args.State && TriggerOnClose || !args.State && !TriggerOnClose)
|
ContactClosure_StateChange(args.State);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContactClosure_StateChange(bool portState)
|
||||||
|
{
|
||||||
|
if (portState && TriggerOnClose || !portState && !TriggerOnClose)
|
||||||
|
{
|
||||||
|
InEmergency = true;
|
||||||
|
if (EmergencyStateChange != null)
|
||||||
|
EmergencyStateChange(this, new EventArgs());
|
||||||
RunEmergencyBehavior();
|
RunEmergencyBehavior();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
InEmergency = false;
|
||||||
|
if (EmergencyStateChange != null)
|
||||||
|
EmergencyStateChange(this, new EventArgs());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -44,4 +83,14 @@ namespace PepperDash.Essentials.Core
|
|||||||
Room.Shutdown();
|
Room.Shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Describes the functionality of a room emergency contact closure
|
||||||
|
/// </summary>
|
||||||
|
public interface IEssentialsRoomEmergency
|
||||||
|
{
|
||||||
|
event EventHandler<EventArgs> EmergencyStateChange;
|
||||||
|
|
||||||
|
bool InEmergency { get; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,7 @@ using PepperDash.Essentials.Core;
|
|||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
using PepperDash.Essentials.Core.Devices;
|
using PepperDash.Essentials.Core.Devices;
|
||||||
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
|
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
@@ -58,28 +59,102 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public IMobileControlRoomMessenger MobileControlRoomBridge { get; private set; }
|
public IMobileControlRoomMessenger MobileControlRoomBridge { get; private set; }
|
||||||
|
|
||||||
|
protected const string _defaultListKey = "default";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The config name of the source list
|
/// The config name of the source list
|
||||||
/// </summary>
|
/// </summary>
|
||||||
///
|
///
|
||||||
protected string _SourceListKey;
|
private string _sourceListKey;
|
||||||
public string SourceListKey {
|
public string SourceListKey {
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return _SourceListKey;
|
if(string.IsNullOrEmpty(_sourceListKey))
|
||||||
}
|
|
||||||
private set
|
|
||||||
{
|
|
||||||
if (value != _SourceListKey)
|
|
||||||
{
|
{
|
||||||
_SourceListKey = value;
|
return _defaultListKey;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return _sourceListKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected set
|
||||||
|
{
|
||||||
|
if (value != _sourceListKey)
|
||||||
|
{
|
||||||
|
_sourceListKey = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string DestinationListKey { get; private set; }
|
private string _destinationListKey;
|
||||||
|
public string DestinationListKey
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(_destinationListKey))
|
||||||
|
{
|
||||||
|
return _defaultListKey;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return _destinationListKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected set
|
||||||
|
{
|
||||||
|
if (value != _destinationListKey)
|
||||||
|
{
|
||||||
|
_destinationListKey = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected const string _defaultSourceListKey = "default";
|
private string _audioControlPointListKey;
|
||||||
|
public string AudioControlPointListKey
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(_audioControlPointListKey))
|
||||||
|
{
|
||||||
|
return _defaultListKey;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return _destinationListKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected set
|
||||||
|
{
|
||||||
|
if (value != _audioControlPointListKey)
|
||||||
|
{
|
||||||
|
_audioControlPointListKey = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string _cameraListKey;
|
||||||
|
public string CameraListKey
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(_cameraListKey))
|
||||||
|
{
|
||||||
|
return _defaultListKey;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return _cameraListKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected set
|
||||||
|
{
|
||||||
|
if (value != _cameraListKey)
|
||||||
|
{
|
||||||
|
_cameraListKey = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Timer used for informing the UIs of a shutdown
|
/// Timer used for informing the UIs of a shutdown
|
||||||
@@ -140,6 +215,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
if (!ShutdownPromptTimer.IsRunningFeedback.BoolValue)
|
if (!ShutdownPromptTimer.IsRunningFeedback.BoolValue)
|
||||||
ShutdownType = eShutdownType.None;
|
ShutdownType = eShutdownType.None;
|
||||||
};
|
};
|
||||||
|
|
||||||
ShutdownPromptTimer.HasFinished += (o, a) => Shutdown(); // Shutdown is triggered
|
ShutdownPromptTimer.HasFinished += (o, a) => Shutdown(); // Shutdown is triggered
|
||||||
|
|
||||||
ShutdownPromptSeconds = 60;
|
ShutdownPromptSeconds = 60;
|
||||||
@@ -190,7 +266,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sourceListKey = _defaultSourceListKey;
|
sourceListKey = _defaultListKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,14 +287,14 @@ namespace PepperDash.Essentials.Core
|
|||||||
var mcBridge = DeviceManager.GetDeviceForKey(mcBridgeKey);
|
var mcBridge = DeviceManager.GetDeviceForKey(mcBridgeKey);
|
||||||
if (mcBridge == null)
|
if (mcBridge == null)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "*********************Mobile Control Bridge Not found for this room.");
|
Debug.LogMessage(LogEventLevel.Debug, this, "*********************Mobile Control Bridge Not found for this room.");
|
||||||
IsMobileControlEnabled = false;
|
IsMobileControlEnabled = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MobileControlRoomBridge = mcBridge as IMobileControlRoomMessenger;
|
MobileControlRoomBridge = mcBridge as IMobileControlRoomMessenger;
|
||||||
Debug.Console(1, this, "*********************Mobile Control Bridge found and enabled for this room");
|
Debug.LogMessage(LogEventLevel.Debug, this, "*********************Mobile Control Bridge found and enabled for this room");
|
||||||
IsMobileControlEnabled = true;
|
IsMobileControlEnabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -236,7 +312,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
case eVacancyMode.InShutdownWarning:
|
case eVacancyMode.InShutdownWarning:
|
||||||
{
|
{
|
||||||
StartShutdown(eShutdownType.Vacancy);
|
StartShutdown(eShutdownType.Vacancy);
|
||||||
Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Shutting Down due to vacancy.");
|
Debug.LogMessage(LogEventLevel.Information, this, "Shutting Down due to vacancy.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -259,7 +335,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
ShutdownType = type;
|
ShutdownType = type;
|
||||||
ShutdownPromptTimer.Start();
|
ShutdownPromptTimer.Start();
|
||||||
|
|
||||||
Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "ShutdownPromptTimer Started. Type: {0}. Seconds: {1}", ShutdownType, ShutdownPromptTimer.SecondsToCount);
|
Debug.LogMessage(LogEventLevel.Information, this, "ShutdownPromptTimer Started. Type: {0}. Seconds: {1}", ShutdownType, ShutdownPromptTimer.SecondsToCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StartRoomVacancyTimer(eVacancyMode mode)
|
public void StartRoomVacancyTimer(eVacancyMode mode)
|
||||||
@@ -273,7 +349,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
VacancyMode = mode;
|
VacancyMode = mode;
|
||||||
RoomVacancyShutdownTimer.Start();
|
RoomVacancyShutdownTimer.Start();
|
||||||
|
|
||||||
Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Vacancy Timer Started. Mode: {0}. Seconds: {1}", VacancyMode, RoomVacancyShutdownTimer.SecondsToCount);
|
Debug.LogMessage(LogEventLevel.Information, this, "Vacancy Timer Started. Mode: {0}. Seconds: {1}", VacancyMode, RoomVacancyShutdownTimer.SecondsToCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -305,12 +381,12 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
if (statusProvider == null)
|
if (statusProvider == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "ERROR: Occupancy sensor device is null");
|
Debug.LogMessage(LogEventLevel.Information, this, "ERROR: Occupancy sensor device is null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Room Occupancy set to device: '{0}'", (statusProvider as Device).Key);
|
Debug.LogMessage(LogEventLevel.Information, this, "Room Occupancy set to device: '{0}'", (statusProvider as Device).Key);
|
||||||
Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Timeout Minutes from Config is: {0}", timeoutMinutes);
|
Debug.LogMessage(LogEventLevel.Information, this, "Timeout Minutes from Config is: {0}", timeoutMinutes);
|
||||||
|
|
||||||
// If status provider is fusion, set flag to remote
|
// If status provider is fusion, set flag to remote
|
||||||
if (statusProvider is Core.Fusion.EssentialsHuddleSpaceFusionSystemControllerBase)
|
if (statusProvider is Core.Fusion.EssentialsHuddleSpaceFusionSystemControllerBase)
|
||||||
@@ -319,7 +395,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
if(timeoutMinutes > 0)
|
if(timeoutMinutes > 0)
|
||||||
RoomVacancyShutdownSeconds = timeoutMinutes * 60;
|
RoomVacancyShutdownSeconds = timeoutMinutes * 60;
|
||||||
|
|
||||||
Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "RoomVacancyShutdownSeconds set to {0}", RoomVacancyShutdownSeconds);
|
Debug.LogMessage(LogEventLevel.Information, this, "RoomVacancyShutdownSeconds set to {0}", RoomVacancyShutdownSeconds);
|
||||||
|
|
||||||
RoomOccupancy = statusProvider;
|
RoomOccupancy = statusProvider;
|
||||||
|
|
||||||
@@ -351,13 +427,13 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
if (RoomOccupancy.RoomIsOccupiedFeedback.BoolValue == false && AllowVacancyTimerToStart())
|
if (RoomOccupancy.RoomIsOccupiedFeedback.BoolValue == false && AllowVacancyTimerToStart())
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Notice: Vacancy Detected");
|
Debug.LogMessage(LogEventLevel.Debug, this, "Notice: Vacancy Detected");
|
||||||
// Trigger the timer when the room is vacant
|
// Trigger the timer when the room is vacant
|
||||||
StartRoomVacancyTimer(eVacancyMode.InInitialVacancy);
|
StartRoomVacancyTimer(eVacancyMode.InInitialVacancy);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Notice: Occupancy Detected");
|
Debug.LogMessage(LogEventLevel.Debug, this, "Notice: Occupancy Detected");
|
||||||
// Reset the timer when the room is occupied
|
// Reset the timer when the room is occupied
|
||||||
RoomVacancyShutdownTimer.Cancel();
|
RoomVacancyShutdownTimer.Cancel();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
string DestinationListKey { get; }
|
string DestinationListKey { get; }
|
||||||
|
|
||||||
|
string AudioControlPointListKey { get; }
|
||||||
|
|
||||||
|
string CameraListKey { get; }
|
||||||
|
|
||||||
SecondsCountdownTimer ShutdownPromptTimer { get; }
|
SecondsCountdownTimer ShutdownPromptTimer { get; }
|
||||||
int ShutdownPromptSeconds { get; }
|
int ShutdownPromptSeconds { get; }
|
||||||
int ShutdownVacancySeconds { get; }
|
int ShutdownVacancySeconds { get; }
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IHasDefaultDisplay
|
public interface IHasDefaultDisplay
|
||||||
{
|
{
|
||||||
IRoutingSinkWithSwitching DefaultDisplay { get; }
|
IRoutingSink DefaultDisplay { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -30,7 +30,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IHasMultipleDisplays
|
public interface IHasMultipleDisplays
|
||||||
{
|
{
|
||||||
Dictionary<eSourceListItemDestinationTypes, IRoutingSinkWithSwitching> Displays { get; }
|
Dictionary<eSourceListItemDestinationTypes, IRoutingSink> Displays { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -51,6 +51,62 @@ namespace PepperDash.Essentials.Core
|
|||||||
void RunDirectRoute(string sourceKey, string destinationKey, eRoutingSignalType type = eRoutingSignalType.AudioVideo);
|
void RunDirectRoute(string sourceKey, string destinationKey, eRoutingSignalType type = eRoutingSignalType.AudioVideo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Describes a room with matrix routing
|
||||||
|
/// </summary>
|
||||||
|
public interface IHasMatrixRouting
|
||||||
|
{
|
||||||
|
string MatrixRoutingDeviceKey { get; }
|
||||||
|
|
||||||
|
List<string> EndpointKeys { get; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Describes a room with routing endpoints
|
||||||
|
/// </summary>
|
||||||
|
public interface IHasRoutingEndpoints
|
||||||
|
{
|
||||||
|
List<string> EndpointKeys { get; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Describes a room with a shutdown prompt timer
|
||||||
|
/// </summary>
|
||||||
|
public interface IShutdownPromptTimer
|
||||||
|
{
|
||||||
|
SecondsCountdownTimer ShutdownPromptTimer { get; }
|
||||||
|
|
||||||
|
void SetShutdownPromptSeconds(int seconds);
|
||||||
|
|
||||||
|
void StartShutdown(eShutdownType type);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary""'""">
|
||||||
|
/// Describes a room with a tech password
|
||||||
|
/// </summary>
|
||||||
|
public interface ITechPassword
|
||||||
|
{
|
||||||
|
event EventHandler<TechPasswordEventArgs> TechPasswordValidateResult;
|
||||||
|
|
||||||
|
event EventHandler<EventArgs> TechPasswordChanged;
|
||||||
|
|
||||||
|
int TechPasswordLength { get; }
|
||||||
|
|
||||||
|
void ValidateTechPassword(string password);
|
||||||
|
|
||||||
|
void SetTechPassword(string oldPassword, string newPassword);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TechPasswordEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
public bool IsValid { get; private set; }
|
||||||
|
|
||||||
|
public TechPasswordEventArgs(bool isValid)
|
||||||
|
{
|
||||||
|
IsValid = isValid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// For rooms that default presentation only routing
|
/// For rooms that default presentation only routing
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -103,4 +159,13 @@ namespace PepperDash.Essentials.Core
|
|||||||
Core.Privacy.MicrophonePrivacyController MicrophonePrivacy { get; }
|
Core.Privacy.MicrophonePrivacyController MicrophonePrivacy { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface IHasAccessoryDevices : IKeyName
|
||||||
|
{
|
||||||
|
List<string> AccessoryDeviceKeys { get; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IHasCiscoNavigatorTouchpanel
|
||||||
|
{
|
||||||
|
string CiscoNavigatorTouchpanelKey { get; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,7 @@ using PepperDash.Core;
|
|||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Routing
|
namespace PepperDash.Essentials.Core.Routing
|
||||||
{
|
{
|
||||||
public class DummyRoutingInputsDevice : Device, IRoutingSource
|
public class DummyRoutingInputsDevice : Device, IRoutingSource, IRoutingOutputs
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A single output port, backplane, audioVideo
|
/// A single output port, backplane, audioVideo
|
||||||
|
|||||||
373
src/PepperDash.Essentials.Core/Routing/Extensions.cs
Normal file
373
src/PepperDash.Essentials.Core/Routing/Extensions.cs
Normal file
@@ -0,0 +1,373 @@
|
|||||||
|
using PepperDash.Essentials.Core.Queues;
|
||||||
|
using PepperDash.Essentials.Core.Routing;
|
||||||
|
using Serilog.Events;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using Debug = PepperDash.Core.Debug;
|
||||||
|
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Extensions added to any IRoutingInputs classes to provide discovery-based routing
|
||||||
|
/// on those destinations.
|
||||||
|
/// </summary>
|
||||||
|
public static class Extensions
|
||||||
|
{
|
||||||
|
private static readonly Dictionary<string, RouteRequest> RouteRequests = new Dictionary<string, RouteRequest>();
|
||||||
|
|
||||||
|
private static readonly GenericQueue routeRequestQueue = new GenericQueue("routingQueue");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets any existing RouteDescriptor for a destination, clears it using ReleaseRoute
|
||||||
|
/// and then attempts a new Route and if sucessful, stores that RouteDescriptor
|
||||||
|
/// in RouteDescriptorCollection.DefaultCollection
|
||||||
|
/// </summary>
|
||||||
|
public static void ReleaseAndMakeRoute(this IRoutingInputs destination, IRoutingOutputs source, eRoutingSignalType signalType, string destinationPortKey = "", string sourcePortKey = "")
|
||||||
|
{
|
||||||
|
// Remove this line before committing!!!!!
|
||||||
|
var frame = new StackFrame(1, true);
|
||||||
|
Debug.LogMessage(LogEventLevel.Information, "ReleaseAndMakeRoute Called from {method} with params {destinationKey}:{sourceKey}:{signalType}:{destinationPortKey}:{sourcePortKey}", frame.GetMethod().Name, destination.Key, source.Key, signalType.ToString(), destinationPortKey, sourcePortKey);
|
||||||
|
|
||||||
|
var inputPort = string.IsNullOrEmpty(destinationPortKey) ? null : destination.InputPorts.FirstOrDefault(p => p.Key == destinationPortKey);
|
||||||
|
var outputPort = string.IsNullOrEmpty(sourcePortKey) ? null : source.OutputPorts.FirstOrDefault(p => p.Key == sourcePortKey);
|
||||||
|
|
||||||
|
ReleaseAndMakeRoute(destination, source, signalType, inputPort, outputPort);
|
||||||
|
}
|
||||||
|
public static void ReleaseRoute(this IRoutingInputs destination)
|
||||||
|
{
|
||||||
|
routeRequestQueue.Enqueue(new ReleaseRouteQueueItem(ReleaseRouteInternal, destination, string.Empty));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ReleaseRoute(this IRoutingInputs destination, string inputPortKey)
|
||||||
|
{
|
||||||
|
routeRequestQueue.Enqueue(new ReleaseRouteQueueItem(ReleaseRouteInternal, destination, inputPortKey));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void RemoveRouteRequestForDestination(string destinationKey)
|
||||||
|
{
|
||||||
|
Debug.LogMessage(LogEventLevel.Information, "Removing route request for {destination}", null, destinationKey);
|
||||||
|
|
||||||
|
var result = RouteRequests.Remove(destinationKey);
|
||||||
|
|
||||||
|
var messageTemplate = result ? "Route Request for {destination} removed" : "Route Request for {destination} not found";
|
||||||
|
|
||||||
|
Debug.LogMessage(LogEventLevel.Information, messageTemplate, null, destinationKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Builds a RouteDescriptor that contains the steps necessary to make a route between devices.
|
||||||
|
/// Routes of type AudioVideo will be built as two separate routes, audio and video. If
|
||||||
|
/// a route is discovered, a new RouteDescriptor is returned. If one or both parts
|
||||||
|
/// of an audio/video route are discovered a route descriptor is returned. If no route is
|
||||||
|
/// discovered, then null is returned
|
||||||
|
/// </summary>
|
||||||
|
public static (RouteDescriptor, RouteDescriptor) GetRouteToSource(this IRoutingInputs destination, IRoutingOutputs source, eRoutingSignalType signalType, RoutingInputPort destinationPort, RoutingOutputPort sourcePort)
|
||||||
|
{
|
||||||
|
// if it's a single signal type, find the route
|
||||||
|
if (!signalType.HasFlag(eRoutingSignalType.AudioVideo))
|
||||||
|
{
|
||||||
|
var singleTypeRouteDescriptor = new RouteDescriptor(source, destination, destinationPort, signalType);
|
||||||
|
Debug.LogMessage(LogEventLevel.Debug, "Attempting to build source route from {sourceKey} of type {type}", destination, source.Key, signalType);
|
||||||
|
|
||||||
|
if (!destination.GetRouteToSource(source, null, null, signalType, 0, singleTypeRouteDescriptor, destinationPort, sourcePort))
|
||||||
|
singleTypeRouteDescriptor = null;
|
||||||
|
|
||||||
|
var routes = singleTypeRouteDescriptor?.Routes ?? new List<RouteSwitchDescriptor>();
|
||||||
|
foreach (var route in routes)
|
||||||
|
{
|
||||||
|
Debug.LogMessage(LogEventLevel.Verbose, "Route for device: {route}", destination, route.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return (singleTypeRouteDescriptor, null);
|
||||||
|
}
|
||||||
|
// otherwise, audioVideo needs to be handled as two steps.
|
||||||
|
|
||||||
|
Debug.LogMessage(LogEventLevel.Debug, "Attempting to build source route from {sourceKey} of type {type}", destination, source.Key);
|
||||||
|
|
||||||
|
var audioRouteDescriptor = new RouteDescriptor(source, destination, destinationPort, eRoutingSignalType.Audio);
|
||||||
|
|
||||||
|
var audioSuccess = destination.GetRouteToSource(source, null, null, eRoutingSignalType.Audio, 0, audioRouteDescriptor, destinationPort, sourcePort);
|
||||||
|
|
||||||
|
if (!audioSuccess)
|
||||||
|
Debug.LogMessage(LogEventLevel.Debug, "Cannot find audio route to {0}", destination, source.Key);
|
||||||
|
|
||||||
|
var videoRouteDescriptor = new RouteDescriptor(source, destination, destinationPort, eRoutingSignalType.Video);
|
||||||
|
|
||||||
|
var videoSuccess = destination.GetRouteToSource(source, null, null, eRoutingSignalType.Video, 0, videoRouteDescriptor, destinationPort, sourcePort);
|
||||||
|
|
||||||
|
if (!videoSuccess)
|
||||||
|
Debug.LogMessage(LogEventLevel.Debug, "Cannot find video route to {0}", destination, source.Key);
|
||||||
|
|
||||||
|
foreach (var route in audioRouteDescriptor.Routes)
|
||||||
|
{
|
||||||
|
Debug.LogMessage(LogEventLevel.Verbose, "Audio route for device: {route}", destination, route.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var route in videoRouteDescriptor.Routes)
|
||||||
|
{
|
||||||
|
Debug.LogMessage(LogEventLevel.Verbose, "Video route for device: {route}", destination, route.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!audioSuccess && !videoSuccess)
|
||||||
|
return (null, null);
|
||||||
|
|
||||||
|
|
||||||
|
return (audioRouteDescriptor, videoRouteDescriptor);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ReleaseAndMakeRoute(IRoutingInputs destination, IRoutingOutputs source, eRoutingSignalType signalType, RoutingInputPort destinationPort = null, RoutingOutputPort sourcePort = null)
|
||||||
|
{
|
||||||
|
if (destination == null) throw new ArgumentNullException(nameof(destination));
|
||||||
|
if (source == null) throw new ArgumentNullException(nameof(source));
|
||||||
|
if (destinationPort == null) Debug.LogMessage(LogEventLevel.Information, "Destination port is null");
|
||||||
|
if (sourcePort == null) Debug.LogMessage(LogEventLevel.Information, "Source port is null");
|
||||||
|
|
||||||
|
var routeRequest = new RouteRequest
|
||||||
|
{
|
||||||
|
Destination = destination,
|
||||||
|
DestinationPort = destinationPort,
|
||||||
|
Source = source,
|
||||||
|
SourcePort = sourcePort,
|
||||||
|
SignalType = signalType
|
||||||
|
};
|
||||||
|
|
||||||
|
var coolingDevice = destination as IWarmingCooling;
|
||||||
|
|
||||||
|
//We already have a route request for this device, and it's a cooling device and is cooling
|
||||||
|
if (RouteRequests.TryGetValue(destination.Key, out RouteRequest existingRouteRequest) && coolingDevice != null && coolingDevice.IsCoolingDownFeedback.BoolValue == true)
|
||||||
|
{
|
||||||
|
coolingDevice.IsCoolingDownFeedback.OutputChange -= existingRouteRequest.HandleCooldown;
|
||||||
|
|
||||||
|
coolingDevice.IsCoolingDownFeedback.OutputChange += routeRequest.HandleCooldown;
|
||||||
|
|
||||||
|
RouteRequests[destination.Key] = routeRequest;
|
||||||
|
|
||||||
|
Debug.LogMessage(LogEventLevel.Information, "Device: {destination} is cooling down and already has a routing request stored. Storing new route request to route to source key: {sourceKey}", null, destination.Key, routeRequest.Source.Key);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//New Request
|
||||||
|
if (coolingDevice != null && coolingDevice.IsCoolingDownFeedback.BoolValue == true)
|
||||||
|
{
|
||||||
|
coolingDevice.IsCoolingDownFeedback.OutputChange += routeRequest.HandleCooldown;
|
||||||
|
|
||||||
|
RouteRequests.Add(destination.Key, routeRequest);
|
||||||
|
|
||||||
|
Debug.LogMessage(LogEventLevel.Information, "Device: {destination} is cooling down. Storing route request to route to source key: {sourceKey}", null, destination.Key, routeRequest.Source.Key);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RouteRequests.ContainsKey(destination.Key) && coolingDevice != null && coolingDevice.IsCoolingDownFeedback.BoolValue == false)
|
||||||
|
{
|
||||||
|
var handledRequest = RouteRequests[destination.Key];
|
||||||
|
|
||||||
|
coolingDevice.IsCoolingDownFeedback.OutputChange -= handledRequest.HandleCooldown;
|
||||||
|
|
||||||
|
RouteRequests.Remove(destination.Key);
|
||||||
|
|
||||||
|
Debug.LogMessage(LogEventLevel.Information, "Device: {destination} is NOT cooling down. Removing stored route request and routing to source key: {sourceKey}", null, destination.Key, routeRequest.Source.Key);
|
||||||
|
}
|
||||||
|
|
||||||
|
routeRequestQueue.Enqueue(new ReleaseRouteQueueItem(ReleaseRouteInternal, destination,destinationPort?.Key ?? string.Empty));
|
||||||
|
|
||||||
|
routeRequestQueue.Enqueue(new RouteRequestQueueItem(RunRouteRequest, routeRequest));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void RunRouteRequest(RouteRequest request)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (request.Source == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var (audioOrSingleRoute, videoRoute) = request.Destination.GetRouteToSource(request.Source, request.SignalType, request.DestinationPort, request.SourcePort);
|
||||||
|
|
||||||
|
if (audioOrSingleRoute == null && videoRoute == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
RouteDescriptorCollection.DefaultCollection.AddRouteDescriptor(audioOrSingleRoute);
|
||||||
|
|
||||||
|
if (videoRoute != null)
|
||||||
|
{
|
||||||
|
RouteDescriptorCollection.DefaultCollection.AddRouteDescriptor(videoRoute);
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.LogMessage(LogEventLevel.Verbose, "Executing full route", request.Destination);
|
||||||
|
|
||||||
|
audioOrSingleRoute.ExecuteRoutes();
|
||||||
|
videoRoute?.ExecuteRoutes();
|
||||||
|
} catch(Exception ex)
|
||||||
|
{
|
||||||
|
Debug.LogMessage(ex, "Exception Running Route Request {request}", null, request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Will release the existing route on the destination, if it is found in
|
||||||
|
/// RouteDescriptorCollection.DefaultCollection
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="destination"></param>
|
||||||
|
private static void ReleaseRouteInternal(IRoutingInputs destination, string inputPortKey)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Debug.LogMessage(LogEventLevel.Information, "Release route for '{destination}':'{inputPortKey}'", destination?.Key ?? null, string.IsNullOrEmpty(inputPortKey) ? "auto" : inputPortKey);
|
||||||
|
|
||||||
|
if (RouteRequests.TryGetValue(destination.Key, out RouteRequest existingRequest) && destination is IWarmingCooling)
|
||||||
|
{
|
||||||
|
var coolingDevice = destination as IWarmingCooling;
|
||||||
|
|
||||||
|
coolingDevice.IsCoolingDownFeedback.OutputChange -= existingRequest.HandleCooldown;
|
||||||
|
}
|
||||||
|
|
||||||
|
RouteRequests.Remove(destination.Key);
|
||||||
|
|
||||||
|
var current = RouteDescriptorCollection.DefaultCollection.RemoveRouteDescriptor(destination, inputPortKey);
|
||||||
|
if (current != null)
|
||||||
|
{
|
||||||
|
Debug.LogMessage(LogEventLevel.Information, "Releasing current route: {0}", destination, current.Source.Key);
|
||||||
|
current.ReleaseRoutes();
|
||||||
|
}
|
||||||
|
} catch (Exception ex)
|
||||||
|
{
|
||||||
|
Debug.LogMessage(ex, "Exception releasing route for '{destination}':'{inputPortKey}'",null, destination?.Key ?? null, string.IsNullOrEmpty(inputPortKey) ? "auto" : inputPortKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The recursive part of this. Will stop on each device, search its inputs for the
|
||||||
|
/// desired source and if not found, invoke this function for the each input port
|
||||||
|
/// hoping to find the source.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="destination"></param>
|
||||||
|
/// <param name="source"></param>
|
||||||
|
/// <param name="destinationPort">The RoutingOutputPort whose link is being checked for a route</param>
|
||||||
|
/// <param name="alreadyCheckedDevices">Prevents Devices from being twice-checked</param>
|
||||||
|
/// <param name="signalType">This recursive function should not be called with AudioVideo</param>
|
||||||
|
/// <param name="cycle">Just an informational counter</param>
|
||||||
|
/// <param name="routeTable">The RouteDescriptor being populated as the route is discovered</param>
|
||||||
|
/// <returns>true if source is hit</returns>
|
||||||
|
private static bool GetRouteToSource(this IRoutingInputs destination, IRoutingOutputs source,
|
||||||
|
RoutingOutputPort outputPortToUse, List<IRoutingInputsOutputs> alreadyCheckedDevices,
|
||||||
|
eRoutingSignalType signalType, int cycle, RouteDescriptor routeTable, RoutingInputPort destinationPort, RoutingOutputPort sourcePort)
|
||||||
|
{
|
||||||
|
cycle++;
|
||||||
|
|
||||||
|
Debug.LogMessage(LogEventLevel.Verbose, "GetRouteToSource: {cycle} {sourceKey}:{sourcePortKey}--> {destinationKey}:{destinationPortKey} {type}", null, cycle, source.Key, sourcePort?.Key ?? "auto", destination.Key, destinationPort?.Key ?? "auto", signalType.ToString());
|
||||||
|
|
||||||
|
RoutingInputPort goodInputPort = null;
|
||||||
|
|
||||||
|
IEnumerable<TieLine> destinationTieLines;
|
||||||
|
TieLine directTie = null;
|
||||||
|
|
||||||
|
if (destinationPort == null)
|
||||||
|
{
|
||||||
|
|
||||||
|
destinationTieLines = TieLineCollection.Default.Where(t =>
|
||||||
|
t.DestinationPort.ParentDevice.Key == destination.Key && (t.Type == signalType || t.Type.HasFlag(eRoutingSignalType.AudioVideo)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
destinationTieLines = TieLineCollection.Default.Where(t => t.DestinationPort.ParentDevice.Key == destination.Key && t.DestinationPort.Key == destinationPort.Key && (t.Type == signalType || t.Type.HasFlag(eRoutingSignalType.AudioVideo)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// find the TieLine without a port
|
||||||
|
if (destinationPort == null && sourcePort == null)
|
||||||
|
{
|
||||||
|
directTie = destinationTieLines.FirstOrDefault(t => t.DestinationPort.ParentDevice.Key == destination.Key && t.SourcePort.ParentDevice.Key == source.Key);
|
||||||
|
}
|
||||||
|
// find a tieLine to a specific destination port without a specific source port
|
||||||
|
else if (destinationPort != null && sourcePort == null)
|
||||||
|
{
|
||||||
|
directTie = destinationTieLines.FirstOrDefault(t => t.DestinationPort.ParentDevice.Key == destination.Key && t.DestinationPort.Key == destinationPort.Key && t.SourcePort.ParentDevice.Key == source.Key);
|
||||||
|
}
|
||||||
|
// find a tieline to a specific source port without a specific destination port
|
||||||
|
else if (destinationPort == null & sourcePort != null)
|
||||||
|
{
|
||||||
|
directTie = destinationTieLines.FirstOrDefault(t => t.DestinationPort.ParentDevice.Key == destination.Key && t.SourcePort.ParentDevice.Key == source.Key && t.SourcePort.Key == sourcePort.Key);
|
||||||
|
}
|
||||||
|
// find a tieline to a specific source port and destination port
|
||||||
|
else if (destinationPort != null && sourcePort != null)
|
||||||
|
{
|
||||||
|
directTie = destinationTieLines.FirstOrDefault(t => t.DestinationPort.ParentDevice.Key == destination.Key && t.DestinationPort.Key == destinationPort.Key && t.SourcePort.ParentDevice.Key == source.Key && t.SourcePort.Key == sourcePort.Key);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (directTie != null) // Found a tie directly to the source
|
||||||
|
{
|
||||||
|
goodInputPort = directTie.DestinationPort;
|
||||||
|
}
|
||||||
|
else // no direct-connect. Walk back devices.
|
||||||
|
{
|
||||||
|
Debug.LogMessage(LogEventLevel.Verbose, "is not directly connected to {sourceKey}. Walking down tie lines", destination, source.Key);
|
||||||
|
|
||||||
|
// No direct tie? Run back out on the inputs' attached devices...
|
||||||
|
// Only the ones that are routing devices
|
||||||
|
var midpointTieLines = destinationTieLines.Where(t => t.SourcePort.ParentDevice is IRoutingInputsOutputs);
|
||||||
|
|
||||||
|
//Create a list for tracking already checked devices to avoid loops, if it doesn't already exist from previous iteration
|
||||||
|
if (alreadyCheckedDevices == null)
|
||||||
|
alreadyCheckedDevices = new List<IRoutingInputsOutputs>();
|
||||||
|
alreadyCheckedDevices.Add(destination as IRoutingInputsOutputs);
|
||||||
|
|
||||||
|
foreach (var tieLine in midpointTieLines)
|
||||||
|
{
|
||||||
|
var midpointDevice = tieLine.SourcePort.ParentDevice as IRoutingInputsOutputs;
|
||||||
|
|
||||||
|
// Check if this previous device has already been walked
|
||||||
|
if (alreadyCheckedDevices.Contains(midpointDevice))
|
||||||
|
{
|
||||||
|
Debug.LogMessage(LogEventLevel.Verbose, "Skipping input {midpointDeviceKey} on {destinationKey}, this was already checked", destination, midpointDevice.Key, destination.Key);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var midpointOutputPort = tieLine.SourcePort;
|
||||||
|
|
||||||
|
Debug.LogMessage(LogEventLevel.Verbose, "Trying to find route on {midpointDeviceKey}", destination, midpointDevice.Key);
|
||||||
|
|
||||||
|
// haven't seen this device yet. Do it. Pass the output port to the next
|
||||||
|
// level to enable switching on success
|
||||||
|
var upstreamRoutingSuccess = midpointDevice.GetRouteToSource(source, midpointOutputPort,
|
||||||
|
alreadyCheckedDevices, signalType, cycle, routeTable, null, sourcePort);
|
||||||
|
|
||||||
|
if (upstreamRoutingSuccess)
|
||||||
|
{
|
||||||
|
Debug.LogMessage(LogEventLevel.Verbose, "Upstream device route found", destination);
|
||||||
|
Debug.LogMessage(LogEventLevel.Verbose, "Route found on {midpointDeviceKey}", destination, midpointDevice.Key);
|
||||||
|
Debug.LogMessage(LogEventLevel.Verbose, "TieLine: SourcePort: {SourcePort} DestinationPort: {DestinationPort}", destination, tieLine.SourcePort, tieLine.DestinationPort);
|
||||||
|
goodInputPort = tieLine.DestinationPort;
|
||||||
|
break; // Stop looping the inputs in this cycle
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (goodInputPort == null)
|
||||||
|
{
|
||||||
|
Debug.LogMessage(LogEventLevel.Verbose, "No route found to {0}", destination, source.Key);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// we have a route on corresponding inputPort. *** Do the route ***
|
||||||
|
|
||||||
|
if (destination is IRoutingSink)
|
||||||
|
{
|
||||||
|
// it's a sink device
|
||||||
|
routeTable.Routes.Add(new RouteSwitchDescriptor(goodInputPort));
|
||||||
|
}
|
||||||
|
else if (destination is IRouting)
|
||||||
|
{
|
||||||
|
routeTable.Routes.Add(new RouteSwitchDescriptor(outputPortToUse, goodInputPort));
|
||||||
|
}
|
||||||
|
else // device is merely IRoutingInputOutputs
|
||||||
|
Debug.LogMessage(LogEventLevel.Verbose, "No routing. Passthrough device", destination);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/* Unmerged change from project 'PepperDash.Essentials.Core (net6)'
|
||||||
|
Before:
|
||||||
|
namespace PepperDash.Essentials.Core.Routing.Interfaces
|
||||||
|
After:
|
||||||
|
using PepperDash;
|
||||||
|
using PepperDash.Essentials;
|
||||||
|
using PepperDash.Essentials.Core;
|
||||||
|
using PepperDash.Essentials.Core.Routing;
|
||||||
|
using PepperDash.Essentials.Core.Routing;
|
||||||
|
using PepperDash.Essentials.Core.Routing.Interfaces
|
||||||
|
*/
|
||||||
|
namespace PepperDash.Essentials.Core
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The handler type for a Room's SourceInfoChange
|
||||||
|
/// </summary>
|
||||||
|
public delegate void SourceInfoChangeHandler(SourceListItem info, ChangeType type);
|
||||||
|
//*******************************************************************************************
|
||||||
|
// Interfaces
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// For rooms with a single presentation source, change event
|
||||||
|
/// </summary>
|
||||||
|
public interface IHasCurrentSourceInfoChange
|
||||||
|
{
|
||||||
|
string CurrentSourceInfoKey { get; set; }
|
||||||
|
SourceListItem CurrentSourceInfo { get; set; }
|
||||||
|
event SourceInfoChangeHandler CurrentSourceChange;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Routing
|
namespace PepperDash.Essentials.Core.Routing
|
||||||
{
|
{
|
||||||
public interface IVideoSync: IKeyed
|
public interface IVideoSync : IKeyed
|
||||||
{
|
{
|
||||||
bool VideoSyncDetected { get; }
|
bool VideoSyncDetected { get; }
|
||||||
|
|
||||||
|
|||||||
10
src/PepperDash.Essentials.Core/Routing/IRmcRouting.cs
Normal file
10
src/PepperDash.Essentials.Core/Routing/IRmcRouting.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
namespace PepperDash.Essentials.Core
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Defines a receiver that has internal routing (DM-RMC-4K-Z-SCALER-C)
|
||||||
|
/// </summary>
|
||||||
|
public interface IRmcRouting : IRoutingNumeric
|
||||||
|
{
|
||||||
|
IntFeedback AudioVideoSourceNumericFeedback { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user