mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-08 09:15:06 +00:00
Compare commits
23 Commits
feature/Ge
...
1.7.5-alph
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a426ebc3a | ||
|
|
f0299729e6 | ||
|
|
657b9f1f54 | ||
|
|
76a8b50b6f | ||
|
|
bee73edbe1 | ||
|
|
fb97cf4753 | ||
|
|
3fd84d1fac | ||
|
|
c262e7c3c5 | ||
|
|
7404566f72 | ||
|
|
cb49b1f8c8 | ||
|
|
de3f2004de | ||
|
|
0cfc727b08 | ||
|
|
0f8251ea8a | ||
|
|
13cbeb7605 | ||
|
|
2fd2b6787f | ||
|
|
dd48147fdb | ||
|
|
33c3c1ad30 | ||
|
|
f154ce2385 | ||
|
|
9a0cf05360 | ||
|
|
d2e4be162d | ||
|
|
9dbfd9bcae | ||
|
|
8d1ec183df | ||
|
|
d52941d91d |
23
.github/scripts/GenerateVersionNumber-2.0.0.ps1
vendored
Normal file
23
.github/scripts/GenerateVersionNumber-2.0.0.ps1
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
$latestVersion = [version]"2.0.0"
|
||||||
|
|
||||||
|
$newVersion = [version]$latestVersion
|
||||||
|
$phase = ""
|
||||||
|
$newVersionString = ""
|
||||||
|
|
||||||
|
switch -regex ($Env:GITHUB_REF) {
|
||||||
|
'^refs\/pull\/*.' {
|
||||||
|
$phase = 'beta';
|
||||||
|
$newVersionString = "{0}-{1}-{2}" -f $newVersion, $phase, $Env:GITHUB_RUN_NUMBER
|
||||||
|
}
|
||||||
|
'^refs\/heads\/feature-2.0.0\/*.' {
|
||||||
|
$phase = 'alpha'
|
||||||
|
$newVersionString = "{0}-{1}-{2}" -f $newVersion, $phase, $Env:GITHUB_RUN_NUMBER
|
||||||
|
}
|
||||||
|
'development-2.0.0' {
|
||||||
|
$phase = 'beta'
|
||||||
|
$newVersionString = "{0}-{1}-{2}" -f $newVersion, $phase, $Env:GITHUB_RUN_NUMBER
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Write-Output $newVersionString
|
||||||
307
.github/workflows/Build Essentials.yml
vendored
Normal file
307
.github/workflows/Build Essentials.yml
vendored
Normal file
@@ -0,0 +1,307 @@
|
|||||||
|
name: Build Essentials 2.0.0
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- feature-2.0.0/*
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- closed
|
||||||
|
branches:
|
||||||
|
- development-2.0.0
|
||||||
|
|
||||||
|
env:
|
||||||
|
# solution path doesn't need slashes unless there it is multiple folders deep
|
||||||
|
# solution name does not include extension. .sln is assumed
|
||||||
|
SOLUTION_PATH: PepperDashEssentials
|
||||||
|
SOLUTION_FILE: PepperDashEssentials
|
||||||
|
# Do not edit this, we're just creating it here
|
||||||
|
VERSION: 0.0.0-buildtype-buildnumber
|
||||||
|
# Defaults to debug for build type
|
||||||
|
BUILD_TYPE: Debug
|
||||||
|
# Defaults to main as the release branch. Change as necessary
|
||||||
|
RELEASE_BRANCH: main
|
||||||
|
jobs:
|
||||||
|
Build_Project:
|
||||||
|
runs-on: windows-latest
|
||||||
|
steps:
|
||||||
|
# First we checkout the source repo
|
||||||
|
- name: Checkout repo
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
# Fetch all tags
|
||||||
|
- name: Fetch tags
|
||||||
|
run: git fetch --tags
|
||||||
|
# Generate the appropriate version number
|
||||||
|
- name: Set Version Number
|
||||||
|
shell: powershell
|
||||||
|
run: |
|
||||||
|
$version = ./.github/scripts/GenerateVersionNumber-2.0.0.ps1
|
||||||
|
echo "VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||||
|
# Use the version number to set the version of the assemblies
|
||||||
|
- name: Update AssemblyInfo.cs
|
||||||
|
shell: powershell
|
||||||
|
run: |
|
||||||
|
./.github/scripts/UpdateAssemblyVersion.ps1 ${{ env.VERSION }}
|
||||||
|
- name: restore Nuget Packages
|
||||||
|
run: nuget install .\packages.config -OutputDirectory .\packages -ExcludeVersion
|
||||||
|
# Login to Docker
|
||||||
|
- name: Login to Docker
|
||||||
|
uses: azure/docker-login@v1
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_TOKEN }}
|
||||||
|
# Build the solutions in the docker image
|
||||||
|
- name: Build Solution
|
||||||
|
shell: powershell
|
||||||
|
run: |
|
||||||
|
Invoke-Expression "docker run --rm --mount type=bind,source=""$($Env:GITHUB_WORKSPACE)"",target=""c:/project"" pepperdash/sspbuilder c:\cihelpers\vsidebuild.exe -Solution ""c:\project\$($Env:SOLUTION_FILE).sln"" -BuildSolutionConfiguration $($ENV:BUILD_TYPE)"
|
||||||
|
# Zip up the output files as needed
|
||||||
|
- name: Zip Build Output
|
||||||
|
shell: powershell
|
||||||
|
run: ./.github/scripts/ZipBuildOutput.ps1
|
||||||
|
# Write the version to a file to be consumed by the push jobs
|
||||||
|
- name: Write Version
|
||||||
|
run: Write-Output "$($Env:VERSION)" | Out-File -FilePath "$($Env:GITHUB_HOME)\output\version.txt"
|
||||||
|
# Upload the build output as an artifact
|
||||||
|
- name: Upload Build Output
|
||||||
|
uses: actions/upload-artifact@v1
|
||||||
|
with:
|
||||||
|
name: Build
|
||||||
|
path: ./${{ env.SOLUTION_FILE}}-${{ env.VERSION}}.zip
|
||||||
|
# Upload the Version file as an artifact
|
||||||
|
- name: Upload version.txt
|
||||||
|
uses: actions/upload-artifact@v1
|
||||||
|
with:
|
||||||
|
name: Version
|
||||||
|
path: ${{env.GITHUB_HOME}}\output\version.txt
|
||||||
|
# Create the release on the source repo
|
||||||
|
- name: Create tag for non-rc builds
|
||||||
|
if: contains(env.VERSION, 'alpha') || contains(env.VERSION, 'beta')
|
||||||
|
run: |
|
||||||
|
git tag $($Env:VERSION)
|
||||||
|
git push --tags origin
|
||||||
|
- name: Create Release
|
||||||
|
id: create_release
|
||||||
|
# using contributor's version to allow for pointing at the right commit
|
||||||
|
if: contains(env.VERSION,'-rc-') || contains(env.VERSION,'-hotfix-')
|
||||||
|
uses: fleskesvor/create-release@feature/support-target-commitish
|
||||||
|
with:
|
||||||
|
tag_name: ${{ env.VERSION }}
|
||||||
|
release_name: ${{ env.VERSION }}
|
||||||
|
prerelease: ${{contains('debug', env.BUILD_TYPE)}}
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
# Upload the build package to the release
|
||||||
|
- name: Upload Release Package
|
||||||
|
if: contains(env.VERSION,'-rc-') || contains(env.VERSION,'-hotfix-')
|
||||||
|
id: upload_release
|
||||||
|
uses: actions/upload-release-asset@v1
|
||||||
|
with:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
asset_path: ./${{ env.SOLUTION_FILE}}-${{ env.VERSION}}.zip
|
||||||
|
asset_name: ${{ env.SOLUTION_FILE}}-${{ env.VERSION}}.zip
|
||||||
|
asset_content_type: application/zip
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
Push_Nuget_Package:
|
||||||
|
needs: Build_Project
|
||||||
|
runs-on: windows-latest
|
||||||
|
steps:
|
||||||
|
- name: Download Build Version Info
|
||||||
|
uses: actions/download-artifact@v1
|
||||||
|
with:
|
||||||
|
name: Version
|
||||||
|
- name: Set Version Number
|
||||||
|
shell: powershell
|
||||||
|
run: |
|
||||||
|
Get-ChildItem "./Version"
|
||||||
|
$version = Get-Content -Path ./Version/version.txt
|
||||||
|
Write-Host "Version: $version"
|
||||||
|
echo "VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||||
|
Remove-Item -Path ./Version/version.txt
|
||||||
|
Remove-Item -Path ./Version
|
||||||
|
- name: Download Build output
|
||||||
|
uses: actions/download-artifact@v1
|
||||||
|
with:
|
||||||
|
name: Build
|
||||||
|
path: ./
|
||||||
|
- name: Unzip Build file
|
||||||
|
run: |
|
||||||
|
Get-ChildItem .\*.zip | Expand-Archive -DestinationPath .\
|
||||||
|
Remove-Item -Path .\*.zip
|
||||||
|
- name: Copy Files to root & delete output directory
|
||||||
|
run: |
|
||||||
|
Remove-Item -Path .\* -Include @("*.cpz","*.md","*.cplz","*.json","*.dll","*.clz")
|
||||||
|
Get-ChildItem -Path .\output\* | Copy-Item -Destination .\
|
||||||
|
Remove-Item -Path .\output -Recurse
|
||||||
|
- name: Add nuget.exe
|
||||||
|
uses: nuget/setup-nuget@v1
|
||||||
|
- name: Add Github Packages source
|
||||||
|
run: nuget sources add -name github -source https://nuget.pkg.github.com/pepperdash/index.json -username Pepperdash -password ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- name: Add nuget.org API Key
|
||||||
|
run: nuget setApiKey ${{ secrets.NUGET_API_KEY }}
|
||||||
|
- name: Create nuget package
|
||||||
|
run: nuget pack "./PepperDash_Essentials_Core.nuspec" -version ${{ env.VERSION }}
|
||||||
|
- name: Publish nuget package to Github registry
|
||||||
|
run: nuget push **/*.nupkg -source github
|
||||||
|
- name: Publish nuget package to nuget.org
|
||||||
|
run: nuget push **/*.nupkg -Source https://api.nuget.org/v3/index.json
|
||||||
|
# This step always runs and pushes the build to the internal build rep
|
||||||
|
# Internal_Push_Output:
|
||||||
|
# needs: Build_Project
|
||||||
|
# runs-on: windows-latest
|
||||||
|
# steps:
|
||||||
|
# - name: check Github ref
|
||||||
|
# run: ${{toJson(github.ref)}}
|
||||||
|
# # Checkout the repo
|
||||||
|
# - name: Checkout Builds Repo
|
||||||
|
# uses: actions/checkout@v2
|
||||||
|
# with:
|
||||||
|
# token: ${{ secrets.BUILDS_TOKEN }}
|
||||||
|
# repository: PepperDash-Engineering/essentials-builds
|
||||||
|
# ref: ${{ Env.GITHUB_REF }}
|
||||||
|
# # Download the version artifact from the build job
|
||||||
|
# - name: Download Build Version Info
|
||||||
|
# uses: actions/download-artifact@v1
|
||||||
|
# with:
|
||||||
|
# name: Version
|
||||||
|
# - name: Check Directory
|
||||||
|
# run: Get-ChildItem "./"
|
||||||
|
# # Set the version number environment variable from the file we just downloaded
|
||||||
|
# - name: Set Version Number
|
||||||
|
# shell: powershell
|
||||||
|
# run: |
|
||||||
|
# Get-ChildItem "./Version"
|
||||||
|
# $version = Get-Content -Path ./Version/version.txt
|
||||||
|
# Write-Host "Version: $version"
|
||||||
|
# echo "VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||||
|
# Remove-Item -Path ./Version/version.txt
|
||||||
|
# Remove-Item -Path ./Version
|
||||||
|
# # Checkout/Create the branch
|
||||||
|
# - name: Create new branch
|
||||||
|
# run: git checkout -b $($Env:GITHUB_REF -replace "refs/heads/")
|
||||||
|
# # Download the build output into the repo
|
||||||
|
# - name: Download Build output
|
||||||
|
# uses: actions/download-artifact@v1
|
||||||
|
# with:
|
||||||
|
# name: Build
|
||||||
|
# path: ./
|
||||||
|
# - name: Check directory
|
||||||
|
# run: Get-ChildItem ./
|
||||||
|
# # Unzip the build package file
|
||||||
|
# - name: Unzip Build file
|
||||||
|
# run: |
|
||||||
|
# Get-ChildItem .\*.zip | Expand-Archive -DestinationPath .\
|
||||||
|
# Remove-Item -Path .\*.zip
|
||||||
|
# - name: Check directory again
|
||||||
|
# run: Get-ChildItem ./
|
||||||
|
# # Copy Contents of output folder to root directory
|
||||||
|
# - name: Copy Files to root & delete output directory
|
||||||
|
# run: |
|
||||||
|
# Remove-Item -Path .\* -Include @("*.cpz","*.md","*.cplz","*.json","*.dll","*.clz")
|
||||||
|
# Get-ChildItem -Path .\output\* | Copy-Item -Destination .\
|
||||||
|
# Remove-Item -Path .\output -Recurse
|
||||||
|
# # Commits the build output to the branch and tags it with the version
|
||||||
|
# - name: Commit build output and tag the commit
|
||||||
|
# shell: powershell
|
||||||
|
# run: |
|
||||||
|
# git config user.email "actions@pepperdash.com"
|
||||||
|
# git config user.name "GitHub Actions"
|
||||||
|
# git add .
|
||||||
|
# $commit = "Build $($Env:GITHUB_RUN_NUMBER) from commit: https://github.com/$($Env:GITHUB_REPOSITORY)/commit/$($Env:GITHUB_SHA)"
|
||||||
|
# Write-Host "Commit: $commit"
|
||||||
|
# git commit -m $commit
|
||||||
|
# git tag $($Env:VERSION)
|
||||||
|
# # Push the commit
|
||||||
|
# - name: Push to Builds Repo
|
||||||
|
# shell: powershell
|
||||||
|
# run: |
|
||||||
|
# $branch = $($Env:GITHUB_REF) -replace "refs/heads/"
|
||||||
|
# Write-Host "Branch: $branch"
|
||||||
|
# git push -u origin $($branch) --force
|
||||||
|
# # Push the tags
|
||||||
|
# - name: Push tags
|
||||||
|
# run: git push --tags origin
|
||||||
|
# - name: Check Directory
|
||||||
|
# run: Get-ChildItem ./
|
||||||
|
# # This step only runs if the branch is main or release/ runs and pushes the build to the public build repo
|
||||||
|
# Public_Push_Output:
|
||||||
|
# needs: Build_Project
|
||||||
|
# runs-on: windows-latest
|
||||||
|
# if: contains(github.ref, 'main') || contains(github.ref, '/release/')
|
||||||
|
# steps:
|
||||||
|
# # Checkout the repo
|
||||||
|
# - name: check Github ref
|
||||||
|
# run: ${{toJson(github.ref)}}
|
||||||
|
# - name: Checkout Builds Repo
|
||||||
|
# uses: actions/checkout@v2
|
||||||
|
# with:
|
||||||
|
# token: ${{ secrets.BUILDS_TOKEN }}
|
||||||
|
# repository: PepperDash/Essentials-Builds
|
||||||
|
# ref: ${{ Env.GITHUB_REF }}
|
||||||
|
# # Download the version artifact from the build job
|
||||||
|
# - name: Download Build Version Info
|
||||||
|
# uses: actions/download-artifact@v1
|
||||||
|
# with:
|
||||||
|
# name: Version
|
||||||
|
# - name: Check Directory
|
||||||
|
# run: Get-ChildItem "./"
|
||||||
|
# # Set the version number environment variable from the file we just downloaded
|
||||||
|
# - name: Set Version Number
|
||||||
|
# shell: powershell
|
||||||
|
# run: |
|
||||||
|
# Get-ChildItem "./Version"
|
||||||
|
# $version = Get-Content -Path ./Version/version.txt
|
||||||
|
# Write-Host "Version: $version"
|
||||||
|
# echo "VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||||
|
# Remove-Item -Path ./Version/version.txt
|
||||||
|
# Remove-Item -Path ./Version
|
||||||
|
# # Checkout/Create the branch
|
||||||
|
# - name: Create new branch
|
||||||
|
# run: git checkout -b $($Env:GITHUB_REF -replace "refs/heads/")
|
||||||
|
# # Download the build output into the repo
|
||||||
|
# - name: Download Build output
|
||||||
|
# uses: actions/download-artifact@v1
|
||||||
|
# with:
|
||||||
|
# name: Build
|
||||||
|
# path: ./
|
||||||
|
# - name: Check directory
|
||||||
|
# run: Get-ChildItem ./
|
||||||
|
# # Unzip the build package file
|
||||||
|
# - name: Unzip Build file
|
||||||
|
# run: |
|
||||||
|
# Get-ChildItem .\*.zip | Expand-Archive -DestinationPath .\
|
||||||
|
# Remove-Item -Path .\*.zip
|
||||||
|
# - name: Check directory again
|
||||||
|
# run: Get-ChildItem ./
|
||||||
|
# # Copy Contents of output folder to root directory
|
||||||
|
# - name: Copy Files to root & delete output directory
|
||||||
|
# run: |
|
||||||
|
# Remove-Item -Path .\* -Include @("*.cpz","*.md","*.cplz","*.json","*.dll","*.clz")
|
||||||
|
# Get-ChildItem -Path .\output\* | Copy-Item -Destination .\
|
||||||
|
# Remove-Item -Path .\output -Recurse
|
||||||
|
# # Commits the build output to the branch and tags it with the version
|
||||||
|
# - name: Commit build output and tag the commit
|
||||||
|
# shell: powershell
|
||||||
|
# run: |
|
||||||
|
# git config user.email "actions@pepperdash.com"
|
||||||
|
# git config user.name "GitHub Actions"
|
||||||
|
# git add .
|
||||||
|
# $commit = "Build $($Env:GITHUB_RUN_NUMBER) from commit: https://github.com/$($Env:GITHUB_REPOSITORY)/commit/$($Env:GITHUB_SHA)"
|
||||||
|
# Write-Host "Commit: $commit"
|
||||||
|
# git commit -m $commit
|
||||||
|
# git tag $($Env:VERSION)
|
||||||
|
# # Push the commit
|
||||||
|
# - name: Push to Builds Repo
|
||||||
|
# shell: powershell
|
||||||
|
# run: |
|
||||||
|
# $branch = $($Env:GITHUB_REF) -replace "refs/heads/"
|
||||||
|
# Write-Host "Branch: $branch"
|
||||||
|
# git push -u origin $($branch) --force
|
||||||
|
# # Push the tags
|
||||||
|
# - name: Push tags
|
||||||
|
# run: git push --tags origin
|
||||||
|
# - name: Check Directory
|
||||||
|
# run: Get-ChildItem ./
|
||||||
@@ -17,6 +17,7 @@ using PepperDash.Essentials.Devices.Common;
|
|||||||
using PepperDash.Essentials.DM;
|
using PepperDash.Essentials.DM;
|
||||||
using PepperDash.Essentials.Fusion;
|
using PepperDash.Essentials.Fusion;
|
||||||
using PepperDash.Essentials.Room.Config;
|
using PepperDash.Essentials.Room.Config;
|
||||||
|
using PepperDash.Essentials.Core.Room;
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
|
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
|
||||||
@@ -61,6 +62,8 @@ namespace PepperDash.Essentials
|
|||||||
|
|
||||||
CrestronConsole.AddNewConsoleCommand(PepperDash.Essentials.Core.DeviceFactory.GetDeviceFactoryTypes, "gettypes", "Gets the device types that can be built. Accepts a filter string.", ConsoleAccessLevelEnum.AccessOperator);
|
CrestronConsole.AddNewConsoleCommand(PepperDash.Essentials.Core.DeviceFactory.GetDeviceFactoryTypes, "gettypes", "Gets the device types that can be built. Accepts a filter string.", ConsoleAccessLevelEnum.AccessOperator);
|
||||||
|
|
||||||
|
CrestronConsole.AddNewConsoleCommand(PepperDash.Essentials.Core.Room.Components.ComponentFactory.GetComponentFactoryTypes, "getcomponenttypes", "Gets the components types that can be built. Accepts a filter string.", ConsoleAccessLevelEnum.AccessOperator);
|
||||||
|
|
||||||
CrestronConsole.AddNewConsoleCommand(BridgeHelper.PrintJoinMap, "getjoinmap", "map(s) for bridge or device on bridge [brKey [devKey]]", ConsoleAccessLevelEnum.AccessOperator);
|
CrestronConsole.AddNewConsoleCommand(BridgeHelper.PrintJoinMap, "getjoinmap", "map(s) for bridge or device on bridge [brKey [devKey]]", ConsoleAccessLevelEnum.AccessOperator);
|
||||||
|
|
||||||
CrestronConsole.AddNewConsoleCommand(s =>
|
CrestronConsole.AddNewConsoleCommand(s =>
|
||||||
@@ -429,8 +432,18 @@ namespace PepperDash.Essentials
|
|||||||
|
|
||||||
foreach (var roomConfig in ConfigReader.ConfigObject.Rooms)
|
foreach (var roomConfig in ConfigReader.ConfigObject.Rooms)
|
||||||
{
|
{
|
||||||
var room = EssentialsRoomConfigHelper.GetRoomObject(roomConfig) as EssentialsRoomBase;
|
Device room = null;
|
||||||
if (room != null)
|
|
||||||
|
if (roomConfig.Type.ToLower() != "componentroom")
|
||||||
|
{
|
||||||
|
room = EssentialsRoomConfigHelper.GetRoomObject(roomConfig) as EssentialsRoomBase;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
room = new ComponentRoom(roomConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (room != null && room is EssentialsRoomBase)
|
||||||
{
|
{
|
||||||
// default IPID
|
// default IPID
|
||||||
uint fusionIpId = 0xf1;
|
uint fusionIpId = 0xf1;
|
||||||
@@ -438,11 +451,14 @@ namespace PepperDash.Essentials
|
|||||||
// default to no join map key
|
// default to no join map key
|
||||||
string fusionJoinMapKey = string.Empty;
|
string fusionJoinMapKey = string.Empty;
|
||||||
|
|
||||||
if (room.Config.Properties["fusion"] != null)
|
|
||||||
|
var essRoom = room as EssentialsRoomBase;
|
||||||
|
|
||||||
|
if (essRoom.Config.Properties["fusion"] != null)
|
||||||
{
|
{
|
||||||
Debug.Console(2, "Custom Fusion config found. Using custom values");
|
Debug.Console(2, "Custom Fusion config found. Using custom values");
|
||||||
|
|
||||||
var fusionConfig = room.Config.Properties["fusion"].ToObject<EssentialsRoomFusionConfig>();
|
var fusionConfig = essRoom.Config.Properties["fusion"].ToObject<EssentialsRoomFusionConfig>();
|
||||||
|
|
||||||
if (fusionConfig != null)
|
if (fusionConfig != null)
|
||||||
{
|
{
|
||||||
@@ -453,26 +469,24 @@ namespace PepperDash.Essentials
|
|||||||
|
|
||||||
if (room is EssentialsHuddleSpaceRoom)
|
if (room is EssentialsHuddleSpaceRoom)
|
||||||
{
|
{
|
||||||
DeviceManager.AddDevice(room);
|
|
||||||
|
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Room is EssentialsHuddleSpaceRoom, attempting to add to DeviceManager with Fusion");
|
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Room is EssentialsHuddleSpaceRoom, attempting to add to DeviceManager with Fusion");
|
||||||
DeviceManager.AddDevice(new Core.Fusion.EssentialsHuddleSpaceFusionSystemControllerBase(room, fusionIpId, fusionJoinMapKey));
|
DeviceManager.AddDevice(new Core.Fusion.EssentialsHuddleSpaceFusionSystemControllerBase(essRoom, fusionIpId, fusionJoinMapKey));
|
||||||
|
|
||||||
|
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to build Mobile Control Bridge...");
|
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to build Mobile Control Bridge...");
|
||||||
|
|
||||||
CreateMobileControlBridge(room);
|
CreateMobileControlBridge(room as EssentialsRoomBase);
|
||||||
}
|
}
|
||||||
else if (room is EssentialsHuddleVtc1Room)
|
else if (room is EssentialsHuddleVtc1Room)
|
||||||
{
|
{
|
||||||
DeviceManager.AddDevice(room);
|
|
||||||
|
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Room is EssentialsHuddleVtc1Room, attempting to add to DeviceManager with Fusion");
|
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Room is EssentialsHuddleVtc1Room, attempting to add to DeviceManager with Fusion");
|
||||||
DeviceManager.AddDevice(new EssentialsHuddleVtc1FusionController((EssentialsHuddleVtc1Room)room, fusionIpId, fusionJoinMapKey));
|
DeviceManager.AddDevice(new EssentialsHuddleVtc1FusionController((EssentialsHuddleVtc1Room)essRoom, fusionIpId, fusionJoinMapKey));
|
||||||
|
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to build Mobile Control Bridge...");
|
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to build Mobile Control Bridge...");
|
||||||
|
|
||||||
CreateMobileControlBridge(room);
|
CreateMobileControlBridge(room as EssentialsRoomBase);
|
||||||
}
|
}
|
||||||
else if (room is EssentialsTechRoom)
|
else if (room is EssentialsTechRoom)
|
||||||
{
|
{
|
||||||
@@ -480,18 +494,20 @@ namespace PepperDash.Essentials
|
|||||||
|
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice,
|
Debug.Console(0, Debug.ErrorLogLevel.Notice,
|
||||||
"Room is EssentialsTechRoom, Attempting to add to DeviceManager with Fusion");
|
"Room is EssentialsTechRoom, Attempting to add to DeviceManager with Fusion");
|
||||||
DeviceManager.AddDevice(new EssentialsTechRoomFusionSystemController((EssentialsTechRoom)room, fusionIpId, fusionJoinMapKey));
|
DeviceManager.AddDevice(new EssentialsTechRoomFusionSystemController((EssentialsTechRoom)essRoom, fusionIpId, fusionJoinMapKey));
|
||||||
|
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to build Mobile Control Bridge");
|
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to build Mobile Control Bridge");
|
||||||
|
|
||||||
CreateMobileControlBridge(room);
|
CreateMobileControlBridge(essRoom);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Room is NOT EssentialsRoom, attempting to add to DeviceManager w/o Fusion");
|
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Room is NOT EssentialsRoom, attempting to add to DeviceManager w/o Fusion");
|
||||||
DeviceManager.AddDevice(room);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else if (room != null)
|
||||||
|
{
|
||||||
|
DeviceManager.AddDevice(room);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Notice: Cannot create room from config, key '{0}' - Is this intentional? This may be a valid configuration.", roomConfig.Key);
|
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Notice: Cannot create room from config, key '{0}' - Is this intentional? This may be a valid configuration.", roomConfig.Key);
|
||||||
@@ -588,9 +604,9 @@ namespace PepperDash.Essentials
|
|||||||
return ((logoDark != null && logoDark == "system") ||
|
return ((logoDark != null && logoDark == "system") ||
|
||||||
(logoLight != null && logoLight == "system") || (logo != null && logo == "system"));
|
(logoLight != null && logoLight == "system") || (logo != null && logo == "system"));
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(1, Debug.ErrorLogLevel.Notice, "Unable to find logo information in any room config");
|
Debug.Console(1, Debug.ErrorLogLevel.Notice, "Unable to find logo information in any room config: {0}", e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<ProjectGuid>{1BED5BA9-88C4-4365-9362-6F4B128071D3}</ProjectGuid>
|
<ProjectGuid>{1BED5BA9-88C4-4365-9362-6F4B128071D3}</ProjectGuid>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>PepperDashEssentials</RootNamespace>
|
<RootNamespace>PepperDash.Essentials</RootNamespace>
|
||||||
<AssemblyName>PepperDashEssentials</AssemblyName>
|
<AssemblyName>PepperDashEssentials</AssemblyName>
|
||||||
<ProjectTypeGuids>{0B4745B0-194B-4BB6-8E21-E9057CA92230};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
<ProjectTypeGuids>{0B4745B0-194B-4BB6-8E21-E9057CA92230};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
<PlatformFamilyName>WindowsCE</PlatformFamilyName>
|
<PlatformFamilyName>WindowsCE</PlatformFamilyName>
|
||||||
|
|||||||
@@ -246,8 +246,11 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
public class DeviceActionWrapper
|
public class DeviceActionWrapper
|
||||||
{
|
{
|
||||||
|
[JsonProperty("deviceKey")]
|
||||||
public string DeviceKey { get; set; }
|
public string DeviceKey { get; set; }
|
||||||
|
[JsonProperty("methodName")]
|
||||||
public string MethodName { get; set; }
|
public string MethodName { get; set; }
|
||||||
|
[JsonProperty("params")]
|
||||||
public object[] Params { get; set; }
|
public object[] Params { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,17 +64,19 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Devices the basic needs for a Device Factory
|
/// Defines the basic needs for a Device Factory
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class EssentialsDeviceFactory<T> : IDeviceFactory where T:EssentialsDevice
|
public abstract class EssentialsDeviceFactory<T> : IDeviceFactory where T:EssentialsDevice
|
||||||
{
|
{
|
||||||
#region IDeviceFactory Members
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A list of strings that can be used in the type property of a DeviceConfig object to build an instance of this device
|
/// A list of strings that can be used in the type property of a DeviceConfig object to build an instance of this device
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<string> TypeNames { get; protected set; }
|
public List<string> TypeNames { get; protected set; }
|
||||||
|
|
||||||
|
|
||||||
|
#region IDeviceFactory Members
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads an item to the DeviceFactory.FactoryMethods dictionary for each entry in the TypeNames list
|
/// Loads an item to the DeviceFactory.FactoryMethods dictionary for each entry in the TypeNames list
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -90,6 +92,8 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The method that will build the device
|
/// The method that will build the device
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -97,11 +101,10 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// <returns>An instance of the device</returns>
|
/// <returns>An instance of the device</returns>
|
||||||
public abstract EssentialsDevice BuildDevice(DeviceConfig dc);
|
public abstract EssentialsDevice BuildDevice(DeviceConfig dc);
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Devices the basic needs for a Device Factory
|
/// Defines the basic needs for a Device Factory
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class EssentialsPluginDeviceFactory<T> : EssentialsDeviceFactory<T>, IPluginDeviceFactory where T : EssentialsDevice
|
public abstract class EssentialsPluginDeviceFactory<T> : EssentialsDeviceFactory<T>, IPluginDeviceFactory where T : EssentialsDevice
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
public interface IDeviceFactory
|
public interface IDeviceFactory
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads all the types to the DeviceFactory
|
/// Loads all the types to the Factory
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void LoadTypeFactories();
|
void LoadTypeFactories();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,135 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Crestron.SimplSharp;
|
||||||
|
|
||||||
|
using PepperDash.Core;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.Interfaces.Components
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Describes a room comprised of components
|
||||||
|
/// </summary>
|
||||||
|
public interface IComponentRoom : IKeyed
|
||||||
|
{
|
||||||
|
List<IActivatableComponent> Components { get; }
|
||||||
|
List<IRoomActivityComponent> Activities { get; }
|
||||||
|
|
||||||
|
List<T> GetComponentsOfType<T>() where T : IActivatableComponent;
|
||||||
|
List<IRoomActivityComponent> GetOrderedActvities();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Describes a component
|
||||||
|
/// </summary>
|
||||||
|
public interface IComponent : IKeyed
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Describes a room component
|
||||||
|
/// </summary>
|
||||||
|
public interface IRoomComponent : IComponent
|
||||||
|
{
|
||||||
|
IComponentRoom Parent { get; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Describes a room activity component
|
||||||
|
/// </summary>
|
||||||
|
public interface IRoomActivityComponent : IRoomComponent
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates if the component is enabled
|
||||||
|
/// </summary>
|
||||||
|
BoolFeedback IsEnabledFeedback { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set this value to enable or disable the component
|
||||||
|
/// </summary>
|
||||||
|
bool Enable { set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Label to be displayed for the activity on the UI
|
||||||
|
/// </summary>
|
||||||
|
string Label { get; }
|
||||||
|
/// <summary>
|
||||||
|
/// Icon to be displayed for the activity on the UI
|
||||||
|
/// </summary>
|
||||||
|
string Icon { get; }
|
||||||
|
/// <summary>
|
||||||
|
/// The component group that will be activated when this activty starts
|
||||||
|
/// </summary>
|
||||||
|
IRoomBehaviourGroupComponent Component { get; }
|
||||||
|
/// <summary>
|
||||||
|
/// Determines the order the activities will be displayed on the UI
|
||||||
|
/// </summary>
|
||||||
|
int Order { get; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Starts the activity
|
||||||
|
/// </summary>
|
||||||
|
void StartActivity();
|
||||||
|
/// <summary>
|
||||||
|
/// Ends the activity
|
||||||
|
/// </summary>
|
||||||
|
void EndActivity();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Describes a room component that can be "activated"
|
||||||
|
/// </summary>
|
||||||
|
public interface IActivatableComponent : IRoomComponent
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates if the component is activated
|
||||||
|
/// </summary>
|
||||||
|
BoolFeedback ActivatedFeedback { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Activates the component
|
||||||
|
/// </summary>
|
||||||
|
void Activate();
|
||||||
|
/// <summary>
|
||||||
|
/// Dactivates the component
|
||||||
|
/// </summary>
|
||||||
|
void Deactivate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Describes a group of room behaviour component. Is able to contain a collection of components that aggregate
|
||||||
|
/// together to behave as one
|
||||||
|
/// </summary>
|
||||||
|
public interface IRoomBehaviourGroupComponent
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A collection of components that work together to achieve a common behaviour
|
||||||
|
/// </summary>
|
||||||
|
List<IActivatableComponent> Components { get; }
|
||||||
|
|
||||||
|
void ActivateComponents();
|
||||||
|
void DeactivateComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Describes an individual room behaviour component
|
||||||
|
/// </summary>
|
||||||
|
public interface IRoomBehaviourComponent : IActivatableComponent
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Describes a room device component behaviour
|
||||||
|
/// </summary>
|
||||||
|
public interface IDeviceBehaviourComponent<T> : IActivatableComponent where T : EssentialsDevice
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The device this component applies behaviour to
|
||||||
|
/// </summary>
|
||||||
|
T Device { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
<ProjectGuid>{A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5}</ProjectGuid>
|
<ProjectGuid>{A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5}</ProjectGuid>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>PepperDash_Essentials_Core</RootNamespace>
|
<RootNamespace>PepperDash.Essentials.Core</RootNamespace>
|
||||||
<AssemblyName>PepperDash_Essentials_Core</AssemblyName>
|
<AssemblyName>PepperDash_Essentials_Core</AssemblyName>
|
||||||
<ProjectTypeGuids>{0B4745B0-194B-4BB6-8E21-E9057CA92300};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
<ProjectTypeGuids>{0B4745B0-194B-4BB6-8E21-E9057CA92300};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
<PlatformFamilyName>WindowsCE</PlatformFamilyName>
|
<PlatformFamilyName>WindowsCE</PlatformFamilyName>
|
||||||
@@ -225,6 +225,7 @@
|
|||||||
<Compile Include="Gateways\CenRfgwController.cs" />
|
<Compile Include="Gateways\CenRfgwController.cs" />
|
||||||
<Compile Include="Gateways\EssentialsRfGatewayConfig.cs" />
|
<Compile Include="Gateways\EssentialsRfGatewayConfig.cs" />
|
||||||
<Compile Include="Global\EthernetAdapterInfo.cs" />
|
<Compile Include="Global\EthernetAdapterInfo.cs" />
|
||||||
|
<Compile Include="Interfaces\Components\RoomComponents.cs" />
|
||||||
<Compile Include="Interfaces\ILogStrings.cs" />
|
<Compile Include="Interfaces\ILogStrings.cs" />
|
||||||
<Compile Include="Interfaces\ILogStringsWithLevel.cs" />
|
<Compile Include="Interfaces\ILogStringsWithLevel.cs" />
|
||||||
<Compile Include="Queues\ComsMessage.cs" />
|
<Compile Include="Queues\ComsMessage.cs" />
|
||||||
@@ -281,10 +282,14 @@
|
|||||||
<Compile Include="Remotes\CrestronRemotePropertiesConfig.cs" />
|
<Compile Include="Remotes\CrestronRemotePropertiesConfig.cs" />
|
||||||
<Compile Include="Remotes\Hrxx0WirelessRemoteController.cs" />
|
<Compile Include="Remotes\Hrxx0WirelessRemoteController.cs" />
|
||||||
<Compile Include="Room\Behaviours\RoomOnToDefaultSourceWhenOccupied.cs" />
|
<Compile Include="Room\Behaviours\RoomOnToDefaultSourceWhenOccupied.cs" />
|
||||||
|
<Compile Include="Room\Components\ComponentFactory.cs" />
|
||||||
|
<Compile Include="Room\Components\ComponentRoom.cs" />
|
||||||
|
<Compile Include="Room\Components\RoomComponentBase.cs" />
|
||||||
<Compile Include="Room\EssentialsRoomBase.cs" />
|
<Compile Include="Room\EssentialsRoomBase.cs" />
|
||||||
<Compile Include="Room\Config\EssentialsRoomScheduledEventsConfig.cs" />
|
<Compile Include="Room\Config\EssentialsRoomScheduledEventsConfig.cs" />
|
||||||
<Compile Include="Room\Interfaces.cs" />
|
<Compile Include="Room\Interfaces.cs" />
|
||||||
<Compile Include="Room\iOccupancyStatusProvider.cs" />
|
<Compile Include="Room\iOccupancyStatusProvider.cs" />
|
||||||
|
<Compile Include="Room\RoomFactory.cs" />
|
||||||
<Compile Include="Routing\DummyRoutingInputsDevice.cs" />
|
<Compile Include="Routing\DummyRoutingInputsDevice.cs" />
|
||||||
<Compile Include="Routing\ICardPortsDevice.cs" />
|
<Compile Include="Routing\ICardPortsDevice.cs" />
|
||||||
<Compile Include="InUseTracking\IInUseTracking.cs" />
|
<Compile Include="InUseTracking\IInUseTracking.cs" />
|
||||||
|
|||||||
@@ -0,0 +1,194 @@
|
|||||||
|
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.Interfaces.Components;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.Room.Components
|
||||||
|
{
|
||||||
|
public class ComponentFactoryWrapper
|
||||||
|
{
|
||||||
|
public CType CType { get; set; }
|
||||||
|
public string Description { get; set; }
|
||||||
|
public Func<RoomComponentConfig, IComponentRoom, IKeyed> FactoryMethod { get; set; }
|
||||||
|
|
||||||
|
public ComponentFactoryWrapper()
|
||||||
|
{
|
||||||
|
CType = null;
|
||||||
|
Description = "Not Available";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Defines a class that is capable of loading component types
|
||||||
|
/// </summary>
|
||||||
|
public interface IComponentFactory : IDeviceFactory
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ComponentFactory
|
||||||
|
{
|
||||||
|
static ComponentFactory()
|
||||||
|
{
|
||||||
|
var assy = Assembly.GetExecutingAssembly();
|
||||||
|
PluginLoader.SetEssentialsAssembly(assy.GetName().Name, assy);
|
||||||
|
|
||||||
|
var types = assy.GetTypes().Where(ct => typeof(IComponentFactory).IsAssignableFrom(ct) && !ct.IsInterface && !ct.IsAbstract);
|
||||||
|
|
||||||
|
if (types != null)
|
||||||
|
{
|
||||||
|
foreach (var type in types)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var factory = (IComponentFactory)Crestron.SimplSharp.Reflection.Activator.CreateInstance(type);
|
||||||
|
factory.LoadTypeFactories();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to load type: '{1}' ComponentFactory: {0}", e, type.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, ComponentFactoryWrapper> FactoryMethods =
|
||||||
|
new Dictionary<string, ComponentFactoryWrapper>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a plugin factory method
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dc"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static void AddFactoryForType(string typeName, Func<RoomComponentConfig, IComponentRoom, IKeyed> method)
|
||||||
|
{
|
||||||
|
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Adding factory method for type '{0}'", typeName);
|
||||||
|
ComponentFactory.FactoryMethods.Add(typeName, new ComponentFactoryWrapper() { FactoryMethod = method });
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AddFactoryForType(string typeName, string description, CType cType, Func<RoomComponentConfig, IComponentRoom, IKeyed> method)
|
||||||
|
{
|
||||||
|
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Adding factory method for type '{0}'", typeName);
|
||||||
|
|
||||||
|
if (FactoryMethods.ContainsKey(typeName))
|
||||||
|
{
|
||||||
|
Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to add type: '{0}'. Already exists in ComponentFactory", typeName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var wrapper = new ComponentFactoryWrapper() { CType = cType, Description = description, FactoryMethod = method };
|
||||||
|
ComponentFactory.FactoryMethods.Add(typeName, wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The factory method for Core components. Also iterates the Factory methods that have
|
||||||
|
/// been loaded from plugins
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dc"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static IKeyed GetComponent(RoomComponentConfig dc, IComponentRoom parent)
|
||||||
|
{
|
||||||
|
var key = dc.Key;
|
||||||
|
var name = dc.Name;
|
||||||
|
var type = dc.Type;
|
||||||
|
var properties = dc.Properties;
|
||||||
|
|
||||||
|
var typeName = dc.Type.ToLower();
|
||||||
|
|
||||||
|
// Check for types that have been added by plugin dlls.
|
||||||
|
if (FactoryMethods.ContainsKey(typeName))
|
||||||
|
{
|
||||||
|
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading '{0}' from Essentials Core", dc.Type);
|
||||||
|
return FactoryMethods[typeName].FactoryMethod(dc, parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Prints the type names and associated metadata from the FactoryMethods collection.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="command"></param>
|
||||||
|
public static void GetComponentFactoryTypes(string filter)
|
||||||
|
{
|
||||||
|
Dictionary<string, ComponentFactoryWrapper> types = new Dictionary<string, ComponentFactoryWrapper>();
|
||||||
|
|
||||||
|
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, "Component Types:");
|
||||||
|
|
||||||
|
foreach (var type in types.OrderBy(t => t.Key))
|
||||||
|
{
|
||||||
|
var description = type.Value.Description;
|
||||||
|
var cType = "Not Specified by Plugin";
|
||||||
|
|
||||||
|
if (type.Value.CType != null)
|
||||||
|
{
|
||||||
|
cType = type.Value.CType.FullName;
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.Console(0,
|
||||||
|
@"Type: '{0}'
|
||||||
|
CType: '{1}'
|
||||||
|
Description: {2}", type.Key, cType, description);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Devices the basic needs for a Device Factory
|
||||||
|
/// </summary>
|
||||||
|
public abstract class EssentialsComponentFactory<T> : IComponentFactory where T : IComponent
|
||||||
|
{
|
||||||
|
#region IComponentFactory 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 ComponentFactory.FactoryMethods dictionary for each entry in the TypeNames list
|
||||||
|
/// </summary>
|
||||||
|
public void LoadTypeFactories()
|
||||||
|
{
|
||||||
|
foreach (var typeName in TypeNames)
|
||||||
|
{
|
||||||
|
Debug.Console(2, "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[];
|
||||||
|
ComponentFactory.AddFactoryForType(typeName.ToLower(), description, typeof(T), BuildComponent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <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 IComponent BuildComponent(RoomComponentConfig dc, IComponentRoom parent);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,163 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Crestron.SimplSharp;
|
||||||
|
|
||||||
|
using PepperDash.Core;
|
||||||
|
using PepperDash.Essentials.Core.Interfaces.Components;
|
||||||
|
using PepperDash.Essentials.Core.Room.Components;
|
||||||
|
using PepperDash.Essentials.Core.Config;
|
||||||
|
using PepperDash.Essentials.Core.Devices;
|
||||||
|
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.Room
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The base config class for various component types
|
||||||
|
/// </summary>
|
||||||
|
public abstract class RoomComponentConfig : DeviceConfig
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The config class for an activiry
|
||||||
|
/// </summary>
|
||||||
|
public class RoomActivityConfig : RoomComponentConfig
|
||||||
|
{
|
||||||
|
[JsonProperty("label")]
|
||||||
|
public string Label { get; set; }
|
||||||
|
[JsonProperty("icon")]
|
||||||
|
public string Icon { get; set; }
|
||||||
|
[JsonProperty("componentKey")]
|
||||||
|
public string ComponentKey { get; set; }
|
||||||
|
[JsonProperty("order")]
|
||||||
|
public int Order { get; set; }
|
||||||
|
[JsonProperty("selectAction")]
|
||||||
|
public DeviceActionWrapper SelectAction { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The config class for a room behaviour
|
||||||
|
/// </summary>
|
||||||
|
public class RoomBehaviourConfig : RoomComponentConfig
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The config class for a device behavior
|
||||||
|
/// </summary>
|
||||||
|
public class RoomDeviceBehaviourConfig : RoomComponentConfig
|
||||||
|
{
|
||||||
|
[JsonProperty("deviceKey")]
|
||||||
|
public string DeviceKey { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The config class for a ComponentRoom
|
||||||
|
/// </summary>
|
||||||
|
public class ComponentRoomPropertiesConfig
|
||||||
|
{
|
||||||
|
[JsonProperty("activities")]
|
||||||
|
public List<RoomActivityConfig> Activities { get; set; }
|
||||||
|
[JsonProperty("components")]
|
||||||
|
public List<RoomComponentConfig> Components { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A room comprised of component parts built at runtime.
|
||||||
|
/// </summary>
|
||||||
|
public class ComponentRoom : ReconfigurableDevice, IComponentRoom
|
||||||
|
{
|
||||||
|
public ComponentRoomPropertiesConfig PropertiesConfig { get; private set; }
|
||||||
|
|
||||||
|
public List<IActivatableComponent> Components { get; private set; }
|
||||||
|
public List<IRoomActivityComponent> Activities { get; private set; }
|
||||||
|
|
||||||
|
public ComponentRoom(DeviceConfig config)
|
||||||
|
: base(config)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PropertiesConfig = config.Properties.ToObject<ComponentRoomPropertiesConfig>();
|
||||||
|
|
||||||
|
BuildComponents();
|
||||||
|
|
||||||
|
BuildActivities();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.Console(1, this, "Error building ComponentRoom: \n{0}", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void BuildComponents()
|
||||||
|
{
|
||||||
|
foreach (var compConf in PropertiesConfig.Components)
|
||||||
|
{
|
||||||
|
IKeyed newComponent = null;
|
||||||
|
|
||||||
|
newComponent = ComponentFactory.GetComponent(compConf, this);
|
||||||
|
|
||||||
|
if (newComponent != null)
|
||||||
|
{
|
||||||
|
Components.Add(newComponent as IActivatableComponent);
|
||||||
|
DeviceManager.AddDevice(newComponent);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Unable to build room component with key: {0}", compConf.Key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void BuildActivities()
|
||||||
|
{
|
||||||
|
foreach (var compConf in PropertiesConfig.Activities)
|
||||||
|
{
|
||||||
|
IKeyed newComponent = null;
|
||||||
|
|
||||||
|
newComponent = ComponentFactory.GetComponent(compConf, this);
|
||||||
|
|
||||||
|
if (newComponent != null)
|
||||||
|
{
|
||||||
|
Activities.Add(newComponent as IRoomActivityComponent);
|
||||||
|
DeviceManager.AddDevice(newComponent);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Unable to build room activity with key: {0}", compConf.Key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a set of IRoomComponent that matches the specified Type
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<T> GetComponentsOfType<T>() where T : IActivatableComponent
|
||||||
|
{
|
||||||
|
return Components.OfType<T>().ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a list of the activies sorted by order
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<IRoomActivityComponent> GetOrderedActvities()
|
||||||
|
{
|
||||||
|
return Activities.OrderBy(a => a.Order).ToList<IRoomActivityComponent>();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Crestron.SimplSharp;
|
||||||
|
|
||||||
|
using PepperDash.Core;
|
||||||
|
using PepperDash.Essentials.Core.Config;
|
||||||
|
using PepperDash.Essentials.Core.Interfaces.Components;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.Room.Components
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The base class from which Room Components should be derived
|
||||||
|
/// </summary>
|
||||||
|
[Description("The base Essentials Device Class")]
|
||||||
|
public abstract class RoomComponentBase : IRoomComponent
|
||||||
|
{
|
||||||
|
private string _componentKey;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The key of the component, which is composed of the parent room key, plus the specific component key
|
||||||
|
/// </summary>
|
||||||
|
public string Key {
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Parent.Key + "-" + _componentKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IComponentRoom Parent { get; private set; }
|
||||||
|
|
||||||
|
public RoomComponentBase(string key, IComponentRoom parent)
|
||||||
|
{
|
||||||
|
_componentKey = key;
|
||||||
|
Parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The base class from which Room Activities should be derived
|
||||||
|
/// </summary>
|
||||||
|
public abstract class RoomActivityComponentBase : IRoomActivityComponent
|
||||||
|
{
|
||||||
|
|
||||||
|
#region IRoomActivityComponent Members
|
||||||
|
|
||||||
|
public BoolFeedback IsEnabledFeedback { get; private set; }
|
||||||
|
|
||||||
|
private bool _enable;
|
||||||
|
|
||||||
|
public bool Enable
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value != _enable)
|
||||||
|
{
|
||||||
|
_enable = value;
|
||||||
|
IsEnabledFeedback.FireUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Label { get; private set; }
|
||||||
|
|
||||||
|
public string Icon { get; private set; }
|
||||||
|
|
||||||
|
public IRoomBehaviourGroupComponent Component { get; private set; }
|
||||||
|
|
||||||
|
public int Order { get; private set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region IRoomComponent Members
|
||||||
|
|
||||||
|
public IComponentRoom Parent { get; private set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region IKeyed Members
|
||||||
|
|
||||||
|
private string _componentKey;
|
||||||
|
|
||||||
|
public string Key
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Parent.Key + "-" + _componentKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public RoomActivityComponentBase(string key, IComponentRoom parent)
|
||||||
|
{
|
||||||
|
_componentKey = key;
|
||||||
|
Parent = parent;
|
||||||
|
|
||||||
|
IsEnabledFeedback = new BoolFeedback(() => _enable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StartActivity()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EndActivity()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -12,45 +12,45 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
//***************************************************************************************************
|
//***************************************************************************************************
|
||||||
|
|
||||||
public abstract class Room : Device, IHasFeedback
|
// public abstract class Room : Device, IHasFeedback
|
||||||
{
|
// {
|
||||||
public abstract BoolFeedback RoomIsOnFeedback { get; protected set; }
|
// public abstract BoolFeedback RoomIsOnFeedback { get; protected set; }
|
||||||
public abstract BoolFeedback IsCoolingDownFeedback { get; protected set; }
|
// public abstract BoolFeedback IsCoolingDownFeedback { get; protected set; }
|
||||||
public abstract BoolFeedback IsWarmingUpFeedback { get; protected set; }
|
// public abstract BoolFeedback IsWarmingUpFeedback { get; protected set; }
|
||||||
|
|
||||||
// In concrete classes, these should be computed from the relevant devices
|
// // In concrete classes, these should be computed from the relevant devices
|
||||||
public virtual uint CooldownTime { get { return 10000; } }
|
// public virtual uint CooldownTime { get { return 10000; } }
|
||||||
public virtual uint WarmupTime { get { return 5000; } }
|
// public virtual uint WarmupTime { get { return 5000; } }
|
||||||
|
|
||||||
public string Description { get; set; }
|
// public string Description { get; set; }
|
||||||
public string HelpMessage { get; set; }
|
// public string HelpMessage { get; set; }
|
||||||
|
|
||||||
public Room(string key, string name)
|
// public Room(string key, string name)
|
||||||
: base(key, name)
|
// : base(key, name)
|
||||||
{
|
// {
|
||||||
Description = "";
|
// Description = "";
|
||||||
HelpMessage = "";
|
// HelpMessage = "";
|
||||||
}
|
// }
|
||||||
|
|
||||||
public virtual void RoomOn() { }
|
// public virtual void RoomOn() { }
|
||||||
|
|
||||||
public virtual void RoomOff() { }
|
// public virtual void RoomOff() { }
|
||||||
|
|
||||||
#region IDeviceWithOutputs Members
|
// #region IDeviceWithOutputs Members
|
||||||
|
|
||||||
public virtual FeedbackCollection<Feedback> Feedbacks
|
// public virtual FeedbackCollection<Feedback> Feedbacks
|
||||||
{
|
// {
|
||||||
get
|
// get
|
||||||
{
|
// {
|
||||||
return new FeedbackCollection<Feedback>
|
// return new FeedbackCollection<Feedback>
|
||||||
{
|
// {
|
||||||
RoomIsOnFeedback,
|
// RoomIsOnFeedback,
|
||||||
IsCoolingDownFeedback,
|
// IsCoolingDownFeedback,
|
||||||
IsWarmingUpFeedback
|
// IsWarmingUpFeedback
|
||||||
};
|
// };
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
#endregion
|
// #endregion
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Crestron.SimplSharp;
|
||||||
|
|
||||||
|
using PepperDash.Essentials.Core.Interfaces.Components;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.Room
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The class that constructs rooms
|
||||||
|
/// </summary>
|
||||||
|
public static class RoomFactory
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user