mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-01-12 03:54:51 +00:00
Compare commits
178 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f6ff28784 | ||
|
|
0a0bfc018d | ||
|
|
bd5a69a83c | ||
|
|
48c6bb78bc | ||
|
|
2cd68d40dc | ||
|
|
43281f0db6 | ||
|
|
fa141c6207 | ||
|
|
07d6fcef1c | ||
|
|
a5ea9bb1eb | ||
|
|
90c122d966 | ||
|
|
634b07dc12 | ||
|
|
699900518a | ||
|
|
ea2d573ab3 | ||
|
|
5c923e66ec | ||
|
|
7958c64e67 | ||
|
|
410ffd2f19 | ||
|
|
53e0599e2a | ||
|
|
af12a81c00 | ||
|
|
2a9e7c81eb | ||
|
|
c15adea02e | ||
|
|
935f2c4bf4 | ||
|
|
327a9a5f6b | ||
|
|
b7ed1d8238 | ||
|
|
aff4e5a61f | ||
|
|
fe172098b9 | ||
|
|
f2c2cd423d | ||
|
|
22722fca21 | ||
|
|
6efec400b8 | ||
|
|
f82816729b | ||
|
|
1b599ff863 | ||
|
|
ae23e48fd0 | ||
|
|
a8f1f77d48 | ||
|
|
68064c7194 | ||
|
|
3ceecd3fbe | ||
|
|
8585977f71 | ||
|
|
288c9bb04c | ||
|
|
47fb805766 | ||
|
|
31b0683cdf | ||
|
|
04194da31c | ||
|
|
09bdc49c15 | ||
|
|
e36b2b97d2 | ||
|
|
d705525a45 | ||
|
|
ecce6e2be9 | ||
|
|
95c0f57000 | ||
|
|
697b9109a3 | ||
|
|
727367c061 | ||
|
|
f26ff0b767 | ||
|
|
44b72dcfe5 | ||
|
|
937f3f3dc0 | ||
|
|
17bf6e3f0a | ||
|
|
e7253b4acc | ||
|
|
71a27027e7 | ||
|
|
2655b8f7b8 | ||
|
|
3adee8bc30 | ||
|
|
e3a3a2cd2d | ||
|
|
6235b44d89 | ||
|
|
90bbd65fdc | ||
|
|
43fd263ea1 | ||
|
|
038e23289e | ||
|
|
2121456d50 | ||
|
|
3a99c3bb30 | ||
|
|
52ac57c080 | ||
|
|
84ee743ff5 | ||
|
|
24fb74701a | ||
|
|
1c9aa1eaf6 | ||
|
|
7c88843f50 | ||
|
|
7a3ce5fcf1 | ||
|
|
3049e5a041 | ||
|
|
59234274dc | ||
|
|
120dae2e63 | ||
|
|
e4317825d3 | ||
|
|
bf6971a52d | ||
|
|
ef0a8dd3b9 | ||
|
|
ca42d744cf | ||
|
|
ffa4de49e9 | ||
|
|
3c5c157a70 | ||
|
|
8ef58359e7 | ||
|
|
530e1ebcb8 | ||
|
|
8d03bef34f | ||
|
|
a870418f96 | ||
|
|
37e2dfd11f | ||
|
|
6c02423a1c | ||
|
|
6ea966ec6c | ||
|
|
6e9b24576e | ||
|
|
ad04235061 | ||
|
|
34f3e543f2 | ||
|
|
e145bfbaee | ||
|
|
4f726007b8 | ||
|
|
d62b5b7e0c | ||
|
|
967d281b62 | ||
|
|
be9fd5e8d1 | ||
|
|
f25d05edc2 | ||
|
|
c3d6890a4c | ||
|
|
ff6184c241 | ||
|
|
034c6913f7 | ||
|
|
03da699a36 | ||
|
|
3a3f6db692 | ||
|
|
87a449d1ee | ||
|
|
1d6a835323 | ||
|
|
6bbad2e0f9 | ||
|
|
821f2a6d60 | ||
|
|
f6136a8c77 | ||
|
|
676526ed48 | ||
|
|
a8ffe2d09f | ||
|
|
541fbbbb2d | ||
|
|
3a5686c27a | ||
|
|
531e7186f2 | ||
|
|
9bc0269e78 | ||
|
|
0df53facb1 | ||
|
|
2ee77f1bca | ||
|
|
9a56f5bb49 | ||
|
|
895f49b888 | ||
|
|
e51e1930d9 | ||
|
|
d245f36cf3 | ||
|
|
47675f12b4 | ||
|
|
a7c920b780 | ||
|
|
3a91a895e6 | ||
|
|
397b0b4d9c | ||
|
|
b793c04ad3 | ||
|
|
3d9070dc4f | ||
|
|
3f82eaeb66 | ||
|
|
3cbf784417 | ||
|
|
3d6ce7534f | ||
|
|
28d694d0b4 | ||
|
|
a320eff13c | ||
|
|
f7db0ef36c | ||
|
|
184144dc3c | ||
|
|
dfd7cb4411 | ||
|
|
5014343fa3 | ||
|
|
f2bfeda074 | ||
|
|
339a4f8a62 | ||
|
|
78668e8abb | ||
|
|
101d1b5625 | ||
|
|
780f7bc249 | ||
|
|
6ec0295aba | ||
|
|
d98b7e837a | ||
|
|
99da6debdc | ||
|
|
c2665f0225 | ||
|
|
0406361d75 | ||
|
|
182326b3c5 | ||
|
|
4a69207038 | ||
|
|
7b4aad3516 | ||
|
|
8dabe732ec | ||
|
|
410cf1b4ad | ||
|
|
ee6293fa75 | ||
|
|
873fd81b5c | ||
|
|
a2a3f4caed | ||
|
|
1df658b7eb | ||
|
|
1c9061cc28 | ||
|
|
a0a83a1af7 | ||
|
|
f17b62844d | ||
|
|
5f8170fb66 | ||
|
|
42086f650d | ||
|
|
a84084b273 | ||
|
|
5ed8ff6dac | ||
|
|
b295f931a3 | ||
|
|
bff8529c9f | ||
|
|
f819d0d743 | ||
|
|
1534433949 | ||
|
|
daf44ae797 | ||
|
|
759635b364 | ||
|
|
96e60f6eaf | ||
|
|
a13428fb4e | ||
|
|
818d6c9ca5 | ||
|
|
a6df8f908b | ||
|
|
0d5c93bbde | ||
|
|
40dcca0e8d | ||
|
|
ef443bdfb0 | ||
|
|
a900a08095 | ||
|
|
fa94b83d63 | ||
|
|
5f119690c2 | ||
|
|
43071a4d91 | ||
|
|
4d4d50bc92 | ||
|
|
2e566b41a0 | ||
|
|
be5b23e9d1 | ||
|
|
448b408f94 | ||
|
|
e1422d8653 | ||
|
|
b353b93458 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -20,4 +20,5 @@ obj/
|
||||
[Rr]elease*/
|
||||
_ReSharper*/
|
||||
SIMPLSharpLogs/
|
||||
*.projectinfo
|
||||
*.projectinfo
|
||||
essentials-framework/EssentialDMTestConfig/
|
||||
|
||||
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,3 +0,0 @@
|
||||
[submodule "essentials-framework"]
|
||||
path = essentials-framework
|
||||
url = https://bitbucket.org/Pepperdash_Products/essentials-framework.git
|
||||
|
||||
BIN
IR Drivers/samsung_un_series.ir
Normal file
BIN
IR Drivers/samsung_un_series.ir
Normal file
Binary file not shown.
@@ -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
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,102 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
using PepperDash.Essentials.Devices.Common.Codec;
|
||||
using PepperDash.Essentials.Devices.Common.AudioCodec;
|
||||
|
||||
namespace PepperDash.Essentials.AppServer.Messengers
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides a messaging bridge for an AudioCodecBase device
|
||||
/// </summary>
|
||||
public class AudioCodecBaseMessenger : MessengerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Device being bridged
|
||||
/// </summary>
|
||||
public AudioCodecBase Codec { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constuctor
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="codec"></param>
|
||||
/// <param name="messagePath"></param>
|
||||
public AudioCodecBaseMessenger(string key, AudioCodecBase codec, string messagePath)
|
||||
: base(key, messagePath)
|
||||
{
|
||||
if (codec == null)
|
||||
throw new ArgumentNullException("codec");
|
||||
|
||||
Codec = codec;
|
||||
codec.CallStatusChange += new EventHandler<CodecCallStatusItemChangeEventArgs>(codec_CallStatusChange);
|
||||
|
||||
}
|
||||
|
||||
protected override void CustomRegisterWithAppServer(CotijaSystemController appServerController)
|
||||
{
|
||||
appServerController.AddAction(MessagePath + "/fullStatus", new Action(SendAtcFullMessageObject));
|
||||
appServerController.AddAction(MessagePath + "/dial", new Action<string>(s => Codec.Dial(s)));
|
||||
appServerController.AddAction(MessagePath + "/endCallById", new Action<string>(s =>
|
||||
{
|
||||
var call = GetCallWithId(s);
|
||||
if (call != null)
|
||||
Codec.EndCall(call);
|
||||
}));
|
||||
appServerController.AddAction(MessagePath + "/endAllCalls", new Action(Codec.EndAllCalls));
|
||||
appServerController.AddAction(MessagePath + "/dtmf", new Action<string>(s => Codec.SendDtmf(s)));
|
||||
appServerController.AddAction(MessagePath + "/rejectById", new Action<string>(s =>
|
||||
{
|
||||
var call = GetCallWithId(s);
|
||||
if (call != null)
|
||||
Codec.RejectCall(call);
|
||||
}));
|
||||
appServerController.AddAction(MessagePath + "/acceptById", new Action<string>(s =>
|
||||
{
|
||||
var call = GetCallWithId(s);
|
||||
if (call != null)
|
||||
Codec.AcceptCall(call);
|
||||
}));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper to grab a call with string ID
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
CodecActiveCallItem GetCallWithId(string id)
|
||||
{
|
||||
return Codec.ActiveCalls.FirstOrDefault(c => c.Id == id);
|
||||
}
|
||||
|
||||
void codec_CallStatusChange(object sender, CodecCallStatusItemChangeEventArgs e)
|
||||
{
|
||||
SendAtcFullMessageObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method to build call status for vtc
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
void SendAtcFullMessageObject()
|
||||
{
|
||||
|
||||
var info = Codec.CodecInfo;
|
||||
PostStatusMessage(new
|
||||
{
|
||||
isInCall = Codec.IsInCall,
|
||||
calls = Codec.ActiveCalls,
|
||||
info = new
|
||||
{
|
||||
phoneNumber = info.PhoneNumber
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
75
PepperDashEssentials/AppServer/Messengers/ConfigMessenger.cs
Normal file
75
PepperDashEssentials/AppServer/Messengers/ConfigMessenger.cs
Normal 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
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
216
PepperDashEssentials/AppServer/Messengers/Ddvc01AtcMessenger.cs
Normal file
216
PepperDashEssentials/AppServer/Messengers/Ddvc01AtcMessenger.cs
Normal file
@@ -0,0 +1,216 @@
|
||||
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 Ddvc01AtcMessenger : MessengerBase
|
||||
{
|
||||
BasicTriList EISC;
|
||||
|
||||
/// <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>
|
||||
/// 201
|
||||
/// </summary>
|
||||
const uint SCurrentDialString = 201;
|
||||
/// <summary>
|
||||
/// 211
|
||||
/// </summary>
|
||||
const uint SCurrentCallNumber = 211;
|
||||
/// <summary>
|
||||
/// 212
|
||||
/// </summary>
|
||||
const uint SCurrentCallName = 212;
|
||||
/// <summary>
|
||||
/// 221
|
||||
/// </summary>
|
||||
const uint SHookState = 221;
|
||||
/// <summary>
|
||||
/// 222
|
||||
/// </summary>
|
||||
const uint SCallDirection = 222;
|
||||
|
||||
/// <summary>
|
||||
/// 201-212 0-9*#
|
||||
/// </summary>
|
||||
Dictionary<string, uint> DTMFMap = new Dictionary<string, uint>
|
||||
{
|
||||
{ "1", 201 },
|
||||
{ "2", 202 },
|
||||
{ "3", 203 },
|
||||
{ "4", 204 },
|
||||
{ "5", 205 },
|
||||
{ "6", 206 },
|
||||
{ "7", 207 },
|
||||
{ "8", 208 },
|
||||
{ "9", 209 },
|
||||
{ "0", 210 },
|
||||
{ "*", 211 },
|
||||
{ "#", 212 },
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
CodecActiveCallItem CurrentCallItem;
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="eisc"></param>
|
||||
/// <param name="messagePath"></param>
|
||||
public Ddvc01AtcMessenger(string key, BasicTriList eisc, string messagePath)
|
||||
: base(key, messagePath)
|
||||
{
|
||||
EISC = eisc;
|
||||
|
||||
CurrentCallItem = new CodecActiveCallItem();
|
||||
CurrentCallItem.Type = eCodecCallType.Audio;
|
||||
CurrentCallItem.Id = "-audio-";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
void SendFullStatus()
|
||||
{
|
||||
|
||||
|
||||
this.PostStatusMessage(new
|
||||
{
|
||||
calls = GetCurrentCallList(),
|
||||
currentCallString = EISC.GetString(SCurrentCallNumber),
|
||||
currentDialString = EISC.GetString(SCurrentDialString),
|
||||
isInCall = EISC.GetString(SHookState) == "Connected"
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="appServerController"></param>
|
||||
protected override void CustomRegisterWithAppServer(CotijaSystemController appServerController)
|
||||
{
|
||||
//EISC.SetStringSigAction(SCurrentDialString, s => PostStatusMessage(new { currentDialString = s }));
|
||||
|
||||
EISC.SetStringSigAction(SHookState, s =>
|
||||
{
|
||||
CurrentCallItem.Status = (eCodecCallStatus)Enum.Parse(typeof(eCodecCallStatus), s, true);
|
||||
//GetCurrentCallList();
|
||||
SendFullStatus();
|
||||
});
|
||||
|
||||
EISC.SetStringSigAction(SCurrentCallNumber, s =>
|
||||
{
|
||||
CurrentCallItem.Number = s;
|
||||
SendCallsList();
|
||||
});
|
||||
|
||||
EISC.SetStringSigAction(SCurrentCallName, s =>
|
||||
{
|
||||
CurrentCallItem.Name = s;
|
||||
SendCallsList();
|
||||
});
|
||||
|
||||
EISC.SetStringSigAction(SCallDirection, s =>
|
||||
{
|
||||
CurrentCallItem.Direction = (eCodecCallDirection)Enum.Parse(typeof(eCodecCallDirection), s, true);
|
||||
SendCallsList();
|
||||
});
|
||||
|
||||
// Add press and holds using helper
|
||||
Action<string, uint> addPHAction = (s, u) =>
|
||||
AppServerController.AddAction(MessagePath + s, new PressAndHoldAction(b => EISC.SetBool(u, b)));
|
||||
|
||||
// Add straight pulse calls
|
||||
Action<string, uint> addAction = (s, u) =>
|
||||
AppServerController.AddAction(MessagePath + s, new Action(() => EISC.PulseBool(u, 100)));
|
||||
addAction("/endCallById", BDialHangupOnHook);
|
||||
addAction("/endAllCalls", BDialHangupOnHook);
|
||||
addAction("/acceptById", BIncomingAnswer);
|
||||
addAction("/rejectById", BIncomingReject);
|
||||
addAction("/speedDial1", BSpeedDial1);
|
||||
addAction("/speedDial2", BSpeedDial2);
|
||||
addAction("/speedDial3", BSpeedDial3);
|
||||
addAction("/speedDial4", BSpeedDial4);
|
||||
|
||||
// Get status
|
||||
AppServerController.AddAction(MessagePath + "/fullStatus", new Action(SendFullStatus));
|
||||
// Dial on string
|
||||
AppServerController.AddAction(MessagePath + "/dial", new Action<string>(s => EISC.SetString(SCurrentDialString, s)));
|
||||
// Pulse DTMF
|
||||
AppServerController.AddAction(MessagePath + "/dtmf", new Action<string>(s =>
|
||||
{
|
||||
if (DTMFMap.ContainsKey(s))
|
||||
{
|
||||
EISC.PulseBool(DTMFMap[s], 100);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
void SendCallsList()
|
||||
{
|
||||
PostStatusMessage(new
|
||||
{
|
||||
calls = GetCurrentCallList(),
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Turns the
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
List<CodecActiveCallItem> GetCurrentCallList()
|
||||
{
|
||||
if (CurrentCallItem.Status == eCodecCallStatus.Disconnected)
|
||||
{
|
||||
return new List<CodecActiveCallItem>();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new List<CodecActiveCallItem>() { CurrentCallItem };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
623
PepperDashEssentials/AppServer/Messengers/Ddvc01VtcMessenger.cs
Normal file
623
PepperDashEssentials/AppServer/Messengers/Ddvc01VtcMessenger.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
81
PepperDashEssentials/AppServer/Messengers/MessengerBase.cs
Normal file
81
PepperDashEssentials/AppServer/Messengers/MessengerBase.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
using PepperDash.Core;
|
||||
|
||||
using PepperDash.Essentials.Devices.Common.Codec;
|
||||
using PepperDash.Essentials.Devices.Common.VideoCodec;
|
||||
|
||||
namespace PepperDash.Essentials.AppServer.Messengers
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides a messaging bridge for a VideoCodecBase
|
||||
/// </summary>
|
||||
public abstract class MessengerBase : IKeyed
|
||||
{
|
||||
public string Key { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public CotijaSystemController AppServerController { get; private set; }
|
||||
|
||||
public string MessagePath { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="codec"></param>
|
||||
public MessengerBase(string key, string messagePath)
|
||||
{
|
||||
Key = key;
|
||||
|
||||
if (string.IsNullOrEmpty(messagePath))
|
||||
throw new ArgumentException("messagePath must not be empty or null");
|
||||
|
||||
MessagePath = messagePath;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Registers this messenger with appserver controller
|
||||
/// </summary>
|
||||
/// <param name="appServerController"></param>
|
||||
public void RegisterWithAppServer(CotijaSystemController appServerController)
|
||||
{
|
||||
if (appServerController == null)
|
||||
throw new ArgumentNullException("appServerController");
|
||||
|
||||
AppServerController = appServerController;
|
||||
CustomRegisterWithAppServer(AppServerController);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implemented in extending classes. Wire up API calls and feedback here
|
||||
/// </summary>
|
||||
/// <param name="appServerController"></param>
|
||||
abstract protected void CustomRegisterWithAppServer(CotijaSystemController appServerController);
|
||||
|
||||
/// <summary>
|
||||
/// Helper for posting status message
|
||||
/// </summary>
|
||||
/// <param name="contentObject">The contents of the content object</param>
|
||||
protected void PostStatusMessage(object contentObject)
|
||||
{
|
||||
if (AppServerController != null)
|
||||
{
|
||||
AppServerController.SendMessageToServer(JObject.FromObject(new
|
||||
{
|
||||
type = MessagePath,
|
||||
content = contentObject
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
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.Monitoring;
|
||||
|
||||
namespace PepperDash.Essentials.AppServer.Messengers
|
||||
{
|
||||
public class SystemMonitorMessenger : MessengerBase
|
||||
{
|
||||
public SystemMonitorController SysMon { get; private set; }
|
||||
|
||||
public SystemMonitorMessenger(string key, SystemMonitorController sysMon, string messagePath)
|
||||
: base(key, messagePath)
|
||||
{
|
||||
if (sysMon == null)
|
||||
throw new ArgumentNullException("sysMon");
|
||||
|
||||
SysMon = sysMon;
|
||||
|
||||
SysMon.SystemMonitorPropertiesChanged += new EventHandler<EventArgs>(SysMon_SystemMonitorPropertiesChanged);
|
||||
|
||||
foreach (var p in SysMon.ProgramStatusFeedbackCollection)
|
||||
{
|
||||
p.Value.ProgramInfoChanged += new EventHandler<ProgramInfoEventArgs>(ProgramInfoChanged);
|
||||
}
|
||||
|
||||
CrestronConsole.AddNewConsoleCommand(s => SendFullStatusMessage(), "SendFullSysMonStatus", "Sends the full System Monitor Status", ConsoleAccessLevelEnum.AccessOperator);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Posts the program information message
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void ProgramInfoChanged(object sender, ProgramInfoEventArgs e)
|
||||
{
|
||||
if (e.ProgramInfo != null)
|
||||
{
|
||||
//Debug.Console(1, "Posting Status Message: {0}", e.ProgramInfo.ToString());
|
||||
PostStatusMessage(e.ProgramInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Posts the system monitor properties
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void SysMon_SystemMonitorPropertiesChanged(object sender, EventArgs e)
|
||||
{
|
||||
SendSystemMonitorStatusMessage();
|
||||
}
|
||||
|
||||
void SendFullStatusMessage()
|
||||
{
|
||||
SendSystemMonitorStatusMessage();
|
||||
|
||||
foreach (var p in SysMon.ProgramStatusFeedbackCollection)
|
||||
{
|
||||
PostStatusMessage(p.Value.ProgramInfo);
|
||||
}
|
||||
}
|
||||
|
||||
void SendSystemMonitorStatusMessage()
|
||||
{
|
||||
Debug.Console(1, "Posting System Monitor Status Message.");
|
||||
|
||||
// This takes a while, launch a new thread
|
||||
CrestronInvoke.BeginInvoke((o) =>
|
||||
{
|
||||
PostStatusMessage(new
|
||||
{
|
||||
timeZone = SysMon.TimeZoneFeedback.IntValue,
|
||||
timeZoneName = SysMon.TimeZoneTextFeedback.StringValue,
|
||||
ioControllerVersion = SysMon.IOControllerVersionFeedback.StringValue,
|
||||
snmpVersion = SysMon.SnmpVersionFeedback.StringValue,
|
||||
bacnetVersion = SysMon.BACnetAppVersionFeedback.StringValue,
|
||||
controllerVersion = SysMon.ControllerVersionFeedback.StringValue
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
protected override void CustomRegisterWithAppServer(CotijaSystemController appServerController)
|
||||
{
|
||||
AppServerController.AddAction(MessagePath + "/fullStatus", new Action(SendFullStatusMessage));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -8,36 +8,31 @@ 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
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides a messaging bridge for a VideoCodecBase
|
||||
/// Provides a messaging bridge for a VideoCodecBase device
|
||||
/// </summary>
|
||||
public class VideoCodecBaseMessenger
|
||||
public class VideoCodecBaseMessenger : MessengerBase
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public VideoCodecBase Codec { get; private set; }
|
||||
|
||||
public CotijaSystemController AppServerController { get; private set; }
|
||||
|
||||
public string MessagePath { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="codec"></param>
|
||||
public VideoCodecBaseMessenger(VideoCodecBase codec, string messagePath)
|
||||
public VideoCodecBaseMessenger(string key, VideoCodecBase codec, string messagePath)
|
||||
: base(key, messagePath)
|
||||
{
|
||||
if (codec == null)
|
||||
throw new ArgumentNullException("codec");
|
||||
if (string.IsNullOrEmpty(messagePath))
|
||||
throw new ArgumentException("messagePath must not be empty or null");
|
||||
|
||||
MessagePath = messagePath;
|
||||
Codec = codec;
|
||||
codec.CallStatusChange += new EventHandler<CodecCallStatusItemChangeEventArgs>(codec_CallStatusChange);
|
||||
codec.IsReadyChange += new EventHandler<EventArgs>(codec_IsReadyChange);
|
||||
@@ -46,8 +41,33 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
||||
if (dirCodec != null)
|
||||
{
|
||||
dirCodec.DirectoryResultReturned += new EventHandler<DirectoryEventArgs>(dirCodec_DirectoryResultReturned);
|
||||
|
||||
}
|
||||
|
||||
var recCodec = codec as IHasCallHistory;
|
||||
if (recCodec != null)
|
||||
{
|
||||
recCodec.CallHistory.RecentCallsListHasChanged += new EventHandler<EventArgs>(CallHistory_RecentCallsListHasChanged);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void CallHistory_RecentCallsListHasChanged(object sender, EventArgs e)
|
||||
{
|
||||
var recents = (sender as CodecCallHistory).RecentCalls;
|
||||
|
||||
if (recents != null)
|
||||
{
|
||||
PostStatusMessage(new
|
||||
{
|
||||
recentCalls = recents
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -56,13 +76,73 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
||||
/// <param name="e"></param>
|
||||
void dirCodec_DirectoryResultReturned(object sender, DirectoryEventArgs e)
|
||||
{
|
||||
var dir = e.Directory;
|
||||
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>
|
||||
@@ -77,16 +157,11 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers this codec's messaging with an app server controller
|
||||
/// Called from base's RegisterWithAppServer method
|
||||
/// </summary>
|
||||
/// <param name="appServerController"></param>
|
||||
public void RegisterWithAppServer(CotijaSystemController appServerController)
|
||||
protected override void CustomRegisterWithAppServer(CotijaSystemController appServerController)
|
||||
{
|
||||
if (appServerController == null)
|
||||
throw new ArgumentNullException("appServerController");
|
||||
|
||||
AppServerController = appServerController;
|
||||
|
||||
appServerController.AddAction("/device/videoCodec/isReady", new Action(SendIsReady));
|
||||
appServerController.AddAction("/device/videoCodec/fullStatus", new Action(SendVtcFullMessageObject));
|
||||
appServerController.AddAction("/device/videoCodec/dial", new Action<string>(s => Codec.Dial(s)));
|
||||
@@ -110,9 +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)));
|
||||
|
||||
// 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));
|
||||
@@ -122,6 +212,24 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
||||
appServerController.AddAction(MessagePath + "/standbyOff", new Action(Codec.StandbyDeactivate));
|
||||
}
|
||||
|
||||
void GetCallHistory()
|
||||
{
|
||||
var codec = (Codec as IHasCallHistory);
|
||||
|
||||
if (codec != null)
|
||||
{
|
||||
var recents = codec.CallHistory.RecentCalls;
|
||||
|
||||
if (recents != null)
|
||||
{
|
||||
PostStatusMessage(new
|
||||
{
|
||||
recentCalls = recents
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void GetFullStatusMessage()
|
||||
{
|
||||
|
||||
@@ -184,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>
|
||||
@@ -239,21 +363,11 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
||||
sipURI = info.SipUri
|
||||
},
|
||||
showSelfViewByDefault = Codec.ShowSelfViewByDefault,
|
||||
hasDirectory = Codec is IHasDirectory
|
||||
hasDirectory = Codec is IHasDirectory,
|
||||
hasDirectorySearch = true,
|
||||
hasRecents = Codec is IHasCallHistory,
|
||||
hasCameras = Codec is IHasCodecCameras
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper for posting status message
|
||||
/// </summary>
|
||||
/// <param name="contentObject">The contents of the content object</param>
|
||||
void PostStatusMessage(object contentObject)
|
||||
{
|
||||
AppServerController.SendMessageToServer(JObject.FromObject(new
|
||||
{
|
||||
type = MessagePath,
|
||||
content = contentObject
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.AppServer.Messengers;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using PepperDash.Essentials.Room.Config;
|
||||
@@ -26,18 +27,31 @@ namespace PepperDash.Essentials.Room.Cotija
|
||||
/// </summary>
|
||||
public const uint RoomIsOn = 301;
|
||||
|
||||
/// <summary>
|
||||
/// 12
|
||||
/// </summary>
|
||||
public const uint PrivacyMute = 12;
|
||||
|
||||
/// <summary>
|
||||
/// 41
|
||||
/// </summary>
|
||||
public const uint PromptForCode = 41;
|
||||
/// <summary>
|
||||
/// 42
|
||||
/// </summary>
|
||||
public const uint ClientJoined = 42;
|
||||
/// <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
|
||||
@@ -47,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>
|
||||
@@ -60,17 +77,31 @@ namespace PepperDash.Essentials.Room.Cotija
|
||||
/// 63
|
||||
/// </summary>
|
||||
public const uint ShutdownStart = 63;
|
||||
|
||||
|
||||
|
||||
/// <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>
|
||||
public const uint SpeedDialVisibleStartJoin = 261;
|
||||
/// <summary>
|
||||
/// 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
|
||||
@@ -79,19 +110,40 @@ 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>
|
||||
public const uint SelectedSourceKey = 71;
|
||||
|
||||
/// <summary>
|
||||
/// 241
|
||||
/// </summary>
|
||||
public const uint SpeedDialNameStartJoin = 241;
|
||||
|
||||
/// <summary>
|
||||
/// 251
|
||||
/// </summary>
|
||||
public const uint SpeedDialNumberStartJoin = 251;
|
||||
|
||||
/// <summary>
|
||||
/// 501
|
||||
@@ -121,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>
|
||||
@@ -145,6 +229,9 @@ namespace PepperDash.Essentials.Room.Cotija
|
||||
|
||||
CotijaDdvc01DeviceBridge SourceBridge;
|
||||
|
||||
Ddvc01AtcMessenger AtcMessenger;
|
||||
Ddvc01VtcMessenger VtcMessenger;
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -182,6 +269,14 @@ namespace PepperDash.Essentials.Room.Cotija
|
||||
SetupFunctions();
|
||||
SetupFeedbacks();
|
||||
|
||||
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) =>
|
||||
{
|
||||
@@ -216,8 +311,6 @@ namespace PepperDash.Essentials.Room.Cotija
|
||||
}
|
||||
}, "mobilebridgedump", "Dumps DDVC01 bridge EISC data b,u,s", ConsoleAccessLevelEnum.AccessOperator);
|
||||
|
||||
CrestronConsole.AddNewConsoleCommand(s => LoadConfigValues(), "loadddvc", "", ConsoleAccessLevelEnum.AccessOperator);
|
||||
|
||||
return base.CustomActivate();
|
||||
}
|
||||
|
||||
@@ -227,6 +320,8 @@ namespace PepperDash.Essentials.Room.Cotija
|
||||
/// </summary>
|
||||
void SetupFunctions()
|
||||
{
|
||||
Parent.AddAction(@"/room/room1/promptForCode", new Action(() => EISC.PulseBool(BoolJoin.PromptForCode)));
|
||||
Parent.AddAction(@"/room/room1/clientJoined", new Action(() => EISC.PulseBool(BoolJoin.ClientJoined)));
|
||||
|
||||
Parent.AddAction(@"/room/room1/status", new Action(SendFullStatus));
|
||||
|
||||
@@ -237,12 +332,26 @@ namespace PepperDash.Essentials.Room.Cotija
|
||||
}));
|
||||
|
||||
Parent.AddAction(@"/room/room1/defaultsource", new Action(() =>
|
||||
EISC.PulseBool(BoolJoin.ActivitySharePress)));
|
||||
EISC.PulseBool(BoolJoin.ActivityShare)));
|
||||
Parent.AddAction(@"/room/room1/activityPhone", new Action(() =>
|
||||
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)));
|
||||
@@ -250,20 +359,26 @@ namespace PepperDash.Essentials.Room.Cotija
|
||||
EISC.PulseBool(BoolJoin.ShutdownEnd)));
|
||||
Parent.AddAction(@"/room/room1/shutdownCancel", new Action(() =>
|
||||
EISC.PulseBool(BoolJoin.ShutdownCancel)));
|
||||
|
||||
|
||||
// Source Device (Current Source)'
|
||||
|
||||
SourceDeviceMapDictionary sourceJoinMap = new SourceDeviceMapDictionary();
|
||||
|
||||
var prefix = @"/device/currentSource/";
|
||||
|
||||
foreach (var item in sourceJoinMap)
|
||||
{
|
||||
Parent.AddAction(string.Format("{0}{1}", prefix, item.Key), new PressAndHoldAction(b => EISC.SetBool(item.Value, b)));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="devKey"></param>
|
||||
void SetupSourceFunctions(string devKey)
|
||||
{
|
||||
SourceDeviceMapDictionary sourceJoinMap = new SourceDeviceMapDictionary();
|
||||
|
||||
var prefix = string.Format("/device/{0}/", devKey);
|
||||
|
||||
foreach (var item in sourceJoinMap)
|
||||
{
|
||||
var join = item.Value;
|
||||
Parent.AddAction(string.Format("{0}{1}", prefix, item.Key), new PressAndHoldAction(b => EISC.SetBool(join, b)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Links feedbacks to whatever is gonna happen!
|
||||
/// </summary>
|
||||
@@ -295,7 +410,6 @@ namespace PepperDash.Essentials.Room.Cotija
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
EISC.SetBoolSigAction(BoolJoin.MasterVolumeIsMuted, b =>
|
||||
PostStatusMessage(new
|
||||
{
|
||||
@@ -307,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
|
||||
@@ -329,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>
|
||||
@@ -345,10 +518,10 @@ namespace PepperDash.Essentials.Room.Cotija
|
||||
var version = Assembly.GetExecutingAssembly().GetName().Version;
|
||||
co.Info.RuntimeInfo.AssemblyVersion = string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Build);
|
||||
|
||||
|
||||
//Room
|
||||
if (co.Rooms == null)
|
||||
co.Rooms = new List<DeviceConfig>();
|
||||
//if (co.Rooms == null)
|
||||
// always start fresh in case simpl changed
|
||||
co.Rooms = new List<DeviceConfig>();
|
||||
var rm = new DeviceConfig();
|
||||
if (co.Rooms.Count == 0)
|
||||
{
|
||||
@@ -360,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";
|
||||
|
||||
@@ -371,25 +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 = "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>();
|
||||
@@ -403,7 +572,10 @@ namespace PepperDash.Essentials.Room.Cotija
|
||||
co.Devices = new List<DeviceConfig>();
|
||||
|
||||
// clear out previous DDVC devices
|
||||
co.Devices.RemoveAll(d => d.Key.StartsWith("source-", StringComparison.OrdinalIgnoreCase));
|
||||
co.Devices.RemoveAll(d =>
|
||||
d.Key.StartsWith("source-", StringComparison.OrdinalIgnoreCase)
|
||||
|| d.Key.Equals("audioCodec", StringComparison.OrdinalIgnoreCase)
|
||||
|| d.Key.Equals("videoCodec", StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
rmProps.SourceListKey = "default";
|
||||
rm.Properties = JToken.FromObject(rmProps);
|
||||
@@ -414,22 +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,
|
||||
DisableCodecSharing = disableShare,
|
||||
};
|
||||
newSl.Add(key, newSLI);
|
||||
|
||||
@@ -447,10 +636,97 @@ namespace PepperDash.Essentials.Room.Cotija
|
||||
Type = type
|
||||
};
|
||||
co.Devices.Add(devConf);
|
||||
|
||||
if (group.ToLower().StartsWith("settopbox")) // Add others here as needed
|
||||
{
|
||||
SetupSourceFunctions(key);
|
||||
}
|
||||
}
|
||||
|
||||
co.SourceLists.Add("default", newSl);
|
||||
|
||||
// Build "audioCodec" config if we need
|
||||
if (!string.IsNullOrEmpty(rmProps.AudioCodecKey))
|
||||
{
|
||||
var acFavs = new List<PepperDash.Essentials.Devices.Common.Codec.CodecActiveCallItem>();
|
||||
for (uint i = 0; i < 4; i++)
|
||||
{
|
||||
if (!EISC.GetBool(BoolJoin.SpeedDialVisibleStartJoin + i))
|
||||
{
|
||||
break;
|
||||
}
|
||||
acFavs.Add(new PepperDash.Essentials.Devices.Common.Codec.CodecActiveCallItem()
|
||||
{
|
||||
Name = EISC.GetString(StringJoin.SpeedDialNameStartJoin + i),
|
||||
Number = EISC.GetString(StringJoin.SpeedDialNumberStartJoin + i),
|
||||
Type = PepperDash.Essentials.Devices.Common.Codec.eCodecCallType.Audio
|
||||
});
|
||||
}
|
||||
|
||||
var acProps = new
|
||||
{
|
||||
favorites = acFavs
|
||||
};
|
||||
|
||||
var acStr = "audioCodec";
|
||||
var acConf = new DeviceConfig()
|
||||
{
|
||||
Group = acStr,
|
||||
Key = acStr,
|
||||
Name = acStr,
|
||||
Type = acStr,
|
||||
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));
|
||||
|
||||
var handler = ConfigurationIsReady;
|
||||
@@ -462,43 +738,48 @@ namespace PepperDash.Essentials.Room.Cotija
|
||||
ConfigIsLoaded = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
void SendFullStatus()
|
||||
{
|
||||
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
|
||||
@@ -513,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>
|
||||
@@ -585,86 +878,5 @@ namespace PepperDash.Essentials.Room.Cotija
|
||||
EISC.StringInput[StringJoin.UserCodeToSystem].StringValue = UserCode;
|
||||
EISC.StringInput[StringJoin.ServerUrl].StringValue = Parent.Config.ClientAppUrl;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="oldKey"></param>
|
||||
/// <param name="newKey"></param>
|
||||
void SourceChange(string oldKey, string newKey)
|
||||
{
|
||||
/* Example message
|
||||
* {
|
||||
"type":"/room/status",
|
||||
"content": {
|
||||
"selectedSourceKey": "off",
|
||||
}
|
||||
}
|
||||
*/
|
||||
//if (type == ChangeType.WillChange)
|
||||
//{
|
||||
// // Disconnect from previous source
|
||||
|
||||
// if (info != null)
|
||||
// {
|
||||
// var previousDev = info.SourceDevice;
|
||||
|
||||
// // device type interfaces
|
||||
// if (previousDev is ISetTopBoxControls)
|
||||
// (previousDev as ISetTopBoxControls).UnlinkActions(Parent);
|
||||
// // common interfaces
|
||||
// if (previousDev is IChannel)
|
||||
// (previousDev as IChannel).UnlinkActions(Parent);
|
||||
// if (previousDev is IColor)
|
||||
// (previousDev as IColor).UnlinkActions(Parent);
|
||||
// if (previousDev is IDPad)
|
||||
// (previousDev as IDPad).UnlinkActions(Parent);
|
||||
// if (previousDev is IDvr)
|
||||
// (previousDev as IDvr).UnlinkActions(Parent);
|
||||
// if (previousDev is INumericKeypad)
|
||||
// (previousDev as INumericKeypad).UnlinkActions(Parent);
|
||||
// if (previousDev is IPower)
|
||||
// (previousDev as IPower).UnlinkActions(Parent);
|
||||
// if (previousDev is ITransport)
|
||||
// (previousDev as ITransport).UnlinkActions(Parent);
|
||||
// }
|
||||
|
||||
|
||||
// var huddleRoom = room as EssentialsHuddleSpaceRoom;
|
||||
// JObject roomStatus = new JObject();
|
||||
// roomStatus.Add("selectedSourceKey", huddleRoom.CurrentSourceInfoKey);
|
||||
|
||||
// JObject message = new JObject();
|
||||
|
||||
// message.Add("type", "/room/status/");
|
||||
// message.Add("content", roomStatus);
|
||||
|
||||
// Parent.PostToServer(message);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// if (info != null)
|
||||
// {
|
||||
// var dev = info.SourceDevice;
|
||||
|
||||
// if (dev is ISetTopBoxControls)
|
||||
// (dev as ISetTopBoxControls).LinkActions(Parent);
|
||||
// if (dev is IChannel)
|
||||
// (dev as IChannel).LinkActions(Parent);
|
||||
// if (dev is IColor)
|
||||
// (dev as IColor).LinkActions(Parent);
|
||||
// if (dev is IDPad)
|
||||
// (dev as IDPad).LinkActions(Parent);
|
||||
// if (dev is IDvr)
|
||||
// (dev as IDvr).LinkActions(Parent);
|
||||
// if (dev is INumericKeypad)
|
||||
// (dev as INumericKeypad).LinkActions(Parent);
|
||||
// if (dev is IPower)
|
||||
// (dev as IPower).LinkActions(Parent);
|
||||
// if (dev is ITransport)
|
||||
// (dev as ITransport).LinkActions(Parent);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Room.Cotija;
|
||||
using PepperDash.Essentials.Devices.Common.Codec;
|
||||
using PepperDash.Essentials.Devices.Common.VideoCodec;
|
||||
using PepperDash.Essentials.Devices.Common.AudioCodec;
|
||||
|
||||
namespace PepperDash.Essentials
|
||||
{
|
||||
@@ -22,6 +23,9 @@ namespace PepperDash.Essentials
|
||||
|
||||
public VideoCodecBaseMessenger VCMessenger { get; private set; }
|
||||
|
||||
public AudioCodecBaseMessenger ACMessenger { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
@@ -74,7 +78,7 @@ namespace PepperDash.Essentials
|
||||
{
|
||||
Parent.AddAction(string.Format(@"/room/{0}/volumes/master/level", Room.Key), new Action<ushort>(u =>
|
||||
(volumeRoom.CurrentVolumeControls as IBasicVolumeWithFeedback).SetVolume(u)));
|
||||
Parent.AddAction(string.Format(@"/room/{0}/volumes/master/mute", Room.Key), new Action(() =>
|
||||
Parent.AddAction(string.Format(@"/room/{0}/volumes/master/muteToggle", Room.Key), new Action(() =>
|
||||
volumeRoom.CurrentVolumeControls.MuteToggle()));
|
||||
volumeRoom.CurrentVolumeDeviceChange += new EventHandler<VolumeDeviceChangeEventArgs>(Room_CurrentVolumeDeviceChange);
|
||||
|
||||
@@ -82,7 +86,7 @@ namespace PepperDash.Essentials
|
||||
var currentVolumeDevice = volumeRoom.CurrentVolumeControls as IBasicVolumeWithFeedback;
|
||||
if (currentVolumeDevice != null)
|
||||
{
|
||||
currentVolumeDevice.MuteFeedback.OutputChange += VolumeLevelFeedback_OutputChange;
|
||||
currentVolumeDevice.MuteFeedback.OutputChange += MuteFeedback_OutputChange;
|
||||
currentVolumeDevice.VolumeLevelFeedback.OutputChange += VolumeLevelFeedback_OutputChange;
|
||||
}
|
||||
}
|
||||
@@ -92,29 +96,25 @@ namespace PepperDash.Essentials
|
||||
sscRoom.CurrentSingleSourceChange += new SourceInfoChangeHandler(Room_CurrentSingleSourceChange);
|
||||
|
||||
var vcRoom = Room as IHasVideoCodec;
|
||||
if (vcRoom != null)
|
||||
if (vcRoom != null && vcRoom.VideoCodec != null)
|
||||
{
|
||||
var codec = vcRoom.VideoCodec;
|
||||
VCMessenger = new VideoCodecBaseMessenger(vcRoom.VideoCodec, "/device/videoCodec");
|
||||
var key = vcRoom.VideoCodec.Key + "-" + parent.Key;
|
||||
VCMessenger = new VideoCodecBaseMessenger(key, vcRoom.VideoCodec, "/device/videoCodec");
|
||||
VCMessenger.RegisterWithAppServer(Parent);
|
||||
|
||||
// May need to move this or remove this
|
||||
codec.CallStatusChange += new EventHandler<CodecCallStatusItemChangeEventArgs>(codec_CallStatusChange);
|
||||
|
||||
vcRoom.IsSharingFeedback.OutputChange += new EventHandler<FeedbackEventArgs>(IsSharingFeedback_OutputChange);
|
||||
|
||||
//Parent.AddAction("/device/videoCodec/dial", new Action<string>(s => codec.Dial(s)));
|
||||
//Parent.AddAction("/device/videoCodec/endCall", new Action<string>(s =>
|
||||
//{
|
||||
// var call = codec.ActiveCalls.FirstOrDefault(c => c.Id == s);
|
||||
// if (call != null)
|
||||
// {
|
||||
// codec.EndCall(call);
|
||||
// }
|
||||
//}));
|
||||
//Parent.AddAction("/device/videoCodec/endAllCalls", new Action(() => codec.EndAllCalls()));
|
||||
}
|
||||
|
||||
var acRoom = Room as IHasAudioCodec;
|
||||
if (acRoom != null && acRoom.AudioCodec != null)
|
||||
{
|
||||
var codec = acRoom.AudioCodec;
|
||||
var key = acRoom.AudioCodec.Key + "-" + parent.Key;
|
||||
ACMessenger = new AudioCodecBaseMessenger(key, acRoom.AudioCodec, "/device/audioCodec");
|
||||
ACMessenger.RegisterWithAppServer(Parent);
|
||||
}
|
||||
|
||||
var defCallRm = Room as IRunDefaultCallRoute;
|
||||
if (defCallRm != null)
|
||||
{
|
||||
@@ -169,18 +169,18 @@ namespace PepperDash.Essentials
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handler for codec changes
|
||||
/// </summary>
|
||||
void codec_CallStatusChange(object sender, CodecCallStatusItemChangeEventArgs e)
|
||||
{
|
||||
PostStatusMessage(new
|
||||
{
|
||||
calls = GetCallsMessageObject(),
|
||||
//vtc = GetVtcCallsMessageObject()
|
||||
});
|
||||
///// <summary>
|
||||
///// Handler for codec changes
|
||||
///// </summary>
|
||||
//void codec_CallStatusChange(object sender, CodecCallStatusItemChangeEventArgs e)
|
||||
//{
|
||||
// PostStatusMessage(new
|
||||
// {
|
||||
// calls = GetCallsMessageObject(),
|
||||
// //vtc = GetVtcCallsMessageObject()
|
||||
// });
|
||||
|
||||
}
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Helper for posting status message
|
||||
@@ -417,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, "");
|
||||
}
|
||||
@@ -425,53 +425,52 @@ namespace PepperDash.Essentials
|
||||
|
||||
PostStatusMessage(new
|
||||
{
|
||||
calls = GetCallsMessageObject(),
|
||||
//calls = GetCallsMessageObject(),
|
||||
isOn = room.OnFeedback.BoolValue,
|
||||
selectedSourceKey = sourceKey,
|
||||
vtc = GetVtcCallsMessageObject(),
|
||||
//vtc = GetVtcCallsMessageObject(),
|
||||
volumes = volumes
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper to return a anonymous object with the call data for JSON message
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
object GetCallsMessageObject()
|
||||
{
|
||||
var callRm = Room as IHasVideoCodec;
|
||||
if (callRm == null)
|
||||
return null;
|
||||
return new
|
||||
{
|
||||
activeCalls = callRm.VideoCodec.ActiveCalls,
|
||||
callType = callRm.CallTypeFeedback.IntValue,
|
||||
inCall = callRm.InCallFeedback.BoolValue,
|
||||
isSharing = callRm.IsSharingFeedback.BoolValue,
|
||||
privacyModeIsOn = callRm.PrivacyModeIsOnFeedback.BoolValue
|
||||
};
|
||||
}
|
||||
///// <summary>
|
||||
///// Helper to return a anonymous object with the call data for JSON message
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//object GetCallsMessageObject()
|
||||
//{
|
||||
// var callRm = Room as IHasVideoCodec;
|
||||
// if (callRm == null)
|
||||
// return null;
|
||||
// return new
|
||||
// {
|
||||
// activeCalls = callRm.VideoCodec.ActiveCalls,
|
||||
// callType = callRm.CallTypeFeedback.IntValue,
|
||||
// inCall = callRm.InCallFeedback.BoolValue,
|
||||
// isSharing = callRm.IsSharingFeedback.BoolValue,
|
||||
// privacyModeIsOn = callRm.PrivacyModeIsOnFeedback.BoolValue
|
||||
// };
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method to build call status for vtc
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
object GetVtcCallsMessageObject()
|
||||
{
|
||||
var callRm = Room as IHasVideoCodec;
|
||||
object vtc = null;
|
||||
if (callRm != null)
|
||||
{
|
||||
var codec = callRm.VideoCodec;
|
||||
vtc = new
|
||||
{
|
||||
isInCall = codec.IsInCall,
|
||||
calls = codec.ActiveCalls
|
||||
};
|
||||
}
|
||||
return vtc;
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// Helper method to build call status for vtc
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//object GetVtcCallsMessageObject()
|
||||
//{
|
||||
// var callRm = Room as IHasVideoCodec;
|
||||
// object vtc = null;
|
||||
// if (callRm != null)
|
||||
// {
|
||||
// var codec = callRm.VideoCodec;
|
||||
// vtc = new
|
||||
// {
|
||||
// isInCall = codec.IsInCall,
|
||||
// calls = codec.ActiveCalls
|
||||
// };
|
||||
// }
|
||||
// return vtc;
|
||||
//}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -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; }
|
||||
|
||||
|
||||
BIN
PepperDashEssentials/Bridges/._EssentialsLightsBridge.cs
Normal file
BIN
PepperDashEssentials/Bridges/._EssentialsLightsBridge.cs
Normal file
Binary file not shown.
122
PepperDashEssentials/Bridges/AirMediaControllerBridge.cs
Normal file
122
PepperDashEssentials/Bridges/AirMediaControllerBridge.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
75
PepperDashEssentials/Bridges/AppleTvBridge.cs
Normal file
75
PepperDashEssentials/Bridges/AppleTvBridge.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,17 @@ using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro.EthernetCommunication;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Lighting;
|
||||
using PepperDash.Essentials.Core.Devices;
|
||||
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;
|
||||
|
||||
namespace PepperDash.Essentials.Bridges
|
||||
{
|
||||
@@ -44,17 +52,162 @@ namespace PepperDash.Essentials.Bridges
|
||||
/// </summary>
|
||||
public class EiscApi : BridgeApi
|
||||
{
|
||||
public EiscApiPropertiesConfig PropertiesConfig { get; private set; }
|
||||
|
||||
public ThreeSeriesTcpIpEthernetIntersystemCommunications Eisc { get; private set; }
|
||||
|
||||
|
||||
public EiscApi(string key, uint ipid, string hostname) :
|
||||
base(key)
|
||||
public EiscApi(DeviceConfig dc) :
|
||||
base(dc.Key)
|
||||
{
|
||||
Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(ipid, hostname, Global.ControlSystem);
|
||||
PropertiesConfig = JsonConvert.DeserializeObject<EiscApiPropertiesConfig>(dc.Properties.ToString());
|
||||
|
||||
Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(PropertiesConfig.Control.IpIdInt, PropertiesConfig.Control.TcpSshProperties.Address, Global.ControlSystem);
|
||||
|
||||
Eisc.SigChange += new Crestron.SimplSharpPro.DeviceSupport.SigEventHandler(Eisc_SigChange);
|
||||
|
||||
Eisc.Register();
|
||||
|
||||
AddPostActivationAction( () =>
|
||||
{
|
||||
Debug.Console(1, this, "Linking Devices...");
|
||||
|
||||
foreach (var d in PropertiesConfig.Devices)
|
||||
{
|
||||
var device = DeviceManager.GetDeviceForKey(d.DeviceKey);
|
||||
|
||||
if (device != null)
|
||||
{
|
||||
if (device is PepperDash.Essentials.Core.Monitoring.SystemMonitorController)
|
||||
{
|
||||
(device as PepperDash.Essentials.Core.Monitoring.SystemMonitorController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
|
||||
continue;
|
||||
}
|
||||
else if (device is GenericComm)
|
||||
{
|
||||
(device as GenericComm).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
|
||||
continue;
|
||||
}
|
||||
//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 DisplayBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
|
||||
continue;
|
||||
}
|
||||
else if (device is DmChassisController)
|
||||
{
|
||||
(device as DmChassisController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
|
||||
continue;
|
||||
}
|
||||
|
||||
else if (device is DmTxControllerBase)
|
||||
{
|
||||
(device as DmTxControllerBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
|
||||
continue;
|
||||
}
|
||||
else if (device is DmRmcControllerBase)
|
||||
{
|
||||
(device as DmRmcControllerBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
|
||||
continue;
|
||||
}
|
||||
else if (device is GenericRelayDevice)
|
||||
{
|
||||
(device as GenericRelayDevice).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
|
||||
continue;
|
||||
}
|
||||
else if (device is IDigitalInput)
|
||||
{
|
||||
(device as IDigitalInput).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;
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Console(1, this, "Devices Linked.");
|
||||
});
|
||||
}
|
||||
|
||||
/// <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>
|
||||
@@ -65,8 +218,9 @@ namespace PepperDash.Essentials.Bridges
|
||||
void Eisc_SigChange(object currentDevice, Crestron.SimplSharpPro.SigEventArgs args)
|
||||
{
|
||||
if (Debug.Level >= 1)
|
||||
Debug.Console(1, this, "BridgeApi EISC change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue);
|
||||
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>)
|
||||
@@ -76,138 +230,27 @@ namespace PepperDash.Essentials.Bridges
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Defines each type and it's matching API type
|
||||
/// </summary>
|
||||
public static class DeviceApiFactory
|
||||
public class EiscApiPropertiesConfig
|
||||
{
|
||||
public static Dictionary<Type, Type> TypeMap = new Dictionary<Type, Type>
|
||||
[JsonProperty("control")]
|
||||
public EssentialsControlPropertiesConfig Control { get; set; }
|
||||
|
||||
[JsonProperty("devices")]
|
||||
public List<ApiDevice> Devices { get; set; }
|
||||
|
||||
|
||||
public class ApiDevice
|
||||
{
|
||||
{ typeof(DmChassisController), typeof(DmChassisControllerApi) },
|
||||
{ typeof(IBasicCommunication), typeof(IBasicCommunicationApi) }
|
||||
//{ typeof(SomeShittyDisplayController), typeof(SomeShittyDisplayControllerApi) }
|
||||
};
|
||||
}
|
||||
[JsonProperty("deviceKey")]
|
||||
public string DeviceKey { get; set; }
|
||||
|
||||
[JsonProperty("joinStart")]
|
||||
public uint JoinStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// API class for IBasicCommunication devices
|
||||
/// </summary>
|
||||
public class IBasicCommunicationApi : DeviceApiBase
|
||||
{
|
||||
public IBasicCommunication Device { get; set; }
|
||||
|
||||
SerialFeedback TextReceivedFeedback;
|
||||
|
||||
public IBasicCommunicationApi(IBasicCommunication dev)
|
||||
{
|
||||
TextReceivedFeedback = new SerialFeedback();
|
||||
|
||||
Device = dev;
|
||||
|
||||
SetupFeedbacks();
|
||||
|
||||
ActionApi = new Dictionary<string, Object>
|
||||
{
|
||||
{ "connect", new Action(Device.Connect) },
|
||||
{ "disconnect", new Action(Device.Disconnect) },
|
||||
{ "connectstate", new Action<bool>( b => ConnectByState(b) ) },
|
||||
{ "sendtext", new Action<string>( s => Device.SendText(s) ) }
|
||||
|
||||
};
|
||||
|
||||
FeedbackApi = new Dictionary<string, Feedback>
|
||||
{
|
||||
{ "isconnected", new BoolFeedback( () => Device.IsConnected ) },
|
||||
{ "textrecieved", TextReceivedFeedback }
|
||||
};
|
||||
[JsonProperty("joinMapKey")]
|
||||
public string JoinMapKey { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Controls connection based on state of input
|
||||
/// </summary>
|
||||
/// <param name="state"></param>
|
||||
void ConnectByState(bool state)
|
||||
{
|
||||
if (state)
|
||||
Device.Connect();
|
||||
else
|
||||
Device.Disconnect();
|
||||
}
|
||||
|
||||
void SetupFeedbacks()
|
||||
{
|
||||
Device.TextReceived += new EventHandler<GenericCommMethodReceiveTextArgs>(Device_TextReceived);
|
||||
|
||||
if(Device is ISocketStatus)
|
||||
(Device as ISocketStatus).ConnectionChange += new EventHandler<GenericSocketStatusChageEventArgs>(IBasicCommunicationApi_ConnectionChange);
|
||||
}
|
||||
|
||||
void IBasicCommunicationApi_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e)
|
||||
{
|
||||
FeedbackApi["isconnected"].FireUpdate();
|
||||
}
|
||||
|
||||
void Device_TextReceived(object sender, GenericCommMethodReceiveTextArgs e)
|
||||
{
|
||||
TextReceivedFeedback.FireUpdate(e.Text);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class DmChassisController : Device
|
||||
{
|
||||
public DmChassisController(string key)
|
||||
: base(key)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void SetInput(int input)
|
||||
{
|
||||
Debug.Console(2, this, "Dm Chassis {0}, input {1}", Key, input);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Each flavor of API is a static class with static properties and a static constructor that
|
||||
/// links up the things to do.
|
||||
/// </summary>
|
||||
public class DmChassisControllerApi : DeviceApiBase
|
||||
{
|
||||
IntFeedback Output1Feedback;
|
||||
IntFeedback Output2Feedback;
|
||||
|
||||
public DmChassisControllerApi(DmChassisController dev)
|
||||
{
|
||||
Output1Feedback = new IntFeedback( new Func<int>(() => 1));
|
||||
Output2Feedback = new IntFeedback( new Func<int>(() => 2));
|
||||
|
||||
ActionApi = new Dictionary<string, Object>
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
FeedbackApi = new Dictionary<string, Feedback>
|
||||
{
|
||||
{ "Output-1/fb", Output1Feedback },
|
||||
{ "Output-2/fb", Output2Feedback }
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Factory method
|
||||
/// </summary>
|
||||
/// <param name="dev"></param>
|
||||
/// <returns></returns>
|
||||
public static DmChassisControllerApi GetActionApiForDevice(DmChassisController dev)
|
||||
{
|
||||
return new DmChassisControllerApi(dev);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -9,83 +9,38 @@ using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core.Routing;
|
||||
using PepperDash.Essentials.Bridges;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.EthernetCommunication;
|
||||
|
||||
namespace PepperDash.Essentials
|
||||
namespace PepperDash.Essentials
|
||||
{
|
||||
public class BridgeFactory
|
||||
public class BridgeFactory
|
||||
{
|
||||
public static IKeyed GetDevice(PepperDash.Essentials.Core.Config.DeviceConfig dc)
|
||||
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 { };
|
||||
JsonConvert.DeserializeAnonymousType(dc.Properties.ToString(), propAnon);
|
||||
|
||||
var typeName = dc.Type.ToLower();
|
||||
var groupName = dc.Group.ToLower();
|
||||
// ? why is this static JTA 2018-06-13?
|
||||
|
||||
Debug.Console(0, "Name {0}, Key {1}, Type {2}, Properties {3}", name, key, type, properties.ToString());
|
||||
if (typeName == "dm")
|
||||
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();
|
||||
|
||||
//Debug.Console(2, "Name {0}, Key {1}, Type {2}, Properties {3}", name, key, type, properties.ToString());
|
||||
|
||||
if (typeName == "eiscapi")
|
||||
{
|
||||
return new DmBridge(key, name, properties);
|
||||
}
|
||||
else if (typeName == "comm")
|
||||
{
|
||||
return new CommBridge(key, name, properties);
|
||||
return new EiscApi(dc);
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class DmBridge : Device
|
||||
{
|
||||
public EiscBridgeProperties Properties { get; private set; }
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public PepperDash.Essentials.DM.DmChassisController DmSwitch { get; private set; }
|
||||
|
||||
public DmBridge(string key, string name, JToken properties) : base(key, name)
|
||||
{
|
||||
Properties = JsonConvert.DeserializeObject<EiscBridgeProperties>(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);
|
||||
|
||||
ApiEisc.Eisc.SetUShortSigAction(101, u => DmSwitch.ExecuteSwitch(u,1, eRoutingSignalType.Video));
|
||||
ApiEisc.Eisc.SetUShortSigAction(102, u => DmSwitch.ExecuteSwitch(u,2, eRoutingSignalType.Video));
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var device in DeviceManager.AllDevices)
|
||||
{
|
||||
if (device.Key == this.Properties.ParentDeviceKey)
|
||||
{
|
||||
Debug.Console(0, "deviceKey {0} Matches", device.Key);
|
||||
DmSwitch = DeviceManager.GetDeviceForKey(device.Key) as PepperDash.Essentials.DM.DmChassisController;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Console(0, "deviceKey {0} doesn't match", device.Key);
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Console(0, "Bridge {0} Activated", this.Name);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class CommBridge : Device
|
||||
{
|
||||
@@ -134,10 +89,10 @@ namespace PepperDash.Essentials
|
||||
}
|
||||
|
||||
|
||||
public class EiscBridgeProperties
|
||||
public class EiscBridgeProperties
|
||||
{
|
||||
public string ParentDeviceKey { get; set; }
|
||||
public eApiType ApiType { get; set; }
|
||||
public eApiType ApiType { get; set; }
|
||||
public List<EiscProperties> Eiscs { get; set; }
|
||||
public string ApiOverrideFilePath { get; set; }
|
||||
|
||||
@@ -146,7 +101,7 @@ namespace PepperDash.Essentials
|
||||
public string IpId { get; set; }
|
||||
public string Hostname { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class CommBridgeProperties : EiscBridgeProperties
|
||||
{
|
||||
@@ -155,30 +110,30 @@ namespace PepperDash.Essentials
|
||||
|
||||
public enum eApiType { Eisc = 0 }
|
||||
|
||||
public class BridgeApiEisc
|
||||
public class BridgeApiEisc
|
||||
{
|
||||
public uint Ipid { get; private set; }
|
||||
public ThreeSeriesTcpIpEthernetIntersystemCommunications Eisc { get; private set; }
|
||||
|
||||
public BridgeApiEisc(string ipid, string hostname)
|
||||
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)
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
90
PepperDashEssentials/Bridges/Bridges.BridgeFactory.cs
Normal file
90
PepperDashEssentials/Bridges/Bridges.BridgeFactory.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core.Routing;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.EthernetCommunication;
|
||||
using PepperDash.Essentials.Bridges;
|
||||
|
||||
namespace PepperDash.Essentials {
|
||||
public class BridgeFactory {
|
||||
public static IKeyed GetDevice(PepperDash.Essentials.Core.Config.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 { };
|
||||
JsonConvert.DeserializeAnonymousType(dc.Properties.ToString(), propAnon);
|
||||
|
||||
var typeName = dc.Type.ToLower();
|
||||
var groupName = dc.Group.ToLower();
|
||||
|
||||
Debug.Console(2, "Name {0}, Key {1}, Type {2}, Properties {3}", name, key, type, properties.ToString());
|
||||
if (typeName == "essentialdm")
|
||||
{
|
||||
return new EssentialDM(key, name, properties);
|
||||
}
|
||||
else if (typeName == "essentialcomm")
|
||||
{
|
||||
Debug.Console(2, "Launch Essential Comm");
|
||||
return new EssentialComm(key, name, properties);
|
||||
}
|
||||
else if (typeName == "essentialdsp")
|
||||
{
|
||||
Debug.Console(2, "Launch EssentialDsp");
|
||||
return new EssentialDsp(key, name, properties);
|
||||
}
|
||||
else if (typeName == "essentialstvone")
|
||||
{
|
||||
Debug.Console(2, "Launch essentialstvone");
|
||||
return new EssentialsTVOne(key, name, properties);
|
||||
}
|
||||
else if (typeName == "essentialslighting")
|
||||
{
|
||||
Debug.Console(2, "Launch essentialslighting");
|
||||
return new EssentialsLightsBridge(key, name, properties);
|
||||
}
|
||||
else if (typeName == "eiscapi")
|
||||
{
|
||||
return new EiscApi(dc);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public class BridgeApiEisc {
|
||||
public uint Ipid;
|
||||
public ThreeSeriesTcpIpEthernetIntersystemCommunications Eisc;
|
||||
public BridgeApiEisc(string ipid) {
|
||||
Ipid = (UInt32)int.Parse(ipid, System.Globalization.NumberStyles.HexNumber);
|
||||
Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(Ipid, "127.0.0.2", Global.ControlSystem);
|
||||
Eisc.Register();
|
||||
Eisc.SigChange += Eisc_SigChange;
|
||||
Debug.Console(2, "BridgeApiEisc Created at Ipid {0}", ipid);
|
||||
}
|
||||
void Eisc_SigChange(object currentDevice, Crestron.SimplSharpPro.SigEventArgs args) {
|
||||
if (Debug.Level >= 1)
|
||||
Debug.Console(2, "DDVC EISC 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
187
PepperDashEssentials/Bridges/CameraControllerBridge.cs
Normal file
187
PepperDashEssentials/Bridges/CameraControllerBridge.cs
Normal file
@@ -0,0 +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;
|
||||
|
||||
//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;
|
||||
|
||||
// _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());
|
||||
|
||||
// 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.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.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());
|
||||
|
||||
// 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);
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// }
|
||||
|
||||
|
||||
// }
|
||||
// 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 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;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
77
PepperDashEssentials/Bridges/DigitalLoggerBridge.cs
Normal file
77
PepperDashEssentials/Bridges/DigitalLoggerBridge.cs
Normal file
@@ -0,0 +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;
|
||||
|
||||
//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();
|
||||
|
||||
// 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 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;
|
||||
|
||||
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
//}
|
||||
222
PepperDashEssentials/Bridges/DisplayControllerBridge.cs
Normal file
222
PepperDashEssentials/Bridges/DisplayControllerBridge.cs
Normal file
@@ -0,0 +1,222 @@
|
||||
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 DisplayControllerApiExtensions
|
||||
{
|
||||
|
||||
public static int InputNumber;
|
||||
public static IntFeedback InputNumberFeedback;
|
||||
public static List<string> InputKeys = new List<string>();
|
||||
public static void LinkToApi(this PepperDash.Essentials.Core.DisplayBase displayDevice, BasicTriList trilist, uint joinStart, string joinMapKey)
|
||||
{
|
||||
|
||||
var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as DisplayControllerJoinMap;
|
||||
|
||||
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());
|
||||
|
||||
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();
|
||||
});
|
||||
|
||||
|
||||
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());
|
||||
|
||||
var volumeDisplayWithFeedback = volumeDisplay as IBasicVolumeWithFeedback;
|
||||
if(volumeDisplayWithFeedback != null)
|
||||
{
|
||||
volumeDisplayWithFeedback.VolumeLevelFeedback.LinkInputSig(trilist.UShortInput[joinMap.VolumeLevelFB]);
|
||||
volumeDisplayWithFeedback.MuteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VolumeMute]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void CurrentInputFeedback_OutputChange(object sender, FeedbackEventArgs e)
|
||||
{
|
||||
|
||||
Debug.Console(0, "CurrentInputFeedback_OutputChange {0}", e.StringValue);
|
||||
|
||||
}
|
||||
|
||||
static void PowerIsOnFeedback_OutputChange(object sender, FeedbackEventArgs e)
|
||||
{
|
||||
|
||||
// Debug.Console(0, "PowerIsOnFeedback_OutputChange {0}", e.BoolValue);
|
||||
if (!e.BoolValue)
|
||||
{
|
||||
InputNumber = 102;
|
||||
InputNumberFeedback.FireUpdate();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
InputNumber = 0;
|
||||
InputNumberFeedback.FireUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
public class DisplayControllerJoinMap : JoinMapBase
|
||||
{
|
||||
// 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 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()
|
||||
{
|
||||
// Digital
|
||||
IsOnline = 50;
|
||||
PowerOff = 1;
|
||||
PowerOn = 2;
|
||||
IsTwoWayDisplay = 3;
|
||||
VolumeUp = 5;
|
||||
VolumeDown = 6;
|
||||
VolumeMute = 7;
|
||||
|
||||
ButtonVisibilityOffset = 40;
|
||||
InputSelectOffset = 10;
|
||||
|
||||
// Analog
|
||||
InputSelect = 11;
|
||||
VolumeLevelFB = 5;
|
||||
|
||||
// Serial
|
||||
Name = 1;
|
||||
InputNamesOffset = 10;
|
||||
}
|
||||
|
||||
public override void OffsetJoinNumbers(uint joinStart)
|
||||
{
|
||||
var joinOffset = joinStart - 1;
|
||||
|
||||
IsOnline = IsOnline + joinOffset;
|
||||
PowerOff = PowerOff + joinOffset;
|
||||
PowerOn = PowerOn + joinOffset;
|
||||
IsTwoWayDisplay = IsTwoWayDisplay + joinOffset;
|
||||
ButtonVisibilityOffset = ButtonVisibilityOffset + joinOffset;
|
||||
Name = Name + joinOffset;
|
||||
InputNamesOffset = InputNamesOffset + joinOffset;
|
||||
InputSelectOffset = InputSelectOffset + joinOffset;
|
||||
|
||||
InputSelect = InputSelect + joinOffset;
|
||||
|
||||
VolumeUp = VolumeUp + joinOffset;
|
||||
VolumeDown = VolumeDown + joinOffset;
|
||||
VolumeMute = VolumeMute + joinOffset;
|
||||
VolumeLevelFB = VolumeLevelFB + joinOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
130
PepperDashEssentials/Bridges/DmChassisControllerBridge.cs
Normal file
130
PepperDashEssentials/Bridges/DmChassisControllerBridge.cs
Normal file
@@ -0,0 +1,130 @@
|
||||
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]);
|
||||
// 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]);
|
||||
// trilist.UShortInput[ApiMap.HdcpSupportCapability[ioSlot]].UShortValue = TxDevice.HdcpSupportCapability;
|
||||
}
|
||||
else
|
||||
{
|
||||
// dmChassis.VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[ApiMap.TxVideoSyncStatus[ioSlot]]);
|
||||
}
|
||||
if (dmChassis.RxDictionary.ContainsKey(ioSlot))
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
75
PepperDashEssentials/Bridges/DmRmcControllerBridge.cs
Normal file
75
PepperDashEssentials/Bridges/DmRmcControllerBridge.cs
Normal 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.DM;
|
||||
|
||||
namespace PepperDash.Essentials.Bridges
|
||||
{
|
||||
public static class DmRmcControllerApiExtensions
|
||||
{
|
||||
public static void LinkToApi(this DmRmcControllerBase rmc, BasicTriList trilist, uint joinStart, string joinMapKey)
|
||||
{
|
||||
var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as DmRmcControllerJoinMap;
|
||||
|
||||
if (joinMap == null)
|
||||
joinMap = new DmRmcControllerJoinMap();
|
||||
|
||||
joinMap.OffsetJoinNumbers(joinStart);
|
||||
|
||||
Debug.Console(1, rmc, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
||||
|
||||
rmc.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]);
|
||||
if(rmc.VideoOutputResolutionFeedback != null)
|
||||
rmc.VideoOutputResolutionFeedback.LinkInputSig(trilist.StringInput[joinMap.CurrentOutputResolution]);
|
||||
if(rmc.EdidManufacturerFeedback != null)
|
||||
rmc.EdidManufacturerFeedback.LinkInputSig(trilist.StringInput[joinMap.EdidManufacturer]);
|
||||
if(rmc.EdidNameFeedback != null)
|
||||
rmc.EdidNameFeedback.LinkInputSig(trilist.StringInput[joinMap.EdidName]);
|
||||
if(rmc.EdidPreferredTimingFeedback != null)
|
||||
rmc.EdidPreferredTimingFeedback.LinkInputSig(trilist.StringInput[joinMap.EdidPrefferedTiming]);
|
||||
if(rmc.EdidSerialNumberFeedback != null)
|
||||
rmc.EdidSerialNumberFeedback.LinkInputSig(trilist.StringInput[joinMap.EdidSerialNumber]);
|
||||
}
|
||||
|
||||
public class DmRmcControllerJoinMap : JoinMapBase
|
||||
{
|
||||
public uint IsOnline { get; set; }
|
||||
public uint CurrentOutputResolution { get; set; }
|
||||
public uint EdidManufacturer { get; set; }
|
||||
public uint EdidName { get; set; }
|
||||
public uint EdidPrefferedTiming { get; set; }
|
||||
public uint EdidSerialNumber { get; set; }
|
||||
|
||||
public DmRmcControllerJoinMap()
|
||||
{
|
||||
// Digital
|
||||
IsOnline = 1;
|
||||
|
||||
// Serial
|
||||
CurrentOutputResolution = 1;
|
||||
EdidManufacturer = 2;
|
||||
EdidName = 3;
|
||||
EdidPrefferedTiming = 4;
|
||||
EdidSerialNumber = 5;
|
||||
}
|
||||
|
||||
public override void OffsetJoinNumbers(uint joinStart)
|
||||
{
|
||||
var joinOffset = joinStart - 1;
|
||||
|
||||
IsOnline = IsOnline + joinOffset;
|
||||
CurrentOutputResolution = CurrentOutputResolution + joinOffset;
|
||||
EdidManufacturer = EdidManufacturer + joinOffset;
|
||||
EdidName = EdidName + joinOffset;
|
||||
EdidPrefferedTiming = EdidPrefferedTiming + joinOffset;
|
||||
EdidSerialNumber = EdidSerialNumber + joinOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
173
PepperDashEssentials/Bridges/DmTxControllerBridge.cs
Normal file
173
PepperDashEssentials/Bridges/DmTxControllerBridge.cs
Normal file
@@ -0,0 +1,173 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro.DM;
|
||||
using Crestron.SimplSharpPro.DM.Endpoints;
|
||||
using Crestron.SimplSharpPro.DM.Endpoints.Transmitters;
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.DM;
|
||||
|
||||
namespace PepperDash.Essentials.Bridges
|
||||
{
|
||||
public static class DmTxControllerApiExtensions
|
||||
{
|
||||
public static void LinkToApi(this DmTxControllerBase tx, BasicTriList trilist, uint joinStart, string joinMapKey)
|
||||
{
|
||||
var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as DmTxControllerJoinMap;
|
||||
|
||||
if (joinMap == null)
|
||||
joinMap = new DmTxControllerJoinMap();
|
||||
|
||||
joinMap.OffsetJoinNumbers(joinStart);
|
||||
|
||||
Debug.Console(1, tx, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
||||
|
||||
tx.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]);
|
||||
tx.AnyVideoInput.VideoStatus.VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus]);
|
||||
tx.AnyVideoInput.VideoStatus.VideoResolutionFeedback.LinkInputSig(trilist.StringInput[joinMap.CurrentInputResolution]);
|
||||
//tx.HdcpSupportAllFeedback.LinkInputSig(trilist.UShortInput[joinMap.HdcpSupportCapability]);
|
||||
|
||||
bool hdcpTypeSimple;
|
||||
|
||||
if (tx.Hardware is DmTx4kX02CBase || tx.Hardware is DmTx4kzX02CBase)
|
||||
hdcpTypeSimple = false;
|
||||
else
|
||||
hdcpTypeSimple = true;
|
||||
|
||||
if (tx is ITxRouting)
|
||||
{
|
||||
var txR = tx as ITxRouting;
|
||||
|
||||
trilist.SetUShortSigAction(joinMap.VideoInput,
|
||||
new Action<ushort>(i => txR.ExecuteNumericSwitch(i, 0, eRoutingSignalType.Video)));
|
||||
trilist.SetUShortSigAction(joinMap.AudioInput,
|
||||
new Action<ushort>(i => txR.ExecuteNumericSwitch(i, 0, eRoutingSignalType.Audio)));
|
||||
|
||||
txR.VideoSourceNumericFeedback.LinkInputSig(trilist.UShortInput[joinMap.VideoInput]);
|
||||
txR.AudioSourceNumericFeedback.LinkInputSig(trilist.UShortInput[joinMap.AudioInput]);
|
||||
|
||||
trilist.UShortInput[joinMap.HdcpSupportCapability].UShortValue = (ushort)tx.HdcpSupportCapability;
|
||||
|
||||
if(txR.InputPorts[DmPortName.HdmiIn] != null)
|
||||
{
|
||||
var inputPort = txR.InputPorts[DmPortName.HdmiIn];
|
||||
|
||||
if (tx.Feedbacks["HdmiInHdcpCapability"] != null)
|
||||
(tx.Feedbacks["HdmiInHdcpCapability"] as IntFeedback).LinkInputSig(trilist.UShortInput[joinMap.Port1HdcpState]);
|
||||
|
||||
if (inputPort.ConnectionType == eRoutingPortConnectionType.Hdmi && inputPort.Port != null)
|
||||
{
|
||||
var port = inputPort.Port as EndpointHdmiInput;
|
||||
|
||||
SetHdcpCapabilityAction(hdcpTypeSimple, port, joinMap.Port1HdcpState, trilist);
|
||||
}
|
||||
}
|
||||
|
||||
if (txR.InputPorts[DmPortName.HdmiIn1] != null)
|
||||
{
|
||||
var inputPort = txR.InputPorts[DmPortName.HdmiIn1];
|
||||
|
||||
if (tx.Feedbacks["HdmiIn1HdcpCapability"] != null)
|
||||
(tx.Feedbacks["HdmiIn1HdcpCapability"] as IntFeedback).LinkInputSig(trilist.UShortInput[joinMap.Port1HdcpState]);
|
||||
|
||||
if (inputPort.ConnectionType == eRoutingPortConnectionType.Hdmi && inputPort.Port != null)
|
||||
{
|
||||
var port = inputPort.Port as EndpointHdmiInput;
|
||||
|
||||
SetHdcpCapabilityAction(hdcpTypeSimple, port, joinMap.Port1HdcpState, trilist);
|
||||
}
|
||||
}
|
||||
|
||||
if (txR.InputPorts[DmPortName.HdmiIn2] != null)
|
||||
{
|
||||
var inputPort = txR.InputPorts[DmPortName.HdmiIn2];
|
||||
|
||||
if (tx.Feedbacks["HdmiIn2HdcpCapability"] != null)
|
||||
(tx.Feedbacks["HdmiIn2HdcpCapability"] as IntFeedback).LinkInputSig(trilist.UShortInput[joinMap.Port1HdcpState]);
|
||||
|
||||
if (inputPort.ConnectionType == eRoutingPortConnectionType.Hdmi && inputPort.Port != null)
|
||||
{
|
||||
var port = inputPort.Port as EndpointHdmiInput;
|
||||
|
||||
SetHdcpCapabilityAction(hdcpTypeSimple, port, joinMap.Port2HdcpState, trilist);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static void SetHdcpCapabilityAction(bool hdcpTypeSimple, EndpointHdmiInput port, uint join, BasicTriList trilist)
|
||||
{
|
||||
if (hdcpTypeSimple)
|
||||
{
|
||||
trilist.SetUShortSigAction(join,
|
||||
new Action<ushort>(s =>
|
||||
{
|
||||
if (s == 0)
|
||||
{
|
||||
port.HdcpSupportOff();
|
||||
}
|
||||
else if (s > 0)
|
||||
{
|
||||
port.HdcpSupportOn();
|
||||
}
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
trilist.SetUShortSigAction(join,
|
||||
new Action<ushort>(s =>
|
||||
{
|
||||
port.HdcpCapability = (eHdcpCapabilityType)s;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
public class DmTxControllerJoinMap : JoinMapBase
|
||||
{
|
||||
public uint IsOnline { get; set; }
|
||||
public uint VideoSyncStatus { get; set; }
|
||||
public uint CurrentInputResolution { get; set; }
|
||||
public uint HdcpSupportCapability { get; set; }
|
||||
public uint VideoInput { get; set; }
|
||||
public uint AudioInput { get; set; }
|
||||
public uint Port1HdcpState { get; set; }
|
||||
public uint Port2HdcpState { get; set; }
|
||||
|
||||
|
||||
public DmTxControllerJoinMap()
|
||||
{
|
||||
// Digital
|
||||
IsOnline = 1;
|
||||
VideoSyncStatus = 2;
|
||||
// Serial
|
||||
CurrentInputResolution = 1;
|
||||
// Analog
|
||||
VideoInput = 1;
|
||||
AudioInput = 2;
|
||||
HdcpSupportCapability = 3;
|
||||
Port1HdcpState = 4;
|
||||
Port2HdcpState = 5;
|
||||
}
|
||||
|
||||
public override void OffsetJoinNumbers(uint joinStart)
|
||||
{
|
||||
var joinOffset = joinStart - 1;
|
||||
|
||||
IsOnline = IsOnline + joinOffset;
|
||||
VideoSyncStatus = VideoSyncStatus + joinOffset;
|
||||
CurrentInputResolution = CurrentInputResolution + joinOffset;
|
||||
VideoInput = VideoInput + joinOffset;
|
||||
AudioInput = AudioInput + joinOffset;
|
||||
HdcpSupportCapability = HdcpSupportCapability + joinOffset;
|
||||
Port1HdcpState = Port1HdcpState + joinOffset;
|
||||
Port2HdcpState = Port2HdcpState + joinOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
120
PepperDashEssentials/Bridges/DspControllerBridge.cs
Normal file
120
PepperDashEssentials/Bridges/DspControllerBridge.cs
Normal file
@@ -0,0 +1,120 @@
|
||||
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 SamsungDisplayControllerApiExtensions
|
||||
{
|
||||
public static void LinkToApi(this PepperDash.Essentials.Core.TwoWayDisplayBase displayDevice, BasicTriList trilist, uint joinStart, string joinMapKey)
|
||||
{
|
||||
var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as DisplayControllerJoinMap;
|
||||
|
||||
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 lighting Type {0}", displayDevice.GetType().Name.ToString());
|
||||
|
||||
var commMonitor = displayDevice as ICommunicationMonitor;
|
||||
commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]);
|
||||
|
||||
|
||||
// Poewer Off
|
||||
trilist.SetSigTrueAction(joinMap.PowerOff, () => displayDevice.PowerOff());
|
||||
displayDevice.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PowerOff]);
|
||||
|
||||
// Poewer On
|
||||
trilist.SetSigTrueAction(joinMap.PowerOn, () => displayDevice.PowerOn());
|
||||
displayDevice.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn]);
|
||||
|
||||
// GenericLighitng Actions & FeedBack
|
||||
|
||||
// int sceneIndex = 1;
|
||||
/*
|
||||
foreach (var scene in displayDevice.LightingScenes)
|
||||
{
|
||||
var tempIndex = sceneIndex - 1;
|
||||
//trilist.SetSigTrueAction((uint)(joinMap.LightingSceneOffset + sceneIndex), () => displayDevice.SelectScene(displayDevice.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 (displayDevice.GetType().Name.ToString() == "LutronQuantumArea")
|
||||
{
|
||||
var lutronDevice = displayDevice 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; });
|
||||
|
||||
|
||||
/*
|
||||
var lutronLights = displayDevice 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));
|
||||
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
public class DisplayControllerJoinMap : JoinMapBase
|
||||
{
|
||||
public uint IsOnline { get; set; }
|
||||
public uint PowerOff { get; set; }
|
||||
public uint PowerOn { get; set; }
|
||||
public uint SelectScene { get; set; }
|
||||
public uint LightingSceneOffset { get; set; }
|
||||
public uint ButtonVisibilityOffset { get; set; }
|
||||
public uint IntegrationIdSet { get; set; }
|
||||
|
||||
public DisplayControllerJoinMap()
|
||||
{
|
||||
// Digital
|
||||
IsOnline = 1;
|
||||
PowerOff = 1;
|
||||
PowerOn = 2;
|
||||
SelectScene = 1;
|
||||
IntegrationIdSet = 1;
|
||||
LightingSceneOffset = 10;
|
||||
ButtonVisibilityOffset = 40;
|
||||
// Analog
|
||||
}
|
||||
|
||||
public override void OffsetJoinNumbers(uint joinStart)
|
||||
{
|
||||
var joinOffset = joinStart - 1;
|
||||
|
||||
IsOnline = IsOnline + joinOffset;
|
||||
PowerOff = PowerOff + joinOffset;
|
||||
PowerOn = PowerOn + joinOffset;
|
||||
SelectScene = SelectScene + joinOffset;
|
||||
LightingSceneOffset = LightingSceneOffset + joinOffset;
|
||||
ButtonVisibilityOffset = ButtonVisibilityOffset + joinOffset;
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
144
PepperDashEssentials/Bridges/EssentialComms.cs
Normal file
144
PepperDashEssentials/Bridges/EssentialComms.cs
Normal file
@@ -0,0 +1,144 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core.Routing;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.EthernetCommunication;
|
||||
using Crestron.SimplSharpPro.CrestronThread;
|
||||
|
||||
namespace PepperDash.Essentials {
|
||||
public class EssentialCommConfig {
|
||||
public string[] EiscApiIpids;
|
||||
public EssentialCommCommConnectionConfigs[] CommConnections;
|
||||
}
|
||||
public class EssentialCommCommConnectionConfigs {
|
||||
public uint joinNumber {get; set; }
|
||||
public EssentialsControlPropertiesConfig control { get; set; }
|
||||
}
|
||||
|
||||
public class EssentialCommsPort {
|
||||
public IBasicCommunication Comm;
|
||||
public IntFeedback StatusFeedback;
|
||||
public BoolFeedback ConnectedFeedback;
|
||||
public List<EssentialComApiMap> Outputs = new List<EssentialComApiMap>();
|
||||
public String RxBuffer;
|
||||
public EssentialCommsPort(EssentialsControlPropertiesConfig config, string keyPrefix) {
|
||||
Comm = CommFactory.CreateCommForConfig(config, keyPrefix);
|
||||
// var PortGather = new CommunicationGather(Comm, config.EndOfLineChar);
|
||||
Comm.TextReceived += new EventHandler<GenericCommMethodReceiveTextArgs>(Communication_TextReceived);
|
||||
|
||||
var socket = Comm as ISocketStatus;
|
||||
StatusFeedback = new IntFeedback(() => { return (int)socket.ClientStatus; });
|
||||
ConnectedFeedback = new BoolFeedback(() => { return Comm.IsConnected; });
|
||||
|
||||
if (socket != null) {
|
||||
socket.ConnectionChange += new EventHandler<GenericSocketStatusChageEventArgs>(socket_ConnectionChange);
|
||||
} else {
|
||||
}
|
||||
|
||||
}
|
||||
void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e) {
|
||||
StatusFeedback.FireUpdate();
|
||||
ConnectedFeedback.FireUpdate();
|
||||
if (e.Client.IsConnected) {
|
||||
// Tasks on connect
|
||||
} else {
|
||||
// Cleanup items from this session
|
||||
}
|
||||
}
|
||||
void Communication_TextReceived(object sender, GenericCommMethodReceiveTextArgs args) {
|
||||
try {
|
||||
foreach (var Output in Outputs) {
|
||||
Output.Api.Eisc.StringInput[Output.Join].StringValue = args.Text;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception) {
|
||||
throw new FormatException(string.Format("ERROR:{0}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class EssentialComm : Device {
|
||||
public EssentialCommConfig Properties;
|
||||
|
||||
public CommunicationGather PortGather { get; private set; }
|
||||
public List<BridgeApiEisc> Apis {get; set;}
|
||||
public Dictionary<string, StringFeedback> CommFeedbacks {get; private set; }
|
||||
public StatusMonitorBase CommunicationMonitor { get; private set; }
|
||||
public Dictionary<uint, EssentialCommsPort> CommDictionary { get; private set; }
|
||||
|
||||
public EssentialComm(string key, string name, JToken properties) : base(key, name) {
|
||||
Properties = JsonConvert.DeserializeObject<EssentialCommConfig>(properties.ToString());
|
||||
CommFeedbacks = new Dictionary<string, StringFeedback>();
|
||||
CommDictionary = new Dictionary<uint, EssentialCommsPort>();
|
||||
Apis = new List<BridgeApiEisc>();
|
||||
int commNumber = 1;
|
||||
foreach (var commConfig in Properties.CommConnections) {
|
||||
var commPort = new EssentialCommsPort(commConfig.control, string.Format("{0}-{1}", this.Key, commConfig.joinNumber));
|
||||
CommDictionary.Add(commConfig.joinNumber, commPort);
|
||||
|
||||
commNumber++;
|
||||
}
|
||||
|
||||
foreach (var Ipid in Properties.EiscApiIpids) {
|
||||
var ApiEisc = new BridgeApiEisc(Ipid);
|
||||
Apis.Add(ApiEisc);
|
||||
foreach (var commConnection in CommDictionary) {
|
||||
Debug.Console(2, "Joining Api{0} to comm {1}", Ipid, commConnection.Key);
|
||||
var tempComm = commConnection.Value;
|
||||
var tempJoin = (uint)commConnection.Key;
|
||||
EssentialComApiMap ApiMap = new EssentialComApiMap(ApiEisc, (uint)tempJoin);
|
||||
|
||||
tempComm.Outputs.Add(ApiMap);
|
||||
// Check for ApiMap Overide Values here
|
||||
|
||||
ApiEisc.Eisc.SetBoolSigAction(tempJoin, b => {if (b) { tempComm.Comm.Connect(); } else { tempComm.Comm.Disconnect(); }});
|
||||
ApiEisc.Eisc.SetStringSigAction(tempJoin, s => tempComm.Comm.SendText(s));
|
||||
|
||||
tempComm.StatusFeedback.LinkInputSig(ApiEisc.Eisc.UShortInput[tempJoin]);
|
||||
tempComm.ConnectedFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[tempJoin]);
|
||||
|
||||
|
||||
|
||||
}
|
||||
ApiEisc.Eisc.Register();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override bool CustomActivate()
|
||||
{
|
||||
try {
|
||||
|
||||
|
||||
|
||||
Debug.Console(2, "Name {0} Activated", this.Name);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e) {
|
||||
Debug.Console(0, "Bridge {0}", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public class EssentialComApiMap {
|
||||
public uint Join;
|
||||
public BridgeApiEisc Api;
|
||||
public uint connectJoin;
|
||||
public EssentialComApiMap(BridgeApiEisc api, uint join) {
|
||||
Join = join;
|
||||
Api = api;
|
||||
}
|
||||
}
|
||||
}
|
||||
150
PepperDashEssentials/Bridges/EssentialDM.cs
Normal file
150
PepperDashEssentials/Bridges/EssentialDM.cs
Normal file
@@ -0,0 +1,150 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using PepperDash.Essentials.DM;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core.Routing;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.EthernetCommunication;
|
||||
using Crestron.SimplSharpPro.DM;
|
||||
|
||||
namespace PepperDash.Essentials {
|
||||
public class EssentialDM : PepperDash.Core.Device {
|
||||
public EssentialDMProperties Properties;
|
||||
public List<BridgeApiEisc> BridgeApiEiscs;
|
||||
private PepperDash.Essentials.DM.DmChassisController DmSwitch;
|
||||
private EssentialDMApiMap ApiMap = new EssentialDMApiMap();
|
||||
public EssentialDM(string key, string name, JToken properties)
|
||||
: base(key, name) {
|
||||
Properties = JsonConvert.DeserializeObject<EssentialDMProperties>(properties.ToString());
|
||||
|
||||
|
||||
}
|
||||
public override bool CustomActivate() {
|
||||
// Create EiscApis
|
||||
try {
|
||||
foreach (var device in DeviceManager.AllDevices) {
|
||||
if (device.Key == this.Properties.connectionDeviceKey) {
|
||||
Debug.Console(2, "deviceKey {0} Matches", device.Key);
|
||||
DmSwitch = DeviceManager.GetDeviceForKey(device.Key) as PepperDash.Essentials.DM.DmChassisController;
|
||||
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
Debug.Console(2, "deviceKey {0} doesn't match", device.Key);
|
||||
}
|
||||
}
|
||||
if (Properties.EiscApiIpids != null) {
|
||||
|
||||
|
||||
foreach (string Ipid in Properties.EiscApiIpids) {
|
||||
var ApiEisc = new BridgeApiEisc(Ipid);
|
||||
for (uint x = 1; x <= DmSwitch.Chassis.NumberOfInputs;x++ ) {
|
||||
uint tempX = x;
|
||||
Debug.Console(2, "Creating EiscActions {0}", tempX);
|
||||
|
||||
|
||||
ApiEisc.Eisc.SetUShortSigAction(ApiMap.OutputVideoRoutes[tempX], u => DmSwitch.ExecuteSwitch(u, tempX, eRoutingSignalType.Video));
|
||||
ApiEisc.Eisc.SetUShortSigAction(ApiMap.OutputAudioRoutes[tempX], u => DmSwitch.ExecuteSwitch(u, tempX, eRoutingSignalType.Audio));
|
||||
|
||||
|
||||
if (DmSwitch.TxDictionary.ContainsKey(tempX)) {
|
||||
Debug.Console(2, "Creating Tx Feedbacks {0}", tempX);
|
||||
var TxKey = DmSwitch.TxDictionary[tempX];
|
||||
var TxDevice = DeviceManager.GetDeviceForKey(TxKey) as DmTxControllerBase;
|
||||
TxDevice.IsOnline.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.TxOnlineStatus[tempX]]);
|
||||
TxDevice.AnyVideoInput.VideoStatus.VideoSyncFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.TxVideoSyncStatus[tempX]]);
|
||||
ApiEisc.Eisc.SetUShortSigAction((ApiMap.HdcpSupport[tempX]), u => TxDevice.SetHdcpSupportAll((ePdtHdcpSupport)(u)));
|
||||
TxDevice.HdcpSupportAllFeedback.LinkInputSig(ApiEisc.Eisc.UShortInput[ApiMap.HdcpSupport[tempX]]);
|
||||
ApiEisc.Eisc.UShortInput[ApiMap.HdcpSupportCapability[tempX]].UShortValue = TxDevice.HdcpSupportCapability;
|
||||
}
|
||||
else {
|
||||
DmSwitch.VideoInputSyncFeedbacks[tempX].LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.TxVideoSyncStatus[tempX]]);
|
||||
}
|
||||
if (DmSwitch.RxDictionary.ContainsKey(tempX)) {
|
||||
Debug.Console(2, "Creating Rx Feedbacks {0}", tempX);
|
||||
var RxKey = DmSwitch.RxDictionary[tempX];
|
||||
var RxDevice = DeviceManager.GetDeviceForKey(RxKey) as DmRmcControllerBase;
|
||||
RxDevice.IsOnline.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.RxOnlineStatus[tempX]]);
|
||||
}
|
||||
// DmSwitch.InputEndpointOnlineFeedbacks[(ushort)tempOutputNum].LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.OutputVideoRoutes[tempOutputNum]]);
|
||||
DmSwitch.VideoOutputFeedbacks[(ushort)tempX].LinkInputSig(ApiEisc.Eisc.UShortInput[ApiMap.OutputVideoRoutes[tempX]]);
|
||||
DmSwitch.AudioOutputFeedbacks[(ushort)tempX].LinkInputSig(ApiEisc.Eisc.UShortInput[ApiMap.OutputAudioRoutes[tempX]]);
|
||||
DmSwitch.InputNameFeedbacks[(ushort)tempX].LinkInputSig(ApiEisc.Eisc.StringInput[ApiMap.InputNames[tempX]]);
|
||||
DmSwitch.OutputNameFeedbacks[(ushort)tempX].LinkInputSig(ApiEisc.Eisc.StringInput[ApiMap.OutputNames[tempX]]);
|
||||
DmSwitch.OutputRouteNameFeedbacks[(ushort)tempX].LinkInputSig(ApiEisc.Eisc.StringInput[ApiMap.OutputRouteNames[tempX]]);
|
||||
}
|
||||
DmSwitch.IsOnline.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.ChassisOnline]);
|
||||
ApiEisc.Eisc.Register();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Debug.Console(2, "Name {0} Activated", this.Name);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e) {
|
||||
Debug.Console(2, "BRidge {0}", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
public class EssentialDMProperties {
|
||||
public string connectionDeviceKey;
|
||||
public string[] EiscApiIpids;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class EssentialDMApiMap {
|
||||
public ushort ChassisOnline = 11;
|
||||
public Dictionary<uint, ushort> OutputVideoRoutes;
|
||||
public Dictionary<uint, ushort> OutputAudioRoutes;
|
||||
public Dictionary<uint, ushort> TxOnlineStatus;
|
||||
public Dictionary<uint, ushort> RxOnlineStatus;
|
||||
public Dictionary<uint, ushort> TxVideoSyncStatus;
|
||||
public Dictionary<uint, ushort> InputNames;
|
||||
public Dictionary<uint, ushort> OutputNames;
|
||||
public Dictionary<uint, ushort> OutputRouteNames;
|
||||
public Dictionary<uint, ushort> HdcpSupport;
|
||||
public Dictionary<uint, ushort> HdcpSupportCapability;
|
||||
|
||||
public EssentialDMApiMap() {
|
||||
OutputVideoRoutes = new Dictionary<uint, ushort>();
|
||||
OutputAudioRoutes = new Dictionary<uint, ushort>();
|
||||
TxOnlineStatus = new Dictionary<uint, ushort>();
|
||||
RxOnlineStatus = new Dictionary<uint, ushort>();
|
||||
TxVideoSyncStatus = new Dictionary<uint, ushort>();
|
||||
InputNames = new Dictionary<uint, ushort>();
|
||||
OutputNames = new Dictionary<uint, ushort>();
|
||||
OutputRouteNames = new Dictionary<uint, ushort>();
|
||||
HdcpSupport = new Dictionary<uint, ushort>();
|
||||
HdcpSupportCapability = new Dictionary<uint, ushort>();
|
||||
|
||||
for (uint x = 1; x <= 200; x++) {
|
||||
// Debug.Console(0, "Init Value {0}", x);
|
||||
uint tempNum = x;
|
||||
HdcpSupportCapability[tempNum] = (ushort)(tempNum + 1200);
|
||||
HdcpSupport[tempNum] = (ushort)(tempNum + 1000);
|
||||
OutputVideoRoutes[tempNum] = (ushort)(tempNum + 100);
|
||||
OutputAudioRoutes[tempNum] = (ushort)(tempNum + 300);
|
||||
TxOnlineStatus[tempNum] = (ushort)(tempNum + 500);
|
||||
RxOnlineStatus[tempNum] = (ushort)(tempNum + 700);
|
||||
TxVideoSyncStatus[tempNum] = (ushort)(tempNum + 100);
|
||||
InputNames[tempNum] = (ushort)(tempNum + 100);
|
||||
OutputNames[tempNum] = (ushort)(tempNum + 300);
|
||||
OutputRouteNames[tempNum] = (ushort)(tempNum + 2000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
217
PepperDashEssentials/Bridges/EssentialDsp.cs
Normal file
217
PepperDashEssentials/Bridges/EssentialDsp.cs
Normal file
@@ -0,0 +1,217 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using PepperDash.Essentials.DM;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core.Routing;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.EthernetCommunication;
|
||||
using Crestron.SimplSharpPro.DM;
|
||||
|
||||
namespace PepperDash.Essentials {
|
||||
public class EssentialDsp : PepperDash.Core.Device {
|
||||
public EssentialDspProperties Properties;
|
||||
public List<BridgeApiEisc> BridgeApiEiscs;
|
||||
private PepperDash.Essentials.Devices.Common.DSP.QscDsp Dsp;
|
||||
private EssentialDspApiMap ApiMap = new EssentialDspApiMap();
|
||||
public EssentialDsp(string key, string name, JToken properties)
|
||||
: base(key, name) {
|
||||
Properties = JsonConvert.DeserializeObject<EssentialDspProperties>(properties.ToString());
|
||||
|
||||
|
||||
}
|
||||
public override bool CustomActivate() {
|
||||
// Create EiscApis
|
||||
|
||||
try
|
||||
{
|
||||
ICommunicationMonitor comm = null;
|
||||
foreach (var device in DeviceManager.AllDevices)
|
||||
{
|
||||
if (device.Key == this.Properties.connectionDeviceKey)
|
||||
{
|
||||
if (!(device is ICommunicationMonitor))
|
||||
{
|
||||
comm = device as ICommunicationMonitor;
|
||||
}
|
||||
Debug.Console(2, "deviceKey {0} Matches", device.Key);
|
||||
Dsp = DeviceManager.GetDeviceForKey(device.Key) as PepperDash.Essentials.Devices.Common.DSP.QscDsp;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Console(2, "deviceKey {0} doesn't match", device.Key);
|
||||
|
||||
}
|
||||
}
|
||||
if (Properties.EiscApiIpids != null && Dsp != null)
|
||||
{
|
||||
foreach (string Ipid in Properties.EiscApiIpids)
|
||||
{
|
||||
var ApiEisc = new BridgeApiEisc(Ipid);
|
||||
Debug.Console(2, "Connecting EiscApi {0} to {1}", ApiEisc.Ipid, Dsp.Name);
|
||||
ushort x = 1;
|
||||
if (comm != null)
|
||||
{
|
||||
comm.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.Online]);
|
||||
}
|
||||
foreach (var channel in Dsp.LevelControlPoints)
|
||||
{
|
||||
//var QscChannel = channel.Value as PepperDash.Essentials.Devices.Common.DSP.QscDspLevelControl;
|
||||
Debug.Console(2, "QscChannel {0} connect", x);
|
||||
|
||||
var genericChannel = channel.Value as IBasicVolumeWithFeedback;
|
||||
if (channel.Value.Enabled)
|
||||
{
|
||||
ApiEisc.Eisc.StringInput[ApiMap.channelName[x]].StringValue = channel.Value.LevelCustomName;
|
||||
ApiEisc.Eisc.UShortInput[ApiMap.channelType[x]].UShortValue = (ushort)channel.Value.Type;
|
||||
|
||||
genericChannel.MuteFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.channelMuteToggle[x]]);
|
||||
genericChannel.VolumeLevelFeedback.LinkInputSig(ApiEisc.Eisc.UShortInput[ApiMap.channelVolume[x]]);
|
||||
|
||||
ApiEisc.Eisc.SetSigTrueAction(ApiMap.channelMuteToggle[x], () => genericChannel.MuteToggle());
|
||||
ApiEisc.Eisc.SetSigTrueAction(ApiMap.channelMuteOn[x], () => genericChannel.MuteOn());
|
||||
ApiEisc.Eisc.SetSigTrueAction(ApiMap.channelMuteOff[x], () => genericChannel.MuteOff());
|
||||
|
||||
ApiEisc.Eisc.SetBoolSigAction(ApiMap.channelVolumeUp[x], b => genericChannel.VolumeUp(b));
|
||||
ApiEisc.Eisc.SetBoolSigAction(ApiMap.channelVolumeDown[x], b => genericChannel.VolumeDown(b));
|
||||
|
||||
ApiEisc.Eisc.SetUShortSigAction(ApiMap.channelVolume[x], u => genericChannel.SetVolume(u));
|
||||
ApiEisc.Eisc.SetStringSigAction(ApiMap.presetString, s => Dsp.RunPreset(s));
|
||||
}
|
||||
x++;
|
||||
|
||||
}
|
||||
x = 1;
|
||||
foreach (var preset in Dsp.PresetList)
|
||||
{
|
||||
ApiEisc.Eisc.StringInput[ApiMap.presets[x]].StringValue = preset.label;
|
||||
ApiEisc.Eisc.SetSigTrueAction(ApiMap.presets[x], () => Dsp.RunPresetNumber(x));
|
||||
x++;
|
||||
}
|
||||
foreach (var dialer in Dsp.Dialers)
|
||||
{
|
||||
ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad0, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num0));
|
||||
ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad1, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num1));
|
||||
ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad2, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num2));
|
||||
ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad3, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num3));
|
||||
ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad4, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num4));
|
||||
ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad5, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num5));
|
||||
ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad6, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num6));
|
||||
ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad7, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num7));
|
||||
ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad8, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num8));
|
||||
ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad9, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num9));
|
||||
ApiEisc.Eisc.SetSigTrueAction(ApiMap.KeypadStar, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Star));
|
||||
ApiEisc.Eisc.SetSigTrueAction(ApiMap.KeypadPound, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Pound));
|
||||
ApiEisc.Eisc.SetSigTrueAction(ApiMap.KeypadClear, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Clear));
|
||||
ApiEisc.Eisc.SetSigTrueAction(ApiMap.KeypadBackspace, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Backspace));
|
||||
|
||||
ApiEisc.Eisc.SetSigTrueAction(ApiMap.Dial, () => dialer.Value.Dial());
|
||||
ApiEisc.Eisc.SetSigTrueAction(ApiMap.DoNotDisturbToggle, () => dialer.Value.DoNotDisturbToggle());
|
||||
ApiEisc.Eisc.SetSigTrueAction(ApiMap.DoNotDisturbOn, () => dialer.Value.DoNotDisturbOn());
|
||||
ApiEisc.Eisc.SetSigTrueAction(ApiMap.DoNotDisturbOff, () => dialer.Value.DoNotDisturbOff());
|
||||
ApiEisc.Eisc.SetSigTrueAction(ApiMap.AutoAnswerToggle, () => dialer.Value.AutoAnswerToggle());
|
||||
ApiEisc.Eisc.SetSigTrueAction(ApiMap.AutoAnswerOn, () => dialer.Value.AutoAnswerOn());
|
||||
ApiEisc.Eisc.SetSigTrueAction(ApiMap.AutoAnswerOff, () => dialer.Value.AutoAnswerOff());
|
||||
|
||||
dialer.Value.DoNotDisturbFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.DoNotDisturbToggle]);
|
||||
dialer.Value.DoNotDisturbFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.DoNotDisturbOn]);
|
||||
dialer.Value.DoNotDisturbFeedback.LinkComplementInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.DoNotDisturbOff]);
|
||||
|
||||
dialer.Value.AutoAnswerFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.AutoAnswerToggle]);
|
||||
dialer.Value.AutoAnswerFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.AutoAnswerOn]);
|
||||
dialer.Value.AutoAnswerFeedback.LinkComplementInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.AutoAnswerOff]);
|
||||
|
||||
dialer.Value.OffHookFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.Dial]);
|
||||
dialer.Value.DialStringFeedback.LinkInputSig(ApiEisc.Eisc.StringInput[ApiMap.DialString]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Debug.Console(2, "Name {0} Activated", this.Name);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e) {
|
||||
Debug.Console(0, "Bridge {0}", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
public class EssentialDspProperties {
|
||||
public string connectionDeviceKey;
|
||||
public string[] EiscApiIpids;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class EssentialDspApiMap {
|
||||
public ushort Online = 1;
|
||||
public ushort presetString = 2000;
|
||||
public Dictionary<uint, ushort> channelMuteToggle;
|
||||
public Dictionary<uint, ushort> channelMuteOn;
|
||||
public Dictionary<uint, ushort> channelMuteOff;
|
||||
public Dictionary<uint, ushort> channelVolume;
|
||||
public Dictionary<uint, ushort> channelType;
|
||||
public Dictionary<uint, ushort> channelName;
|
||||
public Dictionary<uint, ushort> channelVolumeUp;
|
||||
public Dictionary<uint, ushort> channelVolumeDown;
|
||||
public Dictionary<uint, ushort> presets;
|
||||
public ushort DialString = 3100;
|
||||
public ushort Keypad0 = 3110;
|
||||
public ushort Keypad1 = 3111;
|
||||
public ushort Keypad2 = 3112;
|
||||
public ushort Keypad3 = 3113;
|
||||
public ushort Keypad4 = 3114;
|
||||
public ushort Keypad5 = 3115;
|
||||
public ushort Keypad6 = 3116;
|
||||
public ushort Keypad7 = 3117;
|
||||
public ushort Keypad8 = 3118;
|
||||
public ushort Keypad9 = 3119;
|
||||
public ushort KeypadStar = 3120;
|
||||
public ushort KeypadPound = 3121;
|
||||
public ushort KeypadClear = 3122;
|
||||
public ushort KeypadBackspace = 3123;
|
||||
public ushort Dial = 3124;
|
||||
public ushort DoNotDisturbToggle = 3132;
|
||||
public ushort DoNotDisturbOn = 3133;
|
||||
public ushort DoNotDisturbOff = 3134;
|
||||
public ushort AutoAnswerToggle = 3127;
|
||||
public ushort AutoAnswerOn = 3125;
|
||||
public ushort AutoAnswerOff = 3126;
|
||||
|
||||
public EssentialDspApiMap() {
|
||||
channelMuteToggle = new Dictionary<uint, ushort>();
|
||||
channelMuteOn = new Dictionary<uint, ushort>();
|
||||
channelMuteOff = new Dictionary<uint, ushort>();
|
||||
channelVolume = new Dictionary<uint, ushort>();
|
||||
channelName = new Dictionary<uint, ushort>();
|
||||
channelType = new Dictionary<uint, ushort>();
|
||||
presets = new Dictionary<uint, ushort>();
|
||||
channelVolumeUp = new Dictionary<uint, ushort>();
|
||||
channelVolumeDown = new Dictionary<uint, ushort>();
|
||||
for (uint x = 1; x <= 100; x++) {
|
||||
uint tempNum = x;
|
||||
presets[tempNum] = (ushort)(tempNum + 100);
|
||||
channelMuteToggle[tempNum] = (ushort)(tempNum + 400);
|
||||
channelMuteOn[tempNum] = (ushort)(tempNum + 600);
|
||||
channelMuteOff[tempNum] = (ushort)(tempNum + 800);
|
||||
channelVolume[tempNum] = (ushort)(tempNum + 200);
|
||||
channelName[tempNum] = (ushort)(tempNum + 200);
|
||||
channelType[tempNum] = (ushort)(tempNum + 400);
|
||||
channelVolumeUp[tempNum] = (ushort)(tempNum + 1000);
|
||||
channelVolumeDown[tempNum] = (ushort)(tempNum + 1200);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
98
PepperDashEssentials/Bridges/EssentialTVOne.cs
Normal file
98
PepperDashEssentials/Bridges/EssentialTVOne.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using PepperDash.Essentials.DM;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core.Routing;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.EthernetCommunication;
|
||||
using Crestron.SimplSharpPro.DM;
|
||||
|
||||
namespace PepperDash.Essentials
|
||||
{
|
||||
public class EssentialsTVOne : PepperDash.Core.Device
|
||||
{
|
||||
public EssentialTVOneProperties Properties;
|
||||
public List<BridgeApiEisc> BridgeApiEiscs;
|
||||
private PepperDash.Essentials.Devices.Common.TVOneCorio TVOneCorio;
|
||||
private EssentialsTVOneApiMap ApiMap = new EssentialsTVOneApiMap();
|
||||
public EssentialsTVOne(string key, string name, JToken properties)
|
||||
: base(key, name)
|
||||
{
|
||||
Properties = JsonConvert.DeserializeObject<EssentialTVOneProperties>(properties.ToString());
|
||||
|
||||
|
||||
}
|
||||
public override bool CustomActivate() {
|
||||
// Create EiscApis
|
||||
try
|
||||
{
|
||||
foreach (var device in DeviceManager.AllDevices)
|
||||
{
|
||||
if (device.Key == this.Properties.connectionDeviceKey)
|
||||
{
|
||||
Debug.Console(2, "deviceKey {0} Matches", device.Key);
|
||||
TVOneCorio = DeviceManager.GetDeviceForKey(device.Key) as PepperDash.Essentials.Devices.Common.TVOneCorio;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Console(2, "deviceKey {0} doesn't match", device.Key);
|
||||
|
||||
}
|
||||
}
|
||||
if (Properties.EiscApiIpids != null && TVOneCorio != null)
|
||||
{
|
||||
foreach (string Ipid in Properties.EiscApiIpids)
|
||||
{
|
||||
var ApiEisc = new BridgeApiEisc(Ipid);
|
||||
Debug.Console(2, "Connecting EiscApi {0} to {1}", ApiEisc.Ipid, TVOneCorio.Name);
|
||||
ushort x = 1;
|
||||
TVOneCorio.OnlineFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.Online]);
|
||||
ApiEisc.Eisc.SetUShortSigAction(ApiMap.CallPreset, u => TVOneCorio.CallPreset(u));
|
||||
TVOneCorio.PresetFeedback.LinkInputSig(ApiEisc.Eisc.UShortInput[ApiMap.PresetFeedback]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Debug.Console(2, "Name {0} Activated", this.Name);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e) {
|
||||
Debug.Console(0, "Bridge {0}", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
public class EssentialTVOneProperties
|
||||
{
|
||||
public string connectionDeviceKey;
|
||||
public string[] EiscApiIpids;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class EssentialsTVOneApiMap
|
||||
{
|
||||
public ushort CallPreset = 1;
|
||||
public ushort PresetFeedback = 1;
|
||||
public ushort Online = 1;
|
||||
|
||||
public EssentialsTVOneApiMap()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
103
PepperDashEssentials/Bridges/GenericLightingBridge.cs
Normal file
103
PepperDashEssentials/Bridges/GenericLightingBridge.cs
Normal file
@@ -0,0 +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;
|
||||
|
||||
//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();
|
||||
|
||||
// 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());
|
||||
|
||||
// // 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++;
|
||||
// }
|
||||
|
||||
// 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; });
|
||||
|
||||
|
||||
// /*
|
||||
// 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));
|
||||
|
||||
// }
|
||||
// */
|
||||
// }
|
||||
// }
|
||||
// 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 override void OffsetJoinNumbers(uint joinStart)
|
||||
// {
|
||||
// var joinOffset = joinStart - 1;
|
||||
|
||||
// IsOnline = IsOnline + joinOffset;
|
||||
// SelectScene = SelectScene + joinOffset;
|
||||
// LightingSceneOffset = LightingSceneOffset + joinOffset;
|
||||
// ButtonVisibilityOffset = ButtonVisibilityOffset + joinOffset;
|
||||
|
||||
|
||||
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
66
PepperDashEssentials/Bridges/GenericRelayDeviceBridge.cs
Normal file
66
PepperDashEssentials/Bridges/GenericRelayDeviceBridge.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
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.Core.CrestronIO;
|
||||
|
||||
namespace PepperDash.Essentials.Bridges
|
||||
{
|
||||
public static class GenericRelayDeviceApiExtensions
|
||||
{
|
||||
public static void LinkToApi(this GenericRelayDevice relay, BasicTriList trilist, uint joinStart, string joinMapKey)
|
||||
{
|
||||
var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as GenericRelayControllerJoinMap;
|
||||
|
||||
if (joinMap == null)
|
||||
joinMap = new GenericRelayControllerJoinMap();
|
||||
|
||||
joinMap.OffsetJoinNumbers(joinStart);
|
||||
|
||||
if (relay.RelayOutput == null)
|
||||
{
|
||||
Debug.Console(1, relay, "Unable to link device '{0}'. Relay is null", relay.Key);
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.Console(1, relay, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
||||
|
||||
trilist.SetBoolSigAction(joinMap.Relay, new Action<bool>(b =>
|
||||
{
|
||||
if (b)
|
||||
relay.CloseRelay();
|
||||
else
|
||||
relay.OpenRelay();
|
||||
}));
|
||||
|
||||
// feedback for relay state
|
||||
|
||||
relay.OutputIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Relay]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class GenericRelayControllerJoinMap : JoinMapBase
|
||||
{
|
||||
//Digital
|
||||
public uint Relay { get; set; }
|
||||
|
||||
public GenericRelayControllerJoinMap()
|
||||
{
|
||||
Relay = 1;
|
||||
}
|
||||
|
||||
public override void OffsetJoinNumbers(uint joinStart)
|
||||
{
|
||||
var joinOffset = joinStart - 1;
|
||||
|
||||
Relay = Relay + joinOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
107
PepperDashEssentials/Bridges/IBasicCommunicationBridge.cs
Normal file
107
PepperDashEssentials/Bridges/IBasicCommunicationBridge.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
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;
|
||||
|
||||
namespace PepperDash.Essentials.Bridges
|
||||
{
|
||||
public static class IBasicCommunicationApiExtensions
|
||||
{
|
||||
public static void LinkToApi(this GenericComm comm, BasicTriList trilist, uint joinStart, string joinMapKey)
|
||||
{
|
||||
var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as IBasicCommunicationJoinMap;
|
||||
|
||||
if (joinMap == null)
|
||||
joinMap = new IBasicCommunicationJoinMap();
|
||||
|
||||
joinMap.OffsetJoinNumbers(joinStart);
|
||||
|
||||
if (comm.CommPort == null)
|
||||
{
|
||||
Debug.Console(1, comm, "Unable to link device '{0}'. CommPort is null", comm.Key);
|
||||
return;
|
||||
}
|
||||
|
||||
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) =>
|
||||
{
|
||||
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)));
|
||||
|
||||
|
||||
var sComm = comm.CommPort as ISocketStatus;
|
||||
if (sComm != null)
|
||||
{
|
||||
sComm.ConnectionChange += (s, a) =>
|
||||
{
|
||||
trilist.SetUshort(joinMap.Status, (ushort)(a.Client.ClientStatus));
|
||||
trilist.SetBool(joinMap.Connected, a.Client.ClientStatus ==
|
||||
Crestron.SimplSharp.CrestronSockets.SocketStatus.SOCKET_STATUS_CONNECTED);
|
||||
};
|
||||
|
||||
trilist.SetBoolSigAction(joinMap.Connect, new Action<bool>(b =>
|
||||
{
|
||||
if (b)
|
||||
{
|
||||
sComm.Connect();
|
||||
}
|
||||
else
|
||||
{
|
||||
sComm.Disconnect();
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class IBasicCommunicationJoinMap : JoinMapBase
|
||||
{
|
||||
//Digital
|
||||
public uint Connect { get; set; }
|
||||
public uint Connected { get; set; }
|
||||
|
||||
//Analog
|
||||
public uint Status { get; set; }
|
||||
|
||||
// Serial
|
||||
public uint TextReceived { get; set; }
|
||||
public uint SendText { get; set; }
|
||||
public uint SetPortConfig { get; set; }
|
||||
|
||||
|
||||
public IBasicCommunicationJoinMap()
|
||||
{
|
||||
TextReceived = 1;
|
||||
SendText = 1;
|
||||
SetPortConfig = 2;
|
||||
Connect = 1;
|
||||
Connected = 1;
|
||||
Status = 1;
|
||||
}
|
||||
|
||||
public override void OffsetJoinNumbers(uint joinStart)
|
||||
{
|
||||
var joinOffset = joinStart - 1;
|
||||
|
||||
TextReceived = TextReceived + joinOffset;
|
||||
SendText = SendText + joinOffset;
|
||||
SetPortConfig = SetPortConfig + joinOffset;
|
||||
Connect = Connect + joinOffset;
|
||||
Connected = Connected + joinOffset;
|
||||
Status = Status + joinOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
14
PepperDashEssentials/Bridges/IBridge.cs
Normal file
14
PepperDashEssentials/Bridges/IBridge.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
59
PepperDashEssentials/Bridges/IDigitalInputBridge.cs
Normal file
59
PepperDashEssentials/Bridges/IDigitalInputBridge.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
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.CrestronIO;
|
||||
|
||||
namespace PepperDash.Essentials.Bridges
|
||||
{
|
||||
public static class IDigitalInputApiExtenstions
|
||||
{
|
||||
public static void LinkToApi(this IDigitalInput input, BasicTriList trilist, uint joinStart, string joinMapKey)
|
||||
{
|
||||
var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as IDigitalInputApiJoinMap;
|
||||
|
||||
if (joinMap == null)
|
||||
joinMap = new IDigitalInputApiJoinMap();
|
||||
|
||||
joinMap.OffsetJoinNumbers(joinStart);
|
||||
|
||||
try
|
||||
{
|
||||
Debug.Console(1, input as Device, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
||||
|
||||
// Link feedback for input state
|
||||
input.InputStateFeedback.LinkInputSig(trilist.BooleanInput[joinMap.InputState]);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(1, input as Device, "Unable to link device '{0}'. Input is null", (input as Device).Key);
|
||||
Debug.Console(1, input as Device, "Error: {0}", e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class IDigitalInputApiJoinMap : JoinMapBase
|
||||
{
|
||||
//Digital
|
||||
public uint InputState { get; set; }
|
||||
|
||||
public IDigitalInputApiJoinMap()
|
||||
{
|
||||
InputState = 1;
|
||||
}
|
||||
|
||||
public override void OffsetJoinNumbers(uint joinStart)
|
||||
{
|
||||
var joinOffset = joinStart - 1;
|
||||
|
||||
InputState = InputState + joinOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
40
PepperDashEssentials/Bridges/JoinMapBase.cs
Normal file
40
PepperDashEssentials/Bridges/JoinMapBase.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
namespace PepperDash.Essentials.Bridges
|
||||
{
|
||||
public static class JoinMapHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Attempts to get the join map from config
|
||||
/// </summary>
|
||||
/// <param name="joinMapKey"></param>
|
||||
/// <returns></returns>
|
||||
public static JoinMapBase GetJoinMapForDevice(string joinMapKey)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(joinMapKey))
|
||||
return null;
|
||||
|
||||
// FUTURE TODO: Get the join map from the ConfigReader.ConfigObject
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public abstract class JoinMapBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Modifies all the join numbers by adding the offset. This should never be called twice
|
||||
/// </summary>
|
||||
/// <param name="joinStart"></param>
|
||||
public abstract void OffsetJoinNumbers(uint joinStart);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
150
PepperDashEssentials/Bridges/SystemMonitorBridge.cs
Normal file
150
PepperDashEssentials/Bridges/SystemMonitorBridge.cs
Normal file
@@ -0,0 +1,150 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
using Crestron.SimplSharpPro.Diagnostics;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Monitoring;
|
||||
|
||||
namespace PepperDash.Essentials.Bridges
|
||||
{
|
||||
public static class SystemMonitorBridge
|
||||
{
|
||||
public static void LinkToApi(this SystemMonitorController systemMonitorController, BasicTriList trilist, uint joinStart, string joinMapKey)
|
||||
{
|
||||
var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as SystemMonitorJoinMap;
|
||||
|
||||
if (joinMap == null)
|
||||
joinMap = new SystemMonitorJoinMap();
|
||||
|
||||
joinMap.OffsetJoinNumbers(joinStart);
|
||||
|
||||
//Debug.Console(1, systemMonitorController, "Linking API starting at join: {0}", joinStart);
|
||||
|
||||
systemMonitorController.TimeZoneFeedback.LinkInputSig(trilist.UShortInput[joinMap.TimeZone]);
|
||||
//trilist.SetUShortSigAction(joinMap.TimeZone, new Action<ushort>(u => systemMonitorController.SetTimeZone(u)));
|
||||
systemMonitorController.TimeZoneTextFeedback.LinkInputSig(trilist.StringInput[joinMap.TimeZoneName]);
|
||||
|
||||
systemMonitorController.IOControllerVersionFeedback.LinkInputSig(trilist.StringInput[joinMap.IOControllerVersion]);
|
||||
systemMonitorController.SnmpVersionFeedback.LinkInputSig(trilist.StringInput[joinMap.SnmpAppVersion]);
|
||||
systemMonitorController.BACnetAppVersionFeedback.LinkInputSig(trilist.StringInput[joinMap.BACnetAppVersion]);
|
||||
systemMonitorController.ControllerVersionFeedback.LinkInputSig(trilist.StringInput[joinMap.ControllerVersion]);
|
||||
|
||||
|
||||
// iterate the program status feedback collection and map all the joins
|
||||
var programSlotJoinStart = joinMap.ProgramStartJoin;
|
||||
|
||||
foreach (var p in systemMonitorController.ProgramStatusFeedbackCollection)
|
||||
{
|
||||
|
||||
// TODO: link feedbacks for each program slot
|
||||
var programNumber = p.Value.Program.Number;
|
||||
|
||||
//Debug.Console(1, systemMonitorController, "Linking API for Program Slot: {0} starting at join: {1}", programNumber, programSlotJoinStart);
|
||||
|
||||
trilist.SetBoolSigAction(programSlotJoinStart + joinMap.ProgramStart, new Action<bool>
|
||||
(b => SystemMonitor.ProgramCollection[programNumber].OperatingState = eProgramOperatingState.Start));
|
||||
p.Value.ProgramStartedFeedback.LinkInputSig(trilist.BooleanInput[programSlotJoinStart + joinMap.ProgramStart]);
|
||||
|
||||
trilist.SetBoolSigAction(programSlotJoinStart + joinMap.ProgramStop, new Action<bool>
|
||||
(b => SystemMonitor.ProgramCollection[programNumber].OperatingState = eProgramOperatingState.Stop));
|
||||
p.Value.ProgramStoppedFeedback.LinkInputSig(trilist.BooleanInput[programSlotJoinStart + joinMap.ProgramStop]);
|
||||
|
||||
trilist.SetBoolSigAction(programSlotJoinStart + joinMap.ProgramRegister, new Action<bool>
|
||||
(b => SystemMonitor.ProgramCollection[programNumber].RegistrationState = eProgramRegistrationState.Register));
|
||||
p.Value.ProgramRegisteredFeedback.LinkInputSig(trilist.BooleanInput[programSlotJoinStart + joinMap.ProgramRegister]);
|
||||
|
||||
trilist.SetBoolSigAction(programSlotJoinStart + joinMap.ProgramUnregister, new Action<bool>
|
||||
(b => SystemMonitor.ProgramCollection[programNumber].RegistrationState = eProgramRegistrationState.Unregister));
|
||||
p.Value.ProgramUnregisteredFeedback.LinkInputSig(trilist.BooleanInput[programSlotJoinStart + joinMap.ProgramUnregister]);
|
||||
|
||||
programSlotJoinStart = programSlotJoinStart + joinMap.ProgramOffsetJoin;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class SystemMonitorJoinMap : JoinMapBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Offset to indicate where the range of iterated program joins will start
|
||||
/// </summary>
|
||||
public uint ProgramStartJoin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Offset between each program join set
|
||||
/// </summary>
|
||||
public uint ProgramOffsetJoin { get; set; }
|
||||
|
||||
//Digital
|
||||
public uint ProgramStart { get; set; }
|
||||
public uint ProgramStop { get; set; }
|
||||
public uint ProgramRegister { get; set; }
|
||||
public uint ProgramUnregister { get; set; }
|
||||
|
||||
//Analog
|
||||
public uint TimeZone { get; set; }
|
||||
|
||||
//Serial
|
||||
public uint TimeZoneName { get; set; }
|
||||
public uint IOControllerVersion { get; set; }
|
||||
public uint SnmpAppVersion { get; set; }
|
||||
public uint BACnetAppVersion { get; set; }
|
||||
public uint ControllerVersion { get; set; }
|
||||
|
||||
public uint ProgramName { get; set; }
|
||||
public uint ProgramCompiledTime { get; set; }
|
||||
public uint ProgramCrestronDatabaseVersion { get; set; }
|
||||
public uint ProgramEnvironmentVersion { get; set; }
|
||||
public uint AggregatedProgramInfo { get; set; }
|
||||
|
||||
public SystemMonitorJoinMap()
|
||||
{
|
||||
TimeZone = 1;
|
||||
|
||||
TimeZoneName = 1;
|
||||
IOControllerVersion = 2;
|
||||
SnmpAppVersion = 3;
|
||||
BACnetAppVersion = 4;
|
||||
ControllerVersion = 5;
|
||||
|
||||
|
||||
ProgramStartJoin = 10;
|
||||
|
||||
ProgramOffsetJoin = 5;
|
||||
|
||||
// Offset in groups of 5 joins
|
||||
ProgramStart = 1;
|
||||
ProgramStop = 2;
|
||||
ProgramRegister = 3;
|
||||
ProgramUnregister = 4;
|
||||
|
||||
ProgramName = 1;
|
||||
ProgramCompiledTime = 2;
|
||||
ProgramCrestronDatabaseVersion = 3;
|
||||
ProgramEnvironmentVersion = 4;
|
||||
AggregatedProgramInfo = 5;
|
||||
}
|
||||
|
||||
public override void OffsetJoinNumbers(uint joinStart)
|
||||
{
|
||||
var joinOffset = joinStart - 1;
|
||||
|
||||
TimeZone = TimeZone + joinOffset;
|
||||
|
||||
TimeZoneName = TimeZoneName + joinOffset;
|
||||
IOControllerVersion = IOControllerVersion + joinOffset;
|
||||
SnmpAppVersion = SnmpAppVersion + joinOffset;
|
||||
BACnetAppVersion = BACnetAppVersion + joinOffset;
|
||||
ControllerVersion = ControllerVersion + joinOffset;
|
||||
|
||||
// Sets the initial join value where the iterated program joins will begin
|
||||
ProgramStartJoin = ProgramStartJoin + joinOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,6 +80,16 @@ namespace PepperDash.Essentials
|
||||
var dm = new DmMd8x8(ipId, Global.ControlSystem);
|
||||
//dev = new DmChassisController(devKey, devName, dm);
|
||||
}
|
||||
else if (devType.Equals("dmmd16x16", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var dm = new DmMd16x16(ipId, Global.ControlSystem);
|
||||
//dev = new DmChassisController(devKey, devName, dm);
|
||||
}
|
||||
else if (devType.Equals("dmmd32x32", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var dm = new DmMd32x32(ipId, Global.ControlSystem);
|
||||
//dev = new DmChassisController(devKey, devName, dm);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
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;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
@@ -15,29 +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()
|
||||
{
|
||||
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 => { 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 =>
|
||||
{
|
||||
@@ -46,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>
|
||||
@@ -85,100 +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)
|
||||
{
|
||||
var filesReady = SetupFilesystem();
|
||||
if (filesReady)
|
||||
{
|
||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Checking for plugins");
|
||||
LoadPlugins();
|
||||
|
||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Folder structure verified. Loading config...");
|
||||
if (!ConfigReader.LoadConfig2())
|
||||
return;
|
||||
if (!ConfigReader.LoadConfig2())
|
||||
return;
|
||||
|
||||
Load();
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
/// <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);
|
||||
}
|
||||
|
||||
var irDir = Global.FilePathPrefix + "ir";
|
||||
if (!Directory.Exists(irDir))
|
||||
Directory.Create(irDir);
|
||||
// Notify the OS that the program intitialization has completed
|
||||
SystemMonitor.ProgramInitialization.ProgramInitializationComplete = true;
|
||||
|
||||
}
|
||||
|
||||
/// <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)
|
||||
|
||||
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");
|
||||
@@ -203,24 +327,47 @@ namespace PepperDash.Essentials
|
||||
LoadLogoServer();
|
||||
|
||||
DeviceManager.ActivateAll();
|
||||
}
|
||||
|
||||
LinkSystemMonitorToAppServer();
|
||||
}
|
||||
|
||||
void LinkSystemMonitorToAppServer()
|
||||
{
|
||||
var sysMon = DeviceManager.GetDeviceForKey("systemMonitor") as PepperDash.Essentials.Core.Monitoring.SystemMonitorController;
|
||||
|
||||
var appServer = DeviceManager.GetDeviceForKey("appServer") as CotijaSystemController;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Reads all devices from config and adds them to DeviceManager
|
||||
/// </summary>
|
||||
public void LoadDevices()
|
||||
{
|
||||
if (sysMon != null && appServer != null)
|
||||
{
|
||||
var key = sysMon.Key + "-" + appServer.Key;
|
||||
var messenger = new PepperDash.Essentials.AppServer.Messengers.SystemMonitorMessenger
|
||||
(key, sysMon, "/device/systemMonitor");
|
||||
|
||||
messenger.RegisterWithAppServer(appServer);
|
||||
|
||||
DeviceManager.AddDevice(messenger);
|
||||
}
|
||||
}
|
||||
|
||||
/// <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"));
|
||||
|
||||
foreach (var devConf in ConfigReader.ConfigObject.Devices)
|
||||
{
|
||||
// Add global System Monitor device
|
||||
DeviceManager.AddDevice(new PepperDash.Essentials.Core.Monitoring.SystemMonitorController("systemMonitor"));
|
||||
|
||||
try
|
||||
{
|
||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Creating device '{0}'", devConf.Key);
|
||||
// Skip this to prevent unnecessary warnings
|
||||
foreach (var devConf in ConfigReader.ConfigObject.Devices)
|
||||
{
|
||||
|
||||
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())
|
||||
@@ -231,10 +378,15 @@ namespace PepperDash.Essentials
|
||||
continue;
|
||||
}
|
||||
|
||||
// Try local factory first
|
||||
var newDev = DeviceFactory.GetDevice(devConf);
|
||||
// Try local factories first
|
||||
var newDev = DeviceFactory.GetDevice(devConf);
|
||||
|
||||
// Then associated library factories
|
||||
if (newDev == null)
|
||||
newDev = BridgeFactory.GetDevice(devConf);
|
||||
|
||||
// Then associated library factories
|
||||
if (newDev == null)
|
||||
newDev = PepperDash.Essentials.Core.DeviceFactory.GetDevice(devConf);
|
||||
if (newDev == null)
|
||||
newDev = PepperDash.Essentials.Devices.Common.DeviceFactory.GetDevice(devConf);
|
||||
if (newDev == null)
|
||||
@@ -242,62 +394,76 @@ namespace PepperDash.Essentials
|
||||
if (newDev == null)
|
||||
newDev = PepperDash.Essentials.Devices.Displays.DisplayDeviceFactory.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
|
||||
|
||||
var tlc = TieLineCollection.Default;
|
||||
//tlc.Clear();
|
||||
if (ConfigReader.ConfigObject.TieLines == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
/// <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
|
||||
|
||||
foreach (var tieLineConfig in ConfigReader.ConfigObject.TieLines)
|
||||
{
|
||||
var newTL = tieLineConfig.GetTieLine();
|
||||
if (newTL != null)
|
||||
tlc.Add(newTL);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -307,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...");
|
||||
}
|
||||
@@ -321,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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,348 +1,348 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharp.CrestronIO;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
using Crestron.SimplSharpPro.Fusion;
|
||||
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using PepperDash.Essentials.Devices.Common;
|
||||
using PepperDash.Essentials.Devices.Common.Occupancy;
|
||||
|
||||
namespace PepperDash.Essentials.Fusion
|
||||
{
|
||||
public class EssentialsHuddleVtc1FusionController : EssentialsHuddleSpaceFusionSystemControllerBase
|
||||
{
|
||||
BooleanSigData CodecIsInCall;
|
||||
|
||||
public EssentialsHuddleVtc1FusionController(EssentialsHuddleVtc1Room room, uint ipId)
|
||||
: base(room, ipId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called in base class constructor before RVI and GUID files are built
|
||||
/// </summary>
|
||||
protected override void ExecuteCustomSteps()
|
||||
{
|
||||
SetUpCodec();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a static asset for the codec and maps the joins to the main room symbol
|
||||
/// </summary>
|
||||
void SetUpCodec()
|
||||
{
|
||||
try
|
||||
{
|
||||
var codec = (Room as EssentialsHuddleVtc1Room).VideoCodec;
|
||||
|
||||
if (codec == null)
|
||||
{
|
||||
Debug.Console(1, this, "Cannot link codec to Fusion because codec is null");
|
||||
return;
|
||||
}
|
||||
|
||||
codec.UsageTracker = new UsageTracking(codec);
|
||||
codec.UsageTracker.UsageIsTracked = true;
|
||||
codec.UsageTracker.DeviceUsageEnded += UsageTracker_DeviceUsageEnded;
|
||||
|
||||
var codecPowerOnAction = new Action<bool>(b => { if (!b) codec.StandbyDeactivate(); });
|
||||
var codecPowerOffAction = new Action<bool>(b => { if (!b) codec.StandbyActivate(); });
|
||||
|
||||
// Map FusionRoom Attributes:
|
||||
|
||||
// Codec volume
|
||||
var codecVolume = FusionRoom.CreateOffsetUshortSig(50, "Volume - Fader01", eSigIoMask.InputOutputSig);
|
||||
codecVolume.OutputSig.UserObject = new Action<ushort>(b => (codec as IBasicVolumeWithFeedback).SetVolume(b));
|
||||
(codec as IBasicVolumeWithFeedback).VolumeLevelFeedback.LinkInputSig(codecVolume.InputSig);
|
||||
|
||||
// In Call Status
|
||||
CodecIsInCall = FusionRoom.CreateOffsetBoolSig(69, "Conf - VC 1 In Call", eSigIoMask.InputSigOnly);
|
||||
codec.CallStatusChange += new EventHandler<PepperDash.Essentials.Devices.Common.Codec.CodecCallStatusItemChangeEventArgs>(codec_CallStatusChange);
|
||||
|
||||
// Online status
|
||||
if (codec is ICommunicationMonitor)
|
||||
{
|
||||
var c = codec as ICommunicationMonitor;
|
||||
var codecOnline = FusionRoom.CreateOffsetBoolSig(122, "Online - VC 1", eSigIoMask.InputSigOnly);
|
||||
codecOnline.InputSig.BoolValue = c.CommunicationMonitor.Status == MonitorStatus.IsOk;
|
||||
c.CommunicationMonitor.StatusChange += (o, a) =>
|
||||
{
|
||||
codecOnline.InputSig.BoolValue = a.Status == MonitorStatus.IsOk;
|
||||
};
|
||||
Debug.Console(0, this, "Linking '{0}' communication monitor to Fusion '{1}'", codec.Key, "Online - VC 1");
|
||||
}
|
||||
|
||||
// Codec IP Address
|
||||
bool codecHasIpInfo = false;
|
||||
var codecComm = codec.Communication;
|
||||
|
||||
string codecIpAddress = string.Empty;
|
||||
int codecIpPort = 0;
|
||||
|
||||
StringSigData codecIpAddressSig;
|
||||
StringSigData codecIpPortSig;
|
||||
|
||||
if(codecComm is GenericSshClient)
|
||||
{
|
||||
codecIpAddress = (codecComm as GenericSshClient).Hostname;
|
||||
codecIpPort = (codecComm as GenericSshClient).Port;
|
||||
codecHasIpInfo = true;
|
||||
}
|
||||
else if (codecComm is GenericTcpIpClient)
|
||||
{
|
||||
codecIpAddress = (codecComm as GenericTcpIpClient).Hostname;
|
||||
codecIpPort = (codecComm as GenericTcpIpClient).Port;
|
||||
codecHasIpInfo = true;
|
||||
}
|
||||
|
||||
if (codecHasIpInfo)
|
||||
{
|
||||
codecIpAddressSig = FusionRoom.CreateOffsetStringSig(121, "IP Address - VC", eSigIoMask.InputSigOnly);
|
||||
codecIpAddressSig.InputSig.StringValue = codecIpAddress;
|
||||
|
||||
codecIpPortSig = FusionRoom.CreateOffsetStringSig(150, "IP Port - VC", eSigIoMask.InputSigOnly);
|
||||
codecIpPortSig.InputSig.StringValue = codecIpPort.ToString();
|
||||
}
|
||||
|
||||
var tempAsset = new FusionAsset();
|
||||
|
||||
var deviceConfig = ConfigReader.ConfigObject.Devices.FirstOrDefault(c => c.Key.Equals(codec.Key));
|
||||
|
||||
if (FusionStaticAssets.ContainsKey(deviceConfig.Uid))
|
||||
{
|
||||
tempAsset = FusionStaticAssets[deviceConfig.Uid];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create a new asset
|
||||
tempAsset = new FusionAsset(FusionRoomGuids.GetNextAvailableAssetNumber(FusionRoom), codec.Name, "Codec", "");
|
||||
FusionStaticAssets.Add(deviceConfig.Uid, tempAsset);
|
||||
}
|
||||
|
||||
var codecAsset = FusionRoom.CreateStaticAsset(tempAsset.SlotNumber, tempAsset.Name, "Display", tempAsset.InstanceId);
|
||||
codecAsset.PowerOn.OutputSig.UserObject = codecPowerOnAction;
|
||||
codecAsset.PowerOff.OutputSig.UserObject = codecPowerOffAction;
|
||||
codec.StandbyIsOnFeedback.LinkComplementInputSig(codecAsset.PowerOn.InputSig);
|
||||
|
||||
// TODO: Map relevant attributes on asset symbol
|
||||
|
||||
codecAsset.TrySetMakeModel(codec);
|
||||
codecAsset.TryLinkAssetErrorToCommunication(codec);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(1, this, "Error setting up codec in Fusion: {0}", e);
|
||||
}
|
||||
}
|
||||
|
||||
void codec_CallStatusChange(object sender, PepperDash.Essentials.Devices.Common.Codec.CodecCallStatusItemChangeEventArgs e)
|
||||
{
|
||||
var codec = (Room as EssentialsHuddleVtc1Room).VideoCodec;
|
||||
|
||||
CodecIsInCall.InputSig.BoolValue = codec.IsInCall;
|
||||
}
|
||||
|
||||
// These methods are overridden because they access the room class which is of a different type
|
||||
|
||||
protected override void CreateSymbolAndBasicSigs(uint ipId)
|
||||
{
|
||||
Debug.Console(1, this, "Creating Fusion Room symbol with GUID: {0}", RoomGuid);
|
||||
|
||||
FusionRoom = new FusionRoom(ipId, Global.ControlSystem, Room.Name, RoomGuid);
|
||||
FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.Use();
|
||||
FusionRoom.ExtenderFusionRoomDataReservedSigs.Use();
|
||||
|
||||
FusionRoom.Register();
|
||||
|
||||
FusionRoom.FusionStateChange += FusionRoom_FusionStateChange;
|
||||
|
||||
FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.DeviceExtenderSigChange += FusionRoomSchedule_DeviceExtenderSigChange;
|
||||
FusionRoom.ExtenderFusionRoomDataReservedSigs.DeviceExtenderSigChange += ExtenderFusionRoomDataReservedSigs_DeviceExtenderSigChange;
|
||||
FusionRoom.OnlineStatusChange += FusionRoom_OnlineStatusChange;
|
||||
|
||||
CrestronConsole.AddNewConsoleCommand(RequestFullRoomSchedule, "FusReqRoomSchedule", "Requests schedule of the room for the next 24 hours", ConsoleAccessLevelEnum.AccessOperator);
|
||||
CrestronConsole.AddNewConsoleCommand(ModifyMeetingEndTimeConsoleHelper, "FusReqRoomSchMod", "Ends or extends a meeting by the specified time", ConsoleAccessLevelEnum.AccessOperator);
|
||||
CrestronConsole.AddNewConsoleCommand(CreateAsHocMeeting, "FusCreateMeeting", "Creates and Ad Hoc meeting for on hour or until the next meeting", ConsoleAccessLevelEnum.AccessOperator);
|
||||
|
||||
// Room to fusion room
|
||||
Room.OnFeedback.LinkInputSig(FusionRoom.SystemPowerOn.InputSig);
|
||||
|
||||
// Moved to
|
||||
CurrentRoomSourceNameSig = FusionRoom.CreateOffsetStringSig(84, "Display 1 - Current Source", eSigIoMask.InputSigOnly);
|
||||
// Don't think we need to get current status of this as nothing should be alive yet.
|
||||
(Room as EssentialsHuddleVtc1Room).CurrentSingleSourceChange += Room_CurrentSourceInfoChange;
|
||||
|
||||
|
||||
FusionRoom.SystemPowerOn.OutputSig.SetSigFalseAction((Room as EssentialsHuddleVtc1Room).PowerOnToDefaultOrLastSource);
|
||||
FusionRoom.SystemPowerOff.OutputSig.SetSigFalseAction(() => (Room as EssentialsHuddleVtc1Room).RunRouteAction("roomOff"));
|
||||
// NO!! room.RoomIsOn.LinkComplementInputSig(FusionRoom.SystemPowerOff.InputSig);
|
||||
|
||||
|
||||
CrestronEnvironment.EthernetEventHandler += CrestronEnvironment_EthernetEventHandler;
|
||||
}
|
||||
|
||||
protected override void SetUpSources()
|
||||
{
|
||||
// Sources
|
||||
var dict = ConfigReader.ConfigObject.GetSourceListForKey((Room as EssentialsHuddleVtc1Room).SourceListKey);
|
||||
if (dict != null)
|
||||
{
|
||||
// NEW PROCESS:
|
||||
// Make these lists and insert the fusion attributes by iterating these
|
||||
var setTopBoxes = dict.Where(d => d.Value.SourceDevice is ISetTopBoxControls);
|
||||
uint i = 1;
|
||||
foreach (var kvp in setTopBoxes)
|
||||
{
|
||||
TryAddRouteActionSigs("Display 1 - Source TV " + i, 188 + i, kvp.Key, kvp.Value.SourceDevice);
|
||||
i++;
|
||||
if (i > 5) // We only have five spots
|
||||
break;
|
||||
}
|
||||
|
||||
var discPlayers = dict.Where(d => d.Value.SourceDevice is IDiscPlayerControls);
|
||||
i = 1;
|
||||
foreach (var kvp in discPlayers)
|
||||
{
|
||||
TryAddRouteActionSigs("Display 1 - Source DVD " + i, 181 + i, kvp.Key, kvp.Value.SourceDevice);
|
||||
i++;
|
||||
if (i > 5) // We only have five spots
|
||||
break;
|
||||
}
|
||||
|
||||
var laptops = dict.Where(d => d.Value.SourceDevice is Laptop);
|
||||
i = 1;
|
||||
foreach (var kvp in laptops)
|
||||
{
|
||||
TryAddRouteActionSigs("Display 1 - Source Laptop " + i, 166 + i, kvp.Key, kvp.Value.SourceDevice);
|
||||
i++;
|
||||
if (i > 10) // We only have ten spots???
|
||||
break;
|
||||
}
|
||||
|
||||
foreach (var kvp in dict)
|
||||
{
|
||||
var usageDevice = kvp.Value.SourceDevice as IUsageTracking;
|
||||
|
||||
if (usageDevice != null)
|
||||
{
|
||||
usageDevice.UsageTracker = new UsageTracking(usageDevice as Device);
|
||||
usageDevice.UsageTracker.UsageIsTracked = true;
|
||||
usageDevice.UsageTracker.DeviceUsageEnded += new EventHandler<DeviceUsageEventArgs>(UsageTracker_DeviceUsageEnded);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Console(1, this, "WARNING: Config source list '{0}' not found for room '{1}'",
|
||||
(Room as EssentialsHuddleVtc1Room).SourceListKey, Room.Key);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SetUpDisplay()
|
||||
{
|
||||
try
|
||||
{
|
||||
//Setup Display Usage Monitoring
|
||||
|
||||
var displays = DeviceManager.AllDevices.Where(d => d is DisplayBase);
|
||||
|
||||
// Consider updating this in multiple display systems
|
||||
|
||||
foreach (DisplayBase display in displays)
|
||||
{
|
||||
display.UsageTracker = new UsageTracking(display);
|
||||
display.UsageTracker.UsageIsTracked = true;
|
||||
display.UsageTracker.DeviceUsageEnded += new EventHandler<DeviceUsageEventArgs>(UsageTracker_DeviceUsageEnded);
|
||||
}
|
||||
|
||||
var defaultDisplay = (Room as EssentialsHuddleVtc1Room).DefaultDisplay as DisplayBase;
|
||||
if (defaultDisplay == null)
|
||||
{
|
||||
Debug.Console(1, this, "Cannot link null display to Fusion because default display is null");
|
||||
return;
|
||||
}
|
||||
|
||||
var dispPowerOnAction = new Action<bool>(b => { if (!b) defaultDisplay.PowerOn(); });
|
||||
var dispPowerOffAction = new Action<bool>(b => { if (!b) defaultDisplay.PowerOff(); });
|
||||
|
||||
// Display to fusion room sigs
|
||||
FusionRoom.DisplayPowerOn.OutputSig.UserObject = dispPowerOnAction;
|
||||
FusionRoom.DisplayPowerOff.OutputSig.UserObject = dispPowerOffAction;
|
||||
defaultDisplay.PowerIsOnFeedback.LinkInputSig(FusionRoom.DisplayPowerOn.InputSig);
|
||||
if (defaultDisplay is IDisplayUsage)
|
||||
(defaultDisplay as IDisplayUsage).LampHours.LinkInputSig(FusionRoom.DisplayUsage.InputSig);
|
||||
|
||||
|
||||
|
||||
MapDisplayToRoomJoins(1, 158, defaultDisplay);
|
||||
|
||||
|
||||
var deviceConfig = ConfigReader.ConfigObject.Devices.FirstOrDefault(d => d.Key.Equals(defaultDisplay.Key));
|
||||
|
||||
//Check for existing asset in GUIDs collection
|
||||
|
||||
var tempAsset = new FusionAsset();
|
||||
|
||||
if (FusionStaticAssets.ContainsKey(deviceConfig.Uid))
|
||||
{
|
||||
tempAsset = FusionStaticAssets[deviceConfig.Uid];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create a new asset
|
||||
tempAsset = new FusionAsset(FusionRoomGuids.GetNextAvailableAssetNumber(FusionRoom), defaultDisplay.Name, "Display", "");
|
||||
FusionStaticAssets.Add(deviceConfig.Uid, tempAsset);
|
||||
}
|
||||
|
||||
var dispAsset = FusionRoom.CreateStaticAsset(tempAsset.SlotNumber, tempAsset.Name, "Display", tempAsset.InstanceId);
|
||||
dispAsset.PowerOn.OutputSig.UserObject = dispPowerOnAction;
|
||||
dispAsset.PowerOff.OutputSig.UserObject = dispPowerOffAction;
|
||||
defaultDisplay.PowerIsOnFeedback.LinkInputSig(dispAsset.PowerOn.InputSig);
|
||||
// NO!! display.PowerIsOn.LinkComplementInputSig(dispAsset.PowerOff.InputSig);
|
||||
// Use extension methods
|
||||
dispAsset.TrySetMakeModel(defaultDisplay);
|
||||
dispAsset.TryLinkAssetErrorToCommunication(defaultDisplay);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(1, this, "Error setting up display in Fusion: {0}", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected override void MapDisplayToRoomJoins(int displayIndex, int joinOffset, DisplayBase display)
|
||||
{
|
||||
string displayName = string.Format("Display {0} - ", displayIndex);
|
||||
|
||||
|
||||
if (display == (Room as EssentialsHuddleVtc1Room).DefaultDisplay)
|
||||
{
|
||||
// Power on
|
||||
var defaultDisplayPowerOn = FusionRoom.CreateOffsetBoolSig((uint)joinOffset, displayName + "Power On", eSigIoMask.InputOutputSig);
|
||||
defaultDisplayPowerOn.OutputSig.UserObject = new Action<bool>(b => { if (!b) display.PowerOn(); });
|
||||
display.PowerIsOnFeedback.LinkInputSig(defaultDisplayPowerOn.InputSig);
|
||||
|
||||
// Power Off
|
||||
var defaultDisplayPowerOff = FusionRoom.CreateOffsetBoolSig((uint)joinOffset + 1, displayName + "Power Off", eSigIoMask.InputOutputSig);
|
||||
defaultDisplayPowerOn.OutputSig.UserObject = new Action<bool>(b => { if (!b) display.PowerOff(); }); ;
|
||||
display.PowerIsOnFeedback.LinkInputSig(defaultDisplayPowerOn.InputSig);
|
||||
|
||||
// Current Source
|
||||
var defaultDisplaySourceNone = FusionRoom.CreateOffsetBoolSig((uint)joinOffset + 8, displayName + "Source None", eSigIoMask.InputOutputSig);
|
||||
defaultDisplaySourceNone.OutputSig.UserObject = new Action<bool>(b => { if (!b) (Room as EssentialsHuddleVtc1Room).RunRouteAction("roomOff"); }); ;
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharp.CrestronIO;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
using Crestron.SimplSharpPro.Fusion;
|
||||
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using PepperDash.Essentials.Devices.Common;
|
||||
using PepperDash.Essentials.Devices.Common.Occupancy;
|
||||
|
||||
namespace PepperDash.Essentials.Fusion
|
||||
{
|
||||
public class EssentialsHuddleVtc1FusionController : EssentialsHuddleSpaceFusionSystemControllerBase
|
||||
{
|
||||
BooleanSigData CodecIsInCall;
|
||||
|
||||
public EssentialsHuddleVtc1FusionController(EssentialsHuddleVtc1Room room, uint ipId)
|
||||
: base(room, ipId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called in base class constructor before RVI and GUID files are built
|
||||
/// </summary>
|
||||
protected override void ExecuteCustomSteps()
|
||||
{
|
||||
SetUpCodec();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a static asset for the codec and maps the joins to the main room symbol
|
||||
/// </summary>
|
||||
void SetUpCodec()
|
||||
{
|
||||
try
|
||||
{
|
||||
var codec = (Room as EssentialsHuddleVtc1Room).VideoCodec;
|
||||
|
||||
if (codec == null)
|
||||
{
|
||||
Debug.Console(1, this, "Cannot link codec to Fusion because codec is null");
|
||||
return;
|
||||
}
|
||||
|
||||
codec.UsageTracker = new UsageTracking(codec);
|
||||
codec.UsageTracker.UsageIsTracked = true;
|
||||
codec.UsageTracker.DeviceUsageEnded += UsageTracker_DeviceUsageEnded;
|
||||
|
||||
var codecPowerOnAction = new Action<bool>(b => { if (!b) codec.StandbyDeactivate(); });
|
||||
var codecPowerOffAction = new Action<bool>(b => { if (!b) codec.StandbyActivate(); });
|
||||
|
||||
// Map FusionRoom Attributes:
|
||||
|
||||
// Codec volume
|
||||
var codecVolume = FusionRoom.CreateOffsetUshortSig(50, "Volume - Fader01", eSigIoMask.InputOutputSig);
|
||||
codecVolume.OutputSig.UserObject = new Action<ushort>(b => (codec as IBasicVolumeWithFeedback).SetVolume(b));
|
||||
(codec as IBasicVolumeWithFeedback).VolumeLevelFeedback.LinkInputSig(codecVolume.InputSig);
|
||||
|
||||
// In Call Status
|
||||
CodecIsInCall = FusionRoom.CreateOffsetBoolSig(69, "Conf - VC 1 In Call", eSigIoMask.InputSigOnly);
|
||||
codec.CallStatusChange += new EventHandler<PepperDash.Essentials.Devices.Common.Codec.CodecCallStatusItemChangeEventArgs>(codec_CallStatusChange);
|
||||
|
||||
// Online status
|
||||
if (codec is ICommunicationMonitor)
|
||||
{
|
||||
var c = codec as ICommunicationMonitor;
|
||||
var codecOnline = FusionRoom.CreateOffsetBoolSig(122, "Online - VC 1", eSigIoMask.InputSigOnly);
|
||||
codecOnline.InputSig.BoolValue = c.CommunicationMonitor.Status == MonitorStatus.IsOk;
|
||||
c.CommunicationMonitor.StatusChange += (o, a) =>
|
||||
{
|
||||
codecOnline.InputSig.BoolValue = a.Status == MonitorStatus.IsOk;
|
||||
};
|
||||
Debug.Console(0, this, "Linking '{0}' communication monitor to Fusion '{1}'", codec.Key, "Online - VC 1");
|
||||
}
|
||||
|
||||
// Codec IP Address
|
||||
bool codecHasIpInfo = false;
|
||||
var codecComm = codec.Communication;
|
||||
|
||||
string codecIpAddress = string.Empty;
|
||||
int codecIpPort = 0;
|
||||
|
||||
StringSigData codecIpAddressSig;
|
||||
StringSigData codecIpPortSig;
|
||||
|
||||
if(codecComm is GenericSshClient)
|
||||
{
|
||||
codecIpAddress = (codecComm as GenericSshClient).Hostname;
|
||||
codecIpPort = (codecComm as GenericSshClient).Port;
|
||||
codecHasIpInfo = true;
|
||||
}
|
||||
else if (codecComm is GenericTcpIpClient)
|
||||
{
|
||||
codecIpAddress = (codecComm as GenericTcpIpClient).Hostname;
|
||||
codecIpPort = (codecComm as GenericTcpIpClient).Port;
|
||||
codecHasIpInfo = true;
|
||||
}
|
||||
|
||||
if (codecHasIpInfo)
|
||||
{
|
||||
codecIpAddressSig = FusionRoom.CreateOffsetStringSig(121, "IP Address - VC", eSigIoMask.InputSigOnly);
|
||||
codecIpAddressSig.InputSig.StringValue = codecIpAddress;
|
||||
|
||||
codecIpPortSig = FusionRoom.CreateOffsetStringSig(150, "IP Port - VC", eSigIoMask.InputSigOnly);
|
||||
codecIpPortSig.InputSig.StringValue = codecIpPort.ToString();
|
||||
}
|
||||
|
||||
var tempAsset = new FusionAsset();
|
||||
|
||||
var deviceConfig = ConfigReader.ConfigObject.Devices.FirstOrDefault(c => c.Key.Equals(codec.Key));
|
||||
|
||||
if (FusionStaticAssets.ContainsKey(deviceConfig.Uid))
|
||||
{
|
||||
tempAsset = FusionStaticAssets[deviceConfig.Uid];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create a new asset
|
||||
tempAsset = new FusionAsset(FusionRoomGuids.GetNextAvailableAssetNumber(FusionRoom), codec.Name, "Codec", "");
|
||||
FusionStaticAssets.Add(deviceConfig.Uid, tempAsset);
|
||||
}
|
||||
|
||||
var codecAsset = FusionRoom.CreateStaticAsset(tempAsset.SlotNumber, tempAsset.Name, "Display", tempAsset.InstanceId);
|
||||
codecAsset.PowerOn.OutputSig.UserObject = codecPowerOnAction;
|
||||
codecAsset.PowerOff.OutputSig.UserObject = codecPowerOffAction;
|
||||
codec.StandbyIsOnFeedback.LinkComplementInputSig(codecAsset.PowerOn.InputSig);
|
||||
|
||||
// TODO: Map relevant attributes on asset symbol
|
||||
|
||||
codecAsset.TrySetMakeModel(codec);
|
||||
codecAsset.TryLinkAssetErrorToCommunication(codec);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(1, this, "Error setting up codec in Fusion: {0}", e);
|
||||
}
|
||||
}
|
||||
|
||||
void codec_CallStatusChange(object sender, PepperDash.Essentials.Devices.Common.Codec.CodecCallStatusItemChangeEventArgs e)
|
||||
{
|
||||
var codec = (Room as EssentialsHuddleVtc1Room).VideoCodec;
|
||||
|
||||
CodecIsInCall.InputSig.BoolValue = codec.IsInCall;
|
||||
}
|
||||
|
||||
// These methods are overridden because they access the room class which is of a different type
|
||||
|
||||
protected override void CreateSymbolAndBasicSigs(uint ipId)
|
||||
{
|
||||
Debug.Console(1, this, "Creating Fusion Room symbol with GUID: {0}", RoomGuid);
|
||||
|
||||
FusionRoom = new FusionRoom(ipId, Global.ControlSystem, Room.Name, RoomGuid);
|
||||
FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.Use();
|
||||
FusionRoom.ExtenderFusionRoomDataReservedSigs.Use();
|
||||
|
||||
FusionRoom.Register();
|
||||
|
||||
FusionRoom.FusionStateChange += FusionRoom_FusionStateChange;
|
||||
|
||||
FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.DeviceExtenderSigChange += FusionRoomSchedule_DeviceExtenderSigChange;
|
||||
FusionRoom.ExtenderFusionRoomDataReservedSigs.DeviceExtenderSigChange += ExtenderFusionRoomDataReservedSigs_DeviceExtenderSigChange;
|
||||
FusionRoom.OnlineStatusChange += FusionRoom_OnlineStatusChange;
|
||||
|
||||
CrestronConsole.AddNewConsoleCommand(RequestFullRoomSchedule, "FusReqRoomSchedule", "Requests schedule of the room for the next 24 hours", ConsoleAccessLevelEnum.AccessOperator);
|
||||
CrestronConsole.AddNewConsoleCommand(ModifyMeetingEndTimeConsoleHelper, "FusReqRoomSchMod", "Ends or extends a meeting by the specified time", ConsoleAccessLevelEnum.AccessOperator);
|
||||
CrestronConsole.AddNewConsoleCommand(CreateAsHocMeeting, "FusCreateMeeting", "Creates and Ad Hoc meeting for on hour or until the next meeting", ConsoleAccessLevelEnum.AccessOperator);
|
||||
|
||||
// Room to fusion room
|
||||
Room.OnFeedback.LinkInputSig(FusionRoom.SystemPowerOn.InputSig);
|
||||
|
||||
// Moved to
|
||||
CurrentRoomSourceNameSig = FusionRoom.CreateOffsetStringSig(84, "Display 1 - Current Source", eSigIoMask.InputSigOnly);
|
||||
// Don't think we need to get current status of this as nothing should be alive yet.
|
||||
(Room as EssentialsHuddleVtc1Room).CurrentSingleSourceChange += Room_CurrentSourceInfoChange;
|
||||
|
||||
|
||||
FusionRoom.SystemPowerOn.OutputSig.SetSigFalseAction((Room as EssentialsHuddleVtc1Room).PowerOnToDefaultOrLastSource);
|
||||
FusionRoom.SystemPowerOff.OutputSig.SetSigFalseAction(() => (Room as EssentialsHuddleVtc1Room).RunRouteAction("roomOff"));
|
||||
// NO!! room.RoomIsOn.LinkComplementInputSig(FusionRoom.SystemPowerOff.InputSig);
|
||||
|
||||
|
||||
CrestronEnvironment.EthernetEventHandler += CrestronEnvironment_EthernetEventHandler;
|
||||
}
|
||||
|
||||
protected override void SetUpSources()
|
||||
{
|
||||
// Sources
|
||||
var dict = ConfigReader.ConfigObject.GetSourceListForKey((Room as EssentialsHuddleVtc1Room).SourceListKey);
|
||||
if (dict != null)
|
||||
{
|
||||
// NEW PROCESS:
|
||||
// Make these lists and insert the fusion attributes by iterating these
|
||||
var setTopBoxes = dict.Where(d => d.Value.SourceDevice is ISetTopBoxControls);
|
||||
uint i = 1;
|
||||
foreach (var kvp in setTopBoxes)
|
||||
{
|
||||
TryAddRouteActionSigs("Display 1 - Source TV " + i, 188 + i, kvp.Key, kvp.Value.SourceDevice);
|
||||
i++;
|
||||
if (i > 5) // We only have five spots
|
||||
break;
|
||||
}
|
||||
|
||||
var discPlayers = dict.Where(d => d.Value.SourceDevice is IDiscPlayerControls);
|
||||
i = 1;
|
||||
foreach (var kvp in discPlayers)
|
||||
{
|
||||
TryAddRouteActionSigs("Display 1 - Source DVD " + i, 181 + i, kvp.Key, kvp.Value.SourceDevice);
|
||||
i++;
|
||||
if (i > 5) // We only have five spots
|
||||
break;
|
||||
}
|
||||
|
||||
var laptops = dict.Where(d => d.Value.SourceDevice is Laptop);
|
||||
i = 1;
|
||||
foreach (var kvp in laptops)
|
||||
{
|
||||
TryAddRouteActionSigs("Display 1 - Source Laptop " + i, 166 + i, kvp.Key, kvp.Value.SourceDevice);
|
||||
i++;
|
||||
if (i > 10) // We only have ten spots???
|
||||
break;
|
||||
}
|
||||
|
||||
foreach (var kvp in dict)
|
||||
{
|
||||
var usageDevice = kvp.Value.SourceDevice as IUsageTracking;
|
||||
|
||||
if (usageDevice != null)
|
||||
{
|
||||
usageDevice.UsageTracker = new UsageTracking(usageDevice as Device);
|
||||
usageDevice.UsageTracker.UsageIsTracked = true;
|
||||
usageDevice.UsageTracker.DeviceUsageEnded += new EventHandler<DeviceUsageEventArgs>(UsageTracker_DeviceUsageEnded);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Console(1, this, "WARNING: Config source list '{0}' not found for room '{1}'",
|
||||
(Room as EssentialsHuddleVtc1Room).SourceListKey, Room.Key);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SetUpDisplay()
|
||||
{
|
||||
try
|
||||
{
|
||||
//Setup Display Usage Monitoring
|
||||
|
||||
var displays = DeviceManager.AllDevices.Where(d => d is DisplayBase);
|
||||
|
||||
// Consider updating this in multiple display systems
|
||||
|
||||
foreach (DisplayBase display in displays)
|
||||
{
|
||||
display.UsageTracker = new UsageTracking(display);
|
||||
display.UsageTracker.UsageIsTracked = true;
|
||||
display.UsageTracker.DeviceUsageEnded += new EventHandler<DeviceUsageEventArgs>(UsageTracker_DeviceUsageEnded);
|
||||
}
|
||||
|
||||
var defaultDisplay = (Room as EssentialsHuddleVtc1Room).DefaultDisplay as DisplayBase;
|
||||
if (defaultDisplay == null)
|
||||
{
|
||||
Debug.Console(1, this, "Cannot link null display to Fusion because default display is null");
|
||||
return;
|
||||
}
|
||||
|
||||
var dispPowerOnAction = new Action<bool>(b => { if (!b) defaultDisplay.PowerOn(); });
|
||||
var dispPowerOffAction = new Action<bool>(b => { if (!b) defaultDisplay.PowerOff(); });
|
||||
|
||||
// Display to fusion room sigs
|
||||
FusionRoom.DisplayPowerOn.OutputSig.UserObject = dispPowerOnAction;
|
||||
FusionRoom.DisplayPowerOff.OutputSig.UserObject = dispPowerOffAction;
|
||||
defaultDisplay.PowerIsOnFeedback.LinkInputSig(FusionRoom.DisplayPowerOn.InputSig);
|
||||
if (defaultDisplay is IDisplayUsage)
|
||||
(defaultDisplay as IDisplayUsage).LampHours.LinkInputSig(FusionRoom.DisplayUsage.InputSig);
|
||||
|
||||
|
||||
|
||||
MapDisplayToRoomJoins(1, 158, defaultDisplay);
|
||||
|
||||
|
||||
var deviceConfig = ConfigReader.ConfigObject.Devices.FirstOrDefault(d => d.Key.Equals(defaultDisplay.Key));
|
||||
|
||||
//Check for existing asset in GUIDs collection
|
||||
|
||||
var tempAsset = new FusionAsset();
|
||||
|
||||
if (FusionStaticAssets.ContainsKey(deviceConfig.Uid))
|
||||
{
|
||||
tempAsset = FusionStaticAssets[deviceConfig.Uid];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create a new asset
|
||||
tempAsset = new FusionAsset(FusionRoomGuids.GetNextAvailableAssetNumber(FusionRoom), defaultDisplay.Name, "Display", "");
|
||||
FusionStaticAssets.Add(deviceConfig.Uid, tempAsset);
|
||||
}
|
||||
|
||||
var dispAsset = FusionRoom.CreateStaticAsset(tempAsset.SlotNumber, tempAsset.Name, "Display", tempAsset.InstanceId);
|
||||
dispAsset.PowerOn.OutputSig.UserObject = dispPowerOnAction;
|
||||
dispAsset.PowerOff.OutputSig.UserObject = dispPowerOffAction;
|
||||
defaultDisplay.PowerIsOnFeedback.LinkInputSig(dispAsset.PowerOn.InputSig);
|
||||
// NO!! display.PowerIsOn.LinkComplementInputSig(dispAsset.PowerOff.InputSig);
|
||||
// Use extension methods
|
||||
dispAsset.TrySetMakeModel(defaultDisplay);
|
||||
dispAsset.TryLinkAssetErrorToCommunication(defaultDisplay);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(1, this, "Error setting up display in Fusion: {0}", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected override void MapDisplayToRoomJoins(int displayIndex, int joinOffset, DisplayBase display)
|
||||
{
|
||||
string displayName = string.Format("Display {0} - ", displayIndex);
|
||||
|
||||
|
||||
if (display == (Room as EssentialsHuddleVtc1Room).DefaultDisplay)
|
||||
{
|
||||
// Power on
|
||||
var defaultDisplayPowerOn = FusionRoom.CreateOffsetBoolSig((uint)joinOffset, displayName + "Power On", eSigIoMask.InputOutputSig);
|
||||
defaultDisplayPowerOn.OutputSig.UserObject = new Action<bool>(b => { if (!b) display.PowerOn(); });
|
||||
display.PowerIsOnFeedback.LinkInputSig(defaultDisplayPowerOn.InputSig);
|
||||
|
||||
// Power Off
|
||||
var defaultDisplayPowerOff = FusionRoom.CreateOffsetBoolSig((uint)joinOffset + 1, displayName + "Power Off", eSigIoMask.InputOutputSig);
|
||||
defaultDisplayPowerOn.OutputSig.UserObject = new Action<bool>(b => { if (!b) display.PowerOff(); }); ;
|
||||
display.PowerIsOnFeedback.LinkInputSig(defaultDisplayPowerOn.InputSig);
|
||||
|
||||
// Current Source
|
||||
var defaultDisplaySourceNone = FusionRoom.CreateOffsetBoolSig((uint)joinOffset + 8, displayName + "Source None", eSigIoMask.InputOutputSig);
|
||||
defaultDisplaySourceNone.OutputSig.UserObject = new Action<bool>(b => { if (!b) (Room as EssentialsHuddleVtc1Room).RunRouteAction("roomOff"); }); ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,102 +1,119 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using PepperDash.Essentials.Room.Behaviours;
|
||||
|
||||
namespace PepperDash.Essentials.Fusion
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles mapping Fusion Custom Property values to system properties
|
||||
/// </summary>
|
||||
public class FusionCustomPropertiesBridge
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates the room info and custom properties from Fusion and updates the system properties aa needed
|
||||
/// </summary>
|
||||
/// <param name="roomInfo"></param>
|
||||
public void EvaluateRoomInfo(string roomKey, RoomInformation roomInfo)
|
||||
{
|
||||
var runtimeConfigurableDevices = DeviceManager.AllDevices.Where(d => d is IRuntimeConfigurableDevice);
|
||||
|
||||
try
|
||||
{
|
||||
foreach (var device in runtimeConfigurableDevices)
|
||||
{
|
||||
// Get the current device config so new values can be overwritten over existing
|
||||
var deviceConfig = (device as IRuntimeConfigurableDevice).GetDeviceConfig();
|
||||
|
||||
if (device is RoomOnToDefaultSourceWhenOccupied)
|
||||
{
|
||||
var devConfig = (deviceConfig as RoomOnToDefaultSourceWhenOccupiedConfig);
|
||||
|
||||
var enableFeature = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupied"));
|
||||
if (enableFeature != null)
|
||||
devConfig.EnableRoomOnWhenOccupied = bool.Parse(enableFeature.CustomFieldValue);
|
||||
|
||||
var enableTime = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("RoomOnWhenOccupiedStartTime"));
|
||||
if (enableTime != null)
|
||||
devConfig.OccupancyStartTime = enableTime.CustomFieldValue;
|
||||
|
||||
var disableTime = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("RoomOnWhenOccupiedEndTime"));
|
||||
if (disableTime != null)
|
||||
devConfig.OccupancyEndTime = disableTime.CustomFieldValue;
|
||||
|
||||
var enableSunday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedSun"));
|
||||
if (enableSunday != null)
|
||||
devConfig.EnableSunday = bool.Parse(enableSunday.CustomFieldValue);
|
||||
|
||||
var enableMonday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedMon"));
|
||||
if (enableMonday != null)
|
||||
devConfig.EnableMonday = bool.Parse(enableMonday.CustomFieldValue);
|
||||
|
||||
var enableTuesday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedTue"));
|
||||
if (enableTuesday != null)
|
||||
devConfig.EnableTuesday = bool.Parse(enableTuesday.CustomFieldValue);
|
||||
|
||||
var enableWednesday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedWed"));
|
||||
if (enableWednesday != null)
|
||||
devConfig.EnableWednesday = bool.Parse(enableWednesday.CustomFieldValue);
|
||||
|
||||
var enableThursday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedThu"));
|
||||
if (enableThursday != null)
|
||||
devConfig.EnableThursday = bool.Parse(enableThursday.CustomFieldValue);
|
||||
|
||||
var enableFriday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedFri"));
|
||||
if (enableFriday != null)
|
||||
devConfig.EnableFriday = bool.Parse(enableFriday.CustomFieldValue);
|
||||
|
||||
var enableSaturday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedSat"));
|
||||
if (enableSaturday != null)
|
||||
devConfig.EnableSaturday = bool.Parse(enableSaturday.CustomFieldValue);
|
||||
|
||||
deviceConfig = devConfig;
|
||||
}
|
||||
|
||||
// Set the config on the device
|
||||
(device as IRuntimeConfigurableDevice).SetDeviceConfig(deviceConfig);
|
||||
}
|
||||
|
||||
//var roomConfig = ConfigReader.ConfigObject.Rooms.FirstOrDefault(r => r.Key.Equals(roomKey);
|
||||
|
||||
//if(roomConfig != null)
|
||||
//{
|
||||
// roomConfig.Name = roomInfo.Name;
|
||||
|
||||
// // Update HelpMessage in room properties
|
||||
// roomConfig.Properties.
|
||||
//}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(1, "FusionCustomPropetiesBridge: Error mapping properties: {0}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using PepperDash.Essentials.Core.Devices;
|
||||
using PepperDash.Essentials.Room.Behaviours;
|
||||
|
||||
namespace PepperDash.Essentials.Fusion
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles mapping Fusion Custom Property values to system properties
|
||||
/// </summary>
|
||||
public class FusionCustomPropertiesBridge
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates the room info and custom properties from Fusion and updates the system properties aa needed
|
||||
/// </summary>
|
||||
/// <param name="roomInfo"></param>
|
||||
public void EvaluateRoomInfo(string roomKey, RoomInformation roomInfo)
|
||||
{
|
||||
try
|
||||
{
|
||||
var reconfigurableDevices = DeviceManager.AllDevices.Where(d => d is ReconfigurableDevice);
|
||||
|
||||
foreach (var device in reconfigurableDevices)
|
||||
{
|
||||
// Get the current device config so new values can be overwritten over existing
|
||||
var deviceConfig = (device as ReconfigurableDevice).Config;
|
||||
|
||||
if (device is RoomOnToDefaultSourceWhenOccupied)
|
||||
{
|
||||
Debug.Console(1, "Mapping Room on via Occupancy values from Fusion");
|
||||
|
||||
var devProps = JsonConvert.DeserializeObject<RoomOnToDefaultSourceWhenOccupiedConfig>(deviceConfig.Properties.ToString());
|
||||
|
||||
var enableFeature = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupied"));
|
||||
if (enableFeature != null)
|
||||
devProps.EnableRoomOnWhenOccupied = bool.Parse(enableFeature.CustomFieldValue);
|
||||
|
||||
var enableTime = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("RoomOnWhenOccupiedStartTime"));
|
||||
if (enableTime != null)
|
||||
devProps.OccupancyStartTime = enableTime.CustomFieldValue;
|
||||
|
||||
var disableTime = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("RoomOnWhenOccupiedEndTime"));
|
||||
if (disableTime != null)
|
||||
devProps.OccupancyEndTime = disableTime.CustomFieldValue;
|
||||
|
||||
var enableSunday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedSun"));
|
||||
if (enableSunday != null)
|
||||
devProps.EnableSunday = bool.Parse(enableSunday.CustomFieldValue);
|
||||
|
||||
var enableMonday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedMon"));
|
||||
if (enableMonday != null)
|
||||
devProps.EnableMonday = bool.Parse(enableMonday.CustomFieldValue);
|
||||
|
||||
var enableTuesday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedTue"));
|
||||
if (enableTuesday != null)
|
||||
devProps.EnableTuesday = bool.Parse(enableTuesday.CustomFieldValue);
|
||||
|
||||
var enableWednesday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedWed"));
|
||||
if (enableWednesday != null)
|
||||
devProps.EnableWednesday = bool.Parse(enableWednesday.CustomFieldValue);
|
||||
|
||||
var enableThursday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedThu"));
|
||||
if (enableThursday != null)
|
||||
devProps.EnableThursday = bool.Parse(enableThursday.CustomFieldValue);
|
||||
|
||||
var enableFriday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedFri"));
|
||||
if (enableFriday != null)
|
||||
devProps.EnableFriday = bool.Parse(enableFriday.CustomFieldValue);
|
||||
|
||||
var enableSaturday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedSat"));
|
||||
if (enableSaturday != null)
|
||||
devProps.EnableSaturday = bool.Parse(enableSaturday.CustomFieldValue);
|
||||
|
||||
deviceConfig.Properties = JToken.FromObject(devProps);
|
||||
}
|
||||
else if (device is EssentialsRoomBase)
|
||||
{
|
||||
// Set the room name
|
||||
if (!string.IsNullOrEmpty(roomInfo.Name))
|
||||
{
|
||||
Debug.Console(1, "Current Room Name: {0}. New Room Name: {1}", deviceConfig.Name, roomInfo.Name);
|
||||
// Set the name in config
|
||||
deviceConfig.Name = roomInfo.Name;
|
||||
|
||||
Debug.Console(1, "Room Name Successfully Changed.");
|
||||
}
|
||||
|
||||
// Set the help message
|
||||
var helpMessage = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("RoomHelpMessage"));
|
||||
if (helpMessage != null)
|
||||
{
|
||||
//Debug.Console(1, "Current Help Message: {0}. New Help Message: {1}", deviceConfig.Properties["help"]["message"].Value<string>(ToString()), helpMessage.CustomFieldValue);
|
||||
deviceConfig.Properties["helpMessage"] = (string)helpMessage.CustomFieldValue;
|
||||
}
|
||||
}
|
||||
|
||||
// Set the config on the device
|
||||
(device as ReconfigurableDevice).SetConfig(deviceConfig);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(1, "FusionCustomPropetiesBridge: Error mapping properties: {0}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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")
|
||||
{
|
||||
@@ -87,9 +87,7 @@ namespace PepperDash.Essentials
|
||||
|
||||
else if (typeName == "roomonwhenoccupancydetectedfeature")
|
||||
{
|
||||
var props = JsonConvert.DeserializeObject<Room.Behaviours.RoomOnToDefaultSourceWhenOccupiedConfig>(properties.ToString());
|
||||
|
||||
return new Room.Behaviours.RoomOnToDefaultSourceWhenOccupied(key, props);
|
||||
return new Room.Behaviours.RoomOnToDefaultSourceWhenOccupied(dc);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -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.Config.Environment != null && avDriver.CurrentRoom.Config.Environment.DeviceKeys.Count > 0)
|
||||
{
|
||||
Debug.Console(0, panelController, "Adding environment driver");
|
||||
mainDriver.EnvironmentDriver = new EssentialsEnvironmentDriver(mainDriver, props);
|
||||
|
||||
mainDriver.EnvironmentDriver.GetDevicesFromConfig(avDriver.CurrentRoom.Config.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.Config.Environment != null && avDriver.CurrentRoom.Config.Environment.DeviceKeys.Count > 0)
|
||||
{
|
||||
Debug.Console(0, panelController, "Adding environment driver");
|
||||
mainDriver.EnvironmentDriver = new EssentialsEnvironmentDriver(mainDriver, props);
|
||||
|
||||
mainDriver.EnvironmentDriver.GetDevicesFromConfig(avDriver.CurrentRoom.Config.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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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,37 +81,58 @@
|
||||
</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\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" />
|
||||
<Compile Include="Bridges\DmTxControllerBridge.cs" />
|
||||
<Compile Include="Bridges\GenericLightingBridge.cs" />
|
||||
<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" />
|
||||
<Compile Include="Configuration ORIGINAL\Builders\TPConfig.cs" />
|
||||
<Compile Include="Configuration ORIGINAL\Configuration.cs" />
|
||||
<Compile Include="Configuration ORIGINAL\ConfigurationHelpers.cs" />
|
||||
@@ -132,13 +153,13 @@
|
||||
<Compile Include="Devices\NUMERIC AppleTV.cs" />
|
||||
<Compile Include="ControlSystem.cs" />
|
||||
<Compile Include="Factory\UiDeviceFactory.cs" />
|
||||
<Compile Include="OTHER\Fusion\EssentialsHuddleVtc1FusionController.cs" />
|
||||
<Compile Include="OTHER\Fusion\FusionCustomPropertiesBridge.cs" />
|
||||
<Compile Include="OTHER\Fusion\FusionEventHandlers.cs" />
|
||||
<Compile Include="OTHER\Fusion\FusionProcessorQueries.cs" />
|
||||
<Compile Include="OTHER\Fusion\FusionRviDataClasses.cs" />
|
||||
<Compile Include="FOR REFERENCE UI\OTHER\Fusion\EssentialsHuddleVtc1FusionController.cs" />
|
||||
<Compile Include="FOR REFERENCE UI\OTHER\Fusion\FusionCustomPropertiesBridge.cs" />
|
||||
<Compile Include="FOR REFERENCE UI\OTHER\Fusion\FusionEventHandlers.cs" />
|
||||
<Compile Include="FOR REFERENCE UI\OTHER\Fusion\FusionProcessorQueries.cs" />
|
||||
<Compile Include="FOR REFERENCE UI\OTHER\Fusion\FusionRviDataClasses.cs" />
|
||||
<Compile Include="REMOVE EssentialsApp.cs" />
|
||||
<Compile Include="OTHER\Fusion\EssentialsHuddleSpaceFusionSystemControllerBase.cs" />
|
||||
<Compile Include="FOR REFERENCE UI\OTHER\Fusion\EssentialsHuddleSpaceFusionSystemControllerBase.cs" />
|
||||
<Compile Include="HttpApiHandler.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Room\Behaviours\RoomOnToDefaultSourceWhenOccupied.cs" />
|
||||
@@ -203,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" />
|
||||
|
||||
@@ -4,5 +4,5 @@
|
||||
[assembly: AssemblyCompany("PepperDash Technology Corp")]
|
||||
[assembly: AssemblyProduct("PepperDashEssentials")]
|
||||
[assembly: AssemblyCopyright("Copyright © PepperDash Technology Corp 2018")]
|
||||
[assembly: AssemblyVersion("1.2.11.*")]
|
||||
[assembly: AssemblyVersion("1.4.12.*")]
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ControlSystem>
|
||||
<Name>Test RMC3</Name>
|
||||
<Address>auto 192.168.1.40</Address>
|
||||
<ProgramSlot>Program01</ProgramSlot>
|
||||
<Storage>Internal Flash</Storage>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ControlSystem>
|
||||
<Name>192.168.10.1</Name>
|
||||
<Address>auto 192.168.10.1</Address>
|
||||
<ProgramSlot>Program01</ProgramSlot>
|
||||
<Storage>Internal Flash</Storage>
|
||||
</ControlSystem>
|
||||
@@ -11,6 +11,7 @@ using Newtonsoft.Json.Linq;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using PepperDash.Essentials.Core.Devices;
|
||||
using PepperDash.Essentials.Devices.Common.Occupancy;
|
||||
|
||||
namespace PepperDash.Essentials.Room.Behaviours
|
||||
@@ -18,9 +19,9 @@ namespace PepperDash.Essentials.Room.Behaviours
|
||||
/// <summary>
|
||||
/// A device that when linked to a room can power the room on when enabled during scheduled hours.
|
||||
/// </summary>
|
||||
public class RoomOnToDefaultSourceWhenOccupied : Device, IRuntimeConfigurableDevice
|
||||
public class RoomOnToDefaultSourceWhenOccupied : ReconfigurableDevice
|
||||
{
|
||||
RoomOnToDefaultSourceWhenOccupiedConfig Config;
|
||||
RoomOnToDefaultSourceWhenOccupiedConfig PropertiesConfig;
|
||||
|
||||
public bool FeatureEnabled { get; private set; }
|
||||
|
||||
@@ -42,10 +43,10 @@ namespace PepperDash.Essentials.Room.Behaviours
|
||||
|
||||
private Fusion.EssentialsHuddleSpaceFusionSystemControllerBase FusionRoom;
|
||||
|
||||
public RoomOnToDefaultSourceWhenOccupied(string key, RoomOnToDefaultSourceWhenOccupiedConfig config)
|
||||
: base(key)
|
||||
public RoomOnToDefaultSourceWhenOccupied(DeviceConfig config) :
|
||||
base (config)
|
||||
{
|
||||
Config = config;
|
||||
PropertiesConfig = JsonConvert.DeserializeObject<RoomOnToDefaultSourceWhenOccupiedConfig>(config.Properties.ToString());
|
||||
|
||||
FeatureEventGroup = new ScheduledEventGroup(this.Key);
|
||||
|
||||
@@ -63,7 +64,7 @@ namespace PepperDash.Essentials.Room.Behaviours
|
||||
else
|
||||
Debug.Console(1, this, "Room has no RoomOccupancy object set");
|
||||
|
||||
var fusionRoomKey = Config.RoomKey + "-fusion";
|
||||
var fusionRoomKey = PropertiesConfig.RoomKey + "-fusion";
|
||||
|
||||
FusionRoom = DeviceManager.GetDeviceForKey(fusionRoomKey) as Fusion.EssentialsHuddleSpaceFusionSystemControllerBase;
|
||||
|
||||
@@ -79,45 +80,48 @@ namespace PepperDash.Essentials.Room.Behaviours
|
||||
return base.CustomActivate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets up device based on config values
|
||||
/// </summary>
|
||||
void SetUpDevice()
|
||||
{
|
||||
Room = DeviceManager.GetDeviceForKey(Config.RoomKey) as EssentialsRoomBase;
|
||||
Room = DeviceManager.GetDeviceForKey(PropertiesConfig.RoomKey) as EssentialsRoomBase;
|
||||
|
||||
if (Room != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
FeatureEnabledTime = DateTime.Parse(Config.OccupancyStartTime);
|
||||
FeatureEnabledTime = DateTime.Parse(PropertiesConfig.OccupancyStartTime);
|
||||
|
||||
if (FeatureEnabledTime != null)
|
||||
{
|
||||
Debug.Console(1, this, "Enabled Time: {0}", FeatureEnabledTime.ToString());
|
||||
}
|
||||
else
|
||||
Debug.Console(1, this, "Unable to parse {0} to DateTime", Config.OccupancyStartTime);
|
||||
Debug.Console(1, this, "Unable to parse {0} to DateTime", PropertiesConfig.OccupancyStartTime);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(1, this, "Unable to parse OccupancyStartTime property: {0} \n Error: {1}", Config.OccupancyStartTime, e);
|
||||
Debug.Console(1, this, "Unable to parse OccupancyStartTime property: {0} \n Error: {1}", PropertiesConfig.OccupancyStartTime, e);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
FeatureDisabledTime = DateTime.Parse(Config.OccupancyEndTime);
|
||||
FeatureDisabledTime = DateTime.Parse(PropertiesConfig.OccupancyEndTime);
|
||||
|
||||
if (FeatureDisabledTime != null)
|
||||
{
|
||||
Debug.Console(1, this, "Disabled Time: {0}", FeatureDisabledTime.ToString());
|
||||
}
|
||||
else
|
||||
Debug.Console(1, this, "Unable to parse {0} to DateTime", Config.OccupancyEndTime);
|
||||
Debug.Console(1, this, "Unable to parse {0} to DateTime", PropertiesConfig.OccupancyEndTime);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(1, this, "Unable to parse a DateTime config value \n Error: {1}", e);
|
||||
}
|
||||
|
||||
if (!Config.EnableRoomOnWhenOccupied)
|
||||
if (!PropertiesConfig.EnableRoomOnWhenOccupied)
|
||||
FeatureEventGroup.ClearAllEvents();
|
||||
else
|
||||
{
|
||||
@@ -133,30 +137,18 @@ namespace PepperDash.Essentials.Room.Behaviours
|
||||
FeatureEnabled = CheckIfFeatureShouldBeEnabled();
|
||||
}
|
||||
else
|
||||
Debug.Console(1, this, "Unable to get room from Device Manager with key: {0}", Config.RoomKey);
|
||||
Debug.Console(1, this, "Unable to get room from Device Manager with key: {0}", PropertiesConfig.RoomKey);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a JObject of the device config properties as they currently exist at runtime
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public JToken GetLocalConfigProperties()
|
||||
|
||||
protected override void CustomSetConfig(DeviceConfig config)
|
||||
{
|
||||
return JToken.FromObject(Config);
|
||||
}
|
||||
var newPropertiesConfig = JsonConvert.DeserializeObject<RoomOnToDefaultSourceWhenOccupiedConfig>(config.Properties.ToString());
|
||||
|
||||
public object GetDeviceConfig()
|
||||
{
|
||||
return Config;
|
||||
}
|
||||
if(newPropertiesConfig != null)
|
||||
PropertiesConfig = newPropertiesConfig;
|
||||
|
||||
public void SetDeviceConfig(object config)
|
||||
{
|
||||
var newConfig = config as RoomOnToDefaultSourceWhenOccupiedConfig;
|
||||
|
||||
Config = newConfig;
|
||||
|
||||
ConfigWriter.UpdateDeviceProperties(this.Key, GetLocalConfigProperties());
|
||||
ConfigWriter.UpdateDeviceConfig(config);
|
||||
|
||||
SetUpDevice();
|
||||
}
|
||||
@@ -182,7 +174,7 @@ namespace PepperDash.Essentials.Room.Behaviours
|
||||
{
|
||||
if (SchEvent.Name == FeatureEnableEventName)
|
||||
{
|
||||
if (Config.EnableRoomOnWhenOccupied)
|
||||
if (PropertiesConfig.EnableRoomOnWhenOccupied)
|
||||
FeatureEnabled = true;
|
||||
|
||||
Debug.Console(1, this, "*****Feature Enabled by event.*****");
|
||||
@@ -204,7 +196,7 @@ namespace PepperDash.Essentials.Room.Behaviours
|
||||
{
|
||||
bool enabled = false;
|
||||
|
||||
if(Config.EnableRoomOnWhenOccupied)
|
||||
if(PropertiesConfig.EnableRoomOnWhenOccupied)
|
||||
{
|
||||
Debug.Console(1, this, "Current Time: {0} \n FeatureEnabledTime: {1} \n FeatureDisabledTime: {2}", DateTime.Now, FeatureEnabledTime, FeatureDisabledTime);
|
||||
|
||||
@@ -446,19 +438,19 @@ namespace PepperDash.Essentials.Room.Behaviours
|
||||
{
|
||||
ScheduledEventCommon.eWeekDays value = new ScheduledEventCommon.eWeekDays();
|
||||
|
||||
if (Config.EnableSunday)
|
||||
if (PropertiesConfig.EnableSunday)
|
||||
value = value | ScheduledEventCommon.eWeekDays.Sunday;
|
||||
if (Config.EnableMonday)
|
||||
if (PropertiesConfig.EnableMonday)
|
||||
value = value | ScheduledEventCommon.eWeekDays.Monday;
|
||||
if (Config.EnableTuesday)
|
||||
if (PropertiesConfig.EnableTuesday)
|
||||
value = value | ScheduledEventCommon.eWeekDays.Tuesday;
|
||||
if (Config.EnableWednesday)
|
||||
if (PropertiesConfig.EnableWednesday)
|
||||
value = value | ScheduledEventCommon.eWeekDays.Wednesday;
|
||||
if (Config.EnableThursday)
|
||||
if (PropertiesConfig.EnableThursday)
|
||||
value = value | ScheduledEventCommon.eWeekDays.Thursday;
|
||||
if (Config.EnableFriday)
|
||||
if (PropertiesConfig.EnableFriday)
|
||||
value = value | ScheduledEventCommon.eWeekDays.Friday;
|
||||
if (Config.EnableSaturday)
|
||||
if (PropertiesConfig.EnableSaturday)
|
||||
value = value | ScheduledEventCommon.eWeekDays.Saturday;
|
||||
|
||||
return value;
|
||||
@@ -473,7 +465,7 @@ namespace PepperDash.Essentials.Room.Behaviours
|
||||
{
|
||||
if (type == ScheduledEventCommon.eCallbackReason.NormalExpiration)
|
||||
{
|
||||
if(Config.EnableRoomOnWhenOccupied)
|
||||
if(PropertiesConfig.EnableRoomOnWhenOccupied)
|
||||
FeatureEnabled = true;
|
||||
|
||||
Debug.Console(1, this, "RoomOnToDefaultSourceWhenOccupied Feature Enabled.");
|
||||
|
||||
@@ -20,5 +20,7 @@ namespace PepperDash.Essentials.Room.Config
|
||||
public string DefaultSourceItem { get; set; }
|
||||
[JsonProperty("videoCodecKey")]
|
||||
public string VideoCodecKey { get; set; }
|
||||
[JsonProperty("audioCodecKey")]
|
||||
public string AudioCodecKey { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -24,64 +24,14 @@ namespace PepperDash.Essentials.Room.Config
|
||||
var typeName = roomConfig.Type.ToLower();
|
||||
if (typeName == "huddle")
|
||||
{
|
||||
var props = JsonConvert.DeserializeObject<EssentialsHuddleRoomPropertiesConfig>
|
||||
(roomConfig.Properties.ToString());
|
||||
var disp = DeviceManager.GetDeviceForKey(props.DefaultDisplayKey) as IRoutingSinkWithSwitching;
|
||||
var audio = DeviceManager.GetDeviceForKey(props.DefaultAudioKey) as IRoutingSinkNoSwitching;
|
||||
var huddle = new EssentialsHuddleSpaceRoom(roomConfig.Key, roomConfig.Name, disp, audio, props);
|
||||
var huddle = new EssentialsHuddleSpaceRoom(roomConfig);
|
||||
|
||||
if (props.Occupancy != null)
|
||||
huddle.SetRoomOccupancy(DeviceManager.GetDeviceForKey(props.Occupancy.DeviceKey) as
|
||||
PepperDash.Essentials.Devices.Common.Occupancy.IOccupancyStatusProvider, props.Occupancy.TimeoutMinutes);
|
||||
huddle.LogoUrl = props.Logo.GetUrl();
|
||||
huddle.SourceListKey = props.SourceListKey;
|
||||
huddle.DefaultSourceItem = props.DefaultSourceItem;
|
||||
huddle.DefaultVolume = (ushort)(props.Volumes.Master.Level * 65535 / 100);
|
||||
return huddle;
|
||||
}
|
||||
//else if (typeName == "presentation")
|
||||
//{
|
||||
// var props = JsonConvert.DeserializeObject<EssentialsPresentationRoomPropertiesConfig>
|
||||
// (this.Properties.ToString());
|
||||
// var displaysDict = new Dictionary<uint, IRoutingSinkNoSwitching>();
|
||||
// uint i = 1;
|
||||
// foreach (var dispKey in props.DisplayKeys) // read in the ordered displays list
|
||||
// {
|
||||
// var disp = DeviceManager.GetDeviceForKey(dispKey) as IRoutingSinkWithSwitching;
|
||||
// displaysDict.Add(i++, disp);
|
||||
// }
|
||||
|
||||
// // Get the master volume control
|
||||
// IBasicVolumeWithFeedback masterVolumeControlDev = props.Volumes.Master.GetDevice();
|
||||
|
||||
|
||||
// var presRoom = new EssentialsPresentationRoom(Key, Name, displaysDict, masterVolumeControlDev, props);
|
||||
// return presRoom;
|
||||
//}
|
||||
else if (typeName == "huddlevtc1")
|
||||
{
|
||||
var props = JsonConvert.DeserializeObject<EssentialsHuddleVtc1PropertiesConfig>
|
||||
(roomConfig.Properties.ToString());
|
||||
var disp = DeviceManager.GetDeviceForKey(props.DefaultDisplayKey) as IRoutingSinkWithSwitching;
|
||||
|
||||
var codec = DeviceManager.GetDeviceForKey(props.VideoCodecKey) as
|
||||
PepperDash.Essentials.Devices.Common.VideoCodec.VideoCodecBase;
|
||||
|
||||
var rm = new EssentialsHuddleVtc1Room(roomConfig.Key, roomConfig.Name, disp, codec, codec, props);
|
||||
// Add Occupancy object from config
|
||||
|
||||
if (props.Occupancy != null)
|
||||
rm.SetRoomOccupancy(DeviceManager.GetDeviceForKey(props.Occupancy.DeviceKey) as
|
||||
PepperDash.Essentials.Devices.Common.Occupancy.IOccupancyStatusProvider, props.Occupancy.TimeoutMinutes);
|
||||
rm.LogoUrl = props.Logo.GetUrl();
|
||||
rm.SourceListKey = props.SourceListKey;
|
||||
rm.DefaultSourceItem = props.DefaultSourceItem;
|
||||
rm.DefaultVolume = (ushort)(props.Volumes.Master.Level * 65535 / 100);
|
||||
|
||||
rm.MicrophonePrivacy = GetMicrophonePrivacy(props, rm); // Get Microphone Privacy object, if any
|
||||
|
||||
rm.Emergency = GetEmergency(props, rm); // Get emergency object, if any
|
||||
|
||||
var rm = new EssentialsHuddleVtc1Room(roomConfig);
|
||||
|
||||
return rm;
|
||||
}
|
||||
else if (typeName == "ddvc01Bridge")
|
||||
@@ -96,7 +46,7 @@ namespace PepperDash.Essentials.Room.Config
|
||||
/// Gets and operating, standalone emergegncy object that can be plugged into a room.
|
||||
/// Returns null if there is no emergency defined
|
||||
/// </summary>
|
||||
static EssentialsRoomEmergencyBase GetEmergency(EssentialsRoomPropertiesConfig props, EssentialsRoomBase room)
|
||||
public static EssentialsRoomEmergencyBase GetEmergency(EssentialsRoomPropertiesConfig props, EssentialsRoomBase room)
|
||||
{
|
||||
// This emergency
|
||||
var emergency = props.Emergency;
|
||||
@@ -115,13 +65,13 @@ namespace PepperDash.Essentials.Room.Config
|
||||
/// <param name="props"></param>
|
||||
/// <param name="room"></param>
|
||||
/// <returns></returns>
|
||||
static PepperDash.Essentials.Devices.Common.Microphones.MicrophonePrivacyController GetMicrophonePrivacy(
|
||||
public static PepperDash.Essentials.Devices.Common.Microphones.MicrophonePrivacyController GetMicrophonePrivacy(
|
||||
EssentialsRoomPropertiesConfig props, EssentialsHuddleVtc1Room room)
|
||||
{
|
||||
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
|
||||
|
||||
@@ -4,6 +4,8 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
@@ -11,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;
|
||||
@@ -66,7 +68,7 @@ namespace PepperDash.Essentials
|
||||
}
|
||||
}
|
||||
|
||||
public EssentialsRoomPropertiesConfig Config { get; private set; }
|
||||
public EssentialsHuddleRoomPropertiesConfig PropertiesConfig { get; private set; }
|
||||
|
||||
public IRoutingSinkWithSwitching DefaultDisplay { get; private set; }
|
||||
public IRoutingSinkNoSwitching DefaultAudioDevice { get; private set; }
|
||||
@@ -147,22 +149,32 @@ namespace PepperDash.Essentials
|
||||
|
||||
public string CurrentSourceInfoKey { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="name"></param>
|
||||
public EssentialsHuddleSpaceRoom(string key, string name, IRoutingSinkWithSwitching defaultDisplay,
|
||||
IRoutingSinkNoSwitching defaultAudio, EssentialsRoomPropertiesConfig config)
|
||||
: base(key, name)
|
||||
public EssentialsHuddleSpaceRoom(DeviceConfig config)
|
||||
: base(config)
|
||||
{
|
||||
try
|
||||
{
|
||||
PropertiesConfig = JsonConvert.DeserializeObject<EssentialsHuddleRoomPropertiesConfig>
|
||||
(config.Properties.ToString());
|
||||
DefaultDisplay = DeviceManager.GetDeviceForKey(PropertiesConfig.DefaultDisplayKey) as IRoutingSinkWithSwitching;
|
||||
|
||||
|
||||
DefaultAudioDevice = DeviceManager.GetDeviceForKey(PropertiesConfig.DefaultAudioKey) as IRoutingSinkWithSwitching;
|
||||
|
||||
Initialize();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(1, this, "Error building room: \n{0}", e);
|
||||
}
|
||||
}
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
Config = config;
|
||||
DefaultDisplay = defaultDisplay;
|
||||
DefaultAudioDevice = defaultAudio;
|
||||
if (defaultAudio is IBasicVolumeControls)
|
||||
DefaultVolumeControls = defaultAudio as IBasicVolumeControls;
|
||||
else if (defaultAudio is IHasVolumeDevice)
|
||||
DefaultVolumeControls = (defaultAudio as IHasVolumeDevice).VolumeDevice;
|
||||
if (DefaultAudioDevice is IBasicVolumeControls)
|
||||
DefaultVolumeControls = DefaultAudioDevice as IBasicVolumeControls;
|
||||
else if (DefaultAudioDevice is IHasVolumeDevice)
|
||||
DefaultVolumeControls = (DefaultAudioDevice as IHasVolumeDevice).VolumeDevice;
|
||||
CurrentVolumeControls = DefaultVolumeControls;
|
||||
|
||||
var disp = DefaultDisplay as DisplayBase;
|
||||
@@ -195,6 +207,15 @@ namespace PepperDash.Essentials
|
||||
EnablePowerOnToLastSource = true;
|
||||
}
|
||||
|
||||
protected override void CustomSetConfig(DeviceConfig config)
|
||||
{
|
||||
var newPropertiesConfig = JsonConvert.DeserializeObject<EssentialsHuddleRoomPropertiesConfig>(config.Properties.ToString());
|
||||
|
||||
if (newPropertiesConfig != null)
|
||||
PropertiesConfig = newPropertiesConfig;
|
||||
|
||||
ConfigWriter.UpdateRoomConfig(config);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -225,6 +246,21 @@ namespace PepperDash.Essentials
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool CustomActivate()
|
||||
{
|
||||
// Add Occupancy object from config
|
||||
if (PropertiesConfig.Occupancy != null)
|
||||
this.SetRoomOccupancy(DeviceManager.GetDeviceForKey(PropertiesConfig.Occupancy.DeviceKey) as
|
||||
PepperDash.Essentials.Devices.Common.Occupancy.IOccupancyStatusProvider, PropertiesConfig.Occupancy.TimeoutMinutes);
|
||||
|
||||
this.LogoUrl = PropertiesConfig.Logo.GetUrl();
|
||||
this.SourceListKey = PropertiesConfig.SourceListKey;
|
||||
this.DefaultSourceItem = PropertiesConfig.DefaultSourceItem;
|
||||
this.DefaultVolume = (ushort)(PropertiesConfig.Volumes.Master.Level * 65535 / 100);
|
||||
|
||||
return base.CustomActivate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,6 +7,8 @@ using Crestron.SimplSharp.Scheduler;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using PepperDash.Essentials.Core.Devices;
|
||||
using PepperDash.Essentials.Devices.Common.Occupancy;
|
||||
|
||||
namespace PepperDash.Essentials
|
||||
@@ -14,7 +16,7 @@ namespace PepperDash.Essentials
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public abstract class EssentialsRoomBase : Device
|
||||
public abstract class EssentialsRoomBase : ReconfigurableDevice
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
@@ -80,12 +82,9 @@ namespace PepperDash.Essentials
|
||||
/// </summary>
|
||||
public bool ZeroVolumeWhenSwtichingVolumeDevices { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="name"></param>
|
||||
public EssentialsRoomBase(string key, string name) : base(key, name)
|
||||
|
||||
public EssentialsRoomBase(DeviceConfig config)
|
||||
: base(config)
|
||||
{
|
||||
// Setup the ShutdownPromptTimer
|
||||
ShutdownPromptTimer = new SecondsCountdownTimer(Key + "-offTimer");
|
||||
@@ -201,7 +200,7 @@ namespace PepperDash.Essentials
|
||||
/// </summary>
|
||||
/// <param name="statusProvider"></param>
|
||||
public void SetRoomOccupancy(IOccupancyStatusProvider statusProvider, int timeoutMinutes)
|
||||
{
|
||||
{
|
||||
if (statusProvider == null)
|
||||
{
|
||||
Debug.Console(0, this, "ERROR: Occupancy sensor device is null");
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace PepperDash.Essentials
|
||||
avDriver.PopupInterlock.HideAndClear());
|
||||
}
|
||||
|
||||
void SetUpHelpButton(EssentialsRoomPropertiesConfig roomConf)
|
||||
public void SetUpHelpButton(EssentialsRoomPropertiesConfig roomConf)
|
||||
{
|
||||
// Help roomConf and popup
|
||||
if (roomConf.Help != null)
|
||||
@@ -107,7 +107,7 @@ namespace PepperDash.Essentials
|
||||
var room = DeviceManager.GetDeviceForKey(Config.DefaultRoomKey)
|
||||
as EssentialsHuddleSpaceRoom;
|
||||
if (room != null)
|
||||
message = room.Config.HelpMessage;
|
||||
message = room.PropertiesConfig.HelpMessage;
|
||||
else
|
||||
message = "Sorry, no help message available. No room connected.";
|
||||
//TriList.StringInput[UIStringJoin.HelpMessage].StringValue = message;
|
||||
@@ -227,7 +227,7 @@ namespace PepperDash.Essentials
|
||||
|
||||
TriList.SetBool(UIBoolJoin.TopBarHabaneroDynamicVisible, true);
|
||||
|
||||
var roomConf = currentRoom.Config;
|
||||
var roomConf = currentRoom.PropertiesConfig;
|
||||
|
||||
// Register for the PopupInterlock IsShowsFeedback event to tie the header carets subpage visiblity to it
|
||||
Parent.AvDriver.PopupInterlock.StatusChanged -= PopupInterlock_StatusChanged;
|
||||
@@ -289,7 +289,7 @@ namespace PepperDash.Essentials
|
||||
|
||||
TriList.SetBool(UIBoolJoin.TopBarHabaneroDynamicVisible, true);
|
||||
|
||||
var roomConf = currentRoom.Config;
|
||||
var roomConf = currentRoom.PropertiesConfig;
|
||||
|
||||
// Register for the PopupInterlock IsShowsFeedback event to tie the header carets subpage visiblity to it
|
||||
Parent.AvDriver.PopupInterlock.StatusChanged -= PopupInterlock_StatusChanged;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -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]);
|
||||
|
||||
@@ -484,9 +476,9 @@ namespace PepperDash.Essentials.UIDrivers.VC
|
||||
TriList.SetString(timeTextOffset + i, timeText);
|
||||
|
||||
string iconName = null;
|
||||
if (c.OccurenceType == eCodecOccurrenceType.Received)
|
||||
if (c.OccurrenceType == eCodecOccurrenceType.Received)
|
||||
iconName = "Misc-18_Light";
|
||||
else if (c.OccurenceType == eCodecOccurrenceType.Placed)
|
||||
else if (c.OccurrenceType == eCodecOccurrenceType.Placed)
|
||||
iconName = "Misc-17_Light";
|
||||
else
|
||||
iconName = "Delete";
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
16
README.md
Normal file
16
README.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# Pepperdash Essentials
|
||||
|
||||
#### How to merge
|
||||
|
||||
|
||||
## Essentials Framework
|
||||
|
||||
- If any external references have changed (like PepperDash.Core), make not of them in the commit in Framework
|
||||
|
||||
|
||||
- Make changes
|
||||
- Build
|
||||
- Test on your system
|
||||
- Commit and push to framework
|
||||
- Commit and push to essentials
|
||||
- Curse a whole lot when you try to figure out how to then get developments all synced up
|
||||
Binary file not shown.
Binary file not shown.
@@ -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" ]}
|
||||
Submodule essentials-framework deleted from 1587cee74f
@@ -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
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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 = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
|
||||
// }
|
||||
//}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user