Compare commits

...

95 Commits
JTA ... 1.4.15

Author SHA1 Message Date
Neil Dorin
2c98fc4545 Merged in bugfix/ecs-1134 (pull request #22)
Switches to using input/output enpoint online feedback collections on chassis rather than IsOnline feedback from individual endpoints.

Approved-by: Neil Dorin <ndorin@pepperdash.com>
2019-07-25 16:13:35 +00:00
Neil Dorin
05c9dd3c69 Switches to using input/output enpoint online feedback collections on chassis rather than IsOnline feedback from individual endpoints. 2019-07-25 10:01:04 -06:00
Neil Dorin
5aed3c4480 Merged in bugfix/ecs-1131 (pull request #21)
Bugfix/ecs 1131

Approved-by: Neil Dorin <ndorin@pepperdash.com>
2019-07-18 20:16:48 +00:00
Neil Dorin
ddfd1d0586 Corrected case of dmTx to dmtx on dmtx200 2019-07-18 14:13:43 -06:00
Neil Dorin
77d5438063 Updates to script file 2019-07-12 11:37:16 -06:00
Neil Dorin
42a79f0e1e Merged in testing/jenkinsCI-1 (pull request #20)
Testing/jenkinsCI-1

Approved-by: Neil Dorin <ndorin@pepperdash.com>
2019-07-11 23:34:17 +00:00
Neil Dorin
f8a6ef8c41 Updated readme 2019-07-11 17:13:11 -06:00
Neil Dorin
af1489d511 reset revision number for assembly version to allow CI process to set it. 2019-07-11 16:35:36 -06:00
Neil Dorin
aa2b5b9ab4 Fixes double quotes in script 2019-07-11 12:26:56 -06:00
Neil Dorin
fd2fe8fa6e Comments out set-ExecutionPolicy RemoteSigned from script 2019-07-11 12:22:42 -06:00
Neil Dorin
15c6da43eb Adds PowerShell Script for updating assembly version number 2019-07-11 12:04:37 -06:00
Neil Dorin
6725266ad9 Set SGD files to copy to output directory 2019-07-10 12:01:11 -06:00
Neil Dorin
8f564a82d4 copies Crestron.SimplSharpPro.UI hint path from Essentials Core.csproj which works 2019-07-10 11:55:23 -06:00
Neil Dorin
6f6ff28784 Merged in maintenance/remove-essentials-framework-submodule (pull request #19)
Updates Assembly version to 1.4.12

Approved-by: Neil Dorin <ndorin@pepperdash.com>
2019-07-10 17:28:52 +00:00
Neil Dorin
0a0bfc018d Updates Assembly version to 1.4.12 2019-07-10 11:27:18 -06:00
Neil Dorin
bd5a69a83c Merged in maintenance/remove-essentials-framework-submodule (pull request #18)
Removes essentials-framework as a submodule and brings the files back into the main repo

Approved-by: Neil Dorin <ndorin@pepperdash.com>
2019-07-09 23:23:10 +00:00
Neil Dorin
48c6bb78bc Removes essentials-framework as a submodule and brings the files back into the main repo 2019-07-09 17:21:53 -06:00
Neil Dorin
2cd68d40dc Merged in feature/ecs-1123 (pull request #17)
Feature/ecs 1123

Approved-by: Neil Dorin <ndorin@pepperdash.com>
2019-07-09 22:53:53 +00:00
Neil Dorin
43281f0db6 Merge remote-tracking branch 'origin/bugfix/weil20190610' into feature/ecs-1123
# Conflicts:
#	PepperDashEssentials/ControlSystem.cs
#	PepperDashEssentials/Properties/AssemblyInfo.cs
2019-07-09 16:52:23 -06:00
Neil Dorin
fa141c6207 Merge remote-tracking branch 'origin/maintenance/KPMG' into feature/ecs-1123
# Conflicts:
#	PepperDashEssentials/Bridges/BridgeBase.cs
#	PepperDashEssentials/ControlSystem.cs
2019-07-09 16:49:37 -06:00
Neil Dorin
07d6fcef1c Merge branch 'feature/ecs-1079' into feature/ecs-1123 2019-07-09 16:38:51 -06:00
Neil Dorin
a5ea9bb1eb Merge branch 'feature/ecs-1120' into feature/ecs-1123 2019-07-09 16:38:09 -06:00
Neil Dorin
90c122d966 Committing framework submodule before removing submodule reference 2019-07-09 16:30:50 -06:00
Neil Dorin
634b07dc12 Adds AppleTvBridge. Untested so far. 2019-07-03 15:28:34 -06:00
Neil Dorin
699900518a Moved CrestronTouchpanelPropertiesConfig down to Essentials.Core so that the DgeController can use it from Essentials.DM. Modified EssentialsTouchpanelController to be able to use a dge100 as a panel. Added UiDeviceFactory condition to build dge100/dmdge200c 2019-06-30 10:58:11 -06:00
Neil Dorin
ea2d573ab3 Started on DgeController 2019-06-28 08:20:06 -06:00
Neil Dorin
5c923e66ec Adds necessary framework commit 2019-06-27 14:21:48 -06:00
Neil Dorin
7958c64e67 Adds support for AirMediaControllerBridge 2019-06-27 14:21:09 -06:00
Neil Dorin
410ffd2f19 Assembly Version incremented to 1.4.11. Fixes issues with DisplayControllerBridge join mapping. Adds volume controls and ensures all input selection joins start at joinstart + 10. 2019-06-26 12:56:53 -06:00
Neil Dorin
53e0599e2a Resolves ecs-1117. Tested at Einstein 2019-06-25 13:43:21 -06:00
Neil Dorin
af12a81c00 Updates DisplayControllerBridge to support BasicIrDisplay types, adds Samsung IR driver file, updates SetupFileSystem in ControlSystem.cs to build plugin folder 2019-06-24 15:16:20 -06:00
Jason T Alborough
2a9e7c81eb Merge branch 'JAG-Add_IBridge' into JTA/KPMG
# Conflicts:
#	essentials-framework
2019-06-24 15:51:58 -04:00
Neil Dorin
c15adea02e Updates assembly version to include bugfix for ecs-1115 2019-06-21 11:17:55 -06:00
Neil Dorin
935f2c4bf4 Increments Assembly version and includes bugfix to set DmChassisController.EnableAudioBreakaway.BoolValue to true. 2019-06-20 15:25:13 -06:00
Joshua Gutenplan
327a9a5f6b Update compile to include pdc feature/MultipleServerUpdates 2019-06-18 16:56:51 -07:00
Neil Dorin
b7ed1d8238 Updates Assembly version number to 1.4.7 2019-06-18 14:04:00 -06:00
Joshua Gutenplan
aff4e5a61f update core ref 2019-06-14 19:18:50 -07:00
Joshua Gutenplan
fe172098b9 updated core 2019-06-14 15:50:21 -07:00
Joshua Gutenplan
f2c2cd423d Remove the crestron invoke from the eisc change event. Not good as it could spool a lot of threads 2019-06-14 15:23:05 -07:00
Joshua Gutenplan
22722fca21 update core ref to add PDC-14 and 15 features for testing kpmg 2019-06-13 20:06:43 -07:00
Joshua Gutenplan
6efec400b8 add invoke to bridgeapieisc 2019-06-13 20:05:38 -07:00
Joshua Gutenplan
f82816729b DID Not commit separately but also made bridge eisc uo actions use a threadpool thread. Fix the load plugin to load dlls before calling the load plugin method. Also added capability to place a cplz and unzip and load. The crestron dlls will throw exceptions so catching them and printing to console if debug is enabled to hide the messages from log and user as they can look like a problem when they are not. IMPORTANT we may need to add some logic to deal with multiple cplz's unzipping as the files will auto overwrite. See JIRA ticket ECS-1113 2019-06-13 19:44:14 -07:00
Neil Dorin
1b599ff863 Updated Assembly version to 1.4.6 2019-06-11 22:10:46 -06:00
Neil Dorin
ae23e48fd0 Resolves issue with GenericRelay factory not returning device if portDeviceKey maps to a device that is not of type CrestronControlSystem 2019-06-11 22:09:20 -06:00
Neil Dorin
a8f1f77d48 Adds README.md with basic process instructions for repo maintenance cycle 2019-06-11 11:58:57 -06:00
Heath Volmer
68064c7194 Various fixes 2019-06-11 10:15:38 -06:00
Heath Volmer
3ceecd3fbe Modified volumes format; added config for VC cameras and recents 2019-06-10 11:59:09 -06:00
Heath Volmer
8585977f71 ECS-1108, ECS-1109. Added construction for endpoints on CPU3 chassis 2019-06-06 15:51:17 -06:00
Heath Volmer
288c9bb04c Added ALL 8x8 - 32x32 chassis varieties 2019-06-06 11:31:17 -06:00
Joshua Gutenplan
47fb805766 Added IBridge to make it easier to deal with calling the linkToApi method. Added as an else if in EiscApI to ensure backwards compatibility. 2019-05-28 19:25:18 -07:00
Neil Dorin
31b0683cdf Merged in feature/ecs-1079 (pull request #13)
Feature/ecs 1079

Approved-by: Neil Dorin <ndorin@pepperdash.com>
2019-05-23 22:21:11 +00:00
Neil Dorin
04194da31c Merge remote-tracking branch 'origin/development' into HEAD 2019-05-23 16:18:22 -06:00
Heath Volmer
09bdc49c15 Merged in feature/heath-shades (pull request #12)
esc-1103: Plugins - (heath shades)
2019-05-22 15:33:24 +00:00
Heath Volmer
e36b2b97d2 Merge fixup 2019-05-22 09:32:48 -06:00
Heath Volmer
d705525a45 Framework at development after merges 2019-05-22 09:27:17 -06:00
Heath Volmer
ecce6e2be9 Framework... 2019-05-21 15:26:43 -06:00
Heath Volmer
95c0f57000 Plugin loading! 2019-05-21 13:58:57 -06:00
Heath Volmer
697b9109a3 Modifications to plugin load and factories 2019-05-17 09:14:18 -06:00
Heath Volmer
727367c061 Changes for PoC plugin loading... 2019-05-16 17:29:38 -06:00
Heath Volmer
f26ff0b767 Merge branch 'feature/mob-506' into feature/heath-shades 2019-05-16 13:01:47 -06:00
Heath Volmer
44b72dcfe5 Volume control fix 2019-05-16 13:00:48 -06:00
Jason Alborough
937f3f3dc0 # ECS-1079_AddDisplayControlBridge
- Adds in the Essentials Framework commit which includes an required feature feature/ECS-1080 AddIsOnlineFBtoStatusMonitor
2019-05-03 16:05:36 -04:00
Jason Alborough
17bf6e3f0a # ECS-1079_AddDisplayControlBridge
- Adds DisplayController Eisc Bride for a TwoWayDispalyDevice
2019-05-03 12:51:12 -04:00
Neil Dorin
e7253b4acc Merged in bugfix/ecs-1062 (pull request #8)
Bugfix/ecs 1062

Approved-by: Neil Dorin <ndorin@pepperdash.com>
2019-04-02 22:19:37 +00:00
Neil Dorin
71a27027e7 Updates framework commit to development branch 2019-04-02 16:04:46 -06:00
Neil Dorin
2655b8f7b8 Resolves issue with HuddleVtc1Room adding Emergency device in CustomActivate() which would throw an exception in DeviceManager.ActivateAll() when attempting to iterate the modified devices dictionary 2019-04-02 15:58:12 -06:00
Neil Dorin
3adee8bc30 Resolves ecs-1042 2019-03-18 11:25:46 -06:00
Neil Dorin
e3a3a2cd2d Attempting to resolve exception in CotijaSystemController when SystemMonitor tries to notify AppServer of program start before WSClient is *really* connected. 2019-03-15 14:42:47 -06:00
Neil Dorin
6235b44d89 Updates to delete any existing archived configs during update process to prevent name conflicts 2019-03-15 12:16:01 -06:00
Neil Dorin
90bbd65fdc Add lastest essentials framework 2019-03-14 10:41:07 -06:00
Neil Dorin
43fd263ea1 Config Update Working 2019-03-13 16:33:51 -06:00
Neil Dorin
038e23289e Adds inital ConfigMessenger 2019-03-12 11:08:32 -06:00
Neil Dorin
2121456d50 Adds fake directory to MockVC with full features 2019-03-08 16:56:37 -07:00
Neil Dorin
3a99c3bb30 Adds PrefixDictionaryFolderItems method to add "[+] " prefix to folder names for MC. 2019-03-07 16:31:56 -07:00
Neil Dorin
52ac57c080 fixed vc directory browsing to properly sync between MC and Essentials UIs 2019-03-07 15:20:24 -07:00
Neil Dorin
84ee743ff5 Moved Directory browsing logic from VideoCodecUiDriver down to IHasDirectory Interface to sync better with VideoCodecBaseMessenger for MC 2019-03-06 16:33:00 -07:00
Neil Dorin
24fb74701a Working on moving codec browsing data from UI into codec class 2019-03-05 16:31:13 -07:00
Neil Dorin
1c9aa1eaf6 Moves setting program initialization value out of InitializeSystem() to SystemMonitorController class 2019-03-05 11:33:39 -07:00
Heath Volmer
7c88843f50 Changed one directory message path for mobile control 2019-03-05 10:08:04 -07:00
Heath Volmer
7a3ce5fcf1 Added interface to huddle room to enable volume controls 2019-03-04 11:56:55 -07:00
Neil Dorin
3049e5a041 Merge branch 'feature/ecs-963' into HEAD 2019-02-27 14:27:44 -07:00
Heath Volmer
59234274dc Source-none confirmed; camera selects and FB 2019-02-25 17:51:17 -07:00
Heath Volmer
120dae2e63 Changed SourceNone to Source-None 2019-02-25 12:08:35 -07:00
Heath Volmer
e4317825d3 Create 'none' source 2019-01-30 17:23:57 -07:00
Neil Dorin
bf6971a52d Adds ability to have configuration filenames with prefixes or suffixes. 2019-01-29 17:50:46 -07:00
Heath Volmer
ef0a8dd3b9 Don't know, screw this 2019-01-29 15:09:45 -07:00
Heath Volmer
ca42d744cf Directory browsing largely alive for Weil 2019-01-29 09:33:01 -07:00
Neil Dorin
ffa4de49e9 Changes default folder to user/programX. Will fail back to nvram/programX if found, otherwise if no default folder found, will create user/programX. 2019-01-28 16:18:06 -07:00
Heath Volmer
3c5c157a70 Framework-sub changes 2019-01-28 11:09:43 -07:00
Heath Volmer
8ef58359e7 Added directory browsing things for DDVC01 2019-01-26 15:54:24 -07:00
Heath Volmer
530e1ebcb8 Smash system monitor bug 2019-01-24 11:20:24 -07:00
Heath Volmer
8d03bef34f Added missing join constants in Ddvc01RoomBridge 2019-01-24 09:20:29 -07:00
Heath Volmer
a870418f96 Added Ddvc01VtcMessenger; added to bridge; basic functions and feedbacks 2019-01-22 12:00:50 -07:00
Jason Alborough
37e2dfd11f Merged in JTA and about 1000 other things! (pull request #5)
JTA
2019-01-21 18:20:55 +00:00
Heath Volmer
47675f12b4 Added CsmQmtdc2504CnController, incomplete 2018-11-26 09:03:23 -07:00
399 changed files with 57465 additions and 1310 deletions

3
.gitignore vendored
View File

@@ -20,4 +20,5 @@ obj/
[Rr]elease*/
_ReSharper*/
SIMPLSharpLogs/
*.projectinfo
*.projectinfo
essentials-framework/EssentialDMTestConfig/

3
.gitmodules vendored
View File

@@ -1,3 +0,0 @@
[submodule "essentials-framework"]
path = essentials-framework
url = https://bitbucket.org/Pepperdash_Products/essentials-framework.git

Binary file not shown.

View File

@@ -1,49 +1,49 @@
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PepperDashEssentials", ".\PepperDashEssentials\PepperDashEssentials.csproj", "{1BED5BA9-88C4-4365-9362-6F4B128071D3}"
ProjectSection(ProjectDependencies) = postProject
{892B761C-E479-44CE-BD74-243E9214AF13} = {892B761C-E479-44CE-BD74-243E9214AF13}
{9199CE8A-0C9F-4952-8672-3EED798B284F} = {9199CE8A-0C9F-4952-8672-3EED798B284F}
{A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} = {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PepperDash_Essentials_Core", ".\essentials-framework\Essentials Core\PepperDashEssentialsBase\PepperDash_Essentials_Core.csproj", "{A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Essentials Devices Common", ".\essentials-framework\Essentials Devices Common\Essentials Devices Common\Essentials Devices Common.csproj", "{892B761C-E479-44CE-BD74-243E9214AF13}"
ProjectSection(ProjectDependencies) = postProject
{A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} = {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Essentials_DM", ".\essentials-framework\Essentials DM\Essentials_DM\Essentials_DM.csproj", "{9199CE8A-0C9F-4952-8672-3EED798B284F}"
ProjectSection(ProjectDependencies) = postProject
{A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} = {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1BED5BA9-88C4-4365-9362-6F4B128071D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1BED5BA9-88C4-4365-9362-6F4B128071D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1BED5BA9-88C4-4365-9362-6F4B128071D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1BED5BA9-88C4-4365-9362-6F4B128071D3}.Release|Any CPU.Build.0 = Release|Any CPU
{A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5}.Release|Any CPU.Build.0 = Release|Any CPU
{892B761C-E479-44CE-BD74-243E9214AF13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{892B761C-E479-44CE-BD74-243E9214AF13}.Debug|Any CPU.Build.0 = Debug|Any CPU
{892B761C-E479-44CE-BD74-243E9214AF13}.Release|Any CPU.ActiveCfg = Release|Any CPU
{892B761C-E479-44CE-BD74-243E9214AF13}.Release|Any CPU.Build.0 = Release|Any CPU
{9199CE8A-0C9F-4952-8672-3EED798B284F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9199CE8A-0C9F-4952-8672-3EED798B284F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9199CE8A-0C9F-4952-8672-3EED798B284F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9199CE8A-0C9F-4952-8672-3EED798B284F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PepperDashEssentials", ".\PepperDashEssentials\PepperDashEssentials.csproj", "{1BED5BA9-88C4-4365-9362-6F4B128071D3}"
ProjectSection(ProjectDependencies) = postProject
{892B761C-E479-44CE-BD74-243E9214AF13} = {892B761C-E479-44CE-BD74-243E9214AF13}
{9199CE8A-0C9F-4952-8672-3EED798B284F} = {9199CE8A-0C9F-4952-8672-3EED798B284F}
{A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} = {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PepperDash_Essentials_Core", ".\essentials-framework\Essentials Core\PepperDashEssentialsBase\PepperDash_Essentials_Core.csproj", "{A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Essentials Devices Common", ".\essentials-framework\Essentials Devices Common\Essentials Devices Common\Essentials Devices Common.csproj", "{892B761C-E479-44CE-BD74-243E9214AF13}"
ProjectSection(ProjectDependencies) = postProject
{A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} = {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Essentials_DM", ".\essentials-framework\Essentials DM\Essentials_DM\Essentials_DM.csproj", "{9199CE8A-0C9F-4952-8672-3EED798B284F}"
ProjectSection(ProjectDependencies) = postProject
{A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5} = {A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1BED5BA9-88C4-4365-9362-6F4B128071D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1BED5BA9-88C4-4365-9362-6F4B128071D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1BED5BA9-88C4-4365-9362-6F4B128071D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1BED5BA9-88C4-4365-9362-6F4B128071D3}.Release|Any CPU.Build.0 = Release|Any CPU
{A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5}.Release|Any CPU.Build.0 = Release|Any CPU
{892B761C-E479-44CE-BD74-243E9214AF13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{892B761C-E479-44CE-BD74-243E9214AF13}.Debug|Any CPU.Build.0 = Debug|Any CPU
{892B761C-E479-44CE-BD74-243E9214AF13}.Release|Any CPU.ActiveCfg = Release|Any CPU
{892B761C-E479-44CE-BD74-243E9214AF13}.Release|Any CPU.Build.0 = Release|Any CPU
{9199CE8A-0C9F-4952-8672-3EED798B284F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9199CE8A-0C9F-4952-8672-3EED798B284F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9199CE8A-0C9F-4952-8672-3EED798B284F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9199CE8A-0C9F-4952-8672-3EED798B284F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -17,6 +17,7 @@ using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Room.Cotija;
using PepperDash.Essentials.AppServer.Messengers;
namespace PepperDash.Essentials
{
@@ -39,6 +40,8 @@ namespace PepperDash.Essentials
Dictionary<string, CTimer> PushedActions = new Dictionary<string, CTimer>();
public ConfigMessenger ConfigMessenger { get; private set; }
CTimer ServerHeartbeatCheckTimer;
long ServerHeartbeatInterval = 20000;
@@ -49,7 +52,7 @@ namespace PepperDash.Essentials
DateTime LastAckMessage;
string SystemUuid;
public string SystemUuid;
List<CotijaBridgeBase> RoomBridges = new List<CotijaBridgeBase>();
@@ -97,9 +100,15 @@ namespace PepperDash.Essentials
CrestronConsole.AddNewConsoleCommand(s => CleanUpWebsocketClient(), "mobiledisco",
"Disconnects websocket", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s => ParseStreamRx(s), "mobilesimulateaction", "Simulates a message from the server", ConsoleAccessLevelEnum.AccessOperator);
CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(CrestronEnvironment_EthernetEventHandler);
// Config Messenger
var cmKey = Key + "-config";
ConfigMessenger = new ConfigMessenger(cmKey, "/config");
ConfigMessenger.RegisterWithAppServer(this);
}
/// <summary>
@@ -138,7 +147,9 @@ namespace PepperDash.Essentials
/// <param name="programEventType"></param>
void CrestronEnvironment_ProgramStatusEventHandler(eProgramStatusEventType programEventType)
{
if (programEventType == eProgramStatusEventType.Stopping && WSClient.Connected)
if (programEventType == eProgramStatusEventType.Stopping
&& WSClient != null
&& WSClient.Connected)
{
CleanUpWebsocketClient();
}
@@ -315,10 +326,12 @@ namespace PepperDash.Essentials
CrestronConsole.ConsoleCommandResponse(@"Mobile Control Information:
Server address: {0}
System Name: {1}
System UUID: {2}
System User code: {3}
Connected?: {4}
Seconds Since Last Ack: {5}", url, name, SystemUuid,
System URL: {2}
System UUID: {3}
System User code: {4}
Connected?: {5}
Seconds Since Last Ack: {6}"
, url, name, ConfigReader.ConfigObject.SystemUrl, SystemUuid,
code, conn, secSinceLastAck.Seconds);
}
@@ -448,9 +461,9 @@ namespace PepperDash.Essentials
Debug.Console(1, this, "Socket send result error: {0}", result);
}
}
else if (!WSClient.Connected)
else if (WSClient == null)
{
Debug.Console(1, this, "Cannot send. Not connected {0}");
Debug.Console(1, this, "Cannot send. Not connected.");
}
}
@@ -666,13 +679,14 @@ namespace PepperDash.Essentials
if(string.IsNullOrEmpty(message))
return;
if (!message.Contains("/system/heartbeat"))
Debug.Console(1, this, "Message RX: {0}", message);
else
{
LastAckMessage = DateTime.Now;
//Debug.Console(1, this, "RX message contains /system/heartbeat");
}
if (!message.Contains("/system/heartbeat"))
{
Debug.Console(1, this, "Message RX: {0}", message);
}
else
{
LastAckMessage = DateTime.Now;
}
try
{
@@ -689,6 +703,11 @@ namespace PepperDash.Essentials
{
HandleHeartBeat(messageObj["content"]);
}
else if (type == "raw")
{
var wrapper = messageObj["content"].ToObject<DeviceActionWrapper>();
DeviceJsonApi.DoDeviceAction(wrapper);
}
else if (type == "close")
{
Debug.Console(1, this, "Received close message from server.");

View File

@@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
using PepperDash.Essentials.Core.Config;
namespace PepperDash.Essentials.AppServer.Messengers
{
/// <summary>
/// Handles interactions with the app server to update the config
/// </summary>
public class ConfigMessenger : MessengerBase
{
public ConfigMessenger(string key, string messagePath)
: base(key, messagePath)
{
ConfigUpdater.ConfigStatusChanged -= ConfigUpdater_ConfigStatusChanged;
ConfigUpdater.ConfigStatusChanged += new EventHandler<ConfigStatusEventArgs>(ConfigUpdater_ConfigStatusChanged);
}
void ConfigUpdater_ConfigStatusChanged(object sender, ConfigStatusEventArgs e)
{
PostUpdateStatus(e.UpdateStatus.ToString());
}
protected override void CustomRegisterWithAppServer(CotijaSystemController appServerController)
{
appServerController.AddAction(MessagePath + "/updateConfig", new Action<string>(s => GetConfigFile(s)));
}
/// <summary>
/// Generates or passes the URL to make the request to GET the config from a server
/// </summary>
/// <param name="url"></param>
void GetConfigFile(string url)
{
try
{
// Attempt to parse the URL
var parser = new Crestron.SimplSharp.Net.Http.UrlParser(url);
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Successfully parsed URL from AppServer message: {0}", parser.Url);
}
catch (Exception e)
{
// If unable to parse the URL, generate it from config data
Debug.Console(2, "Error parsing URL: {0}", e);
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Unable to parse URL from AppServer message. Generating URL from config data");
url = string.Format("http://{0}/api/system/{1}/config", AppServerController.Config.ServerUrl, AppServerController.SystemUuid);
}
ConfigUpdater.GetConfigFromServer(url);
}
/// <summary>
/// Posts a message with the current status of the config update
/// </summary>
/// <param name="status"></param>
void PostUpdateStatus(string status)
{
PostStatusMessage(new
{
updateStatus = status
});
}
}
}

View File

@@ -16,12 +16,34 @@ namespace PepperDash.Essentials.AppServer.Messengers
{
BasicTriList EISC;
const uint BDialHangup = 221;
/// <summary>
/// 221
/// </summary>
const uint BDialHangupOnHook = 221;
/// <summary>
/// 251
/// </summary>
const uint BIncomingAnswer = 251;
/// <summary>
/// 252
/// </summary>
const uint BIncomingReject = 252;
/// <summary>
/// 241
/// </summary>
const uint BSpeedDial1 = 241;
/// <summary>
/// 242
/// </summary>
const uint BSpeedDial2 = 242;
/// <summary>
/// 243
/// </summary>
const uint BSpeedDial3 = 243;
/// <summary>
/// 244
/// </summary>
const uint BSpeedDial4 = 244;
/// <summary>
@@ -46,7 +68,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
const uint SCallDirection = 222;
/// <summary>
///
/// 201-212 0-9*#
/// </summary>
Dictionary<string, uint> DTMFMap = new Dictionary<string, uint>
{
@@ -64,6 +86,9 @@ namespace PepperDash.Essentials.AppServer.Messengers
{ "#", 212 },
};
/// <summary>
///
/// </summary>
CodecActiveCallItem CurrentCallItem;
@@ -110,7 +135,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
{
CurrentCallItem.Status = (eCodecCallStatus)Enum.Parse(typeof(eCodecCallStatus), s, true);
//GetCurrentCallList();
SendCallsList();
SendFullStatus();
});
EISC.SetStringSigAction(SCurrentCallNumber, s =>
@@ -138,7 +163,8 @@ namespace PepperDash.Essentials.AppServer.Messengers
// Add straight pulse calls
Action<string, uint> addAction = (s, u) =>
AppServerController.AddAction(MessagePath + s, new Action(() => EISC.PulseBool(u, 100)));
addAction("/endCallById", BDialHangup);
addAction("/endCallById", BDialHangupOnHook);
addAction("/endAllCalls", BDialHangupOnHook);
addAction("/acceptById", BIncomingAnswer);
addAction("/rejectById", BIncomingReject);
addAction("/speedDial1", BSpeedDial1);
@@ -160,6 +186,9 @@ namespace PepperDash.Essentials.AppServer.Messengers
}));
}
/// <summary>
///
/// </summary>
void SendCallsList()
{
PostStatusMessage(new

View File

@@ -0,0 +1,623 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DeviceSupport;
using Crestron.SimplSharpPro.EthernetCommunication;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Devices.Common.Codec;
namespace PepperDash.Essentials.AppServer.Messengers
{
public class Ddvc01VtcMessenger : MessengerBase
{
BasicTriList EISC;
/********* Bools *********/
/// <summary>
/// 724
/// </summary>
const uint BDialHangup = 724;
/// <summary>
/// 750
/// </summary>
const uint BCallIncoming = 750;
/// <summary>
/// 751
/// </summary>
const uint BIncomingAnswer = 751;
/// <summary>
/// 752
/// </summary>
const uint BIncomingReject = 752;
/// <summary>
/// 741
/// </summary>
const uint BSpeedDial1 = 741;
/// <summary>
/// 742
/// </summary>
const uint BSpeedDial2 = 742;
/// <summary>
/// 743
/// </summary>
const uint BSpeedDial3 = 743;
/// <summary>
/// 744
/// </summary>
const uint BSpeedDial4 = 744;
/// <summary>
/// 800
/// </summary>
const uint BDirectorySearchBusy = 800;
/// <summary>
/// 801
/// </summary>
const uint BDirectoryLineSelected = 801;
/// <summary>
/// 801 when selected entry is a contact
/// </summary>
const uint BDirectoryEntryIsContact = 801;
/// <summary>
/// 802 To show/hide back button
/// </summary>
const uint BDirectoryIsRoot = 802;
/// <summary>
/// 803 Pulse from system to inform us when directory is ready
/// </summary>
const uint DDirectoryHasChanged = 803;
/// <summary>
/// 804
/// </summary>
const uint BDirectoryRoot = 804;
/// <summary>
/// 805
/// </summary>
const uint BDirectoryFolderBack = 805;
/// <summary>
/// 806
/// </summary>
const uint BDirectoryDialSelectedLine = 806;
/// <summary>
/// 811
/// </summary>
const uint BCameraControlUp = 811;
/// <summary>
/// 812
/// </summary>
const uint BCameraControlDown = 812;
/// <summary>
/// 813
/// </summary>
const uint BCameraControlLeft = 813;
/// <summary>
/// 814
/// </summary>
const uint BCameraControlRight = 814;
/// <summary>
/// 815
/// </summary>
const uint BCameraControlZoomIn = 815;
/// <summary>
/// 816
/// </summary>
const uint BCameraControlZoomOut = 816;
/// <summary>
/// 821 - 826
/// </summary>
const uint BCameraPresetStart = 821;
/// <summary>
/// 831
/// </summary>
const uint BCameraModeAuto = 831;
/// <summary>
/// 832
/// </summary>
const uint BCameraModeManual = 832;
/// <summary>
/// 833
/// </summary>
const uint BCameraModeOff = 833;
/// <summary>
/// 841
/// </summary>
const uint BCameraSelfView = 841;
/// <summary>
/// 842
/// </summary>
const uint BCameraLayout = 842;
/********* Ushorts *********/
/// <summary>
/// 760
/// </summary>
const uint UCameraNumberSelect = 760;
/// <summary>
/// 801
/// </summary>
const uint UDirectorySelectRow = 801;
/// <summary>
/// 801
/// </summary>
const uint UDirectoryRowCount = 801;
/********* Strings *********/
/// <summary>
/// 701
/// </summary>
const uint SCurrentDialString = 701;
/// <summary>
/// 702
/// </summary>
const uint SCurrentCallName = 702;
/// <summary>
/// 703
/// </summary>
const uint SCurrentCallNumber = 703;
/// <summary>
/// 731
/// </summary>
const uint SHookState = 731;
/// <summary>
/// 722
/// </summary>
const uint SCallDirection = 722;
/// <summary>
/// 751
/// </summary>
const uint SIncomingCallName = 751;
/// <summary>
/// 752
/// </summary>
const uint SIncomingCallNumber = 752;
/// <summary>
/// 800
/// </summary>
const uint SDirectorySearchString = 800;
/// <summary>
/// 801-1055
/// </summary>
const uint SDirectoryEntriesStart = 801;
/// <summary>
/// 1056
/// </summary>
const uint SDirectoryEntrySelectedName = 1056;
/// <summary>
/// 1057
/// </summary>
const uint SDirectoryEntrySelectedNumber = 1057;
/// <summary>
/// 1058
/// </summary>
const uint SDirectorySelectedFolderName = 1058;
/// <summary>
/// 701-712 0-9*#
/// </summary>
Dictionary<string, uint> DTMFMap = new Dictionary<string, uint>
{
{ "1", 701 },
{ "2", 702 },
{ "3", 703 },
{ "4", 704 },
{ "5", 705 },
{ "6", 706 },
{ "7", 707 },
{ "8", 708 },
{ "9", 709 },
{ "0", 710 },
{ "*", 711 },
{ "#", 712 },
};
CodecActiveCallItem CurrentCallItem;
CodecActiveCallItem IncomingCallItem;
ushort PreviousDirectoryLength = 0;
/// <summary>
///
/// </summary>
/// <param name="eisc"></param>
/// <param name="messagePath"></param>
public Ddvc01VtcMessenger(string key, BasicTriList eisc, string messagePath)
: base(key, messagePath)
{
EISC = eisc;
CurrentCallItem = new CodecActiveCallItem();
CurrentCallItem.Type = eCodecCallType.Video;
CurrentCallItem.Id = "-video-";
}
/// <summary>
///
/// </summary>
/// <param name="appServerController"></param>
protected override void CustomRegisterWithAppServer(CotijaSystemController appServerController)
{
var asc = appServerController;
EISC.SetStringSigAction(SHookState, s =>
{
CurrentCallItem.Status = (eCodecCallStatus)Enum.Parse(typeof(eCodecCallStatus), s, true);
PostFullStatus(); // SendCallsList();
});
EISC.SetStringSigAction(SCurrentCallNumber, s =>
{
CurrentCallItem.Number = s;
PostCallsList();
});
EISC.SetStringSigAction(SCurrentCallName, s =>
{
CurrentCallItem.Name = s;
PostCallsList();
});
EISC.SetStringSigAction(SCallDirection, s =>
{
CurrentCallItem.Direction = (eCodecCallDirection)Enum.Parse(typeof(eCodecCallDirection), s, true);
PostCallsList();
});
EISC.SetBoolSigAction(BCallIncoming, b =>
{
if (b)
{
var ica = new CodecActiveCallItem()
{
Direction = eCodecCallDirection.Incoming,
Id = "-video-incoming",
Name = EISC.GetString(SIncomingCallName),
Number = EISC.GetString(SIncomingCallNumber),
Status = eCodecCallStatus.Ringing,
Type = eCodecCallType.Video
};
IncomingCallItem = ica;
}
else
{
IncomingCallItem = null;
}
PostCallsList();
});
// Directory insanity
EISC.SetUShortSigAction(UDirectoryRowCount, u =>
{
// The length of the list comes in before the list does.
// Splice the sig change operation onto the last string sig that will be changing
// when the directory entries make it through.
if (PreviousDirectoryLength > 0)
{
EISC.ClearStringSigAction(SDirectoryEntriesStart + PreviousDirectoryLength - 1);
}
EISC.SetStringSigAction(SDirectoryEntriesStart + u - 1, s => PostDirectory());
PreviousDirectoryLength = u;
});
EISC.SetStringSigAction(SDirectoryEntrySelectedName, s =>
{
PostStatusMessage(new
{
directoryContactSelected = new
{
name = EISC.GetString(SDirectoryEntrySelectedName),
}
});
});
EISC.SetStringSigAction(SDirectoryEntrySelectedNumber, s =>
{
PostStatusMessage(new
{
directoryContactSelected = new
{
number = EISC.GetString(SDirectoryEntrySelectedNumber),
}
});
});
EISC.SetStringSigAction(SDirectorySelectedFolderName, s => PostStatusMessage(new
{
directorySelectedFolderName = EISC.GetString(SDirectorySelectedFolderName)
}));
EISC.SetSigTrueAction(BCameraModeAuto, () => PostCameraMode());
EISC.SetSigTrueAction(BCameraModeManual, () => PostCameraMode());
EISC.SetSigTrueAction(BCameraModeOff, () => PostCameraMode());
EISC.SetBoolSigAction(BCameraSelfView, b => PostStatusMessage(new
{
cameraSelfView = b
}));
EISC.SetUShortSigAction(UCameraNumberSelect, (u) => PostSelectedCamera());
// Add press and holds using helper action
Action<string, uint> addPHAction = (s, u) =>
AppServerController.AddAction(MessagePath + s, new PressAndHoldAction(b => EISC.SetBool(u, b)));
addPHAction("/cameraUp", BCameraControlUp);
addPHAction("/cameraDown", BCameraControlDown);
addPHAction("/cameraLeft", BCameraControlLeft);
addPHAction("/cameraRight", BCameraControlRight);
addPHAction("/cameraZoomIn", BCameraControlZoomIn);
addPHAction("/cameraZoomOut", BCameraControlZoomOut);
// Add straight pulse calls using helper action
Action<string, uint> addAction = (s, u) =>
AppServerController.AddAction(MessagePath + s, new Action(() => EISC.PulseBool(u, 100)));
addAction("/endCallById", BDialHangup);
addAction("/endAllCalls", BDialHangup);
addAction("/acceptById", BIncomingAnswer);
addAction("/rejectById", BIncomingReject);
addAction("/speedDial1", BSpeedDial1);
addAction("/speedDial2", BSpeedDial2);
addAction("/speedDial3", BSpeedDial3);
addAction("/speedDial4", BSpeedDial4);
addAction("/cameraModeAuto", BCameraModeAuto);
addAction("/cameraModeManual", BCameraModeManual);
addAction("/cameraModeOff", BCameraModeOff);
addAction("/cameraSelfView", BCameraSelfView);
addAction("/cameraLayout", BCameraLayout);
asc.AddAction("/cameraSelect", new Action<string>(SelectCamera));
// camera presets
for(uint i = 0; i < 6; i++)
{
addAction("/cameraPreset" + (i + 1), BCameraPresetStart + i);
}
asc.AddAction(MessagePath + "/isReady", new Action(PostIsReady));
// Get status
asc.AddAction(MessagePath + "/fullStatus", new Action(PostFullStatus));
// Dial on string
asc.AddAction(MessagePath + "/dial", new Action<string>(s =>
EISC.SetString(SCurrentDialString, s)));
// Pulse DTMF
asc.AddAction(MessagePath + "/dtmf", new Action<string>(s =>
{
if (DTMFMap.ContainsKey(s))
{
EISC.PulseBool(DTMFMap[s], 100);
}
}));
// Directory madness
asc.AddAction(MessagePath + "/directoryRoot", new Action(() => EISC.PulseBool(BDirectoryRoot)));
asc.AddAction(MessagePath + "/directoryBack", new Action(() => EISC.PulseBool(BDirectoryFolderBack)));
asc.AddAction(MessagePath + "/directoryById", new Action<string>(s =>
{
// the id should contain the line number to forward to simpl
try
{
var u = ushort.Parse(s);
EISC.SetUshort(UDirectorySelectRow, u);
EISC.PulseBool(BDirectoryLineSelected);
}
catch (Exception)
{
Debug.Console(1, this, Debug.ErrorLogLevel.Warning,
"/directoryById request contains non-numeric ID incompatible with DDVC bridge");
}
}));
asc.AddAction(MessagePath + "/directorySelectContact", new Action<string>(s =>
{
try
{
var u = ushort.Parse(s);
EISC.SetUshort(UDirectorySelectRow, u);
EISC.PulseBool(BDirectoryLineSelected);
}
catch
{
}
}));
asc.AddAction(MessagePath + "/directoryDialContact", new Action(() => {
EISC.PulseBool(BDirectoryDialSelectedLine);
}));
asc.AddAction(MessagePath + "/getDirectory", new Action(() =>
{
if (EISC.GetUshort(UDirectoryRowCount) > 0)
{
PostDirectory();
}
else
{
EISC.PulseBool(BDirectoryRoot);
}
}));
}
/// <summary>
///
/// </summary>
void PostFullStatus()
{
this.PostStatusMessage(new
{
calls = GetCurrentCallList(),
cameraMode = GetCameraMode(),
cameraSelfView = EISC.GetBool(BCameraSelfView),
currentCallString = EISC.GetString(SCurrentCallNumber),
currentDialString = EISC.GetString(SCurrentDialString),
directoryContactSelected = new
{
name = EISC.GetString(SDirectoryEntrySelectedName),
number = EISC.GetString(SDirectoryEntrySelectedNumber)
},
directorySelectedFolderName = EISC.GetString(SDirectorySelectedFolderName),
isInCall = EISC.GetString(SHookState) == "Connected",
hasDirectory = true,
hasDirectorySearch = false,
hasRecents = !EISC.BooleanOutput[502].BoolValue,
hasCameras = true,
showCamerasWhenNotInCall = EISC.BooleanOutput[503].BoolValue,
selectedCamera = GetSelectedCamera(),
});
}
/// <summary>
///
/// </summary>
void PostDirectory()
{
var u = EISC.GetUshort(UDirectoryRowCount);
var items = new List<object>();
for (uint i = 0; i < u; i++)
{
var name = EISC.GetString(SDirectoryEntriesStart + i);
var id = (i + 1).ToString();
// is folder or contact?
if (name.StartsWith("[+]"))
{
items.Add(new
{
folderId = id,
name = name
});
}
else
{
items.Add(new
{
contactId = id,
name = name
});
}
}
var directoryMessage = new
{
currentDirectory = new
{
isRootDirectory = EISC.GetBool(BDirectoryIsRoot),
directoryResults = items
}
};
PostStatusMessage(directoryMessage);
}
/// <summary>
///
/// </summary>
void PostCameraMode()
{
PostStatusMessage(new
{
cameraMode = GetCameraMode()
});
}
/// <summary>
///
/// </summary>
/// <param name="mode"></param>
string GetCameraMode()
{
string m;
if (EISC.GetBool(BCameraModeAuto)) m = "auto";
else if (EISC.GetBool(BCameraModeManual)) m = "manual";
else m = "off";
return m;
}
void PostSelectedCamera()
{
PostStatusMessage(new
{
selectedCamera = GetSelectedCamera()
});
}
/// <summary>
///
/// </summary>
string GetSelectedCamera()
{
var num = EISC.GetUshort(UCameraNumberSelect);
string m;
if (num == 100)
{
m = "cameraFar";
}
else
{
m = "camera" + num;
}
return m;
}
/// <summary>
///
/// </summary>
void PostIsReady()
{
PostStatusMessage(new
{
isReady = true
});
}
/// <summary>
///
/// </summary>
void PostCallsList()
{
PostStatusMessage(new
{
calls = GetCurrentCallList(),
});
}
/// <summary>
///
/// </summary>
/// <param name="s"></param>
void SelectCamera(string s)
{
var cam = s.Substring(6);
if (cam.ToLower() == "far")
{
EISC.SetUshort(UCameraNumberSelect, 100);
}
else
{
EISC.SetUshort(UCameraNumberSelect, UInt16.Parse(cam));
}
}
/// <summary>
/// Turns the
/// </summary>
/// <returns></returns>
List<CodecActiveCallItem> GetCurrentCallList()
{
var list = new List<CodecActiveCallItem>();
if (CurrentCallItem.Status != eCodecCallStatus.Disconnected)
{
list.Add(CurrentCallItem);
}
if (EISC.GetBool(BCallIncoming)) {
}
return list;
}
}
}

View File

@@ -40,8 +40,11 @@ namespace PepperDash.Essentials.AppServer.Messengers
/// <param name="e"></param>
void ProgramInfoChanged(object sender, ProgramInfoEventArgs e)
{
Debug.Console(1, "Posting Status Message: {0}", e.ProgramInfo.ToString());
PostStatusMessage(e.ProgramInfo);
if (e.ProgramInfo != null)
{
//Debug.Console(1, "Posting Status Message: {0}", e.ProgramInfo.ToString());
PostStatusMessage(e.ProgramInfo);
}
}
/// <summary>

View File

@@ -8,6 +8,7 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Essentials.Devices.Common.Codec;
using PepperDash.Essentials.Devices.Common.Cameras;
using PepperDash.Essentials.Devices.Common.VideoCodec;
namespace PepperDash.Essentials.AppServer.Messengers
@@ -40,6 +41,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
if (dirCodec != null)
{
dirCodec.DirectoryResultReturned += new EventHandler<DirectoryEventArgs>(dirCodec_DirectoryResultReturned);
}
var recCodec = codec as IHasCallHistory;
@@ -74,12 +76,73 @@ namespace PepperDash.Essentials.AppServer.Messengers
/// <param name="e"></param>
void dirCodec_DirectoryResultReturned(object sender, DirectoryEventArgs e)
{
PostStatusMessage(new
{
currentDirectory = e.Directory
});
SendDirectory((Codec as IHasDirectory).CurrentDirectoryResult, e.DirectoryIsOnRoot);
}
/// <summary>
/// Posts the current directory
/// </summary>
void SendDirectory(CodecDirectory directory, bool isRoot)
{
var dirCodec = Codec as IHasDirectory;
if (dirCodec != null)
{
var prefixedDirectoryResults = PrefixDirectoryFolderItems(directory);
var directoryMessage = new
{
currentDirectory = new
{
directoryResults = prefixedDirectoryResults,
isRootDirectory = isRoot
}
};
PostStatusMessage(directoryMessage);
}
}
/// <summary>
/// Iterates a directory object and prefixes any folder items with "[+] "
/// </summary>
/// <param name="directory"></param>
/// <returns></returns>
List<DirectoryItem> PrefixDirectoryFolderItems (CodecDirectory directory)
{
var tempDirectoryList = new List<DirectoryItem>();
if (directory.CurrentDirectoryResults.Count > 0)
{
foreach (var item in directory.CurrentDirectoryResults)
{
if (item is DirectoryFolder)
{
var newFolder = new DirectoryFolder();
newFolder = (DirectoryFolder)item.Clone();
string prefixName = "[+] " + newFolder.Name;
newFolder.Name = prefixName;
tempDirectoryList.Add(newFolder);
}
else
{
tempDirectoryList.Add(item);
}
}
}
//else
//{
// DirectoryItem noResults = new DirectoryItem() { Name = "No Results Found" };
// tempDirectoryList.Add(noResults);
//}
return tempDirectoryList;
}
/// <summary>
///
/// </summary>
@@ -122,10 +185,24 @@ namespace PepperDash.Essentials.AppServer.Messengers
if (call != null)
Codec.AcceptCall(call);
}));
appServerController.AddAction(MessagePath + "/directoryRoot", new Action(GetDirectoryRoot));
appServerController.AddAction(MessagePath + "/directoryById", new Action<string>(s => GetDirectory(s)));
appServerController.AddAction(MessagePath + "/directorySearch", new Action<string>(s => DirectorySearch(s)));
appServerController.AddAction(MessagePath + "/getCallHistory", new Action(GetCallHistory));
// Directory actions
var dirCodec = Codec as IHasDirectory;
if (dirCodec != null)
{
appServerController.AddAction(MessagePath + "/getDirectory", new Action(GetDirectoryRoot));
appServerController.AddAction(MessagePath + "/directoryById", new Action<string>(s => GetDirectory(s)));
appServerController.AddAction(MessagePath + "/directorySearch", new Action<string>(s => DirectorySearch(s)));
appServerController.AddAction(MessagePath + "/directoryBack", new Action(GetPreviousDirectory));
}
// History actions
var recCodec = Codec as IHasCallHistory;
if (recCodec != null)
{
appServerController.AddAction(MessagePath + "/getCallHistory", new Action(GetCallHistory));
}
appServerController.AddAction(MessagePath + "/privacyModeOn", new Action(Codec.PrivacyModeOn));
appServerController.AddAction(MessagePath + "/privacyModeOff", new Action(Codec.PrivacyModeOff));
appServerController.AddAction(MessagePath + "/privacyModeToggle", new Action(Codec.PrivacyModeToggle));
@@ -215,12 +292,28 @@ namespace PepperDash.Essentials.AppServer.Messengers
return;
}
PostStatusMessage(new
{
currentDirectory = dirCodec.DirectoryRoot
});
dirCodec.SetCurrentDirectoryToRoot();
//PostStatusMessage(new
//{
// currentDirectory = dirCodec.DirectoryRoot
//});
}
/// <summary>
/// Requests the parent folder contents
/// </summary>
void GetPreviousDirectory()
{
var dirCodec = Codec as IHasDirectory;
if (dirCodec == null)
{
return;
}
dirCodec.GetDirectoryParentFolderContents();
}
/// <summary>
/// Handler for codec changes
/// </summary>
@@ -271,8 +364,9 @@ namespace PepperDash.Essentials.AppServer.Messengers
},
showSelfViewByDefault = Codec.ShowSelfViewByDefault,
hasDirectory = Codec is IHasDirectory,
hasDirectorySearch = true,
hasRecents = Codec is IHasCallHistory,
hasCameras = Codec is IHasCameraControl
hasCameras = Codec is IHasCodecCameras
});
}
}

View File

@@ -27,6 +27,11 @@ namespace PepperDash.Essentials.Room.Cotija
/// </summary>
public const uint RoomIsOn = 301;
/// <summary>
/// 12
/// </summary>
public const uint PrivacyMute = 12;
/// <summary>
/// 41
/// </summary>
@@ -38,15 +43,15 @@ namespace PepperDash.Essentials.Room.Cotija
/// <summary>
/// 51
/// </summary>
public const uint ActivitySharePress = 51;
public const uint ActivityShare = 51;
/// <summary>
/// 52
/// </summary>
public const uint ActivityPhoneCallPress = 52;
public const uint ActivityPhoneCall = 52;
/// <summary>
/// 53
/// </summary>
public const uint ActivityVideoCallPress = 53;
public const uint ActivityVideoCall = 53;
/// <summary>
/// 1
@@ -56,7 +61,10 @@ namespace PepperDash.Essentials.Room.Cotija
/// 1
/// </summary>
public const uint MasterVolumeMuteToggle = 1;
/// <summary>
/// 1
/// </summary>
public const uint VolumeMutesJoinStart = 1;
/// <summary>
/// 61
/// </summary>
@@ -72,7 +80,7 @@ namespace PepperDash.Essentials.Room.Cotija
/// <summary>
/// 72
/// </summary>
public const uint SourceHasChanged = 72;
public const uint SourceHasChanged = 71;
/// <summary>
/// 261 - The start of the range of speed dial visibles
/// </summary>
@@ -81,6 +89,19 @@ namespace PepperDash.Essentials.Room.Cotija
/// 501
/// </summary>
public const uint ConfigIsReady = 501;
/// <summary>
/// 502
/// </summary>
public const uint HideVideoConfRecents = 502;
/// <summary>
/// 503
/// </summary>
public const uint ShowCameraWhenNotInCall = 503;
/// <summary>
/// 601
/// </summary>
public const uint SourceShareDisableStartJoin = 601;
}
public class UshortJoin
@@ -89,15 +110,26 @@ namespace PepperDash.Essentials.Room.Cotija
/// 1
/// </summary>
public const uint MasterVolumeLevel = 1;
/// <summary>
/// 1
/// </summary>
public const uint VolumeSlidersJoinStart = 1;
/// <summary>
/// 61
/// </summary>
public const uint ShutdownPromptDuration = 61;
/// <summary>
/// 101
/// </summary>
public const uint VolumeSliderCount = 101;
}
public class StringJoin
{
/// <summary>
/// 1
/// </summary>
public const uint VolumeSliderNamesJoinStart = 1;
/// <summary>
/// 71
/// </summary>
@@ -141,6 +173,38 @@ namespace PepperDash.Essentials.Room.Cotija
/// 402
/// </summary>
public const uint ServerUrl = 402;
/// <summary>
/// 512
/// </summary>
public const uint RoomSpeedDialNamesJoinStart = 512;
/// <summary>
/// 516
/// </summary>
public const uint RoomSpeedDialNumberssJoinStart = 516;
/// <summary>
/// 601
/// </summary>
public const uint SourceNameJoinStart = 601;
/// <summary>
/// 621
/// </summary>
public const uint SourceIconJoinStart = 621;
/// <summary>
/// 641
/// </summary>
public const uint SourceKeyJoinStart = 641;
/// <summary>
/// 661
/// </summary>
public const uint SourceTypeJoinStart = 661;
/// <summary>
/// 761
/// </summary>
public const uint CameraNearNameStart = 761;
/// <summary>
/// 770 - presence of this name on the input will cause the camera to be added
/// </summary>
public const uint CameraFarName = 770;
}
/// <summary>
@@ -166,6 +230,7 @@ namespace PepperDash.Essentials.Room.Cotija
CotijaDdvc01DeviceBridge SourceBridge;
Ddvc01AtcMessenger AtcMessenger;
Ddvc01VtcMessenger VtcMessenger;
/// <summary>
@@ -204,10 +269,14 @@ namespace PepperDash.Essentials.Room.Cotija
SetupFunctions();
SetupFeedbacks();
var key = this.Key + "-" + Parent.Key;
AtcMessenger = new Ddvc01AtcMessenger(key, EISC, "/device/audioCodec");
var atcKey = string.Format("atc-{0}-{1}", this.Key, Parent.Key);
AtcMessenger = new Ddvc01AtcMessenger(atcKey, EISC, "/device/audioCodec");
AtcMessenger.RegisterWithAppServer(Parent);
var vtcKey = string.Format("atc-{0}-{1}", this.Key, Parent.Key);
VtcMessenger = new Ddvc01VtcMessenger(vtcKey, EISC, "/device/videoCodec");
VtcMessenger.RegisterWithAppServer(Parent);
EISC.SigChange += EISC_SigChange;
EISC.OnlineStatusChange += (o, a) =>
{
@@ -251,7 +320,6 @@ namespace PepperDash.Essentials.Room.Cotija
/// </summary>
void SetupFunctions()
{
#warning need join numbers for these
Parent.AddAction(@"/room/room1/promptForCode", new Action(() => EISC.PulseBool(BoolJoin.PromptForCode)));
Parent.AddAction(@"/room/room1/clientJoined", new Action(() => EISC.PulseBool(BoolJoin.ClientJoined)));
@@ -264,16 +332,26 @@ namespace PepperDash.Essentials.Room.Cotija
}));
Parent.AddAction(@"/room/room1/defaultsource", new Action(() =>
EISC.PulseBool(BoolJoin.ActivitySharePress)));
Parent.AddAction(@"/room/room1/activityVideo", new Action(() =>
EISC.PulseBool(BoolJoin.ActivityVideoCallPress)));
EISC.PulseBool(BoolJoin.ActivityShare)));
Parent.AddAction(@"/room/room1/activityPhone", new Action(() =>
EISC.PulseBool(BoolJoin.ActivityPhoneCallPress)));
EISC.PulseBool(BoolJoin.ActivityPhoneCall)));
Parent.AddAction(@"/room/room1/activityVideo", new Action(() =>
EISC.PulseBool(BoolJoin.ActivityVideoCall)));
Parent.AddAction(@"/room/room1/volumes/master/level", new Action<ushort>(u =>
EISC.SetUshort(UshortJoin.MasterVolumeLevel, u)));
Parent.AddAction(@"/room/room1/volumes/master/muteToggle", new Action(() =>
EISC.PulseBool(BoolJoin.MasterVolumeIsMuted)));
Parent.AddAction(@"/room/room1/volumes/master/privacyMuteToggle", new Action(() =>
EISC.PulseBool(BoolJoin.PrivacyMute)));
for (uint i = 2; i <= 7; i++)
{
var index = i;
Parent.AddAction(string.Format(@"/room/room1/volumes/level-{0}/level", index), new Action<ushort>(u =>
EISC.SetUshort(index, u)));
Parent.AddAction(string.Format(@"/room/room1/volumes/level-{0}/muteToggle", index), new Action(() =>
EISC.PulseBool(index)));
}
Parent.AddAction(@"/room/room1/shutdownStart", new Action(() =>
EISC.PulseBool(BoolJoin.ShutdownStart)));
@@ -332,7 +410,6 @@ namespace PepperDash.Essentials.Room.Cotija
}
}
}));
EISC.SetBoolSigAction(BoolJoin.MasterVolumeIsMuted, b =>
PostStatusMessage(new
{
@@ -344,6 +421,48 @@ namespace PepperDash.Essentials.Room.Cotija
}
}
}));
EISC.SetBoolSigAction(BoolJoin.PrivacyMute, b =>
PostStatusMessage(new
{
volumes = new
{
master = new
{
privacyMuted = b
}
}
}));
for (uint i = 2; i <= 7; i++)
{
var index = i; // local scope for lambdas
EISC.SetUShortSigAction(index, u => // start at join 2
{
// need a dict in order to create the level-n property on auxFaders
var dict = new Dictionary<string, object>();
dict.Add("level-" + index, new { level = u });
PostStatusMessage(new
{
volumes = new
{
auxFaders = dict,
}
});
});
EISC.SetBoolSigAction(index, b =>
{
// need a dict in order to create the level-n property on auxFaders
var dict = new Dictionary<string, object>();
dict.Add("level-" + index, new { muted = b });
PostStatusMessage(new
{
volumes = new
{
auxFaders = dict,
}
});
});
}
// shutdown things
@@ -366,6 +485,23 @@ namespace PepperDash.Essentials.Room.Cotija
// Config things
EISC.SetSigTrueAction(BoolJoin.ConfigIsReady, LoadConfigValues);
// Activity modes
EISC.SetSigTrueAction(BoolJoin.ActivityShare, () => UpdateActivity(1));
EISC.SetSigTrueAction(BoolJoin.ActivityPhoneCall, () => UpdateActivity(2));
EISC.SetSigTrueAction(BoolJoin.ActivityVideoCall, () => UpdateActivity(3));
}
/// <summary>
/// Updates activity states
/// </summary>
void UpdateActivity(int mode)
{
PostStatusMessage(new
{
activityMode = mode,
});
}
/// <summary>
@@ -397,7 +533,7 @@ namespace PepperDash.Essentials.Room.Cotija
Debug.Console(0, this, "Replacing Room[0] in config");
co.Rooms[0] = rm;
}
rm.Name = EISC.StringOutput[501].StringValue;
rm.Name = EISC.StringOutput[StringJoin.ConfigRoomName].StringValue;
rm.Key = "room1";
rm.Type = "ddvc01";
@@ -408,30 +544,21 @@ namespace PepperDash.Essentials.Room.Cotija
rmProps = JsonConvert.DeserializeObject<DDVC01RoomPropertiesConfig>(rm.Properties.ToString());
rmProps.Help = new EssentialsHelpPropertiesConfig();
rmProps.Help.CallButtonText = EISC.StringOutput[503].StringValue;
rmProps.Help.Message = EISC.StringOutput[502].StringValue;
rmProps.Help.CallButtonText = EISC.StringOutput[StringJoin.ConfigHelpNumber].StringValue;
rmProps.Help.Message = EISC.StringOutput[StringJoin.ConfigHelpMessage].StringValue;
rmProps.Environment = new EssentialsEnvironmentPropertiesConfig(); // enabled defaults to false
rmProps.RoomPhoneNumber = EISC.StringOutput[504].StringValue;
rmProps.RoomURI = EISC.StringOutput[505].StringValue;
rmProps.RoomPhoneNumber = EISC.StringOutput[StringJoin.ConfigRoomPhoneNumber].StringValue;
rmProps.RoomURI = EISC.StringOutput[StringJoin.ConfigRoomURI].StringValue;
rmProps.SpeedDials = new List<DDVC01SpeedDial>();
// add speed dials as long as there are more - up to 4
for (uint i = 512; i <= 519; i = i + 2)
{
var num = EISC.StringOutput[i].StringValue;
if (string.IsNullOrEmpty(num))
break;
var name = EISC.StringOutput[i + 1].StringValue;
rmProps.SpeedDials.Add(new DDVC01SpeedDial { Number = num, Name = name});
}
// This MAY need a check
rmProps.AudioCodecKey = "audioCodec";
rmProps.VideoCodecKey = null; // "videoCodec";
rmProps.VideoCodecKey = "videoCodec";
// volume control names
var volCount = EISC.UShortOutput[701].UShortValue;
var volCount = EISC.UShortOutput[UshortJoin.VolumeSliderCount].UShortValue;
//// use Volumes object or?
//rmProps.VolumeSliderNames = new List<string>();
@@ -459,24 +586,39 @@ namespace PepperDash.Essentials.Room.Cotija
co.SourceLists = new Dictionary<string,Dictionary<string,SourceListItem>>();
var newSl = new Dictionary<string, SourceListItem>();
// add sources...
for (uint i = 0; i<= 19; i++)
// add "none" source if VTC present
if (!string.IsNullOrEmpty(rmProps.VideoCodecKey))
{
var name = EISC.StringOutput[601 + i].StringValue;
var codecOsd = new SourceListItem()
{
Name = "None",
IncludeInSourceList = true,
Order = 1,
Type = eSourceListItemType.Route,
SourceKey = ""
};
newSl.Add("Source-None", codecOsd);
}
// add sources...
for (uint i = 0; i <= 19; i++)
{
var name = EISC.StringOutput[StringJoin.SourceNameJoinStart + i].StringValue;
if(string.IsNullOrEmpty(name))
break;
var icon = EISC.StringOutput[651 + i].StringValue;
var key = EISC.StringOutput[671 + i].StringValue;
var type = EISC.StringOutput[701 + i].StringValue;
var icon = EISC.StringOutput[StringJoin.SourceIconJoinStart + i].StringValue;
var key = EISC.StringOutput[StringJoin.SourceKeyJoinStart + i].StringValue;
var type = EISC.StringOutput[StringJoin.SourceTypeJoinStart + i].StringValue;
var disableShare = EISC.BooleanOutput[BoolJoin.SourceShareDisableStartJoin + i].BoolValue;
Debug.Console(0, this, "Adding source {0} '{1}'", key, name);
var newSLI = new SourceListItem{
Icon = icon,
Name = name,
Order = (int)i + 1,
Order = (int)i + 10,
SourceKey = key,
Type = eSourceListItemType.Route
Type = eSourceListItemType.Route,
DisableCodecSharing = disableShare,
};
newSl.Add(key, newSLI);
@@ -503,7 +645,7 @@ namespace PepperDash.Essentials.Room.Cotija
co.SourceLists.Add("default", newSl);
// build "audioCodec" config if we need
// Build "audioCodec" config if we need
if (!string.IsNullOrEmpty(rmProps.AudioCodecKey))
{
var acFavs = new List<PepperDash.Essentials.Devices.Common.Codec.CodecActiveCallItem>();
@@ -536,7 +678,54 @@ namespace PepperDash.Essentials.Room.Cotija
Properties = JToken.FromObject(acProps)
};
co.Devices.Add(acConf);
}
}
// Build Video codec config
if (!string.IsNullOrEmpty(rmProps.VideoCodecKey))
{
// No favorites, for now?
var favs = new List<PepperDash.Essentials.Devices.Common.Codec.CodecActiveCallItem>();
// cameras
var camsProps = new List<object>();
for (uint i = 0; i < 9; i++)
{
var name = EISC.GetString(i + StringJoin.CameraNearNameStart);
if (!string.IsNullOrEmpty(name))
{
camsProps.Add(new
{
name = name,
selector = "camera" + (i + 1),
});
}
}
var farName = EISC.GetString(StringJoin.CameraFarName);
if (!string.IsNullOrEmpty(farName))
{
camsProps.Add(new
{
name = farName,
selector = "cameraFar",
});
}
var props = new
{
favorites = favs,
cameras = camsProps,
};
var str = "videoCodec";
var conf = new DeviceConfig()
{
Group = str,
Key = str,
Name = str,
Type = str,
Properties = JToken.FromObject(props)
};
co.Devices.Add(conf);
}
Debug.Console(0, this, "******* CONFIG FROM DDVC: \r{0}", JsonConvert.SerializeObject(ConfigReader.ConfigObject, Formatting.Indented));
@@ -556,39 +745,41 @@ namespace PepperDash.Essentials.Room.Cotija
{
if (ConfigIsLoaded)
{
var count = EISC.UShortOutput[801].UShortValue;
var count = EISC.UShortOutput[101].UShortValue;
Debug.Console(1, this, "The Fader Count is : {0}", count);
// build volumes object, serialize and put in content of method below
var auxFaders = new List<Volume>();
// Create auxFaders
for (uint i = 2; i <= count; i++)
{
auxFaders.Add(
new Volume(string.Format("level-{0}", i),
EISC.UShortOutput[i].UShortValue,
EISC.BooleanOutput[i].BoolValue,
EISC.StringOutput[800 + i].StringValue,
true,
"someting.png"));
}
var auxFaderDict = new Dictionary<string, Volume>();
for (uint i = 2; i <= count; i++)
{
auxFaderDict.Add("level-" + i,
new Volume("level-" + i,
EISC.UShortOutput[i].UShortValue,
EISC.BooleanOutput[i].BoolValue,
EISC.StringOutput[i].StringValue,
true,
"someting.png"));
}
var volumes = new Volumes();
volumes.Master = new Volume("master",
EISC.UShortOutput[UshortJoin.MasterVolumeLevel].UShortValue,
EISC.BooleanOutput[BoolJoin.MasterVolumeIsMuted].BoolValue,
EISC.StringOutput[801].StringValue,
EISC.StringOutput[1].StringValue,
true,
"something.png");
volumes.Master.HasPrivacyMute = true;
volumes.Master.PrivacyMuted = EISC.BooleanOutput[BoolJoin.PrivacyMute].BoolValue;
volumes.AuxFaders = auxFaders;
volumes.AuxFaders = auxFaderDict;
PostStatusMessage(new
{
activityMode = GetActivityMode(),
isOn = EISC.BooleanOutput[BoolJoin.RoomIsOn].BoolValue,
selectedSourceKey = EISC.StringOutput[StringJoin.SelectedSourceKey].StringValue,
volumes = volumes
@@ -603,6 +794,18 @@ namespace PepperDash.Essentials.Room.Cotija
}
}
/// <summary>
/// Returns the activity mode int
/// </summary>
/// <returns></returns>
int GetActivityMode()
{
if (EISC.BooleanOutput[BoolJoin.ActivityPhoneCall].BoolValue) return 2;
else if (EISC.BooleanOutput[BoolJoin.ActivityShare].BoolValue) return 1;
else if (EISC.BooleanOutput[BoolJoin.ActivityVideoCall].BoolValue) return 3;
return 0;
}
/// <summary>
/// Helper for posting status message
/// </summary>

View File

@@ -25,6 +25,7 @@ namespace PepperDash.Essentials
public AudioCodecBaseMessenger ACMessenger { get; private set; }
/// <summary>
///
/// </summary>
@@ -416,7 +417,7 @@ namespace PepperDash.Essentials
if (rmVc != null)
{
var vc = rmVc.CurrentVolumeControls as IBasicVolumeWithFeedback;
if (rmVc != null)
if (vc != null)
{
volumes.Master = new Volume("master", vc.VolumeLevelFeedback.UShortValue, vc.MuteFeedback.BoolValue, "Volume", true, "");
}

View File

@@ -14,11 +14,11 @@ namespace PepperDash.Essentials.Room.Cotija
public Volume Master { get; set; }
[JsonProperty("auxFaders")]
public List<Volume> AuxFaders { get; set; }
public Dictionary<string, Volume> AuxFaders { get; set; }
public Volumes()
{
AuxFaders = new List<Volume>();
AuxFaders = new Dictionary<string, Volume>();
}
}
@@ -39,6 +39,13 @@ namespace PepperDash.Essentials.Room.Cotija
[JsonProperty("hasMute")]
public bool HasMute { get; set; }
[JsonProperty("hasPrivacyMute")]
public bool HasPrivacyMute { get; set; }
[JsonProperty("privacyMuted")]
public bool PrivacyMuted { get; set; }
[JsonProperty("muteIcon")]
public string MuteIcon { get; set; }

View File

@@ -0,0 +1,122 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Devices.Common;
using PepperDash.Essentials.DM.AirMedia;
namespace PepperDash.Essentials.Bridges
{
public static class AirMediaControllerApiExtensions
{
public static void LinkToApi(this AirMediaController airMedia, BasicTriList trilist, uint joinStart, string joinMapKey)
{
var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as AirMediaControllerJoinMap;
if (joinMap == null)
{
joinMap = new AirMediaControllerJoinMap();
}
joinMap.OffsetJoinNumbers(joinStart);
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
Debug.Console(0, "Linking to Bridge Type {0}", airMedia.GetType().Name.ToString());
trilist.StringInput[joinMap.Name].StringValue = airMedia.GetType().Name.ToString();
var commMonitor = airMedia as ICommunicationMonitor;
if (commMonitor != null)
{
commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]);
}
airMedia.IsInSessionFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsInSession]);
airMedia.HdmiVideoSyncDetectedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.HdmiVideoSync]);
trilist.SetSigTrueAction(joinMap.AutomaticInputRoutingEnabled, new Action( airMedia.AirMedia.DisplayControl.EnableAutomaticRouting));
trilist.SetSigFalseAction(joinMap.AutomaticInputRoutingEnabled, new Action( airMedia.AirMedia.DisplayControl.DisableAutomaticRouting));
airMedia.AutomaticInputRoutingEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.AutomaticInputRoutingEnabled]);
trilist.SetUShortSigAction(joinMap.VideoOut, new Action<ushort>((u) => airMedia.SelectVideoOut(u)));
airMedia.VideoOutFeedback.LinkInputSig(trilist.UShortInput[joinMap.VideoOut]);
airMedia.ErrorFeedback.LinkInputSig(trilist.UShortInput[joinMap.ErrorFB]);
airMedia.NumberOfUsersConnectedFeedback.LinkInputSig(trilist.UShortInput[joinMap.NumberOfUsersConnectedFB]);
trilist.SetUShortSigAction(joinMap.LoginCode, new Action<ushort>((u) => airMedia.AirMedia.AirMedia.LoginCode.UShortValue = u));
airMedia.LoginCodeFeedback.LinkInputSig(trilist.UShortInput[joinMap.LoginCode]);
airMedia.ConnectionAddressFeedback.LinkInputSig(trilist.StringInput[joinMap.ConnectionAddressFB]);
airMedia.HostnameFeedback.LinkInputSig(trilist.StringInput[joinMap.HostnameFB]);
airMedia.SerialNumberFeedback.LinkInputSig(trilist.StringInput[joinMap.SerialNumberFeedback]);
}
}
public class AirMediaControllerJoinMap : JoinMapBase
{
// Digital
public uint IsOnline { get; set; }
public uint IsInSession { get; set; }
public uint HdmiVideoSync { get; set; }
public uint AutomaticInputRoutingEnabled { get; set; }
// Analog
public uint VideoOut { get; set; }
public uint ErrorFB { get; set; }
public uint NumberOfUsersConnectedFB { get; set; }
public uint LoginCode { get; set; }
// Serial
public uint Name { get; set; }
public uint ConnectionAddressFB { get; set; }
public uint HostnameFB { get; set; }
public uint SerialNumberFeedback { get; set; }
public AirMediaControllerJoinMap()
{
// Digital
IsOnline = 1;
IsInSession = 2;
HdmiVideoSync = 3;
AutomaticInputRoutingEnabled = 4;
// Analog
VideoOut = 1;
ErrorFB = 2;
NumberOfUsersConnectedFB = 3;
LoginCode = 4;
// Serial
Name = 1;
ConnectionAddressFB = 2;
HostnameFB = 3;
SerialNumberFeedback = 4;
}
public override void OffsetJoinNumbers(uint joinStart)
{
var joinOffset = joinStart - 1;
IsOnline = IsOnline + joinOffset;
IsInSession = IsInSession + joinOffset;
HdmiVideoSync = HdmiVideoSync + joinOffset;
AutomaticInputRoutingEnabled = AutomaticInputRoutingEnabled + joinOffset;
VideoOut = VideoOut + joinOffset;
ErrorFB = ErrorFB + joinOffset;
NumberOfUsersConnectedFB = NumberOfUsersConnectedFB + joinOffset;
LoginCode = LoginCode + joinOffset;
Name = Name + joinOffset;
ConnectionAddressFB = ConnectionAddressFB + joinOffset;
HostnameFB = HostnameFB + joinOffset;
SerialNumberFeedback = SerialNumberFeedback + joinOffset;
}
}
}

View File

@@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Devices.Common;
namespace PepperDash.Essentials.Bridges
{
public static class AppleTvApiExtensions
{
public static void LinkToApi(this AppleTV appleTv, BasicTriList trilist, uint joinStart, string joinMapKey)
{
var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as AppleTvJoinMap;
if (joinMap == null)
{
joinMap = new AppleTvJoinMap();
}
joinMap.OffsetJoinNumbers(joinStart);
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
Debug.Console(0, "Linking to Bridge Type {0}", appleTv.GetType().Name.ToString());
trilist.SetBoolSigAction(joinMap.UpArrow, (b) => appleTv.Up(b));
trilist.SetBoolSigAction(joinMap.DnArrow, (b) => appleTv.Down(b));
trilist.SetBoolSigAction(joinMap.LeftArrow, (b) => appleTv.Left(b));
trilist.SetBoolSigAction(joinMap.RightArrow, (b) => appleTv.Right(b));
trilist.SetBoolSigAction(joinMap.Select, (b) => appleTv.Select(b));
trilist.SetBoolSigAction(joinMap.Menu, (b) => appleTv.Menu(b));
trilist.SetBoolSigAction(joinMap.PlayPause, (b) => appleTv.Play(b));
}
}
public class AppleTvJoinMap : JoinMapBase
{
// Digital
public uint UpArrow { get; set; }
public uint DnArrow { get; set; }
public uint LeftArrow { get; set; }
public uint RightArrow { get; set; }
public uint Menu { get; set; }
public uint Select { get; set; }
public uint PlayPause { get; set; }
public AppleTvJoinMap()
{
UpArrow = 1;
DnArrow = 2;
LeftArrow = 3;
RightArrow = 4;
Menu = 5;
Select = 6;
PlayPause = 7;
}
public override void OffsetJoinNumbers(uint joinStart)
{
var joinOffset = joinStart - 1;
UpArrow = UpArrow + joinOffset;
DnArrow = DnArrow + joinOffset;
LeftArrow = LeftArrow + joinOffset;
RightArrow = RightArrow + joinOffset;
Menu = Menu + joinOffset;
Select = Select + joinOffset;
PlayPause = PlayPause + joinOffset;
}
}
}

View File

@@ -15,7 +15,7 @@ using PepperDash.Essentials.Devices.Common;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.CrestronIO;
using PepperDash.Essentials.DM;
using PepperDash.Essentials.Devices.Common.Cameras;
//using PepperDash.Essentials.Devices.Common.Cameras;
namespace PepperDash.Essentials.Bridges
{
@@ -56,7 +56,6 @@ namespace PepperDash.Essentials.Bridges
public ThreeSeriesTcpIpEthernetIntersystemCommunications Eisc { get; private set; }
public EiscApi(DeviceConfig dc) :
base(dc.Key)
{
@@ -88,14 +87,14 @@ namespace PepperDash.Essentials.Bridges
(device as GenericComm).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is CameraBase)
//else if (device is CameraBase)
//{
// (device as CameraBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
// continue;
//}
else if (device is PepperDash.Essentials.Core.DisplayBase)
{
(device as CameraBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is PepperDash.Essentials.Core.TwoWayDisplayBase)
{
(device as TwoWayDisplayBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
(device as DisplayBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is DmChassisController)
@@ -124,16 +123,26 @@ namespace PepperDash.Essentials.Bridges
(device as IDigitalInput).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is LightingBase)
{
(device as LightingBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is DigitalLogger)
{
(device as DigitalLogger).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is AppleTV)
{
(device as AppleTV).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is IBridge)
{
(device as IBridge).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
//else if (device is LightingBase)
//{
// (device as LightingBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
// continue;
//}
//else if (device is DigitalLogger)
//{
// (device as DigitalLogger).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
// continue;
//}
}
}
@@ -141,6 +150,66 @@ namespace PepperDash.Essentials.Bridges
});
}
/// <summary>
/// Used for debugging to trigger an action based on a join number and type
/// </summary>
/// <param name="join"></param>
/// <param name="type"></param>
public void ExecuteJoinAction(uint join, string type, object state)
{
try
{
switch (type.ToLower())
{
case "digital":
{
var uo = Eisc.BooleanOutput[join].UserObject as Action<bool>;
if (uo != null)
{
Debug.Console(1, this, "Executing Action: {0}", uo.ToString());
uo(Convert.ToBoolean(state));
}
else
Debug.Console(1, this, "User Action is null. Nothing to Execute");
break;
}
case "analog":
{
var uo = Eisc.BooleanOutput[join].UserObject as Action<ushort>;
if (uo != null)
{
Debug.Console(1, this, "Executing Action: {0}", uo.ToString());
uo(Convert.ToUInt16(state));
}
else
Debug.Console(1, this, "User Action is null. Nothing to Execute"); break;
}
case "serial":
{
var uo = Eisc.BooleanOutput[join].UserObject as Action<string>;
if (uo != null)
{
Debug.Console(1, this, "Executing Action: {0}", uo.ToString());
uo(Convert.ToString(state));
}
else
Debug.Console(1, this, "User Action is null. Nothing to Execute");
break;
}
default:
{
Debug.Console(1, "Unknown join type. Use digital/serial/analog");
break;
}
}
}
catch (Exception e)
{
Debug.Console(1, this, "Error: {0}", e);
}
}
/// <summary>
/// Handles incoming sig changes
/// </summary>
@@ -151,6 +220,7 @@ namespace PepperDash.Essentials.Bridges
if (Debug.Level >= 1)
Debug.Console(1, this, "EiscApi change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue);
var uo = args.Sig.UserObject;
Debug.Console(1, this, "Executing Action: {0}", uo.ToString());
if (uo is Action<bool>)
(uo as Action<bool>)(args.Sig.BoolValue);
else if (uo is Action<ushort>)

View File

@@ -13,129 +13,127 @@ using PepperDash.Essentials.Bridges;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.EthernetCommunication;
namespace PepperDash.Essentials
namespace PepperDash.Essentials
{
public class BridgeFactory
{
public static IKeyed GetDevice(DeviceConfig dc)
{
// ? why is this static JTA 2018-06-13?
var key = dc.Key;
var name = dc.Name;
var type = dc.Type;
var properties = dc.Properties;
var propAnon = new { };
var typeName = dc.Type.ToLower();
var groupName = dc.Group.ToLower();
public class BridgeFactory
{
public static IKeyed GetDevice(DeviceConfig dc)
{
// ? why is this static JTA 2018-06-13?
//Debug.Console(2, "Name {0}, Key {1}, Type {2}, Properties {3}", name, key, type, properties.ToString());
var key = dc.Key;
var name = dc.Name;
var type = dc.Type;
var properties = dc.Properties;
var propAnon = new { };
if (typeName == "eiscapi")
{
return new EiscApi(dc);
}
var typeName = dc.Type.ToLower();
var groupName = dc.Group.ToLower();
return null;
}
//Debug.Console(2, "Name {0}, Key {1}, Type {2}, Properties {3}", name, key, type, properties.ToString());
if (typeName == "eiscapi")
{
return new EiscApi(dc);
}
return null;
}
}
public class CommBridge : Device
{
public CommBridgeProperties Properties { get; private set; }
public List<IBasicCommunication> CommDevices { get; private set; }
public CommBridge(string key, string name, JToken properties)
: base(key, name)
{
Properties = JsonConvert.DeserializeObject<CommBridgeProperties>(properties.ToString());
}
public override bool CustomActivate()
{
// Create EiscApis
if (Properties.Eiscs != null)
{
foreach (var eisc in Properties.Eiscs)
{
var ApiEisc = new BridgeApiEisc(eisc.IpId, eisc.Hostname);
}
}
foreach (var deviceKey in Properties.CommDevices)
{
var device = DeviceManager.GetDeviceForKey(deviceKey);
if (device != null)
{
Debug.Console(0, "deviceKey {0} Found in Device Manager", device.Key);
CommDevices.Add(device as IBasicCommunication);
}
else
{
Debug.Console(0, "deviceKey {0} Not Found in Device Manager", deviceKey);
}
}
// Iterate through all the CommDevices and link up their Actions and Feedbacks
Debug.Console(0, "Bridge {0} Activated", this.Name);
return true;
}
}
public class EiscBridgeProperties
{
public string ParentDeviceKey { get; set; }
public eApiType ApiType { get; set; }
public List<EiscProperties> Eiscs { get; set; }
public string ApiOverrideFilePath { get; set; }
public class EiscProperties
{
public string IpId { get; set; }
public string Hostname { get; set; }
}
}
public class CommBridgeProperties : EiscBridgeProperties
{
public List<string> CommDevices { get; set; }
}
public enum eApiType { Eisc = 0 }
public class BridgeApiEisc
{
public uint Ipid { get; private set; }
public ThreeSeriesTcpIpEthernetIntersystemCommunications Eisc { get; private set; }
public BridgeApiEisc(string ipid, string hostname)
{
Ipid = (UInt32)int.Parse(ipid, System.Globalization.NumberStyles.HexNumber);
Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(Ipid, hostname, Global.ControlSystem);
Eisc.Register();
Eisc.SigChange += Eisc_SigChange;
Debug.Console(0, "BridgeApiEisc Created at Ipid {0}", ipid);
}
void Eisc_SigChange(object currentDevice, Crestron.SimplSharpPro.SigEventArgs args)
{
if (Debug.Level >= 1)
Debug.Console(1, "BridgeApiEisc change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue);
var uo = args.Sig.UserObject;
if (uo is Action<bool>)
(uo as Action<bool>)(args.Sig.BoolValue);
else if (uo is Action<ushort>)
(uo as Action<ushort>)(args.Sig.UShortValue);
else if (uo is Action<string>)
(uo as Action<string>)(args.Sig.StringValue);
}
}
}
public class CommBridge : Device
{
public CommBridgeProperties Properties { get; private set; }
public List<IBasicCommunication> CommDevices { get; private set; }
public CommBridge(string key, string name, JToken properties)
: base(key, name)
{
Properties = JsonConvert.DeserializeObject<CommBridgeProperties>(properties.ToString());
}
public override bool CustomActivate()
{
// Create EiscApis
if (Properties.Eiscs != null)
{
foreach (var eisc in Properties.Eiscs)
{
var ApiEisc = new BridgeApiEisc(eisc.IpId, eisc.Hostname);
}
}
foreach (var deviceKey in Properties.CommDevices)
{
var device = DeviceManager.GetDeviceForKey(deviceKey);
if (device != null)
{
Debug.Console(0, "deviceKey {0} Found in Device Manager", device.Key);
CommDevices.Add(device as IBasicCommunication);
}
else
{
Debug.Console(0, "deviceKey {0} Not Found in Device Manager", deviceKey);
}
}
// Iterate through all the CommDevices and link up their Actions and Feedbacks
Debug.Console(0, "Bridge {0} Activated", this.Name);
return true;
}
}
public class EiscBridgeProperties
{
public string ParentDeviceKey { get; set; }
public eApiType ApiType { get; set; }
public List<EiscProperties> Eiscs { get; set; }
public string ApiOverrideFilePath { get; set; }
public class EiscProperties
{
public string IpId { get; set; }
public string Hostname { get; set; }
}
}
public class CommBridgeProperties : EiscBridgeProperties
{
public List<string> CommDevices { get; set; }
}
public enum eApiType { Eisc = 0 }
public class BridgeApiEisc
{
public uint Ipid { get; private set; }
public ThreeSeriesTcpIpEthernetIntersystemCommunications Eisc { get; private set; }
public BridgeApiEisc(string ipid, string hostname)
{
Ipid = (UInt32)int.Parse(ipid, System.Globalization.NumberStyles.HexNumber);
Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(Ipid, hostname, Global.ControlSystem);
Eisc.Register();
Eisc.SigChange += Eisc_SigChange;
Debug.Console(0, "BridgeApiEisc Created at Ipid {0}", ipid);
}
void Eisc_SigChange(object currentDevice, Crestron.SimplSharpPro.SigEventArgs args)
{
if (Debug.Level >= 1)
Debug.Console(1, "BridgeApiEisc change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue);
var uo = args.Sig.UserObject;
if (uo is Action<bool>)
(uo as Action<bool>)(args.Sig.BoolValue);
else if (uo is Action<ushort>)
(uo as Action<ushort>)(args.Sig.UShortValue);
else if (uo is Action<string>)
(uo as Action<string>)(args.Sig.StringValue);
}
}
}

View File

@@ -1,187 +1,187 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Devices.Common;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using Crestron.SimplSharp;
//using Crestron.SimplSharpPro.DeviceSupport;
//using PepperDash.Core;
//using PepperDash.Essentials.Core;
//using PepperDash.Essentials.Devices.Common;
namespace PepperDash.Essentials.Bridges
{
public static class CameraControllerApiExtensions
{
//namespace PepperDash.Essentials.Bridges
//{
// public static class CameraControllerApiExtensions
// {
public static BasicTriList _TriList;
public static CameraControllerJoinMap JoinMap;
public static void LinkToApi(this PepperDash.Essentials.Devices.Common.Cameras.CameraBase cameraDevice, BasicTriList trilist, uint joinStart, string joinMapKey)
{
JoinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as CameraControllerJoinMap;
// public static BasicTriList _TriList;
// public static CameraControllerJoinMap JoinMap;
// public static void LinkToApi(this PepperDash.Essentials.Devices.Common.Cameras.CameraBase cameraDevice, BasicTriList trilist, uint joinStart, string joinMapKey)
// {
// JoinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as CameraControllerJoinMap;
_TriList = trilist;
if (JoinMap == null)
{
JoinMap = new CameraControllerJoinMap();
}
// _TriList = trilist;
// if (JoinMap == null)
// {
// JoinMap = new CameraControllerJoinMap();
// }
JoinMap.OffsetJoinNumbers(joinStart);
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
Debug.Console(0, "Linking to Bridge Type {0}", cameraDevice.GetType().Name.ToString());
// JoinMap.OffsetJoinNumbers(joinStart);
// Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
// Debug.Console(0, "Linking to Bridge Type {0}", cameraDevice.GetType().Name.ToString());
var commMonitor = cameraDevice as ICommunicationMonitor;
commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[JoinMap.IsOnline]);
// var commMonitor = cameraDevice as ICommunicationMonitor;
// commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[JoinMap.IsOnline]);
trilist.SetBoolSigAction(JoinMap.Left, (b) =>
{
if (b)
{
cameraDevice.PanLeft();
}
else
{
cameraDevice.Stop();
}
});
trilist.SetBoolSigAction(JoinMap.Right, (b) =>
{
if (b)
{
cameraDevice.PanRight();
}
else
{
cameraDevice.Stop();
}
});
// trilist.SetBoolSigAction(JoinMap.Left, (b) =>
// {
// if (b)
// {
// cameraDevice.PanLeft();
// }
// else
// {
// cameraDevice.Stop();
// }
// });
// trilist.SetBoolSigAction(JoinMap.Right, (b) =>
// {
// if (b)
// {
// cameraDevice.PanRight();
// }
// else
// {
// cameraDevice.Stop();
// }
// });
trilist.SetBoolSigAction(JoinMap.Up, (b) =>
{
if (b)
{
cameraDevice.TiltUp();
}
else
{
cameraDevice.Stop();
}
});
trilist.SetBoolSigAction(JoinMap.Down, (b) =>
{
if (b)
{
cameraDevice.TiltDown();
}
else
{
cameraDevice.Stop();
}
});
// trilist.SetBoolSigAction(JoinMap.Up, (b) =>
// {
// if (b)
// {
// cameraDevice.TiltUp();
// }
// else
// {
// cameraDevice.Stop();
// }
// });
// trilist.SetBoolSigAction(JoinMap.Down, (b) =>
// {
// if (b)
// {
// cameraDevice.TiltDown();
// }
// else
// {
// cameraDevice.Stop();
// }
// });
trilist.SetBoolSigAction(JoinMap.ZoomIn, (b) =>
{
if (b)
{
cameraDevice.ZoomIn();
}
else
{
cameraDevice.Stop();
}
});
// trilist.SetBoolSigAction(JoinMap.ZoomIn, (b) =>
// {
// if (b)
// {
// cameraDevice.ZoomIn();
// }
// else
// {
// cameraDevice.Stop();
// }
// });
trilist.SetBoolSigAction(JoinMap.ZoomOut, (b) =>
{
if (b)
{
cameraDevice.ZoomOut();
}
else
{
cameraDevice.Stop();
}
});
// trilist.SetBoolSigAction(JoinMap.ZoomOut, (b) =>
// {
// if (b)
// {
// cameraDevice.ZoomOut();
// }
// else
// {
// cameraDevice.Stop();
// }
// });
if (cameraDevice.GetType().Name.ToString().ToLower() == "cameravisca")
{
var viscaCamera = cameraDevice as PepperDash.Essentials.Devices.Common.Cameras.CameraVisca;
trilist.SetSigTrueAction(JoinMap.PowerOn, () => viscaCamera.PowerOn());
trilist.SetSigTrueAction(JoinMap.PowerOff, () => viscaCamera.PowerOff());
// if (cameraDevice.GetType().Name.ToString().ToLower() == "cameravisca")
// {
// var viscaCamera = cameraDevice as PepperDash.Essentials.Devices.Common.Cameras.CameraVisca;
// trilist.SetSigTrueAction(JoinMap.PowerOn, () => viscaCamera.PowerOn());
// trilist.SetSigTrueAction(JoinMap.PowerOff, () => viscaCamera.PowerOff());
viscaCamera.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[JoinMap.PowerOn]);
viscaCamera.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[JoinMap.PowerOff]);
// viscaCamera.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[JoinMap.PowerOn]);
// viscaCamera.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[JoinMap.PowerOff]);
viscaCamera.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[JoinMap.IsOnline]);
for (int i = 0; i < JoinMap.NumberOfPresets; i++)
{
int tempNum = i;
trilist.SetSigTrueAction((ushort)(JoinMap.PresetRecallOffset + tempNum), () =>
{
viscaCamera.RecallPreset(tempNum);
});
trilist.SetSigTrueAction((ushort)(JoinMap.PresetSaveOffset + tempNum), () =>
{
viscaCamera.SavePreset(tempNum);
});
}
}
// viscaCamera.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[JoinMap.IsOnline]);
// for (int i = 0; i < JoinMap.NumberOfPresets; i++)
// {
// int tempNum = i;
// trilist.SetSigTrueAction((ushort)(JoinMap.PresetRecallOffset + tempNum), () =>
// {
// viscaCamera.RecallPreset(tempNum);
// });
// trilist.SetSigTrueAction((ushort)(JoinMap.PresetSaveOffset + tempNum), () =>
// {
// viscaCamera.SavePreset(tempNum);
// });
// }
// }
}
// }
}
public class CameraControllerJoinMap : JoinMapBase
{
public uint IsOnline { get; set; }
public uint PowerOff { get; set; }
public uint PowerOn { get; set; }
public uint Up { get; set; }
public uint Down { get; set; }
public uint Left { get; set; }
public uint Right { get; set; }
public uint ZoomIn { get; set; }
public uint ZoomOut { get; set; }
public uint PresetRecallOffset { get; set; }
public uint PresetSaveOffset { get; set; }
public uint NumberOfPresets { get; set; }
// }
// public class CameraControllerJoinMap : JoinMapBase
// {
// public uint IsOnline { get; set; }
// public uint PowerOff { get; set; }
// public uint PowerOn { get; set; }
// public uint Up { get; set; }
// public uint Down { get; set; }
// public uint Left { get; set; }
// public uint Right { get; set; }
// public uint ZoomIn { get; set; }
// public uint ZoomOut { get; set; }
// public uint PresetRecallOffset { get; set; }
// public uint PresetSaveOffset { get; set; }
// public uint NumberOfPresets { get; set; }
public CameraControllerJoinMap()
{
// Digital
IsOnline = 9;
PowerOff = 8;
PowerOn = 7;
Up = 1;
Down = 2;
Left = 3;
Right = 4;
ZoomIn = 5;
ZoomOut = 6;
PresetRecallOffset = 10;
PresetSaveOffset = 30;
NumberOfPresets = 5;
// Analog
}
// public CameraControllerJoinMap()
// {
// // Digital
// IsOnline = 9;
// PowerOff = 8;
// PowerOn = 7;
// Up = 1;
// Down = 2;
// Left = 3;
// Right = 4;
// ZoomIn = 5;
// ZoomOut = 6;
// PresetRecallOffset = 10;
// PresetSaveOffset = 30;
// NumberOfPresets = 5;
// // Analog
// }
public override void OffsetJoinNumbers(uint joinStart)
{
var joinOffset = joinStart - 1;
// public override void OffsetJoinNumbers(uint joinStart)
// {
// var joinOffset = joinStart - 1;
IsOnline = IsOnline + joinOffset;
PowerOff = PowerOff + joinOffset;
PowerOn = PowerOn + joinOffset;
Up = Up + joinOffset;
Down = Down + joinOffset;
Left = Left + joinOffset;
Right = Right + joinOffset;
ZoomIn = ZoomIn + joinOffset;
ZoomOut = ZoomOut + joinOffset;
PresetRecallOffset = PresetRecallOffset + joinOffset;
PresetSaveOffset = PresetSaveOffset + joinOffset;
}
}
}
// IsOnline = IsOnline + joinOffset;
// PowerOff = PowerOff + joinOffset;
// PowerOn = PowerOn + joinOffset;
// Up = Up + joinOffset;
// Down = Down + joinOffset;
// Left = Left + joinOffset;
// Right = Right + joinOffset;
// ZoomIn = ZoomIn + joinOffset;
// ZoomOut = ZoomOut + joinOffset;
// PresetRecallOffset = PresetRecallOffset + joinOffset;
// PresetSaveOffset = PresetSaveOffset + joinOffset;
// }
// }
//}

View File

@@ -1,77 +1,77 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Devices.Common;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using Crestron.SimplSharp;
//using Crestron.SimplSharpPro.DeviceSupport;
//using PepperDash.Core;
//using PepperDash.Essentials.Core;
//using PepperDash.Essentials.Devices.Common;
namespace PepperDash.Essentials.Bridges
{
public static class DigitalLoggerApiExtensions
{
public static void LinkToApi(this DigitalLogger DigitalLogger, BasicTriList trilist, uint joinStart, string joinMapKey)
{
var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as DigitalLoggerJoinMap;
//namespace PepperDash.Essentials.Bridges
//{
// public static class DigitalLoggerApiExtensions
// {
// public static void LinkToApi(this DigitalLogger DigitalLogger, BasicTriList trilist, uint joinStart, string joinMapKey)
// {
// var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as DigitalLoggerJoinMap;
if (joinMap == null)
joinMap = new DigitalLoggerJoinMap();
// if (joinMap == null)
// joinMap = new DigitalLoggerJoinMap();
joinMap.OffsetJoinNumbers(joinStart);
Debug.Console(1, DigitalLogger, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
for (uint i = 1; i <= DigitalLogger.CircuitCount; i++)
{
var circuit = i;
DigitalLogger.CircuitNameFeedbacks[circuit - 1].LinkInputSig(trilist.StringInput[joinMap.CircuitNames + circuit]);
DigitalLogger.CircuitIsCritical[circuit - 1].LinkInputSig(trilist.BooleanInput[joinMap.CircuitIsCritical + circuit]);
DigitalLogger.CircuitState[circuit - 1].LinkInputSig(trilist.BooleanInput[joinMap.CircuitState + circuit]);
trilist.SetSigTrueAction(joinMap.CircuitCycle + circuit, () => DigitalLogger.CycleCircuit(circuit - 1));
trilist.SetSigTrueAction(joinMap.CircuitOnCmd + circuit, () => DigitalLogger.TurnOnCircuit(circuit - 1));
trilist.SetSigTrueAction(joinMap.CircuitOffCmd + circuit, () => DigitalLogger.TurnOffCircuit(circuit - 1));
// joinMap.OffsetJoinNumbers(joinStart);
// Debug.Console(1, DigitalLogger, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
// for (uint i = 1; i <= DigitalLogger.CircuitCount; i++)
// {
// var circuit = i;
// DigitalLogger.CircuitNameFeedbacks[circuit - 1].LinkInputSig(trilist.StringInput[joinMap.CircuitNames + circuit]);
// DigitalLogger.CircuitIsCritical[circuit - 1].LinkInputSig(trilist.BooleanInput[joinMap.CircuitIsCritical + circuit]);
// DigitalLogger.CircuitState[circuit - 1].LinkInputSig(trilist.BooleanInput[joinMap.CircuitState + circuit]);
// trilist.SetSigTrueAction(joinMap.CircuitCycle + circuit, () => DigitalLogger.CycleCircuit(circuit - 1));
// trilist.SetSigTrueAction(joinMap.CircuitOnCmd + circuit, () => DigitalLogger.TurnOnCircuit(circuit - 1));
// trilist.SetSigTrueAction(joinMap.CircuitOffCmd + circuit, () => DigitalLogger.TurnOffCircuit(circuit - 1));
}
}
}
public class DigitalLoggerJoinMap : JoinMapBase
{
public uint IsOnline { get; set; }
public uint CircuitNames { get; set; }
public uint CircuitState { get; set; }
public uint CircuitCycle { get; set; }
public uint CircuitIsCritical { get; set; }
public uint CircuitOnCmd { get; set; }
public uint CircuitOffCmd { get; set; }
public DigitalLoggerJoinMap()
{
// Digital
IsOnline = 9;
CircuitState = 0;
CircuitCycle = 0;
CircuitIsCritical = 10;
CircuitOnCmd = 10;
CircuitOffCmd = 20;
// Serial
CircuitNames = 0;
// Analog
}
// }
// }
// }
// public class DigitalLoggerJoinMap : JoinMapBase
// {
// public uint IsOnline { get; set; }
// public uint CircuitNames { get; set; }
// public uint CircuitState { get; set; }
// public uint CircuitCycle { get; set; }
// public uint CircuitIsCritical { get; set; }
// public uint CircuitOnCmd { get; set; }
// public uint CircuitOffCmd { get; set; }
// public DigitalLoggerJoinMap()
// {
// // Digital
// IsOnline = 9;
// CircuitState = 0;
// CircuitCycle = 0;
// CircuitIsCritical = 10;
// CircuitOnCmd = 10;
// CircuitOffCmd = 20;
// // Serial
// CircuitNames = 0;
// // Analog
// }
public override void OffsetJoinNumbers(uint joinStart)
{
var joinOffset = joinStart - 1;
// public override void OffsetJoinNumbers(uint joinStart)
// {
// var joinOffset = joinStart - 1;
IsOnline = IsOnline + joinOffset;
CircuitNames = CircuitNames + joinOffset;
CircuitState = CircuitState + joinOffset;
CircuitCycle = CircuitCycle + joinOffset;
CircuitIsCritical = CircuitIsCritical + joinOffset;
CircuitOnCmd = CircuitOnCmd + joinOffset;
CircuitOffCmd = CircuitOffCmd + joinOffset;
// IsOnline = IsOnline + joinOffset;
// CircuitNames = CircuitNames + joinOffset;
// CircuitState = CircuitState + joinOffset;
// CircuitCycle = CircuitCycle + joinOffset;
// CircuitIsCritical = CircuitIsCritical + joinOffset;
// CircuitOnCmd = CircuitOnCmd + joinOffset;
// CircuitOffCmd = CircuitOffCmd + joinOffset;
}
}
// }
// }
}
//}

View File

@@ -13,87 +13,118 @@ namespace PepperDash.Essentials.Bridges
public static class DisplayControllerApiExtensions
{
public static BasicTriList _TriList;
public static DisplayControllerJoinMap JoinMap;
public static int InputNumber;
public static IntFeedback InputNumberFeedback;
public static List<string> InputKeys = new List<string>();
public static void LinkToApi(this PepperDash.Essentials.Core.TwoWayDisplayBase displayDevice, BasicTriList trilist, uint joinStart, string joinMapKey)
public static void LinkToApi(this PepperDash.Essentials.Core.DisplayBase displayDevice, BasicTriList trilist, uint joinStart, string joinMapKey)
{
JoinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as DisplayControllerJoinMap;
_TriList = trilist;
if (JoinMap == null)
{
JoinMap = new DisplayControllerJoinMap();
}
JoinMap.OffsetJoinNumbers(joinStart);
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
Debug.Console(0, "Linking to Bridge Type {0}", displayDevice.GetType().Name.ToString());
var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as DisplayControllerJoinMap;
trilist.StringInput[JoinMap.Name].StringValue = displayDevice.GetType().Name.ToString();
InputNumberFeedback = new IntFeedback(() => { return InputNumber;});
InputNumberFeedback.LinkInputSig(trilist.UShortInput[JoinMap.InputSelect]);
var commMonitor = displayDevice as ICommunicationMonitor;
commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[JoinMap.IsOnline]);
// Poewer Off
trilist.SetSigTrueAction(JoinMap.PowerOff, () =>
if (joinMap == null)
{
InputNumber = 102;
InputNumberFeedback.FireUpdate();
displayDevice.PowerOff();
joinMap = new DisplayControllerJoinMap();
}
joinMap.OffsetJoinNumbers(joinStart);
Debug.Console(1, "Linking to Trilist '{0}'",trilist.ID.ToString("X"));
Debug.Console(0, "Linking to Bridge Type {0}", displayDevice.GetType().Name.ToString());
trilist.StringInput[joinMap.Name].StringValue = displayDevice.GetType().Name.ToString();
var commMonitor = displayDevice as ICommunicationMonitor;
if (commMonitor != null)
{
commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]);
}
InputNumberFeedback = new IntFeedback(() => { return InputNumber; });
// Two way feedbacks
var twoWayDisplay = displayDevice as PepperDash.Essentials.Core.TwoWayDisplayBase;
if (twoWayDisplay != null)
{
trilist.SetBool(joinMap.IsTwoWayDisplay, true);
twoWayDisplay.CurrentInputFeedback.OutputChange += new EventHandler<FeedbackEventArgs>(CurrentInputFeedback_OutputChange);
InputNumberFeedback.LinkInputSig(trilist.UShortInput[joinMap.InputSelect]);
}
// Power Off
trilist.SetSigTrueAction(joinMap.PowerOff, () =>
{
InputNumber = 102;
InputNumberFeedback.FireUpdate();
displayDevice.PowerOff();
});
displayDevice.PowerIsOnFeedback.OutputChange += new EventHandler<FeedbackEventArgs>(PowerIsOnFeedback_OutputChange);
displayDevice.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PowerOff]);
// PowerOn
trilist.SetSigTrueAction(joinMap.PowerOn, () =>
{
InputNumber = 0;
InputNumberFeedback.FireUpdate();
displayDevice.PowerOn();
});
displayDevice.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn]);
int count = 1;
foreach (var input in displayDevice.InputPorts)
{
InputKeys.Add(input.Key.ToString());
var tempKey = InputKeys.ElementAt(count - 1);
trilist.SetSigTrueAction((ushort)(joinMap.InputSelectOffset + count), () => { displayDevice.ExecuteSwitch(displayDevice.InputPorts[tempKey].Selector); });
Debug.Console(2, displayDevice, "Setting Input Select Action on Digital Join {0} to Input: {1}", joinMap.InputSelectOffset + count, displayDevice.InputPorts[tempKey].Key.ToString());
trilist.StringInput[(ushort)(joinMap.InputNamesOffset + count)].StringValue = input.Key.ToString();
count++;
}
Debug.Console(2, displayDevice, "Setting Input Select Action on Analog Join {0}", joinMap.InputSelect);
trilist.SetUShortSigAction(joinMap.InputSelect, (a) =>
{
if (a == 0)
{
displayDevice.PowerOff();
InputNumber = 0;
}
else if (a > 0 && a < displayDevice.InputPorts.Count && a != InputNumber)
{
displayDevice.ExecuteSwitch(displayDevice.InputPorts.ElementAt(a - 1).Selector);
InputNumber = a;
}
else if (a == 102)
{
displayDevice.PowerToggle();
}
if (twoWayDisplay != null)
InputNumberFeedback.FireUpdate();
});
displayDevice.PowerIsOnFeedback.OutputChange += new EventHandler<FeedbackEventArgs>(PowerIsOnFeedback_OutputChange);
displayDevice.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[JoinMap.PowerOff]);
// Poewer On
trilist.SetSigTrueAction(JoinMap.PowerOn, () =>
{
InputNumber = 0;
InputNumberFeedback.FireUpdate();
displayDevice.PowerOn();
});
var volumeDisplay = displayDevice as IBasicVolumeControls;
if (volumeDisplay != null)
{
trilist.SetBoolSigAction(joinMap.VolumeUp, (b) => volumeDisplay.VolumeUp(b));
trilist.SetBoolSigAction(joinMap.VolumeDown, (b) => volumeDisplay.VolumeDown(b));
trilist.SetSigTrueAction(joinMap.VolumeMute, () => volumeDisplay.MuteToggle());
displayDevice.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[JoinMap.PowerOn]);
int count = 1;
foreach (var input in displayDevice.InputPorts)
{
InputKeys.Add(input.Key.ToString());
var tempKey = InputKeys.ElementAt(count - 1);
trilist.SetSigTrueAction((ushort)(JoinMap.InputSelectOffset + count), () => { displayDevice.ExecuteSwitch(displayDevice.InputPorts[tempKey].Selector); });
trilist.StringInput[(ushort)(JoinMap.InputNamesOffset + count)].StringValue = input.Key.ToString();
count++;
var volumeDisplayWithFeedback = volumeDisplay as IBasicVolumeWithFeedback;
if(volumeDisplayWithFeedback != null)
{
volumeDisplayWithFeedback.VolumeLevelFeedback.LinkInputSig(trilist.UShortInput[joinMap.VolumeLevelFB]);
volumeDisplayWithFeedback.MuteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VolumeMute]);
}
}
}
displayDevice.CurrentInputFeedback.OutputChange += new EventHandler<FeedbackEventArgs>(CurrentInputFeedback_OutputChange);
trilist.SetUShortSigAction(JoinMap.InputSelect, (a) =>
{
if (a == 0)
{
displayDevice.PowerOff();
InputNumber = 0;
}
else if (a > 0 && a < displayDevice.InputPorts.Count && a != InputNumber)
{
displayDevice.ExecuteSwitch(displayDevice.InputPorts.ElementAt(a - 1).Selector);
InputNumber = a;
}
else if (a == 102)
{
displayDevice.PowerToggle();
}
InputNumberFeedback.FireUpdate();
});
}
static void CurrentInputFeedback_OutputChange(object sender, FeedbackEventArgs e)
{
@@ -122,19 +153,27 @@ namespace PepperDash.Essentials.Bridges
}
public class DisplayControllerJoinMap : JoinMapBase
public class DisplayControllerJoinMap : JoinMapBase
{
public uint Name { get; set; }
public uint InputNamesOffset { get; set; }
public uint InputSelectOffset { get; set; }
public uint IsOnline { get; set; }
public uint PowerOff { get; set; }
public uint InputSelect { get; set; }
public uint PowerOn { get; set; }
public uint SelectScene { get; set; }
public uint LightingSceneOffset { get; set; }
// Digital
public uint PowerOff { get; set; }
public uint PowerOn { get; set; }
public uint IsTwoWayDisplay { get; set; }
public uint VolumeUp { get; set; }
public uint VolumeDown { get; set; }
public uint VolumeMute { get; set; }
public uint InputSelectOffset { get; set; }
public uint ButtonVisibilityOffset { get; set; }
public uint IntegrationIdSet { get; set; }
public uint IsOnline { get; set; }
// Analog
public uint InputSelect { get; set; }
public uint VolumeLevelFB { get; set; }
// Serial
public uint Name { get; set; }
public uint InputNamesOffset { get; set; }
public DisplayControllerJoinMap()
{
@@ -142,15 +181,22 @@ namespace PepperDash.Essentials.Bridges
IsOnline = 50;
PowerOff = 1;
PowerOn = 2;
InputSelect = 4;
IntegrationIdSet = 1;
LightingSceneOffset = 10;
IsTwoWayDisplay = 3;
VolumeUp = 5;
VolumeDown = 6;
VolumeMute = 7;
ButtonVisibilityOffset = 40;
Name = 1;
InputNamesOffset = 10;
InputSelectOffset = 4;
InputSelectOffset = 10;
// Analog
}
InputSelect = 11;
VolumeLevelFB = 5;
// Serial
Name = 1;
InputNamesOffset = 10;
}
public override void OffsetJoinNumbers(uint joinStart)
{
@@ -159,13 +205,18 @@ namespace PepperDash.Essentials.Bridges
IsOnline = IsOnline + joinOffset;
PowerOff = PowerOff + joinOffset;
PowerOn = PowerOn + joinOffset;
SelectScene = SelectScene + joinOffset;
LightingSceneOffset = LightingSceneOffset + joinOffset;
IsTwoWayDisplay = IsTwoWayDisplay + joinOffset;
ButtonVisibilityOffset = ButtonVisibilityOffset + joinOffset;
Name = Name + joinOffset;
InputNamesOffset = InputNamesOffset + joinOffset;
InputSelectOffset = InputSelectOffset + joinOffset;
InputSelect = InputSelect + joinOffset;
VolumeUp = VolumeUp + joinOffset;
VolumeDown = VolumeDown + joinOffset;
VolumeMute = VolumeMute + joinOffset;
VolumeLevelFB = VolumeLevelFB + joinOffset;
}
}
}

View File

@@ -1,45 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.DM;
namespace PepperDash.Essentials.Bridges
{
public static class DmChassisControllerApiExtentions
{
public static void LinkToApi(this DmChassisController dmChassis, BasicTriList trilist, uint joinStart, string joinMapKey)
{
var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as DmChassisControllerJoinMap;
if (joinMap == null)
joinMap = new DmChassisControllerJoinMap();
joinMap.OffsetJoinNumbers(joinStart);
Debug.Console(1, dmChassis, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
dmChassis.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]);
// Link up outputs
for (uint i = 1; i <= dmChassis.Chassis.NumberOfOutputs - 1; i++)
{
var ioSlot = i;
// Control
trilist.SetUShortSigAction(joinMap.OutputVideo + ioSlot, new Action<ushort>(o => dmChassis.ExecuteSwitch(o, ioSlot, eRoutingSignalType.Video)));
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.DM;
namespace PepperDash.Essentials.Bridges
{
public static class DmChassisControllerApiExtentions
{
public static void LinkToApi(this DmChassisController dmChassis, BasicTriList trilist, uint joinStart, string joinMapKey)
{
var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as DmChassisControllerJoinMap;
if (joinMap == null)
joinMap = new DmChassisControllerJoinMap();
joinMap.OffsetJoinNumbers(joinStart);
Debug.Console(1, dmChassis, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
dmChassis.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]);
// Link up outputs
for (uint i = 1; i <= dmChassis.Chassis.NumberOfOutputs - 1; i++)
{
var ioSlot = i;
// Control
trilist.SetUShortSigAction(joinMap.OutputVideo + ioSlot, new Action<ushort>(o => dmChassis.ExecuteSwitch(o, ioSlot, eRoutingSignalType.Video)));
trilist.SetUShortSigAction(joinMap.OutputAudio + ioSlot, new Action<ushort>(o => dmChassis.ExecuteSwitch(o, ioSlot, eRoutingSignalType.Audio)));
if (dmChassis.TxDictionary.ContainsKey(ioSlot))
{
Debug.Console(2, "Creating Tx Feedbacks {0}", ioSlot);
var TxKey = dmChassis.TxDictionary[ioSlot];
var TxDevice = DeviceManager.GetDeviceForKey(TxKey) as DmTxControllerBase;
TxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]);
dmChassis.InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]);
//TxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]);
// TxDevice.AnyVideoInput.VideoStatus.VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]);
// trilist.SetUShortSigAction((ApiMap.HdcpSupport[ioSlot]), u => TxDevice.SetHdcpSupportAll((ePdtHdcpSupport)(u)));
// TxDevice.HdcpSupportAllFeedback.LinkInputSig(trilist.UShortInput[joinMap. + ioSlot]);
@@ -54,77 +55,79 @@ namespace PepperDash.Essentials.Bridges
Debug.Console(2, "Creating Rx Feedbacks {0}", ioSlot);
var RxKey = dmChassis.RxDictionary[ioSlot];
var RxDevice = DeviceManager.GetDeviceForKey(RxKey) as DmRmcControllerBase;
RxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]);
}
// Feedback
dmChassis.VideoOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputVideo + ioSlot]);
dmChassis.AudioOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputAudio + ioSlot]);
dmChassis.VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus + ioSlot]);
dmChassis.OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputNames + ioSlot]);
dmChassis.InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputNames + ioSlot]);
dmChassis.OutputVideoRouteNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentVideoInputNames + ioSlot]);
dmChassis.OutputAudioRouteNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentAudioInputNames + ioSlot]);
// dmChassis.InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]);
// dmChassis.OutputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]);
}
}
public class DmChassisControllerJoinMap : JoinMapBase
{
public uint IsOnline { get; set; }
public uint OutputVideo { get; set; }
public uint OutputAudio { get; set; }
public uint VideoSyncStatus { get; set; }
public uint InputNames { get; set; }
public uint OutputNames { get; set; }
public uint OutputCurrentVideoInputNames { get; set; }
public uint OutputCurrentAudioInputNames { get; set; }
public uint InputCurrentResolution { get; set; }
public uint InputEndpointOnline { get; set; }
public uint OutputEndpointOnline { get; set; }
//public uint HdcpSupport { get; set; }
//public uint HdcpSupportCapability { get; set; }
public DmChassisControllerJoinMap()
{
IsOnline = 11;
OutputVideo = 100; //101-299
OutputAudio = 300; //301-499
VideoSyncStatus = 100; //101-299
InputNames = 100; //101-299
OutputNames = 300; //301-499
OutputCurrentVideoInputNames = 2000; //2001-2199
OutputCurrentAudioInputNames = 2200; //2201-2399
InputCurrentResolution = 2400; // 2401-2599
InputEndpointOnline = 500;
OutputEndpointOnline = 700;
//HdcpSupport = 1000; //1001-1199
//HdcpSupportCapability = 1200; //1201-1399
}
public override void OffsetJoinNumbers(uint joinStart)
{
var joinOffset = joinStart - 1;
IsOnline = IsOnline + joinOffset;
OutputVideo = OutputVideo + joinOffset;
OutputAudio = OutputAudio + joinOffset;
VideoSyncStatus = VideoSyncStatus + joinOffset;
InputNames = InputNames + joinOffset;
OutputNames = OutputNames + joinOffset;
OutputCurrentVideoInputNames = OutputCurrentVideoInputNames + joinOffset;
OutputCurrentAudioInputNames = OutputCurrentAudioInputNames + joinOffset;
InputCurrentResolution = InputCurrentResolution + joinOffset;
InputEndpointOnline = InputEndpointOnline + joinOffset;
OutputEndpointOnline = OutputEndpointOnline + joinOffset;
//HdcpSupport = HdcpSupport + joinOffset;
//HdcpSupportCapability = HdcpSupportCapability + joinOffset;
}
}
}
dmChassis.OutputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]);
//RxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]);
}
// Feedback
dmChassis.VideoOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputVideo + ioSlot]);
dmChassis.AudioOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputAudio + ioSlot]);
dmChassis.VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus + ioSlot]);
dmChassis.OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputNames + ioSlot]);
dmChassis.InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputNames + ioSlot]);
dmChassis.OutputVideoRouteNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentVideoInputNames + ioSlot]);
dmChassis.OutputAudioRouteNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentAudioInputNames + ioSlot]);
// dmChassis.InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]);
// dmChassis.OutputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]);
}
}
public class DmChassisControllerJoinMap : JoinMapBase
{
public uint IsOnline { get; set; }
public uint OutputVideo { get; set; }
public uint OutputAudio { get; set; }
public uint VideoSyncStatus { get; set; }
public uint InputNames { get; set; }
public uint OutputNames { get; set; }
public uint OutputCurrentVideoInputNames { get; set; }
public uint OutputCurrentAudioInputNames { get; set; }
public uint InputCurrentResolution { get; set; }
public uint InputEndpointOnline { get; set; }
public uint OutputEndpointOnline { get; set; }
//public uint HdcpSupport { get; set; }
//public uint HdcpSupportCapability { get; set; }
public DmChassisControllerJoinMap()
{
IsOnline = 11;
OutputVideo = 100; //101-299
OutputAudio = 300; //301-499
VideoSyncStatus = 100; //101-299
InputNames = 100; //101-299
OutputNames = 300; //301-499
OutputCurrentVideoInputNames = 2000; //2001-2199
OutputCurrentAudioInputNames = 2200; //2201-2399
InputCurrentResolution = 2400; // 2401-2599
InputEndpointOnline = 500;
OutputEndpointOnline = 700;
//HdcpSupport = 1000; //1001-1199
//HdcpSupportCapability = 1200; //1201-1399
}
public override void OffsetJoinNumbers(uint joinStart)
{
var joinOffset = joinStart - 1;
IsOnline = IsOnline + joinOffset;
OutputVideo = OutputVideo + joinOffset;
OutputAudio = OutputAudio + joinOffset;
VideoSyncStatus = VideoSyncStatus + joinOffset;
InputNames = InputNames + joinOffset;
OutputNames = OutputNames + joinOffset;
OutputCurrentVideoInputNames = OutputCurrentVideoInputNames + joinOffset;
OutputCurrentAudioInputNames = OutputCurrentAudioInputNames + joinOffset;
InputCurrentResolution = InputCurrentResolution + joinOffset;
InputEndpointOnline = InputEndpointOnline + joinOffset;
OutputEndpointOnline = OutputEndpointOnline + joinOffset;
//HdcpSupport = HdcpSupport + joinOffset;
//HdcpSupportCapability = HdcpSupportCapability + joinOffset;
}
}
}
}

View File

@@ -1,103 +1,103 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Devices.Common;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using Crestron.SimplSharp;
//using Crestron.SimplSharpPro.DeviceSupport;
//using PepperDash.Core;
//using PepperDash.Essentials.Core;
//using PepperDash.Essentials.Devices.Common;
namespace PepperDash.Essentials.Bridges
{
public static class GenericLightingApiExtensions
{
public static void LinkToApi(this PepperDash.Essentials.Core.Lighting.LightingBase lightingDevice, BasicTriList trilist, uint joinStart, string joinMapKey)
{
var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as GenericLightingJoinMap;
//namespace PepperDash.Essentials.Bridges
//{
// public static class GenericLightingApiExtensions
// {
// public static void LinkToApi(this PepperDash.Essentials.Core.Lighting.LightingBase lightingDevice, BasicTriList trilist, uint joinStart, string joinMapKey)
// {
// var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as GenericLightingJoinMap;
if (joinMap == null)
joinMap = new GenericLightingJoinMap();
// if (joinMap == null)
// joinMap = new GenericLightingJoinMap();
joinMap.OffsetJoinNumbers(joinStart);
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
// joinMap.OffsetJoinNumbers(joinStart);
// Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
Debug.Console(0, "Linking to lighting Type {0}", lightingDevice.GetType().Name.ToString());
// Debug.Console(0, "Linking to lighting Type {0}", lightingDevice.GetType().Name.ToString());
// GenericLighitng Actions & FeedBack
trilist.SetUShortSigAction(joinMap.SelectScene, u => lightingDevice.SelectScene(lightingDevice.LightingScenes[u]));
// // GenericLighitng Actions & FeedBack
// trilist.SetUShortSigAction(joinMap.SelectScene, u => lightingDevice.SelectScene(lightingDevice.LightingScenes[u]));
int sceneIndex = 1;
foreach (var scene in lightingDevice.LightingScenes)
{
var tempIndex = sceneIndex - 1;
trilist.SetSigTrueAction((uint)(joinMap.LightingSceneOffset + sceneIndex), () => lightingDevice.SelectScene(lightingDevice.LightingScenes[tempIndex]));
scene.IsActiveFeedback.LinkInputSig(trilist.BooleanInput[(uint)(joinMap.LightingSceneOffset + sceneIndex)]);
trilist.StringInput[(uint)(joinMap.LightingSceneOffset + sceneIndex)].StringValue = scene.Name;
trilist.BooleanInput[(uint)(joinMap.ButtonVisibilityOffset + sceneIndex)].BoolValue = true;
sceneIndex++;
}
// int sceneIndex = 1;
// foreach (var scene in lightingDevice.LightingScenes)
// {
// var tempIndex = sceneIndex - 1;
// trilist.SetSigTrueAction((uint)(joinMap.LightingSceneOffset + sceneIndex), () => lightingDevice.SelectScene(lightingDevice.LightingScenes[tempIndex]));
// scene.IsActiveFeedback.LinkInputSig(trilist.BooleanInput[(uint)(joinMap.LightingSceneOffset + sceneIndex)]);
// trilist.StringInput[(uint)(joinMap.LightingSceneOffset + sceneIndex)].StringValue = scene.Name;
// trilist.BooleanInput[(uint)(joinMap.ButtonVisibilityOffset + sceneIndex)].BoolValue = true;
// sceneIndex++;
// }
if (lightingDevice.GetType().Name.ToString() == "LutronQuantumArea")
{
var lutronDevice = lightingDevice as PepperDash.Essentials.Devices.Common.Environment.Lutron.LutronQuantumArea;
lutronDevice.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]);
trilist.SetStringSigAction(joinMap.IntegrationIdSet, s => lutronDevice.IntegrationId = s);
}
// if (lightingDevice.GetType().Name.ToString() == "LutronQuantumArea")
// {
// var lutronDevice = lightingDevice as PepperDash.Essentials.Devices.Common.Environment.Lutron.LutronQuantumArea;
// lutronDevice.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]);
// trilist.SetStringSigAction(joinMap.IntegrationIdSet, s => lutronDevice.IntegrationId = s);
// }
//ApiEisc.Eisc.SetStringSigAction(ApiMap.integrationID, (s) => { lutronLights.IntegrationId = s; });
// //ApiEisc.Eisc.SetStringSigAction(ApiMap.integrationID, (s) => { lutronLights.IntegrationId = s; });
/*
var lutronLights = lightingDevice as PepperDash.Essentials.Devices.Common.Environment.Lutron.LutronQuantumArea;
// /*
// var lutronLights = lightingDevice as PepperDash.Essentials.Devices.Common.Environment.Lutron.LutronQuantumArea;
for (uint i = 1; i <= lightingBase.CircuitCount; i++)
{
var circuit = i;
lightingBase.CircuitNameFeedbacks[circuit - 1].LinkInputSig(trilist.StringInput[joinMap.CircuitNames + circuit]);
lightingBase.CircuitIsCritical[circuit - 1].LinkInputSig(trilist.BooleanInput[joinMap.CircuitIsCritical + circuit]);
lightingBase.CircuitState[circuit - 1].LinkInputSig(trilist.BooleanInput[joinMap.CircuitState + circuit]);
trilist.SetSigTrueAction(joinMap.CircuitCycle + circuit, () => lightingBase.CycleCircuit(circuit - 1));
trilist.SetSigTrueAction(joinMap.CircuitOnCmd + circuit, () => lightingBase.TurnOnCircuit(circuit - 1));
trilist.SetSigTrueAction(joinMap.CircuitOffCmd + circuit, () => lightingBase.TurnOffCircuit(circuit - 1));
// for (uint i = 1; i <= lightingBase.CircuitCount; i++)
// {
// var circuit = i;
// lightingBase.CircuitNameFeedbacks[circuit - 1].LinkInputSig(trilist.StringInput[joinMap.CircuitNames + circuit]);
// lightingBase.CircuitIsCritical[circuit - 1].LinkInputSig(trilist.BooleanInput[joinMap.CircuitIsCritical + circuit]);
// lightingBase.CircuitState[circuit - 1].LinkInputSig(trilist.BooleanInput[joinMap.CircuitState + circuit]);
// trilist.SetSigTrueAction(joinMap.CircuitCycle + circuit, () => lightingBase.CycleCircuit(circuit - 1));
// trilist.SetSigTrueAction(joinMap.CircuitOnCmd + circuit, () => lightingBase.TurnOnCircuit(circuit - 1));
// trilist.SetSigTrueAction(joinMap.CircuitOffCmd + circuit, () => lightingBase.TurnOffCircuit(circuit - 1));
}
*/
}
}
public class GenericLightingJoinMap : JoinMapBase
{
public uint IsOnline { get; set; }
public uint SelectScene { get; set; }
public uint LightingSceneOffset { get; set; }
public uint ButtonVisibilityOffset { get; set; }
public uint IntegrationIdSet { get; set; }
// }
// */
// }
// }
// public class GenericLightingJoinMap : JoinMapBase
// {
// public uint IsOnline { get; set; }
// public uint SelectScene { get; set; }
// public uint LightingSceneOffset { get; set; }
// public uint ButtonVisibilityOffset { get; set; }
// public uint IntegrationIdSet { get; set; }
public GenericLightingJoinMap()
{
// Digital
IsOnline = 1;
SelectScene = 1;
IntegrationIdSet = 1;
LightingSceneOffset = 10;
ButtonVisibilityOffset = 40;
// Analog
}
// public GenericLightingJoinMap()
// {
// // Digital
// IsOnline = 1;
// SelectScene = 1;
// IntegrationIdSet = 1;
// LightingSceneOffset = 10;
// ButtonVisibilityOffset = 40;
// // Analog
// }
public override void OffsetJoinNumbers(uint joinStart)
{
var joinOffset = joinStart - 1;
// public override void OffsetJoinNumbers(uint joinStart)
// {
// var joinOffset = joinStart - 1;
IsOnline = IsOnline + joinOffset;
SelectScene = SelectScene + joinOffset;
LightingSceneOffset = LightingSceneOffset + joinOffset;
ButtonVisibilityOffset = ButtonVisibilityOffset + joinOffset;
// IsOnline = IsOnline + joinOffset;
// SelectScene = SelectScene + joinOffset;
// LightingSceneOffset = LightingSceneOffset + joinOffset;
// ButtonVisibilityOffset = ButtonVisibilityOffset + joinOffset;
}
}
}
// }
// }
//}

View File

@@ -30,7 +30,11 @@ namespace PepperDash.Essentials.Bridges
Debug.Console(1, comm, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
// this is a permanent event handler. This cannot be -= from event
comm.CommPort.TextReceived += (s, a) => trilist.SetString(joinMap.TextReceived, a.Text);
comm.CommPort.TextReceived += (s, a) =>
{
Debug.Console(2, comm, "RX: {0}", a.Text);
trilist.SetString(joinMap.TextReceived, a.Text);
};
trilist.SetStringSigAction(joinMap.SendText, new Action<string>(s => comm.CommPort.SendText(s)));
trilist.SetStringSigAction(joinMap.SetPortConfig + 1, new Action<string>(s => comm.SetPortConfig(s)));

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DeviceSupport;
namespace PepperDash.Essentials.Bridges
{
public interface IBridge
{
void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey);
}
}

View File

@@ -1,10 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.CrestronThread;
using Crestron.SimplSharpPro.Diagnostics;
using Crestron.SimplSharp.Reflection;
using PepperDash.Core;
using PepperDash.Essentials.Core;
@@ -17,35 +19,35 @@ using PepperDash.Essentials.Room.Cotija;
namespace PepperDash.Essentials
{
public class ControlSystem : CrestronControlSystem
{
public class ControlSystem : CrestronControlSystem
{
HttpLogoServer LogoServer;
public ControlSystem()
: base()
{
Thread.MaxNumberOfUserThreads = 400;
Global.ControlSystem = this;
DeviceManager.Initialize(this);
}
List<object> FactoryObjects = new List<object>();
/// <summary>
/// Git 'er goin'
/// </summary>
public override void InitializeSystem()
{
SystemMonitor.ProgramInitialization.ProgramInitializationUnderUserControl = true;
public ControlSystem()
: base()
{
Thread.MaxNumberOfUserThreads = 400;
Global.ControlSystem = this;
DeviceManager.Initialize(this);
}
/// <summary>
/// Git 'er goin'
/// </summary>
public override void InitializeSystem()
{
DeterminePlatform();
//CrestronConsole.AddNewConsoleCommand(s => GoWithLoad(), "go", "Loads configuration file",
// ConsoleAccessLevelEnum.AccessOperator);
// CrestronConsole.AddNewConsoleCommand(S => { ConfigWriter.WriteConfigFile(null); }, "writeconfig", "writes the current config to a file", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s =>
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "CONSOLE MESSAGE: {0}", s);
}, "appdebugmessage", "Writes message to log", ConsoleAccessLevelEnum.AccessOperator);
// CrestronConsole.AddNewConsoleCommand(S => { ConfigWriter.WriteConfigFile(null); }, "writeconfig", "writes the current config to a file", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s =>
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "CONSOLE MESSAGE: {0}", s);
}, "appdebugmessage", "Writes message to log", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s =>
{
@@ -54,26 +56,26 @@ namespace PepperDash.Essentials
},
"listtielines", "Prints out all tie lines", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s =>
{
CrestronConsole.ConsoleCommandResponse
("Current running configuration. This is the merged system and template configuration");
CrestronConsole.ConsoleCommandResponse(Newtonsoft.Json.JsonConvert.SerializeObject
(ConfigReader.ConfigObject, Newtonsoft.Json.Formatting.Indented));
}, "showconfig", "Shows the current running merged config", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s =>
{
CrestronConsole.ConsoleCommandResponse
("Current running configuration. This is the merged system and template configuration");
CrestronConsole.ConsoleCommandResponse(Newtonsoft.Json.JsonConvert.SerializeObject
(ConfigReader.ConfigObject, Newtonsoft.Json.Formatting.Indented));
}, "showconfig", "Shows the current running merged config", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s =>
{
CrestronConsole.ConsoleCommandResponse("This system can be found at the following URLs:\r" +
"System URL: {0}\r" +
"Template URL: {1}", ConfigReader.ConfigObject.SystemUrl, ConfigReader.ConfigObject.TemplateUrl);
}, "portalinfo", "Shows portal URLS from configuration", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s =>
{
CrestronConsole.ConsoleCommandResponse("This system can be found at the following URLs:\r" +
"System URL: {0}\r" +
"Template URL: {1}", ConfigReader.ConfigObject.SystemUrl, ConfigReader.ConfigObject.TemplateUrl);
}, "portalinfo", "Shows portal URLS from configuration", ConsoleAccessLevelEnum.AccessOperator);
GoWithLoad();
}
}
/// <summary>
/// Determines if the program is running on a processor (appliance) or server (XiO Edge).
/// Determines if the program is running on a processor (appliance) or server (VC-4).
///
/// Sets Global.FilePathPrefix based on platform
/// </summary>
@@ -93,106 +95,214 @@ namespace PepperDash.Essentials
directoryPrefix = Crestron.SimplSharp.CrestronIO.Directory.GetApplicationRootDirectory();
//directoryPrefix = "";
if (CrestronEnvironment.DevicePlatform != eDevicePlatform.Server)
if (CrestronEnvironment.DevicePlatform != eDevicePlatform.Server) // Handles 3-series running Windows OS
{
filePathPrefix = directoryPrefix + dirSeparator + "NVRAM"
+ dirSeparator + string.Format("program{0}", InitialParametersClass.ApplicationNumber) + dirSeparator;
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials v{0} on 3-series Appliance", versionString);
}
else
{
filePathPrefix = directoryPrefix + dirSeparator + "User" + dirSeparator;
// Check if User/ProgramX exists
if (Directory.Exists(directoryPrefix + dirSeparator + "User"
+ dirSeparator + string.Format("program{0}", InitialParametersClass.ApplicationNumber)))
{
Debug.Console(0, @"User/program{0} directory found", InitialParametersClass.ApplicationNumber);
filePathPrefix = directoryPrefix + dirSeparator + "User"
+ dirSeparator + string.Format("program{0}", InitialParametersClass.ApplicationNumber) + dirSeparator;
}
// Check if Nvram/Programx exists
else if (Directory.Exists(directoryPrefix + dirSeparator + "Nvram"
+ dirSeparator + string.Format("program{0}", InitialParametersClass.ApplicationNumber)))
{
Debug.Console(0, @"Nvram/program{0} directory found", InitialParametersClass.ApplicationNumber);
filePathPrefix = directoryPrefix + dirSeparator + "Nvram"
+ dirSeparator + string.Format("program{0}", InitialParametersClass.ApplicationNumber) + dirSeparator;
}
// If neither exists, set path to User/ProgramX
else
{
Debug.Console(0, @"No previous directory found. Using User/program{0}", InitialParametersClass.ApplicationNumber);
filePathPrefix = directoryPrefix + dirSeparator + "User"
+ dirSeparator + string.Format("program{0}", InitialParametersClass.ApplicationNumber) + dirSeparator;
}
}
else // Handles Linux OS (Virtual Control)
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials v{0} on Virtual Control Server", versionString);
// Set path to User/
filePathPrefix = directoryPrefix + dirSeparator + "User" + dirSeparator;
}
Global.SetFilePathPrefix(filePathPrefix);
}
/// <summary>
/// Do it, yo
/// </summary>
public void GoWithLoad()
{
try
{
CrestronConsole.AddNewConsoleCommand(EnablePortalSync, "portalsync", "Loads Portal Sync",
ConsoleAccessLevelEnum.AccessOperator);
//PortalSync = new PepperDashPortalSyncClient();
/// <summary>
/// Do it, yo
/// </summary>
public void GoWithLoad()
{
try
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials load from configuration");
var filesReady = SetupFilesystem();
if (filesReady)
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Folder structure verified. Loading config...");
if (!ConfigReader.LoadConfig2())
return;
var filesReady = SetupFilesystem();
if (filesReady)
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Checking for plugins");
LoadPlugins();
Load();
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Folder structure verified. Loading config...");
if (!ConfigReader.LoadConfig2())
return;
Load();
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Essentials load complete\r" +
"-------------------------------------------------------------");
}
else
{
Debug.Console(0,
"------------------------------------------------\r" +
"------------------------------------------------\r" +
"------------------------------------------------\r" +
"Essentials file structure setup completed.\r" +
"Please load config, sgd and ir files and\r" +
"restart program.\r" +
"------------------------------------------------\r" +
"------------------------------------------------\r" +
"------------------------------------------------");
}
"-------------------------------------------------------------");
}
else
{
Debug.Console(0,
"------------------------------------------------\r" +
"------------------------------------------------\r" +
"------------------------------------------------\r" +
"Essentials file structure setup completed.\r" +
"Please load config, sgd and ir files and\r" +
"restart program.\r" +
"------------------------------------------------\r" +
"------------------------------------------------\r" +
"------------------------------------------------");
}
}
catch (Exception e)
{
Debug.Console(0, "FATAL INITIALIZE ERROR. System is in an inconsistent state:\r{0}", e);
catch (Exception e)
{
Debug.Console(0, "FATAL INITIALIZE ERROR. System is in an inconsistent state:\r{0}", e);
}
}
// Notify the
// Notify the OS that the program intitialization has completed
SystemMonitor.ProgramInitialization.ProgramInitializationComplete = true;
}
}
/// <summary>
/// Verifies filesystem is set up. IR, SGD, and program1 folders
/// </summary>
bool SetupFilesystem()
{
Debug.Console(0, "Verifying and/or creating folder structure");
var configDir = Global.FilePathPrefix;
var configExists = Directory.Exists(configDir);
if (!configExists)
Directory.Create(configDir);
/// <summary>
/// Initial simple implementation. Reads user/programN/plugins folder and
/// use
/// </summary>
void LoadPlugins()
{
var dir = Global.FilePathPrefix + "plugins";
if (Directory.Exists(dir))
{
// TODO Clear out or create localPlugins folder (maybe in program slot folder)
var irDir = Global.FilePathPrefix + "ir";
if (!Directory.Exists(irDir))
Directory.Create(irDir);
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Plugins directory found, checking for factory plugins");
var di = new DirectoryInfo(dir);
var zFiles = di.GetFiles("*.cplz");
foreach (var fi in zFiles)
{
Debug.Console(0, "Found cplz: {0}. Unzipping into plugins directory", fi.Name);
var result = CrestronZIP.Unzip(fi.FullName, di.FullName);
Debug.Console(0, "UnZip Result: {0}", result.ToString());
fi.Delete();
}
var files = di.GetFiles("*.dll");
Dictionary<string, Assembly> assyList = new Dictionary<string, Assembly>();
foreach (FileInfo fi in files)
{
// TODO COPY plugin to loadedPlugins folder
// TODO LOAD that loadedPlugins dll file
try
{
var assy = Assembly.LoadFrom(fi.FullName);
var ver = assy.GetName().Version;
var verStr = string.Format("{0}.{1}.{2}.{3}", ver.Major, ver.Minor, ver.Build, ver.Revision);
assyList.Add(fi.FullName, assy);
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loaded plugin file '{0}', version {1}", fi.FullName, verStr);
}
catch
{
Debug.Console(2, "Assembly {0} is not a custom assembly", fi.FullName);
continue; //catching any load issues and continuing. There will be exceptions loading Crestron .dlls from the cplz Probably should do something different here
}
}
foreach (var assy in assyList)
{
// iteratate this assembly's classes, looking for "LoadPlugin()" methods
try
{
var types = assy.Value.GetTypes();
foreach (var type in types)
{
try
{
var methods = type.GetMethods(BindingFlags.Public | BindingFlags.Static);
var loadPlugin = methods.FirstOrDefault(m => m.Name.Equals("LoadPlugin"));
if (loadPlugin != null)
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Adding type {0}", assy.Key, type.FullName);
loadPlugin.Invoke(null, null);
}
}
catch
{
Debug.Console(2, "Load Plugin not found. {0} is not a plugin assembly", assy.Value.FullName);
continue;
}
}
}
catch
{
Debug.Console(2, "Assembly {0} is not a custom assembly. Types cannot be loaded.", assy.Value.FullName);
continue;
}
}
// plugin dll will be loaded. Any classes in plugin should have a static constructor
// that registers that class with the Core.DeviceFactory
}
}
/// <summary>
/// Verifies filesystem is set up. IR, SGD, and programX folders
/// </summary>
bool SetupFilesystem()
{
Debug.Console(0, "Verifying and/or creating folder structure");
var configDir = Global.FilePathPrefix;
var configExists = Directory.Exists(configDir);
if (!configExists)
Directory.Create(configDir);
var irDir = Global.FilePathPrefix + "ir";
if (!Directory.Exists(irDir))
Directory.Create(irDir);
var sgdDir = Global.FilePathPrefix + "sgd";
if (!Directory.Exists(sgdDir))
Directory.Create(sgdDir);
var pluginDir = Global.FilePathPrefix + "plugins";
if (!Directory.Exists(pluginDir))
Directory.Create(pluginDir);
return configExists;
}
public void EnablePortalSync(string s)
{
if (s.ToLower() == "enable")
{
CrestronConsole.ConsoleCommandResponse("Portal Sync features enabled");
}
}
///// <summary>
/////
///// </summary>
///// <param name="s"></param>
//public void EnablePortalSync(string s)
//{
// if (s.ToLower() == "enable")
// {
// CrestronConsole.ConsoleCommandResponse("Portal Sync features enabled");
// }
//}
/// <summary>
///
/// </summary>
public void TearDown()
{
Debug.Console(0, "Tearing down existing system");
@@ -219,7 +329,7 @@ namespace PepperDash.Essentials
DeviceManager.ActivateAll();
LinkSystemMonitorToAppServer();
}
}
void LinkSystemMonitorToAppServer()
{
@@ -236,29 +346,28 @@ namespace PepperDash.Essentials
messenger.RegisterWithAppServer(appServer);
DeviceManager.AddDevice(messenger);
DeviceManager.AddDevice(messenger);
}
}
/// <summary>
/// Reads all devices from config and adds them to DeviceManager
/// </summary>
public void LoadDevices()
{
# warning Missing PepperDash.Essentials.Core.Devices.CrestronProcessor("processor"));
// Build the processor wrapper class
// DeviceManager.AddDevice(new PepperDash.Essentials.Core.Devices.CrestronProcessor("processor"));
/// <summary>
/// Reads all devices from config and adds them to DeviceManager
/// </summary>
public void LoadDevices()
{
// Build the processor wrapper class
DeviceManager.AddDevice(new PepperDash.Essentials.Core.Devices.CrestronProcessor("processor"));
// Add global System Monitor device
DeviceManager.AddDevice(new PepperDash.Essentials.Core.Monitoring.SystemMonitorController("systemMonitor"));
foreach (var devConf in ConfigReader.ConfigObject.Devices)
{
foreach (var devConf in ConfigReader.ConfigObject.Devices)
{
try
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Creating device '{0}'", devConf.Key);
// Skip this to prevent unnecessary warnings
try
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Creating device '{0}', type '{1}'", devConf.Key, devConf.Type);
// Skip this to prevent unnecessary warnings
if (devConf.Key == "processor")
{
if (devConf.Type.ToLower() != Global.ControlSystem.ControllerPrompt.ToLower())
@@ -269,13 +378,13 @@ namespace PepperDash.Essentials
continue;
}
// Try local factories first
var newDev = DeviceFactory.GetDevice(devConf);
// Try local factories first
var newDev = DeviceFactory.GetDevice(devConf);
if (newDev == null)
newDev = BridgeFactory.GetDevice(devConf);
// Then associated library factories
// Then associated library factories
if (newDev == null)
newDev = PepperDash.Essentials.Core.DeviceFactory.GetDevice(devConf);
if (newDev == null)
@@ -284,65 +393,77 @@ namespace PepperDash.Essentials
newDev = PepperDash.Essentials.DM.DeviceFactory.GetDevice(devConf);
if (newDev == null)
newDev = PepperDash.Essentials.Devices.Displays.DisplayDeviceFactory.GetDevice(devConf);
if (newDev == null)
newDev = PepperDash.Essentials.BridgeFactory.GetDevice(devConf);
//if (newDev == null) // might want to consider the ability to override an essentials "type"
//{
// // iterate plugin factories
// foreach (var f in FactoryObjects)
// {
// var cresFactory = f as IGetCrestronDevice;
// if (cresFactory != null)
// {
// newDev = cresFactory.GetDevice(devConf, this);
// }
// }
//}
if (newDev != null)
DeviceManager.AddDevice(newDev);
else
Debug.Console(0, Debug.ErrorLogLevel.Notice, "ERROR: Cannot load unknown device type '{0}', key '{1}'.", devConf.Type, devConf.Key);
}
catch (Exception e)
{
}
catch (Exception e)
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "ERROR: Creating device {0}. Skipping device. \r{1}", devConf.Key, e);
}
}
}
}
Debug.Console(0, Debug.ErrorLogLevel.Notice, "All Devices Loaded.");
}
}
/// <summary>
/// Helper method to load tie lines. This should run after devices have loaded
/// </summary>
public void LoadTieLines()
{
// In the future, we can't necessarily just clear here because devices
// might be making their own internal sources/tie lines
/// <summary>
/// Helper method to load tie lines. This should run after devices have loaded
/// </summary>
public void LoadTieLines()
{
// In the future, we can't necessarily just clear here because devices
// might be making their own internal sources/tie lines
var tlc = TieLineCollection.Default;
//tlc.Clear();
if (ConfigReader.ConfigObject.TieLines == null)
{
return;
}
var tlc = TieLineCollection.Default;
//tlc.Clear();
if (ConfigReader.ConfigObject.TieLines == null)
{
return;
}
foreach (var tieLineConfig in ConfigReader.ConfigObject.TieLines)
{
var newTL = tieLineConfig.GetTieLine();
if (newTL != null)
tlc.Add(newTL);
}
foreach (var tieLineConfig in ConfigReader.ConfigObject.TieLines)
{
var newTL = tieLineConfig.GetTieLine();
if (newTL != null)
tlc.Add(newTL);
}
Debug.Console(0, Debug.ErrorLogLevel.Notice, "All Tie Lines Loaded.");
}
}
/// <summary>
/// Reads all rooms from config and adds them to DeviceManager
/// </summary>
public void LoadRooms()
{
if (ConfigReader.ConfigObject.Rooms == null)
{
Debug.Console(0, Debug.ErrorLogLevel.Warning, "WARNING: Configuration contains no rooms");
return;
}
/// <summary>
/// Reads all rooms from config and adds them to DeviceManager
/// </summary>
public void LoadRooms()
{
if (ConfigReader.ConfigObject.Rooms == null)
{
Debug.Console(0, Debug.ErrorLogLevel.Warning, "WARNING: Configuration contains no rooms");
return;
}
foreach (var roomConfig in ConfigReader.ConfigObject.Rooms)
{
foreach (var roomConfig in ConfigReader.ConfigObject.Rooms)
{
var room = EssentialsRoomConfigHelper.GetRoomObject(roomConfig) as EssentialsRoomBase;
if (room != null)
{
if (room != null)
{
if (room is EssentialsHuddleSpaceRoom)
{
DeviceManager.AddDevice(room);
@@ -352,10 +473,10 @@ namespace PepperDash.Essentials
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to build Cotija Bridge...");
// Cotija bridge
var bridge = new CotijaEssentialsHuddleSpaceRoomBridge(room as EssentialsHuddleSpaceRoom);
AddBridgePostActivationHelper(bridge); // Lets things happen later when all devices are present
DeviceManager.AddDevice(bridge);
// Cotija bridge
var bridge = new CotijaEssentialsHuddleSpaceRoomBridge(room as EssentialsHuddleSpaceRoom);
AddBridgePostActivationHelper(bridge); // Lets things happen later when all devices are present
DeviceManager.AddDevice(bridge);
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Cotija Bridge Added...");
}
@@ -366,60 +487,60 @@ namespace PepperDash.Essentials
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Room is EssentialsHuddleVtc1Room, attempting to add to DeviceManager with Fusion");
DeviceManager.AddDevice(new EssentialsHuddleVtc1FusionController((EssentialsHuddleVtc1Room)room, 0xf1));
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to build Cotija Bridge...");
// Cotija bridge
var bridge = new CotijaEssentialsHuddleSpaceRoomBridge(room);
AddBridgePostActivationHelper(bridge); // Lets things happen later when all devices are present
DeviceManager.AddDevice(bridge);
}
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to build Cotija Bridge...");
// Cotija bridge
var bridge = new CotijaEssentialsHuddleSpaceRoomBridge(room);
AddBridgePostActivationHelper(bridge); // Lets things happen later when all devices are present
DeviceManager.AddDevice(bridge);
}
else
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Room is NOT EssentialsRoom, attempting to add to DeviceManager w/o Fusion");
DeviceManager.AddDevice(room);
}
}
else
}
else
Debug.Console(0, Debug.ErrorLogLevel.Notice, "WARNING: Cannot create room from config, key '{0}'", roomConfig.Key);
}
}
Debug.Console(0, Debug.ErrorLogLevel.Notice, "All Rooms Loaded.");
}
}
/// <summary>
/// Helps add the post activation steps that link bridges to main controller
/// </summary>
/// <param name="bridge"></param>
void AddBridgePostActivationHelper(CotijaBridgeBase bridge)
{
bridge.AddPostActivationAction(() =>
{
var parent = DeviceManager.AllDevices.FirstOrDefault(d => d.Key == "appServer") as CotijaSystemController;
if (parent == null)
{
Debug.Console(0, bridge, "ERROR: Cannot connect app server room bridge. System controller not present");
return;
}
Debug.Console(0, bridge, "Linking to parent controller");
bridge.AddParent(parent);
parent.AddBridge(bridge);
});
}
/// <summary>
/// Helps add the post activation steps that link bridges to main controller
/// </summary>
/// <param name="bridge"></param>
void AddBridgePostActivationHelper(CotijaBridgeBase bridge)
{
bridge.AddPostActivationAction(() =>
{
var parent = DeviceManager.AllDevices.FirstOrDefault(d => d.Key == "appServer") as CotijaSystemController;
if (parent == null)
{
Debug.Console(0, bridge, "ERROR: Cannot connect app server room bridge. System controller not present");
return;
}
Debug.Console(0, bridge, "Linking to parent controller");
bridge.AddParent(parent);
parent.AddBridge(bridge);
});
}
/// <summary>
/// Fires up a logo server if not already running
/// </summary>
void LoadLogoServer()
{
try
{
/// <summary>
/// Fires up a logo server if not already running
/// </summary>
void LoadLogoServer()
{
try
{
LogoServer = new HttpLogoServer(8080, Global.DirectorySeparator + "html" + Global.DirectorySeparator + "logo");
}
catch (Exception)
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "NOTICE: Logo server cannot be started. Likely already running in another program");
}
}
}
catch (Exception)
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "NOTICE: Logo server cannot be started. Likely already running in another program");
}
}
}
}

View File

@@ -43,13 +43,13 @@ namespace PepperDash.Essentials
return new Device(key, name);
}
// MOVE into something else???
else if (typeName == "basicirdisplay")
{
var ir = IRPortHelper.GetIrPort(properties);
if (ir != null)
return new BasicIrDisplay(key, name, ir.Port, ir.FileName);
}
//// MOVE into something else???
//else if (typeName == "basicirdisplay")
//{
// var ir = IRPortHelper.GetIrPort(properties);
// if (ir != null)
// return new BasicIrDisplay(key, name, ir.Port, ir.FileName);
//}
else if (typeName == "commmock")
{

View File

@@ -1,162 +1,185 @@
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.UI;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.PageManagers;
namespace PepperDash.Essentials
{
public class UiDeviceFactory
{
public static IKeyed GetUiDevice(DeviceConfig config)
{
var comm = CommFactory.GetControlPropertiesConfig(config);
var props = JsonConvert.DeserializeObject<CrestronTouchpanelPropertiesConfig>(config.Properties.ToString());
EssentialsTouchpanelController panelController = new EssentialsTouchpanelController(config.Key, config.Name, config.Type, props, comm.IpIdInt);
panelController.AddPostActivationAction(() =>
{
var mainDriver = new EssentialsPanelMainInterfaceDriver(panelController.Panel, props);
// Then the sub drivers
// spin up different room drivers depending on room type
var room = DeviceManager.GetDeviceForKey(props.DefaultRoomKey);
if (room is EssentialsHuddleSpaceRoom)
{
// Header Driver
Debug.Console(0, panelController, "Adding header driver");
mainDriver.HeaderDriver = new EssentialsHeaderDriver(mainDriver, props);
// AV Driver
Debug.Console(0, panelController, "Adding huddle space AV driver");
var avDriver = new EssentialsHuddlePanelAvFunctionsDriver(mainDriver, props);
avDriver.DefaultRoomKey = props.DefaultRoomKey;
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.UI;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.PageManagers;
using PepperDash.Essentials.DM.Endpoints.DGEs;
namespace PepperDash.Essentials
{
public class UiDeviceFactory
{
public static IKeyed GetUiDevice(DeviceConfig config)
{
var comm = CommFactory.GetControlPropertiesConfig(config);
var typeName = config.Type.ToLower();
EssentialsTouchpanelController panelController = null;
var props = JsonConvert.DeserializeObject<CrestronTouchpanelPropertiesConfig>(config.Properties.ToString());
if (typeName.Contains("dge"))
{
Dge100 dgeDevice = null;
if (typeName == "dge100")
dgeDevice = new Dge100(comm.IpIdInt, Global.ControlSystem);
else if (typeName == "dmdge200c")
dgeDevice = new DmDge200C(comm.IpIdInt, Global.ControlSystem);
var dgeController = new DgeController(config.Key, config.Name, dgeDevice, config, props);
DeviceManager.AddDevice(dgeController);
panelController = new EssentialsTouchpanelController(config.Key, config.Name, dgeController.DigitalGraphicsEngine,
props.ProjectName, props.SgdFile);
}
else
{
panelController = new EssentialsTouchpanelController(config.Key, config.Name, config.Type, props, comm.IpIdInt);
}
panelController.AddPostActivationAction(() =>
{
var mainDriver = new EssentialsPanelMainInterfaceDriver(panelController.Panel, props);
// Then the sub drivers
// spin up different room drivers depending on room type
var room = DeviceManager.GetDeviceForKey(props.DefaultRoomKey);
if (room is EssentialsHuddleSpaceRoom)
{
// Header Driver
Debug.Console(0, panelController, "Adding header driver");
mainDriver.HeaderDriver = new EssentialsHeaderDriver(mainDriver, props);
// AV Driver
Debug.Console(0, panelController, "Adding huddle space AV driver");
var avDriver = new EssentialsHuddlePanelAvFunctionsDriver(mainDriver, props);
avDriver.DefaultRoomKey = props.DefaultRoomKey;
mainDriver.AvDriver = avDriver;
avDriver.CurrentRoom = room as EssentialsHuddleSpaceRoom;
// Environment Driver
if (avDriver.CurrentRoom.PropertiesConfig.Environment != null && avDriver.CurrentRoom.PropertiesConfig.Environment.DeviceKeys.Count > 0)
{
Debug.Console(0, panelController, "Adding environment driver");
mainDriver.EnvironmentDriver = new EssentialsEnvironmentDriver(mainDriver, props);
mainDriver.EnvironmentDriver.GetDevicesFromConfig(avDriver.CurrentRoom.PropertiesConfig.Environment);
}
mainDriver.HeaderDriver.SetupHeaderButtons(avDriver, avDriver.CurrentRoom);
panelController.LoadAndShowDriver(mainDriver); // This is a little convoluted.
if (panelController.Panel is TswFt5ButtonSystem)
{
var tsw = panelController.Panel as TswFt5ButtonSystem;
// Wire up hard keys
tsw.Power.UserObject = new Action<bool>(b => { if (!b) avDriver.PowerButtonPressed(); });
//tsw.Home.UserObject = new Action<bool>(b => { if (!b) HomePressed(); });
if(mainDriver.EnvironmentDriver != null)
tsw.Lights.UserObject = new Action<bool>(b =>
{
if (!b)
{
//mainDriver.AvDriver.PopupInterlock.ShowInterlockedWithToggle(mainDriver.EnvironmentDriver.BackgroundSubpageJoin);
mainDriver.EnvironmentDriver.Toggle();
}
});
tsw.Up.UserObject = new Action<bool>(avDriver.VolumeUpPress);
tsw.Down.UserObject = new Action<bool>(avDriver.VolumeDownPress);
}
}
//else if (room is EssentialsPresentationRoom)
//{
// Debug.Console(0, panelController, "Adding presentation room driver");
// var avDriver = new EssentialsPresentationPanelAvFunctionsDriver(mainDriver, props);
// avDriver.CurrentRoom = room as EssentialsPresentationRoom;
// avDriver.DefaultRoomKey = props.DefaultRoomKey;
// mainDriver.AvDriver = avDriver ;
// mainDriver.HeaderDriver = new EssentialsHeaderDriver(mainDriver, props);
// panelController.LoadAndShowDriver(mainDriver);
// if (panelController.Panel is TswFt5ButtonSystem)
// {
// var tsw = panelController.Panel as TswFt5ButtonSystem;
// // Wire up hard keys
// tsw.Power.UserObject = new Action<bool>(b => { if (!b) avDriver.PowerButtonPressed(); });
// //tsw.Home.UserObject = new Action<bool>(b => { if (!b) HomePressed(); });
// tsw.Up.UserObject = new Action<bool>(avDriver.VolumeUpPress);
// tsw.Down.UserObject = new Action<bool>(avDriver.VolumeDownPress);
// }
//}
else if (room is EssentialsHuddleVtc1Room)
{
Debug.Console(0, panelController, "Adding huddle space VTC AV driver");
// Header Driver
mainDriver.HeaderDriver = new EssentialsHeaderDriver(mainDriver, props);
// AV Driver
var avDriver = new EssentialsHuddleVtc1PanelAvFunctionsDriver(mainDriver, props);
var codecDriver = new PepperDash.Essentials.UIDrivers.VC.EssentialsVideoCodecUiDriver(panelController.Panel, avDriver,
(room as EssentialsHuddleVtc1Room).VideoCodec, mainDriver.HeaderDriver);
avDriver.SetVideoCodecDriver(codecDriver);
avDriver.DefaultRoomKey = props.DefaultRoomKey;
// Environment Driver
if (avDriver.CurrentRoom.PropertiesConfig.Environment != null && avDriver.CurrentRoom.PropertiesConfig.Environment.DeviceKeys.Count > 0)
{
Debug.Console(0, panelController, "Adding environment driver");
mainDriver.EnvironmentDriver = new EssentialsEnvironmentDriver(mainDriver, props);
mainDriver.EnvironmentDriver.GetDevicesFromConfig(avDriver.CurrentRoom.PropertiesConfig.Environment);
}
mainDriver.HeaderDriver.SetupHeaderButtons(avDriver, avDriver.CurrentRoom);
panelController.LoadAndShowDriver(mainDriver); // This is a little convoluted.
if (panelController.Panel is TswFt5ButtonSystem)
{
var tsw = panelController.Panel as TswFt5ButtonSystem;
// Wire up hard keys
tsw.Power.UserObject = new Action<bool>(b => { if (!b) avDriver.PowerButtonPressed(); });
//tsw.Home.UserObject = new Action<bool>(b => { if (!b) HomePressed(); });
if(mainDriver.EnvironmentDriver != null)
tsw.Lights.UserObject = new Action<bool>(b =>
{
if (!b)
{
//mainDriver.AvDriver.PopupInterlock.ShowInterlockedWithToggle(mainDriver.EnvironmentDriver.BackgroundSubpageJoin);
mainDriver.EnvironmentDriver.Toggle();
}
});
tsw.Up.UserObject = new Action<bool>(avDriver.VolumeUpPress);
tsw.Down.UserObject = new Action<bool>(avDriver.VolumeDownPress);
}
}
//else if (room is EssentialsPresentationRoom)
//{
// Debug.Console(0, panelController, "Adding presentation room driver");
// var avDriver = new EssentialsPresentationPanelAvFunctionsDriver(mainDriver, props);
// avDriver.CurrentRoom = room as EssentialsPresentationRoom;
// avDriver.DefaultRoomKey = props.DefaultRoomKey;
// mainDriver.AvDriver = avDriver ;
// mainDriver.HeaderDriver = new EssentialsHeaderDriver(mainDriver, props);
// panelController.LoadAndShowDriver(mainDriver);
// if (panelController.Panel is TswFt5ButtonSystem)
// {
// var tsw = panelController.Panel as TswFt5ButtonSystem;
// // Wire up hard keys
// tsw.Power.UserObject = new Action<bool>(b => { if (!b) avDriver.PowerButtonPressed(); });
// //tsw.Home.UserObject = new Action<bool>(b => { if (!b) HomePressed(); });
// tsw.Up.UserObject = new Action<bool>(avDriver.VolumeUpPress);
// tsw.Down.UserObject = new Action<bool>(avDriver.VolumeDownPress);
// }
//}
else if (room is EssentialsHuddleVtc1Room)
{
Debug.Console(0, panelController, "Adding huddle space VTC AV driver");
// Header Driver
mainDriver.HeaderDriver = new EssentialsHeaderDriver(mainDriver, props);
// AV Driver
var avDriver = new EssentialsHuddleVtc1PanelAvFunctionsDriver(mainDriver, props);
var codecDriver = new PepperDash.Essentials.UIDrivers.VC.EssentialsVideoCodecUiDriver(panelController.Panel, avDriver,
(room as EssentialsHuddleVtc1Room).VideoCodec, mainDriver.HeaderDriver);
avDriver.SetVideoCodecDriver(codecDriver);
avDriver.DefaultRoomKey = props.DefaultRoomKey;
mainDriver.AvDriver = avDriver;
avDriver.CurrentRoom = room as EssentialsHuddleVtc1Room;
// Environment Driver
if (avDriver.CurrentRoom.PropertiesConfig.Environment != null && avDriver.CurrentRoom.PropertiesConfig.Environment.DeviceKeys.Count > 0)
{
Debug.Console(0, panelController, "Adding environment driver");
mainDriver.EnvironmentDriver = new EssentialsEnvironmentDriver(mainDriver, props);
mainDriver.EnvironmentDriver.GetDevicesFromConfig(avDriver.CurrentRoom.PropertiesConfig.Environment);
}
mainDriver.HeaderDriver.SetupHeaderButtons(avDriver, avDriver.CurrentRoom);
panelController.LoadAndShowDriver(mainDriver); // This is a little convoluted.
if (panelController.Panel is TswFt5ButtonSystem)
{
var tsw = panelController.Panel as TswFt5ButtonSystem;
// Wire up hard keys
tsw.Power.UserObject = new Action<bool>(b => { if (!b) avDriver.EndMeetingPress(); });
//tsw.Home.UserObject = new Action<bool>(b => { if (!b) HomePressed(); });
if (mainDriver.EnvironmentDriver != null)
tsw.Lights.UserObject = new Action<bool>(b =>
{
if (!b)
{
//mainDriver.AvDriver.PopupInterlock.ShowInterlockedWithToggle(mainDriver.EnvironmentDriver.BackgroundSubpageJoin);
mainDriver.EnvironmentDriver.Toggle();
}
});
tsw.Up.UserObject = new Action<bool>(avDriver.VolumeUpPress);
tsw.Down.UserObject = new Action<bool>(avDriver.VolumeDownPress);
}
}
else
{
Debug.Console(0, panelController, "ERROR: Cannot load AvFunctionsDriver for room '{0}'", props.DefaultRoomKey);
}
});
return panelController;
}
}
avDriver.CurrentRoom = room as EssentialsHuddleVtc1Room;
// Environment Driver
if (avDriver.CurrentRoom.PropertiesConfig.Environment != null && avDriver.CurrentRoom.PropertiesConfig.Environment.DeviceKeys.Count > 0)
{
Debug.Console(0, panelController, "Adding environment driver");
mainDriver.EnvironmentDriver = new EssentialsEnvironmentDriver(mainDriver, props);
mainDriver.EnvironmentDriver.GetDevicesFromConfig(avDriver.CurrentRoom.PropertiesConfig.Environment);
}
mainDriver.HeaderDriver.SetupHeaderButtons(avDriver, avDriver.CurrentRoom);
panelController.LoadAndShowDriver(mainDriver); // This is a little convoluted.
if (panelController.Panel is TswFt5ButtonSystem)
{
var tsw = panelController.Panel as TswFt5ButtonSystem;
// Wire up hard keys
tsw.Power.UserObject = new Action<bool>(b => { if (!b) avDriver.EndMeetingPress(); });
//tsw.Home.UserObject = new Action<bool>(b => { if (!b) HomePressed(); });
if (mainDriver.EnvironmentDriver != null)
tsw.Lights.UserObject = new Action<bool>(b =>
{
if (!b)
{
//mainDriver.AvDriver.PopupInterlock.ShowInterlockedWithToggle(mainDriver.EnvironmentDriver.BackgroundSubpageJoin);
mainDriver.EnvironmentDriver.Toggle();
}
});
tsw.Up.UserObject = new Action<bool>(avDriver.VolumeUpPress);
tsw.Down.UserObject = new Action<bool>(avDriver.VolumeDownPress);
}
}
else
{
Debug.Console(0, panelController, "ERROR: Cannot load AvFunctionsDriver for room '{0}'", props.DefaultRoomKey);
}
});
return panelController;
}
}
}

View File

@@ -48,27 +48,27 @@
<ItemGroup>
<Reference Include="Crestron.SimplSharpPro.DeviceSupport, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll</HintPath>
<HintPath>..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll</HintPath>
</Reference>
<Reference Include="Crestron.SimplSharpPro.DM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DM.dll</HintPath>
<HintPath>..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DM.dll</HintPath>
</Reference>
<Reference Include="Crestron.SimplSharpPro.EthernetCommunications, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.EthernetCommunications.dll</HintPath>
<HintPath>..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.EthernetCommunications.dll</HintPath>
</Reference>
<Reference Include="Crestron.SimplSharpPro.Fusion, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Fusion.dll</HintPath>
<HintPath>..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Fusion.dll</HintPath>
</Reference>
<Reference Include="Crestron.SimplSharpPro.Remotes, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Remotes.dll</HintPath>
<HintPath>..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Remotes.dll</HintPath>
</Reference>
<Reference Include="Crestron.SimplSharpPro.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll</HintPath>
<HintPath>..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll</HintPath>
</Reference>
<Reference Include="mscorlib" />
<Reference Include="PepperDash_Core, Version=1.0.3.27452, Culture=neutral, processorArchitecture=MSIL">
@@ -81,42 +81,46 @@
</Reference>
<Reference Include="SimplSharpCustomAttributesInterface, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll</HintPath>
<HintPath>..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll</HintPath>
</Reference>
<Reference Include="SimplSharpHelperInterface, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll</HintPath>
<HintPath>..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll</HintPath>
</Reference>
<Reference Include="SimplSharpNewtonsoft, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpNewtonsoft.dll</HintPath>
<HintPath>..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpNewtonsoft.dll</HintPath>
</Reference>
<Reference Include="SimplSharpPro, Version=1.5.2.0, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
<Reference Include="SimplSharpPro, Version=1.5.3.17, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe</HintPath>
<HintPath>..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe</HintPath>
</Reference>
<Reference Include="SimplSharpReflectionInterface, Version=1.0.5583.25238, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpReflectionInterface.dll</HintPath>
<HintPath>..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpReflectionInterface.dll</HintPath>
</Reference>
<Reference Include="SimplSharpTimerEventInterface, Version=1.0.6197.20052, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpTimerEventInterface.dll</HintPath>
<HintPath>..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpTimerEventInterface.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
</ItemGroup>
<ItemGroup>
<Compile Include="AppServer\Messengers\AtcDdvc01Messenger.cs" />
<Compile Include="AppServer\Messengers\ConfigMessenger.cs" />
<Compile Include="AppServer\Messengers\Ddvc01AtcMessenger.cs" />
<Compile Include="AppServer\Messengers\AudioCodecBaseMessenger.cs" />
<Compile Include="AppServer\Messengers\Ddvc01VtcMessenger.cs" />
<Compile Include="AppServer\Messengers\MessengerBase.cs" />
<Compile Include="AppServer\Messengers\SystemMonitorMessenger.cs" />
<Compile Include="AppServer\Messengers\VideoCodecBaseMessenger.cs" />
<Compile Include="Audio\EssentialsVolumeLevelConfig.cs" />
<Compile Include="Bridges\AppleTvBridge.cs" />
<Compile Include="Bridges\BridgeBase.cs" />
<Compile Include="Bridges\BridgeFactory.cs" />
<Compile Include="Bridges\CameraControllerBridge.cs" />
<Compile Include="Bridges\AirMediaControllerBridge.cs" />
<Compile Include="Bridges\DisplayControllerBridge.cs" />
<Compile Include="Bridges\DigitalLoggerBridge.cs" />
<Compile Include="Bridges\DmChassisControllerBridge.cs" />
@@ -125,6 +129,7 @@
<Compile Include="Bridges\GenericRelayDeviceBridge.cs" />
<Compile Include="Bridges\IBasicCommunicationBridge.cs" />
<Compile Include="Bridges\DmRmcControllerBridge.cs" />
<Compile Include="Bridges\IBridge.cs" />
<Compile Include="Bridges\IDigitalInputBridge.cs" />
<Compile Include="Bridges\JoinMapBase.cs" />
<Compile Include="Bridges\SystemMonitorBridge.cs" />
@@ -219,7 +224,6 @@
<Compile Include="AppServer\CotijaSystemController.cs" />
<Compile Include="UI\DualDisplaySourceSRLController.cs" />
<Compile Include="UI\SubpageReferenceListActivityItem.cs" />
<Compile Include="UI\CrestronTouchpanelPropertiesConfig.cs" />
<Compile Include="FOR REFERENCE UI\Panels\REMOVE UiCue.cs" />
<Compile Include="FOR REFERENCE UI\SRL\SourceListSubpageReferenceList.cs" />
<Compile Include="Room\Types\EssentialsHuddleSpaceRoom.cs" />
@@ -227,9 +231,15 @@
<Compile Include="UI\SubpageReferenceListSourceItem.cs" />
<None Include="app.config" />
<None Include="Properties\ControlSystem.cfg" />
<EmbeddedResource Include="SGD\PepperDash Essentials iPad.sgd" />
<EmbeddedResource Include="SGD\PepperDash Essentials TSW-560.sgd" />
<EmbeddedResource Include="SGD\PepperDash Essentials TSW-760.sgd" />
<EmbeddedResource Include="SGD\PepperDash Essentials iPad.sgd">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="SGD\PepperDash Essentials TSW-560.sgd">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="SGD\PepperDash Essentials TSW-760.sgd">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\essentials-framework\Essentials Core\PepperDashEssentialsBase\PepperDash_Essentials_Core.csproj">

View File

@@ -4,5 +4,5 @@
[assembly: AssemblyCompany("PepperDash Technology Corp")]
[assembly: AssemblyProduct("PepperDashEssentials")]
[assembly: AssemblyCopyright("Copyright © PepperDash Technology Corp 2018")]
[assembly: AssemblyVersion("1.3.1.*")]
[assembly: AssemblyVersion("1.4.0.*")]

View File

@@ -0,0 +1,35 @@
function Update-SourceVersion
{
Param ([string]$Version)
$NewVersion = AssemblyVersion(" + $Version + .*");
foreach ($o in $input)
{
Write-output $o.FullName
$TmpFile = $o.FullName + .tmp
get-content $o.FullName |
%{$_ -replace AssemblyVersion\("(\d+\.\d+\.\d+)\.\*"\), $NewVersion } > $TmpFile
move-item $TmpFile $o.FullName -force
}
}
function Update-AllAssemblyInfoFiles ( $version )
{
foreach ($file in AssemblyInfo.cs, AssemblyInfo.vb )
{
get-childitem -recurse |? {$_.Name -eq $file} | Update-SourceVersion $version ;
}
}
# validate arguments
$r= [System.Text.RegularExpressions.Regex]::Match($args[0], "^\d+\.\d+\.\d+$");
if ($r.Success)
{
Update-AllAssemblyInfoFiles $args[0];
}
else
{
echo ;
echo Error: Input version does not match x.y.z format!
echo ;
echo "Unable to apply version to AssemblyInfo.cs files";
}

View File

@@ -71,7 +71,7 @@ namespace PepperDash.Essentials.Room.Config
var microphonePrivacy = props.MicrophonePrivacy;
if (microphonePrivacy == null)
{
Debug.Console(0, "ERROR: Cannot create microphone privacy with null properties");
Debug.Console(0, "Cannot create microphone privacy with null properties");
return null;
}
// Get the MicrophonePrivacy device from the device manager

View File

@@ -13,7 +13,7 @@ using PepperDash.Essentials.Room.Config;
namespace PepperDash.Essentials
{
public class EssentialsHuddleSpaceRoom : EssentialsRoomBase, IHasCurrentSourceInfoChange, IRunRouteAction, IRunDefaultPresentRoute
public class EssentialsHuddleSpaceRoom : EssentialsRoomBase, IHasCurrentSourceInfoChange, IRunRouteAction, IRunDefaultPresentRoute, IHasCurrentVolumeControls
{
public event EventHandler<VolumeDeviceChangeEventArgs> CurrentVolumeDeviceChange;
public event SourceInfoChangeHandler CurrentSingleSourceChange;

View File

@@ -266,6 +266,16 @@ namespace PepperDash.Essentials
{
IsCoolingDownFeedback.FireUpdate();
};
// Get Microphone Privacy object, if any
this.MicrophonePrivacy = EssentialsRoomConfigHelper.GetMicrophonePrivacy(PropertiesConfig, this);
Debug.Console(2, this, "Microphone Privacy Config evaluated.");
// Get emergency object, if any
this.Emergency = EssentialsRoomConfigHelper.GetEmergency(PropertiesConfig, this);
Debug.Console(2, this, "Emergency Config evaluated.");
}
@@ -279,7 +289,7 @@ namespace PepperDash.Essentials
inAudioCall = AudioCodec.IsInCall;
if(VideoCodec != null)
inVideoCall = AudioCodec.IsInCall;
inVideoCall = VideoCodec.IsInCall;
if (inAudioCall || inVideoCall)
return true;
@@ -327,12 +337,6 @@ namespace PepperDash.Essentials
this.DefaultSourceItem = PropertiesConfig.DefaultSourceItem;
this.DefaultVolume = (ushort)(PropertiesConfig.Volumes.Master.Level * 65535 / 100);
// Get Microphone Privacy object, if any
this.MicrophonePrivacy = EssentialsRoomConfigHelper.GetMicrophonePrivacy(PropertiesConfig, this);
// Get emergency object, if any
this.Emergency = EssentialsRoomConfigHelper.GetEmergency(PropertiesConfig, this);
return base.CustomActivate();
}

View File

@@ -1,48 +0,0 @@
namespace PepperDash.Essentials
{
public class CrestronTouchpanelPropertiesConfig
{
public string IpId { get; set; }
public string DefaultRoomKey { get; set; }
public string RoomListKey { get; set; }
public string SgdFile { get; set; }
public string ProjectName { get; set; }
public bool ShowVolumeGauge { get; set; }
public bool UsesSplashPage { get; set; }
public bool ShowDate { get; set; }
public bool ShowTime { get; set; }
public UiSetupPropertiesConfig Setup { get; set; }
public string HeaderStyle { get; set; }
public bool IncludeInFusionRoomHealth { get; set; }
/// <summary>
/// The count of sources that will trigger the "additional" arrows to show on the SRL.
/// Defaults to 5
/// </summary>
public int SourcesOverflowCount { get; set; }
public CrestronTouchpanelPropertiesConfig()
{
SourcesOverflowCount = 5;
HeaderStyle = CrestronTouchpanelPropertiesConfig.Habanero;
}
/// <summary>
/// "habanero"
/// </summary>
public const string Habanero = "habanero";
/// <summary>
/// "verbose"
/// </summary>
public const string Verbose = "verbose";
}
/// <summary>
///
/// </summary>
public class UiSetupPropertiesConfig
{
public bool IsVisible { get; set; }
}
}

View File

@@ -27,9 +27,17 @@ namespace PepperDash.Essentials
{
Panel = tsw;
tsw.LoadSmartObjects(sgdPath);
tsw.SigChange += new Crestron.SimplSharpPro.DeviceSupport.SigEventHandler(Tsw_SigChange);
tsw.SigChange += Panel_SigChange;
}
public EssentialsTouchpanelController(string key, string name, Dge100 panel, string projectName, string sgdPath)
: base(key, name)
{
Panel = panel;
panel.LoadSmartObjects(sgdPath);
panel.SigChange += Panel_SigChange;
}
/// <summary>
/// Config constructor
/// </summary>
@@ -102,7 +110,7 @@ namespace PepperDash.Essentials
}
Panel.LoadSmartObjects(sgdName);
Panel.SigChange += Tsw_SigChange;
Panel.SigChange += Panel_SigChange;
}
@@ -158,7 +166,7 @@ namespace PepperDash.Essentials
}
}
void Tsw_SigChange(object currentDevice, Crestron.SimplSharpPro.SigEventArgs args)
void Panel_SigChange(object currentDevice, Crestron.SimplSharpPro.SigEventArgs args)
{
if (Debug.Level == 2)
Debug.Console(2, this, "Sig change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue);

View File

@@ -927,7 +927,10 @@ namespace PepperDash.Essentials
_CurrentRoom.CurrentSingleSourceChange += CurrentRoom_SourceInfoChange;
RefreshSourceInfo();
(_CurrentRoom.VideoCodec as IHasScheduleAwareness).CodecSchedule.MeetingsListHasChanged += CodecSchedule_MeetingsListHasChanged;
if (_CurrentRoom.VideoCodec is IHasScheduleAwareness)
{
(_CurrentRoom.VideoCodec as IHasScheduleAwareness).CodecSchedule.MeetingsListHasChanged += CodecSchedule_MeetingsListHasChanged;
}
CallSharingInfoVisibleFeedback = new BoolFeedback(() => _CurrentRoom.VideoCodec.SharingContentIsOnFeedback.BoolValue);
_CurrentRoom.VideoCodec.SharingContentIsOnFeedback.OutputChange += SharingContentIsOnFeedback_OutputChange;

View File

@@ -58,16 +58,7 @@ namespace PepperDash.Essentials.UIDrivers.VC
SmartObjectDynamicList RecentCallsList;
SmartObjectDynamicList DirectoryList;
CodecDirectory CurrentDirectoryResult;
/// <summary>
/// Tracks the directory browse history when browsing beyond the root directory
/// </summary>
List<CodecDirectory> DirectoryBrowseHistory;
bool NextDirectoryResultIsFolderContents;
BoolFeedback DirectoryBackButtonVisibleFeedback;
// These are likely temp until we get a keyboard built
@@ -111,7 +102,6 @@ namespace PepperDash.Essentials.UIDrivers.VC
SetupCallStagingPopover();
SetupDialKeypad();
ActiveCallsSRL = new SubpageReferenceList(triList, UISmartObjectJoin.CodecActiveCallsHeaderList, 5,5,5);
SetupDirectoryList();
SetupRecentCallsList();
SetupFavorites();
SetupLayoutControls();
@@ -169,12 +159,14 @@ namespace PepperDash.Essentials.UIDrivers.VC
});
SearchStringFeedback.LinkInputSig(triList.StringInput[UIStringJoin.CodecDirectorySearchEntryText]);
SetupDirectoryList();
SearchStringBackspaceVisibleFeedback = new BoolFeedback(() => SearchStringBuilder.Length > 0);
SearchStringBackspaceVisibleFeedback.LinkInputSig(triList.BooleanInput[UIBoolJoin.VCDirectoryBackspaceVisible]);
triList.SetSigFalseAction(UIBoolJoin.VCDirectoryBackPress, GetDirectoryParentFolderContents);
DirectoryBackButtonVisibleFeedback = new BoolFeedback(() => CurrentDirectoryResult != (codec as IHasDirectory).DirectoryRoot);
DirectoryBackButtonVisibleFeedback = (codec as IHasDirectory).CurrentDirectoryResultIsNotDirectoryRoot;
DirectoryBackButtonVisibleFeedback
.LinkInputSig(triList.BooleanInput[UIBoolJoin.VCDirectoryBackVisible]);
@@ -532,8 +524,6 @@ namespace PepperDash.Essentials.UIDrivers.VC
/// </summary>
void SetupDirectoryList()
{
DirectoryBrowseHistory = new List<CodecDirectory>();
var codec = Codec as IHasDirectory;
if (codec != null)
{
@@ -548,28 +538,20 @@ namespace PepperDash.Essentials.UIDrivers.VC
codec.PhonebookSyncState.InitialSyncCompleted += new EventHandler<EventArgs>(PhonebookSyncState_InitialSyncCompleted);
}
// If there is something here now, show it otherwise wait for the event
if (CurrentDirectoryResult != null && codec.DirectoryRoot.DirectoryResults.Count > 0)
{
RefreshDirectory();
}
RefreshDirectory();
}
}
/// <summary>
/// Sets the current directory resutls to the DirectorRoot and updates Back Button visibiltiy
/// Sets the current directory results to the DirectoryRoot and updates Back Button visibiltiy
/// </summary>
void SetCurrentDirectoryToRoot()
{
DirectoryBrowseHistory.Clear();
CurrentDirectoryResult = (Codec as IHasDirectory).DirectoryRoot;
(Codec as IHasDirectory).SetCurrentDirectoryToRoot();
SearchKeypadClear();
DirectoryBackButtonVisibleFeedback.FireUpdate();
RefreshDirectory();
}
@@ -584,10 +566,8 @@ namespace PepperDash.Essentials.UIDrivers.VC
SetCurrentDirectoryToRoot();
if (CurrentDirectoryResult != null && codec.DirectoryRoot.DirectoryResults.Count > 0)
{
RefreshDirectory();
}
RefreshDirectory();
}
/// <summary>
@@ -597,13 +577,7 @@ namespace PepperDash.Essentials.UIDrivers.VC
/// <param name="e"></param>
void dir_DirectoryResultReturned(object sender, DirectoryEventArgs e)
{
if (NextDirectoryResultIsFolderContents)
{
NextDirectoryResultIsFolderContents = false;
DirectoryBrowseHistory.Add(e.Directory);
}
CurrentDirectoryResult = e.Directory;
DirectoryBackButtonVisibleFeedback.FireUpdate();
RefreshDirectory();
}
@@ -615,7 +589,6 @@ namespace PepperDash.Essentials.UIDrivers.VC
{
(Codec as IHasDirectory).GetDirectoryFolderContents(folder.FolderId);
NextDirectoryResultIsFolderContents = true;
}
/// <summary>
@@ -625,18 +598,13 @@ namespace PepperDash.Essentials.UIDrivers.VC
{
var codec = Codec as IHasDirectory;
if (DirectoryBrowseHistory.Count > 0)
if (codec != null)
{
var lastItemIndex = DirectoryBrowseHistory.Count - 1;
CurrentDirectoryResult = DirectoryBrowseHistory[lastItemIndex];
DirectoryBrowseHistory.Remove(DirectoryBrowseHistory[lastItemIndex]);
codec.GetDirectoryParentFolderContents();
RefreshDirectory();
}
else
{
SetCurrentDirectoryToRoot();
//RefreshDirectory();
}
}
/// <summary>
@@ -645,10 +613,10 @@ namespace PepperDash.Essentials.UIDrivers.VC
/// <param name="dir"></param>
void RefreshDirectory()
{
if (CurrentDirectoryResult.DirectoryResults.Count > 0)
if ((Codec as IHasDirectory).CurrentDirectoryResult.CurrentDirectoryResults.Count > 0)
{
ushort i = 0;
foreach (var r in CurrentDirectoryResult.DirectoryResults)
foreach (var r in (Codec as IHasDirectory).CurrentDirectoryResult.CurrentDirectoryResults)
{
if (i == DirectoryList.MaxCount)
{
@@ -725,13 +693,13 @@ namespace PepperDash.Essentials.UIDrivers.VC
Parent.MeetingOrContactMethodModalSrl.StringInputSig(i, 4).StringValue = "";
Parent.MeetingOrContactMethodModalSrl.StringInputSig(i, 5).StringValue = "Connect";
Parent.MeetingOrContactMethodModalSrl.BoolInputSig(i, 2).BoolValue = true;
var cc = c; // lambda scope
var cc = c; // to maintian lambda scope
Parent.MeetingOrContactMethodModalSrl.GetBoolFeedbackSig(i, 1).SetSigFalseAction(() =>
{
Parent.PopupInterlock.Hide();
var codec = Codec as VideoCodecBase;
if (codec != null)
codec.Dial(c.Number);
codec.Dial(cc.Number);
});
}
Parent.MeetingOrContactMethodModalSrl.Count = i;
@@ -744,10 +712,10 @@ namespace PepperDash.Essentials.UIDrivers.VC
void SetupLayoutControls()
{
TriList.SetSigFalseAction(UIBoolJoin.VCStagingSelfViewLayoutPress, this.ShowSelfViewLayout);
var svc = Codec as IHasCodecSelfview;
var svc = Codec as IHasCodecSelfView;
if (svc != null)
{
TriList.SetSigFalseAction(UIBoolJoin.VCSelfViewTogglePress, svc.SelfviewModeToggle);
TriList.SetSigFalseAction(UIBoolJoin.VCSelfViewTogglePress, svc.SelfViewModeToggle);
svc.SelfviewIsOnFeedback.LinkInputSig(TriList.BooleanInput[UIBoolJoin.VCSelfViewTogglePress]);
}
var lc = Codec as IHasCodecLayouts;
@@ -1102,7 +1070,7 @@ namespace PepperDash.Essentials.UIDrivers.VC
SearchStringFeedback.FireUpdate();
SearchStringKeypadCheckEnables();
if(CurrentDirectoryResult != (Codec as IHasDirectory).DirectoryRoot)
if ((Codec as IHasDirectory).CurrentDirectoryResultIsNotDirectoryRoot.BoolValue)
SetCurrentDirectoryToRoot();
}

13
README.md Normal file
View File

@@ -0,0 +1,13 @@
# Pepperdash Essentials
## RELEASE PROCESS CONTROLLED BY JENKINS CI PROCESS
#### How to merge
- Make changes
- Build
- Test on your system
- Commit and push to essentials
- Curse a whole lot when you try to figure out how to then get developments all synced up

View File

@@ -30,4 +30,12 @@ devjson:1 {"deviceKey":"room1.InCallFeedback","methodName":"SetTestValue", "para
devjson:1 {"deviceKey":"room1.InCallFeedback","methodName":"ClearTestValue", "params": []}
devjson:3 {"deviceKey":"room1.RoomOccupancy.RoomIsOccupiedFeedback","methodName":"SetTestValue", "params": [ true ]}
devjson:3 {"deviceKey":"room1.RoomOccupancy.RoomIsOccupiedFeedback","methodName":"SetTestValue", "params": [ true ]}
devjson:2 {"deviceKey":"codec-comms-ssh", "methodName":"SendText", "params": ["xcommand dial number: 10.11.50.211\r"]}
devjson:2 {"deviceKey":"codec-comms-ssh", "methodName":"Connect", "params": []}
devjson:1 {"deviceKey":"commBridge", "methodName":"ExecuteJoinAction", "params":[ 301, "digital", true ]}
devjson:2 {"deviceKey":"display01Comm-com", "methodName":"SendText", "params": [ "I'M GETTING TIRED OF THIS" ]}

View File

@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PepperDash_Essentials_Core", "PepperDashEssentialsBase\PepperDash_Essentials_Core.csproj", "{A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,100 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DM;
using PepperDash.Core;
namespace PepperDash.Essentials.Core
{
public class CecPortController : Device, IBasicCommunication
{
public event EventHandler<GenericCommMethodReceiveBytesArgs> BytesReceived;
public event EventHandler<GenericCommMethodReceiveTextArgs> TextReceived;
public bool IsConnected { get { return true; } }
ICec Port;
public CecPortController(string key, ICec port)
: base(key)
{
Port = port;
Port.StreamCec.CecChange += new CecChangeEventHandler(StreamCec_CecChange);
}
void StreamCec_CecChange(Cec cecDevice, CecEventArgs args)
{
if (args.EventId == CecEventIds.CecMessageReceivedEventId)
OnDataReceived(cecDevice.Received.StringValue);
else if (args.EventId == CecEventIds.ErrorFeedbackEventId)
if(cecDevice.ErrorFeedback.BoolValue)
Debug.Console(2, this, "CEC NAK Error");
}
void OnDataReceived(string s)
{
var bytesHandler = BytesReceived;
if (bytesHandler != null)
{
var bytes = Encoding.GetEncoding(28591).GetBytes(s);
bytesHandler(this, new GenericCommMethodReceiveBytesArgs(bytes));
}
var textHandler = TextReceived;
if (textHandler != null)
textHandler(this, new GenericCommMethodReceiveTextArgs(s));
}
#region IBasicCommunication Members
public void SendText(string text)
{
if (Port == null)
return;
Port.StreamCec.Send.StringValue = text;
}
public void SendBytes(byte[] bytes)
{
if (Port == null)
return;
var text = Encoding.GetEncoding(28591).GetString(bytes, 0, bytes.Length);
Port.StreamCec.Send.StringValue = text;
}
public void Connect()
{
}
public void Disconnect()
{
}
#endregion
/// <summary>
///
/// </summary>
/// <param name="s"></param>
public void SimulateReceive(string s)
{
// split out hex chars and build string
var split = Regex.Split(s, @"(\\[Xx][0-9a-fA-F][0-9a-fA-F])");
StringBuilder b = new StringBuilder();
foreach (var t in split)
{
if (t.StartsWith(@"\") && t.Length == 4)
b.Append((char)(Convert.ToByte(t.Substring(2, 2), 16)));
else
b.Append(t);
}
OnDataReceived(b.ToString());
}
}
}

View File

@@ -0,0 +1,132 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using PepperDash.Core;
namespace PepperDash.Essentials.Core
{
public class ComPortController : Device, IBasicCommunication
{
public event EventHandler<GenericCommMethodReceiveBytesArgs> BytesReceived;
public event EventHandler<GenericCommMethodReceiveTextArgs> TextReceived;
public bool IsConnected { get { return true; } }
ComPort Port;
ComPort.ComPortSpec Spec;
public ComPortController(string key, ComPort port, ComPort.ComPortSpec spec)
: base(key)
{
if (port == null)
{
Debug.Console(0, this, "ERROR: Invalid com port, continuing but comms will not function");
return;
}
Port = port;
Spec = spec;
//IsConnected = new BoolFeedback(CommonBoolCue.IsConnected, () => true);
if (Port.Parent is CrestronControlSystem)
{
var result = Port.Register();
if (result != eDeviceRegistrationUnRegistrationResponse.Success)
{
Debug.Console(0, this, "ERROR: Cannot register Com port: {0}", result);
return; // false
}
}
var specResult = Port.SetComPortSpec(Spec);
if (specResult != 0)
{
Debug.Console(0, this, "WARNING: Cannot set comspec");
return; // false
}
Port.SerialDataReceived += new ComPortDataReceivedEvent(Port_SerialDataReceived);
}
~ComPortController()
{
Port.SerialDataReceived -= Port_SerialDataReceived;
}
void Port_SerialDataReceived(ComPort ReceivingComPort, ComPortSerialDataEventArgs args)
{
OnDataReceived(args.SerialData);
}
void OnDataReceived(string s)
{
var bytesHandler = BytesReceived;
if (bytesHandler != null)
{
var bytes = Encoding.GetEncoding(28591).GetBytes(s);
bytesHandler(this, new GenericCommMethodReceiveBytesArgs(bytes));
}
var textHandler = TextReceived;
if (textHandler != null)
textHandler(this, new GenericCommMethodReceiveTextArgs(s));
}
public override bool Deactivate()
{
return Port.UnRegister() == eDeviceRegistrationUnRegistrationResponse.Success;
}
#region IBasicCommunication Members
public void SendText(string text)
{
if (Port == null)
return;
Port.Send(text);
}
public void SendBytes(byte[] bytes)
{
if (Port == null)
return;
var text = Encoding.GetEncoding(28591).GetString(bytes, 0, bytes.Length);
Port.Send(text);
}
public void Connect()
{
}
public void Disconnect()
{
}
#endregion
/// <summary>
///
/// </summary>
/// <param name="s"></param>
public void SimulateReceive(string s)
{
// split out hex chars and build string
var split = Regex.Split(s, @"(\\[Xx][0-9a-fA-F][0-9a-fA-F])");
StringBuilder b = new StringBuilder();
foreach (var t in split)
{
if (t.StartsWith(@"\") && t.Length == 4)
b.Append((char)(Convert.ToByte(t.Substring(2, 2), 16)));
else
b.Append(t);
}
OnDataReceived(b.ToString());
}
}
}

View File

@@ -0,0 +1,102 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
namespace PepperDash.Essentials.Core
{
/// <summary>
/// This converter creates a proper ComPort.ComPortSpec struct from more-friendly JSON values. It uses
/// ComSpecPropsJsonConverter to finish the individual properties.
/// </summary>
public class ComSpecJsonConverter : JsonConverter
{
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
if (objectType == typeof(ComPort.ComPortSpec))
{
var newSer = new JsonSerializer();
newSer.Converters.Add(new ComSpecPropsJsonConverter());
newSer.ObjectCreationHandling = ObjectCreationHandling.Replace;
return newSer.Deserialize<ComPort.ComPortSpec>(reader);
}
return null;
}
/// <summary>
///
/// </summary>
public override bool CanConvert(Type objectType)
{
return objectType == typeof(ComPort.ComPortSpec);
}
public override bool CanRead { get { return true; } }
/// <summary>
/// This converter will not be used for writing
/// </summary>
public override bool CanWrite { get { return false; } }
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
throw new NotImplementedException();
}
}
/// <summary>
/// The gist of this converter: The comspec JSON comes in with normal values that need to be converted
/// into enum names. This converter takes the value and applies the appropriate enum's name prefix to the value
/// and then returns the enum value using Enum.Parse. NOTE: Does not write
/// </summary>
public class ComSpecPropsJsonConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
return objectType == typeof(ComPort.eComBaudRates)
|| objectType == typeof(ComPort.eComDataBits)
|| objectType == typeof(ComPort.eComParityType)
|| objectType == typeof(ComPort.eComHardwareHandshakeType)
|| objectType == typeof(ComPort.eComSoftwareHandshakeType)
|| objectType == typeof(ComPort.eComProtocolType)
|| objectType == typeof(ComPort.eComStopBits);
}
public override bool CanRead { get { return true; } }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
//Debug.Console(2, "ReadJson type: " + objectType.Name);
if (objectType == typeof(ComPort.eComBaudRates))
return Enum.Parse(typeof(ComPort.eComBaudRates), "ComspecBaudRate" + reader.Value, false);
else if (objectType == typeof(ComPort.eComDataBits))
return Enum.Parse(typeof(ComPort.eComDataBits), "ComspecDataBits" + reader.Value, true);
else if (objectType == typeof(ComPort.eComHardwareHandshakeType))
return Enum.Parse(typeof(ComPort.eComHardwareHandshakeType), "ComspecHardwareHandshake" + reader.Value, true);
else if (objectType == typeof(ComPort.eComParityType))
return Enum.Parse(typeof(ComPort.eComParityType), "ComspecParity" + reader.Value, true);
else if (objectType == typeof(ComPort.eComProtocolType))
return Enum.Parse(typeof(ComPort.eComProtocolType), "ComspecProtocol" + reader.Value, true);
else if (objectType == typeof(ComPort.eComSoftwareHandshakeType))
return Enum.Parse(typeof(ComPort.eComSoftwareHandshakeType), "ComspecSoftwareHandshake" + reader.Value, true);
else if (objectType == typeof(ComPort.eComStopBits))
return Enum.Parse(typeof(ComPort.eComStopBits), "ComspecStopBits" + reader.Value, true);
return null;
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,196 @@
using System;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DM;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Essentials.Core.Config;
namespace PepperDash.Essentials.Core
{
/// <summary>
///
/// </summary>
public class CommFactory
{
public static EssentialsControlPropertiesConfig GetControlPropertiesConfig(DeviceConfig deviceConfig)
{
try
{
return JsonConvert.DeserializeObject<EssentialsControlPropertiesConfig>
(deviceConfig.Properties["control"].ToString());
//Debug.Console(2, "Control TEST: {0}", JsonConvert.SerializeObject(controlConfig));
}
catch (Exception e)
{
Debug.Console(0, "ERROR: [{0}] Control properties deserialize failed:\r{1}", deviceConfig.Key, e);
return null;
}
}
/// <summary>
/// Returns a comm method of either com port, TCP, SSH, and puts this into the DeviceManager
/// </summary>
/// <param name="deviceConfig">The Device config object</param>
public static IBasicCommunication CreateCommForDevice(DeviceConfig deviceConfig)
{
EssentialsControlPropertiesConfig controlConfig = GetControlPropertiesConfig(deviceConfig);
if (controlConfig == null)
return null;
IBasicCommunication comm = null;
try
{
var c = controlConfig.TcpSshProperties;
switch (controlConfig.Method)
{
case eControlMethod.Com:
comm = new ComPortController(deviceConfig.Key + "-com", GetComPort(controlConfig), controlConfig.ComParams);
break;
case eControlMethod.Cec:
comm = new CecPortController(deviceConfig.Key + "-cec", GetCecPort(controlConfig));
break;
case eControlMethod.IR:
break;
case eControlMethod.Ssh:
{
var ssh = new GenericSshClient(deviceConfig.Key + "-ssh", c.Address, c.Port, c.Username, c.Password);
ssh.AutoReconnect = c.AutoReconnect;
if(ssh.AutoReconnect)
ssh.AutoReconnectIntervalMs = c.AutoReconnectIntervalMs;
comm = ssh;
break;
}
case eControlMethod.Tcpip:
{
var tcp = new GenericTcpIpClient(deviceConfig.Key + "-tcp", c.Address, c.Port, c.BufferSize);
tcp.AutoReconnect = c.AutoReconnect;
if (tcp.AutoReconnect)
tcp.AutoReconnectIntervalMs = c.AutoReconnectIntervalMs;
comm = tcp;
break;
}
case eControlMethod.Udp:
{
var udp = new GenericUdpServer(deviceConfig.Key + "-udp", c.Address, c.Port, c.BufferSize);
comm = udp;
break;
}
case eControlMethod.Telnet:
break;
default:
break;
}
}
catch (Exception e)
{
Debug.Console(0, "Cannot create communication from JSON:\r{0}\r\rException:\r{1}",
deviceConfig.Properties.ToString(), e);
}
// put it in the device manager if it's the right flavor
var comDev = comm as Device;
if (comDev != null)
DeviceManager.AddDevice(comDev);
return comm;
}
public static ComPort GetComPort(EssentialsControlPropertiesConfig config)
{
var comPar = config.ComParams;
var dev = GetIComPortsDeviceFromManagedDevice(config.ControlPortDevKey);
if (dev != null && config.ControlPortNumber <= dev.NumberOfComPorts)
return dev.ComPorts[config.ControlPortNumber];
Debug.Console(0, "GetComPort: Device '{0}' does not have com port {1}", config.ControlPortDevKey, config.ControlPortNumber);
return null;
}
/// <summary>
/// Gets an ICec port from a RoutingInput or RoutingOutput on a device
/// </summary>
/// <param name="config"></param>
/// <returns></returns>
public static ICec GetCecPort(ControlPropertiesConfig config)
{
var dev = DeviceManager.GetDeviceForKey(config.ControlPortDevKey);
if (dev != null)
{
var inputPort = (dev as IRoutingInputsOutputs).InputPorts[config.ControlPortName];
if (inputPort != null)
if (inputPort.Port is ICec)
return inputPort.Port as ICec;
var outputPort = (dev as IRoutingInputsOutputs).OutputPorts[config.ControlPortName];
if (outputPort != null)
if (outputPort.Port is ICec)
return outputPort.Port as ICec;
}
Debug.Console(0, "GetCecPort: Device '{0}' does not have a CEC port called: '{1}'", config.ControlPortDevKey, config.ControlPortName);
return null;
}
/// <summary>
/// Helper to grab the IComPorts device for this PortDeviceKey. Key "controlSystem" will
/// return the ControlSystem object from the Global class.
/// </summary>
/// <returns>IComPorts device or null if the device is not found or does not implement IComPorts</returns>
public static IComPorts GetIComPortsDeviceFromManagedDevice(string ComPortDevKey)
{
if ((ComPortDevKey.Equals("controlSystem", System.StringComparison.OrdinalIgnoreCase)
|| ComPortDevKey.Equals("processor", System.StringComparison.OrdinalIgnoreCase))
&& Global.ControlSystem is IComPorts)
return Global.ControlSystem;
else
{
var dev = DeviceManager.GetDeviceForKey(ComPortDevKey) as IComPorts;
if (dev == null)
Debug.Console(0, "ComPortConfig: Cannot find com port device '{0}'", ComPortDevKey);
return dev;
}
}
}
/// <summary>
///
/// </summary>
public class EssentialsControlPropertiesConfig :
PepperDash.Core.ControlPropertiesConfig
{
[JsonConverter(typeof(ComSpecJsonConverter))]
public ComPort.ComPortSpec ComParams { get; set; }
public string CresnetId { get; set; }
/// <summary>
/// Attempts to provide uint conversion of string CresnetId
/// </summary>
public uint CresnetIdInt
{
get
{
try
{
return Convert.ToUInt32(CresnetId, 16);
}
catch (Exception)
{
throw new FormatException(string.Format("ERROR:Unable to convert Cresnet ID: {0} to hex. Error:\n{1}", CresnetId));
}
}
}
}
public class IrControlSpec
{
public string PortDeviceKey { get; set; }
public uint PortNumber { get; set; }
public string File { get; set; }
}
}

View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
namespace PepperDash.Essentials.Core
{
/// <summary>
///
/// </summary>
public interface IComPortsDevice
{
IComPorts Device { get; }
}
}

View File

@@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
namespace PepperDash.Essentials.Core
{
public class ConsoleCommMockDevice : Device, ICommunicationMonitor
{
public IBasicCommunication Communication { get; private set; }
public CommunicationGather PortGather { get; private set; }
public StatusMonitorBase CommunicationMonitor { get; private set; }
/// <summary>
/// Defaults to \x0a
/// </summary>
public string LineEnding { get; set; }
/// <summary>
/// Set to true to show responses in full hex
/// </summary>
public bool ShowHexResponse { get; set; }
public ConsoleCommMockDevice(string key, string name, ConsoleCommMockDevicePropertiesConfig props, IBasicCommunication comm)
:base(key, name)
{
Communication = comm;
PortGather = new CommunicationGather(Communication, '\x0d');
PortGather.LineReceived += this.Port_LineReceived;
CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, props.CommunicationMonitorProperties);
LineEnding = props.LineEnding;
}
public override bool CustomActivate()
{
Communication.Connect();
CommunicationMonitor.StatusChange += (o, a) => { Debug.Console(2, this, "Communication monitor state: {0}", CommunicationMonitor.Status); };
CommunicationMonitor.Start();
CrestronConsole.AddNewConsoleCommand(SendLine, "send" + Key, "", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s => Communication.Connect(), "con" + Key, "", ConsoleAccessLevelEnum.AccessOperator);
return true;
}
void Port_LineReceived(object dev, GenericCommMethodReceiveTextArgs args)
{
if (Debug.Level == 2)
Debug.Console(2, this, "RX: '{0}'",
ShowHexResponse ? ComTextHelper.GetEscapedText(args.Text) : args.Text);
}
void SendLine(string s)
{
//if (Debug.Level == 2)
// Debug.Console(2, this, " Send '{0}'", ComTextHelper.GetEscapedText(s));
Communication.SendText(s + LineEnding);
}
}
public class ConsoleCommMockDevicePropertiesConfig
{
public string LineEnding { get; set; }
public CommunicationMonitorConfig CommunicationMonitorProperties { get; set; }
public ConsoleCommMockDevicePropertiesConfig()
{
LineEnding = "\x0a";
}
}
}

View File

@@ -0,0 +1,105 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Newtonsoft.Json;
namespace PepperDash.Essentials.Core
{
public class ComPortController : Device, IBasicCommunication
{
public event EventHandler<GenericCommMethodReceiveBytesArgs> BytesReceived;
public event EventHandler<GenericCommMethodReceiveTextArgs> TextReceived;
ComPort Port;
ComPort.ComPortSpec Spec;
public ComPortController(string key, IComPorts ComDevice, uint comPortNum, ComPort.ComPortSpec spec)
: base(key)
{
Port = ComDevice.ComPorts[comPortNum];
Spec = spec;
Debug.Console(2, "Creating com port '{0}'", key);
Debug.Console(2, "Com port spec:\r{0}", JsonConvert.SerializeObject(spec));
}
/// <summary>
/// Creates a ComPort if the parameters are correct. Returns and logs errors if not
/// </summary>
public static ComPortController GetComPortController(string key,
IComPorts comDevice, uint comPortNum, ComPort.ComPortSpec spec)
{
Debug.Console(1, "Creating com port '{0}'", key);
if (comDevice == null)
throw new ArgumentNullException("comDevice");
if (string.IsNullOrEmpty(key))
throw new ArgumentNullException("key");
if (comPortNum > comDevice.NumberOfComPorts)
{
Debug.Console(0, "[{0}] Com port {1} out of range on {2}",
key, comPortNum, comDevice.GetType().Name);
return null;
}
var port = new ComPortController(key, comDevice, comPortNum, spec);
return port;
}
/// <summary>
/// Registers port and sends ComSpec
/// </summary>
/// <returns>false if either register or comspec fails</returns>
public override bool CustomActivate()
{
var result = Port.Register();
if (result != eDeviceRegistrationUnRegistrationResponse.Success)
{
Debug.Console(0, this, "Cannot register Com port: {0}", result);
return false;
}
var specResult = Port.SetComPortSpec(Spec);
if (specResult != 0)
{
Debug.Console(0, this, "Cannot set comspec");
return false;
}
Port.SerialDataReceived += new ComPortDataReceivedEvent(Port_SerialDataReceived);
return true;
}
void Port_SerialDataReceived(ComPort ReceivingComPort, ComPortSerialDataEventArgs args)
{
if (BytesReceived != null)
{
var bytes = Encoding.GetEncoding(28591).GetBytes(args.SerialData);
BytesReceived(this, new GenericCommMethodReceiveBytesArgs(bytes));
}
if(TextReceived != null)
TextReceived(this, new GenericCommMethodReceiveTextArgs(args.SerialData));
}
public override bool Deactivate()
{
return Port.UnRegister() == eDeviceRegistrationUnRegistrationResponse.Success;
}
#region IBasicCommunication Members
public void SendText(string text)
{
Port.Send(text);
}
public void SendBytes(byte[] bytes)
{
var text = Encoding.GetEncoding(28591).GetString(bytes, 0, bytes.Length);
Port.Send(text);
}
#endregion
}
}

View File

@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Essentials.Core.Devices;
using PepperDash.Essentials.Core.Config;
namespace PepperDash.Essentials.Core
{
/// <summary>
/// Serves as a generic wrapper class for all styles of IBasicCommuncation ports
/// </summary>
public class
GenericComm : ReconfigurableDevice
{
EssentialsControlPropertiesConfig PropertiesConfig;
public IBasicCommunication CommPort { get; private set; }
public GenericComm(DeviceConfig config)
: base(config)
{
PropertiesConfig = CommFactory.GetControlPropertiesConfig(config);
CommPort = CommFactory.CreateCommForDevice(config);
}
public void SetPortConfig(string portConfig)
{
// TODO: Deserialize new EssentialsControlPropertiesConfig and handle as necessary
try
{
PropertiesConfig = JsonConvert.DeserializeObject<EssentialsControlPropertiesConfig>
(portConfig.ToString());
}
catch (Exception e)
{
Debug.Console(2, this, "Error deserializing port config: {0}", e);
}
}
protected override void CustomSetConfig(DeviceConfig config)
{
PropertiesConfig = CommFactory.GetControlPropertiesConfig(config);
ConfigWriter.UpdateDeviceConfig(config);
}
}
}

View File

@@ -0,0 +1,160 @@
using System;
using System.Collections.Generic;
using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO;
using Crestron.SimplSharpPro;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Essentials.Core.Config;
namespace PepperDash.Essentials.Core
{
/// <summary>
///
/// </summary>
public static class IRPortHelper
{
public static string IrDriverPathPrefix
{
get
{
return Global.FilePathPrefix + "IR" + Global.DirectorySeparator;
}
}
/// <summary>
/// Finds either the ControlSystem or a device controller that contains IR ports and
/// returns a port from the hardware device
/// </summary>
/// <param name="propsToken"></param>
/// <returns>IrPortConfig object. The port and or filename will be empty/null
/// if valid values don't exist on config</returns>
public static IrOutPortConfig GetIrPort(JToken propsToken)
{
var control = propsToken["control"];
if (control == null)
return null;
if (control["method"].Value<string>() != "ir")
{
Debug.Console(0, "IRPortHelper called with non-IR properties");
return null;
}
var port = new IrOutPortConfig();
var portDevKey = control.Value<string>("controlPortDevKey");
var portNum = control.Value<uint>("controlPortNumber");
if (portDevKey == null || portNum == 0)
{
Debug.Console(1, "WARNING: Properties is missing port device or port number");
return port;
}
IIROutputPorts irDev = null;
if (portDevKey.Equals("controlSystem", StringComparison.OrdinalIgnoreCase)
|| portDevKey.Equals("processor", StringComparison.OrdinalIgnoreCase))
irDev = Global.ControlSystem;
else
irDev = DeviceManager.GetDeviceForKey(portDevKey) as IIROutputPorts;
if (irDev == null)
{
Debug.Console(1, "[Config] Error, device with IR ports '{0}' not found", portDevKey);
return port;
}
if (portNum <= irDev.NumberOfIROutputPorts) // success!
{
var file = IrDriverPathPrefix + control["irFile"].Value<string>();
port.Port = irDev.IROutputPorts[portNum];
port.FileName = file;
return port; // new IrOutPortConfig { Port = irDev.IROutputPorts[portNum], FileName = file };
}
else
{
Debug.Console(1, "[Config] Error, device '{0}' IR port {1} out of range",
portDevKey, portNum);
return port;
}
}
/// <summary>
/// Returns a ready-to-go IrOutputPortController from a DeviceConfig object.
/// </summary>
public static IrOutputPortController GetIrOutputPortController(DeviceConfig devConf)
{
var irControllerKey = devConf.Key + "-ir";
if (devConf.Properties == null)
{
Debug.Console(0, "[{0}] WARNING: Device config does not include properties. IR will not function.", devConf.Key);
return new IrOutputPortController(irControllerKey, null, "");
}
var control = devConf.Properties["control"];
if (control == null)
{
var c = new IrOutputPortController(irControllerKey, null, "");
Debug.Console(0, c, "WARNING: Device config does not include control properties. IR will not function");
return c;
}
var portDevKey = control.Value<string>("controlPortDevKey");
var portNum = control.Value<uint>("controlPortNumber");
IIROutputPorts irDev = null;
if (portDevKey == null)
{
var c = new IrOutputPortController(irControllerKey, null, "");
Debug.Console(0, c, "WARNING: control properties is missing ir device");
return c;
}
if (portNum == 0)
{
var c = new IrOutputPortController(irControllerKey, null, "");
Debug.Console(0, c, "WARNING: control properties is missing ir port number");
return c;
}
if (portDevKey.Equals("controlSystem", StringComparison.OrdinalIgnoreCase)
|| portDevKey.Equals("processor", StringComparison.OrdinalIgnoreCase))
irDev = Global.ControlSystem;
else
irDev = DeviceManager.GetDeviceForKey(portDevKey) as IIROutputPorts;
if (irDev == null)
{
var c = new IrOutputPortController(irControllerKey, null, "");
Debug.Console(0, c, "WARNING: device with IR ports '{0}' not found", portDevKey);
return c;
}
if (portNum <= irDev.NumberOfIROutputPorts) // success!
return new IrOutputPortController(irControllerKey, irDev.IROutputPorts[portNum],
IrDriverPathPrefix + control["irFile"].Value<string>());
else
{
var c = new IrOutputPortController(irControllerKey, null, "");
Debug.Console(0, c, "WARNING: device '{0}' IR port {1} out of range",
portDevKey, portNum);
return c;
}
}
}
/// <summary>
/// Wrapper to help in IR port creation
/// </summary>
public class IrOutPortConfig
{
public IROutputPort Port { get; set; }
public string FileName { get; set; }
public IrOutPortConfig()
{
FileName = "";
}
}
}

View File

@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Core.Config
{
/// <summary>
/// Override this and splice on specific room type behavior, as well as other properties
/// </summary>
public class BasicConfig
{
[JsonProperty("info")]
public InfoConfig Info { get; set; }
[JsonProperty("devices")]
public List<DeviceConfig> Devices { get; set; }
[JsonProperty("sourceLists")]
public Dictionary<string, Dictionary<string, SourceListItem>> SourceLists { get; set; }
[JsonProperty("tieLines")]
public List<TieLineConfig> TieLines { get; set; }
/// <summary>
/// Checks SourceLists for a given list and returns it if found. Otherwise, returns null
/// </summary>
public Dictionary<string, SourceListItem> GetSourceListForKey(string key)
{
if (string.IsNullOrEmpty(key) || !SourceLists.ContainsKey(key))
return null;
return SourceLists[key];
}
}
}

View File

@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Essentials.Core;
using PepperDash.Core;
using Newtonsoft.Json.Linq;
namespace PepperDash.Essentials.Core.Config
{
public class ConfigPropertiesHelpers
{
/// <summary>
/// Returns the value of properties.hasAudio, or false if not defined
/// </summary>
public static bool GetHasAudio(DeviceConfig deviceConfig)
{
return deviceConfig.Properties.Value<bool>("hasAudio");
}
/// <summary>
/// Returns the value of properties.hasControls, or false if not defined
/// </summary>
public static bool GetHasControls(DeviceConfig deviceConfig)
{
return deviceConfig.Properties.Value<bool>("hasControls");
}
}
}

View File

@@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO;
using Crestron.SimplSharpPro;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Core.Config
{
public class DeviceConfig
{
[JsonProperty("key")]
public string Key { get; set; }
[JsonProperty("uid")]
public int Uid { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("group")]
public string Group { get; set; }
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("properties")]
[JsonConverter(typeof(DevicePropertiesConverter))]
public JToken Properties { get; set; }
}
/// <summary>
///
/// </summary>
public class DevicePropertiesConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
return objectType == typeof(JToken);
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
return JToken.ReadFrom(reader);
}
public override bool CanWrite
{
get
{
return false;
}
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
throw new NotImplementedException("SOD OFF HOSER");
}
}
}

View File

@@ -0,0 +1,176 @@
using System;
using System.Linq;
using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Core.Config;
namespace PepperDash.Essentials.Core.Config
{
/// <summary>
/// Loads the ConfigObject from the file
/// </summary>
public class ConfigReader
{
public static EssentialsConfig ConfigObject { get; private set; }
public static bool LoadConfig2()
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading unmerged system/template portal configuration file.");
try
{
// Check for local config file first
var filePath = Global.FilePathPrefix + ConfigWriter.LocalConfigFolder + Global.DirectorySeparator + Global.ConfigFileName;
bool localConfigFound = false;
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to load Local config file: '{0}'", filePath);
// Check for local config directory first
var configFiles = GetConfigFiles(filePath);
if (configFiles != null)
{
if (configFiles.Length > 1)
{
Debug.Console(0, Debug.ErrorLogLevel.Error,
"****Error: Multiple Local Configuration files present. Please ensure only a single file exists and reset program.****");
return false;
}
else if(configFiles.Length == 1)
{
localConfigFound = true;
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Found Local config file: '{0}'", filePath);
}
}
else
{
Debug.Console(0, Debug.ErrorLogLevel.Notice,
"Local Configuration file not present.", filePath);
}
// Check for Portal Config
if(!localConfigFound)
{
filePath = Global.FilePathPrefix + Global.ConfigFileName;
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to load Portal config file: '{0}'", filePath);
configFiles = GetConfigFiles(filePath);
if (configFiles != null)
{
if (configFiles.Length > 1)
{
Debug.Console(0, Debug.ErrorLogLevel.Error,
"****Error: Multiple Portal Configuration files present. Please ensure only a single file exists and reset program.****");
return false;
}
else
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Found Portal config file: '{0}'", filePath);
}
}
else
{
Debug.Console(0, Debug.ErrorLogLevel.Error,
"ERROR: Portal Configuration file not present. Please load file and reset program.");
return false;
}
}
// Get the actual file path
filePath = configFiles[0].FullName;
// Read the file
using (StreamReader fs = new StreamReader(filePath))
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading config file: '{0}'", filePath);
if (localConfigFound)
{
ConfigObject = JObject.Parse(fs.ReadToEnd()).ToObject<EssentialsConfig>();
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Successfully Loaded Local Config");
return true;
}
else
{
var doubleObj = JObject.Parse(fs.ReadToEnd());
ConfigObject = PortalConfigReader.MergeConfigs(doubleObj).ToObject<EssentialsConfig>();
// Extract SystemUrl and TemplateUrl into final config output
if (doubleObj["system_url"] != null)
{
ConfigObject.SystemUrl = doubleObj["system_url"].Value<string>();
}
if (doubleObj["template_url"] != null)
{
ConfigObject.TemplateUrl = doubleObj["template_url"].Value<string>();
}
}
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Successfully Loaded Merged Config");
return true;
}
}
catch (Exception e)
{
Debug.Console(0, Debug.ErrorLogLevel.Error, "ERROR: Config load failed: \r{0}", e);
return false;
}
}
/// <summary>
/// Returns all the files from the directory specified.
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
public static FileInfo[] GetConfigFiles(string filePath)
{
// Get the directory
var dir = Path.GetDirectoryName(filePath);
if (Directory.Exists(dir))
{
Debug.Console(1, "Searching in Directory '{0}'", dir);
// Get the directory info
var dirInfo = new DirectoryInfo(dir);
// Get the file name
var fileName = Path.GetFileName(filePath);
Debug.Console(1, "For Config Files matching: '{0}'", fileName);
// Get the files that match from the directory
return dirInfo.GetFiles(fileName);
}
else
{
Debug.Console(0, Debug.ErrorLogLevel.Notice,
"Directory not found: ", dir);
return null;
}
}
/// <summary>
/// Returns the group for a given device key in config
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static string GetGroupForDeviceKey(string key)
{
var dev = ConfigObject.Devices.FirstOrDefault(d => d.Key.Equals(key, StringComparison.OrdinalIgnoreCase));
return dev == null ? null : dev.Group;
}
}
}

View File

@@ -0,0 +1,223 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Crestron.SimplSharp.Net.Http;
using Crestron.SimplSharpPro.Diagnostics;
using PepperDash.Core;
namespace PepperDash.Essentials.Core.Config
{
public static class ConfigUpdater
{
public static event EventHandler<ConfigStatusEventArgs> ConfigStatusChanged;
public static void GetConfigFromServer(string url)
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to get new config from '{0}'", url);
// HTTP GET
var req = new HttpClientRequest();
try
{
req.RequestType = RequestType.Get;
req.Url.Parse(url);
new HttpClient().DispatchAsync(req, (r, e) =>
{
if (e == HTTP_CALLBACK_ERROR.COMPLETED)
{
if (r.Code == 200)
{
var newConfig = r.ContentString;
OnStatusUpdate(eUpdateStatus.ConfigFileReceived);
ArchiveExistingPortalConfigs();
CheckForLocalConfigAndDelete();
WriteConfigToFile(newConfig);
RestartProgram();
}
else
{
Debug.Console(0, Debug.ErrorLogLevel.Error, "Config Update Process Stopped. Failed to get config file from server: {0}", r.Code);
OnStatusUpdate(eUpdateStatus.UpdateFailed);
}
}
else
Debug.Console(0, Debug.ErrorLogLevel.Error, "Request for config from Server Failed: {0}", e);
});
}
catch (Exception e)
{
Debug.Console(1, "Error Getting Config from Server: {0}", e);
}
}
static void OnStatusUpdate(eUpdateStatus status)
{
var handler = ConfigStatusChanged;
if(handler != null)
{
handler(typeof(ConfigUpdater), new ConfigStatusEventArgs(status));
}
}
static void WriteConfigToFile(string configData)
{
var filePath = Global.FilePathPrefix+ "configurationFile-updated.json";
try
{
var config = JObject.Parse(configData).ToObject<EssentialsConfig>();
ConfigWriter.WriteFile(filePath, configData);
OnStatusUpdate(eUpdateStatus.WritingConfigFile);
}
catch (Exception e)
{
Debug.Console(1, "Error parsing new config: {0}", e);
OnStatusUpdate(eUpdateStatus.UpdateFailed);
}
}
/// <summary>
/// Checks for any existing portal config files and archives them
/// </summary>
static void ArchiveExistingPortalConfigs()
{
var filePath = Global.FilePathPrefix + Global.ConfigFileName;
var configFiles = ConfigReader.GetConfigFiles(filePath);
if (configFiles != null)
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Existing config files found. Moving to Archive folder.");
OnStatusUpdate(eUpdateStatus.ArchivingConfigs);
MoveFilesToArchiveFolder(configFiles);
}
else
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "No Existing config files found in '{0}'. Nothing to archive", filePath);
}
}
/// <summary>
/// Checks for presence of archive folder and if found deletes contents.
/// Moves any config files to the archive folder and adds a .bak suffix
/// </summary>
/// <param name="files"></param>
static void MoveFilesToArchiveFolder(FileInfo[] files)
{
string archiveDirectoryPath = Global.FilePathPrefix + "archive";
if (!Directory.Exists(archiveDirectoryPath))
{
// Directory does not exist, create it
Directory.Create(archiveDirectoryPath);
}
else
{
// Directory exists, first clear any contents
var archivedConfigFiles = ConfigReader.GetConfigFiles(archiveDirectoryPath + Global.DirectorySeparator + Global.ConfigFileName + ".bak");
if(archivedConfigFiles != null || archivedConfigFiles.Length > 0)
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "{0} Existing files found in archive folder. Deleting.", archivedConfigFiles.Length);
for (int i = 0; i < archivedConfigFiles.Length; i++ )
{
var file = archivedConfigFiles[i];
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Deleting archived file: '{0}'", file.FullName);
file.Delete();
}
}
}
// Move any files from the program folder to the archive folder
foreach (var file in files)
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Moving config file '{0}' to archive folder", file.FullName);
// Moves the file and appends the .bak extension
var fileDest = archiveDirectoryPath + "/" + file.Name + ".bak";
if(!File.Exists(fileDest))
{
file.MoveTo(fileDest);
}
else
Debug.Console(0, Debug.ErrorLogLevel.Warning, "Cannot move file to archive folder. Existing file already exists with same name: '{0}'", fileDest);
}
}
/// <summary>
/// Checks for LocalConfig folder in file system and deletes if found
/// </summary>
static void CheckForLocalConfigAndDelete()
{
var folderPath = Global.FilePathPrefix + ConfigWriter.LocalConfigFolder;
if (Directory.Exists(folderPath))
{
OnStatusUpdate(eUpdateStatus.DeletingLocalConfig);
Directory.Delete(folderPath);
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Local Config Found in '{0}'. Deleting.", folderPath);
}
}
/// <summary>
/// Connects to the processor via SSH and restarts the program
/// </summary>
static void RestartProgram()
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to Reset Program");
OnStatusUpdate(eUpdateStatus.RestartingProgram);
string response = string.Empty;
CrestronConsole.SendControlSystemCommand(string.Format("progreset -p:{0}", InitialParametersClass.ApplicationNumber), ref response);
Debug.Console(1, "Console Response: {0}", response);
}
}
public enum eUpdateStatus
{
UpdateStarted,
ConfigFileReceived,
ArchivingConfigs,
DeletingLocalConfig,
WritingConfigFile,
RestartingProgram,
UpdateSucceeded,
UpdateFailed
}
public class ConfigStatusEventArgs : EventArgs
{
public eUpdateStatus UpdateStatus { get; private set; }
public ConfigStatusEventArgs(eUpdateStatus status)
{
UpdateStatus = status;
}
}
}

View File

@@ -0,0 +1,163 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
namespace PepperDash.Essentials.Core.Config
{
/// <summary>
/// Responsible for updating config at runtime, and writing the updates out to a local file
/// </summary>
public class ConfigWriter
{
public const string LocalConfigFolder = "LocalConfig";
public const long WriteTimeout = 30000;
public static CTimer WriteTimer;
/// <summary>
/// Updates the config properties of a device
/// </summary>
/// <param name="deviceKey"></param>
/// <param name="properties"></param>
/// <returns></returns>
public static bool UpdateDeviceProperties(string deviceKey, JToken properties)
{
bool success = false;
// Get the current device config
var deviceConfig = ConfigReader.ConfigObject.Devices.FirstOrDefault(d => d.Key.Equals(deviceKey));
if (deviceConfig != null)
{
// Replace the current properties JToken with the new one passed into this method
deviceConfig.Properties = properties;
Debug.Console(1, "Updated properties of device: '{0}'", deviceKey);
success = true;
}
ResetTimer();
return success;
}
public static bool UpdateDeviceConfig(DeviceConfig config)
{
bool success = false;
var deviceConfig = ConfigReader.ConfigObject.Devices.FirstOrDefault(d => d.Key.Equals(config.Key));
if (deviceConfig != null)
{
deviceConfig = config;
Debug.Console(1, "Updated config of device: '{0}'", config.Key);
success = true;
}
ResetTimer();
return success;
}
public static bool UpdateRoomConfig(DeviceConfig config)
{
bool success = false;
var deviceConfig = ConfigReader.ConfigObject.Rooms.FirstOrDefault(d => d.Key.Equals(config.Key));
if (deviceConfig != null)
{
deviceConfig = config;
Debug.Console(1, "Updated config of device: '{0}'", config.Key);
success = true;
}
ResetTimer();
return success;
}
/// <summary>
/// Resets (or starts) the write timer
/// </summary>
static void ResetTimer()
{
if (WriteTimer == null)
WriteTimer = new CTimer(WriteConfigFile, WriteTimeout);
WriteTimer.Reset(WriteTimeout);
Debug.Console(1, "Config File write timer has been reset.");
}
/// <summary>
/// Writes the current config to a file in the LocalConfig subfolder
/// </summary>
/// <returns></returns>
private static void WriteConfigFile(object o)
{
var filePath = Global.FilePathPrefix + LocalConfigFolder + Global.DirectorySeparator + "configurationFile.json";
var configData = JsonConvert.SerializeObject(ConfigReader.ConfigObject);
WriteFile(filePath, configData);
}
/// <summary>
/// Writes
/// </summary>
/// <param name="filepath"></param>
/// <param name="o"></param>
public static void WriteFile(string filePath, string configData)
{
if (WriteTimer != null)
WriteTimer.Stop();
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Writing Configuration to file");
var fileLock = new CCriticalSection();
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to write config file: '{0}'", filePath);
try
{
if (fileLock.TryEnter())
{
using (StreamWriter sw = new StreamWriter(filePath))
{
sw.Write(configData);
sw.Flush();
}
}
else
{
Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to enter FileLock");
}
}
catch (Exception e)
{
Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: Config write failed: \r{0}", e);
}
finally
{
if (fileLock != null && !fileLock.Disposed)
fileLock.Leave();
}
}
}
}

View File

@@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using Crestron.SimplSharp.CrestronIO;
using Newtonsoft.Json;
using PepperDash.Core;
namespace PepperDash.Essentials.Core.Config
{
/// <summary>
/// Loads the ConfigObject from the file
/// </summary>
public class EssentialsConfig : BasicConfig
{
[JsonProperty("system_url")]
public string SystemUrl { get; set; }
[JsonProperty("template_url")]
public string TemplateUrl { get; set; }
//public CotijaConfig Cotija { get; private set; }
[JsonProperty("systemUuid")]
public string SystemUuid
{
get
{
if (string.IsNullOrEmpty(SystemUrl))
return "missing url";
var result = Regex.Match(SystemUrl, @"https?:\/\/.*\/systems\/(.*)\/#.*");
string uuid = result.Groups[1].Value;
return uuid;
}
}
[JsonProperty("templateUuid")]
public string TemplateUuid
{
get
{
if (string.IsNullOrEmpty(TemplateUrl))
return "missing template url";
var result = Regex.Match(TemplateUrl, @"https?:\/\/.*\/templates\/(.*)\/#.*");
string uuid = result.Groups[1].Value;
return uuid;
}
}
[JsonProperty("rooms")]
public List<DeviceConfig> Rooms { get; set; }
}
/// <summary>
///
/// </summary>
public class SystemTemplateConfigs
{
public EssentialsConfig System { get; set; }
public EssentialsConfig Template { get; set; }
}
}

View File

@@ -0,0 +1,96 @@
using System;
using Crestron.SimplSharp;
using Crestron.SimplSharp.Reflection;
using Newtonsoft.Json;
namespace PepperDash.Essentials.Core.Config
{
/// <summary>
/// Represents the info section of a Config file
/// </summary>
public class InfoConfig
{
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("date")]
public DateTime Date { get; set; }
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("version")]
public string Version { get; set; }
[JsonProperty("runtimeInfo")]
public RuntimeInfo RuntimeInfo { get; set; }
[JsonProperty("comment")]
public string Comment { get; set; }
[JsonProperty("hostname")]
public string HostName { get; set; }
[JsonProperty("appNumber")]
public uint AppNumber { get; set; }
public InfoConfig()
{
Name = "";
Date = DateTime.Now;
Type = "";
Version = "";
Comment = "";
HostName = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME, 0);
AppNumber = InitialParametersClass.ApplicationNumber;
RuntimeInfo = new RuntimeInfo();
}
}
/// <summary>
/// Represents runtime information about the program/processor
/// </summary>
public class RuntimeInfo
{
/// <summary>
/// The name of the running application
/// </summary>
[JsonProperty("appName")]
public string AppName {get; set;}
//{
// get
// {
// return Assembly.GetExecutingAssembly().GetName().Name;
// }
//}
/// <summary>
/// The Assembly version of the running application
/// </summary>
[JsonProperty("assemblyVersion")]
public string AssemblyVersion {get; set;}
//{
// get
// {
// var version = Assembly.GetExecutingAssembly().GetName().Version;
// return string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Build);
// }
//}
/// <summary>
/// The OS Version of the processor (Firmware Version)
/// </summary>
[JsonProperty("osVersion")]
public string OsVersion {get; set;}
//{
// get
// {
// return Crestron.SimplSharp.CrestronEnvironment.OSVersion.Firmware;
// }
//}
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Core.Config
{
public class SourceDevicePropertiesConfigBase
{
public bool DisableSharing { get; set; }
}
}

View File

@@ -0,0 +1,127 @@
using Crestron.SimplSharpPro;
namespace PepperDash.Essentials.Core
{
public static class CommonBoolCue
{
public static readonly Cue Power = new Cue("Power", 101, eCueType.Bool);
public static readonly Cue PowerOn = new Cue("PowerOn", 102, eCueType.Bool);
public static readonly Cue PowerOff = new Cue("PowerOff", 103, eCueType.Bool);
public static readonly Cue HasPowerFeedback = new Cue("HasPowerFeedback", 101, eCueType.Bool);
public static readonly Cue PowerOnFeedback = new Cue("PowerOnFeedback", 102, eCueType.Bool);
public static readonly Cue IsOnlineFeedback = new Cue("IsOnlineFeedback", 104, eCueType.Bool);
public static readonly Cue IsWarmingUp = new Cue("IsWarmingUp", 105, eCueType.Bool);
public static readonly Cue IsCoolingDown = new Cue("IsCoolingDown", 106, eCueType.Bool);
public static readonly Cue Dash = new Cue("Dash", 109, eCueType.Bool);
public static readonly Cue Digit0 = new Cue("Digit0", 110, eCueType.Bool);
public static readonly Cue Digit1 = new Cue("Digit1", 111, eCueType.Bool);
public static readonly Cue Digit2 = new Cue("Digit2", 112, eCueType.Bool);
public static readonly Cue Digit3 = new Cue("Digit3", 113, eCueType.Bool);
public static readonly Cue Digit4 = new Cue("Digit4", 114, eCueType.Bool);
public static readonly Cue Digit5 = new Cue("Digit5", 115, eCueType.Bool);
public static readonly Cue Digit6 = new Cue("Digit6", 116, eCueType.Bool);
public static readonly Cue Digit7 = new Cue("Digit7", 117, eCueType.Bool);
public static readonly Cue Digit8 = new Cue("Digit8", 118, eCueType.Bool);
public static readonly Cue Digit9 = new Cue("Digit9", 119, eCueType.Bool);
public static readonly Cue KeypadMisc1 = new Cue("KeypadMisc1", 120, eCueType.Bool);
public static readonly Cue KeypadMisc2 = new Cue("KeypadMisc2", 121, eCueType.Bool);
public static readonly Cue NumericEnter = new Cue("Enter", 122, eCueType.Bool);
public static readonly Cue ChannelUp = new Cue("ChannelUp", 123, eCueType.Bool);
public static readonly Cue ChannelDown = new Cue("ChannelDown", 124, eCueType.Bool);
public static readonly Cue Last = new Cue("Last", 125, eCueType.Bool);
public static readonly Cue OpenClose = new Cue("OpenClose", 126, eCueType.Bool);
public static readonly Cue Subtitle = new Cue("Subtitle", 127, eCueType.Bool);
public static readonly Cue Audio = new Cue("Audio", 128, eCueType.Bool);
public static readonly Cue Info = new Cue("Info", 129, eCueType.Bool);
public static readonly Cue Menu = new Cue("Menu", 130, eCueType.Bool);
public static readonly Cue DeviceMenu = new Cue("DeviceMenu", 131, eCueType.Bool);
public static readonly Cue Return = new Cue("Return", 132, eCueType.Bool);
public static readonly Cue Back = new Cue("Back", 133, eCueType.Bool);
public static readonly Cue Exit = new Cue("Exit", 134, eCueType.Bool);
public static readonly Cue Clear = new Cue("Clear", 135, eCueType.Bool);
public static readonly Cue List = new Cue("List", 136, eCueType.Bool);
public static readonly Cue Guide = new Cue("Guide", 137, eCueType.Bool);
public static readonly Cue Am = new Cue("Am", 136, eCueType.Bool);
public static readonly Cue Fm = new Cue("Fm", 137, eCueType.Bool);
public static readonly Cue Up = new Cue("Up", 138, eCueType.Bool);
public static readonly Cue Down = new Cue("Down", 139, eCueType.Bool);
public static readonly Cue Left = new Cue("Left", 140, eCueType.Bool);
public static readonly Cue Right = new Cue("Right", 141, eCueType.Bool);
public static readonly Cue Select = new Cue("Select", 142, eCueType.Bool);
public static readonly Cue SmartApps = new Cue("SmartApps", 143, eCueType.Bool);
public static readonly Cue Dvr = new Cue("Dvr", 144, eCueType.Bool);
public static readonly Cue Play = new Cue("Play", 145, eCueType.Bool);
public static readonly Cue Pause = new Cue("Pause", 146, eCueType.Bool);
public static readonly Cue Stop = new Cue("Stop", 147, eCueType.Bool);
public static readonly Cue ChapNext = new Cue("ChapNext", 148, eCueType.Bool);
public static readonly Cue ChapPrevious = new Cue("ChapPrevious", 149, eCueType.Bool);
public static readonly Cue Rewind = new Cue("Rewind", 150, eCueType.Bool);
public static readonly Cue Ffwd = new Cue("Ffwd", 151, eCueType.Bool);
public static readonly Cue Replay = new Cue("Replay", 152, eCueType.Bool);
public static readonly Cue Advance = new Cue("Advance", 153, eCueType.Bool);
public static readonly Cue Record = new Cue("Record", 154, eCueType.Bool);
public static readonly Cue Red = new Cue("Red", 155, eCueType.Bool);
public static readonly Cue Green = new Cue("Green", 156, eCueType.Bool);
public static readonly Cue Yellow = new Cue("Yellow", 157, eCueType.Bool);
public static readonly Cue Blue = new Cue("Blue", 158, eCueType.Bool);
public static readonly Cue Home = new Cue("Home", 159, eCueType.Bool);
public static readonly Cue PopUp = new Cue("PopUp", 160, eCueType.Bool);
public static readonly Cue PageUp = new Cue("PageUp", 161, eCueType.Bool);
public static readonly Cue PageDown = new Cue("PageDown", 162, eCueType.Bool);
public static readonly Cue Search = new Cue("Search", 163, eCueType.Bool);
public static readonly Cue Setup = new Cue("Setup", 164, eCueType.Bool);
public static readonly Cue RStep = new Cue("RStep", 165, eCueType.Bool);
public static readonly Cue FStep = new Cue("FStep", 166, eCueType.Bool);
public static readonly Cue IsConnected = new Cue("IsConnected", 281, eCueType.Bool);
public static readonly Cue IsOk = new Cue("IsOk", 282, eCueType.Bool);
public static readonly Cue InWarning = new Cue("InWarning", 283, eCueType.Bool);
public static readonly Cue InError = new Cue("InError", 284, eCueType.Bool);
public static readonly Cue StatusUnknown = new Cue("StatusUnknown", 285, eCueType.Bool);
public static readonly Cue VolumeUp = new Cue("VolumeUp", 401, eCueType.Bool);
public static readonly Cue VolumeDown = new Cue("VolumeDown", 402, eCueType.Bool);
public static readonly Cue MuteOn = new Cue("MuteOn", 403, eCueType.Bool);
public static readonly Cue MuteOff = new Cue("MuteOff", 404, eCueType.Bool);
public static readonly Cue MuteToggle = new Cue("MuteToggle", 405, eCueType.Bool);
public static readonly Cue ShowVolumeButtons = new Cue("ShowVolumeButtons", 406, eCueType.Bool);
public static readonly Cue ShowVolumeSlider = new Cue("ShowVolumeSlider", 407, eCueType.Bool);
public static readonly Cue Hdmi1 = new Cue("Hdmi1", 451, eCueType.Bool);
public static readonly Cue Hdmi2 = new Cue("Hdmi2", 452, eCueType.Bool);
public static readonly Cue Hdmi3 = new Cue("Hdmi3", 453, eCueType.Bool);
public static readonly Cue Hdmi4 = new Cue("Hdmi4", 454, eCueType.Bool);
public static readonly Cue Hdmi5 = new Cue("Hdmi5", 455, eCueType.Bool);
public static readonly Cue Hdmi6 = new Cue("Hdmi6", 456, eCueType.Bool);
public static readonly Cue DisplayPort1 = new Cue("DisplayPort1", 457, eCueType.Bool);
public static readonly Cue DisplayPort2 = new Cue("DisplayPort2", 458, eCueType.Bool);
public static readonly Cue Dvi1 = new Cue("Dvi1", 459, eCueType.Bool);
public static readonly Cue Dvi2 = new Cue("Dvi2", 460, eCueType.Bool);
public static readonly Cue Video1 = new Cue("Video1", 461, eCueType.Bool);
public static readonly Cue Video2 = new Cue("Video2", 462, eCueType.Bool);
public static readonly Cue Component1 = new Cue("Component1", 463, eCueType.Bool);
public static readonly Cue Component2 = new Cue("Component2", 464, eCueType.Bool);
public static readonly Cue Vga1 = new Cue("Vga1", 465, eCueType.Bool);
public static readonly Cue Vga2 = new Cue("Vga2", 466, eCueType.Bool);
public static readonly Cue Rgb1 = new Cue("Rgb1", 467, eCueType.Bool);
public static readonly Cue Rgb2 = new Cue("Rgb2", 468, eCueType.Bool);
public static readonly Cue Antenna = new Cue("Antenna", 469, eCueType.Bool);
public static readonly Cue InCall = new Cue("InCall", 501, eCueType.Bool);
}
public static class CommonIntCue
{
public static readonly Cue MainVolumeLevel = new Cue("MainVolumeLevel", 401, eCueType.Int);
public static readonly Cue MainVolumeLevelFeedback = new Cue("MainVolumeLevelFeedback", 401, eCueType.Int);
}
public static class CommonStringCue
{
public static readonly Cue IpConnectionsText = new Cue("IpConnectionsText", 9999, eCueType.String);
}
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Newtonsoft.Json;
namespace PepperDash.Essentials.Core.CrestronIO
{
public class IOPortConfig
{
[JsonProperty("portDeviceKey")]
public string PortDeviceKey { get; set; }
[JsonProperty("portNumber")]
public uint PortNumber { get; set; }
[JsonProperty("disablePullUpResistor")]
public bool DisablePullUpResistor { get; set; }
}
}

View File

@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using PepperDash.Core;
namespace PepperDash.Essentials.Core.CrestronIO
{
public class GenericDigitalInputDevice : Device, IDigitalInput
{
public DigitalInput InputPort { get; private set; }
public BoolFeedback InputStateFeedback { get; private set; }
Func<bool> InputStateFeedbackFunc
{
get
{
return () => InputPort.State;
}
}
public GenericDigitalInputDevice(string key, DigitalInput inputPort):
base(key)
{
InputStateFeedback = new BoolFeedback(InputStateFeedbackFunc);
InputPort = inputPort;
InputPort.StateChange += new DigitalInputEventHandler(InputPort_StateChange);
}
void InputPort_StateChange(DigitalInput digitalInput, DigitalInputEventArgs args)
{
InputStateFeedback.FireUpdate();
}
}
}

View File

@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using PepperDash.Core;
namespace PepperDash.Essentials.Core.CrestronIO
{
/// <summary>
/// Represents a generic digital input deviced tied to a versiport
/// </summary>
public class GenericVersiportDigitalInputDevice : Device, IDigitalInput
{
public Versiport InputPort { get; private set; }
public BoolFeedback InputStateFeedback { get; private set; }
Func<bool> InputStateFeedbackFunc
{
get
{
return () => InputPort.DigitalIn;
}
}
public GenericVersiportDigitalInputDevice(string key, Versiport inputPort, IOPortConfig props):
base(key)
{
InputStateFeedback = new BoolFeedback(InputStateFeedbackFunc);
InputPort = inputPort;
InputPort.SetVersiportConfiguration(eVersiportConfiguration.DigitalInput);
if (props.DisablePullUpResistor)
InputPort.DisablePullUpResistor = true;
InputPort.VersiportChange += new VersiportEventHandler(InputPort_VersiportChange);
Debug.Console(1, this, "Created GenericVersiportDigitalInputDevice on port '{0}'. DisablePullUpResistor: '{1}'", props.PortNumber, InputPort.DisablePullUpResistor);
}
void InputPort_VersiportChange(Versiport port, VersiportEventArgs args)
{
Debug.Console(1, this, "Versiport change: {0}", args.Event);
if(args.Event == eVersiportEvent.DigitalInChange)
InputStateFeedback.FireUpdate();
}
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Core.CrestronIO
{
/// <summary>
/// Represents a device that provides digital input
/// </summary>
public interface IDigitalInput
{
BoolFeedback InputStateFeedback { get; }
}
}

View File

@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using PepperDash.Core;
namespace PepperDash.Essentials.Core.CrestronIO
{
/// <summary>
/// Represents a generic device controlled by relays
/// </summary>
public class GenericRelayDevice : Device, ISwitchedOutput
{
public Relay RelayOutput { get; private set; }
public BoolFeedback OutputIsOnFeedback { get; private set; }
public GenericRelayDevice(string key, Relay relay):
base(key)
{
OutputIsOnFeedback = new BoolFeedback(new Func<bool>(() => RelayOutput.State));
RelayOutput = relay;
RelayOutput.Register();
RelayOutput.StateChange += new RelayEventHandler(RelayOutput_StateChange);
}
void RelayOutput_StateChange(Relay relay, RelayEventArgs args)
{
OutputIsOnFeedback.FireUpdate();
}
public void OpenRelay()
{
RelayOutput.State = false;
}
public void CloseRelay()
{
RelayOutput.State = true;
}
public void ToggleRelayState()
{
if (RelayOutput.State == true)
OpenRelay();
else
CloseRelay();
}
#region ISwitchedOutput Members
void ISwitchedOutput.On()
{
CloseRelay();
}
void ISwitchedOutput.Off()
{
OpenRelay();
}
#endregion
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Core.CrestronIO
{
/// <summary>
/// Describes an output capable of switching on and off
/// </summary>
public interface ISwitchedOutput
{
BoolFeedback OutputIsOnFeedback {get;}
void On();
void Off();
}
public interface ISwitchedOutputCollection
{
Dictionary<uint, ISwitchedOutput> SwitchedOutputs { get; }
}
}

View File

@@ -0,0 +1,156 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
namespace PepperDash.Essentials.Core
{
/// <summary>
/// A bridge class to cover the basic features of GenericBase hardware
/// </summary>
public class CrestronGenericBaseDevice : Device, IOnline, IHasFeedback, ICommunicationMonitor, IUsageTracking
{
public virtual GenericBase Hardware { get; protected set; }
/// <summary>
/// Returns a list containing the Outputs that we want to expose.
/// </summary>
public FeedbackCollection<Feedback> Feedbacks { get; private set; }
public BoolFeedback IsOnline { get; private set; }
public BoolFeedback IsRegistered { get; private set; }
public StringFeedback IpConnectionsText { get; private set; }
/// <summary>
/// Used by implementing classes to prevent registration with Crestron TLDM. For
/// devices like RMCs and TXs attached to a chassis.
/// </summary>
public bool PreventRegistration { get; protected set; }
public CrestronGenericBaseDevice(string key, string name, GenericBase hardware)
: base(key, name)
{
Feedbacks = new FeedbackCollection<Feedback>();
Hardware = hardware;
IsOnline = new BoolFeedback("IsOnlineFeedback", () => Hardware.IsOnline);
IsRegistered = new BoolFeedback("IsRegistered", () => Hardware.Registered);
IpConnectionsText = new StringFeedback("IpConnectionsText", () =>
string.Join(",", Hardware.ConnectedIpList.Select(cip => cip.DeviceIpAddress).ToArray()));
AddToFeedbackList(IsOnline, IsRegistered, IpConnectionsText);
CommunicationMonitor = new CrestronGenericBaseCommunicationMonitor(this, hardware, 120000, 300000);
}
/// <summary>
/// Make sure that overriding classes call this!
/// Registers the Crestron device, connects up to the base events, starts communication monitor
/// </summary>
public override bool CustomActivate()
{
Debug.Console(0, this, "Activating");
if (!PreventRegistration)
{
//Debug.Console(1, this, " Does not require registration. Skipping");
var response = Hardware.RegisterWithLogging(Key);
if (response != eDeviceRegistrationUnRegistrationResponse.Success)
{
//Debug.Console(0, this, "ERROR: Cannot register Crestron device: {0}", response);
return false;
}
}
Hardware.OnlineStatusChange += new OnlineStatusChangeEventHandler(Hardware_OnlineStatusChange);
CommunicationMonitor.Start();
return true;
}
/// <summary>
/// This disconnects events and unregisters the base hardware device.
/// </summary>
/// <returns></returns>
public override bool Deactivate()
{
CommunicationMonitor.Stop();
Hardware.OnlineStatusChange -= Hardware_OnlineStatusChange;
return Hardware.UnRegister() == eDeviceRegistrationUnRegistrationResponse.Success;
}
/// <summary>
/// Adds feedback(s) to the list
/// </summary>
/// <param name="newFbs"></param>
public void AddToFeedbackList(params Feedback[] newFbs)
{
foreach (var f in newFbs)
{
if (f != null)
{
if (!Feedbacks.Contains(f))
{
Feedbacks.Add(f);
}
}
}
}
void Hardware_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args)
{
if (args.DeviceOnLine)
{
foreach (var feedback in Feedbacks)
{
if (feedback != null)
feedback.FireUpdate();
}
}
}
#region IStatusMonitor Members
public StatusMonitorBase CommunicationMonitor { get; private set; }
#endregion
#region IUsageTracking Members
public UsageTracking UsageTracker { get; set; }
#endregion
}
//***********************************************************************************
public class CrestronGenericBaseDeviceEventIds
{
public const uint IsOnline = 1;
public const uint IpConnectionsText =2;
}
/// <summary>
/// Adds logging to Register() failure
/// </summary>
public static class GenericBaseExtensions
{
public static eDeviceRegistrationUnRegistrationResponse RegisterWithLogging(this GenericBase device, string key)
{
var result = device.Register();
var level = result == eDeviceRegistrationUnRegistrationResponse.Success ?
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)
//{
// Debug.Console(0, Debug.ErrorLogLevel.Error, "Cannot register device '{0}': {1}", key, result);
//}
return result;
}
}
}

View File

@@ -0,0 +1,128 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
namespace PepperDash.Essentials.Core
{
/// <summary>
/// A bridge class to cover the basic features of GenericBase hardware
/// </summary>
public class CrestronGenericBaseDevice : Device, IOnline, IHasFeedback, ICommunicationMonitor, IUsageTracking
{
public virtual GenericBase Hardware { get; protected set; }
public BoolFeedback IsOnline { get; private set; }
public BoolFeedback IsRegistered { get; private set; }
public StringFeedback IpConnectionsText { get; private set; }
public CrestronGenericBaseDevice(string key, string name, GenericBase hardware)
: base(key, name)
{
Hardware = hardware;
IsOnline = new BoolFeedback(CommonBoolCue.IsOnlineFeedback, () => Hardware.IsOnline);
IsRegistered = new BoolFeedback(new Cue("IsRegistered", 0, eCueType.Bool), () => Hardware.Registered);
IpConnectionsText = new StringFeedback(CommonStringCue.IpConnectionsText, () =>
string.Join(",", Hardware.ConnectedIpList.Select(cip => cip.DeviceIpAddress).ToArray()));
CommunicationMonitor = new CrestronGenericBaseCommunicationMonitor(this, hardware, 120000, 300000);
}
/// <summary>
/// Make sure that overriding classes call this!
/// Registers the Crestron device, connects up to the base events, starts communication monitor
/// </summary>
public override bool CustomActivate()
{
Debug.Console(0, this, "Activating");
var response = Hardware.RegisterWithLogging(Key);
if (response != eDeviceRegistrationUnRegistrationResponse.Success)
{
<<<<<<< HEAD
Debug.Console(0, this, "ERROR: Cannot register Crestron device: {0}", response);
return false;
}
=======
Debug.Console(0, this, "ERROR: Cannot register Crestron device: {0}", response);
return false;
}
>>>>>>> origin/feature/ecs-342-neil
Hardware.OnlineStatusChange += new OnlineStatusChangeEventHandler(Hardware_OnlineStatusChange);
CommunicationMonitor.Start();
return true;
}
/// <summary>
/// This disconnects events and unregisters the base hardware device.
/// </summary>
/// <returns></returns>
public override bool Deactivate()
{
CommunicationMonitor.Stop();
Hardware.OnlineStatusChange -= Hardware_OnlineStatusChange;
return Hardware.UnRegister() == eDeviceRegistrationUnRegistrationResponse.Success;
}
/// <summary>
/// Returns a list containing the Outputs that we want to expose.
/// </summary>
public virtual List<Feedback> Feedbacks
{
get
{
return new List<Feedback>
{
IsOnline,
IsRegistered,
IpConnectionsText
};
}
}
void Hardware_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args)
{
IsOnline.FireUpdate();
}
#region IStatusMonitor Members
public StatusMonitorBase CommunicationMonitor { get; private set; }
#endregion
#region IUsageTracking Members
public UsageTracking UsageTracker { get; set; }
#endregion
}
//***********************************************************************************
public class CrestronGenericBaseDeviceEventIds
{
public const uint IsOnline = 1;
public const uint IpConnectionsText =2;
}
/// <summary>
/// Adds logging to Register() failure
/// </summary>
public static class GenericBaseExtensions
{
public static eDeviceRegistrationUnRegistrationResponse RegisterWithLogging(this GenericBase device, string key)
{
var result = device.Register();
if (result != eDeviceRegistrationUnRegistrationResponse.Success)
{
Debug.Console(0, Debug.ErrorLogLevel.Error, "Cannot register device '{0}': {1}", key, result);
}
return result;
}
}
}

View File

@@ -0,0 +1,98 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
namespace PepperDash.Essentials.Core
{
/// <summary>
/// Encapsulates a string-named, joined and typed command to a device
/// </summary>
[Obsolete()]
public class DevAction
{
public Cue Cue { get; private set; }
public Action<object> Action { get; private set; }
public DevAction(Cue cue, Action<object> action)
{
Cue = cue;
Action = action;
}
}
public enum eCueType
{
Bool, Int, String, Serial, Void, Other
}
/// <summary>
/// The Cue class is a container to represent a name / join number / type for simplifying
/// commands coming into devices.
/// </summary>
public class Cue
{
public string Name { get; private set; }
public uint Number { get; private set; }
public eCueType Type { get; private set; }
public Cue(string name, uint join, eCueType type)
{
Name = name;
Number = join;
Type = type;
}
/// <summary>
/// Override that prints out the cue's data
/// </summary>
public override string ToString()
{
return string.Format("{0} Cue '{1}'-{2}", Type, Name, Number);
}
///// <summary>
///// Returns a new Cue with JoinNumber offset
///// </summary>
//public Cue GetOffsetCopy(uint offset)
//{
// return new Cue(Name, Number + offset, Type);
//}
/// <summary>
/// Helper method to create a Cue of Bool type
/// </summary>
/// <returns>Cue</returns>
public static Cue BoolCue(string name, uint join)
{
return new Cue(name, join, eCueType.Bool);
}
/// <summary>
/// Helper method to create a Cue of ushort type
/// </summary>
/// <returns>Cue</returns>
public static Cue UShortCue(string name, uint join)
{
return new Cue(name, join, eCueType.Int);
}
/// <summary>
/// Helper method to create a Cue of string type
/// </summary>
/// <returns>Cue</returns>
public static Cue StringCue(string name, uint join)
{
return new Cue(name, join, eCueType.String);
}
public static readonly Cue DefaultBoolCue = new Cue("-none-", 0, eCueType.Bool);
public static readonly Cue DefaultIntCue = new Cue("-none-", 0, eCueType.Int);
public static readonly Cue DefaultStringCue = new Cue("-none-", 0, eCueType.String);
}
}

View File

@@ -0,0 +1,19 @@
//using System;
//using System.Collections.Generic;
//using Crestron.SimplSharpPro;
//using Crestron.SimplSharpPro.DeviceSupport;
//using PepperDash.Core;
//namespace PepperDash.Essentials.Core
//{
// public interface IPresentationSource : IKeyed
// {
// string Name { get; }
// PresentationSourceType Type { get; }
// string IconName { get; set; }
// BoolFeedback HasPowerOnFeedback { get; }
// }
//}

View File

@@ -0,0 +1,47 @@
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.SmartObjects;
namespace PepperDash.Essentials.Core
{
/// <summary>
///
/// </summary>
public interface IChannel
{
void ChannelUp(bool pressRelease);
void ChannelDown(bool pressRelease);
void LastChannel(bool pressRelease);
void Guide(bool pressRelease);
void Info(bool pressRelease);
void Exit(bool pressRelease);
}
/// <summary>
///
/// </summary>
public static class IChannelExtensions
{
public static void LinkButtons(this IChannel dev, BasicTriList triList)
{
triList.SetBoolSigAction(123, dev.ChannelUp);
triList.SetBoolSigAction(124, dev.ChannelDown);
triList.SetBoolSigAction(125, dev.LastChannel);
triList.SetBoolSigAction(137, dev.Guide);
triList.SetBoolSigAction(129, dev.Info);
triList.SetBoolSigAction(134, dev.Exit);
}
public static void UnlinkButtons(this IChannel dev, BasicTriList triList)
{
triList.ClearBoolSigAction(123);
triList.ClearBoolSigAction(124);
triList.ClearBoolSigAction(125);
triList.ClearBoolSigAction(137);
triList.ClearBoolSigAction(129);
triList.ClearBoolSigAction(134);
}
}
}

View File

@@ -0,0 +1,41 @@
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.SmartObjects;
namespace PepperDash.Essentials.Core
{
/// <summary>
///
/// </summary>
public interface IColor
{
void Red(bool pressRelease);
void Green(bool pressRelease);
void Yellow(bool pressRelease);
void Blue(bool pressRelease);
}
/// <summary>
///
/// </summary>
public static class IColorExtensions
{
public static void LinkButtons(this IColor dev, BasicTriList TriList)
{
TriList.SetBoolSigAction(155, dev.Red);
TriList.SetBoolSigAction(156, dev.Green);
TriList.SetBoolSigAction(157, dev.Yellow);
TriList.SetBoolSigAction(158, dev.Blue);
}
public static void UnlinkButtons(this IColor dev, BasicTriList triList)
{
triList.ClearBoolSigAction(155);
triList.ClearBoolSigAction(156);
triList.ClearBoolSigAction(157);
triList.ClearBoolSigAction(158);
}
}
}

View File

@@ -0,0 +1,50 @@
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.SmartObjects;
namespace PepperDash.Essentials.Core
{
/// <summary>
///
/// </summary>
public interface IDPad
{
void Up(bool pressRelease);
void Down(bool pressRelease);
void Left(bool pressRelease);
void Right(bool pressRelease);
void Select(bool pressRelease);
void Menu(bool pressRelease);
void Exit(bool pressRelease);
}
/// <summary>
///
/// </summary>
public static class IDPadExtensions
{
public static void LinkButtons(this IDPad dev, BasicTriList triList)
{
triList.SetBoolSigAction(138, dev.Up);
triList.SetBoolSigAction(139, dev.Down);
triList.SetBoolSigAction(140, dev.Left);
triList.SetBoolSigAction(141, dev.Right);
triList.SetBoolSigAction(142, dev.Select);
triList.SetBoolSigAction(130, dev.Menu);
triList.SetBoolSigAction(134, dev.Exit);
}
public static void UnlinkButtons(this IDPad dev, BasicTriList triList)
{
triList.ClearBoolSigAction(138);
triList.ClearBoolSigAction(139);
triList.ClearBoolSigAction(140);
triList.ClearBoolSigAction(141);
triList.ClearBoolSigAction(142);
triList.ClearBoolSigAction(130);
triList.ClearBoolSigAction(134);
}
}
}

View File

@@ -0,0 +1,13 @@
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.SmartObjects;
namespace PepperDash.Essentials.Core
{
public interface IDiscPlayerControls : IColor, IDPad, INumericKeypad, IPower, ITransport, IUiDisplayInfo
{
}
}

View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Core.Devices.DeviceTypeInterfaces
{
public interface IDisplayBasic
{
void InputHdmi1();
void InputHdmi2();
void InputHdmi3();
void InputHdmi4();
void InputDisplayPort1();
void InputDvi1();
void InputVideo1();
void InputVga1();
void InputVga2();
void InputRgb1();
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Core
{
public interface IDumbSource
{
}
}

View File

@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.SmartObjects;
namespace PepperDash.Essentials.Core
{
/// <summary>
///
/// </summary>
public interface IDvr : IDPad
{
void DvrList(bool pressRelease);
void Record(bool pressRelease);
}
/// <summary>
///
/// </summary>
public static class IDvrExtensions
{
public static void LinkButtons(this IDvr dev, BasicTriList triList)
{
triList.SetBoolSigAction(136, dev.DvrList);
triList.SetBoolSigAction(152, dev.Record);
}
public static void UnlinkButtons(this IDvr dev, BasicTriList triList)
{
triList.ClearBoolSigAction(136);
triList.ClearBoolSigAction(152);
}
}
}

View File

@@ -0,0 +1,84 @@
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.SmartObjects;
namespace PepperDash.Essentials.Core
{
/// <summary>
///
/// </summary>
public interface INumericKeypad
{
void Digit0(bool pressRelease);
void Digit1(bool pressRelease);
void Digit2(bool pressRelease);
void Digit3(bool pressRelease);
void Digit4(bool pressRelease);
void Digit5(bool pressRelease);
void Digit6(bool pressRelease);
void Digit7(bool pressRelease);
void Digit8(bool pressRelease);
void Digit9(bool pressRelease);
/// <summary>
/// Used to hide/show the button and/or text on the left-hand keypad button
/// </summary>
bool HasKeypadAccessoryButton1 { get; }
string KeypadAccessoryButton1Label { get; }
void KeypadAccessoryButton1(bool pressRelease);
bool HasKeypadAccessoryButton2 { get; }
string KeypadAccessoryButton2Label { get; }
void KeypadAccessoryButton2(bool pressRelease);
}
public interface ISetTopBoxNumericKeypad : INumericKeypad
{
void Dash(bool pressRelease);
void KeypadEnter(bool pressRelease);
}
/// <summary>
///
/// </summary>
public static class INumericExtensions
{
/// <summary>
/// Links to the smart object, and sets the misc button's labels on joins x and y
/// </summary>
public static void LinkButtons(this INumericKeypad dev, BasicTriList trilist)
{
trilist.SetBoolSigAction(110, dev.Digit0);
trilist.SetBoolSigAction(111, dev.Digit1);
trilist.SetBoolSigAction(112, dev.Digit2);
trilist.SetBoolSigAction(113, dev.Digit3);
trilist.SetBoolSigAction(114, dev.Digit4);
trilist.SetBoolSigAction(115, dev.Digit5);
trilist.SetBoolSigAction(116, dev.Digit6);
trilist.SetBoolSigAction(117, dev.Digit7);
trilist.SetBoolSigAction(118, dev.Digit8);
trilist.SetBoolSigAction(119, dev.Digit9);
trilist.SetBoolSigAction(120, dev.KeypadAccessoryButton1);
trilist.SetBoolSigAction(121, dev.KeypadAccessoryButton2);
trilist.StringInput[111].StringValue = dev.KeypadAccessoryButton1Label;
trilist.StringInput[111].StringValue = dev.KeypadAccessoryButton2Label;
}
public static void UnlinkButtons(this INumericKeypad dev, BasicTriList trilist)
{
trilist.ClearBoolSigAction(110);
trilist.ClearBoolSigAction(111);
trilist.ClearBoolSigAction(112);
trilist.ClearBoolSigAction(113);
trilist.ClearBoolSigAction(114);
trilist.ClearBoolSigAction(115);
trilist.ClearBoolSigAction(116);
trilist.ClearBoolSigAction(117);
trilist.ClearBoolSigAction(118);
trilist.ClearBoolSigAction(119);
trilist.ClearBoolSigAction(120);
trilist.ClearBoolSigAction(121);
}
}
}

View File

@@ -0,0 +1,48 @@
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.Fusion;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.SmartObjects;
namespace PepperDash.Essentials.Core
{
/// <summary>
///
/// </summary>
public interface IPower
{
void PowerOn();
void PowerOff();
void PowerToggle();
BoolFeedback PowerIsOnFeedback { get; }
}
/// <summary>
///
/// </summary>
public static class IPowerExtensions
{
public static void LinkButtons(this IPower dev, BasicTriList triList)
{
triList.SetSigFalseAction(101, dev.PowerOn);
triList.SetSigFalseAction(102, dev.PowerOff);
triList.SetSigFalseAction(103, dev.PowerToggle);
dev.PowerIsOnFeedback.LinkInputSig(triList.BooleanInput[101]);
}
public static void UnlinkButtons(this IPower dev, BasicTriList triList)
{
triList.ClearBoolSigAction(101);
triList.ClearBoolSigAction(102);
triList.ClearBoolSigAction(103);
dev.PowerIsOnFeedback.UnlinkInputSig(triList.BooleanInput[101]);
}
}
}

View File

@@ -0,0 +1,55 @@
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.SmartObjects;
namespace PepperDash.Essentials.Core
{
/// <summary>
///
/// </summary>
public interface ISetTopBoxControls : IChannel, IColor, IDPad, ISetTopBoxNumericKeypad,
ITransport, IUiDisplayInfo
{
/// <summary>
/// Show DVR controls?
/// </summary>
bool HasDvr { get; }
/// <summary>
/// Show presets controls?
/// </summary>
bool HasPresets { get; }
/// <summary>
/// Show number pad controls?
/// </summary>
bool HasNumeric { get; }
/// <summary>
/// Show D-pad controls?
/// </summary>
bool HasDpad { get; }
PepperDash.Essentials.Core.Presets.DevicePresetsModel PresetsModel { get; }
void LoadPresets(string filePath);
void DvrList(bool pressRelease);
void Replay(bool pressRelease);
}
public static class ISetTopBoxControlsExtensions
{
public static void LinkButtons(this ISetTopBoxControls dev, BasicTriList triList)
{
triList.SetBoolSigAction(136, dev.DvrList);
triList.SetBoolSigAction(152, dev.Replay);
}
public static void UnlinkButtons(this ISetTopBoxControls dev, BasicTriList triList)
{
triList.ClearBoolSigAction(136);
triList.ClearBoolSigAction(152);
}
}
}

View File

@@ -0,0 +1,53 @@
using Crestron.SimplSharpPro.DeviceSupport;
namespace PepperDash.Essentials.Core
{
/// <summary>
///
/// </summary>
public interface ITransport
{
void Play(bool pressRelease);
void Pause(bool pressRelease);
void Rewind(bool pressRelease);
void FFwd(bool pressRelease);
void ChapMinus(bool pressRelease);
void ChapPlus(bool pressRelease);
void Stop(bool pressRelease);
void Record(bool pressRelease);
}
/// <summary>
///
/// </summary>
public static class ITransportExtensions
{
/// <summary>
/// Attaches to trilist joins: Play:145, Pause:146, Stop:147, ChapPlus:148, ChapMinus:149, Rewind:150, Ffwd:151, Record:154
///
/// </summary>
public static void LinkButtons(this ITransport dev, BasicTriList triList)
{
triList.SetBoolSigAction(145, dev.Play);
triList.SetBoolSigAction(146, dev.Pause);
triList.SetBoolSigAction(147, dev.Stop);
triList.SetBoolSigAction(148, dev.ChapPlus);
triList.SetBoolSigAction(149, dev.ChapMinus);
triList.SetBoolSigAction(150, dev.Rewind);
triList.SetBoolSigAction(151, dev.FFwd);
triList.SetBoolSigAction(154, dev.Record);
}
public static void UnlinkButtons(this ITransport dev, BasicTriList triList)
{
triList.ClearBoolSigAction(145);
triList.ClearBoolSigAction(146);
triList.ClearBoolSigAction(147);
triList.ClearBoolSigAction(148);
triList.ClearBoolSigAction(149);
triList.ClearBoolSigAction(150);
triList.ClearBoolSigAction(151);
triList.ClearBoolSigAction(154);
}
}
}

View File

@@ -0,0 +1,12 @@
using PepperDash.Core;
namespace PepperDash.Essentials.Core
{
/// <summary>
/// Describes things needed to show on UI
/// </summary>
public interface IUiDisplayInfo : IKeyed
{
uint DisplayUiType { get; }
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Core
{
/// <summary>
/// Defines a class that has warm up and cool down
/// </summary>
public interface IWarmingCooling
{
BoolFeedback IsWarmingUpFeedback { get; }
BoolFeedback IsCoolingDownFeedback { get; }
}
}

View File

@@ -0,0 +1,9 @@
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.SmartObjects;
namespace PepperDash.Essentials.Core
{
}

View File

@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Core
{
/// <summary>
/// Adds control of codec receive volume
/// </summary>
public interface IReceiveVolume
{
// Break this out into 3 interfaces
void SetReceiveVolume(ushort level);
void ReceiveMuteOn();
void ReceiveMuteOff();
void ReceiveMuteToggle();
IntFeedback ReceiveLevelFeedback { get; }
BoolFeedback ReceiveMuteIsOnFeedback { get; }
}
/// <summary>
/// Adds control of codec transmit volume
/// </summary>
public interface ITransmitVolume
{
void SetTransmitVolume(ushort level);
void TransmitMuteOn();
void TransmitMuteOff();
void TransmitMuteToggle();
IntFeedback TransmitLevelFeedback { get; }
BoolFeedback TransmitMuteIsOnFeedback { get; }
}
/// <summary>
/// Adds control of codec privacy function (microphone mute)
/// </summary>
public interface IPrivacy
{
void PrivacyModeOn();
void PrivacyModeOff();
void PrivacyModeToggle();
BoolFeedback PrivacyModeIsOnFeedback { get; }
}
}

View File

@@ -0,0 +1,92 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Core
{
/// <summary>
/// Requirements for a device that has dialing capabilities
/// </summary>
public interface IHasDialer
{
// Add requirements for Dialer functionality
void Dial(string number);
<<<<<<< HEAD
void EndCall(string number);
=======
void EndCall(object activeCall);
void EndAllCalls();
>>>>>>> origin/feature/cisco-spark-2
void AcceptCall();
void RejectCall();
void SendDtmf(string digit);
IntFeedback ActiveCallCountFeedback { get; }
BoolFeedback IncomingCallFeedback { get; }
}
/// <summary>
/// Defines minimum volume controls for a codec device with dialing capabilities
/// </summary>
public interface ICodecAudio : IBasicVolumeWithFeedback, IPrivacy
{
}
/// <summary>
/// Adds control of codec receive volume
/// </summary>
public interface IReceiveVolume
{
// Break this out into 3 interfaces
void SetReceiveVolume(ushort level);
void ReceiveMuteOn();
void ReceiveMuteOff();
void ReceiveMuteToggle();
IntFeedback ReceiveLevelFeedback { get; }
BoolFeedback ReceiveMuteIsOnFeedback { get; }
}
/// <summary>
/// Adds control of codec transmit volume
/// </summary>
public interface ITransmitVolume
{
void SetTransmitVolume(ushort level);
void TransmitMuteOn();
void TransmitMuteOff();
void TransmitMuteToggle();
IntFeedback TransmitLevelFeedback { get; }
BoolFeedback TransmitMuteIsOnFeedback { get; }
}
/// <summary>
/// Adds control of codec privacy function (microphone mute)
/// </summary>
public interface IPrivacy
{
void PrivacyModeOn();
void PrivacyModeOff();
void PrivacyModeToggle();
BoolFeedback PrivacyModeIsOnFeedback { get; }
}
public interface IHasCallHistory
{
// Add recent calls list
}
public interface IHasDirectory
{
}
public interface IHasObtp
{
// Upcoming Meeting warning event
}
}

View File

@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
using PepperDash.Essentials.Core.CrestronIO;
namespace PepperDash.Essentials.Core.Devices
{
/// <summary>
/// This wrapper class is meant to allow interfaces to be applied to any Crestron processor
/// </summary>
public class CrestronProcessor : Device, ISwitchedOutputCollection
{
public Dictionary<uint, ISwitchedOutput> SwitchedOutputs { get; private set; }
public Crestron.SimplSharpPro.CrestronControlSystem Processor { get; private set; }
public CrestronProcessor(string key)
: base(key)
{
SwitchedOutputs = new Dictionary<uint, ISwitchedOutput>();
Processor = Global.ControlSystem;
GetRelays();
}
/// <summary>
/// Creates a GenericRelayDevice for each relay on the processor and adds them to the SwitchedOutputs collection
/// </summary>
void GetRelays()
{
try
{
if (Processor.SupportsRelay)
{
for (uint i = 1; i <= Processor.NumberOfRelayPorts; i++)
{
var relay = new GenericRelayDevice(string.Format("{0}-relay-{1}", this.Key, i), Processor.RelayPorts[i]);
SwitchedOutputs.Add(i, relay);
}
}
}
catch (Exception e)
{
Debug.Console(1, this, "Error Getting Relays from processor:\n '{0}'", e);
}
}
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Core.Devices
{
/// <summary>
/// Base class for all Device APIs
/// </summary>
public abstract class DeviceApiBase
{
public Dictionary<string, Object> ActionApi { get; protected set; }
public Dictionary<string, Feedback> FeedbackApi { get; protected set; }
}
}

View File

@@ -0,0 +1,292 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharp.Reflection;
using Newtonsoft.Json;
using PepperDash.Core;
namespace PepperDash.Essentials.Core
{
public class DeviceJsonApi
{
/// <summary>
///
/// </summary>
/// <param name="json"></param>
public static void DoDeviceActionWithJson(string json)
{
var action = JsonConvert.DeserializeObject<DeviceActionWrapper>(json);
DoDeviceAction(action);
}
/// <summary>
///
/// </summary>
/// <param name="action"></param>
public static void DoDeviceAction(DeviceActionWrapper action)
{
var key = action.DeviceKey;
var obj = FindObjectOnPath(key);
if (obj == null)
return;
CType t = obj.GetType();
var method = t.GetMethod(action.MethodName);
if (method == null)
{
Debug.Console(0, "Method '{0}' not found", action.MethodName);
return;
}
var mParams = method.GetParameters();
// Add empty params if not provided
if (action.Params == null) action.Params = new object[0];
if (mParams.Length > action.Params.Length)
{
Debug.Console(0, "Method '{0}' requires {1} params", action.MethodName, mParams.Length);
return;
}
object[] convertedParams = mParams
.Select((p, i) => Convert.ChangeType(action.Params[i], p.ParameterType,
System.Globalization.CultureInfo.InvariantCulture))
.ToArray();
object ret = method.Invoke(obj, convertedParams);
}
/// <summary>
///
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static string GetProperties(string deviceObjectPath)
{
var obj = FindObjectOnPath(deviceObjectPath);
if (obj == null)
return "{ \"error\":\"No Device\"}";
CType t = obj.GetType();
// get the properties and set them into a new collection of NameType wrappers
var props = t.GetProperties().Select(p => new PropertyNameType(p, obj));
return JsonConvert.SerializeObject(props, Formatting.Indented);
}
/// <summary>
///
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static string GetMethods(string deviceObjectPath)
{
var obj = FindObjectOnPath(deviceObjectPath);
if (obj == null)
return "{ \"error\":\"No Device\"}";
// Package up method names using helper objects
CType t = obj.GetType();
var methods = t.GetMethods()
.Where(m => !m.IsSpecialName)
.Select(p => new MethodNameParams(p));
return JsonConvert.SerializeObject(methods, Formatting.Indented);
}
public static string GetApiMethods(string deviceObjectPath)
{
var obj = FindObjectOnPath(deviceObjectPath);
if (obj == null)
return "{ \"error\":\"No Device\"}";
// Package up method names using helper objects
CType t = obj.GetType();
var methods = t.GetMethods()
.Where(m => !m.IsSpecialName)
.Where(m => m.GetCustomAttributes(typeof(ApiAttribute), true).Any())
.Select(p => new MethodNameParams(p));
return JsonConvert.SerializeObject(methods, Formatting.Indented);
}
/// <summary>
/// Walks down a dotted object path, starting with a Device, and returns the object
/// at the end of the path
/// </summary>
public static object FindObjectOnPath(string deviceObjectPath)
{
var path = deviceObjectPath.Split('.');
var dev = DeviceManager.GetDeviceForKey(path[0]);
if (dev == null)
{
Debug.Console(0, "Device {0} not found", path[0]);
return null;
}
// loop through any dotted properties
object obj = dev;
if (path.Length > 1)
{
for (int i = 1; i < path.Length; i++)
{
var objName = path[i];
string indexStr = null;
var indexOpen = objName.IndexOf('[');
if (indexOpen != -1)
{
var indexClose = objName.IndexOf(']');
if (indexClose == -1)
{
Debug.Console(0, dev, "ERROR Unmatched index brackets");
return null;
}
// Get the index and strip quotes if any
indexStr = objName.Substring(indexOpen + 1, indexClose - indexOpen - 1).Replace("\"", "");
objName = objName.Substring(0, indexOpen);
Debug.Console(0, dev, " Checking for collection '{0}', index '{1}'", objName, indexStr);
}
CType oType = obj.GetType();
var prop = oType.GetProperty(objName);
if (prop == null)
{
Debug.Console(0, dev, "Property {0} not found on {1}", objName, path[i - 1]);
return null;
}
// if there's an index, try to get the property
if (indexStr != null)
{
if (!typeof(ICollection).IsAssignableFrom(prop.PropertyType))
{
Debug.Console(0, dev, "Property {0} is not collection", objName);
return null;
}
var collection = prop.GetValue(obj, null) as ICollection;
// Get the indexed items "property"
var indexedPropInfo = prop.PropertyType.GetProperty("Item");
// These are the parameters for the indexing. Only care about one
var indexParams = indexedPropInfo.GetIndexParameters();
if (indexParams.Length > 0)
{
Debug.Console(0, " Indexed, param type: {0}", indexParams[0].ParameterType.Name);
var properParam = Convert.ChangeType(indexStr, indexParams[0].ParameterType,
System.Globalization.CultureInfo.InvariantCulture);
try
{
obj = indexedPropInfo.GetValue(collection, new object[] { properParam });
}
// if the index is bad, catch it here.
catch (Crestron.SimplSharp.Reflection.TargetInvocationException e)
{
if (e.InnerException is ArgumentOutOfRangeException)
Debug.Console(0, " Index Out of range");
else if (e.InnerException is KeyNotFoundException)
Debug.Console(0, " Key not found");
return null;
}
}
}
else
obj = prop.GetValue(obj, null);
}
}
return obj;
}
/// <summary>
/// Sets a property on an object.
/// </summary>
/// <param name="deviceObjectPath"></param>
/// <returns></returns>
public static string SetProperty(string deviceObjectPath)
{
throw new NotImplementedException("This could be really useful. Finish it please");
//var obj = FindObjectOnPath(deviceObjectPath);
//if (obj == null)
// return "{\"error\":\"No object found\"}";
//CType t = obj.GetType();
//// get the properties and set them into a new collection of NameType wrappers
//var props = t.GetProperties().Select(p => new PropertyNameType(p, obj));
//return JsonConvert.SerializeObject(props, Formatting.Indented);
}
}
public class DeviceActionWrapper
{
public string DeviceKey { get; set; }
public string MethodName { get; set; }
public object[] Params { get; set; }
}
public class PropertyNameType
{
object Parent;
[JsonIgnore]
public PropertyInfo PropInfo { get; private set; }
public string Name { get { return PropInfo.Name; } }
public string Type { get { return PropInfo.PropertyType.Name; } }
public string Value { get
{
if (PropInfo.CanRead)
{
try
{
return PropInfo.GetValue(Parent, null).ToString();
}
catch (Exception)
{
return null;
}
}
else
return null;
} }
public bool CanRead { get { return PropInfo.CanRead; } }
public bool CanWrite { get { return PropInfo.CanWrite; } }
public PropertyNameType(PropertyInfo info, object parent)
{
PropInfo = info;
Parent = parent;
}
}
public class MethodNameParams
{
[JsonIgnore]
public MethodInfo MethodInfo { get; private set; }
public string Name { get { return MethodInfo.Name; } }
public IEnumerable<NameType> Params { get {
return MethodInfo.GetParameters().Select(p =>
new NameType { Name = p.Name, Type = p.ParameterType.Name });
} }
public MethodNameParams(MethodInfo info)
{
MethodInfo = info;
}
}
public class NameType
{
public string Name { get; set; }
public string Type { get; set; }
}
[AttributeUsage(AttributeTargets.All)]
public class ApiAttribute : CAttribute
{
}
}

View File

@@ -0,0 +1,268 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport;
using Crestron.SimplSharpPro.EthernetCommunication;
using Crestron.SimplSharpPro.UI;
using Crestron.SimplSharp.Reflection;
using PepperDash.Core;
namespace PepperDash.Essentials.Core
{
public static class DeviceManager
{
//public static List<Device> Devices { get { return _Devices; } }
//static List<Device> _Devices = new List<Device>();
static Dictionary<string, IKeyed> Devices = new Dictionary<string, IKeyed>(StringComparer.OrdinalIgnoreCase);
/// <summary>
/// Returns a copy of all the devices in a list
/// </summary>
public static List<IKeyed> AllDevices { get { return new List<IKeyed>(Devices.Values); } }
public static void Initialize(CrestronControlSystem cs)
{
CrestronConsole.AddNewConsoleCommand(ListDeviceCommStatuses, "devcommstatus", "Lists the communication status of all devices",
ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(ListDeviceFeedbacks, "devfb", "Lists current feedbacks",
ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(ListDevices, "devlist", "Lists current managed devices",
ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(DeviceJsonApi.DoDeviceActionWithJson, "devjson", "",
ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s =>
{
CrestronConsole.ConsoleCommandResponse(DeviceJsonApi.GetProperties(s));
}, "devprops", "", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s =>
{
CrestronConsole.ConsoleCommandResponse(DeviceJsonApi.GetMethods(s));
}, "devmethods", "", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s =>
{
CrestronConsole.ConsoleCommandResponse(DeviceJsonApi.GetApiMethods(s));
}, "apimethods", "", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(SimulateComReceiveOnDevice, "devsimreceive",
"Simulates incoming data on a com device", ConsoleAccessLevelEnum.AccessOperator);
}
/// <summary>
/// Calls activate steps on all Device class items
/// </summary>
public static void ActivateAll()
{
// PreActivate all devices
foreach (var d in Devices.Values)
{
try
{
if (d is Device)
(d as Device).PreActivate();
}
catch (Exception e)
{
Debug.Console(0, d, "ERROR: Device PreActivation failure:\r{0}", e);
}
}
// Activate all devices
foreach (var d in Devices.Values)
{
try
{
if (d is Device)
(d as Device).Activate();
}
catch (Exception e)
{
Debug.Console(0, d, "ERROR: Device Activation failure:\r{0}", e);
}
}
// PostActivate all devices
foreach (var d in Devices.Values)
{
try
{
if (d is Device)
(d as Device).PostActivate();
}
catch (Exception e)
{
Debug.Console(0, d, "ERROR: Device PostActivation failure:\r{0}", e);
}
}
}
/// <summary>
/// Calls activate on all Device class items
/// </summary>
public static void DeactivateAll()
{
foreach (var d in Devices.Values)
{
if (d is Device)
(d as Device).Deactivate();
}
}
//static void ListMethods(string devKey)
//{
// var dev = GetDeviceForKey(devKey);
// if(dev != null)
// {
// var type = dev.GetType().GetCType();
// var methods = type.GetMethods(BindingFlags.Public|BindingFlags.Instance);
// var sb = new StringBuilder();
// sb.AppendLine(string.Format("{2} methods on [{0}] ({1}):", dev.Key, type.Name, methods.Length));
// foreach (var m in methods)
// {
// sb.Append(string.Format("{0}(", m.Name));
// var pars = m.GetParameters();
// foreach (var p in pars)
// sb.Append(string.Format("({1}){0} ", p.Name, p.ParameterType.Name));
// sb.AppendLine(")");
// }
// CrestronConsole.ConsoleCommandResponse(sb.ToString());
// }
//}
static void ListDevices(string s)
{
Debug.Console(0, "{0} Devices registered with Device Mangager:",Devices.Count);
var sorted = Devices.Values.ToList();
sorted.Sort((a, b) => a.Key.CompareTo(b.Key));
foreach (var d in sorted)
{
var name = d is IKeyName ? (d as IKeyName).Name : "---";
Debug.Console(0, " [{0}] {1}", d.Key, name);
}
}
static void ListDeviceFeedbacks(string devKey)
{
var dev = GetDeviceForKey(devKey);
if(dev == null)
{
Debug.Console(0, "Device '{0}' not found", devKey);
return;
}
var statusDev = dev as IHasFeedback;
if(statusDev == null)
{
Debug.Console(0, "Device '{0}' does not have visible feedbacks", devKey);
return;
}
statusDev.DumpFeedbacksToConsole(true);
}
//static void ListDeviceCommands(string devKey)
//{
// var dev = GetDeviceForKey(devKey);
// if (dev == null)
// {
// Debug.Console(0, "Device '{0}' not found", devKey);
// return;
// }
// Debug.Console(0, "This needs to be reworked. Stay tuned.", devKey);
//}
static void ListDeviceCommStatuses(string input)
{
var sb = new StringBuilder();
foreach (var dev in Devices.Values)
{
if (dev is ICommunicationMonitor)
sb.Append(string.Format("{0}: {1}\r", dev.Key, (dev as ICommunicationMonitor).CommunicationMonitor.Status));
}
CrestronConsole.ConsoleCommandResponse(sb.ToString());
}
//static void DoDeviceCommand(string command)
//{
// Debug.Console(0, "Not yet implemented. Stay tuned");
//}
public static void AddDevice(IKeyed newDev)
{
// Check for device with same key
//var existingDevice = _Devices.FirstOrDefault(d => d.Key.Equals(newDev.Key, StringComparison.OrdinalIgnoreCase));
////// If it exists, remove or warn??
//if (existingDevice != null)
if(Devices.ContainsKey(newDev.Key))
{
Debug.Console(0, newDev, "WARNING: A device with this key already exists. Not added to manager");
return;
}
Devices.Add(newDev.Key, newDev);
//if (!(_Devices.Contains(newDev)))
// _Devices.Add(newDev);
}
public static void RemoveDevice(IKeyed newDev)
{
if(newDev == null)
return;
if (Devices.ContainsKey(newDev.Key))
Devices.Remove(newDev.Key);
//if (_Devices.Contains(newDev))
// _Devices.Remove(newDev);
else
Debug.Console(0, "Device manager: Device '{0}' does not exist in manager. Cannot remove", newDev.Key);
}
public static IEnumerable<string> GetDeviceKeys()
{
//return _Devices.Select(d => d.Key).ToList();
return Devices.Keys;
}
public static IEnumerable<IKeyed> GetDevices()
{
//return _Devices.Select(d => d.Key).ToList();
return Devices.Values;
}
public static IKeyed GetDeviceForKey(string key)
{
//return _Devices.FirstOrDefault(d => d.Key.Equals(key, StringComparison.OrdinalIgnoreCase));
if (key != null && Devices.ContainsKey(key))
return Devices[key];
return null;
}
/// <summary>
/// Console handler that simulates com port data receive
/// </summary>
/// <param name="s"></param>
public static void SimulateComReceiveOnDevice(string s)
{
// devcomsim:1 xyzabc
var match = Regex.Match(s, @"(\S*)\s*(.*)");
if (match.Groups.Count < 3)
{
CrestronConsole.ConsoleCommandResponse(" Format: devsimreceive:P <device key> <string to send>");
return;
}
//Debug.Console(2, "**** {0} - {1} ****", match.Groups[1].Value, match.Groups[2].Value);
ComPortController com = GetDeviceForKey(match.Groups[1].Value) as ComPortController;
if (com == null)
{
CrestronConsole.ConsoleCommandResponse("'{0}' is not a comm port device", match.Groups[1].Value);
return;
}
com.SimulateReceive(match.Groups[2].Value);
}
}
}

View File

@@ -0,0 +1,253 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport;
using Crestron.SimplSharpPro.EthernetCommunication;
using Crestron.SimplSharpPro.UI;
using Crestron.SimplSharp.Reflection;
using PepperDash.Core;
namespace PepperDash.Essentials.Core
{
public static class DeviceManager
{
//public static List<Device> Devices { get { return _Devices; } }
//static List<Device> _Devices = new List<Device>();
static Dictionary<string, IKeyed> Devices = new Dictionary<string, IKeyed>(StringComparer.OrdinalIgnoreCase);
/// <summary>
/// Returns a copy of all the devices in a list
/// </summary>
public static List<IKeyed> AllDevices { get { return new List<IKeyed>(Devices.Values); } }
public static void Initialize(CrestronControlSystem cs)
{
CrestronConsole.AddNewConsoleCommand(ListDeviceCommStatuses, "devcommstatus", "Lists the communication status of all devices",
ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(ListDeviceFeedbacks, "devfb", "Lists current feedbacks",
ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(ListDevices, "devlist", "Lists current managed devices",
ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(DeviceJsonApi.DoDeviceActionWithJson, "devjson", "",
ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s =>
{
CrestronConsole.ConsoleCommandResponse(DeviceJsonApi.GetProperties(s));
}, "devprops", "", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s =>
{
CrestronConsole.ConsoleCommandResponse(DeviceJsonApi.GetMethods(s));
}, "devmethods", "", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s =>
{
CrestronConsole.ConsoleCommandResponse(DeviceJsonApi.GetApiMethods(s));
}, "apimethods", "", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(SimulateComReceiveOnDevice, "devsimreceive",
"Simulates incoming data on a com device", ConsoleAccessLevelEnum.AccessOperator);
}
/// <summary>
/// Calls activate on all Device class items
/// </summary>
public static void ActivateAll()
{
foreach (var d in Devices.Values)
<<<<<<< HEAD
{
try
{
if (d is Device)
(d as Device).Activate();
}
catch (Exception e)
{
Debug.Console(0, d, "ERROR: Device activation failure:\r{0}", e);
}
}
=======
{
try
{
if (d is Device)
(d as Device).Activate();
}
catch (Exception e)
{
Debug.Console(0, d, "ERROR: Device activation failure:\r{0}", e);
}
}
>>>>>>> origin/feature/ecs-342-neil
}
/// <summary>
/// Calls activate on all Device class items
/// </summary>
public static void DeactivateAll()
{
foreach (var d in Devices.Values)
{
if (d is Device)
(d as Device).Deactivate();
}
}
//static void ListMethods(string devKey)
//{
// var dev = GetDeviceForKey(devKey);
// if(dev != null)
// {
// var type = dev.GetType().GetCType();
// var methods = type.GetMethods(BindingFlags.Public|BindingFlags.Instance);
// var sb = new StringBuilder();
// sb.AppendLine(string.Format("{2} methods on [{0}] ({1}):", dev.Key, type.Name, methods.Length));
// foreach (var m in methods)
// {
// sb.Append(string.Format("{0}(", m.Name));
// var pars = m.GetParameters();
// foreach (var p in pars)
// sb.Append(string.Format("({1}){0} ", p.Name, p.ParameterType.Name));
// sb.AppendLine(")");
// }
// CrestronConsole.ConsoleCommandResponse(sb.ToString());
// }
//}
static void ListDevices(string s)
{
Debug.Console(0, "{0} Devices registered with Device Mangager:",Devices.Count);
var sorted = Devices.Values.ToList();
sorted.Sort((a, b) => a.Key.CompareTo(b.Key));
foreach (var d in sorted)
{
var name = d is IKeyName ? (d as IKeyName).Name : "---";
Debug.Console(0, " [{0}] {1}", d.Key, name);
}
}
static void ListDeviceFeedbacks(string devKey)
{
var dev = GetDeviceForKey(devKey);
if(dev == null)
{
Debug.Console(0, "Device '{0}' not found", devKey);
return;
}
var statusDev = dev as IHasFeedback;
if(statusDev == null)
{
Debug.Console(0, "Device '{0}' does not have visible feedbacks", devKey);
return;
}
statusDev.DumpFeedbacksToConsole(true);
}
//static void ListDeviceCommands(string devKey)
//{
// var dev = GetDeviceForKey(devKey);
// if (dev == null)
// {
// Debug.Console(0, "Device '{0}' not found", devKey);
// return;
// }
// Debug.Console(0, "This needs to be reworked. Stay tuned.", devKey);
//}
static void ListDeviceCommStatuses(string input)
{
var sb = new StringBuilder();
foreach (var dev in Devices.Values)
{
if (dev is ICommunicationMonitor)
sb.Append(string.Format("{0}: {1}\r", dev.Key, (dev as ICommunicationMonitor).CommunicationMonitor.Status));
}
CrestronConsole.ConsoleCommandResponse(sb.ToString());
}
//static void DoDeviceCommand(string command)
//{
// Debug.Console(0, "Not yet implemented. Stay tuned");
//}
public static void AddDevice(IKeyed newDev)
{
// Check for device with same key
//var existingDevice = _Devices.FirstOrDefault(d => d.Key.Equals(newDev.Key, StringComparison.OrdinalIgnoreCase));
////// If it exists, remove or warn??
//if (existingDevice != null)
if(Devices.ContainsKey(newDev.Key))
{
Debug.Console(0, newDev, "WARNING: A device with this key already exists. Not added to manager");
return;
}
Devices.Add(newDev.Key, newDev);
//if (!(_Devices.Contains(newDev)))
// _Devices.Add(newDev);
}
public static void RemoveDevice(IKeyed newDev)
{
if(newDev == null)
return;
if (Devices.ContainsKey(newDev.Key))
Devices.Remove(newDev.Key);
//if (_Devices.Contains(newDev))
// _Devices.Remove(newDev);
else
Debug.Console(0, "Device manager: Device '{0}' does not exist in manager. Cannot remove", newDev.Key);
}
public static IEnumerable<string> GetDeviceKeys()
{
//return _Devices.Select(d => d.Key).ToList();
return Devices.Keys;
}
public static IEnumerable<IKeyed> GetDevices()
{
//return _Devices.Select(d => d.Key).ToList();
return Devices.Values;
}
public static IKeyed GetDeviceForKey(string key)
{
//return _Devices.FirstOrDefault(d => d.Key.Equals(key, StringComparison.OrdinalIgnoreCase));
if (key != null && Devices.ContainsKey(key))
return Devices[key];
return null;
}
/// <summary>
/// Console handler that simulates com port data receive
/// </summary>
/// <param name="s"></param>
public static void SimulateComReceiveOnDevice(string s)
{
// devcomsim:1 xyzabc
var match = Regex.Match(s, @"(\S*)\s*(.*)");
if (match.Groups.Count < 3)
{
CrestronConsole.ConsoleCommandResponse(" Format: devsimreceive:P <device key> <string to send>");
return;
}
//Debug.Console(2, "**** {0} - {1} ****", match.Groups[1].Value, match.Groups[2].Value);
ComPortController com = GetDeviceForKey(match.Groups[1].Value) as ComPortController;
if (com == null)
{
CrestronConsole.ConsoleCommandResponse("'{0}' is not a comm port device", match.Groups[1].Value);
return;
}
com.SimulateReceive(match.Groups[2].Value);
}
}
}

View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Core
{
/// <summary>
/// Integers that represent the "source type number" for given sources.
/// Primarily used by the UI to calculate subpage join offsets
/// Note, for UI, only values 1-49 are valid.
/// </summary>
public class DisplayUiConstants
{
public const uint TypeRadio = 1;
public const uint TypeDirecTv = 9;
public const uint TypeBluray = 13;
public const uint TypeChromeTv = 15;
public const uint TypeFireTv = 16;
public const uint TypeAppleTv = 17;
public const uint TypeRoku = 18;
public const uint TypeLaptop = 31;
public const uint TypePc = 32;
public const uint TypeNoControls = 49;
}
}

View File

@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
namespace PepperDash.Essentials.Core
{
public interface IOnline
{
BoolFeedback IsOnline { get; }
}
///// <summary>
///// ** WANT THIS AND ALL ITS FRIENDS TO GO AWAY **
///// Defines a class that has a list of CueAction objects, typically
///// for linking functions to user interfaces or API calls
///// </summary>
//public interface IHasCueActionList
//{
// List<CueActionPair> CueActionList { get; }
//}
//public interface IHasComPortsHardware
//{
// IComPorts ComPortsDevice { get; }
//}
/// <summary>
/// Describes a device that can have a video sync providing device attached to it
/// </summary>
public interface IAttachVideoStatus : IKeyed
{
// Extension methods will depend on this
}
/// <summary>
/// For display classes that can provide usage data
/// </summary>
public interface IDisplayUsage
{
IntFeedback LampHours { get; }
}
public interface IMakeModel : IKeyed
{
string DeviceMake { get; }
string DeviceModel { get; }
}
}

View File

@@ -0,0 +1,79 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
namespace PepperDash.Essentials.Core.Devices
{
public class GenericCommunicationMonitoredDevice : Device, ICommunicationMonitor
{
IBasicCommunication Client;
public StatusMonitorBase CommunicationMonitor { get; private set; }
public GenericCommunicationMonitoredDevice(string key, string name, IBasicCommunication comm, string pollString,
long pollTime, long warningTime, long errorTime)
: base(key, name)
{
Client = comm;
CommunicationMonitor = new GenericCommunicationMonitor(this, Client, pollTime, warningTime, errorTime, pollString);
// ------------------------------------------------------DELETE THIS
CommunicationMonitor.StatusChange += (o, a) =>
{
Debug.Console(2, this, "Communication monitor status change: {0}", a.Status);
};
}
public GenericCommunicationMonitoredDevice(string key, string name, IBasicCommunication comm, string pollString)
: this(key, name, comm, pollString, 30000, 120000, 300000)
{
}
/// <summary>
/// Generic monitor for TCP reachability. Default with 30s poll, 120s warning and 300s error times
/// </summary>
[Obsolete]
public GenericCommunicationMonitoredDevice(string key, string name, string hostname, int port, string pollString)
: this(key, name, hostname, port, pollString, 30000, 120000, 300000)
{
}
/// <summary>
/// Monitor for TCP reachability
/// </summary>
[Obsolete]
public GenericCommunicationMonitoredDevice(string key, string name, string hostname, int port, string pollString,
long pollTime, long warningTime, long errorTime)
: base(key, name)
{
Client = new GenericTcpIpClient(key + "-tcp", hostname, port, 512);
CommunicationMonitor = new GenericCommunicationMonitor(this, Client, pollTime, warningTime, errorTime, pollString);
// ------------------------------------------------------DELETE THIS
CommunicationMonitor.StatusChange += (o, a) =>
{
Debug.Console(2, this, "Communication monitor status change: {0}", a.Status);
};
}
public override bool CustomActivate()
{
CommunicationMonitor.Start();
return true;
}
public override bool Deactivate()
{
CommunicationMonitor.Stop();
return true;
}
}
}

View File

@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Core
{
public static class IAttachVideoStatusExtensions
{
/// <summary>
/// Gets the VideoStatusOutputs for the device
/// </summary>
/// <param name="attachDev"></param>
/// <returns>Attached VideoStatusOutputs or the default if none attached</returns>
public static VideoStatusOutputs GetVideoStatuses(this IAttachVideoStatus attachedDev)
{
// See if this device is connected to a status-providing port
var tl = TieLineCollection.Default.FirstOrDefault(t =>
t.SourcePort.ParentDevice == attachedDev
&& t.DestinationPort is RoutingInputPortWithVideoStatuses);
if (tl != null)
{
// if so, and it's got status, return it -- or null
var port = tl.DestinationPort as RoutingInputPortWithVideoStatuses;
if (port != null)
return port.VideoStatus;
}
return VideoStatusOutputs.NoStatus;
}
public static bool HasVideoStatuses(this IAttachVideoStatus attachedDev)
{
return TieLineCollection.Default.FirstOrDefault(t =>
t.SourcePort.ParentDevice == attachedDev
&& t.DestinationPort is RoutingInputPortWithVideoStatuses) != null;
}
}
}

View File

@@ -0,0 +1,65 @@
using System.Collections.Generic;
using System.Linq;
using Crestron.SimplSharpPro.DeviceSupport;
using Crestron.SimplSharp.Reflection;
using PepperDash.Core;
namespace PepperDash.Essentials.Core
{
public interface IHasFeedback : IKeyed
{
/// <summary>
/// This method shall return a list of all Output objects on a device,
/// including all "aggregate" devices.
/// </summary>
FeedbackCollection<Feedback> Feedbacks { get; }
}
public static class IHasFeedbackExtensions
{
public static void DumpFeedbacksToConsole(this IHasFeedback source, bool getCurrentStates)
{
CType t = source.GetType();
// get the properties and set them into a new collection of NameType wrappers
var props = t.GetProperties().Select(p => new PropertyNameType(p, t));
var feedbacks = source.Feedbacks.OrderBy(x => x.Type);
if (feedbacks != null)
{
Debug.Console(0, source, "\n\nAvailable feedbacks:");
foreach (var f in feedbacks)
{
string val = "";
string type = "";
if (getCurrentStates)
{
if (f is BoolFeedback)
{
val = f.BoolValue.ToString();
type = "boolean";
}
else if (f is IntFeedback)
{
val = f.IntValue.ToString();
type = "integer";
}
else if (f is StringFeedback)
{
val = f.StringValue;
type = "string";
}
}
Debug.Console(0, "{0,-12} {1, -25} {2}", type,
(string.IsNullOrEmpty(f.Key) ? "-no key-" : f.Key), val);
}
}
else
Debug.Console(0, source, "No available outputs:");
}
}
}

View File

@@ -0,0 +1,135 @@
<<<<<<< HEAD
using System.Collections.Generic;
using System.Linq;
using Crestron.SimplSharpPro.DeviceSupport;
using Crestron.SimplSharp.Reflection;
using PepperDash.Core;
namespace PepperDash.Essentials.Core
{
public interface IHasFeedback : IKeyed
{
/// <summary>
/// This method shall return a list of all Output objects on a device,
/// including all "aggregate" devices.
/// </summary>
List<Feedback> Feedbacks { get; }
}
public static class IHasFeedbackExtensions
{
public static void DumpFeedbacksToConsole(this IHasFeedback source, bool getCurrentStates)
{
CType t = source.GetType();
// get the properties and set them into a new collection of NameType wrappers
var props = t.GetProperties().Select(p => new PropertyNameType(p, t));
var feedbacks = source.Feedbacks.OrderBy(x => x.Type);
if (feedbacks != null)
{
Debug.Console(0, source, "\n\nAvailable feedbacks:");
foreach (var f in feedbacks)
{
string val = "";
string type = "";
if (getCurrentStates)
{
if (f is BoolFeedback)
{
val = f.BoolValue.ToString();
type = "boolean";
}
else if (f is IntFeedback)
{
val = f.IntValue.ToString();
type = "integer";
}
else if (f is StringFeedback)
{
val = f.StringValue;
type = "string";
}
}
Debug.Console(0, "{0,-12} {1, -25} {2}", type,
(string.IsNullOrEmpty(f.Cue.Name) ? "-no name-" : f.Cue.Name), val);
}
}
else
Debug.Console(0, source, "No available outputs:");
}
}
=======
using System.Collections.Generic;
using System.Linq;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
namespace PepperDash.Essentials.Core
{
public interface IHasFeedback : IKeyed
{
/// <summary>
/// This method shall return a list of all Output objects on a device,
/// including all "aggregate" devices.
/// </summary>
List<Feedback> Feedbacks { get; }
}
public static class IHasFeedbackExtensions
{
public static void DumpFeedbacksToConsole(this IHasFeedback source, bool getCurrentStates)
{
var feedbacks = source.Feedbacks.OrderBy(x => x.Type);
if (feedbacks != null)
{
Debug.Console(0, source, "\n\nAvailable feedbacks:");
foreach (var f in feedbacks)
{
string val = "";
if (getCurrentStates)
{
if (f is BoolFeedback)
val = " = " + f.BoolValue;
else if(f is IntFeedback)
val = " = " + f.IntValue;
else if(f is StringFeedback)
val = " = " + f.StringValue;
//switch (f.Type)
//{
// case eCueType.Bool:
// val = " = " + f.BoolValue;
// break;
// case eCueType.Int:
// val = " = " + f.IntValue;
// break;
// case eCueType.String:
// val = " = " + f.StringValue;
// break;
// //case eOutputType.Other:
// // break;
//}
}
Debug.Console(0, "{0,-8} {1}{2}", f.GetType(),
(string.IsNullOrEmpty(f.Cue.Name) ? "-none-" : f.Cue.Name), val);
}
}
else
Debug.Console(0, source, "No available outputs:");
}
}
public static class IHasFeedbackFusionExtensions
{
}
>>>>>>> origin/feature/ecs-307
}

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