Compare commits

..

5 Commits

Author SHA1 Message Date
Nick Genovese
edefe0a0bf feat: removed crestron io devices 2023-10-31 10:25:28 -04:00
Nick Genovese
9b4a33f3b9 feat: removed deprecated diplay devices 2023-10-26 22:20:07 -04:00
Nick Genovese
7f5e991921 feat: updated namespaces on a few things 2023-10-26 22:19:47 -04:00
Nick Genovese
48dd29ae83 feat: removed DSP, Lutron, Analog Way, TVOne 2023-10-26 22:18:10 -04:00
Nick Genovese
154dbb8e2a feature: removed everything that had obsolete marked 2023-10-26 21:53:10 -04:00
409 changed files with 52974 additions and 10915 deletions

View File

@@ -0,0 +1,37 @@
name: Add bugs to bugs project
on:
issues:
types:
- opened
- labeled
jobs:
check-secret:
runs-on: ubuntu-latest
outputs:
my-key: ${{ steps.my-key.outputs.defined }}
steps:
- id: my-key
if: "${{ env.MY_KEY != '' }}"
run: echo "::set-output name=defined::true"
env:
MY_KEY: ${{ secrets.PROJECT_URL }}
throw-error:
name: Check
runs-on: ubuntu-latest
needs: [check-secret]
if: needs.check-secret.outputs.my-key != 'true'
steps:
- run: echo "The Project URL Repo Secret is empty"
add-to-project:
name: Add issue to project
runs-on: ubuntu-latest
needs: [check-secret]
if: needs.check-secret.outputs.my-key == 'true'
steps:
- uses: actions/add-to-project@main
with:
project-url: ${{ secrets.PROJECT_URL }}
github-token: ${{ secrets.GH_PROJECTS_PASSWORD }}

View File

@@ -66,55 +66,6 @@ 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: |
@@ -123,9 +74,12 @@ 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)'
generateReleaseNotes: true generateReleaseNotes: true
prerelease: ${{contains('debug', env.BUILD_TYPE)}} prerelease: ${{contains('debug', env.BUILD_TYPE)}}
tag: ${{ steps.setVersion.outputs.version }} tag: ${{ steps.setVersion.outputs.version }}

View File

@@ -37,14 +37,12 @@ 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
with: with:
updateRelease: true updateRelease: true
artifacts: 'output\**\*.*(cpz|cplz)' artifacts: 'output\*.*(cpz|cplz)'
tag: ${{ steps.setVersion.outputs.version }} tag: ${{ steps.setVersion.outputs.version }}
- name: Setup Nuget - name: Setup Nuget
run: | run: |

3
.gitignore vendored
View File

@@ -389,6 +389,3 @@ MigrationBackup/
# Fody - auto-generated XML schema # Fody - auto-generated XML schema
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
/._PepperDash.Essentials.sln
.vscode/settings.json

View File

@@ -3,33 +3,32 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.4.33213.308 VisualStudioVersion = 17.4.33213.308
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PepperDash.Essentials.Devices.Common", "src\PepperDash.Essentials.Devices.Common\PepperDash.Essentials.Devices.Common.csproj", "{53E204B7-97DD-441D-A96C-721DF014DF82}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PepperDash.Essentials.Devices.Common", "src\PepperDash.Essentials.Devices.Common\PepperDash.Essentials.Devices.Common.csproj", "{53E204B7-97DD-441D-A96C-721DF014DF82}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PepperDash.Essentials", "src\PepperDash.Essentials\PepperDash.Essentials.csproj", "{CB3B11BA-625C-4D35-B663-FDC5BE9A230E}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PepperDash.Essentials.DM", "src\PepperDash.Essentials.DM\PepperDash.Essentials.DM.csproj", "{08EB4B98-9B4D-455A-81E0-4F913E08ADB5}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PepperDash.Essentials.Core", "src\PepperDash.Essentials.Core\PepperDash.Essentials.Core.csproj", "{3D192FED-8FFC-4CB5-B5F7-BA307ABA254B}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PepperDash.Essentials", "src\PepperDash.Essentials\PepperDash.Essentials.csproj", "{CB3B11BA-625C-4D35-B663-FDC5BE9A230E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PepperDash.Essentials.Core", "src\PepperDash.Essentials.Core\PepperDash.Essentials.Core.csproj", "{3D192FED-8FFC-4CB5-B5F7-BA307ABA254B}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug 4.7.2|Any CPU = Debug 4.7.2|Any CPU
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{53E204B7-97DD-441D-A96C-721DF014DF82}.Debug 4.7.2|Any CPU.ActiveCfg = Debug 4.7.2|Any CPU
{53E204B7-97DD-441D-A96C-721DF014DF82}.Debug 4.7.2|Any CPU.Build.0 = Debug 4.7.2|Any CPU
{53E204B7-97DD-441D-A96C-721DF014DF82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {53E204B7-97DD-441D-A96C-721DF014DF82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{53E204B7-97DD-441D-A96C-721DF014DF82}.Debug|Any CPU.Build.0 = Debug|Any CPU {53E204B7-97DD-441D-A96C-721DF014DF82}.Debug|Any CPU.Build.0 = Debug|Any CPU
{53E204B7-97DD-441D-A96C-721DF014DF82}.Release|Any CPU.ActiveCfg = Release|Any CPU {53E204B7-97DD-441D-A96C-721DF014DF82}.Release|Any CPU.ActiveCfg = Release|Any CPU
{53E204B7-97DD-441D-A96C-721DF014DF82}.Release|Any CPU.Build.0 = Release|Any CPU {53E204B7-97DD-441D-A96C-721DF014DF82}.Release|Any CPU.Build.0 = Release|Any CPU
{CB3B11BA-625C-4D35-B663-FDC5BE9A230E}.Debug 4.7.2|Any CPU.ActiveCfg = Debug 4.7.2|Any CPU {08EB4B98-9B4D-455A-81E0-4F913E08ADB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CB3B11BA-625C-4D35-B663-FDC5BE9A230E}.Debug 4.7.2|Any CPU.Build.0 = Debug 4.7.2|Any CPU {08EB4B98-9B4D-455A-81E0-4F913E08ADB5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{08EB4B98-9B4D-455A-81E0-4F913E08ADB5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{08EB4B98-9B4D-455A-81E0-4F913E08ADB5}.Release|Any CPU.Build.0 = Release|Any CPU
{CB3B11BA-625C-4D35-B663-FDC5BE9A230E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CB3B11BA-625C-4D35-B663-FDC5BE9A230E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CB3B11BA-625C-4D35-B663-FDC5BE9A230E}.Debug|Any CPU.Build.0 = Debug|Any CPU {CB3B11BA-625C-4D35-B663-FDC5BE9A230E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CB3B11BA-625C-4D35-B663-FDC5BE9A230E}.Release|Any CPU.ActiveCfg = Release|Any CPU {CB3B11BA-625C-4D35-B663-FDC5BE9A230E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CB3B11BA-625C-4D35-B663-FDC5BE9A230E}.Release|Any CPU.Build.0 = Release|Any CPU {CB3B11BA-625C-4D35-B663-FDC5BE9A230E}.Release|Any CPU.Build.0 = Release|Any CPU
{3D192FED-8FFC-4CB5-B5F7-BA307ABA254B}.Debug 4.7.2|Any CPU.ActiveCfg = Debug 4.7.2|Any CPU
{3D192FED-8FFC-4CB5-B5F7-BA307ABA254B}.Debug 4.7.2|Any CPU.Build.0 = Debug 4.7.2|Any CPU
{3D192FED-8FFC-4CB5-B5F7-BA307ABA254B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3D192FED-8FFC-4CB5-B5F7-BA307ABA254B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3D192FED-8FFC-4CB5-B5F7-BA307ABA254B}.Debug|Any CPU.Build.0 = Debug|Any CPU {3D192FED-8FFC-4CB5-B5F7-BA307ABA254B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3D192FED-8FFC-4CB5-B5F7-BA307ABA254B}.Release|Any CPU.ActiveCfg = Release|Any CPU {3D192FED-8FFC-4CB5-B5F7-BA307ABA254B}.Release|Any CPU.ActiveCfg = Release|Any CPU

View File

@@ -6,7 +6,6 @@
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.

View File

@@ -1,7 +1,6 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<Version>2.0.0-local</Version> <Version>2.0.0-local</Version>
<InformationalVersion>$(Version)</InformationalVersion>
<Authors>PepperDash Technologies</Authors> <Authors>PepperDash Technologies</Authors>
<Company>PepperDash Technologies</Company> <Company>PepperDash Technologies</Company>
<Product>PepperDash Essentials</Product> <Product>PepperDash Essentials</Product>

View File

@@ -1,116 +1,28 @@
<Project> <Project>
<ItemGroup> <ItemGroup>
<!-- Include CPZ files from multiple possible locations --> <None Include="$(TargetDir)\$(TargetName).$(Version).cpz" Condition="$(ProjectType) == 'Program'">
<None Include="$(TargetDir)*.cpz" Condition="$(ProjectType) == 'Program'">
<Pack>true</Pack> <Pack>true</Pack>
<PackagePath>build;</PackagePath> <PackagePath>content;</PackagePath>
</None> </None>
<None Include="$(OutputPath)*.cpz" Condition="$(ProjectType) == 'Program'"> <None Include="$(PackageOutputPath)\$(TargetName).$(Version).cplz" Condition="$(ProjectType) == 'ProgramLibrary'">
<Pack>true</Pack> <Pack>true</Pack>
<PackagePath>build;</PackagePath> <PackagePath>content;</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>
<PackagePath>build;</PackagePath>
</None>
<None Include="$(PackageOutputPath)\$(AssemblyName)\*.cplz" Condition="$(ProjectType) == 'ProgramLibrary'">
<Pack>true</Pack>
<PackagePath>build;</PackagePath>
</None> </None>
</ItemGroup> </ItemGroup>
<Target Name="Create CPLZ" AfterTargets="Build; AfterRebuild" Condition="$(ProjectType) == 'ProgramLibrary' And $(TargetDir) != ''"> <Target Name="Create CPLZ" AfterTargets="Build; Rebuild" Condition="$(ProjectType) == 'ProgramLibrary'">
<Message Text="Creating CPLZ $(TargetDir)" Importance="high" /> <Message Text="Creating CPLZ"></Message>
<Message Text="PackageOutputPath: $(PackageOutputPath)" Importance="high" /> <MakeDir Directories="$(PackageOutputPath)" Condition="!Exists($(PackageOutputPath))"></MakeDir>
<Message Text="AssemblyName: $(AssemblyName)" Importance="high" /> <ZipDirectory SourceDirectory="$(TargetDir)" DestinationFile="$(PackageOutputPath)\$(TargetName).$(Version).cplz" Overwrite="true"/>
<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)\$(AssemblyName)" Condition="!Exists('$(PackageOutputPath)\$(AssemblyName)')" />
<ZipDirectory SourceDirectory="$(TargetDir)" DestinationFile="$(PackageOutputPath)\$(AssemblyName)\$(TargetName).$(Version).$(TargetFramework).cplz" Overwrite="true"/>
</Target> </Target>
<Target Name="Debug Variables" BeforeTargets="Build"> <Target Name="Clean CPLZ" AfterTargets="AfterClean" Condition="$(ProjectType) == 'ProgramLibrary'">
<Message Text="================ Debug Variables ================" Importance="high" /> <Delete Files="$(PackageOutputPath)\$(TargetName).$(Version).cplz"/>
<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 NET472" <Target Name="Copy CPZ" AfterTargets="SimplSharpPostProcess" Condition="$(ProjectType) == 'Program'">
AfterTargets="Build" <Message Text="Copying CPZ"></Message>
DependsOnTargets="BuildDependencies" <Move SourceFiles="$(TargetDir)\$(TargetName).cpz" DestinationFiles="$(TargetDir)\$(TargetName).$(Version).cpz" />
Condition="'$(ProjectType)' == 'Program' And '$(TargetFramework)' == 'net472'"> <Copy SourceFiles="$(TargetDir)\$(TargetName).$(Version).cpz" DestinationFiles="$(PackageOutputPath)\$(TargetName).$(Version).cpz"/>
<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>
<Target Name="Copy CPZ NET6" <Target Name="Clean CPZ" AfterTargets="AfterClean" Condition="$(ProjectType) == 'Program'">
AfterTargets="Build" <Delete Files="$(PackageOutputPath)\$(TargetName).$(Version).cpz"/>
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="&quot;$(SimplSharpCompilerPath)&quot; &quot;$(MSBuildProjectDirectory)&quot; &quot;$(TargetDir)&quot;"
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>

View File

@@ -1,23 +1,97 @@
extern alias Full;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using System.Reflection; using Crestron.SimplSharp.Reflection;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DeviceSupport;
using Crestron.SimplSharpPro.EthernetCommunication; using Crestron.SimplSharpPro.EthernetCommunication;
using Newtonsoft.Json; using Full.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>
@@ -74,11 +148,11 @@ namespace PepperDash.Essentials.Core.Bridges
private void LinkDevices() private void LinkDevices()
{ {
Debug.LogMessage(LogEventLevel.Debug, this, "Linking Devices..."); Debug.Console(1, this, "Linking Devices...");
if (PropertiesConfig.Devices == null) if (PropertiesConfig.Devices == null)
{ {
Debug.LogMessage(LogEventLevel.Debug, this, "No devices linked to this bridge"); Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "No devices linked to this bridge");
return; return;
} }
@@ -91,17 +165,21 @@ namespace PepperDash.Essentials.Core.Bridges
continue; continue;
} }
Debug.LogMessage(LogEventLevel.Debug, this, "Linking Device: '{0}'", device.Key); Debug.Console(1, this, "Linking Device: '{0}'", device.Key);
if (device is IBridgeAdvanced bridge) if (!typeof (IBridgeAdvanced).IsAssignableFrom(device.GetType().GetCType()))
{ {
bridge.LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this); Debug.Console(0, this, Debug.ErrorLogLevel.Notice,
"{0} is not compatible with this bridge type. Please use 'eiscapi' instead, or updae the device.",
device.Key);
continue; continue;
} }
Debug.LogMessage(LogEventLevel.Information, this, var bridge = device as IBridgeAdvanced;
"{0} is not compatible with this bridge type. Please use 'eiscapi' instead, or updae the device.", if (bridge != null)
device.Key); {
bridge.LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this);
}
} }
} }
@@ -116,20 +194,20 @@ namespace PepperDash.Essentials.Core.Bridges
if (registerResult != eDeviceRegistrationUnRegistrationResponse.Success) if (registerResult != eDeviceRegistrationUnRegistrationResponse.Success)
{ {
Debug.LogMessage(LogEventLevel.Verbose, this, "Registration result: {0}", registerResult); Debug.Console(2, this, Debug.ErrorLogLevel.Error, "Registration result: {0}", registerResult);
return; return;
} }
Debug.LogMessage(LogEventLevel.Debug, this, "EISC registration successful"); Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "EISC registration successful");
} }
public void LinkRooms() public void LinkRooms()
{ {
Debug.LogMessage(LogEventLevel.Debug, this, "Linking Rooms..."); Debug.Console(1, this, "Linking Rooms...");
if (PropertiesConfig.Rooms == null) if (PropertiesConfig.Rooms == null)
{ {
Debug.LogMessage(LogEventLevel.Debug, this, "No rooms linked to this bridge."); Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "No rooms linked to this bridge.");
return; return;
} }
@@ -139,7 +217,7 @@ namespace PepperDash.Essentials.Core.Bridges
if (rm == null) if (rm == null)
{ {
Debug.LogMessage(LogEventLevel.Debug, this, Debug.Console(1, this, Debug.ErrorLogLevel.Notice,
"Room {0} does not implement IBridgeAdvanced. Skipping...", room.RoomKey); "Room {0} does not implement IBridgeAdvanced. Skipping...", room.RoomKey);
continue; continue;
} }
@@ -161,7 +239,7 @@ namespace PepperDash.Essentials.Core.Bridges
} }
else else
{ {
Debug.LogMessage(LogEventLevel.Verbose, this, "Unable to add join map with key '{0}'. Key already exists in JoinMaps dictionary", deviceKey); Debug.Console(2, this, "Unable to add join map with key '{0}'. Key already exists in JoinMaps dictionary", deviceKey);
} }
} }
@@ -170,11 +248,11 @@ namespace PepperDash.Essentials.Core.Bridges
/// </summary> /// </summary>
public virtual void PrintJoinMaps() public virtual void PrintJoinMaps()
{ {
CrestronConsole.ConsoleCommandResponse("Join Maps for EISC IPID: {0}\r\n", Eisc.ID.ToString("X")); Debug.Console(0, this, "Join Maps for EISC IPID: {0}", Eisc.ID.ToString("X"));
foreach (var joinMap in JoinMaps) foreach (var joinMap in JoinMaps)
{ {
CrestronConsole.ConsoleCommandResponse("Join map for device '{0}':", joinMap.Key); Debug.Console(0, "Join map for device '{0}':", joinMap.Key);
joinMap.Value.PrintJoinMapInfo(); joinMap.Value.PrintJoinMapInfo();
} }
} }
@@ -183,11 +261,11 @@ namespace PepperDash.Essentials.Core.Bridges
/// </summary> /// </summary>
public virtual void MarkdownForBridge(string bridgeKey) public virtual void MarkdownForBridge(string bridgeKey)
{ {
Debug.LogMessage(LogEventLevel.Information, this, "Writing Joinmaps to files for EISC IPID: {0}", Eisc.ID.ToString("X")); Debug.Console(0, this, "Writing Joinmaps to files for EISC IPID: {0}", Eisc.ID.ToString("X"));
foreach (var joinMap in JoinMaps) foreach (var joinMap in JoinMaps)
{ {
Debug.LogMessage(LogEventLevel.Information, "Generating markdown for device '{0}':", joinMap.Key); Debug.Console(0, "Generating markdown for device '{0}':", joinMap.Key);
joinMap.Value.MarkdownJoinMapInfo(joinMap.Key, bridgeKey); joinMap.Value.MarkdownJoinMapInfo(joinMap.Key, bridgeKey);
} }
} }
@@ -202,11 +280,11 @@ namespace PepperDash.Essentials.Core.Bridges
if (joinMap == null) if (joinMap == null)
{ {
Debug.LogMessage(LogEventLevel.Information, this, "Unable to find joinMap for device with key: '{0}'", deviceKey); Debug.Console(0, this, "Unable to find joinMap for device with key: '{0}'", deviceKey);
return; return;
} }
Debug.LogMessage(LogEventLevel.Information, "Join map for device '{0}' on EISC '{1}':", deviceKey, Key); Debug.Console(0, "Join map for device '{0}' on EISC '{1}':", deviceKey, Key);
joinMap.PrintJoinMapInfo(); joinMap.PrintJoinMapInfo();
} }
/// <summary> /// <summary>
@@ -219,11 +297,11 @@ namespace PepperDash.Essentials.Core.Bridges
if (joinMap == null) if (joinMap == null)
{ {
Debug.LogMessage(LogEventLevel.Information, this, "Unable to find joinMap for device with key: '{0}'", deviceKey); Debug.Console(0, this, "Unable to find joinMap for device with key: '{0}'", deviceKey);
return; return;
} }
Debug.LogMessage(LogEventLevel.Information, "Join map for device '{0}' on EISC '{1}':", deviceKey, Key); Debug.Console(0, "Join map for device '{0}' on EISC '{1}':", deviceKey, Key);
joinMap.MarkdownJoinMapInfo(deviceKey, bridgeKey); joinMap.MarkdownJoinMapInfo(deviceKey, bridgeKey);
} }
@@ -244,11 +322,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.LogMessage(LogEventLevel.Verbose, this, "Executing Action: {0}", uo.ToString()); Debug.Console(2, this, "Executing Action: {0}", uo.ToString());
uo(Convert.ToBoolean(state)); uo(Convert.ToBoolean(state));
} }
else else
Debug.LogMessage(LogEventLevel.Verbose, this, "User Action is null. Nothing to Execute"); Debug.Console(2, this, "User Action is null. Nothing to Execute");
break; break;
} }
case "analog": case "analog":
@@ -256,34 +334,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.LogMessage(LogEventLevel.Verbose, this, "Executing Action: {0}", uo.ToString()); Debug.Console(2, this, "Executing Action: {0}", uo.ToString());
uo(Convert.ToUInt16(state)); uo(Convert.ToUInt16(state));
} }
else else
Debug.LogMessage(LogEventLevel.Verbose, this, "User Action is null. Nothing to Execute"); break; Debug.Console(2, 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.LogMessage(LogEventLevel.Verbose, this, "Executing Action: {0}", uo.ToString()); Debug.Console(2, this, "Executing Action: {0}", uo.ToString());
uo(Convert.ToString(state)); uo(Convert.ToString(state));
} }
else else
Debug.LogMessage(LogEventLevel.Verbose, this, "User Action is null. Nothing to Execute"); Debug.Console(2, this, "User Action is null. Nothing to Execute");
break; break;
} }
default: default:
{ {
Debug.LogMessage(LogEventLevel.Verbose, "Unknown join type. Use digital/serial/analog"); Debug.Console(2, "Unknown join type. Use digital/serial/analog");
break; break;
} }
} }
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Debug, this, "Error: {0}", e); Debug.Console(1, this, "Error: {0}", e);
} }
} }
@@ -297,12 +375,13 @@ namespace PepperDash.Essentials.Core.Bridges
{ {
try try
{ {
Debug.LogMessage(LogEventLevel.Verbose, this, "EiscApiAdvanced change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue); if (Debug.Level >= 1)
Debug.Console(1, 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.LogMessage(LogEventLevel.Debug, this, "Executing Action: {0}", uo.ToString()); Debug.Console(1, 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>)
@@ -312,7 +391,7 @@ namespace PepperDash.Essentials.Core.Bridges
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Verbose, this, "Error in Eisc_SigChange handler: {0}", e); Debug.Console(2, this, "Error in Eisc_SigChange handler: {0}", e);
} }
} }
@@ -370,7 +449,7 @@ namespace PepperDash.Essentials.Core.Bridges
public override EssentialsDevice BuildDevice(DeviceConfig dc) public override EssentialsDevice BuildDevice(DeviceConfig dc)
{ {
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new EiscApiAdvanced Device"); Debug.Console(1, "Factory Attempting to create new EiscApiAdvanced Device");
var controlProperties = CommFactory.GetControlPropertiesConfig(dc); var controlProperties = CommFactory.GetControlPropertiesConfig(dc);
@@ -400,7 +479,7 @@ namespace PepperDash.Essentials.Core.Bridges
{ {
if (string.IsNullOrEmpty(controlProperties.RoomId)) if (string.IsNullOrEmpty(controlProperties.RoomId))
{ {
Debug.LogMessage(LogEventLevel.Information, "Unable to build VC-4 EISC Client for device {0}. Room ID is missing or empty", dc.Key); Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to build VC-4 EISC Client for device {0}. Room ID is missing or empty", dc.Key);
eisc = null; eisc = null;
break; break;
} }

View File

@@ -1,66 +0,0 @@
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);
}
}
}
}

View File

@@ -8,18 +8,6 @@ namespace PepperDash.Essentials.Core.Bridges
public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 },
new JoinMetadata { Description = "DM RMC Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); new JoinMetadata { Description = "DM RMC Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital });
[JoinName("VideoMuteOn")]
public JoinDataComplete VideoMuteOn = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 },
new JoinMetadata { Description = "DM RMC Mute Video", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital });
[JoinName("VideoMuteOff")]
public JoinDataComplete VideoMuteOff = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 },
new JoinMetadata { Description = "DM RMC UnMute Video", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital });
[JoinName("VideoMuteToggle")]
public JoinDataComplete VideoMuteToggle = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 },
new JoinMetadata { Description = "DM RMC Mute Video Toggle", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital });
[JoinName("CurrentOutputResolution")] [JoinName("CurrentOutputResolution")]
public JoinDataComplete CurrentOutputResolution = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, public JoinDataComplete CurrentOutputResolution = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 },
new JoinMetadata { Description = "DM RMC Current Output Resolution", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); new JoinMetadata { Description = "DM RMC Current Output Resolution", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial });
@@ -48,28 +36,6 @@ namespace PepperDash.Essentials.Core.Bridges
public JoinDataComplete AudioVideoSource = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, public JoinDataComplete AudioVideoSource = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 },
new JoinMetadata { Description = "DM RMC Audio Video Source Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); new JoinMetadata { Description = "DM RMC Audio Video Source Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog });
[JoinName("HdcpSupportCapability")]
public JoinDataComplete HdcpSupportCapability = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 },
new JoinMetadata { Description = "DM RMC HDCP Support Capability", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog });
[JoinName("Port1HdcpState")]
public JoinDataComplete Port1HdcpState = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 },
new JoinMetadata { Description = "DM RMC Port 1 (DM) HDCP State Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog });
[JoinName("Port2HdcpState")]
public JoinDataComplete Port2HdcpState = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 },
new JoinMetadata { Description = "DM TX Port 2 (HDMI) HDCP State Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog });
[JoinName("HdmiInputSync")]
public JoinDataComplete HdmiInputSync = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 },
new JoinMetadata { Description = "DM RMC HDMI Input Sync", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital });
[JoinName("HdcpInputPortCount")]
public JoinDataComplete HdcpInputPortCount = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 },
new JoinMetadata { Description = "Number of Input Ports that support HDCP", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog });
/// <summary> /// <summary>
/// Constructor to use when instantiating this Join Map without inheriting from it /// Constructor to use when instantiating this Join Map without inheriting from it
/// </summary> /// </summary>
@@ -84,8 +50,7 @@ namespace PepperDash.Essentials.Core.Bridges
/// </summary> /// </summary>
/// <param name="joinStart">Join this join map will start at</param> /// <param name="joinStart">Join this join map will start at</param>
/// <param name="type">Type of the child join map</param> /// <param name="type">Type of the child join map</param>
protected DmRmcControllerJoinMap(uint joinStart, Type type) protected DmRmcControllerJoinMap(uint joinStart, Type type) : base(joinStart, type)
: base(joinStart, type)
{ {
} }
} }

View File

@@ -64,16 +64,6 @@ namespace PepperDash.Essentials.Core.Bridges
public JoinDataComplete VgaContrast = new JoinDataComplete(new JoinData { JoinNumber = 7, JoinSpan = 1 }, public JoinDataComplete VgaContrast = new JoinDataComplete(new JoinData { JoinNumber = 7, JoinSpan = 1 },
new JoinMetadata { Description = "DM TX Online", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); new JoinMetadata { Description = "DM TX Online", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog });
[JoinName("Port3HdcpState")]
public JoinDataComplete Port3HdcpState = new JoinDataComplete(new JoinData { JoinNumber = 8, JoinSpan = 1 },
new JoinMetadata { Description = "DM TX Port 3 HDCP State Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog });
[JoinName("HdcpInputPortCount")]
public JoinDataComplete HdcpInputPortCount = new JoinDataComplete(new JoinData { JoinNumber = 9, JoinSpan = 1 },
new JoinMetadata { Description = "Number of Input Ports that support HDCP", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog });
/// <summary> /// <summary>
/// Constructor to use when instantiating this Join Map without inheriting from it /// Constructor to use when instantiating this Join Map without inheriting from it
/// </summary> /// </summary>
@@ -88,8 +78,7 @@ namespace PepperDash.Essentials.Core.Bridges
/// </summary> /// </summary>
/// <param name="joinStart">Join this join map will start at</param> /// <param name="joinStart">Join this join map will start at</param>
/// <param name="type">Type of the child join map</param> /// <param name="type">Type of the child join map</param>
protected DmTxControllerJoinMap(uint joinStart, Type type) protected DmTxControllerJoinMap(uint joinStart, Type type) : base(joinStart, type)
: base(joinStart, type)
{ {
} }
} }

View File

@@ -1,827 +0,0 @@
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Core.Bridges.JoinMaps
{
public sealed class GenericIrControllerJoinMap : JoinMapBaseAdvanced
{
[JoinName("PLAY")]
public JoinDataComplete Play = new JoinDataComplete(
new JoinData
{
JoinNumber = 1,
JoinSpan = 1
},
new JoinMetadata
{
Description = "PLAY",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("STOP")]
public JoinDataComplete Stop = new JoinDataComplete(
new JoinData
{
JoinNumber = 2,
JoinSpan = 1
},
new JoinMetadata
{
Description = "STOP",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("PAUSE")]
public JoinDataComplete Pause = new JoinDataComplete(
new JoinData
{
JoinNumber = 3,
JoinSpan = 1
},
new JoinMetadata
{
Description = "PAUSE",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("FSCAN")]
public JoinDataComplete ForwardScan = new JoinDataComplete(
new JoinData
{
JoinNumber = 4,
JoinSpan = 1
},
new JoinMetadata
{
Description = "FSCAN",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("RSCAN")]
public JoinDataComplete ReverseScan = new JoinDataComplete(
new JoinData
{
JoinNumber = 5,
JoinSpan = 1
},
new JoinMetadata
{
Description = "RSCAN",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("F_SKIP")]
public JoinDataComplete ForwardSkip = new JoinDataComplete(
new JoinData
{
JoinNumber = 6,
JoinSpan = 1
},
new JoinMetadata
{
Description = "F_SKIP",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("R_SKIP")]
public JoinDataComplete ReverseSkip = new JoinDataComplete(
new JoinData
{
JoinNumber = 7,
JoinSpan = 1
},
new JoinMetadata
{
Description = "R_SKIP",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("RECORD")]
public JoinDataComplete Record = new JoinDataComplete(
new JoinData
{
JoinNumber = 8,
JoinSpan = 1
},
new JoinMetadata
{
Description = "RECORD",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("POWER")]
public JoinDataComplete Power = new JoinDataComplete(
new JoinData
{
JoinNumber = 9,
JoinSpan = 1
},
new JoinMetadata
{
Description = "POWER",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("0")]
public JoinDataComplete Kp0 = new JoinDataComplete(
new JoinData
{
JoinNumber = 10,
JoinSpan = 1
},
new JoinMetadata
{
Description = "0",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("1")]
public JoinDataComplete Kp1 = new JoinDataComplete(
new JoinData
{
JoinNumber = 11,
JoinSpan = 1
},
new JoinMetadata
{
Description = "1",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("2")]
public JoinDataComplete Kp2 = new JoinDataComplete(
new JoinData
{
JoinNumber = 12,
JoinSpan = 1
},
new JoinMetadata
{
Description = "2",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("3")]
public JoinDataComplete Kp3 = new JoinDataComplete(
new JoinData
{
JoinNumber = 13,
JoinSpan = 1
},
new JoinMetadata
{
Description = "3",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("4")]
public JoinDataComplete Kp4 = new JoinDataComplete(
new JoinData
{
JoinNumber = 14,
JoinSpan = 1
},
new JoinMetadata
{
Description = "4",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("5")]
public JoinDataComplete Kp5 = new JoinDataComplete(
new JoinData
{
JoinNumber = 15,
JoinSpan = 1
},
new JoinMetadata
{
Description = "5",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("6")]
public JoinDataComplete Kp6 = new JoinDataComplete(
new JoinData
{
JoinNumber = 16,
JoinSpan = 1
},
new JoinMetadata
{
Description = "6",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("7")]
public JoinDataComplete Kp7 = new JoinDataComplete(
new JoinData
{
JoinNumber = 17,
JoinSpan = 1
},
new JoinMetadata
{
Description = "7",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("8")]
public JoinDataComplete Kp8 = new JoinDataComplete(
new JoinData
{
JoinNumber = 18,
JoinSpan = 1
},
new JoinMetadata
{
Description = "8",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("9")]
public JoinDataComplete Kp9 = new JoinDataComplete(
new JoinData
{
JoinNumber = 19,
JoinSpan = 1
},
new JoinMetadata
{
Description = "9",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
// [JoinName("+10")]
// public JoinDataComplete Kp9 = new JoinDataComplete(
// new JoinData
// {
// JoinNumber = 20,
// JoinSpan = 1
// },
// new JoinMetadata
// {
// Description = "+10",
// JoinCapabilities = eJoinCapabilities.FromSIMPL,
// JoinType = eJoinType.Digital
// });
[JoinName("ENTER")]
public JoinDataComplete Enter = new JoinDataComplete(
new JoinData
{
JoinNumber = 21,
JoinSpan = 1
},
new JoinMetadata
{
Description = "ENTER",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("CH+")]
public JoinDataComplete ChannelUp = new JoinDataComplete(
new JoinData
{
JoinNumber = 22,
JoinSpan = 1
},
new JoinMetadata
{
Description = "CH+",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("CH-")]
public JoinDataComplete ChannelDown = new JoinDataComplete(
new JoinData
{
JoinNumber = 23,
JoinSpan = 1
},
new JoinMetadata
{
Description = "CH-",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("*")]
public JoinDataComplete KpStar = new JoinDataComplete(
new JoinData
{
JoinNumber = 24,
JoinSpan = 1
},
new JoinMetadata
{
Description = "*",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("#")]
public JoinDataComplete KpPound = new JoinDataComplete(
new JoinData
{
JoinNumber = 25,
JoinSpan = 1
},
new JoinMetadata
{
Description = "#",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
// [JoinName(".")]
// public JoinDataComplete KpPound = new JoinDataComplete(
// new JoinData
// {
// JoinNumber = 26,
// JoinSpan = 1
// },
// new JoinMetadata
// {
// Description = ".",
// JoinCapabilities = eJoinCapabilities.FromSIMPL,
// JoinType = eJoinType.Digital
// });
[JoinName("POWER_ON")]
public JoinDataComplete PowerOn = new JoinDataComplete(
new JoinData
{
JoinNumber = 27,
JoinSpan = 1
},
new JoinMetadata
{
Description = "POWER_ON",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("POWER_OFF")]
public JoinDataComplete PowerOff = new JoinDataComplete(
new JoinData
{
JoinNumber = 28,
JoinSpan = 1
},
new JoinMetadata
{
Description = "POWER_OFF",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("PLAY_PAUSE")]
public JoinDataComplete PlayPause = new JoinDataComplete(
new JoinData
{
JoinNumber = 29,
JoinSpan = 1
},
new JoinMetadata
{
Description = "PLAY_PAUSE",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("LAST")]
public JoinDataComplete Last = new JoinDataComplete(
new JoinData
{
JoinNumber = 30,
JoinSpan = 1
},
new JoinMetadata
{
Description = "LAST",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("HOME")]
public JoinDataComplete Home = new JoinDataComplete(
new JoinData
{
JoinNumber = 40,
JoinSpan = 1
},
new JoinMetadata
{
Description = "HOME",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("BACK")]
public JoinDataComplete Back = new JoinDataComplete(
new JoinData
{
JoinNumber = 41,
JoinSpan = 1
},
new JoinMetadata
{
Description = "BACK",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("GUIDE")]
public JoinDataComplete Guide = new JoinDataComplete(
new JoinData
{
JoinNumber = 42,
JoinSpan = 1
},
new JoinMetadata
{
Description = "GUIDE",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("INFO")]
public JoinDataComplete Info = new JoinDataComplete(
new JoinData
{
JoinNumber = 43,
JoinSpan = 1
},
new JoinMetadata
{
Description = "INFO",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("MENU")]
public JoinDataComplete Menu = new JoinDataComplete(
new JoinData
{
JoinNumber = 44,
JoinSpan = 1
},
new JoinMetadata
{
Description = "MENU",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("UP_ARROW")]
public JoinDataComplete DpadUp = new JoinDataComplete(
new JoinData
{
JoinNumber = 45,
JoinSpan = 1
},
new JoinMetadata
{
Description = "UP_ARROW",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("DN_ARROW")]
public JoinDataComplete DpadDown = new JoinDataComplete(
new JoinData
{
JoinNumber = 46,
JoinSpan = 1
},
new JoinMetadata
{
Description = "DN_ARROW",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("LEFT_ARROW")]
public JoinDataComplete DpadLeft = new JoinDataComplete(
new JoinData
{
JoinNumber = 47,
JoinSpan = 1
},
new JoinMetadata
{
Description = "LEFT_ARROW",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("RIGHT_ARROW")]
public JoinDataComplete DpadRight = new JoinDataComplete(
new JoinData
{
JoinNumber = 48,
JoinSpan = 1
},
new JoinMetadata
{
Description = "RIGHT_ARROW",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("SELECT")]
public JoinDataComplete DpadSelect = new JoinDataComplete(
new JoinData
{
JoinNumber = 49,
JoinSpan = 1
},
new JoinMetadata
{
Description = "SELECT",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("OPTIONS")]
public JoinDataComplete Options = new JoinDataComplete(
new JoinData
{
JoinNumber = 50,
JoinSpan = 1
},
new JoinMetadata
{
Description = "OPTIONS",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("RETURN")]
public JoinDataComplete Return = new JoinDataComplete(
new JoinData
{
JoinNumber = 51,
JoinSpan = 1
},
new JoinMetadata
{
Description = "RETURN",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("DVR")]
public JoinDataComplete Dvr = new JoinDataComplete(
new JoinData
{
JoinNumber = 52,
JoinSpan = 1
},
new JoinMetadata
{
Description = "DVR",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("ON_DEMAND")]
public JoinDataComplete OnDemand = new JoinDataComplete(
new JoinData
{
JoinNumber = 53,
JoinSpan = 1
},
new JoinMetadata
{
Description = "ON_DEMAND",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("PAGE_UP")]
public JoinDataComplete PageUp = new JoinDataComplete(
new JoinData
{
JoinNumber = 54,
JoinSpan = 1
},
new JoinMetadata
{
Description = "PAGE_UP",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("PAGE_DOWN")]
public JoinDataComplete PageDown = new JoinDataComplete(
new JoinData
{
JoinNumber = 55,
JoinSpan = 1
},
new JoinMetadata
{
Description = "PAGE_DOWN",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("F_SRCH")]
public JoinDataComplete ForwardSearch = new JoinDataComplete(
new JoinData
{
JoinNumber = 56,
JoinSpan = 1
},
new JoinMetadata
{
Description = "F_SRCH",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("R_SRCH")]
public JoinDataComplete ReverseSearch = new JoinDataComplete(
new JoinData
{
JoinNumber = 57,
JoinSpan = 1
},
new JoinMetadata
{
Description = "R_SRCH",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("TRACK+")]
public JoinDataComplete TrackPlus = new JoinDataComplete(
new JoinData
{
JoinNumber = 58,
JoinSpan = 1
},
new JoinMetadata
{
Description = "TRACK+",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("TRACK-")]
public JoinDataComplete TrackMinus = new JoinDataComplete(
new JoinData
{
JoinNumber = 59,
JoinSpan = 1
},
new JoinMetadata
{
Description = "TRACK-",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("A")]
public JoinDataComplete KpA = new JoinDataComplete(
new JoinData
{
JoinNumber = 61,
JoinSpan = 1
},
new JoinMetadata
{
Description = "A",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("B")]
public JoinDataComplete KpB = new JoinDataComplete(
new JoinData
{
JoinNumber = 62,
JoinSpan = 1
},
new JoinMetadata
{
Description = "B",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("C")]
public JoinDataComplete KpC = new JoinDataComplete(
new JoinData
{
JoinNumber = 63,
JoinSpan = 1
},
new JoinMetadata
{
Description = "C",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("D")]
public JoinDataComplete KpD = new JoinDataComplete(
new JoinData
{
JoinNumber = 64,
JoinSpan = 1
},
new JoinMetadata
{
Description = "D",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("RED")]
public JoinDataComplete KpRed = new JoinDataComplete(
new JoinData
{
JoinNumber = 65,
JoinSpan = 1
},
new JoinMetadata
{
Description = "RED",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("GREEN")]
public JoinDataComplete KpGreen = new JoinDataComplete(
new JoinData
{
JoinNumber = 66,
JoinSpan = 1
},
new JoinMetadata
{
Description = "GREEN",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("YELLOW")]
public JoinDataComplete KpYellow = new JoinDataComplete(
new JoinData
{
JoinNumber = 67,
JoinSpan = 1
},
new JoinMetadata
{
Description = "YELLOW",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("BLUE")]
public JoinDataComplete KpBlue = new JoinDataComplete(
new JoinData
{
JoinNumber = 68,
JoinSpan = 1
},
new JoinMetadata
{
Description = "BLUE",
JoinCapabilities = eJoinCapabilities.FromSIMPL,
JoinType = eJoinType.Digital
});
public GenericIrControllerJoinMap(uint joinStart)
: base(joinStart, typeof(GenericIrControllerJoinMap))
{
}
}
}

View File

@@ -1,190 +0,0 @@
using System;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Core.Bridges
{
public class HdPsXxxControllerJoinMap : JoinMapBaseAdvanced
{
#region Digital
[JoinName("EnableAutoRoute")]
public JoinDataComplete EnableAutoRoute = new JoinDataComplete(
new JoinData
{
JoinNumber = 1,
JoinSpan = 1
},
new JoinMetadata
{
Description = "Enable Automatic Routing on Xx1 Switchers",
JoinCapabilities = eJoinCapabilities.ToFromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("InputSync")]
public JoinDataComplete InputSync = new JoinDataComplete(
new JoinData
{
JoinNumber = 2,
JoinSpan = 8
},
new JoinMetadata
{
Description = "Device Input Sync",
JoinCapabilities = eJoinCapabilities.ToSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("EnableInputHdcp")]
public JoinDataComplete EnableInputHdcp = new JoinDataComplete(
new JoinData
{
JoinNumber = 11,
JoinSpan = 8
},
new JoinMetadata
{
Description = "Device Enable Input Hdcp",
JoinCapabilities = eJoinCapabilities.ToFromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("DisableInputHdcp")]
public JoinDataComplete DisableInputHdcp = new JoinDataComplete(
new JoinData
{
JoinNumber = 21,
JoinSpan = 8
},
new JoinMetadata
{
Description = "Device Disnable Input Hdcp",
JoinCapabilities = eJoinCapabilities.ToFromSIMPL,
JoinType = eJoinType.Digital
});
[JoinName("IsOnline")]
public JoinDataComplete IsOnline = new JoinDataComplete(
new JoinData
{
JoinNumber = 30,
JoinSpan = 1
},
new JoinMetadata
{
Description = "Device Onlne",
JoinCapabilities = eJoinCapabilities.ToSIMPL,
JoinType = eJoinType.Digital
});
#endregion
#region Analog
[JoinName("OutputRoute")]
public JoinDataComplete OutputRoute = new JoinDataComplete(
new JoinData
{
JoinNumber = 11,
JoinSpan = 2
},
new JoinMetadata
{
Description = "Device Output Route Set/Get",
JoinCapabilities = eJoinCapabilities.ToFromSIMPL,
JoinType = eJoinType.Analog
});
#endregion
#region Serial
[JoinName("Name")]
public JoinDataComplete Name = new JoinDataComplete(
new JoinData
{
JoinNumber = 1,
JoinSpan = 1
},
new JoinMetadata
{
Description = "Device Name",
JoinCapabilities = eJoinCapabilities.ToSIMPL,
JoinType = eJoinType.Serial
});
[JoinName("InputName")]
public JoinDataComplete InputName = new JoinDataComplete(
new JoinData
{
JoinNumber = 2,
JoinSpan = 8
},
new JoinMetadata
{
Description = "Device Input Name",
JoinCapabilities = eJoinCapabilities.ToSIMPL,
JoinType = eJoinType.Serial
});
[JoinName("OutputName")]
public JoinDataComplete OutputName = new JoinDataComplete(
new JoinData
{
JoinNumber = 11,
JoinSpan = 2
},
new JoinMetadata
{
Description = "Device Output Name",
JoinCapabilities = eJoinCapabilities.ToSIMPL,
JoinType = eJoinType.Serial
});
[JoinName("OutputRoutedName")]
public JoinDataComplete OutputRoutedName = new JoinDataComplete(
new JoinData
{
JoinNumber = 16,
JoinSpan = 2
},
new JoinMetadata
{
Description = "Device Output Route Name",
JoinCapabilities = eJoinCapabilities.ToSIMPL,
JoinType = eJoinType.Serial
});
#endregion
/// <summary>
/// Constructor to use when instantiating this join map without inheriting from it
/// </summary>
/// <param name="joinStart">Join this join map will start at</param>
public HdPsXxxControllerJoinMap(uint joinStart)
: this(joinStart, typeof(HdPsXxxControllerJoinMap))
{
}
/// <summary>
/// Constructor to use when extending this Join map
/// </summary>
/// <param name="joinStart">Join this join map will start at</param>
/// <param name="type">Type of the child join map</param>
protected HdPsXxxControllerJoinMap(uint joinStart, Type type)
: base(joinStart, type)
{
}
}
}

View File

@@ -10,7 +10,7 @@ namespace PepperDash.Essentials.Core.Bridges
[JoinName("Online")] [JoinName("Online")]
public JoinDataComplete Online = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, public JoinDataComplete Online = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 },
new JoinMetadata { Description = "Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); new JoinMetadata { Description = "PDU Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital });
[JoinName("OutletCount")] [JoinName("OutletCount")]
public JoinDataComplete OutletCount = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, public JoinDataComplete OutletCount = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 },

View File

@@ -132,23 +132,6 @@ namespace PepperDash.Essentials.Core.Bridges
public JoinDataComplete DhcpStatus = new JoinDataComplete(new JoinData { JoinNumber = 86, JoinSpan = 1 }, public JoinDataComplete DhcpStatus = new JoinDataComplete(new JoinData { JoinNumber = 86, JoinSpan = 1 },
new JoinMetadata { Description = "Processor Ethernet Dhcp Status", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); new JoinMetadata { Description = "Processor Ethernet Dhcp Status", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial });
[JoinName("ProcessorRebot")]
public JoinDataComplete ProcessorReboot = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 },
new JoinMetadata { Description = "Reboot processor", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital });
[JoinName("IsAppliance")]
public JoinDataComplete IsAppliance = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 },
new JoinMetadata { Description = "Is appliance Fb", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital });
[JoinName("IsServer")]
public JoinDataComplete IsServer = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 },
new JoinMetadata { Description = "Is server Fb", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital });
[JoinName("ProgramReset")]
public JoinDataComplete ProgramReset = new JoinDataComplete(new JoinData { JoinNumber = 15, JoinSpan = 1 },
new JoinMetadata { Description = "Resets the program", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital });
/// <summary> /// <summary>
/// Constructor to use when instantiating this Join Map without inheriting from it /// Constructor to use when instantiating this Join Map without inheriting from it
/// </summary> /// </summary>

View File

@@ -8,7 +8,6 @@ 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
{ {
@@ -50,7 +49,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.LogMessage(LogEventLevel.Verbose, this, "CEC NAK Error"); Debug.Console(2, this, "CEC NAK Error");
} }
void OnDataReceived(string s) void OnDataReceived(string s)
@@ -60,14 +59,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.LogMessage(LogEventLevel.Information, this, "Received: '{0}'", ComTextHelper.GetEscapedText(bytes)); Debug.Console(0, 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.LogMessage(LogEventLevel.Information, this, "Received: '{0}'", s); Debug.Console(0, this, "Received: '{0}'", s);
textHandler(this, new GenericCommMethodReceiveTextArgs(s)); textHandler(this, new GenericCommMethodReceiveTextArgs(s));
} }
} }
@@ -79,7 +78,7 @@ namespace PepperDash.Essentials.Core
if (Port == null) if (Port == null)
return; return;
if (StreamDebugging.TxStreamDebuggingIsEnabled) if (StreamDebugging.TxStreamDebuggingIsEnabled)
Debug.LogMessage(LogEventLevel.Information, this, "Sending {0} characters of text: '{1}'", text.Length, text); Debug.Console(0, this, "Sending {0} characters of text: '{1}'", text.Length, text);
Port.StreamCec.Send.StringValue = text; Port.StreamCec.Send.StringValue = text;
} }
@@ -89,7 +88,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.LogMessage(LogEventLevel.Information, this, "Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes)); Debug.Console(0, this, "Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes));
Port.StreamCec.Send.StringValue = text; Port.StreamCec.Send.StringValue = text;
} }

View File

@@ -7,7 +7,6 @@ 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
@@ -44,7 +43,7 @@ namespace PepperDash.Essentials.Core
{ {
if (port == null) if (port == null)
{ {
Debug.LogMessage(LogEventLevel.Information, this, "ERROR: Invalid com port, continuing but comms will not function"); Debug.Console(0, this, "ERROR: Invalid com port, continuing but comms will not function");
return; return;
} }
@@ -59,7 +58,7 @@ namespace PepperDash.Essentials.Core
{ {
if (Port == null) if (Port == null)
{ {
Debug.LogMessage(LogEventLevel.Information, this, "Configured com Port for this device does not exist."); Debug.Console(0,this,Debug.ErrorLogLevel.Error, "Configured com Port for this device does not exist.");
return; return;
} }
if (Port.Parent is CrestronControlSystem) if (Port.Parent is CrestronControlSystem)
@@ -67,7 +66,7 @@ namespace PepperDash.Essentials.Core
var result = Port.Register(); var result = Port.Register();
if (result != eDeviceRegistrationUnRegistrationResponse.Success) if (result != eDeviceRegistrationUnRegistrationResponse.Success)
{ {
Debug.LogMessage(LogEventLevel.Information, this, "ERROR: Cannot register Com port: {0}", result); Debug.Console(0, this, "ERROR: Cannot register Com port: {0}", result);
return; // false return; // false
} }
} }
@@ -75,7 +74,7 @@ namespace PepperDash.Essentials.Core
var specResult = Port.SetComPortSpec(Spec); var specResult = Port.SetComPortSpec(Spec);
if (specResult != 0) if (specResult != 0)
{ {
Debug.LogMessage(LogEventLevel.Information, this, "WARNING: Cannot set comspec"); Debug.Console(0, this, "WARNING: Cannot set comspec");
return; return;
} }
Port.SerialDataReceived += Port_SerialDataReceived; Port.SerialDataReceived += Port_SerialDataReceived;
@@ -93,27 +92,22 @@ 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.LogMessage(LogEventLevel.Information, this, "Received: '{0}'", ComTextHelper.GetEscapedText(bytes)); Debug.Console(0, 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.LogMessage(LogEventLevel.Information, this, "Received: '{0}'", s); Debug.Console(0, 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()
@@ -129,7 +123,7 @@ namespace PepperDash.Essentials.Core
return; return;
if (StreamDebugging.TxStreamDebuggingIsEnabled) if (StreamDebugging.TxStreamDebuggingIsEnabled)
Debug.LogMessage(LogEventLevel.Information, this, "Sending {0} characters of text: '{1}'", text.Length, text); Debug.Console(0, this, "Sending {0} characters of text: '{1}'", text.Length, text);
Port.Send(text); Port.Send(text);
} }
@@ -139,7 +133,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.LogMessage(LogEventLevel.Information, this, "Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes)); Debug.Console(0, this, "Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes));
Port.Send(text); Port.Send(text);
} }

View File

@@ -1,4 +1,4 @@
extern alias Full;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -7,8 +7,8 @@ using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
using Newtonsoft.Json; using Full.Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Full.Newtonsoft.Json.Linq;
using PepperDash.Core; using PepperDash.Core;
@@ -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.LogMessage(LogEventLevel.Verbose, "ReadJson type: " + objectType.Name); //Debug.Console(2, "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))

View File

@@ -1,14 +1,13 @@
extern alias Full;
using System; using System;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM;
using Newtonsoft.Json; using Full.Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Full.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
{ {
@@ -23,12 +22,12 @@ namespace PepperDash.Essentials.Core
{ {
return JsonConvert.DeserializeObject<EssentialsControlPropertiesConfig> return JsonConvert.DeserializeObject<EssentialsControlPropertiesConfig>
(deviceConfig.Properties["control"].ToString()); (deviceConfig.Properties["control"].ToString());
//Debug.LogMessage(LogEventLevel.Verbose, "Control TEST: {0}", JsonConvert.SerializeObject(controlConfig)); //Debug.Console(2, "Control TEST: {0}", JsonConvert.SerializeObject(controlConfig));
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Information, "ERROR: [{0}] Control properties deserialize failed:\r{1}", deviceConfig.Key, e); Debug.Console(0, "ERROR: [{0}] Control properties deserialize failed:\r{1}", deviceConfig.Key, e);
return null; return null;
} }
} }
@@ -51,7 +50,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.Value, controlConfig); comm = new ComPortController(deviceConfig.Key + "-com", GetComPort, controlConfig.ComParams, 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);
@@ -84,22 +83,13 @@ namespace PepperDash.Essentials.Core
} }
case eControlMethod.Telnet: case eControlMethod.Telnet:
break; break;
case eControlMethod.SecureTcpIp:
{
var secureTcp = new GenericSecureTcpIpClient(deviceConfig.Key + "-secureTcp", c.Address, c.Port, c.BufferSize);
secureTcp.AutoReconnect = c.AutoReconnect;
if (secureTcp.AutoReconnect)
secureTcp.AutoReconnectIntervalMs = c.AutoReconnectIntervalMs;
comm = secureTcp;
break;
}
default: default:
break; break;
} }
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Information, "Cannot create communication from JSON:\r{0}\r\rException:\r{1}", Debug.Console(0, "Cannot create communication from JSON:\r{0}\r\rException:\r{1}",
deviceConfig.Properties.ToString(), e); deviceConfig.Properties.ToString(), e);
} }
@@ -115,8 +105,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.Value]; return dev.ComPorts[config.ControlPortNumber];
Debug.LogMessage(LogEventLevel.Information, "GetComPort: Device '{0}' does not have com port {1}", config.ControlPortDevKey, config.ControlPortNumber); Debug.Console(0,Debug.ErrorLogLevel.Notice, "GetComPort: Device '{0}' does not have com port {1}", config.ControlPortDevKey, config.ControlPortNumber);
return null; return null;
} }
@@ -126,53 +116,40 @@ namespace PepperDash.Essentials.Core
/// <param name="config"></param> /// <param name="config"></param>
/// <returns></returns> /// <returns></returns>
public static ICec GetCecPort(ControlPropertiesConfig config) public static ICec GetCecPort(ControlPropertiesConfig config)
{
try
{ {
var dev = DeviceManager.GetDeviceForKey(config.ControlPortDevKey); var dev = DeviceManager.GetDeviceForKey(config.ControlPortDevKey);
Debug.LogMessage(LogEventLevel.Information, "GetCecPort: device '{0}' {1}", config.ControlPortDevKey, dev == null if (dev != null)
? "is not valid, failed to get cec port"
: "found in device manager, attempting to get cec port");
if (dev == null)
return null;
if (String.IsNullOrEmpty(config.ControlPortName))
{ {
Debug.LogMessage(LogEventLevel.Information, "GetCecPort: '{0}' - Configuration missing 'ControlPortName'", config.ControlPortDevKey); if (!String.IsNullOrEmpty(config.ControlPortName))
return null;
}
var inputsOutputs = dev as IRoutingInputsOutputs;
if (inputsOutputs == null)
{ {
Debug.LogMessage(LogEventLevel.Information, "GetCecPort: Device '{0}' does not support IRoutingInputsOutputs, failed to get CEC port called '{1}'",
config.ControlPortDevKey, config.ControlPortName);
return null; var inputPort = (dev as IRoutingInputsOutputs).InputPorts[config.ControlPortName];
}
var inputPort = inputsOutputs.InputPorts[config.ControlPortName]; if (inputPort != null)
if (inputPort != null && inputPort.Port is ICec) {
if (inputPort.Port is ICec)
return inputPort.Port as ICec; return inputPort.Port as ICec;
}
var outputPort = (dev as IRoutingInputsOutputs).OutputPorts[config.ControlPortName];
var outputPort = inputsOutputs.OutputPorts[config.ControlPortName]; if (outputPort != null)
if (outputPort != null && outputPort.Port is ICec) {
if (outputPort.Port is ICec)
return outputPort.Port as ICec; return outputPort.Port as ICec;
} }
catch (Exception ex)
{
Debug.LogMessage(LogEventLevel.Debug, "GetCecPort Exception Message: {0}", ex.Message);
Debug.LogMessage(LogEventLevel.Verbose, "GetCecPort Exception StackTrace: {0}", ex.StackTrace);
if (ex.InnerException != null)
Debug.LogMessage(LogEventLevel.Information, "GetCecPort Exception InnerException: {0}", ex.InnerException);
}
Debug.LogMessage(LogEventLevel.Information, "GetCecPort: Device '{0}' does not have a CEC port called '{1}'", else
Debug.Console(0, "GetCecPort: Device '{0}' does not have a CEC port called: '{1}'",
config.ControlPortDevKey, config.ControlPortName); config.ControlPortDevKey, config.ControlPortName);
}
else
{
Debug.Console(0, "GetCecPort: '{0}' - Configuration missing 'ControlPortName'", config.ControlPortDevKey);
}
}
Debug.Console(0, "GetCecPort: Device '{0}' is not a valid device.", config.ControlPortDevKey);
return null; return null;
} }
@@ -192,7 +169,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.LogMessage(LogEventLevel.Information, "ComPortConfig: Cannot find com port device '{0}'", ComPortDevKey); Debug.Console(0, "ComPortConfig: Cannot find com port device '{0}'", ComPortDevKey);
return dev; return dev;
} }
} }
@@ -202,20 +179,19 @@ namespace PepperDash.Essentials.Core
/// ///
/// </summary> /// </summary>
public class EssentialsControlPropertiesConfig : public class EssentialsControlPropertiesConfig :
ControlPropertiesConfig PepperDash.Core.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
@@ -231,13 +207,11 @@ 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

View File

@@ -1,4 +1,4 @@
extern alias Full;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -7,8 +7,8 @@ using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
using Newtonsoft.Json; using Full.Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Full.Newtonsoft.Json.Linq;
using PepperDash.Core; using PepperDash.Core;

View File

@@ -6,7 +6,6 @@ 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
@@ -40,7 +39,7 @@ namespace PepperDash.Essentials.Core
public override bool CustomActivate() public override bool CustomActivate()
{ {
Communication.Connect(); Communication.Connect();
CommunicationMonitor.StatusChange += (o, a) => { Debug.LogMessage(LogEventLevel.Verbose, this, "Communication monitor state: {0}", CommunicationMonitor.Status); }; CommunicationMonitor.StatusChange += (o, a) => { Debug.Console(2, 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);
@@ -51,7 +50,7 @@ namespace PepperDash.Essentials.Core
void SendLine(string s) void SendLine(string s)
{ {
//if (Debug.Level == 2) //if (Debug.Level == 2)
// Debug.LogMessage(LogEventLevel.Verbose, this, " Send '{0}'", ComTextHelper.GetEscapedText(s)); // Debug.Console(2, this, " Send '{0}'", ComTextHelper.GetEscapedText(s));
Communication.SendText(s + LineEnding); Communication.SendText(s + LineEnding);
} }
} }
@@ -76,7 +75,7 @@ namespace PepperDash.Essentials.Core
public override EssentialsDevice BuildDevice(DeviceConfig dc) public override EssentialsDevice BuildDevice(DeviceConfig dc)
{ {
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Comm Mock Device"); Debug.Console(1, "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());

View File

@@ -1,16 +1,15 @@
extern alias Full;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Crestron.SimplSharp.CrestronSockets; using Crestron.SimplSharp.CrestronSockets;
using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DeviceSupport;
using Newtonsoft.Json; using Full.Newtonsoft.Json;
using PepperDash.Core; 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
@@ -46,7 +45,7 @@ namespace PepperDash.Essentials.Core
public static IKeyed BuildDevice(DeviceConfig dc) public static IKeyed BuildDevice(DeviceConfig dc)
{ {
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic Comm Device"); Debug.Console(1, "Factory Attempting to create new Generic Comm Device");
return new GenericComm(dc); return new GenericComm(dc);
} }
@@ -60,7 +59,7 @@ namespace PepperDash.Essentials.Core
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Verbose, this, "Error deserializing port config: {0}", e); Debug.Console(2, this, "Error deserializing port config: {0}", e);
} }
} }
@@ -86,16 +85,16 @@ namespace PepperDash.Essentials.Core
} }
else else
{ {
Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
} }
if (CommPort == null) if (CommPort == null)
{ {
Debug.LogMessage(LogEventLevel.Debug, this, "Unable to link device '{0}'. CommPort is null", Key); Debug.Console(1, this, "Unable to link device '{0}'. CommPort is null", Key);
return; return;
} }
Debug.LogMessage(LogEventLevel.Debug, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); Debug.Console(1, 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) =>
@@ -138,7 +137,7 @@ namespace PepperDash.Essentials.Core
public override EssentialsDevice BuildDevice(DeviceConfig dc) public override EssentialsDevice BuildDevice(DeviceConfig dc)
{ {
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic Comm Device"); Debug.Console(1, "Factory Attempting to create new Generic Comm Device");
return new GenericComm(dc); return new GenericComm(dc);
} }
} }

View File

@@ -1,10 +1,14 @@
using Crestron.SimplSharp.Net.Http; using System;
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 System; using PepperDash.Core.DebugThings;
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")]
public class GenericHttpClient : Device, IBasicCommunication public class GenericHttpClient : Device, IBasicCommunication
{ {
public HttpClient Client; public HttpClient Client;

View File

@@ -1,4 +1,4 @@
extern alias Full;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -6,11 +6,10 @@ using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO; using Crestron.SimplSharp.CrestronIO;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
using Newtonsoft.Json; using Full.Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Full.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
{ {
@@ -41,7 +40,7 @@ namespace PepperDash.Essentials.Core
return null; return null;
if (control["method"].Value<string>() != "ir") if (control["method"].Value<string>() != "ir")
{ {
Debug.LogMessage(LogEventLevel.Information, "IRPortHelper called with non-IR properties"); Debug.Console(0, "IRPortHelper called with non-IR properties");
return null; return null;
} }
@@ -51,7 +50,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.LogMessage(LogEventLevel.Debug, "WARNING: Properties is missing port device or port number"); Debug.Console(1, "WARNING: Properties is missing port device or port number");
return port; return port;
} }
@@ -64,7 +63,7 @@ namespace PepperDash.Essentials.Core
if (irDev == null) if (irDev == null)
{ {
Debug.LogMessage(LogEventLevel.Debug, "[Config] Error, device with IR ports '{0}' not found", portDevKey); Debug.Console(1, "[Config] Error, device with IR ports '{0}' not found", portDevKey);
return port; return port;
} }
@@ -77,7 +76,7 @@ namespace PepperDash.Essentials.Core
} }
else else
{ {
Debug.LogMessage(LogEventLevel.Debug, "[Config] Error, device '{0}' IR port {1} out of range", Debug.Console(1, "[Config] Error, device '{0}' IR port {1} out of range",
portDevKey, portNum); portDevKey, portNum);
return port; return port;
} }
@@ -88,14 +87,14 @@ namespace PepperDash.Essentials.Core
var irControllerKey = dc.Key + "-ir"; var irControllerKey = dc.Key + "-ir";
if (dc.Properties == null) if (dc.Properties == null)
{ {
Debug.LogMessage(LogEventLevel.Information, "[{0}] WARNING: Device config does not include properties. IR will not function.", dc.Key); Debug.Console(0, "[{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.LogMessage(LogEventLevel.Information, Debug.Console(0,
"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;
} }
@@ -106,13 +105,13 @@ namespace PepperDash.Essentials.Core
if (portDevKey == null) if (portDevKey == null)
{ {
Debug.LogMessage(LogEventLevel.Information, "WARNING: control properties is missing ir device for {0}", dc.Key); Debug.Console(0, "WARNING: control properties is missing ir device for {0}", dc.Key);
return null; return null;
} }
if (portNum == 0) if (portNum == 0)
{ {
Debug.LogMessage(LogEventLevel.Information, "WARNING: control properties is missing ir port number for {0}", dc.Key); Debug.Console(0, "WARNING: control properties is missing ir port number for {0}", dc.Key);
return null; return null;
} }
@@ -124,12 +123,12 @@ namespace PepperDash.Essentials.Core
if (irDev == null) if (irDev == null)
{ {
Debug.LogMessage(LogEventLevel.Information, "WARNING: device with IR ports '{0}' not found", portDevKey); Debug.Console(0, "WARNING: device with IR ports '{0}' not found", portDevKey);
return null; return null;
} }
if (portNum > irDev.NumberOfIROutputPorts) if (portNum > irDev.NumberOfIROutputPorts)
{ {
Debug.LogMessage(LogEventLevel.Information, "WARNING: device '{0}' IR port {1} out of range", Debug.Console(0, "WARNING: device '{0}' IR port {1} out of range",
portDevKey, portNum); portDevKey, portNum);
return null; return null;
} }
@@ -144,7 +143,7 @@ namespace PepperDash.Essentials.Core
public static IrOutputPortController GetIrOutputPortController(DeviceConfig config) public static IrOutputPortController GetIrOutputPortController(DeviceConfig config)
{ {
Debug.LogMessage(LogEventLevel.Debug, "Attempting to create new Ir Port Controller"); Debug.Console(1, "Attempting to create new Ir Port Controller");
if (config == null) if (config == null)
{ {
@@ -166,7 +165,7 @@ namespace PepperDash.Essentials.Core
var irControllerKey = devConf.Key + "-ir"; var irControllerKey = devConf.Key + "-ir";
if (devConf.Properties == null) if (devConf.Properties == null)
{ {
Debug.LogMessage(LogEventLevel.Information, "[{0}] WARNING: Device config does not include properties. IR will not function.", devConf.Key); Debug.Console(0, "[{0}] WARNING: Device config does not include properties. IR will not function.", devConf.Key);
return new IrOutputPortController(irControllerKey, null, ""); return new IrOutputPortController(irControllerKey, null, "");
} }
@@ -174,7 +173,7 @@ namespace PepperDash.Essentials.Core
if (control == null) if (control == null)
{ {
var c = new IrOutputPortController(irControllerKey, null, ""); var c = new IrOutputPortController(irControllerKey, null, "");
Debug.LogMessage(LogEventLevel.Information, c, "WARNING: Device config does not include control properties. IR will not function"); Debug.Console(0, c, "WARNING: Device config does not include control properties. IR will not function");
return c; return c;
} }
@@ -185,14 +184,14 @@ namespace PepperDash.Essentials.Core
if (portDevKey == null) if (portDevKey == null)
{ {
var c = new IrOutputPortController(irControllerKey, null, ""); var c = new IrOutputPortController(irControllerKey, null, "");
Debug.LogMessage(LogEventLevel.Information, c, "WARNING: control properties is missing ir device"); Debug.Console(0, 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.LogMessage(LogEventLevel.Information, c, "WARNING: control properties is missing ir port number"); Debug.Console(0, c, "WARNING: control properties is missing ir port number");
return c; return c;
} }
@@ -205,7 +204,7 @@ namespace PepperDash.Essentials.Core
if (irDev == null) if (irDev == null)
{ {
var c = new IrOutputPortController(irControllerKey, null, ""); var c = new IrOutputPortController(irControllerKey, null, "");
Debug.LogMessage(LogEventLevel.Information, c, "WARNING: device with IR ports '{0}' not found", portDevKey); Debug.Console(0, c, "WARNING: device with IR ports '{0}' not found", portDevKey);
return c; return c;
} }
@@ -215,7 +214,7 @@ namespace PepperDash.Essentials.Core
else else
{ {
var c = new IrOutputPortController(irControllerKey, null, ""); var c = new IrOutputPortController(irControllerKey, null, "");
Debug.LogMessage(LogEventLevel.Information, c, "WARNING: device '{0}' IR port {1} out of range", Debug.Console(0, c, "WARNING: device '{0}' IR port {1} out of range",
portDevKey, portNum); portDevKey, portNum);
return c; return c;
} }
@@ -227,15 +226,9 @@ namespace PepperDash.Essentials.Core
/// </summary> /// </summary>
public class IrOutPortConfig public class IrOutPortConfig
{ {
[JsonProperty("port")]
public IROutputPort Port { get; set; } public IROutputPort Port { get; set; }
[JsonProperty("fileName")]
public string FileName { get; set; } public string FileName { get; set; }
[JsonProperty("useBridgeJoinMap")]
public bool UseBridgeJoinMap { get; set; }
public IrOutPortConfig() public IrOutPortConfig()
{ {
FileName = ""; FileName = "";

View File

@@ -1,20 +0,0 @@
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>();
}
}

View File

@@ -1,11 +1,10 @@
extern alias Full;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Newtonsoft.Json; using Full.Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Full.Newtonsoft.Json.Linq;
using PepperDash.Essentials.Core.Devices;
namespace PepperDash.Essentials.Core.Config namespace PepperDash.Essentials.Core.Config
{ {
@@ -24,13 +23,7 @@ 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; }
@@ -44,8 +37,6 @@ 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>();
} }
@@ -55,7 +46,7 @@ namespace PepperDash.Essentials.Core.Config
/// </summary> /// </summary>
public Dictionary<string, SourceListItem> GetSourceListForKey(string key) public Dictionary<string, SourceListItem> GetSourceListForKey(string key)
{ {
if (SourceLists == null || string.IsNullOrEmpty(key) || !SourceLists.ContainsKey(key)) if (string.IsNullOrEmpty(key) || !SourceLists.ContainsKey(key))
return null; return null;
return SourceLists[key]; return SourceLists[key];
@@ -64,11 +55,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 list to retrieve</param> /// <param name="key">key of the item to retrieve</param>
/// <returns>DestinationList if the key exists, null otherwise</returns> /// <returns>DestinationListItem if the key exists, null otherwise</returns>
public Dictionary<string, DestinationListItem> GetDestinationListForKey(string key) public Dictionary<string, DestinationListItem> GetDestinationListForKey(string key)
{ {
if (DestinationLists == null || string.IsNullOrEmpty(key) || !DestinationLists.ContainsKey(key)) if (string.IsNullOrEmpty(key) || !DestinationLists.ContainsKey(key))
{ {
return null; return null;
} }
@@ -76,30 +67,6 @@ 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>

View File

@@ -1,4 +1,4 @@
extern alias Full;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -7,7 +7,7 @@ using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
using PepperDash.Core; using PepperDash.Core;
using Newtonsoft.Json.Linq; using Full.Newtonsoft.Json.Linq;
namespace PepperDash.Essentials.Core.Config namespace PepperDash.Essentials.Core.Config
{ {

View File

@@ -1,4 +1,4 @@
extern alias Full;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -6,8 +6,8 @@ using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO; using Crestron.SimplSharp.CrestronIO;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
using Newtonsoft.Json; using Full.Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Full.Newtonsoft.Json.Linq;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;

View File

@@ -1,15 +1,14 @@
extern alias Full;
using System; using System;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO; using Crestron.SimplSharp.CrestronIO;
using Newtonsoft.Json; using Full.Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Full.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
{ {
@@ -28,7 +27,7 @@ namespace PepperDash.Essentials.Core.Config
public static bool LoadConfig2() public static bool LoadConfig2()
{ {
Debug.LogMessage(LogEventLevel.Information, "Loading unmerged system/template portal configuration file."); Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading unmerged system/template portal configuration file.");
try try
{ {
// Check for local config file first // Check for local config file first
@@ -36,7 +35,7 @@ namespace PepperDash.Essentials.Core.Config
bool localConfigFound = false; bool localConfigFound = false;
Debug.LogMessage(LogEventLevel.Information, "Attempting to load Local config file: '{0}'", filePath); Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to load Local config file: '{0}'", filePath);
// Check for local config directory first // Check for local config directory first
@@ -46,7 +45,7 @@ namespace PepperDash.Essentials.Core.Config
{ {
if (configFiles.Length > 1) if (configFiles.Length > 1)
{ {
Debug.LogMessage(LogEventLevel.Information, Debug.Console(0, Debug.ErrorLogLevel.Error,
"****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;
} }
@@ -58,7 +57,7 @@ namespace PepperDash.Essentials.Core.Config
} }
else else
{ {
Debug.LogMessage(LogEventLevel.Information, Debug.Console(0, Debug.ErrorLogLevel.Notice,
"Local Configuration file not present.", filePath); "Local Configuration file not present.", filePath);
} }
@@ -68,33 +67,33 @@ namespace PepperDash.Essentials.Core.Config
{ {
filePath = Global.FilePathPrefix + Global.ConfigFileName; filePath = Global.FilePathPrefix + Global.ConfigFileName;
Debug.LogMessage(LogEventLevel.Information, "Attempting to load Portal config file: '{0}'", filePath); Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to load Portal config file: '{0}'", filePath);
configFiles = GetConfigFiles(filePath); configFiles = GetConfigFiles(filePath);
if (configFiles != null) if (configFiles != null)
{ {
Debug.LogMessage(LogEventLevel.Verbose, "{0} config files found matching pattern", configFiles.Length); Debug.Console(2, "{0} config files found matching pattern", configFiles.Length);
if (configFiles.Length > 1) if (configFiles.Length > 1)
{ {
Debug.LogMessage(LogEventLevel.Information, Debug.Console(0, Debug.ErrorLogLevel.Error,
"****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.LogMessage(LogEventLevel.Information, "Found Portal config file: '{0}'", filePath); Debug.Console(0, Debug.ErrorLogLevel.Notice, "Found Portal config file: '{0}'", filePath);
} }
else else
{ {
Debug.LogMessage(LogEventLevel.Information, "No config file found."); Debug.Console(0, Debug.ErrorLogLevel.Notice, "No config file found.");
return false; return false;
} }
} }
else else
{ {
Debug.LogMessage(LogEventLevel.Information, Debug.Console(0, Debug.ErrorLogLevel.Error,
"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;
} }
@@ -112,13 +111,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.LogMessage(LogEventLevel.Information, "Loading config file: '{0}'", filePath); Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading config file: '{0}'", filePath);
if (localConfigFound) if (localConfigFound)
{ {
ConfigObject = JObject.Parse(fs.ReadToEnd()).ToObject<EssentialsConfig>(); ConfigObject = JObject.Parse(fs.ReadToEnd()).ToObject<EssentialsConfig>();
Debug.LogMessage(LogEventLevel.Information, "Successfully Loaded Local Config"); Debug.Console(0, Debug.ErrorLogLevel.Notice, "Successfully Loaded Local Config");
return true; return true;
} }
@@ -140,14 +139,14 @@ namespace PepperDash.Essentials.Core.Config
} }
} }
Debug.LogMessage(LogEventLevel.Information, "Successfully Loaded Merged Config"); Debug.Console(0, Debug.ErrorLogLevel.Notice, "Successfully Loaded Merged Config");
return true; return true;
} }
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Information, "ERROR: Config load failed: \r{0}", e); Debug.Console(0, Debug.ErrorLogLevel.Error, "ERROR: Config load failed: \r{0}", e);
return false; return false;
} }
} }
@@ -164,20 +163,20 @@ namespace PepperDash.Essentials.Core.Config
if (Directory.Exists(dir)) if (Directory.Exists(dir))
{ {
Debug.LogMessage(LogEventLevel.Debug, "Searching in Directory '{0}'", dir); Debug.Console(1, "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.LogMessage(LogEventLevel.Debug, "For Config Files matching: '{0}'", fileName); Debug.Console(1, "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.LogMessage(LogEventLevel.Information, Debug.Console(0, Debug.ErrorLogLevel.Notice,
"Directory not found: ", dir); "Directory not found: ", dir);
return null; return null;
@@ -249,8 +248,8 @@ namespace PepperDash.Essentials.Core.Config
// Line 8 // Line 8
.Append(new string('*', debugStringWidth)); .Append(new string('*', debugStringWidth));
Debug.LogMessage(LogEventLevel.Verbose, "Found Local config file: '{0}'", filePath); Debug.Console(2, Debug.ErrorLogLevel.Notice, "Found Local config file: '{0}'", filePath);
Debug.LogMessage(LogEventLevel.Information, newDebugString.ToString()); Debug.Console(0, newDebugString.ToString());
} }
} }

View File

@@ -1,4 +1,4 @@
extern alias Full;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -6,13 +6,12 @@ using System.Linq;
using System.Text; using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO; using Crestron.SimplSharp.CrestronIO;
using Newtonsoft.Json; using Full.Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Full.Newtonsoft.Json.Linq;
using Crestron.SimplSharp.Net.Http; 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
{ {
@@ -22,7 +21,7 @@ namespace PepperDash.Essentials.Core.Config
public static void GetConfigFromServer(string url) public static void GetConfigFromServer(string url)
{ {
Debug.LogMessage(LogEventLevel.Information, "Attempting to get new config from '{0}'", url); Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to get new config from '{0}'", url);
// HTTP GET // HTTP GET
var req = new HttpClientRequest(); var req = new HttpClientRequest();
@@ -52,17 +51,17 @@ namespace PepperDash.Essentials.Core.Config
} }
else else
{ {
Debug.LogMessage(LogEventLevel.Information, "Config Update Process Stopped. Failed to get config file from server: {0}", r.Code); Debug.Console(0, Debug.ErrorLogLevel.Error, "Config Update Process Stopped. Failed to get config file from server: {0}", r.Code);
OnStatusUpdate(eUpdateStatus.UpdateFailed); OnStatusUpdate(eUpdateStatus.UpdateFailed);
} }
} }
else else
Debug.LogMessage(LogEventLevel.Information, "Request for config from Server Failed: {0}", e); Debug.Console(0, Debug.ErrorLogLevel.Error, "Request for config from Server Failed: {0}", e);
}); });
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Debug, "Error Getting Config from Server: {0}", e); Debug.Console(1, "Error Getting Config from Server: {0}", e);
} }
} }
@@ -91,7 +90,7 @@ namespace PepperDash.Essentials.Core.Config
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Debug, "Error parsing new config: {0}", e); Debug.Console(1, "Error parsing new config: {0}", e);
OnStatusUpdate(eUpdateStatus.UpdateFailed); OnStatusUpdate(eUpdateStatus.UpdateFailed);
} }
@@ -108,7 +107,7 @@ namespace PepperDash.Essentials.Core.Config
if (configFiles != null) if (configFiles != null)
{ {
Debug.LogMessage(LogEventLevel.Information, "Existing config files found. Moving to Archive folder."); Debug.Console(0, Debug.ErrorLogLevel.Notice, "Existing config files found. Moving to Archive folder.");
OnStatusUpdate(eUpdateStatus.ArchivingConfigs); OnStatusUpdate(eUpdateStatus.ArchivingConfigs);
@@ -116,7 +115,7 @@ namespace PepperDash.Essentials.Core.Config
} }
else else
{ {
Debug.LogMessage(LogEventLevel.Information, "No Existing config files found in '{0}'. Nothing to archive", filePath); Debug.Console(0, Debug.ErrorLogLevel.Notice, "No Existing config files found in '{0}'. Nothing to archive", filePath);
} }
} }
@@ -141,12 +140,12 @@ namespace PepperDash.Essentials.Core.Config
if(archivedConfigFiles != null || archivedConfigFiles.Length > 0) if(archivedConfigFiles != null || archivedConfigFiles.Length > 0)
{ {
Debug.LogMessage(LogEventLevel.Information, "{0} Existing files found in archive folder. Deleting.", archivedConfigFiles.Length); Debug.Console(0, Debug.ErrorLogLevel.Notice, "{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.LogMessage(LogEventLevel.Information, "Deleting archived file: '{0}'", file.FullName); Debug.Console(0, Debug.ErrorLogLevel.Notice, "Deleting archived file: '{0}'", file.FullName);
file.Delete(); file.Delete();
} }
} }
@@ -156,7 +155,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.LogMessage(LogEventLevel.Information, "Moving config file '{0}' to archive folder", file.FullName); Debug.Console(0, Debug.ErrorLogLevel.Notice, "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";
@@ -165,7 +164,7 @@ namespace PepperDash.Essentials.Core.Config
file.MoveTo(fileDest); file.MoveTo(fileDest);
} }
else else
Debug.LogMessage(LogEventLevel.Information, "Cannot move file to archive folder. Existing file already exists with same name: '{0}'", fileDest); Debug.Console(0, Debug.ErrorLogLevel.Warning, "Cannot move file to archive folder. Existing file already exists with same name: '{0}'", fileDest);
} }
} }
@@ -180,7 +179,7 @@ namespace PepperDash.Essentials.Core.Config
{ {
OnStatusUpdate(eUpdateStatus.DeletingLocalConfig); OnStatusUpdate(eUpdateStatus.DeletingLocalConfig);
Directory.Delete(folderPath); Directory.Delete(folderPath);
Debug.LogMessage(LogEventLevel.Information, "Local Config Found in '{0}'. Deleting.", folderPath); Debug.Console(0, Debug.ErrorLogLevel.Notice, "Local Config Found in '{0}'. Deleting.", folderPath);
} }
} }
@@ -189,7 +188,7 @@ namespace PepperDash.Essentials.Core.Config
/// </summary> /// </summary>
static void RestartProgram() static void RestartProgram()
{ {
Debug.LogMessage(LogEventLevel.Information, "Attempting to Reset Program"); Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to Reset Program");
OnStatusUpdate(eUpdateStatus.RestartingProgram); OnStatusUpdate(eUpdateStatus.RestartingProgram);
@@ -197,7 +196,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.LogMessage(LogEventLevel.Debug, "Console Response: {0}", response); Debug.Console(1, "Console Response: {0}", response);
} }
} }

View File

@@ -1,4 +1,4 @@
extern alias Full;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -6,10 +6,9 @@ using System.Linq;
using System.Text; using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO; using Crestron.SimplSharp.CrestronIO;
using Newtonsoft.Json; using Full.Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Full.Newtonsoft.Json.Linq;
using PepperDash.Core; using PepperDash.Core;
using Serilog.Events;
namespace PepperDash.Essentials.Core.Config namespace PepperDash.Essentials.Core.Config
{ {
@@ -43,7 +42,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.LogMessage(LogEventLevel.Debug, "Updated properties of device: '{0}'", deviceKey); Debug.Console(1, "Updated properties of device: '{0}'", deviceKey);
success = true; success = true;
} }
@@ -63,7 +62,7 @@ namespace PepperDash.Essentials.Core.Config
{ {
ConfigReader.ConfigObject.Devices[deviceConfigIndex] = config; ConfigReader.ConfigObject.Devices[deviceConfigIndex] = config;
Debug.LogMessage(LogEventLevel.Debug, "Updated config of device: '{0}'", config.Key); Debug.Console(1, "Updated config of device: '{0}'", config.Key);
success = true; success = true;
} }
@@ -83,7 +82,7 @@ namespace PepperDash.Essentials.Core.Config
{ {
ConfigReader.ConfigObject.Rooms[roomConfigIndex] = config; ConfigReader.ConfigObject.Rooms[roomConfigIndex] = config;
Debug.LogMessage(LogEventLevel.Debug, "Updated room of device: '{0}'", config.Key); Debug.Console(1, "Updated room of device: '{0}'", config.Key);
success = true; success = true;
} }
@@ -103,7 +102,7 @@ namespace PepperDash.Essentials.Core.Config
WriteTimer.Reset(WriteTimeout); WriteTimer.Reset(WriteTimeout);
Debug.LogMessage(LogEventLevel.Debug, "Config File write timer has been reset."); Debug.Console(1, "Config File write timer has been reset.");
} }
/// <summary> /// <summary>
@@ -129,9 +128,9 @@ namespace PepperDash.Essentials.Core.Config
if (WriteTimer != null) if (WriteTimer != null)
WriteTimer.Stop(); WriteTimer.Stop();
Debug.LogMessage(LogEventLevel.Information, "Writing Configuration to file"); Debug.Console(0, Debug.ErrorLogLevel.Notice, "Writing Configuration to file");
Debug.LogMessage(LogEventLevel.Information, "Attempting to write config file: '{0}'", filePath); Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to write config file: '{0}'", filePath);
try try
{ {
@@ -145,12 +144,12 @@ namespace PepperDash.Essentials.Core.Config
} }
else else
{ {
Debug.LogMessage(LogEventLevel.Information, "Unable to enter FileLock"); Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to enter FileLock");
} }
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Information, "Error: Config write failed: \r{0}", e); Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: Config write failed: \r{0}", e);
} }
finally finally
{ {

View File

@@ -1,11 +1,11 @@
extern alias Full;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Crestron.SimplSharp.CrestronIO; using Crestron.SimplSharp.CrestronIO;
using Newtonsoft.Json; using Full.Newtonsoft.Json;
using PepperDash.Core; using PepperDash.Core;
@@ -31,17 +31,9 @@ namespace PepperDash.Essentials.Core.Config
if (string.IsNullOrEmpty(SystemUrl)) if (string.IsNullOrEmpty(SystemUrl))
return "missing url"; return "missing url";
if (SystemUrl.Contains("#"))
{
var result = Regex.Match(SystemUrl, @"https?:\/\/.*\/systems\/(.*)\/#.*"); var result = Regex.Match(SystemUrl, @"https?:\/\/.*\/systems\/(.*)\/#.*");
string uuid = result.Groups[1].Value; string uuid = result.Groups[1].Value;
return uuid; return uuid;
} else
{
var result = Regex.Match(SystemUrl, @"https?:\/\/.*\/systems\/(.*)\/.*");
string uuid = result.Groups[1].Value;
return uuid;
}
} }
} }
@@ -53,17 +45,9 @@ namespace PepperDash.Essentials.Core.Config
if (string.IsNullOrEmpty(TemplateUrl)) if (string.IsNullOrEmpty(TemplateUrl))
return "missing template url"; return "missing template url";
if (TemplateUrl.Contains("#"))
{
var result = Regex.Match(TemplateUrl, @"https?:\/\/.*\/templates\/(.*)\/#.*"); var result = Regex.Match(TemplateUrl, @"https?:\/\/.*\/templates\/(.*)\/#.*");
string uuid = result.Groups[1].Value; string uuid = result.Groups[1].Value;
return uuid; return uuid;
} else
{
var result = Regex.Match(TemplateUrl, @"https?:\/\/.*\/system-templates\/(.*)\/system-template-versions\/(.*)\/.*");
string uuid = result.Groups[2].Value;
return uuid;
}
} }
} }

View File

@@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PepperDash.Essentials.Core
{
public interface ILoadConfig
{
void GoWithLoad();
}
}

View File

@@ -1,9 +1,11 @@
extern alias Full;
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 Full.Newtonsoft.Json;
namespace PepperDash.Essentials.Core.Config namespace PepperDash.Essentials.Core.Config
{ {

View File

@@ -1,4 +1,4 @@
 extern alias Full;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -7,11 +7,10 @@ using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DeviceSupport;
using Newtonsoft.Json; using Full.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
@@ -68,7 +67,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
{ {
if (!Global.ControlSystem.SupportsDigitalInput) if (!Global.ControlSystem.SupportsDigitalInput)
{ {
Debug.LogMessage(LogEventLevel.Information, "GetDigitalInput: Processor does not support Digital Inputs"); Debug.Console(0, "GetDigitalInput: Processor does not support Digital Inputs");
return null; return null;
} }
ioPortDevice = Global.ControlSystem; ioPortDevice = Global.ControlSystem;
@@ -78,20 +77,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.LogMessage(LogEventLevel.Information, "GetDigitalInput: Device {0} is not a valid device", dc.PortDeviceKey); Debug.Console(0, "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.LogMessage(LogEventLevel.Information, "GetDigitalInput: Device '0' is not a valid IDigitalInputPorts Device", dc.PortDeviceKey); Debug.Console(0, "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.LogMessage(LogEventLevel.Information, "GetDigitalInput: Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber); Debug.Console(0, "GetDigitalInput: Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber);
} }
return ioPortDevice.DigitalInputPorts[dc.PortNumber]; return ioPortDevice.DigitalInputPorts[dc.PortNumber];
@@ -118,20 +117,20 @@ namespace PepperDash.Essentials.Core.CrestronIO
} }
else else
{ {
Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
} }
try try
{ {
Debug.LogMessage(LogEventLevel.Debug, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); Debug.Console(1, 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.LogMessage(LogEventLevel.Debug, this, "Unable to link device '{0}'. Input is null", Key); Debug.Console(1, this, "Unable to link device '{0}'. Input is null", Key);
Debug.LogMessage(LogEventLevel.Debug, this, "Error: {0}", e); Debug.Console(1, this, "Error: {0}", e);
} }
} }
@@ -148,7 +147,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
public override EssentialsDevice BuildDevice(DeviceConfig dc) public override EssentialsDevice BuildDevice(DeviceConfig dc)
{ {
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic Digital Input Device"); Debug.Console(1, "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());

View File

@@ -1,4 +1,4 @@
 extern alias Full;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -7,11 +7,10 @@ using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DeviceSupport;
using Newtonsoft.Json; using Full.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
{ {
@@ -49,7 +48,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
if (RelayOutput == null) if (RelayOutput == null)
{ {
Debug.LogMessage(LogEventLevel.Information, this, "Unable to get parent relay device for device key {0} and port {1}", config.PortDeviceKey, config.PortNumber); Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Unable to get parent relay device for device key {0} and port {1}", config.PortDeviceKey, config.PortNumber);
return; return;
} }
@@ -70,7 +69,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
{ {
if (!Global.ControlSystem.SupportsRelay) if (!Global.ControlSystem.SupportsRelay)
{ {
Debug.LogMessage(LogEventLevel.Information, "Processor does not support relays"); Debug.Console(0, "Processor does not support relays");
return null; return null;
} }
relayDevice = Global.ControlSystem; relayDevice = Global.ControlSystem;
@@ -81,7 +80,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.LogMessage(LogEventLevel.Information, "Device {0} was not found in Device Manager. Check configuration or for errors with device.", dc.PortDeviceKey); Debug.Console(0, "Device {0} was not found in Device Manager. Check configuration or for errors with device.", dc.PortDeviceKey);
return null; return null;
} }
@@ -89,7 +88,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
if (relayDevice == null) if (relayDevice == null)
{ {
Debug.LogMessage(LogEventLevel.Information, "Device {0} is not a valid relay parent. Please check configuration.", dc.PortDeviceKey); Debug.Console(0, "Device {0} is not a valid relay parent. Please check configuration.", dc.PortDeviceKey);
return null; return null;
} }
@@ -98,7 +97,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
return relayDevice.RelayPorts[dc.PortNumber]; return relayDevice.RelayPorts[dc.PortNumber];
} }
Debug.LogMessage(LogEventLevel.Information, "Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber); Debug.Console(0, "Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber);
return null; return null;
} }
@@ -166,16 +165,16 @@ namespace PepperDash.Essentials.Core.CrestronIO
} }
else else
{ {
Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
} }
if (RelayOutput == null) if (RelayOutput == null)
{ {
Debug.LogMessage(LogEventLevel.Debug, this, "Unable to link device '{0}'. Relay is null", Key); Debug.Console(1, this, "Unable to link device '{0}'. Relay is null", Key);
return; return;
} }
Debug.LogMessage(LogEventLevel.Debug, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
trilist.SetBoolSigAction(joinMap.Relay.JoinNumber, b => trilist.SetBoolSigAction(joinMap.Relay.JoinNumber, b =>
{ {
@@ -203,7 +202,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
public override EssentialsDevice BuildDevice(DeviceConfig dc) public override EssentialsDevice BuildDevice(DeviceConfig dc)
{ {
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic Relay Device"); Debug.Console(1, "Factory Attempting to create new Generic Relay Device");
var props = JsonConvert.DeserializeObject<IOPortConfig>(dc.Properties.ToString()); var props = JsonConvert.DeserializeObject<IOPortConfig>(dc.Properties.ToString());

View File

@@ -1,4 +1,4 @@
 extern alias Full;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -13,8 +13,7 @@ using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Bridges;
using Newtonsoft.Json; using Full.Newtonsoft.Json;
using Serilog.Events;
namespace PepperDash.Essentials.Core.CrestronIO namespace PepperDash.Essentials.Core.CrestronIO
{ {
@@ -60,7 +59,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
InputPort.VersiportChange += InputPort_VersiportChange; InputPort.VersiportChange += InputPort_VersiportChange;
Debug.LogMessage(LogEventLevel.Debug, this, "Created GenericVersiportAnalogInputDevice on port '{0}'. DisablePullUpResistor: '{1}'", config.PortNumber, InputPort.DisablePullUpResistor); Debug.Console(1, this, "Created GenericVersiportAnalogInputDevice on port '{0}'. DisablePullUpResistor: '{1}'", config.PortNumber, InputPort.DisablePullUpResistor);
}); });
@@ -77,7 +76,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
void InputPort_VersiportChange(Versiport port, VersiportEventArgs args) void InputPort_VersiportChange(Versiport port, VersiportEventArgs args)
{ {
Debug.LogMessage(LogEventLevel.Debug, this, "Versiport change: {0}", args.Event); Debug.Console(1, this, "Versiport change: {0}", args.Event);
if(args.Event == eVersiportEvent.AnalogInChange) if(args.Event == eVersiportEvent.AnalogInChange)
InputValueFeedback.FireUpdate(); InputValueFeedback.FireUpdate();
@@ -103,12 +102,12 @@ namespace PepperDash.Essentials.Core.CrestronIO
} }
else else
{ {
Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
} }
try try
{ {
Debug.LogMessage(LogEventLevel.Debug, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); Debug.Console(1, 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]);
@@ -118,8 +117,8 @@ namespace PepperDash.Essentials.Core.CrestronIO
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Debug, this, "Unable to link device '{0}'. Input is null", Key); Debug.Console(1, this, "Unable to link device '{0}'. Input is null", Key);
Debug.LogMessage(LogEventLevel.Debug, this, "Error: {0}", e); Debug.Console(1, this, "Error: {0}", e);
} }
trilist.OnlineStatusChange += (d, args) => trilist.OnlineStatusChange += (d, args) =>
@@ -148,7 +147,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
{ {
if (!Global.ControlSystem.SupportsVersiport) if (!Global.ControlSystem.SupportsVersiport)
{ {
Debug.LogMessage(LogEventLevel.Information, "GetVersiportAnalogInput: Processor does not support Versiports"); Debug.Console(0, "GetVersiportAnalogInput: Processor does not support Versiports");
return null; return null;
} }
ioPortDevice = Global.ControlSystem; ioPortDevice = Global.ControlSystem;
@@ -158,25 +157,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.LogMessage(LogEventLevel.Information, "GetVersiportAnalogInput: Device {0} is not a valid device", dc.PortDeviceKey); Debug.Console(0, "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.LogMessage(LogEventLevel.Information, "GetVersiportAnalogInput: Device '0' is not a valid IIOPorts Device", dc.PortDeviceKey); Debug.Console(0, "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.LogMessage(LogEventLevel.Information, "GetVersiportAnalogInput: Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber); Debug.Console(0, "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.LogMessage(LogEventLevel.Information, "GetVersiportAnalogInput: Device {0} does not support AnalogInput on port {1}", dc.PortDeviceKey, dc.PortNumber); Debug.Console(0, "GetVersiportAnalogInput: Device {0} does not support AnalogInput on port {1}", dc.PortDeviceKey, dc.PortNumber);
return null; return null;
} }
@@ -197,7 +196,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
public override EssentialsDevice BuildDevice(DeviceConfig dc) public override EssentialsDevice BuildDevice(DeviceConfig dc)
{ {
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic Versiport Device"); Debug.Console(1, "Factory Attempting to create new Generic Versiport Device");
var props = JsonConvert.DeserializeObject<IOPortConfig>(dc.Properties.ToString()); var props = JsonConvert.DeserializeObject<IOPortConfig>(dc.Properties.ToString());

View File

@@ -1,4 +1,4 @@
 extern alias Full;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -13,15 +13,14 @@ using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Bridges;
using Newtonsoft.Json; using Full.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, IPartitionStateProvider public class GenericVersiportDigitalInputDevice : EssentialsBridgeableDevice, IDigitalInput
{ {
public Versiport InputPort { get; private set; } public Versiport InputPort { get; private set; }
@@ -35,15 +34,10 @@ 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(() =>
{ {
@@ -57,10 +51,9 @@ 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);
}); });
@@ -68,13 +61,10 @@ namespace PepperDash.Essentials.Core.CrestronIO
void InputPort_VersiportChange(Versiport port, VersiportEventArgs args) void InputPort_VersiportChange(Versiport port, VersiportEventArgs args)
{ {
Debug.LogMessage(LogEventLevel.Debug, this, "Versiport change: {0}", args.Event); Debug.Console(1, this, "Versiport change: {0}", args.Event);
if(args.Event == eVersiportEvent.DigitalInChange) if(args.Event == eVersiportEvent.DigitalInChange)
{
InputStateFeedback.FireUpdate(); InputStateFeedback.FireUpdate();
PartitionPresentFeedback.FireUpdate();
}
} }
@@ -95,20 +85,20 @@ namespace PepperDash.Essentials.Core.CrestronIO
} }
else else
{ {
Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
} }
try try
{ {
Debug.LogMessage(LogEventLevel.Debug, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); Debug.Console(1, 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.LogMessage(LogEventLevel.Debug, this, "Unable to link device '{0}'. Input is null", Key); Debug.Console(1, this, "Unable to link device '{0}'. Input is null", Key);
Debug.LogMessage(LogEventLevel.Debug, this, "Error: {0}", e); Debug.Console(1, this, "Error: {0}", e);
} }
} }
@@ -124,7 +114,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
{ {
if (!Global.ControlSystem.SupportsVersiport) if (!Global.ControlSystem.SupportsVersiport)
{ {
Debug.LogMessage(LogEventLevel.Information, "GetVersiportDigitalInput: Processor does not support Versiports"); Debug.Console(0, "GetVersiportDigitalInput: Processor does not support Versiports");
return null; return null;
} }
ioPortDevice = Global.ControlSystem; ioPortDevice = Global.ControlSystem;
@@ -134,20 +124,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.LogMessage(LogEventLevel.Information, "GetVersiportDigitalInput: Device {0} is not a valid device", dc.PortDeviceKey); Debug.Console(0, "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.LogMessage(LogEventLevel.Information, "GetVersiportDigitalInput: Device '0' is not a valid IIOPorts Device", dc.PortDeviceKey); Debug.Console(0, "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.LogMessage(LogEventLevel.Information, "GetVersiportDigitalInput: Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber); Debug.Console(0, "GetVersiportDigitalInput: Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber);
} }
return ioPortDevice.VersiPorts[dc.PortNumber]; return ioPortDevice.VersiPorts[dc.PortNumber];
@@ -166,7 +156,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
public override EssentialsDevice BuildDevice(DeviceConfig dc) public override EssentialsDevice BuildDevice(DeviceConfig dc)
{ {
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic Versiport Device"); Debug.Console(1, "Factory Attempting to create new Generic Versiport Device");
var props = JsonConvert.DeserializeObject<IOPortConfig>(dc.Properties.ToString()); var props = JsonConvert.DeserializeObject<IOPortConfig>(dc.Properties.ToString());

View File

@@ -1,4 +1,4 @@
 extern alias Full;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -13,8 +13,7 @@ using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Bridges;
using Newtonsoft.Json; using Full.Newtonsoft.Json;
using Serilog.Events;
namespace PepperDash.Essentials.Core.CrestronIO namespace PepperDash.Essentials.Core.CrestronIO
{ {
@@ -49,7 +48,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
if (!OutputPort.SupportsDigitalOutput) if (!OutputPort.SupportsDigitalOutput)
{ {
Debug.LogMessage(LogEventLevel.Information, this, "Device does not support configuration as a Digital Output"); Debug.Console(0, this, "Device does not support configuration as a Digital Output");
return; return;
} }
@@ -64,7 +63,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
void OutputPort_VersiportChange(Versiport port, VersiportEventArgs args) void OutputPort_VersiportChange(Versiport port, VersiportEventArgs args)
{ {
Debug.LogMessage(LogEventLevel.Debug, this, "Versiport change: {0}", args.Event); Debug.Console(1, this, "Versiport change: {0}", args.Event);
if(args.Event == eVersiportEvent.DigitalOutChange) if(args.Event == eVersiportEvent.DigitalOutChange)
OutputStateFeedback.FireUpdate(); OutputStateFeedback.FireUpdate();
@@ -78,14 +77,14 @@ namespace PepperDash.Essentials.Core.CrestronIO
{ {
if (OutputPort.SupportsDigitalOutput) if (OutputPort.SupportsDigitalOutput)
{ {
Debug.LogMessage(LogEventLevel.Information, this, "Passed the Check"); Debug.Console(0, this, "Passed the Check");
OutputPort.DigitalOut = state; OutputPort.DigitalOut = state;
} }
else else
{ {
Debug.LogMessage(LogEventLevel.Information, this, "Versiport does not support Digital Output Mode"); Debug.Console(0, this, "Versiport does not support Digital Output Mode");
} }
} }
@@ -107,12 +106,12 @@ namespace PepperDash.Essentials.Core.CrestronIO
} }
else else
{ {
Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
} }
try try
{ {
Debug.LogMessage(LogEventLevel.Debug, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); Debug.Console(1, 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]);
@@ -120,8 +119,8 @@ namespace PepperDash.Essentials.Core.CrestronIO
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Debug, this, "Unable to link device '{0}'. Input is null", Key); Debug.Console(1, this, "Unable to link device '{0}'. Input is null", Key);
Debug.LogMessage(LogEventLevel.Debug, this, "Error: {0}", e); Debug.Console(1, this, "Error: {0}", e);
} }
} }
@@ -137,7 +136,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
{ {
if (!Global.ControlSystem.SupportsVersiport) if (!Global.ControlSystem.SupportsVersiport)
{ {
Debug.LogMessage(LogEventLevel.Information, "GetVersiportDigitalOuptut: Processor does not support Versiports"); Debug.Console(0, "GetVersiportDigitalOuptut: Processor does not support Versiports");
return null; return null;
} }
ioPortDevice = Global.ControlSystem; ioPortDevice = Global.ControlSystem;
@@ -147,20 +146,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.LogMessage(LogEventLevel.Information, "GetVersiportDigitalOuptut: Device {0} is not a valid device", dc.PortDeviceKey); Debug.Console(0, "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.LogMessage(LogEventLevel.Information, "GetVersiportDigitalOuptut: Device '0' is not a valid IOPorts Device", dc.PortDeviceKey); Debug.Console(0, "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.LogMessage(LogEventLevel.Information, "GetVersiportDigitalOuptut: Device {0} does not contain a port {1}", dc.PortDeviceKey, dc.PortNumber); Debug.Console(0, "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;
@@ -178,7 +177,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
public override EssentialsDevice BuildDevice(DeviceConfig dc) public override EssentialsDevice BuildDevice(DeviceConfig dc)
{ {
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic Versiport Device"); Debug.Console(1, "Factory Attempting to create new Generic Versiport Device");
var props = JsonConvert.DeserializeObject<IOPortConfig>(dc.Properties.ToString()); var props = JsonConvert.DeserializeObject<IOPortConfig>(dc.Properties.ToString());

View File

@@ -1,11 +1,11 @@
 extern alias Full;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Newtonsoft.Json; using Full.Newtonsoft.Json;
namespace PepperDash.Essentials.Core.CrestronIO namespace PepperDash.Essentials.Core.CrestronIO
{ {

View File

@@ -5,10 +5,12 @@ 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
{ {
/// <summary>
/// A bridge class to cover the basic features of GenericBase hardware
/// </summary>
public abstract class CrestronGenericBaseDevice : EssentialsDevice, IOnline, IHasFeedback, ICommunicationMonitor, IUsageTracking public abstract class CrestronGenericBaseDevice : EssentialsDevice, IOnline, IHasFeedback, ICommunicationMonitor, IUsageTracking
{ {
protected GenericBase Hardware; protected GenericBase Hardware;
@@ -66,17 +68,17 @@ namespace PepperDash.Essentials.Core
/// </summary> /// </summary>
public override bool CustomActivate() public override bool CustomActivate()
{ {
Debug.LogMessage(LogEventLevel.Information, this, "Activating"); Debug.Console(0, this, "Activating");
if (!PreventRegistration) if (!PreventRegistration)
{ {
//Debug.LogMessage(LogEventLevel.Debug, this, " Does not require registration. Skipping"); //Debug.Console(1, 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.LogMessage(LogEventLevel.Information, this, "ERROR: Cannot register Crestron device: {0}", response); //Debug.Console(0, this, "ERROR: Cannot register Crestron device: {0}", response);
return false; return false;
} }
} }
@@ -142,7 +144,7 @@ namespace PepperDash.Essentials.Core
void Hardware_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) void Hardware_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args)
{ {
Debug.LogMessage(LogEventLevel.Verbose, this, "OnlineStatusChange Event. Online = {0}", args.DeviceOnLine); Debug.Console(2, this, "OnlineStatusChange Event. Online = {0}", args.DeviceOnLine);
if (!Hardware.Registered) if (!Hardware.Registered)
{ {
@@ -199,11 +201,12 @@ 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.LogMessage(LogEventLevel.Information, "Register device result: '{0}', type '{1}', result {2}", key, device, result); Debug.ErrorLogLevel.Notice : Debug.ErrorLogLevel.Error;
Debug.Console(0, level, "Register device result: '{0}', type '{1}', result {2}", key, device, result);
//if (result != eDeviceRegistrationUnRegistrationResponse.Success) //if (result != eDeviceRegistrationUnRegistrationResponse.Success)
//{ //{
// Debug.LogMessage(LogEventLevel.Information, "Cannot register device '{0}': {1}", key, result); // Debug.Console(0, Debug.ErrorLogLevel.Error, "Cannot register device '{0}': {1}", key, result);
//} //}
return result; return result;
} }

View File

@@ -38,16 +38,16 @@ namespace PepperDash.Essentials.Core
/// </summary> /// </summary>
public override bool CustomActivate() public override bool CustomActivate()
{ {
Debug.LogMessage(LogEventLevel.Information, this, "Activating"); Debug.Console(0, this, "Activating");
var response = Hardware.RegisterWithLogging(Key); var response = Hardware.RegisterWithLogging(Key);
if (response != eDeviceRegistrationUnRegistrationResponse.Success) if (response != eDeviceRegistrationUnRegistrationResponse.Success)
{ {
<<<<<<< HEAD <<<<<<< HEAD
Debug.LogMessage(LogEventLevel.Information, this, "ERROR: Cannot register Crestron device: {0}", response); Debug.Console(0, this, "ERROR: Cannot register Crestron device: {0}", response);
return false; return false;
} }
======= =======
Debug.LogMessage(LogEventLevel.Information, this, "ERROR: Cannot register Crestron device: {0}", response); Debug.Console(0, 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.LogMessage(LogEventLevel.Information, "Cannot register device '{0}': {1}", key, result); Debug.Console(0, Debug.ErrorLogLevel.Error, "Cannot register device '{0}': {1}", key, result);
} }
return result; return result;
} }

View File

@@ -1,219 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using PepperDash.Core;
using Crestron.SimplSharp;
using PepperDash.Essentials.Core;
using Serilog.Events;
namespace PepperDash.Essentials.Core.DeviceInfo
{
public static class NetworkDeviceHelpers
{
/// <summary>
/// Event raised when ArpTable changes
/// </summary>
public static event ArpTableEventHandler ArpTableUpdated;
/// <summary>
/// Delegate called by ArpTableUpdated
/// </summary>
/// <param name="args">contains the entire ARP table and a bool to note if there was an error in retrieving the data</param>
public delegate void ArpTableEventHandler(ArpTableEventArgs args);
private static readonly char NewLineSplitter = CrestronEnvironment.NewLine.ToCharArray().First();
private static readonly string NewLine = CrestronEnvironment.NewLine;
private static readonly CCriticalSection Lock = new CCriticalSection();
/// <summary>
/// Last resolved ARP table - it is recommended to refresh the arp before using this.
/// </summary>
public static List<ArpEntry> ArpTable { get; private set; }
/// <summary>
/// Force recheck of ARP table
/// </summary>
public static void RefreshArp()
{
var error = false;
try
{
Lock.Enter();
var consoleResponse = string.Empty;
if (!CrestronConsole.SendControlSystemCommand("showarptable", ref consoleResponse)) return;
if (string.IsNullOrEmpty(consoleResponse))
{
error = true;
return;
}
ArpTable.Clear();
Debug.LogMessage(LogEventLevel.Verbose, "ConsoleResponse of 'showarptable' : {0}{1}", NewLine, consoleResponse);
var myLines =
consoleResponse.Split(NewLineSplitter)
.ToList()
.Where(o => (o.Contains(':') && !o.Contains("Type", StringComparison.OrdinalIgnoreCase)))
.ToList();
foreach (var line in myLines)
{
var item = line;
var seperator = item.Contains('\t') ? '\t' : ' ';
var dataPoints = item.Split(seperator);
if (dataPoints == null || dataPoints.Length < 2) continue;
var ipAddress = SanitizeIpAddress(dataPoints.First().TrimAll());
var macAddress = dataPoints.Last();
ArpTable.Add(new ArpEntry(ipAddress, macAddress));
}
}
catch (Exception ex)
{
Debug.LogMessage(LogEventLevel.Information, "Exception in \"RefreshArp\" : {0}", ex.Message);
error = true;
}
finally
{
Lock.Leave();
OnArpTableUpdated(new ArpTableEventArgs(ArpTable, error));
}
}
private static void OnArpTableUpdated(ArpTableEventArgs args)
{
if (args == null) return;
var handler = ArpTableUpdated;
if (handler == null) return;
handler.Invoke(args);
}
static NetworkDeviceHelpers()
{
ArpTable = new List<ArpEntry>();
}
/// <summary>
/// Removes leading zeros, leading whitespace, and trailing whitespace from an IPAddress string
/// </summary>
/// <param name="ipAddressIn">Ip Address to Santitize</param>
/// <returns>Sanitized Ip Address</returns>
public static string SanitizeIpAddress(string ipAddressIn)
{
try
{
var ipAddress = IPAddress.Parse(ipAddressIn.TrimStart('0'));
return ipAddress.ToString();
}
catch (Exception ex)
{
Debug.LogMessage(LogEventLevel.Information, "Unable to Santize Ip : {0}", ex.Message);
return ipAddressIn;
}
}
/// <summary>
/// Resolves a hostname by IP Address using DNS
/// </summary>
/// <param name="ipAddress">IP Address to resolve from</param>
/// <returns>Resolved Hostname - on failure to determine hostname, will return IP Address</returns>
public static string ResolveHostnameFromIp(string ipAddress)
{
try
{
var santitizedIp = SanitizeIpAddress(ipAddress);
var hostEntry = Dns.GetHostEntry(santitizedIp);
return hostEntry == null ? ipAddress : hostEntry.HostName;
}
catch (Exception ex)
{
Debug.LogMessage(LogEventLevel.Information, "Exception Resolving Hostname from IP Address : {0}", ex.Message);
return ipAddress;
}
}
/// <summary>
/// Resolves an IP Address by hostname using DNS
/// </summary>
/// <param name="hostName">Hostname to resolve from</param>
/// <returns>Resolved IP Address - on a failure to determine IP Address, will return hostname</returns>
public static string ResolveIpFromHostname(string hostName)
{
try
{
var hostEntry = Dns.GetHostEntry(hostName);
return hostEntry == null ? hostName : hostEntry.AddressList.First().ToString();
}
catch (Exception ex)
{
Debug.LogMessage(LogEventLevel.Information, "Exception Resolving IP Address from Hostname : {0}", ex.Message);
return hostName;
}
}
}
/// <summary>
/// Object to hold data about an arp entry
/// </summary>
public class ArpEntry
{
public readonly IPAddress IpAddress;
public readonly string MacAddress;
/// <summary>
/// Constructs new ArpEntry object
/// </summary>
/// <param name="ipAddress">string formatted as ipv4 address</param>
/// <param name="macAddress">mac address string - format is unimportant</param>
public ArpEntry(string ipAddress, string macAddress)
{
if (string.IsNullOrEmpty(ipAddress))
{
throw new ArgumentException("\"ipAddress\" cannot be null or empty");
}
if (string.IsNullOrEmpty(macAddress))
{
throw new ArgumentException("\"macAddress\" cannot be null or empty");
}
IpAddress = IPAddress.Parse(ipAddress.TrimStart().TrimStart('0').TrimEnd());
MacAddress = macAddress;
}
}
/// <summary>
/// Arguments passed by the ArpTableUpdated event
/// </summary>
public class ArpTableEventArgs : EventArgs
{
/// <summary>
/// The retrieved ARP Table
/// </summary>
public readonly List<ArpEntry> ArpTable;
/// <summary>
/// True if there was a problem retrieving the ARP Table
/// </summary>
public readonly bool Error;
/// <summary>
/// Constructor for ArpTableEventArgs
/// </summary>
/// <param name="arpTable">The entirety of the retrieved ARP table</param>
/// <param name="error">True of an error was encountered updating the ARP table</param>
public ArpTableEventArgs(List<ArpEntry> arpTable, bool error)
{
ArpTable = arpTable;
Error = error;
}
/// <summary>
/// Constructor for ArpTableEventArgs - assumes no error encountered in retrieving ARP Table
/// </summary>
/// <param name="arpTable">The entirety of the retrieved ARP table</param>
public ArpTableEventArgs(List<ArpEntry> arpTable)
{
ArpTable = arpTable;
Error = false;
}
}
}

View File

@@ -1,14 +0,0 @@
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();
}
}

View File

@@ -1,36 +0,0 @@
using PepperDash.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
{
/// <summary>
/// Describes a device that has selectable inputs
/// </summary>
/// <typeparam name="TKey">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>
[Obsolete("Use IHasInputs<T> instead. Will be removed for 2.0 release")]
public interface IHasInputs<T, TSelector>: IKeyName
{
ISelectableItems<T> Inputs { get; }
}
/// <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; }
}
}

View File

@@ -1,20 +0,0 @@
using PepperDash.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
{
/// <summary>
/// Describes a device that has selectable surround sound modes
/// </summary>
/// <typeparam name="TKey">the type to use as the key for each input item. Most likely an enum or string</typeparam>
public interface IHasSurroundSoundModes<TKey, TSelector>: IKeyName
{
ISelectableItems<TKey> SurroundSoundModes { get; }
void SetSurroundSoundMode(TSelector selector);
}
}

View File

@@ -1,18 +0,0 @@
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; }
}
}

View File

@@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
{
public interface ILevelControls
{
Dictionary<string, IBasicVolumeWithFeedback> LevelControlPoints { get; }
}
}

View File

@@ -1,18 +1,9 @@
using System; using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Core; using PepperDash.Core;
namespace PepperDash.Essentials.Core.DeviceTypeInterfaces namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
{ {
/// <summary> /// <summary>
/// Use this interface on a device or room if it uses custom Mobile Control messengers
/// </summary>
public interface ICustomMobileControl : IKeyed
{
}
/*/// <summary>
/// Describes a MobileControlSystemController /// Describes a MobileControlSystemController
/// </summary> /// </summary>
public interface IMobileControl : IKeyed public interface IMobileControl : IKeyed
@@ -20,64 +11,20 @@ namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
void CreateMobileControlRoomBridge(IEssentialsRoom room, IMobileControl parent); void CreateMobileControlRoomBridge(IEssentialsRoom room, IMobileControl parent);
void LinkSystemMonitorToAppServer(); void LinkSystemMonitorToAppServer();
}*/ }
/// <summary> /// <summary>
/// Describes a MobileSystemController that accepts IEssentialsRoom /// Describes a MobileSystemController that accepts IEssentialsRoom
/// </summary> /// </summary>
public interface IMobileControl : IKeyed public interface IMobileControl3 : IMobileControl
{ {
string Host { get; } void CreateMobileControlRoomBridge(IEssentialsRoom room, IMobileControl parent);
string ClientAppUrl { get; }
string SystemUuid { get; }
BoolFeedback ApiOnlineAndAuthorized { get;}
void SendMessageObject(IMobileControlMessage o);
void AddAction<T>(T messenger, Action<string, string, JToken> action) where T:IMobileControlMessenger;
void RemoveAction(string key);
void AddDeviceMessenger(IMobileControlMessenger messenger);
bool CheckForDeviceMessenger(string key);
IMobileControlRoomMessenger GetRoomMessenger(string key);
}
/// <summary>
/// Describes a mobile control messenger
/// </summary>
public interface IMobileControlMessenger: IKeyed
{
IMobileControl AppServerController { get; }
string MessagePath { get; }
string DeviceKey { get; }
void RegisterWithAppServer(IMobileControl appServerController);
}
public interface IMobileControlMessage
{
[JsonProperty("type")]
string Type { get; }
[JsonProperty("clientId", NullValueHandling = NullValueHandling.Ignore)]
string ClientId { get; }
[JsonProperty("content", NullValueHandling = NullValueHandling.Ignore)]
JToken Content { get; }
} }
/// <summary> /// <summary>
/// Describes a MobileControl Room Bridge /// Describes a MobileControl Room Bridge
/// </summary> /// </summary>
public interface IMobileControlRoomMessenger : IKeyed public interface IMobileControlRoomBridge : IKeyed
{ {
event EventHandler<EventArgs> UserCodeChanged; event EventHandler<EventArgs> UserCodeChanged;
@@ -85,8 +32,6 @@ namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
event EventHandler<EventArgs> ClientJoined; event EventHandler<EventArgs> ClientJoined;
event EventHandler<EventArgs> AppUrlChanged;
string UserCode { get; } string UserCode { get; }
string QrCodeUrl { get; } string QrCodeUrl { get; }
@@ -96,24 +41,5 @@ namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
string McServerUrl { get; } string McServerUrl { get; }
string RoomName { get; } string RoomName { get; }
string AppUrl { get; }
void UpdateAppUrl(string url);
}
public interface IMobileControlAction
{
IMobileControlMessenger Messenger { get; }
Action<string,string, JToken> Action { get; }
}
public interface IMobileControlTouchpanelController : IKeyed
{
string DefaultRoomKey { get; }
void SetAppUrl(string url);
bool UseDirectServer { get; }
bool ZoomRoomController { get; }
} }
} }

View File

@@ -1,27 +0,0 @@
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
}
}

View File

@@ -1,19 +0,0 @@
using System;
using Newtonsoft.Json;
using PepperDash.Core;
namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
{
/// <summary>
/// Describes an item that can be selected
/// </summary>
public interface ISelectableItem : IKeyName
{
event EventHandler ItemUpdated;
[JsonProperty("isSelected")]
bool IsSelected { get; set; }
void Select();
}
}

View File

@@ -1,22 +0,0 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
{
/// <summary>
/// Describes a collection of items that can be selected
/// </summary>
/// <typeparam name="TKey">type for the keys in the collection. Probably a string or enum</typeparam>
public interface ISelectableItems<TKey>
{
event EventHandler ItemsUpdated;
event EventHandler CurrentItemChanged;
[JsonProperty("items")]
Dictionary<TKey, ISelectableItem> Items { get; set; }
[JsonProperty("currentItem")]
TKey CurrentItem { get; set; }
}
}

View File

@@ -1,22 +0,0 @@
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);
}
}

View File

@@ -1,42 +0,0 @@
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; }
}
}

View File

@@ -1,76 +0,0 @@
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; }
}
}

View File

@@ -6,7 +6,6 @@ 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
{ {
@@ -46,7 +45,7 @@ namespace PepperDash.Essentials.Core.Devices
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Debug, this, "Error Getting Relays from processor:\n '{0}'", e); Debug.Console(1, this, "Error Getting Relays from processor:\n '{0}'", e);
} }
} }
} }

View File

@@ -1,6 +1,6 @@
extern alias Full;
using Newtonsoft.Json; using Full.Newtonsoft.Json;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Core namespace PepperDash.Essentials.Core
@@ -52,11 +52,5 @@ 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; }
} }
} }

View File

@@ -1,13 +1,16 @@
using Crestron.SimplSharp; extern alias Full;
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.Reflection; using System.Text;
using System.Threading.Tasks; using Crestron.SimplSharp;
using Crestron.SimplSharp.Reflection;
using Full.Newtonsoft.Json;
using PepperDash.Core;
namespace PepperDash.Essentials.Core namespace PepperDash.Essentials.Core
{ {
@@ -31,7 +34,7 @@ namespace PepperDash.Essentials.Core
DoDeviceAction(action); DoDeviceAction(action);
} }
catch (Exception) catch (Exception ex)
{ {
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]}");
} }
@@ -59,7 +62,7 @@ namespace PepperDash.Essentials.Core
action.Params = new object[0]; action.Params = new object[0];
} }
Type t = obj.GetType(); CType 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();
@@ -78,19 +81,7 @@ namespace PepperDash.Essentials.Core
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();
Task.Run(() =>
{
try
{
Debug.LogMessage(LogEventLevel.Verbose, "Calling method {methodName} on device {deviceKey}", null, method.Name, action.DeviceKey);
method.Invoke(obj, convertedParams); method.Invoke(obj, convertedParams);
}
catch (Exception e)
{
Debug.LogMessage(e, "Error invoking method {methodName} on device {deviceKey}", null, method.Name, action.DeviceKey);
}
});
CrestronConsole.ConsoleCommandResponse("Method {0} successfully called on device {1}", method.Name, CrestronConsole.ConsoleCommandResponse("Method {0} successfully called on device {1}", method.Name,
action.DeviceKey); action.DeviceKey);
@@ -98,71 +89,7 @@ namespace PepperDash.Essentials.Core
catch (Exception ex) catch (Exception ex)
{ {
CrestronConsole.ConsoleCommandResponse("Unable to call method with name {0}. {1}", action.MethodName, CrestronConsole.ConsoleCommandResponse("Unable to call method with name {0}. {1}", action.MethodName,
ex.Message); ex.Message);}
}
}
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 (action.Params == null)
{
//no params, so setting action.Params to empty array
action.Params = new object[0];
}
Type t = obj.GetType();
try
{
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);
if (method == null)
{
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) private static object ConvertType(object value, Type conversionType)
@@ -193,7 +120,7 @@ namespace PepperDash.Essentials.Core
if (obj == null) if (obj == null)
return "{ \"error\":\"No Device\"}"; return "{ \"error\":\"No Device\"}";
Type t = obj.GetType(); CType 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
var props = t.GetProperties().Select(p => new PropertyNameType(p, obj)); var props = t.GetProperties().Select(p => new PropertyNameType(p, obj));
return JsonConvert.SerializeObject(props, Formatting.Indented); return JsonConvert.SerializeObject(props, Formatting.Indented);
@@ -208,10 +135,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().GetProperty(propertyName).GetValue(dev, null); object prop = dev.GetType().GetCType().GetProperty(propertyName).GetValue(dev, null);
// var prop = t.GetProperty(propertyName); // var prop = t.GetProperty(propertyName);
if (prop != null) if (prop != null)
@@ -220,7 +147,7 @@ namespace PepperDash.Essentials.Core
} }
else else
{ {
Debug.LogMessage(LogEventLevel.Debug, "Unable to find Property: {0} on Device with path: {1}", propertyName, deviceObjectPath); Debug.Console(1, "Unable to find Property: {0} on Device with path: {1}", propertyName, deviceObjectPath);
return null; return null;
} }
} }
@@ -237,7 +164,7 @@ namespace PepperDash.Essentials.Core
return "{ \"error\":\"No Device\"}"; return "{ \"error\":\"No Device\"}";
// Package up method names using helper objects // Package up method names using helper objects
Type t = obj.GetType(); CType 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));
@@ -251,7 +178,7 @@ namespace PepperDash.Essentials.Core
return "{ \"error\":\"No Device\"}"; return "{ \"error\":\"No Device\"}";
// Package up method names using helper objects // Package up method names using helper objects
Type t = obj.GetType(); CType 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())
@@ -271,7 +198,7 @@ namespace PepperDash.Essentials.Core
var dev = DeviceManager.GetDeviceForKey(path[0]); var dev = DeviceManager.GetDeviceForKey(path[0]);
if (dev == null) if (dev == null)
{ {
Debug.LogMessage(LogEventLevel.Information, "Device {0} not found", path[0]); Debug.Console(0, "Device {0} not found", path[0]);
return null; return null;
} }
@@ -289,20 +216,20 @@ namespace PepperDash.Essentials.Core
var indexClose = objName.IndexOf(']'); var indexClose = objName.IndexOf(']');
if (indexClose == -1) if (indexClose == -1)
{ {
Debug.LogMessage(LogEventLevel.Information, dev, "ERROR Unmatched index brackets"); Debug.Console(0, 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.LogMessage(LogEventLevel.Information, dev, " Checking for collection '{0}', index '{1}'", objName, indexStr); Debug.Console(0, dev, " Checking for collection '{0}', index '{1}'", objName, indexStr);
} }
Type oType = obj.GetType(); CType oType = obj.GetType();
var prop = oType.GetProperty(objName); var prop = oType.GetProperty(objName);
if (prop == null) if (prop == null)
{ {
Debug.LogMessage(LogEventLevel.Information, dev, "Property {0} not found on {1}", objName, path[i - 1]); Debug.Console(0, 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
@@ -310,7 +237,7 @@ namespace PepperDash.Essentials.Core
{ {
if (!typeof(ICollection).IsAssignableFrom(prop.PropertyType)) if (!typeof(ICollection).IsAssignableFrom(prop.PropertyType))
{ {
Debug.LogMessage(LogEventLevel.Information, dev, "Property {0} is not collection", objName); Debug.Console(0, 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;
@@ -320,7 +247,7 @@ namespace PepperDash.Essentials.Core
var indexParams = indexedPropInfo.GetIndexParameters(); var indexParams = indexedPropInfo.GetIndexParameters();
if (indexParams.Length > 0) if (indexParams.Length > 0)
{ {
Debug.LogMessage(LogEventLevel.Information, " Indexed, param type: {0}", indexParams[0].ParameterType.Name); Debug.Console(0, " 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
@@ -328,12 +255,12 @@ namespace PepperDash.Essentials.Core
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 (TargetInvocationException e) catch (Crestron.SimplSharp.Reflection.TargetInvocationException e)
{ {
if (e.InnerException is ArgumentOutOfRangeException) if (e.InnerException is ArgumentOutOfRangeException)
Debug.LogMessage(LogEventLevel.Information, " Index Out of range"); Debug.Console(0, " Index Out of range");
else if (e.InnerException is KeyNotFoundException) else if (e.InnerException is KeyNotFoundException)
Debug.LogMessage(LogEventLevel.Information, " Key not found"); Debug.Console(0, " Key not found");
return null; return null;
} }
} }
@@ -359,7 +286,7 @@ namespace PepperDash.Essentials.Core
//if (obj == null) //if (obj == null)
// return "{\"error\":\"No object found\"}"; // return "{\"error\":\"No object found\"}";
//Type t = obj.GetType(); //CType 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
@@ -379,15 +306,13 @@ namespace PepperDash.Essentials.Core
public class PropertyNameType public class PropertyNameType
{ {
private object Parent; 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 public string Value { get
{
get
{ {
if (PropInfo.CanRead) if (PropInfo.CanRead)
{ {
@@ -402,8 +327,7 @@ namespace PepperDash.Essentials.Core
} }
else else
return null; 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; } }
@@ -422,14 +346,10 @@ namespace PepperDash.Essentials.Core
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 public IEnumerable<NameType> Params { get {
{
get
{
return MethodInfo.GetParameters().Select(p => return MethodInfo.GetParameters().Select(p =>
new NameType { Name = p.Name, Type = p.ParameterType.Name }); new NameType { Name = p.Name, Type = p.ParameterType.Name });
} } }
}
public MethodNameParams(MethodInfo info) public MethodNameParams(MethodInfo info)
{ {
@@ -444,7 +364,7 @@ namespace PepperDash.Essentials.Core
} }
[AttributeUsage(AttributeTargets.All)] [AttributeUsage(AttributeTargets.All)]
public class ApiAttribute : Attribute public class ApiAttribute : CAttribute
{ {
} }

View File

@@ -1,11 +1,12 @@
using Crestron.SimplSharp; using System;
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
@@ -14,15 +15,13 @@ namespace PepperDash.Essentials.Core
{ {
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; } } //public static List<Device> Devices { get { return _Devices; } }
//static List<Device> _Devices = new List<Device>(); //static List<Device> _Devices = new List<Device>();
private static readonly Dictionary<string, IKeyed> Devices = new Dictionary<string, IKeyed>(StringComparer.OrdinalIgnoreCase); static readonly Dictionary<string, IKeyed> Devices = new Dictionary<string, IKeyed>(StringComparer.OrdinalIgnoreCase);
/// <summary> /// <summary>
/// Returns a copy of all the devices in a list /// Returns a copy of all the devices in a list
@@ -64,7 +63,7 @@ namespace PepperDash.Essentials.Core
DeviceCriticalSection.Enter(); DeviceCriticalSection.Enter();
AddDeviceEnabled = false; AddDeviceEnabled = false;
// PreActivate all devices // PreActivate all devices
Debug.LogMessage(LogEventLevel.Information, "****PreActivation starting...****"); Debug.Console(0,"****PreActivation starting...****");
foreach (var d in Devices.Values) foreach (var d in Devices.Values)
{ {
try try
@@ -74,12 +73,12 @@ namespace PepperDash.Essentials.Core
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Information, d, "ERROR: Device {1} PreActivation failure: {0}", e.Message, d.Key); Debug.Console(0, d, "ERROR: Device {1} PreActivation failure: {0}", e.Message, d.Key);
Debug.LogMessage(LogEventLevel.Debug, d, "Stack Trace: {0}", e.StackTrace); Debug.Console(1, d, "Stack Trace: {0}", e.StackTrace);
} }
} }
Debug.LogMessage(LogEventLevel.Information, "****PreActivation complete****"); Debug.Console(0, "****PreActivation complete****");
Debug.LogMessage(LogEventLevel.Information, "****Activation starting...****"); Debug.Console(0, "****Activation starting...****");
// Activate all devices // Activate all devices
foreach (var d in Devices.Values) foreach (var d in Devices.Values)
@@ -91,13 +90,13 @@ namespace PepperDash.Essentials.Core
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Information, d, "ERROR: Device {1} Activation failure: {0}", e.Message, d.Key); Debug.Console(0, d, "ERROR: Device {1} Activation failure: {0}", e.Message, d.Key);
Debug.LogMessage(LogEventLevel.Debug, d, "Stack Trace: {0}", e.StackTrace); Debug.Console(1, d, "Stack Trace: {0}", e.StackTrace);
} }
} }
Debug.LogMessage(LogEventLevel.Information, "****Activation complete****"); Debug.Console(0, "****Activation complete****");
Debug.LogMessage(LogEventLevel.Information, "****PostActivation starting...****"); Debug.Console(0, "****PostActivation starting...****");
// PostActivate all devices // PostActivate all devices
foreach (var d in Devices.Values) foreach (var d in Devices.Values)
@@ -109,12 +108,12 @@ namespace PepperDash.Essentials.Core
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Information, d, "ERROR: Device {1} PostActivation failure: {0}", e.Message, d.Key); Debug.Console(0, d, "ERROR: Device {1} PostActivation failure: {0}", e.Message, d.Key);
Debug.LogMessage(LogEventLevel.Debug, d, "Stack Trace: {0}", e.StackTrace); Debug.Console(1, d, "Stack Trace: {0}", e.StackTrace);
} }
} }
Debug.LogMessage(LogEventLevel.Information, "****PostActivation complete****"); Debug.Console(0, "****PostActivation complete****");
OnAllDevicesActivated(); OnAllDevicesActivated();
} }
@@ -124,18 +123,6 @@ namespace PepperDash.Essentials.Core
} }
} }
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()
{ {
var handler = AllDevicesActivated; var handler = AllDevicesActivated;
@@ -154,15 +141,6 @@ namespace PepperDash.Essentials.Core
} }
} }
private static void OnAllDevicesInitialized()
{
var handler = AllDevicesInitialized;
if (handler != null)
{
handler(null, new EventArgs());
}
}
/// <summary> /// <summary>
/// Calls activate on all Device class items /// Calls activate on all Device class items
/// </summary> /// </summary>
@@ -187,7 +165,7 @@ namespace PepperDash.Essentials.Core
// var dev = GetDeviceForKey(devKey); // var dev = GetDeviceForKey(devKey);
// if(dev != null) // if(dev != null)
// { // {
// var type = dev.GetType().GetType(); // var type = dev.GetType().GetCType();
// var methods = type.GetMethods(BindingFlags.Public|BindingFlags.Instance); // var methods = type.GetMethods(BindingFlags.Public|BindingFlags.Instance);
// var sb = new StringBuilder(); // var sb = new StringBuilder();
// sb.AppendLine(string.Format("{2} methods on [{0}] ({1}):", dev.Key, type.Name, methods.Length)); // sb.AppendLine(string.Format("{2} methods on [{0}] ({1}):", dev.Key, type.Name, methods.Length));
@@ -205,14 +183,14 @@ namespace PepperDash.Essentials.Core
private static void ListDevices(string s) private static void ListDevices(string s)
{ {
Debug.LogMessage(LogEventLevel.Information, "{0} Devices registered with Device Manager:", Devices.Count); Debug.Console(0, "{0} Devices registered with Device Manager:", Devices.Count);
var sorted = Devices.Values.ToList(); var sorted = Devices.Values.ToList();
sorted.Sort((a, b) => a.Key.CompareTo(b.Key)); sorted.Sort((a, b) => a.Key.CompareTo(b.Key));
foreach (var d in sorted) foreach (var d in sorted)
{ {
var name = d is IKeyName ? (d as IKeyName).Name : "---"; var name = d is IKeyName ? (d as IKeyName).Name : "---";
Debug.LogMessage(LogEventLevel.Information, " [{0}] {1}", d.Key, name); Debug.Console(0, " [{0}] {1}", d.Key, name);
} }
} }
@@ -221,12 +199,13 @@ namespace PepperDash.Essentials.Core
var dev = GetDeviceForKey(devKey); var dev = GetDeviceForKey(devKey);
if (dev == null) if (dev == null)
{ {
Debug.LogMessage(LogEventLevel.Information, "Device '{0}' not found", devKey); Debug.Console(0, "Device '{0}' not found", devKey);
return; return;
} }
if (!(dev is IHasFeedback statusDev)) var statusDev = dev as IHasFeedback;
if (statusDev == null)
{ {
Debug.LogMessage(LogEventLevel.Information, "Device '{0}' does not have visible feedbacks", devKey); Debug.Console(0, "Device '{0}' does not have visible feedbacks", devKey);
return; return;
} }
statusDev.DumpFeedbacksToConsole(true); statusDev.DumpFeedbacksToConsole(true);
@@ -237,25 +216,27 @@ namespace PepperDash.Essentials.Core
// var dev = GetDeviceForKey(devKey); // var dev = GetDeviceForKey(devKey);
// if (dev == null) // if (dev == null)
// { // {
// Debug.LogMessage(LogEventLevel.Information, "Device '{0}' not found", devKey); // Debug.Console(0, "Device '{0}' not found", devKey);
// return; // return;
// } // }
// Debug.LogMessage(LogEventLevel.Information, "This needs to be reworked. Stay tuned.", devKey); // Debug.Console(0, "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>())
{ {
CrestronConsole.ConsoleCommandResponse($"{dev}: {dev.CommunicationMonitor.Status}{Environment.NewLine}"); sb.Append(string.Format("{0}: {1}\r", dev,
dev.CommunicationMonitor.Status));
} }
CrestronConsole.ConsoleCommandResponse(sb.ToString());
} }
//static void DoDeviceCommand(string command) //static void DoDeviceCommand(string command)
//{ //{
// Debug.LogMessage(LogEventLevel.Information, "Not yet implemented. Stay tuned"); // Debug.Console(0, "Not yet implemented. Stay tuned");
//} //}
public static void AddDevice(IKeyed newDev) public static void AddDevice(IKeyed newDev)
@@ -264,7 +245,7 @@ namespace PepperDash.Essentials.Core
{ {
if (!DeviceCriticalSection.TryEnter()) if (!DeviceCriticalSection.TryEnter())
{ {
Debug.LogMessage(LogEventLevel.Information, "Currently unable to add devices to Device Manager. Please try again"); Debug.Console(0, Debug.ErrorLogLevel.Error, "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
@@ -274,21 +255,18 @@ namespace PepperDash.Essentials.Core
if (!AddDeviceEnabled) if (!AddDeviceEnabled)
{ {
Debug.LogMessage(LogEventLevel.Information, "All devices have been activated. Adding new devices is not allowed."); Debug.Console(0, Debug.ErrorLogLevel.Error, "All devices have been activated. Adding new devices is not allowed.");
return; return;
} }
if (Devices.ContainsKey(newDev.Key)) if (Devices.ContainsKey(newDev.Key))
{ {
Debug.LogMessage(LogEventLevel.Information, newDev, "WARNING: A device with this key already exists. Not added to manager"); Debug.Console(0, 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);
if (newDev is EssentialsDevice essentialsDev)
essentialsDev.Initialized += DeviceManager_Initialized;
} }
finally finally
{ {
@@ -302,13 +280,13 @@ namespace PepperDash.Essentials.Core
{ {
if (!DeviceCriticalSection.TryEnter()) if (!DeviceCriticalSection.TryEnter())
{ {
Debug.LogMessage(LogEventLevel.Information, Debug.Console(0, Debug.ErrorLogLevel.Error,
"Currently unable to add devices to Device Manager. Please try again"); "Currently unable to add devices to Device Manager. Please try again");
return; return;
} }
if (!AddDeviceEnabled) if (!AddDeviceEnabled)
{ {
Debug.LogMessage(LogEventLevel.Information, Debug.Console(0, Debug.ErrorLogLevel.Error,
"All devices have been activated. Adding new devices is not allowed."); "All devices have been activated. Adding new devices is not allowed.");
return; return;
} }
@@ -321,7 +299,7 @@ namespace PepperDash.Essentials.Core
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
Debug.LogMessage(LogEventLevel.Information, "Error adding device with key {0} to Device Manager: {1}\r\nStack Trace: {2}", Debug.Console(0, "Error adding device with key {0} to Device Manager: {1}\r\nStack Trace: {2}",
dev.Key, ex.Message, ex.StackTrace); dev.Key, ex.Message, ex.StackTrace);
} }
} }
@@ -344,7 +322,7 @@ namespace PepperDash.Essentials.Core
//if (_Devices.Contains(newDev)) //if (_Devices.Contains(newDev))
// _Devices.Remove(newDev); // _Devices.Remove(newDev);
else else
Debug.LogMessage(LogEventLevel.Information, "Device manager: Device '{0}' does not exist in manager. Cannot remove", newDev.Key); Debug.Console(0, "Device manager: Device '{0}' does not exist in manager. Cannot remove", newDev.Key);
} }
finally finally
{ {
@@ -386,9 +364,10 @@ 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.LogMessage(LogEventLevel.Verbose, "**** {0} - {1} ****", match.Groups[1].Value, match.Groups[2].Value); //Debug.Console(2, "**** {0} - {1} ****", match.Groups[1].Value, match.Groups[2].Value);
if (!(GetDeviceForKey(match.Groups[1].Value) is ComPortController com)) var com = GetDeviceForKey(match.Groups[1].Value) as ComPortController;
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;
@@ -409,17 +388,19 @@ namespace PepperDash.Essentials.Core
var outputPorts = ((device as IRoutingOutputs) != null) ? (device as IRoutingOutputs).OutputPorts : null; var outputPorts = ((device as IRoutingOutputs) != null) ? (device as IRoutingOutputs).OutputPorts : null;
if (inputPorts != null) if (inputPorts != null)
{ {
CrestronConsole.ConsoleCommandResponse("Device {0} has {1} Input Ports:{2}", s, inputPorts.Count, CrestronEnvironment.NewLine); Debug.Console(0, "Device {0} has {1} Input Ports:", s, inputPorts.Count);
foreach (var routingInputPort in inputPorts) foreach (var routingInputPort in inputPorts)
{ {
CrestronConsole.ConsoleCommandResponse("{0}{1}", routingInputPort.Key, CrestronEnvironment.NewLine); Debug.Console(0, "{0}", routingInputPort.Key);
} }
} }
if (outputPorts == null) return; if (outputPorts != null)
CrestronConsole.ConsoleCommandResponse("Device {0} has {1} Output Ports:{2}", s, outputPorts.Count, CrestronEnvironment.NewLine); {
Debug.Console(0, "Device {0} has {1} Output Ports:", s, outputPorts.Count);
foreach (var routingOutputPort in outputPorts) foreach (var routingOutputPort in outputPorts)
{ {
CrestronConsole.ConsoleCommandResponse("{0}{1}", routingOutputPort.Key, CrestronEnvironment.NewLine); Debug.Console(0, "{0}", routingOutputPort.Key);
}
} }
} }
@@ -443,17 +424,18 @@ 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 (!(GetDeviceForKey(deviceKey) is IStreamDebugging device)) if (device == null)
{ {
CrestronConsole.ConsoleCommandResponse("Unable to get device with key: {0}", deviceKey); Debug.Console(0, "Unable to get device with key: {0}", deviceKey);
return; return;
} }
@@ -465,7 +447,7 @@ namespace PepperDash.Essentials.Core
} }
catch catch
{ {
CrestronConsole.ConsoleCommandResponse("Unable to convert setting value. Please use off/rx/tx/both"); Debug.Console(0, "Unable to convert setting value. Please use off/rx/tx/both");
return; return;
} }
@@ -476,18 +458,18 @@ namespace PepperDash.Essentials.Core
var min = Convert.ToUInt32(timeout); var min = Convert.ToUInt32(timeout);
device.StreamDebugging.SetDebuggingWithSpecificTimeout(debugSetting, min); device.StreamDebugging.SetDebuggingWithSpecificTimeout(debugSetting, min);
CrestronConsole.ConsoleCommandResponse("Device: '{0}' debug level set to {1} for {2} minutes", deviceKey, debugSetting, min); Debug.Console(0, "Device: '{0}' debug level set to {1} for {2} minutes", deviceKey, debugSetting, min);
} }
catch (Exception e) catch (Exception e)
{ {
CrestronConsole.ConsoleCommandResponse("Unable to convert minutes or settings value. Please use an integer value for minutes. Error: {0}", e); Debug.Console(0, "Unable to convert minutes or settings value. Please use an integer value for minutes. Errro: {0}", e);
} }
} }
else else
{ {
device.StreamDebugging.SetDebuggingWithDefaultTimeout(debugSetting); device.StreamDebugging.SetDebuggingWithDefaultTimeout(debugSetting);
CrestronConsole.ConsoleCommandResponse("Device: '{0}' debug level set to {1} for default time (30 minutes)", deviceKey, debugSetting); Debug.Console(0, "Device: '{0}' debug level set to {1} for default time (30 minutes)", deviceKey, debugSetting);
} }
} }
@@ -498,7 +480,9 @@ namespace PepperDash.Essentials.Core
{ {
foreach (var device in AllDevices) foreach (var device in AllDevices)
{ {
if (device is IStreamDebugging streamDevice) var streamDevice = device as IStreamDebugging;
if (streamDevice != null)
{ {
streamDevice.StreamDebugging.SetDebuggingWithDefaultTimeout(eStreamDebuggingSetting.Off); streamDevice.StreamDebugging.SetDebuggingWithDefaultTimeout(eStreamDebuggingSetting.Off);
} }

View File

@@ -3,11 +3,10 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using System.Reflection; using Crestron.SimplSharp.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
{ {
@@ -17,24 +16,6 @@ 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)
{ {
@@ -59,30 +40,14 @@ namespace PepperDash.Essentials.Core
try try
{ {
Initialize(); Initialize();
IsInitialized = true;
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.LogMessage(LogEventLevel.Error, this, "Exception initializing device: {0}", ex.Message); Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Exception initializing device: {0}", ex.Message);
Debug.LogMessage(LogEventLevel.Debug, this, "Stack Trace: {0}", ex.StackTrace); Debug.Console(1, this, Debug.ErrorLogLevel.Error, "Stack Trace: {0}", ex.StackTrace);
} }
}); });
} }
public override bool CustomActivate()
{
CreateMobileControlMessengers();
return base.CustomActivate();
}
/// <summary>
/// Override this method to build and create custom Mobile Control Messengers during the Activation phase
/// </summary>
protected virtual void CreateMobileControlMessengers() {
}
} }
[AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = true)] [AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = true)]
@@ -92,7 +57,7 @@ namespace PepperDash.Essentials.Core
public DescriptionAttribute(string description) public DescriptionAttribute(string description)
{ {
//Debug.LogMessage(LogEventLevel.Verbose, "Setting Description: {0}", description); //Debug.Console(2, "Setting Description: {0}", description);
_Description = description; _Description = description;
} }
@@ -109,7 +74,7 @@ namespace PepperDash.Essentials.Core
public ConfigSnippetAttribute(string configSnippet) public ConfigSnippetAttribute(string configSnippet)
{ {
//Debug.LogMessage(LogEventLevel.Verbose, "Setting Config Snippet {0}", configSnippet); //Debug.Console(2, "Setting Config Snippet {0}", configSnippet);
_ConfigSnippet = configSnippet; _ConfigSnippet = configSnippet;
} }
@@ -138,7 +103,7 @@ namespace PepperDash.Essentials.Core
{ {
foreach (var typeName in TypeNames) foreach (var typeName in TypeNames)
{ {
//Debug.LogMessage(LogEventLevel.Verbose, "Getting Description Attribute from class: '{0}'", typeof(T).FullName); //Debug.Console(2, "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[];
@@ -156,41 +121,6 @@ namespace PepperDash.Essentials.Core
#endregion #endregion
} }
public abstract class ProcessorExtensionDeviceFactory<T> : IProcessorExtensionDeviceFactory where T: EssentialsDevice
{
#region IProcessorExtensionDeviceFactory Members
/// <summary>
/// A list of strings that can be used in the type property of a DeviceConfig object to build an instance of this device
/// </summary>
public List<string> TypeNames { get; protected set; }
/// <summary>
/// Loads an item to the ProcessorExtensionDeviceFactory.ProcessorExtensionFactoryMethods dictionary for each entry in the TypeNames list
/// </summary>
public void LoadFactories()
{
foreach (var typeName in TypeNames)
{
//Debug.LogMessage(LogEventLevel.Verbose, "Getting Description Attribute from class: '{0}'", typeof(T).FullName);
var descriptionAttribute = typeof(T).GetCustomAttributes(typeof(DescriptionAttribute), true) as DescriptionAttribute[];
string description = descriptionAttribute[0].Description;
var snippetAttribute = typeof(T).GetCustomAttributes(typeof(ConfigSnippetAttribute), true) as ConfigSnippetAttribute[];
ProcessorExtensionDeviceFactory.AddFactoryForType(typeName.ToLower(), description, typeof(T), BuildDevice);
}
}
/// <summary>
/// The method that will build the device
/// </summary>
/// <param name="dc">The device config</param>
/// <returns>An instance of the device</returns>
public abstract EssentialsDevice BuildDevice(DeviceConfig dc);
#endregion
}
/// <summary> /// <summary>
/// Devices the basic needs for a Device Factory /// Devices the basic needs for a Device Factory
/// </summary> /// </summary>

View File

@@ -1,15 +1,13 @@
extern alias Full;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DeviceSupport;
using Newtonsoft.Json; using Full.Newtonsoft.Json;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials.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 Serilog.Events;
namespace PepperDash.Essentials.Core.Devices namespace PepperDash.Essentials.Core.Devices
{ {
@@ -28,9 +26,10 @@ namespace PepperDash.Essentials.Core.Devices
public GenericIrController(string key, string name, IrOutputPortController irPort) : base(key, name) public GenericIrController(string key, string name, IrOutputPortController irPort) : base(key, name)
{ {
_port = irPort; _port = irPort;
if (_port == null) if (_port == null)
{ {
Debug.LogMessage(LogEventLevel.Information, this, "IR Port is null, device will not function"); Debug.Console(0, this, Debug.ErrorLogLevel.Error, "IR Port is null, device will not function");
return; return;
} }
DeviceManager.AddDevice(_port); DeviceManager.AddDevice(_port);
@@ -74,51 +73,10 @@ namespace PepperDash.Essentials.Core.Devices
if (!string.IsNullOrEmpty(joinMapSerialized)) if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<GenericIrControllerJoinMap>(joinMapSerialized); joinMap = JsonConvert.DeserializeObject<GenericIrControllerJoinMap>(joinMapSerialized);
if (_port.UseBridgeJoinMap)
{
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);
if (bridgeJoins == null)
{
Debug.LogMessage(LogEventLevel.Information, this, "Failed to link new IR bridge join map");
return;
}
joinMap.Joins.Clear();
foreach (var bridgeJoin in bridgeJoins)
{
var key = bridgeJoin.Key;
var joinDataKey = bridgeJoin.Value.Key;
var joinDataValue = bridgeJoin.Value.Value;
var joinNumber = bridgeJoin.Value.Value.JoinNumber;
Debug.LogMessage(LogEventLevel.Verbose, this, @"bridgeJoin: Key-'{0}'
Value.Key-'{1}'
Value.JoinNumber-'{2}'
Value.Metadata.Description-'{3}'",
key,
joinDataKey,
joinNumber,
joinDataValue.Metadata.Description);
joinMap.Joins.Add(key, joinDataValue);
trilist.SetBoolSigAction(joinNumber, (b) => Press(key, b));
}
}
else
{
Debug.LogMessage(LogEventLevel.Information, this, "Using legacy IR join mapping based on available IR commands");
joinMap.Joins.Clear();
for (uint i = 0; i < _port.IrFileCommands.Length; i++) for (uint i = 0; i < _port.IrFileCommands.Length; i++)
{ {
var cmd = _port.IrFileCommands[i]; var cmd = _port.IrFileCommands[i];
var joinData = new JoinDataComplete(new JoinData { JoinNumber = i, JoinSpan = 1 }, var joinData = new JoinDataComplete(new JoinData {JoinNumber = i, JoinSpan = 1},
new JoinMetadata new JoinMetadata
{ {
Description = cmd, Description = cmd,
@@ -128,11 +86,10 @@ Value.Metadata.Description-'{3}'",
joinData.SetJoinOffset(joinStart); joinData.SetJoinOffset(joinStart);
joinMap.Joins.Add(cmd, joinData); joinMap.Joins.Add(cmd,joinData);
trilist.SetBoolSigAction(joinData.JoinNumber, (b) => Press(cmd, b)); trilist.SetBoolSigAction(joinData.JoinNumber, (b) => Press(cmd, b));
} }
}
joinMap.PrintJoinMapInfo(); joinMap.PrintJoinMapInfo();
@@ -142,7 +99,7 @@ Value.Metadata.Description-'{3}'",
} }
else else
{ {
Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
} }
} }
@@ -154,6 +111,13 @@ Value.Metadata.Description-'{3}'",
} }
} }
public sealed class GenericIrControllerJoinMap : JoinMapBaseAdvanced
{
public GenericIrControllerJoinMap(uint joinStart) : base(joinStart)
{
}
}
public class GenericIrControllerFactory : EssentialsDeviceFactory<GenericIrController> public class GenericIrControllerFactory : EssentialsDeviceFactory<GenericIrController>
{ {
public GenericIrControllerFactory() public GenericIrControllerFactory()
@@ -164,7 +128,7 @@ Value.Metadata.Description-'{3}'",
public override EssentialsDevice BuildDevice(DeviceConfig dc) public override EssentialsDevice BuildDevice(DeviceConfig dc)
{ {
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Generic IR Controller Device"); Debug.Console(1, "Factory Attempting to create new Generic IR Controller Device");
var irPort = IRPortHelper.GetIrOutputPortController(dc); var irPort = IRPortHelper.GetIrOutputPortController(dc);

View File

@@ -5,7 +5,6 @@ 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
@@ -26,7 +25,7 @@ namespace PepperDash.Essentials.Core.Devices
// ------------------------------------------------------DELETE THIS // ------------------------------------------------------DELETE THIS
CommunicationMonitor.StatusChange += (o, a) => CommunicationMonitor.StatusChange += (o, a) =>
{ {
Debug.LogMessage(LogEventLevel.Verbose, this, "Communication monitor status change: {0}", a.Status); Debug.Console(2, this, "Communication monitor status change: {0}", a.Status);
}; };
} }

View File

@@ -0,0 +1,17 @@
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; }
}
}

View File

@@ -1,12 +0,0 @@
using PepperDash.Core;
using System.Collections.Generic;
namespace PepperDash.Essentials.Core
{
public interface IDspPresets
{
Dictionary<string, IKeyName> Presets { get; }
void RecallPreset(string key);
}
}

View File

@@ -1,8 +1,9 @@
using System; using System.Collections.Generic;
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
{ {
@@ -21,14 +22,14 @@ namespace PepperDash.Essentials.Core
{ {
public static void DumpFeedbacksToConsole(this IHasFeedback source, bool getCurrentStates) public static void DumpFeedbacksToConsole(this IHasFeedback source, bool getCurrentStates)
{ {
Type t = source.GetType(); CType 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.LogMessage(LogEventLevel.Information, source, "\n\nAvailable feedbacks:"); Debug.Console(0, source, "\n\nAvailable feedbacks:");
foreach (var f in feedbacks) foreach (var f in feedbacks)
{ {
string val = ""; string val = "";
@@ -51,12 +52,12 @@ namespace PepperDash.Essentials.Core
type = "string"; type = "string";
} }
} }
Debug.LogMessage(LogEventLevel.Information, "{0,-12} {1, -25} {2}", type, Debug.Console(0, "{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.LogMessage(LogEventLevel.Information, source, "No available outputs:"); Debug.Console(0, source, "No available outputs:");
} }
} }
} }

View File

@@ -4,7 +4,6 @@ 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
{ {
@@ -85,14 +84,14 @@ namespace PepperDash.Essentials.Core
if (handler != null) if (handler != null)
{ {
Debug.LogMessage(LogEventLevel.Debug, "Device Usage Ended for: {0} at {1}. In use for {2} minutes.", Parent.Name, UsageEndTime, timeUsed.Minutes); Debug.Console(1, "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.LogMessage(LogEventLevel.Debug, "Error ending device usage: {0}", e); Debug.Console(1, "Error ending device usage: {0}", e);
} }
} }
} }

View File

@@ -64,24 +64,6 @@ 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.
@@ -90,10 +72,6 @@ namespace PepperDash.Essentials.Core
{ {
IBasicVolumeControls CurrentVolumeControls { get; } IBasicVolumeControls CurrentVolumeControls { get; }
event EventHandler<VolumeDeviceChangeEventArgs> CurrentVolumeDeviceChange; event EventHandler<VolumeDeviceChangeEventArgs> CurrentVolumeDeviceChange;
void SetDefaultLevels();
bool ZeroVolumeWhenSwtichingVolumeDevices { get; }
} }

View File

@@ -1,4 +1,4 @@
extern alias Full;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -6,12 +6,11 @@ using System.Linq;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DeviceSupport;
using Newtonsoft.Json.Linq; using Full.Newtonsoft.Json.Linq;
using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Config;
using PepperDash.Core; using PepperDash.Core;
using Serilog.Events;
namespace PepperDash.Essentials.Core namespace PepperDash.Essentials.Core
{ {
@@ -32,8 +31,6 @@ namespace PepperDash.Essentials.Core
public string[] IrFileCommands { get { return IrPort.AvailableStandardIRCmds(IrPortUid); } } public string[] IrFileCommands { get { return IrPort.AvailableStandardIRCmds(IrPortUid); } }
public bool UseBridgeJoinMap { get; private set; }
/// <summary> /// <summary>
/// Constructor for IrDevice base class. If a null port is provided, this class will /// Constructor for IrDevice base class. If a null port is provided, this class will
/// still function without trying to talk to a port. /// still function without trying to talk to a port.
@@ -47,7 +44,7 @@ namespace PepperDash.Essentials.Core
IrPort = port; IrPort = port;
if (port == null) if (port == null)
{ {
Debug.LogMessage(LogEventLevel.Information, this, "WARNING No valid IR Port assigned to controller. IR will not function"); Debug.Console(0, this, "WARNING No valid IR Port assigned to controller. IR will not function");
return; return;
} }
LoadDriver(irDriverFilepath); LoadDriver(irDriverFilepath);
@@ -58,19 +55,18 @@ namespace PepperDash.Essentials.Core
: base(key) : base(key)
{ {
DriverLoaded = new BoolFeedback(() => DriverIsLoaded); DriverLoaded = new BoolFeedback(() => DriverIsLoaded);
UseBridgeJoinMap = config.Properties["control"].Value<bool>("useBridgeJoinMap");
AddPostActivationAction(() => AddPostActivationAction(() =>
{ {
IrPort = postActivationFunc(config); IrPort = postActivationFunc(config);
if (IrPort == null) if (IrPort == null)
{ {
Debug.LogMessage(LogEventLevel.Information, this, "WARNING No valid IR Port assigned to controller. IR will not function"); Debug.Console(0, 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.LogMessage(LogEventLevel.Debug, "*************Attempting to load IR file: {0}***************", filePath); Debug.Console(1, "*************Attempting to load IR file: {0}***************", filePath);
LoadDriver(filePath); LoadDriver(filePath);
@@ -80,10 +76,10 @@ namespace PepperDash.Essentials.Core
public void PrintAvailableCommands() public void PrintAvailableCommands()
{ {
Debug.LogMessage(LogEventLevel.Verbose, this, "Available IR Commands in IR File {0}", IrPortUid); Debug.Console(2, this, "Available IR Commands in IR File {0}", IrPortUid);
foreach (var cmd in IrPort.AvailableIRCmds()) foreach (var cmd in IrPort.AvailableIRCmds())
{ {
Debug.LogMessage(LogEventLevel.Verbose, this, "{0}", cmd); Debug.Console(2, this, "{0}", cmd);
} }
} }
@@ -94,7 +90,7 @@ namespace PepperDash.Essentials.Core
/// <param name="path"></param> /// <param name="path"></param>
public void LoadDriver(string path) public void LoadDriver(string path)
{ {
Debug.LogMessage(LogEventLevel.Verbose, this, "***Loading IR File***"); Debug.Console(2, this, "***Loading IR File***");
if (string.IsNullOrEmpty(path)) path = DriverFilepath; if (string.IsNullOrEmpty(path)) path = DriverFilepath;
try try
{ {
@@ -109,7 +105,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.LogMessage(LogEventLevel.Information, this, message); Debug.Console(0, this, Debug.ErrorLogLevel.Error, message);
DriverLoaded.FireUpdate(); DriverLoaded.FireUpdate();
} }
} }
@@ -120,15 +116,15 @@ namespace PepperDash.Essentials.Core
/// </summary> /// </summary>
public virtual void PressRelease(string command, bool state) public virtual void PressRelease(string command, bool state)
{ {
Debug.LogMessage(LogEventLevel.Verbose, this, "IR:'{0}'={1}", command, state); Debug.Console(2, this, "IR:'{0}'={1}", command, state);
if (IrPort == null) if (IrPort == null)
{ {
Debug.LogMessage(LogEventLevel.Verbose, this, "WARNING No IR Port assigned to controller"); Debug.Console(2, this, "WARNING No IR Port assigned to controller");
return; return;
} }
if (!DriverIsLoaded) if (!DriverIsLoaded)
{ {
Debug.LogMessage(LogEventLevel.Verbose, this, "WARNING IR driver is not loaded"); Debug.Console(2, this, "WARNING IR driver is not loaded");
return; return;
} }
if (state) if (state)
@@ -149,12 +145,12 @@ namespace PepperDash.Essentials.Core
{ {
if (IrPort == null) if (IrPort == null)
{ {
Debug.LogMessage(LogEventLevel.Verbose, this, "WARNING No IR Port assigned to controller"); Debug.Console(2, this, "WARNING No IR Port assigned to controller");
return; return;
} }
if (!DriverIsLoaded) if (!DriverIsLoaded)
{ {
Debug.LogMessage(LogEventLevel.Verbose, this, "WARNING IR driver is not loaded"); Debug.Console(2, this, "WARNING IR driver is not loaded");
return; return;
} }
if (IrPort.IsIRCommandAvailable(IrPortUid, command)) if (IrPort.IsIRCommandAvailable(IrPortUid, command))
@@ -168,7 +164,7 @@ namespace PepperDash.Essentials.Core
/// </summary> /// </summary>
protected void NoIrCommandError(string command) protected void NoIrCommandError(string command)
{ {
Debug.LogMessage(LogEventLevel.Verbose, this, "Device {0}: IR Driver {1} does not contain command {2}", Debug.Console(2, this, "Device {0}: IR Driver {1} does not contain command {2}",
Key, IrPort.IRDriverFileNameByIRDriverId(IrPortUid), command); Key, IrPort.IRDriverFileNameByIRDriverId(IrPortUid), command);
} }
} }

View File

@@ -1,82 +0,0 @@
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,
}
}

View File

@@ -5,12 +5,14 @@ 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
{ {
[Obsolete("Please use PepperDash.Essentials.Devices.Common, this will be removed in 2.1")] /// <summary>
/// This DVD class should cover most IR, one-way DVD and Bluray fuctions
/// </summary>
public class InRoomPc : EssentialsDevice, IHasFeedback, IRoutingOutputs, IAttachVideoStatus, IUiDisplayInfo, IUsageTracking public class InRoomPc : EssentialsDevice, IHasFeedback, IRoutingOutputs, IAttachVideoStatus, IUiDisplayInfo, IUsageTracking
{ {
public uint DisplayUiType { get { return DisplayUiConstants.TypeLaptop; } } public uint DisplayUiType { get { return DisplayUiConstants.TypeLaptop; } }
@@ -63,7 +65,6 @@ namespace PepperDash.Essentials.Core.Devices
#endregion #endregion
} }
[Obsolete("Please use PepperDash.Essentials.Devices.Common, this will be removed in 2.1")]
public class InRoomPcFactory : EssentialsDeviceFactory<InRoomPc> public class InRoomPcFactory : EssentialsDeviceFactory<InRoomPc>
{ {
public InRoomPcFactory() public InRoomPcFactory()
@@ -73,7 +74,7 @@ namespace PepperDash.Essentials.Core.Devices
public override EssentialsDevice BuildDevice(DeviceConfig dc) public override EssentialsDevice BuildDevice(DeviceConfig dc)
{ {
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new InRoomPc Device"); Debug.Console(1, "Factory Attempting to create new InRoomPc Device");
return new InRoomPc(dc.Key, dc.Name); return new InRoomPc(dc.Key, dc.Name);
} }
} }

View File

@@ -5,13 +5,14 @@ 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
{ {
/// <summary>
[Obsolete("Please use PepperDash.Essentials.Devices.Common, this will be removed in 2.1")] /// This DVD class should cover most IR, one-way DVD and Bluray fuctions
/// </summary>
public class Laptop : EssentialsDevice, IHasFeedback, IRoutingOutputs, IAttachVideoStatus, IUiDisplayInfo, IUsageTracking public class Laptop : EssentialsDevice, IHasFeedback, IRoutingOutputs, IAttachVideoStatus, IUiDisplayInfo, IUsageTracking
{ {
public uint DisplayUiType { get { return DisplayUiConstants.TypeLaptop; } } public uint DisplayUiType { get { return DisplayUiConstants.TypeLaptop; } }
@@ -64,17 +65,16 @@ namespace PepperDash.Essentials.Core.Devices
#endregion #endregion
} }
[Obsolete("Please use PepperDash.Essentials.Devices.Common, this will be removed in 2.1")]
public class LaptopFactory : EssentialsDeviceFactory<Laptop> public class LaptopFactory : EssentialsDeviceFactory<Laptop>
{ {
public LaptopFactory() public LaptopFactory()
{ {
TypeNames = new List<string>() { "deprecated" }; TypeNames = new List<string>() { "laptop" };
} }
public override EssentialsDevice BuildDevice(DeviceConfig dc) public override EssentialsDevice BuildDevice(DeviceConfig dc)
{ {
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Laptop Device"); Debug.Console(1, "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);
} }
} }

View File

@@ -1,10 +1,9 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Core.Devices namespace PepperDash_Essentials_Core.Devices
{ {
/// <summary> /// <summary>
/// Interface for any device that is able to control it'spower and has a configurable reboot time /// Interface for any device that is able to control it'spower and has a configurable reboot time

View File

@@ -1,87 +0,0 @@
using Crestron.SimplSharp;
using PepperDash.Core;
namespace PepperDash.Essentials.Core
{
/// <summary>
/// Interface for any device that has a battery that can be monitored
/// </summary>
public interface IHasBatteryStats : IKeyName
{
int BatteryPercentage { get; }
int BatteryCautionThresholdPercentage { get; }
int BatteryWarningThresholdPercentage { get; }
BoolFeedback BatteryIsWarningFeedback { get; }
BoolFeedback BatteryIsCautionFeedback { get; }
BoolFeedback BatteryIsOkFeedback { get; }
IntFeedback BatteryPercentageFeedback { get; }
}
/// <summary>
/// Interface for any device that has a battery that can be monitored and the ability to charge and discharge
/// </summary>
public interface IHasBatteryCharging : IHasBatteryStats
{
BoolFeedback BatteryIsCharging { get; }
}
/// <summary>
/// Interface for any device that has multiple batteries that can be monitored
/// </summary>
public interface IHasBatteries : IKeyName
{
ReadOnlyDictionary<string, IHasBatteryStats> Batteries { get; }
}
public interface IHasBatteryStatsExtended : IHasBatteryStats
{
int InputVoltage { get; }
int OutputVoltage { get; }
int InptuCurrent { get; }
int OutputCurrent { get; }
IntFeedback InputVoltageFeedback { get; }
IntFeedback OutputVoltageFeedback { get; }
IntFeedback InputCurrentFeedback { get; }
IntFeedback OutputCurrentFeedback { get; }
}
/// <summary>
/// Interface for any device that is able to control its power, has a configurable reboot time, and has batteries that can be monitored
/// </summary>
public interface IHasPowerCycleWithBattery : IHasPowerCycle, IHasBatteryStats
{
}
/// <summary>
/// Interface for any device that is able to control it's power and has a configurable reboot time
/// </summary>
public interface IHasPowerCycle : IKeyName, IHasPowerControlWithFeedback
{
/// <summary>
/// Delay between power off and power on for reboot
/// </summary>
int PowerCycleTimeMs { get; }
/// <summary>
/// Reboot outlet
/// </summary>
void PowerCycle();
}
/// <summary>
/// Interface for any device that contains a collection of IHasPowerReboot Devices
/// </summary>
public interface IHasControlledPowerOutlets : IKeyName
{
/// <summary>
/// Collection of IPduOutlets
/// </summary>
ReadOnlyDictionary<int, IHasPowerCycle> PduOutlets { get; }
}
}

View File

@@ -1,45 +0,0 @@
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;
}
}
}
}

View File

@@ -1,4 +1,4 @@
extern alias Full;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -9,8 +9,8 @@ using Crestron.SimplSharpPro.DeviceSupport;
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 Newtonsoft.Json; using Full.Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Full.Newtonsoft.Json.Linq;
namespace PepperDash.Essentials.Core.Devices namespace PepperDash.Essentials.Core.Devices
{ {

View File

@@ -1,7 +1,15 @@
using Newtonsoft.Json; extern alias Full;
using Newtonsoft.Json.Converters;
using PepperDash.Core; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO;
using Crestron.SimplSharpPro;
using Full.Newtonsoft.Json;
using Full.Newtonsoft.Json.Converters;
using Full.Newtonsoft.Json.Linq;
using PepperDash.Core;
namespace PepperDash.Essentials.Core namespace PepperDash.Essentials.Core
{ {
@@ -34,8 +42,7 @@ namespace PepperDash.Essentials.Core
return _SourceDevice; return _SourceDevice;
} }
} }
Device _SourceDevice;
private Device _SourceDevice;
/// <summary> /// <summary>
/// Gets either the source's Name or this AlternateName property, if /// Gets either the source's Name or this AlternateName property, if
@@ -137,27 +144,12 @@ namespace PepperDash.Essentials.Core
[JsonProperty("isAudioSource")] [JsonProperty("isAudioSource")]
public bool IsAudioSource { get; set; } public bool IsAudioSource { get; set; }
/// <summary>
/// Hide source on UI when Avanced Sharing is enabled
/// </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() public SourceListItem()
{ {
Icon = "Blank"; Icon = "Blank";
} }
public override string ToString()
{
return $"{SourceKey}:{Name}";
}
} }
public class SourceRouteListItem public class SourceRouteListItem
@@ -165,15 +157,9 @@ namespace PepperDash.Essentials.Core
[JsonProperty("sourceKey")] [JsonProperty("sourceKey")]
public string SourceKey { get; set; } public string SourceKey { get; set; }
[JsonProperty("sourcePortKey")]
public string SourcePortKey { get; set; }
[JsonProperty("destinationKey")] [JsonProperty("destinationKey")]
public string DestinationKey { get; set; } public string DestinationKey { get; set; }
[JsonProperty("destinationPortKey")]
public string DestinationPortKey { get; set; }
[JsonProperty("type")] [JsonProperty("type")]
public eRoutingSignalType Type { get; set; } public eRoutingSignalType Type { get; set; }
} }
@@ -186,12 +172,7 @@ namespace PepperDash.Essentials.Core
defaultDisplay, defaultDisplay,
leftDisplay, leftDisplay,
rightDisplay, rightDisplay,
centerDisplay,
programAudio, programAudio,
codecContent, codecContent
frontLeftDisplay,
frontRightDisplay,
rearLeftDisplay,
rearRightDisplay,
} }
} }

View File

@@ -10,11 +10,11 @@ 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 Serilog.Events; using PepperDash.Essentials.Core.Routing;
namespace PepperDash.Essentials.Core namespace PepperDash.Essentials.Core
{ {
[Obsolete("Please use PepperDash.Essentials.Device.Common, this will be removed in 2.1")] [Description("Wrapper class for a Basic IR Display")]
public class BasicIrDisplay : DisplayBase, IBasicVolumeControls, IBridgeAdvanced public class BasicIrDisplay : DisplayBase, IBasicVolumeControls, IBridgeAdvanced
{ {
public IrOutputPortController IrPort { get; private set; } public IrOutputPortController IrPort { get; private set; }
@@ -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.LogMessage(LogEventLevel.Verbose, this, "Warming up={0}", _IsWarmingUp); IsWarmingUpFeedback.OutputChange += (o, a) => Debug.Console(2, this, "Warming up={0}", _IsWarmingUp);
IsCoolingDownFeedback.OutputChange += (o, a) => Debug.LogMessage(LogEventLevel.Verbose, this, "Cooling down={0}", _IsCoolingDown); IsCoolingDownFeedback.OutputChange += (o, a) => Debug.Console(2, 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.LogMessage(LogEventLevel.Verbose, this, "Switching to input '{0}'", (inputSelector as Action).ToString()); Debug.Console(2, this, "Switching to input '{0}'", (inputSelector as Action).ToString());
Action finishSwitch = () => Action finishSwitch = () =>
{ {
@@ -203,7 +203,6 @@ namespace PepperDash.Essentials.Core
} }
} }
[Obsolete("Please use PepperDash.Essentials.Device.Common, this will be removed in 2.1")]
public class BasicIrDisplayFactory : EssentialsDeviceFactory<BasicIrDisplay> public class BasicIrDisplayFactory : EssentialsDeviceFactory<BasicIrDisplay>
{ {
public BasicIrDisplayFactory() public BasicIrDisplayFactory()
@@ -213,7 +212,7 @@ namespace PepperDash.Essentials.Core
public override EssentialsDevice BuildDevice(DeviceConfig dc) public override EssentialsDevice BuildDevice(DeviceConfig dc)
{ {
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new BasicIrDisplay Device"); Debug.Console(1, "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)
{ {

View File

@@ -1,23 +1,28 @@
extern alias Full;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DeviceSupport;
using Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Essentials.Core.Bridges;
using Serilog.Events;
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.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport;
using Crestron.SimplSharpPro.DM;
using Crestron.SimplSharpPro.DM.Endpoints;
using Crestron.SimplSharpPro.DM.Endpoints.Transmitters;
using Full.Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Essentials.Core.Bridges;
namespace PepperDash.Essentials.Core namespace PepperDash.Essentials.Core
{ {
[Obsolete("Please use PepperDash.Essentials.Devices.Common, this will be removed in 2.1")] /// <summary>
///
/// </summary>
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
@@ -94,8 +99,6 @@ namespace PepperDash.Essentials.Core
} }
} }
public RoutingInputPort CurrentInputPort => throw new NotImplementedException();
public abstract void ExecuteSwitch(object selector); 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,
@@ -114,7 +117,7 @@ namespace PepperDash.Essentials.Core
} }
else else
{ {
Debug.LogMessage(LogEventLevel.Information,this,"Please update config to use 'eiscapiadvanced' to get all join map features for this device."); Debug.Console(0,this,"Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
} }
LinkDisplayToApi(displayDevice, trilist, joinMap); LinkDisplayToApi(displayDevice, trilist, joinMap);
@@ -122,8 +125,8 @@ namespace PepperDash.Essentials.Core
protected void LinkDisplayToApi(DisplayBase displayDevice, BasicTriList trilist, DisplayControllerJoinMap joinMap) protected void LinkDisplayToApi(DisplayBase displayDevice, BasicTriList trilist, DisplayControllerJoinMap joinMap)
{ {
Debug.LogMessage(LogEventLevel.Debug, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
Debug.LogMessage(LogEventLevel.Information, "Linking to Display: {0}", displayDevice.Name); Debug.Console(0, "Linking to Display: {0}", displayDevice.Name);
trilist.StringInput[joinMap.Name.JoinNumber].StringValue = displayDevice.Name; trilist.StringInput[joinMap.Name.JoinNumber].StringValue = displayDevice.Name;
@@ -145,7 +148,7 @@ namespace PepperDash.Essentials.Core
{ {
trilist.SetBool(joinMap.IsTwoWayDisplay.JoinNumber, true); trilist.SetBool(joinMap.IsTwoWayDisplay.JoinNumber, true);
twoWayDisplay.CurrentInputFeedback.OutputChange += (o, a) => Debug.LogMessage(LogEventLevel.Information, "CurrentInputFeedback_OutputChange {0}", a.StringValue); twoWayDisplay.CurrentInputFeedback.OutputChange += (o, a) => Debug.Console(0, "CurrentInputFeedback_OutputChange {0}", a.StringValue);
inputNumberFeedback.LinkInputSig(trilist.UShortInput[joinMap.InputSelect.JoinNumber]); inputNumberFeedback.LinkInputSig(trilist.UShortInput[joinMap.InputSelect.JoinNumber]);
@@ -199,16 +202,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.LogMessage(LogEventLevel.Verbose, displayDevice, "Setting Input Select Action on Digital Join {0} to Input: {1}", Debug.Console(2, 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.LogMessage(LogEventLevel.Information, displayDevice, "Device has {0} inputs. The Join Map allows up to {1} inputs. Discarding inputs {2} - {3} from bridge.", 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.",
displayDevice.InputPorts.Count, joinMap.InputNamesOffset.JoinSpan, i + 1, displayDevice.InputPorts.Count); displayDevice.InputPorts.Count, joinMap.InputNamesOffset.JoinSpan, i + 1, displayDevice.InputPorts.Count);
} }
Debug.LogMessage(LogEventLevel.Verbose, displayDevice, "Setting Input Select Action on Analog Join {0}", joinMap.InputSelect); Debug.Console(2, 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)
@@ -254,7 +257,9 @@ namespace PepperDash.Essentials.Core
} }
[Obsolete("Please use PepperDash.Essentials.Devices.Common, this will be removed in 2.1")] /// <summary>
///
/// </summary>
public abstract class TwoWayDisplayBase : DisplayBase, IRoutingFeedback, IHasPowerControlWithFeedback public abstract class TwoWayDisplayBase : DisplayBase, IRoutingFeedback, IHasPowerControlWithFeedback
{ {
public StringFeedback CurrentInputFeedback { get; private set; } public StringFeedback CurrentInputFeedback { get; private set; }
@@ -266,16 +271,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)

View File

@@ -0,0 +1,237 @@
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
{
/// <summary>
///
/// </summary>
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);
}
}
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);
}
}
}

View File

@@ -1,12 +1,12 @@
extern alias Full;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Newtonsoft.Json; using Full.Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Full.Newtonsoft.Json.Linq;
namespace PepperDash.Essentials.Core namespace PepperDash.Essentials.Core
{ {

View File

@@ -1,5 +1,4 @@
using System; using System;
using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -9,70 +8,17 @@ namespace PepperDash.Essentials.Core
{ {
public static class StringExtensions public static class StringExtensions
{ {
/// <summary>
/// Returns null if a string is empty, otherwise returns the string
/// </summary>
/// <param name="s">string input</param>
/// <returns>null if the string is emtpy, otherwise returns the string</returns>
public static string NullIfEmpty(this string s) public static string NullIfEmpty(this string s)
{ {
return string.IsNullOrEmpty(s) ? null : s; return string.IsNullOrEmpty(s) ? null : s;
} }
/// <summary>
/// Returns null if a string is empty or made of only whitespace characters, otherwise returns the string
/// </summary>
/// <param name="s">string input</param>
/// <returns>null if the string is wempty or made of only whitespace characters, otherwise returns the string</returns>
public static string NullIfWhiteSpace(this string s) public static string NullIfWhiteSpace(this string s)
{ {
return string.IsNullOrEmpty(s.Trim()) ? null : s; return string.IsNullOrEmpty(s.Trim()) ? null : s;
} }
/// <summary>
/// Returns a replacement string if the input string is empty or made of only whitespace characters, otherwise returns the input string
/// </summary>
/// <param name="s">input string</param>
/// <param name="newString">string to replace with if input string is empty or whitespace</param>
/// <returns>returns newString if s is null, emtpy, or made of whitespace characters, otherwise returns s</returns>
public static string ReplaceIfNullOrEmpty(this string s, string newString) public static string ReplaceIfNullOrEmpty(this string s, string newString)
{ {
return string.IsNullOrEmpty(s) ? newString : s; return string.IsNullOrEmpty(s) ? newString : s;
} }
/// <summary>
/// Overload for Contains that allows setting an explicit String Comparison
/// </summary>
/// <param name="source">Source String</param>
/// <param name="toCheck">String to check in Source String</param>
/// <param name="comp">Comparison parameters</param>
/// <returns>true of string contains "toCheck"</returns>
public static bool Contains(this string source, string toCheck, StringComparison comp)
{
if (string.IsNullOrEmpty(source)) return false;
return source.IndexOf(toCheck, comp) >= 0;
}
/// <summary>
/// Performs TrimStart() and TrimEnd() on source string
/// </summary>
/// <param name="source">String to Trim</param>
/// <returns>Trimmed String</returns>
public static string TrimAll(this string source)
{
return string.IsNullOrEmpty(source) ? string.Empty : source.TrimStart().TrimEnd();
}
/// <summary>
/// Performs TrimStart(chars char[]) and TrimEnd(chars char[]) on source string.
/// </summary>
/// <param name="source">String to Trim</param>
/// <param name="chars">Char Array to trim from string</param>
/// <returns>Trimmed String</returns>
public static string TrimAll(this string source, char[] chars)
{
return string.IsNullOrEmpty(source) ? string.Empty : source.TrimStart(chars).TrimEnd(chars);
}
} }
} }

View File

@@ -1,26 +1,32 @@
extern alias Full;
using Crestron.SimplSharp;
using System.Reflection;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
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;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.GeneralIO;
using Crestron.SimplSharp.Reflection;
using PepperDash.Core;
using Full.Newtonsoft.Json.Linq;
using Full.Newtonsoft.Json;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.CrestronIO;
using PepperDash.Essentials.Core.Touchpanels;
namespace PepperDash.Essentials.Core namespace PepperDash.Essentials.Core
{ {
public class DeviceFactoryWrapper public class DeviceFactoryWrapper
{ {
public Type Type { get; set; } public CType CType { 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()
{ {
Type = null; CType = null;
Description = "Not Available"; Description = "Not Available";
} }
} }
@@ -40,12 +46,12 @@ namespace PepperDash.Essentials.Core
{ {
try try
{ {
var factory = (IDeviceFactory)Activator.CreateInstance(type); var factory = (IDeviceFactory)Crestron.SimplSharp.Reflection.Activator.CreateInstance(type);
factory.LoadTypeFactories(); factory.LoadTypeFactories();
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Information, "Unable to load type: '{1}' DeviceFactory: {0}", e, type.Name); Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to load type: '{1}' DeviceFactory: {0}", e, type.Name);
} }
} }
} }
@@ -65,21 +71,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.LogMessage(LogEventLevel.Debug, "Adding factory method for type '{0}'", typeName); //Debug.Console(1, Debug.ErrorLogLevel.Notice, "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, Type Type, Func<DeviceConfig, IKeyed> method) public static void AddFactoryForType(string typeName, string description, CType cType, Func<DeviceConfig, IKeyed> method)
{ {
//Debug.LogMessage(LogEventLevel.Debug, "Adding factory method for type '{0}'", typeName); //Debug.Console(1, Debug.ErrorLogLevel.Notice, "Adding factory method for type '{0}'", typeName);
if(FactoryMethods.ContainsKey(typeName)) if(FactoryMethods.ContainsKey(typeName))
{ {
Debug.LogMessage(LogEventLevel.Information, "Unable to add type: '{0}'. Already exists in DeviceFactory", typeName); Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to add type: '{0}'. Already exists in DeviceFactory", typeName);
return; return;
} }
var wrapper = new DeviceFactoryWrapper() { Type = Type, Description = description, FactoryMethod = method }; var wrapper = new DeviceFactoryWrapper() { CType = cType, Description = description, FactoryMethod = method };
DeviceFactory.FactoryMethods.Add(typeName, wrapper); DeviceFactory.FactoryMethods.Add(typeName, wrapper);
} }
@@ -105,7 +111,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.LogMessage(LogEventLevel.Debug, Debug.Console(1,
"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;
@@ -122,7 +128,7 @@ namespace PepperDash.Essentials.Core
{ {
try try
{ {
Debug.LogMessage(LogEventLevel.Information, "Loading '{0}' from Essentials Core", dc.Type); Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading '{0}' from Essentials Core", dc.Type);
var localDc = new DeviceConfig(dc); var localDc = new DeviceConfig(dc);
@@ -143,13 +149,24 @@ namespace PepperDash.Essentials.Core
CheckForSecrets(jProp); CheckForSecrets(jProp);
} }
Debug.LogMessage(LogEventLevel.Verbose, "typeName = {0}", typeName); Debug.Console(2, "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.LogMessage(ex, "Exception occurred while creating device {0}: {1}", null, dc.Key, ex.Message); Debug.Console(0, Debug.ErrorLogLevel.Error, "Exception occurred while creating device {0}: {1}", 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;
} }
} }
@@ -157,29 +174,36 @@ namespace PepperDash.Essentials.Core
/// <summary> /// <summary>
/// Prints the type names and associated metadata from the FactoryMethods collection. /// Prints the type names and associated metadata from the FactoryMethods collection.
/// </summary> /// </summary>
/// <param name="filter"></param> /// <param name="command"></param>
public static void GetDeviceFactoryTypes(string filter) public static void GetDeviceFactoryTypes(string filter)
{ {
var types = !string.IsNullOrEmpty(filter) Dictionary<string, DeviceFactoryWrapper> types = new Dictionary<string, DeviceFactoryWrapper>();
? FactoryMethods.Where(k => k.Key.Contains(filter)).ToDictionary(k => k.Key, k => k.Value)
: FactoryMethods;
CrestronConsole.ConsoleCommandResponse("Device Types:"); if (!string.IsNullOrEmpty(filter))
{
types = FactoryMethods.Where(k => k.Key.Contains(filter)).ToDictionary(k => k.Key, k => k.Value);
}
else
{
types = FactoryMethods;
}
Debug.Console(0, "Device Types:");
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 Type = "Not Specified by Plugin"; var cType = "Not Specified by Plugin";
if (type.Value.Type != null) if(type.Value.CType != null)
{ {
Type = type.Value.Type.FullName; cType = type.Value.CType.FullName;
} }
CrestronConsole.ConsoleCommandResponse( Debug.Console(0,
@"Type: '{0}' @"Type: '{0}'
Type: '{1}' CType: '{1}'
Description: {2}{3}", type.Key, Type, description, CrestronEnvironment.NewLine); Description: {2}", type.Key, cType, description);
} }
} }

View File

@@ -1,4 +1,14 @@
namespace PepperDash.Essentials.Core using System;
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

View File

@@ -1,16 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PepperDash.Essentials.Core
{
public interface IProcessorExtensionDeviceFactory
{
/// <summary>
/// Loads all the extension factories to the ProcessorExtensionDeviceFactory
/// </summary>
void LoadFactories();
}
}

View File

@@ -1,154 +0,0 @@
using System.Reflection;
using PepperDash.Core;
using PepperDash.Essentials.Core.Config;
using Serilog.Events;
using System;
using System.Collections.Generic;
using System.Linq;
namespace PepperDash.Essentials.Core
{
public class ProcessorExtensionDeviceFactory
{
public ProcessorExtensionDeviceFactory() {
var assy = Assembly.GetExecutingAssembly();
PluginLoader.SetEssentialsAssembly(assy.GetName().Name, assy);
var extensions = assy.GetTypes().Where(ct => typeof(IProcessorExtensionDeviceFactory)
.IsAssignableFrom(ct) && !ct.IsInterface && !ct.IsAbstract);
if (extensions != null )
{
foreach ( var extension in extensions )
{
try
{
var factory = (IProcessorExtensionDeviceFactory)Activator.CreateInstance(extension);
factory.LoadFactories();
}
catch( Exception e )
{
Debug.LogMessage(LogEventLevel.Information, "Unable to load extension device: '{1}' ProcessorExtensionDeviceFactory: {0}", e, extension.Name);
}
}
}
}
/// <summary>
/// A dictionary of factory methods, keyed by config types, added by plugins.
/// These methods are looked up and called by GetDevice in this class.
/// </summary>
static Dictionary<string, DeviceFactoryWrapper> ProcessorExtensionFactoryMethods =
new Dictionary<string, DeviceFactoryWrapper>(StringComparer.OrdinalIgnoreCase);
/// <summary>
/// Adds a plugin factory method
/// </summary>
/// <param name="dc"></param>
/// <returns></returns>
public static void AddFactoryForType(string extensionName, Func<DeviceConfig, IKeyed> method)
{
//Debug.LogMessage(LogEventLevel.Debug, "Adding factory method for type '{0}'", typeName);
ProcessorExtensionDeviceFactory.ProcessorExtensionFactoryMethods.Add(extensionName, new DeviceFactoryWrapper() { FactoryMethod = method });
}
public static void AddFactoryForType(string extensionName, string description, Type Type, Func<DeviceConfig, IKeyed> method)
{
//Debug.LogMessage(LogEventLevel.Debug, "Adding factory method for type '{0}'", typeName);
if (ProcessorExtensionFactoryMethods.ContainsKey(extensionName))
{
Debug.LogMessage(LogEventLevel.Information, "Unable to add extension device: '{0}'. Already exists in ProcessorExtensionDeviceFactory", extensionName);
return;
}
var wrapper = new DeviceFactoryWrapper() { Type = Type, Description = description, FactoryMethod = method };
ProcessorExtensionDeviceFactory.ProcessorExtensionFactoryMethods.Add(extensionName, wrapper);
}
private static void CheckForSecrets(IEnumerable<Newtonsoft.Json.Linq.JProperty> obj)
{
foreach (var prop in obj.Where(prop => prop.Value as Newtonsoft.Json.Linq.JObject != null))
{
if (prop.Name.ToLower() == "secret")
{
var secret = GetSecret(prop.Children().First().ToObject<SecretsPropertiesConfig>());
//var secret = GetSecret(JsonConvert.DeserializeObject<SecretsPropertiesConfig>(prop.Children().First().ToString()));
prop.Parent.Replace(secret);
}
var recurseProp = prop.Value as Newtonsoft.Json.Linq.JObject;
if (recurseProp == null) return;
CheckForSecrets(recurseProp.Properties());
}
}
private static string GetSecret(SecretsPropertiesConfig data)
{
var secretProvider = SecretsManager.GetSecretProviderByKey(data.Provider);
if (secretProvider == null) return null;
var secret = secretProvider.GetSecret(data.Key);
if (secret != null) return (string)secret.Value;
Debug.LogMessage(LogEventLevel.Debug,
"Unable to retrieve secret {0}{1} - Make sure you've added it to the secrets provider",
data.Provider, data.Key);
return String.Empty;
}
/// <summary>
/// The factory method for processor extension devices. Also iterates the Factory methods that have
/// been loaded from plugins
/// </summary>
/// <param name="dc"></param>
/// <returns></returns>
public static IKeyed GetExtensionDevice(DeviceConfig dc)
{
try
{
Debug.LogMessage(LogEventLevel.Information, "Loading '{0}' from Essentials Core", dc.Type);
var localDc = new DeviceConfig(dc);
var key = localDc.Key;
var name = localDc.Name;
var type = localDc.Type;
var properties = localDc.Properties;
//var propRecurse = properties;
var typeName = localDc.Type.ToLower();
var jObject = properties as Newtonsoft.Json.Linq.JObject;
if (jObject != null)
{
var jProp = jObject.Properties();
CheckForSecrets(jProp);
}
Debug.LogMessage(LogEventLevel.Verbose, "typeName = {0}", typeName);
// Check for types that have been added by plugin dlls.
return !ProcessorExtensionFactoryMethods.ContainsKey(typeName) ? null : ProcessorExtensionFactoryMethods[typeName].FactoryMethod(localDc);
}
catch (Exception ex)
{
Debug.LogMessage(LogEventLevel.Information, "Exception occurred while creating device {0}: {1}", dc.Key, ex.Message);
Debug.LogMessage(LogEventLevel.Verbose, "{0}", ex.StackTrace);
if (ex.InnerException == null)
{
return null;
}
Debug.LogMessage(LogEventLevel.Information, "Inner exception while creating device {0}: {1}", dc.Key,
ex.InnerException.Message);
Debug.LogMessage(LogEventLevel.Verbose, "{0}", ex.InnerException.StackTrace);
return null;
}
}
}
}

View File

@@ -6,7 +6,6 @@ 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
{ {
@@ -24,10 +23,9 @@ namespace PepperDash.Essentials.Core
/// <returns></returns> /// <returns></returns>
public static FileInfo[] GetFiles(string fileName) public static FileInfo[] GetFiles(string fileName)
{ {
string fullFilePath = Global.FilePathPrefix + fileName; DirectoryInfo dirInfo = new DirectoryInfo(Path.GetDirectoryName(fileName));
DirectoryInfo dirInfo = new DirectoryInfo(Path.GetDirectoryName(fullFilePath)); var files = dirInfo.GetFiles(Path.GetFileName(fileName));
var files = dirInfo.GetFiles(Path.GetFileName(fullFilePath)); Debug.Console(0, "FileIO found: {0}, {1}", files.Count(), fileName);
Debug.LogMessage(LogEventLevel.Information, "FileIO found: {0}, {1}", files.Count(), fullFilePath);
if (files.Count() > 0) if (files.Count() > 0)
{ {
return files; return files;
@@ -40,10 +38,9 @@ namespace PepperDash.Essentials.Core
public static FileInfo GetFile(string fileName) public static FileInfo GetFile(string fileName)
{ {
string fullFilePath = Global.FilePathPrefix + fileName; DirectoryInfo dirInfo = new DirectoryInfo(Path.GetDirectoryName(fileName));
DirectoryInfo dirInfo = new DirectoryInfo(Path.GetDirectoryName(fullFilePath)); var files = dirInfo.GetFiles(Path.GetFileName(fileName));
var files = dirInfo.GetFiles(Path.GetFileName(fullFilePath)); Debug.Console(0, "FileIO found: {0}, {1}", files.Count(), fileName);
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();
@@ -68,7 +65,7 @@ namespace PepperDash.Essentials.Core
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Information, "Error: FileIO read failed: \r{0}", e); Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: FileIO read failed: \r{0}", e);
return ""; return "";
} }
} }
@@ -84,8 +81,8 @@ namespace PepperDash.Essentials.Core
{ {
if (fileLock.TryEnter()) if (fileLock.TryEnter())
{ {
DirectoryInfo dirInfo = new DirectoryInfo(file.DirectoryName); DirectoryInfo dirInfo = new DirectoryInfo(file.Name);
Debug.LogMessage(LogEventLevel.Verbose, "FileIO Getting Data {0}", file.FullName); Debug.Console(2, "FileIO Getting Data {0}", file.FullName);
if (File.Exists(file.FullName)) if (File.Exists(file.FullName))
{ {
@@ -96,20 +93,20 @@ namespace PepperDash.Essentials.Core
} }
else else
{ {
Debug.LogMessage(LogEventLevel.Verbose, "File {0} does not exsist", file.FullName); Debug.Console(2, "File {0} does not exsist", file.FullName);
return ""; return "";
} }
} }
else else
{ {
Debug.LogMessage(LogEventLevel.Information, "FileIO Unable to enter FileLock"); Debug.Console(0, Debug.ErrorLogLevel.Error, "FileIO Unable to enter FileLock");
return ""; return "";
} }
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Information, "Error: FileIO read failed: \r{0}", e); Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: FileIO read failed: \r{0}", e);
return ""; return "";
} }
finally finally
@@ -129,7 +126,7 @@ namespace PepperDash.Essentials.Core
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Information, "Error: FileIO read failed: \r{0}", e); Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: FileIO read failed: \r{0}", e);
} }
} }
@@ -141,7 +138,7 @@ namespace PepperDash.Essentials.Core
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Information, "Error: FileIO read failed: \r{0}", e); Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: FileIO read failed: \r{0}", e);
} }
} }
@@ -153,7 +150,7 @@ namespace PepperDash.Essentials.Core
if (fileLock.TryEnter()) if (fileLock.TryEnter())
{ {
DirectoryInfo dirInfo = new DirectoryInfo(file.Name); DirectoryInfo dirInfo = new DirectoryInfo(file.Name);
Debug.LogMessage(LogEventLevel.Verbose, "FileIO Getting Data {0}", file.FullName); Debug.Console(2, "FileIO Getting Data {0}", file.FullName);
if (File.Exists(file.FullName)) if (File.Exists(file.FullName))
@@ -165,20 +162,20 @@ namespace PepperDash.Essentials.Core
} }
else else
{ {
Debug.LogMessage(LogEventLevel.Verbose, "File {0} Does not exsist", file.FullName); Debug.Console(2, "File {0} Does not exsist", file.FullName);
data = ""; data = "";
} }
GotFileEvent.Invoke(null, new FileEventArgs(data)); GotFileEvent.Invoke(null, new FileEventArgs(data));
} }
else else
{ {
Debug.LogMessage(LogEventLevel.Information, "FileIO Unable to enter FileLock"); Debug.Console(0, Debug.ErrorLogLevel.Error, "FileIO Unable to enter FileLock");
} }
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Information, "Error: FileIO read failed: \r{0}", e); Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: FileIO read failed: \r{0}", e);
data = ""; data = "";
} }
finally finally
@@ -205,22 +202,21 @@ namespace PepperDash.Essentials.Core
public static void WriteDataToFile(string data, string filePath) public static void WriteDataToFile(string data, string filePath)
{ {
Thread _WriteFileThread; Thread _WriteFileThread;
_WriteFileThread = new Thread((O) => _WriteFileMethod(data, Global.FilePathPrefix + "/" + filePath), null, Thread.eThreadStartOptions.CreateSuspended); _WriteFileThread = new Thread((O) => _WriteFileMethod(data, filePath), null, Thread.eThreadStartOptions.CreateSuspended);
_WriteFileThread.Priority = Thread.eThreadPriority.LowestPriority; _WriteFileThread.Priority = Thread.eThreadPriority.LowestPriority;
_WriteFileThread.Start(); _WriteFileThread.Start();
Debug.LogMessage(LogEventLevel.Information, "New WriteFile Thread"); Debug.Console(0, Debug.ErrorLogLevel.Notice, "New WriteFile Thread");
} }
static object _WriteFileMethod(string data, string filePath) static object _WriteFileMethod(string data, string filePath)
{ {
Debug.LogMessage(LogEventLevel.Information, "Attempting to write file: '{0}'", filePath); Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to write file: '{0}'", filePath);
try try
{ {
if (fileLock.TryEnter()) if (fileLock.TryEnter())
{ {
using (StreamWriter sw = new StreamWriter(filePath)) using (StreamWriter sw = new StreamWriter(filePath))
{ {
sw.Write(data); sw.Write(data);
@@ -230,13 +226,13 @@ namespace PepperDash.Essentials.Core
} }
else else
{ {
Debug.LogMessage(LogEventLevel.Information, "FileIO Unable to enter FileLock"); Debug.Console(0, Debug.ErrorLogLevel.Error, "FileIO Unable to enter FileLock");
} }
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Error, "Error: FileIO write failed: \r{0}", e); Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: FileIO write failed: \r{0}", e);
} }
finally finally
{ {
@@ -260,7 +256,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.LogMessage(LogEventLevel.Information, "Returned {0}", readData); Debug.Console(0, "Returned {0}", readData);
File.Delete(file.FullName); File.Delete(file.FullName);
if (testData == readData) if (testData == readData)
{ {

View File

@@ -1,19 +1,18 @@
extern alias Full;
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;
using Crestron.SimplSharp.CrestronXml.Serialization; using Crestron.SimplSharp.CrestronXml.Serialization;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.Fusion; using Crestron.SimplSharpPro.Fusion;
using Newtonsoft.Json; using Full.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
{ {
@@ -129,7 +128,7 @@ namespace PepperDash.Essentials.Core.Fusion
if (File.Exists(oldGuidFilePath)) if (File.Exists(oldGuidFilePath))
{ {
Debug.LogMessage(LogEventLevel.Information, this, "Migrating from old Fusion GUID file to new Fusion GUID File"); Debug.Console(0, this, "Migrating from old Fusion GUID file to new Fusion GUID File");
File.Copy(oldGuidFilePath, guidFilePath); File.Copy(oldGuidFilePath, guidFilePath);
@@ -151,13 +150,9 @@ namespace PepperDash.Essentials.Core.Fusion
ReadGuidFile(guidFilePath); ReadGuidFile(guidFilePath);
} }
var occupancyRoom = Room as IRoomOccupancy; if (Room.RoomOccupancy != null)
if (occupancyRoom != null)
{ {
if (occupancyRoom.RoomOccupancy != null) if (Room.OccupancyStatusProviderIsRemote)
{
if (occupancyRoom.OccupancyStatusProviderIsRemote)
{ {
SetUpRemoteOccupancy(); SetUpRemoteOccupancy();
} }
@@ -166,14 +161,13 @@ namespace PepperDash.Essentials.Core.Fusion
SetUpLocalOccupancy(); SetUpLocalOccupancy();
} }
} }
}
AddPostActivationAction(() => PostActivate(guidFilePath)); AddPostActivationAction(() => PostActivate(guidFilePath));
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Information, this, "Error Building Fusion System Controller: {0}", e); Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Error Building Fusion System Controller: {0}", e);
} }
} }
@@ -232,7 +226,7 @@ namespace PepperDash.Essentials.Core.Fusion
{ {
if (string.IsNullOrEmpty(filePath)) if (string.IsNullOrEmpty(filePath))
{ {
Debug.LogMessage(LogEventLevel.Information, this, "Error writing guid file. No path specified."); Debug.Console(0, this, "Error writing guid file. No path specified.");
return; return;
} }
@@ -247,13 +241,13 @@ namespace PepperDash.Essentials.Core.Fusion
fileLock.Enter(); fileLock.Enter();
Debug.LogMessage(LogEventLevel.Debug, this, "Writing GUIDs to file"); Debug.Console(1, 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)
: new FusionRoomGuids(Room.Name, _ipId, RoomGuid, FusionStaticAssets, FusionOccSensor); : new FusionRoomGuids(Room.Name, _ipId, RoomGuid, FusionStaticAssets, FusionOccSensor);
var json = JsonConvert.SerializeObject(_guiDs, Newtonsoft.Json.Formatting.Indented); var json = JsonConvert.SerializeObject(_guiDs, Full.Newtonsoft.Json.Formatting.Indented);
using (var sw = new StreamWriter(filePath)) using (var sw = new StreamWriter(filePath))
{ {
@@ -261,11 +255,11 @@ namespace PepperDash.Essentials.Core.Fusion
sw.Flush(); sw.Flush();
} }
Debug.LogMessage(LogEventLevel.Debug, this, "Guids successfully written to file '{0}'", filePath); Debug.Console(1, this, "Guids successfully written to file '{0}'", filePath);
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Information, this, "Error writing guid file: {0}", e); Debug.Console(0, this, "Error writing guid file: {0}", e);
} }
finally finally
{ {
@@ -284,7 +278,7 @@ namespace PepperDash.Essentials.Core.Fusion
{ {
if (string.IsNullOrEmpty(filePath)) if (string.IsNullOrEmpty(filePath))
{ {
Debug.LogMessage(LogEventLevel.Information, this, "Error reading guid file. No path specified."); Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Error reading guid file. No path specified.");
return; return;
} }
@@ -310,20 +304,20 @@ namespace PepperDash.Essentials.Core.Fusion
FusionStaticAssets = _guiDs.StaticAssets; FusionStaticAssets = _guiDs.StaticAssets;
} }
Debug.LogMessage(LogEventLevel.Information, this, "Fusion Guids successfully read from file: {0}", Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Fusion Guids successfully read from file: {0}",
filePath); filePath);
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); 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);
foreach (var item in FusionStaticAssets) foreach (var item in FusionStaticAssets)
{ {
Debug.LogMessage(LogEventLevel.Debug, this, "\nAsset Name: {0}\nAsset No: {1}\n Guid: {2}", item.Value.Name, Debug.Console(1, 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.LogMessage(LogEventLevel.Information, this, "Error reading guid file: {0}", e); Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Error reading guid file: {0}", e);
} }
finally finally
{ {
@@ -336,7 +330,7 @@ namespace PepperDash.Essentials.Core.Fusion
protected virtual void CreateSymbolAndBasicSigs(uint ipId) protected virtual void CreateSymbolAndBasicSigs(uint ipId)
{ {
Debug.LogMessage(LogEventLevel.Information, this, "Creating Fusion Room symbol with GUID: {0} and IP-ID {1:X2}", RoomGuid, ipId); Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "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();
@@ -555,7 +549,7 @@ namespace PepperDash.Essentials.Core.Fusion
"</Parameters>\n" + "</Parameters>\n" +
"</RequestAction>\n"; "</RequestAction>\n";
Debug.LogMessage(LogEventLevel.Verbose, this, "Sending Fusion ActionRequest: \n{0}", actionRequest); Debug.Console(2, this, "Sending Fusion ActionRequest: \n{0}", actionRequest);
FusionRoom.ExtenderFusionRoomDataReservedSigs.ActionQuery.StringValue = actionRequest; FusionRoom.ExtenderFusionRoomDataReservedSigs.ActionQuery.StringValue = actionRequest;
@@ -606,7 +600,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.LogMessage(LogEventLevel.Verbose, this, "Sending Fusion ScheduleQuery: \n{0}", requestTest); Debug.Console(2, this, "Sending Fusion ScheduleQuery: \n{0}", requestTest);
FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.ScheduleQuery.StringValue = requestTest; FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.ScheduleQuery.StringValue = requestTest;
@@ -634,7 +628,7 @@ namespace PepperDash.Essentials.Core.Fusion
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Debug, this, "Error parsing console command: {0}", e); Debug.Console(1, this, "Error parsing console command: {0}", e);
} }
ModifyMeetingEndTime(requestId, extendMinutes); ModifyMeetingEndTime(requestId, extendMinutes);
@@ -649,7 +643,7 @@ namespace PepperDash.Essentials.Core.Fusion
{ {
if (_currentMeeting == null) if (_currentMeeting == null)
{ {
Debug.LogMessage(LogEventLevel.Debug, this, "No meeting in progress. Unable to modify end time."); Debug.Console(1, this, "No meeting in progress. Unable to modify end time.");
return; return;
} }
@@ -668,13 +662,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.LogMessage(LogEventLevel.Debug, this, "Sending MeetingChange Request: \n{0}", requestTest); Debug.Console(1, this, "Sending MeetingChange Request: \n{0}", requestTest);
FusionRoom.ExtenderFusionRoomDataReservedSigs.ActionQuery.StringValue = requestTest; FusionRoom.ExtenderFusionRoomDataReservedSigs.ActionQuery.StringValue = requestTest;
} }
else else
{ {
Debug.LogMessage(LogEventLevel.Debug, this, "Invalid time specified"); Debug.Console(1, this, "Invalid time specified");
} }
} }
@@ -717,11 +711,11 @@ namespace PepperDash.Essentials.Core.Fusion
"</Event>" + "</Event>" +
"</CreateSchedule>"; "</CreateSchedule>";
Debug.LogMessage(LogEventLevel.Verbose, this, "Sending CreateMeeting Request: \n{0}", createMeetingRequest); Debug.Console(2, this, "Sending CreateMeeting Request: \n{0}", createMeetingRequest);
FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.CreateMeeting.StringValue = createMeetingRequest; FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.CreateMeeting.StringValue = createMeetingRequest;
//Debug.LogMessage(LogEventLevel.Debug, this, "Sending CreateMeeting Request: \n{0}", command); //Debug.Console(1, this, "Sending CreateMeeting Request: \n{0}", command);
//FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.CreateMeeting.StringValue = command; //FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.CreateMeeting.StringValue = command;
} }
@@ -734,7 +728,7 @@ namespace PepperDash.Essentials.Core.Fusion
protected void ExtenderFusionRoomDataReservedSigs_DeviceExtenderSigChange(DeviceExtender currentDeviceExtender, protected void ExtenderFusionRoomDataReservedSigs_DeviceExtenderSigChange(DeviceExtender currentDeviceExtender,
SigEventArgs args) SigEventArgs args)
{ {
Debug.LogMessage(LogEventLevel.Verbose, this, "Event: {0}\n Sig: {1}\nFusionResponse:\n{2}", args.Event, args.Sig.Name, Debug.Console(2, this, "Event: {0}\n Sig: {1}\nFusionResponse:\n{2}", args.Event, args.Sig.Name,
args.Sig.StringValue); args.Sig.StringValue);
@@ -803,7 +797,7 @@ namespace PepperDash.Essentials.Core.Fusion
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Debug, this, "Error parsing ActionQueryResponse: {0}", e); Debug.Console(1, this, "Error parsing ActionQueryResponse: {0}", e);
} }
} }
else if (args.Sig == FusionRoom.ExtenderFusionRoomDataReservedSigs.LocalDateTimeQueryResponse) else if (args.Sig == FusionRoom.ExtenderFusionRoomDataReservedSigs.LocalDateTimeQueryResponse)
@@ -826,20 +820,20 @@ namespace PepperDash.Essentials.Core.Fusion
var currentTime = DateTime.Parse(tempLocalDateTime); var currentTime = DateTime.Parse(tempLocalDateTime);
Debug.LogMessage(LogEventLevel.Debug, this, "DateTime from Fusion Server: {0}", currentTime); Debug.Console(1, 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.LogMessage(LogEventLevel.Debug, this, "Processor time set to {0}", CrestronEnvironment.GetLocalTime()); Debug.Console(1, this, "Processor time set to {0}", CrestronEnvironment.GetLocalTime());
} }
} }
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Debug, this, "Error parsing LocalDateTimeQueryResponse: {0}", e); Debug.Console(1, this, "Error parsing LocalDateTimeQueryResponse: {0}", e);
} }
} }
else if (args.Sig == FusionRoom.ExtenderFusionRoomDataReservedSigs.RoomConfigResponse) else if (args.Sig == FusionRoom.ExtenderFusionRoomDataReservedSigs.RoomConfigResponse)
@@ -848,7 +842,7 @@ namespace PepperDash.Essentials.Core.Fusion
var roomConfigResponseArgs = args.Sig.StringValue.Replace("&", "and"); var roomConfigResponseArgs = args.Sig.StringValue.Replace("&", "and");
Debug.LogMessage(LogEventLevel.Verbose, this, "Fusion Response: \n {0}", roomConfigResponseArgs); Debug.Console(2, this, "Fusion Response: \n {0}", roomConfigResponseArgs);
try try
{ {
@@ -913,7 +907,7 @@ namespace PepperDash.Essentials.Core.Fusion
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Debug, this, "Error parsing Custom Properties response: {0}", e); Debug.Console(1, this, "Error parsing Custom Properties response: {0}", e);
} }
//PrintRoomInfo(); //PrintRoomInfo();
//getRoomInfoBusy = false; //getRoomInfoBusy = false;
@@ -929,7 +923,7 @@ namespace PepperDash.Essentials.Core.Fusion
protected void FusionRoomSchedule_DeviceExtenderSigChange(DeviceExtender currentDeviceExtender, protected void FusionRoomSchedule_DeviceExtenderSigChange(DeviceExtender currentDeviceExtender,
SigEventArgs args) SigEventArgs args)
{ {
Debug.LogMessage(LogEventLevel.Verbose, this, "Scehdule Response Event: {0}\n Sig: {1}\nFusionResponse:\n{2}", args.Event, Debug.Console(2, 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);
@@ -981,7 +975,7 @@ namespace PepperDash.Essentials.Core.Fusion
} }
else if (element.Name == "Event") else if (element.Name == "Event")
{ {
Debug.LogMessage(LogEventLevel.Verbose, this, "Event Found:\n{0}", element.OuterXml); Debug.Console(2, this, "Event Found:\n{0}", element.OuterXml);
var reader = new XmlReader(element.OuterXml); var reader = new XmlReader(element.OuterXml);
@@ -1025,12 +1019,12 @@ namespace PepperDash.Essentials.Core.Fusion
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Debug, this, "Error parsing ScheduleResponse: {0}", e); Debug.Console(1, this, "Error parsing ScheduleResponse: {0}", e);
} }
} }
else if (args.Sig == FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.CreateResponse) else if (args.Sig == FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.CreateResponse)
{ {
Debug.LogMessage(LogEventLevel.Verbose, this, "Create Meeting Response Event: {0}\n Sig: {1}\nFusionResponse:\n{2}", args.Event, Debug.Console(2, 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);
} }
} }
@@ -1044,16 +1038,16 @@ namespace PepperDash.Essentials.Core.Fusion
{ {
if (_currentSchedule.Meetings.Count > 0) if (_currentSchedule.Meetings.Count > 0)
{ {
Debug.LogMessage(LogEventLevel.Debug, this, "Today's Schedule for '{0}'\n", Room.Name); Debug.Console(1, this, "Today's Schedule for '{0}'\n", Room.Name);
foreach (var e in _currentSchedule.Meetings) foreach (var e in _currentSchedule.Meetings)
{ {
Debug.LogMessage(LogEventLevel.Debug, this, "Subject: {0}", e.Subject); Debug.Console(1, this, "Subject: {0}", e.Subject);
Debug.LogMessage(LogEventLevel.Debug, this, "Organizer: {0}", e.Organizer); Debug.Console(1, this, "Organizer: {0}", e.Organizer);
Debug.LogMessage(LogEventLevel.Debug, this, "MeetingID: {0}", e.MeetingID); Debug.Console(1, this, "MeetingID: {0}", e.MeetingID);
Debug.LogMessage(LogEventLevel.Debug, this, "Start Time: {0}", e.dtStart); Debug.Console(1, this, "Start Time: {0}", e.dtStart);
Debug.LogMessage(LogEventLevel.Debug, this, "End Time: {0}", e.dtEnd); Debug.Console(1, this, "End Time: {0}", e.dtEnd);
Debug.LogMessage(LogEventLevel.Debug, this, "Duration: {0}\n", e.DurationInMinutes); Debug.Console(1, this, "Duration: {0}\n", e.DurationInMinutes);
} }
} }
} }
@@ -1111,7 +1105,7 @@ namespace PepperDash.Essentials.Core.Fusion
} }
else else
{ {
Debug.LogMessage(LogEventLevel.Debug, this, "WARNING: Config source list '{0}' not found for room '{1}'", Debug.Console(1, this, "WARNING: Config source list '{0}' not found for room '{1}'",
Room.SourceListKey, Room.Key); Room.SourceListKey, Room.Key);
} }
} }
@@ -1145,18 +1139,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.LogMessage(LogEventLevel.Debug, this, "Device usage for: {0} ended at {1}. In use for {2} minutes", Debug.Console(1, 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.LogMessage(LogEventLevel.Debug, this, "Device usage string: {0}", deviceUsage); Debug.Console(1, 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.LogMessage(LogEventLevel.Verbose, this, "Creating attribute '{0}' with join {1} for source {2}", Debug.Console(2, this, "Creating attribute '{0}' with join {1} for source {2}",
attrName, attrNum, pSrc.Key); attrName, attrNum, pSrc.Key);
try try
{ {
@@ -1177,7 +1171,7 @@ namespace PepperDash.Essentials.Core.Fusion
} }
catch (Exception) catch (Exception)
{ {
Debug.LogMessage(LogEventLevel.Verbose, this, "Error creating Fusion signal {0} {1} for device '{2}'. THIS NEEDS REWORKING", Debug.Console(2, this, "Error creating Fusion signal {0} {1} for device '{2}'. THIS NEEDS REWORKING",
attrNum, attrName, pSrc.Key); attrNum, attrName, pSrc.Key);
} }
} }
@@ -1206,7 +1200,7 @@ namespace PepperDash.Essentials.Core.Fusion
//var keyNum = ExtractNumberFromKey(dev.Key); //var keyNum = ExtractNumberFromKey(dev.Key);
//if (keyNum == -1) //if (keyNum == -1)
//{ //{
// Debug.LogMessage(LogEventLevel.Debug, this, "WARNING: Cannot link device '{0}' to numbered Fusion monitoring attributes", // Debug.Console(1, this, "WARNING: Cannot link device '{0}' to numbered Fusion monitoring attributes",
// dev.Key); // dev.Key);
// continue; // continue;
//} //}
@@ -1278,7 +1272,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.LogMessage(LogEventLevel.Information, this, "Linking '{0}' communication monitor to Fusion '{1}'", dev.Key, attrName); Debug.Console(0, this, "Linking '{0}' communication monitor to Fusion '{1}'", dev.Key, attrName);
} }
} }
} }
@@ -1307,7 +1301,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.LogMessage(LogEventLevel.Debug, this, "Cannot link null display to Fusion because default display is null"); Debug.Console(1, this, "Cannot link null display to Fusion because default display is null");
return; return;
} }
@@ -1375,7 +1369,7 @@ namespace PepperDash.Essentials.Core.Fusion
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Debug, this, "Error setting up display in Fusion: {0}", e); Debug.Console(1, this, "Error setting up display in Fusion: {0}", e);
} }
} }
@@ -1468,7 +1462,7 @@ namespace PepperDash.Essentials.Core.Fusion
if (md != null) if (md != null)
{ {
_errorMessageRollUp.AddMonitor(md.CommunicationMonitor); _errorMessageRollUp.AddMonitor(md.CommunicationMonitor);
Debug.LogMessage(LogEventLevel.Verbose, this, "Adding '{0}' to room's overall error monitor", Debug.Console(2, this, "Adding '{0}' to room's overall error monitor",
md.CommunicationMonitor.Parent.Key); md.CommunicationMonitor.Parent.Key);
} }
} }
@@ -1531,15 +1525,10 @@ namespace PepperDash.Essentials.Core.Fusion
// Tie to method on occupancy object // Tie to method on occupancy object
//occSensorShutdownMinutes.OutputSig.UserObject(new Action(ushort)(b => Room.OccupancyObj.SetShutdownMinutes(b)); //occSensorShutdownMinutes.OutputSig.UserObject(new Action(ushort)(b => Room.OccupancyObj.SetShutdownMinutes(b));
var occRoom = Room as IRoomOccupancy;
if (occRoom != null)
{
occRoom.RoomOccupancy.RoomIsOccupiedFeedback.LinkInputSig(occSensorAsset.RoomOccupied.InputSig);
occRoom.RoomOccupancy.RoomIsOccupiedFeedback.OutputChange += RoomIsOccupiedFeedback_OutputChange;
}
RoomOccupancyRemoteStringFeedback = new StringFeedback(() => _roomOccupancyRemoteString); RoomOccupancyRemoteStringFeedback = new StringFeedback(() => _roomOccupancyRemoteString);
Room.RoomOccupancy.RoomIsOccupiedFeedback.LinkInputSig(occSensorAsset.RoomOccupied.InputSig);
Room.RoomOccupancy.RoomIsOccupiedFeedback.OutputChange += RoomIsOccupiedFeedback_OutputChange;
RoomOccupancyRemoteStringFeedback.LinkInputSig(occSensorAsset.RoomOccupancyInfo.InputSig); RoomOccupancyRemoteStringFeedback.LinkInputSig(occSensorAsset.RoomOccupancyInfo.InputSig);
//} //}
@@ -1705,19 +1694,19 @@ namespace PepperDash.Essentials.Core.Fusion
{ {
try try
{ {
Debug.LogMessage(LogEventLevel.Information, "Adding Fusion Static Asset '{0}' to slot {1} with GUID: '{2}'", name, number, instanceId); Debug.Console(0, "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.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); 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);
return null; return null;
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Verbose, "Error creating Static Asset: {0}", e); Debug.Console(2, Debug.ErrorLogLevel.Error, "Error creating Static Asset: {0}", e);
return null; return null;
} }
} }
@@ -1727,7 +1716,7 @@ namespace PepperDash.Essentials.Core.Fusion
{ {
try try
{ {
Debug.LogMessage(LogEventLevel.Information, "Adding Fusion Occupancy Sensor Asset '{0}' to slot {1} with GUID: '{2}'", name, number, Debug.Console(0, "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);
@@ -1735,12 +1724,12 @@ namespace PepperDash.Essentials.Core.Fusion
} }
catch (InvalidOperationException ex) catch (InvalidOperationException 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); 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);
return null; return null;
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Error, "Error creating Static Asset: {0}", e); Debug.Console(2, Debug.ErrorLogLevel.Error, "Error creating Static Asset: {0}", e);
return null; return null;
} }
} }

View File

@@ -1,18 +1,17 @@
extern alias Full;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Newtonsoft.Json; using Full.Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Full.Newtonsoft.Json.Linq;
using PepperDash.Core; 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
{ {
@@ -39,7 +38,7 @@ namespace PepperDash.Essentials.Core.Fusion
if (device is RoomOnToDefaultSourceWhenOccupied) if (device is RoomOnToDefaultSourceWhenOccupied)
{ {
Debug.LogMessage(LogEventLevel.Debug, "Mapping Room on via Occupancy values from Fusion"); Debug.Console(1, "Mapping Room on via Occupancy values from Fusion");
var devProps = JsonConvert.DeserializeObject<RoomOnToDefaultSourceWhenOccupiedConfig>(deviceConfig.Properties.ToString()); var devProps = JsonConvert.DeserializeObject<RoomOnToDefaultSourceWhenOccupiedConfig>(deviceConfig.Properties.ToString());
@@ -90,18 +89,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.LogMessage(LogEventLevel.Debug, "Current Room Name: {0}. New Room Name: {1}", deviceConfig.Name, roomInfo.Name); Debug.Console(1, "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.LogMessage(LogEventLevel.Debug, "Room Name Successfully Changed."); Debug.Console(1, "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.LogMessage(LogEventLevel.Debug, "Current Help Message: {0}. New Help Message: {1}", deviceConfig.Properties["help"]["message"].Value<string>(ToString()), helpMessage.CustomFieldValue); //Debug.Console(1, "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;
} }
} }
@@ -114,7 +113,7 @@ namespace PepperDash.Essentials.Core.Fusion
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Debug, "FusionCustomPropetiesBridge: Error mapping properties: {0}", e); Debug.Console(1, "FusionCustomPropetiesBridge: Error mapping properties: {0}", e);
} }
} }
} }

View File

@@ -4,7 +4,6 @@ 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
{ {
@@ -46,7 +45,7 @@ namespace PepperDash.Essentials.Core.Fusion
} }
} }
programs[i] = item; programs[i] = item;
Debug.LogMessage(LogEventLevel.Debug, "Program {0}: {1}", i, item.Name); Debug.Console(1, "Program {0}: {1}", i, item.Name);
} }
return programs; return programs;
} }

View File

@@ -6,7 +6,6 @@ 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
{ {
@@ -75,7 +74,7 @@ namespace PepperDash.Essentials.Core.Fusion
{ {
var slotNum = GetNextAvailableAssetNumber(room); var slotNum = GetNextAvailableAssetNumber(room);
Debug.LogMessage(LogEventLevel.Verbose, "Adding Fusion Asset: {0} of Type: {1} at Slot Number: {2} with GUID: {3}", assetName, type, slotNum, instanceId); Debug.Console(2, "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);
@@ -106,7 +105,7 @@ namespace PepperDash.Essentials.Core.Fusion
else else
slotNum = slotNum + 1; slotNum = slotNum + 1;
Debug.LogMessage(LogEventLevel.Verbose, "#Next available fusion asset number is: {0}", slotNum); Debug.Console(2, "#Next available fusion asset number is: {0}", slotNum);
return slotNum; return slotNum;
} }

View File

@@ -1,4 +1,4 @@
extern alias Full;
using System; using System;
using System.Linq; using System.Linq;
@@ -14,10 +14,9 @@ using Crestron.SimplSharpPro.DM;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials.License; using PepperDash.Essentials.License;
using Newtonsoft.Json; using Full.Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Full.Newtonsoft.Json.Linq;
using Newtonsoft.Json.Schema; using Full.Newtonsoft.Json.Schema;
using Serilog.Events;
namespace PepperDash.Essentials.Core namespace PepperDash.Essentials.Core
@@ -137,7 +136,6 @@ 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;
@@ -171,28 +169,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.LogMessage(LogEventLevel.Verbose, "Running Local Build. Bypassing Dependency Check."); Debug.Console(2, "Running Local Build. Bypassing Dependency Check.");
return true; return true;
} }
if (developmentVersions == null) if (developmentVersions == null)
{ {
Debug.LogMessage(LogEventLevel.Information, Debug.Console(0,
"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.LogMessage(LogEventLevel.Verbose, "Comparing running version '{0}' to minimum versions '{1}'", AssemblyVersion, developmentVersions); Debug.Console(2, "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.LogMessage(LogEventLevel.Information, "Essentials Build does not match any builds required for plugin load. Bypassing Plugin Load."); Debug.Console(0, "Essentials Build does not match any builds required for plugin load. Bypassing Plugin Load.");
return false; return false;
} }
Debug.LogMessage(LogEventLevel.Verbose, "Essentials Build {0} matches list of development builds", AssemblyVersion); Debug.Console(2, "Essentials Build {0} matches list of development builds", AssemblyVersion);
return IsRunningMinimumVersionOrHigher(minimumVersion); return IsRunningMinimumVersionOrHigher(minimumVersion);
@@ -206,11 +204,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.LogMessage(LogEventLevel.Verbose, "Comparing running version '{0}' to minimum version '{1}'", AssemblyVersion, minimumVersion); Debug.Console(2, "Comparing running version '{0}' to minimum version '{1}'", AssemblyVersion, minimumVersion);
if (String.IsNullOrEmpty(minimumVersion)) if (String.IsNullOrEmpty(minimumVersion))
{ {
Debug.LogMessage(LogEventLevel.Information,"Plugin does not specify a minimum version. Loading plugin may not work as expected. Proceeding with loading plugin"); Debug.Console(0,"Plugin does not specify a minimum version. Loading plugin may not work as expected. Proceeding with loading plugin");
return true; return true;
} }
@@ -229,7 +227,7 @@ namespace PepperDash.Essentials.Core
} }
catch catch
{ {
Debug.LogMessage(LogEventLevel.Verbose, "unable to parse minimum version {0}. Bypassing plugin load.", minimumVersion); Debug.Console(2, "unable to parse minimum version {0}. Bypassing plugin load.", minimumVersion);
return false; return false;
} }
@@ -240,7 +238,7 @@ namespace PepperDash.Essentials.Core
return runtimeVer.CompareTo(minimumVer) >= 0; return runtimeVer.CompareTo(minimumVer) >= 0;
} }
Debug.LogMessage(LogEventLevel.Verbose, "Running Local Build. Bypassing Dependency Check."); Debug.Console(2, "Running Local Build. Bypassing Dependency Check.");
return true; return true;
/* /*

View File

@@ -8,7 +8,6 @@ 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
@@ -22,29 +21,13 @@ 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>
@@ -55,8 +38,8 @@ namespace PepperDash.Essentials.Core
{ {
if (!EventGroups.ContainsKey(groupName)) if (!EventGroups.ContainsKey(groupName))
{ {
Debug.LogMessage(LogEventLevel.Information, Debug.Console(0,
"[Scheduler]: Unable to delete events from group '{0}'. Group not found in EventGroups dictionary.", null, "[Scheduler]: Unable to delete events from group '{0}'. Group not found in EventGroups dictionary.",
groupName); groupName);
return; return;
} }
@@ -67,47 +50,47 @@ namespace PepperDash.Essentials.Core
{ {
group.ClearAllEvents(); group.ClearAllEvents();
Debug.LogMessage(LogEventLevel.Information, "[Scheduler]: All events deleted from group '{0}'", null, groupName); Debug.Console(0, "[Scheduler]: All events deleted from group '{0}'", groupName);
} }
else else
Debug.LogMessage(LogEventLevel.Information, Debug.Console(0,
"[Scheduler]: Unable to delete events from group '{0}'. Group not found in EventGroups dictionary.", null, "[Scheduler]: Unable to delete events from group '{0}'. Group not found in EventGroups dictionary.",
groupName); groupName);
} }
static void ListAllEventGroups(string command) static void ListAllEventGroups(string command)
{ {
CrestronConsole.ConsoleCommandResponse("Event Groups:"); Debug.Console(0, "Event Groups:");
foreach (var group in EventGroups) foreach (var group in EventGroups)
{ {
CrestronConsole.ConsoleCommandResponse($"{group.Key}"); Debug.Console(0, "{0}", group.Key);
} }
} }
static void ListAllEventsForGroup(string args) static void ListAllEventsForGroup(string args)
{ {
Debug.LogMessage(LogEventLevel.Information, "Getting events for group {0}...", null, args); Debug.Console(0, "Getting events for group {0}...", args);
ScheduledEventGroup group; ScheduledEventGroup group;
if (!EventGroups.TryGetValue(args, out group)) if (!EventGroups.TryGetValue(args, out group))
{ {
Debug.LogMessage(LogEventLevel.Information, "Unabled to get event group for key {0}", null, args); Debug.Console(0, "Unabled to get event group for key {0}", args);
return; return;
} }
foreach (var evt in group.ScheduledEvents) foreach (var evt in group.ScheduledEvents)
{ {
CrestronConsole.ConsoleCommandResponse( Debug.Console(0,
$@" @"
****Event key {evt.Key}**** ****Event key {0}****
Event state: {evt.Value.EventState} Event date/time: {1}
Event date/time: {evt.Value.DateAndTime} Persistent: {2}
Persistent: {evt.Value.Persistent} Acknowlegable: {3}
Acknowlegable: {evt.Value.Acknowledgeable} Recurrence: {4}
Recurrence: {evt.Value.Recurrence.Recurrence} Recurrence Days: {5}
Recurrence Days: {evt.Value.Recurrence.RecurrenceDays} ********************", evt.Key, evt.Value.DateAndTime, evt.Value.Persistent, evt.Value.Acknowledgeable,
********************"); evt.Value.Recurrence.Recurrence, evt.Value.Recurrence.RecurrenceDays);
} }
} }
@@ -154,7 +137,8 @@ Recurrence Days: {evt.Value.Recurrence.RecurrenceDays}
var dayOfWeek = eventTime.DayOfWeek; var dayOfWeek = eventTime.DayOfWeek;
Debug.LogMessage(LogEventLevel.Debug, "[Scheduler]: eventTime day of week is: {0}",null, dayOfWeek); Debug.Console(1, "[Scheduler]: eventTime day of week is: {0}", dayOfWeek);
switch (dayOfWeek) switch (dayOfWeek)
{ {
case DayOfWeek.Sunday: case DayOfWeek.Sunday:
@@ -201,7 +185,7 @@ Recurrence Days: {evt.Value.Recurrence.RecurrenceDays}
} }
} }
Debug.LogMessage(LogEventLevel.Debug, "[Scheduler]: eventTime day of week matches recurrence days: {0}", isMatch); Debug.Console(1, "[Scheduler]: eventTime day of week matches recurrence days: {0}", isMatch);
return isMatch; return isMatch;
} }
@@ -217,12 +201,10 @@ Recurrence Days: {evt.Value.Recurrence.RecurrenceDays}
} }
public static void CreateEventFromConfig(ScheduledEventConfig config, ScheduledEventGroup group, ScheduledEvent.UserEventCallBack handler) public static void CreateEventFromConfig(ScheduledEventConfig config, ScheduledEventGroup group, ScheduledEvent.UserEventCallBack handler)
{
try
{ {
if (group == null) if (group == null)
{ {
Debug.LogMessage(LogEventLevel.Information, "Unable to create event. Group is null", null, null); Debug.Console(0, "Unable to create event. Group is null");
return; return;
} }
var scheduledEvent = new ScheduledEvent(config.Key, group) var scheduledEvent = new ScheduledEvent(config.Key, group)
@@ -242,12 +224,12 @@ Recurrence Days: {evt.Value.Recurrence.RecurrenceDays}
eventTime = eventTime.AddDays(1); eventTime = eventTime.AddDays(1);
} }
Debug.LogMessage(LogEventLevel.Verbose, "[Scheduler] Current Date day of week: {0} recurrence days: {1}", null, eventTime.DayOfWeek, Debug.Console(2, "[Scheduler] Current Date day of week: {0} recurrence days: {1}", eventTime.DayOfWeek,
config.Days); config.Days);
var dayOfWeekConverted = ConvertDayOfWeek(eventTime); var dayOfWeekConverted = ConvertDayOfWeek(eventTime);
Debug.LogMessage(LogEventLevel.Debug, "[Scheduler] eventTime Day: {0}", null, dayOfWeekConverted); Debug.Console(1, "[Scheduler] eventTime Day: {0}", dayOfWeekConverted);
while (!dayOfWeekConverted.IsFlagSet(config.Days)) while (!dayOfWeekConverted.IsFlagSet(config.Days))
{ {
@@ -260,23 +242,14 @@ Recurrence Days: {evt.Value.Recurrence.RecurrenceDays}
scheduledEvent.Recurrence.Weekly(config.Days); scheduledEvent.Recurrence.Weekly(config.Days);
Debug.LogMessage(LogEventLevel.Verbose, $"[Scheduler] Event State: {scheduledEvent.EventState}", null, null); if (config.Enable)
if (config.Enable && scheduledEvent.EventState != ScheduledEventCommon.eEventState.Enabled)
{ {
scheduledEvent.Enable(); scheduledEvent.Enable();
} }
else if (!config.Enable && scheduledEvent.EventState != ScheduledEventCommon.eEventState.Disabled) else
{ {
scheduledEvent.Disable(); scheduledEvent.Disable();
} }
}
catch (Exception e)
{
Debug.LogMessage(LogEventLevel.Error, "Error creating scheduled event: {0}", null, e);
}
} }
private static ScheduledEventCommon.eWeekDays ConvertDayOfWeek(DateTime eventTime) private static ScheduledEventCommon.eWeekDays ConvertDayOfWeek(DateTime eventTime)

View File

@@ -1,19 +1,20 @@
extern alias Full;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Reflection; using Crestron.SimplSharp.Reflection;
using Crestron.SimplSharp.CrestronIO; using Crestron.SimplSharp.CrestronIO;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Config;
using Newtonsoft.Json; using Full.Newtonsoft.Json;
using Serilog.Events;
namespace PepperDash.Essentials.Core namespace PepperDash.Essentials.Core
{ {
@@ -58,11 +59,11 @@ namespace PepperDash.Essentials.Core
if (!ConfigReader.ConfigObject.JoinMaps.ContainsKey(joinMapKey)) if (!ConfigReader.ConfigObject.JoinMaps.ContainsKey(joinMapKey))
{ {
Debug.LogMessage(LogEventLevel.Verbose, "No Join Map found in config with key: '{0}'", joinMapKey); Debug.Console(2, "No Join Map found in config with key: '{0}'", joinMapKey);
return null; return null;
} }
Debug.LogMessage(LogEventLevel.Verbose, "Attempting to load custom join map with key: {0}", joinMapKey); Debug.Console(2, "Attempting to load custom join map with key: {0}", joinMapKey);
var joinMapJToken = ConfigReader.ConfigObject.JoinMaps[joinMapKey]; var joinMapJToken = ConfigReader.ConfigObject.JoinMaps[joinMapKey];
@@ -75,7 +76,7 @@ namespace PepperDash.Essentials.Core
} }
catch (Exception e) catch (Exception e)
{ {
Debug.LogMessage(LogEventLevel.Verbose, "Error getting join map for key: '{0}'. Error: {1}", joinMapKey, e); Debug.Console(2, "Error getting join map for key: '{0}'. Error: {1}", joinMapKey, e);
return null; return null;
} }
} }
@@ -109,20 +110,19 @@ namespace PepperDash.Essentials.Core
protected void AddJoins(Type type) protected void AddJoins(Type type)
{ {
var fields = var fields =
type.GetFields(BindingFlags.Public | BindingFlags.Instance) type.GetCType()
.Where(f => f.IsDefined(typeof (JoinNameAttribute), true)).ToList(); .GetFields(BindingFlags.Public | BindingFlags.Instance)
.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);
//this here is JoinMapBaseAdvanced, not the child class. JoinMapBaseAdvanced has no fields. var value = field.GetValue(childClass) as JoinDataComplete; //this here is JoinMapBaseAdvanced, not the child class. JoinMapBaseAdvanced has no fields.
if (!(field.GetValue(childClass) is JoinDataComplete value)) if (value == null)
{ {
Debug.LogMessage(LogEventLevel.Information, "Unable to cast base class to {0}", type.Name); Debug.Console(0, "Unable to cast base class to {0}", type.Name);
continue; continue;
} }
@@ -130,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);
} }
@@ -147,53 +147,25 @@ namespace PepperDash.Essentials.Core
/// </summary> /// </summary>
public void PrintJoinMapInfo() public void PrintJoinMapInfo()
{ {
var sb = JoinmapStringBuilder(); Debug.Console(0, "{0}:\n", GetType().Name);
CrestronConsole.ConsoleCommandResponse(sb.ToString());
}
private StringBuilder JoinmapStringBuilder()
{
var sb = new StringBuilder();
var lineEnding = "\r\n";
var digitals =
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);
var serials =
Joins.Where(j => j.Value.Metadata.JoinType.HasFlag(eJoinType.Serial))
.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 // Get the joins of each type and print them
sb.Append($"# {GetType().Name}\r\n"); Debug.Console(0, "Digitals:");
sb.Append(lineEnding); var digitals = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Digital) == eJoinType.Digital).ToDictionary(j => j.Key, j => j.Value);
sb.Append($"## Digitals{lineEnding}"); Debug.Console(2, "Found {0} Digital Joins", digitals.Count);
sb.Append(lineEnding); PrintJoinList(GetSortedJoins(digitals));
// Get the joins of each type and print them
var digitalSb = AppendJoinList(GetSortedJoins(digitals)); Debug.Console(0, "Analogs:");
digitalSb.Append($"## Analogs{lineEnding}"); var analogs = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Analog) == eJoinType.Analog).ToDictionary(j => j.Key, j => j.Value);
digitalSb.Append(lineEnding); Debug.Console(2, "Found {0} Analog Joins", analogs.Count);
PrintJoinList(GetSortedJoins(analogs));
var analogSb = AppendJoinList(GetSortedJoins(analogs)); Debug.Console(0, "Serials:");
analogSb.Append($"## Serials{lineEnding}"); var serials = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Serial) == eJoinType.Serial).ToDictionary(j => j.Key, j => j.Value);
analogSb.Append(lineEnding); Debug.Console(2, "Found {0} Serial Joins", serials.Count);
PrintJoinList(GetSortedJoins(serials));
var serialSb = AppendJoinList(GetSortedJoins(serials));
sb.EnsureCapacity(sb.Length + digitalSb.Length + analogSb.Length + serialSb.Length);
sb.Append(digitalSb).Append(analogSb).Append(serialSb);
return sb;
} }
/// <summary> /// <summary>
/// Prints the join information to console /// Prints the join information to console
/// </summary> /// </summary>
@@ -201,22 +173,48 @@ namespace PepperDash.Essentials.Core
{ {
var pluginType = GetType().Name; var pluginType = GetType().Name;
CrestronConsole.ConsoleCommandResponse("{0}:\n", pluginType); Debug.Console(0, "{0}:\n", pluginType);
var sb = new StringBuilder();
sb.AppendLine(String.Format("# {0}", GetType().Name));
sb.AppendLine(String.Format("Generated from '{0}' on bridge '{1}'", deviceKey, bridgeKey));
sb.AppendLine();
sb.AppendLine("## Digitals");
// 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);
Debug.Console(2, "Found {0} Digital Joins", digitals.Count);
var digitalSb = AppendJoinList(GetSortedJoins(digitals));
digitalSb.AppendLine("## Analogs");
digitalSb.AppendLine();
WriteJoinmapMarkdown(JoinmapStringBuilder(), pluginType, bridgeKey, deviceKey); Debug.Console(0, "Analogs:");
var analogs = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Analog) == eJoinType.Analog).ToDictionary(j => j.Key, j => j.Value);
Debug.Console(2, "Found {0} Analog Joins", analogs.Count);
var analogSb = AppendJoinList(GetSortedJoins(analogs));
analogSb.AppendLine("## Serials");
analogSb.AppendLine();
Debug.Console(0, "Serials:");
var serials = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Serial) == eJoinType.Serial).ToDictionary(j => j.Key, j => j.Value);
Debug.Console(2, "Found {0} Serial Joins", serials.Count);
var serialSb = AppendJoinList(GetSortedJoins(serials));
sb.EnsureCapacity(sb.Length + digitalSb.Length + analogSb.Length + serialSb.Length);
sb.Append(digitalSb).Append(analogSb).Append(serialSb);
WriteJoinmapMarkdown(sb, pluginType, bridgeKey, deviceKey);
} }
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))
{ {
sw.WriteLine(stringBuilder.ToString()); sw.WriteLine(stringBuilder.ToString());
CrestronConsole.ConsoleCommandResponse("Joinmap Readme generated and written to {0}", fileName); Debug.Console(0, "Joinmap Readme generated and written to {0}", fileName);
} }
} }
@@ -226,7 +224,7 @@ namespace PepperDash.Essentials.Core
/// </summary> /// </summary>
/// <param name="joins"></param> /// <param name="joins"></param>
/// <returns></returns> /// <returns></returns>
static List<KeyValuePair<string, JoinDataComplete>> GetSortedJoins(Dictionary<string, JoinDataComplete> joins) List<KeyValuePair<string, JoinDataComplete>> GetSortedJoins(Dictionary<string, JoinDataComplete> joins)
{ {
var sortedJoins = joins.ToList(); var sortedJoins = joins.ToList();
@@ -235,11 +233,25 @@ namespace PepperDash.Essentials.Core
return sortedJoins; return sortedJoins;
} }
void PrintJoinList(List<KeyValuePair<string, JoinDataComplete>> joins)
{
foreach (var join in joins)
{
Debug.Console(0,
@"Join Number: {0} | JoinSpan: '{1}' | JoinName: {2} | Description: '{3}' | Type: '{4}' | Capabilities: '{5}'",
join.Value.JoinNumber,
join.Value.JoinSpan,
join.Key,
join.Value.AttributeName,
join.Value.Metadata.JoinType.ToString(),
join.Value.Metadata.JoinCapabilities.ToString());
}
}
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} |\r\n"; const string stringFormatter = "| {0} | {1} | {2} | {3} | {4} |";
const int joinNumberLen = 11; const int joinNumberLen = 11;
const int joinSpanLen = 9; const int joinSpanLen = 9;
const int typeLen = 19; const int typeLen = 19;
@@ -247,25 +259,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.Append(string.Format(stringFormatter, sb.AppendLine(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.Append(string.Format(stringFormatter, sb.AppendLine(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.Append(join.Value.GetMarkdownFormattedData(stringFormatter, descriptionLen)); sb.AppendLine(join.Value.GetMarkdownFormattedData(stringFormatter, descriptionLen));
} }
sb.Append("\r\n"); sb.AppendLine();
return sb; return sb;
} }
@@ -277,18 +289,16 @@ namespace PepperDash.Essentials.Core
{ {
foreach (var customJoinData in joinData) foreach (var customJoinData in joinData)
{ {
JoinDataComplete join; var join = Joins[customJoinData.Key];
if (!Joins.TryGetValue(customJoinData.Key, out join))
{
Debug.LogMessage(LogEventLevel.Verbose, "No matching key found in join map for: '{0}'", customJoinData.Key);
continue;
}
if (join != null) if (join != null)
{ {
join.SetCustomJoinData(customJoinData.Value); join.SetCustomJoinData(customJoinData.Value);
} }
else
{
Debug.Console(2, "No matching key found in join map for: '{0}'", customJoinData.Key);
}
} }
PrintJoinMapInfo(); PrintJoinMapInfo();
@@ -420,10 +430,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";
@@ -439,13 +449,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"],
@@ -463,8 +473,8 @@ namespace PepperDash.Essentials.Core
errorKey = item.Key; errorKey = item.Key;
break; break;
} }
Debug.LogMessage(LogEventLevel.Information, "Unable to decode join metadata {1}- {0}", e.Message, !string.IsNullOrEmpty(errorKey) ? (' ' + errorKey) : string.Empty); Debug.Console(0, "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"],
@@ -510,12 +520,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)Attribute.GetCustomAttribute(memberInfo, typeof(JoinNameAttribute)); var attribute = (JoinNameAttribute)CAttribute.GetCustomAttribute(memberInfo, typeof(JoinNameAttribute));
if (attribute == null) return name; if (attribute == null) return name;
name = attribute.Name; name = attribute.Name;
Debug.LogMessage(LogEventLevel.Verbose, "JoinName Attribute value: {0}", name); Debug.Console(2, "JoinName Attribute value: {0}", name);
return name; return name;
} }
} }
@@ -523,13 +533,13 @@ namespace PepperDash.Essentials.Core
[AttributeUsage(AttributeTargets.All)] [AttributeUsage(AttributeTargets.All)]
public class JoinNameAttribute : Attribute public class JoinNameAttribute : CAttribute
{ {
private string _Name; private string _Name;
public JoinNameAttribute(string name) public JoinNameAttribute(string name)
{ {
Debug.LogMessage(LogEventLevel.Verbose, "Setting Attribute Name: {0}",null, name); Debug.Console(2, "Setting Attribute Name: {0}", name);
_Name = name; _Name = name;
} }

View File

@@ -8,7 +8,6 @@ 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
@@ -70,7 +69,7 @@ namespace PepperDash.Essentials.License
{ {
IsValid = isValid; IsValid = isValid;
CrestronDataStoreStatic.SetGlobalBoolValue("MockLicense", isValid); CrestronDataStoreStatic.SetGlobalBoolValue("MockLicense", isValid);
Debug.LogMessage(LogEventLevel.Information, "Mock License is{0} valid", IsValid ? "" : " not"); Debug.Console(0, "Mock License is{0} valid", IsValid ? "" : " not");
LicenseIsValid.FireUpdate(); LicenseIsValid.FireUpdate();
} }

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