mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-01-12 12:05:00 +00:00
Compare commits
600 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d93a563cd8 | ||
|
|
63f81456e8 | ||
|
|
764d8d2b48 | ||
|
|
1ae6069ac2 | ||
|
|
7eccc82541 | ||
|
|
b2dbd3c377 | ||
|
|
47e47ec272 | ||
|
|
c392ac6b06 | ||
|
|
af2fe7e54e | ||
|
|
3f68a84fe8 | ||
|
|
5d93a5177c | ||
|
|
f83a7aecf2 | ||
|
|
6b21b37aef | ||
|
|
b1459da2ba | ||
|
|
82e2f1e959 | ||
|
|
c329e31802 | ||
|
|
b917ff980a | ||
|
|
c3c9c584ae | ||
|
|
b6f6c72c92 | ||
|
|
59b2995a1b | ||
|
|
bdf3e2054f | ||
|
|
1acb3a20c5 | ||
|
|
2c98fc4545 | ||
|
|
05c9dd3c69 | ||
|
|
5de8b703dd | ||
|
|
a3887510df | ||
|
|
dc8d0e25d5 | ||
|
|
028e411ffe | ||
|
|
5aed3c4480 | ||
|
|
ddfd1d0586 | ||
|
|
77d5438063 | ||
|
|
42a79f0e1e | ||
|
|
f8a6ef8c41 | ||
|
|
af1489d511 | ||
|
|
aa2b5b9ab4 | ||
|
|
fd2fe8fa6e | ||
|
|
15c6da43eb | ||
|
|
6725266ad9 | ||
|
|
8f564a82d4 | ||
|
|
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 | ||
|
|
bd31831a9b | ||
|
|
3d9070dc4f | ||
|
|
3f82eaeb66 | ||
|
|
3cbf784417 | ||
|
|
3d6ce7534f | ||
|
|
28d694d0b4 | ||
|
|
a320eff13c | ||
|
|
f7db0ef36c | ||
|
|
184144dc3c | ||
|
|
dfd7cb4411 | ||
|
|
5014343fa3 | ||
|
|
f2bfeda074 | ||
|
|
339a4f8a62 | ||
|
|
78668e8abb | ||
|
|
101d1b5625 | ||
|
|
780f7bc249 | ||
|
|
6ec0295aba | ||
|
|
f4d2ad86f5 | ||
|
|
d98b7e837a | ||
|
|
99da6debdc | ||
|
|
c2665f0225 | ||
|
|
0406361d75 | ||
|
|
182326b3c5 | ||
|
|
4a69207038 | ||
|
|
7b4aad3516 | ||
|
|
8dabe732ec | ||
|
|
410cf1b4ad | ||
|
|
fbb4951548 | ||
|
|
065075aabd | ||
|
|
ee6293fa75 | ||
|
|
7112c50f5a | ||
|
|
873fd81b5c | ||
|
|
a2a3f4caed | ||
|
|
1df658b7eb | ||
|
|
1c9061cc28 | ||
|
|
a0a83a1af7 | ||
|
|
f17b62844d | ||
|
|
5f8170fb66 | ||
|
|
42086f650d | ||
|
|
6a8ae5b244 | ||
|
|
30506419df | ||
|
|
a84084b273 | ||
|
|
5ed8ff6dac | ||
|
|
b295f931a3 | ||
|
|
0487099ee4 | ||
|
|
bff8529c9f | ||
|
|
c3bea683fc | ||
|
|
f819d0d743 | ||
|
|
6afe1729bf | ||
|
|
d563a6224b | ||
|
|
7ba2429cbf | ||
|
|
1534433949 | ||
|
|
daf44ae797 | ||
|
|
bd31d76e8b | ||
|
|
759635b364 | ||
|
|
c0c90f926e | ||
|
|
96e60f6eaf | ||
|
|
a13428fb4e | ||
|
|
818d6c9ca5 | ||
|
|
a6df8f908b | ||
|
|
0d5c93bbde | ||
|
|
40dcca0e8d | ||
|
|
ef443bdfb0 | ||
|
|
c839cea495 | ||
|
|
768bbf9298 | ||
|
|
999982f789 | ||
|
|
ad48b1ebac | ||
|
|
e196ff1627 | ||
|
|
a900a08095 | ||
|
|
fa94b83d63 | ||
|
|
d70d8b58dd | ||
|
|
1b942918d7 | ||
|
|
ccfcd95508 | ||
|
|
5f119690c2 | ||
|
|
3778314d51 | ||
|
|
163f6e6941 | ||
|
|
7e8cdd738f | ||
|
|
1371c728c5 | ||
|
|
d1d8e29be2 | ||
|
|
43071a4d91 | ||
|
|
4d4d50bc92 | ||
|
|
9eb9485bba | ||
|
|
c447875baf | ||
|
|
f1feaaae90 | ||
|
|
b989b07d78 | ||
|
|
3841a9bad1 | ||
|
|
9ad2fef94a | ||
|
|
f09ccda33c | ||
|
|
4e45103080 | ||
|
|
c2e82e9cb9 | ||
|
|
b16d61f64c | ||
|
|
2e566b41a0 | ||
|
|
be5b23e9d1 | ||
|
|
385686e7e0 | ||
|
|
448b408f94 | ||
|
|
e1422d8653 | ||
|
|
b353b93458 | ||
|
|
55f9dc4c1f | ||
|
|
e7adaabb87 | ||
|
|
0f25d9ed4b | ||
|
|
5cefba4934 | ||
|
|
0e9d1e4c35 | ||
|
|
058ea730ed | ||
|
|
9945f36c90 | ||
|
|
8490f2d722 | ||
|
|
ca9da1ef79 | ||
|
|
e0bfb8f091 | ||
|
|
97db1f35a1 | ||
|
|
f5b589bc2e | ||
|
|
2b6a13271f | ||
|
|
4686799371 | ||
|
|
cb750a2fd0 | ||
|
|
6d81e8d21e | ||
|
|
600b9f11ff | ||
|
|
c20036cfe9 | ||
|
|
005b3f0843 | ||
|
|
fbe5df84be | ||
|
|
8e4c84dd02 | ||
|
|
dace2a57c2 | ||
|
|
3cf188f820 | ||
|
|
80377a41d0 | ||
|
|
a0ebc08838 | ||
|
|
0de4fbb69c | ||
|
|
c88b259c71 | ||
|
|
20660c561a | ||
|
|
b44613b91f | ||
|
|
58de8ce8ad | ||
|
|
33f0a1fe32 | ||
|
|
4b0f8abd9f | ||
|
|
4defea55f0 | ||
|
|
9c8f85555e | ||
|
|
62e2c3d19f | ||
|
|
e1c8b54434 | ||
|
|
6d913e8a72 | ||
|
|
afa1cff0e0 | ||
|
|
ce6cecbb79 | ||
|
|
69314bb1f1 | ||
|
|
fb19b5894b | ||
|
|
82fad55c1e | ||
|
|
8d03e81431 | ||
|
|
fa8ea4cef6 | ||
|
|
97a44ffa4f | ||
|
|
ee55be86e0 | ||
|
|
ced1efdb47 | ||
|
|
5129b19748 | ||
|
|
525881ebe1 | ||
|
|
856a81ded4 | ||
|
|
ef8298ccd6 | ||
|
|
cdbab152f6 | ||
|
|
359bd508e5 | ||
|
|
62e5e6f176 | ||
|
|
2d375ed2d7 | ||
|
|
2e78191e33 | ||
|
|
45ac17622a | ||
|
|
e7e6ae98cf | ||
|
|
2fbd645bf0 | ||
|
|
2a4ed67bee | ||
|
|
17c448e309 | ||
|
|
5afa626fb3 | ||
|
|
ba1e8646e5 | ||
|
|
88e82fb398 | ||
|
|
53ee87c9be | ||
|
|
032bb2b8e5 | ||
|
|
6ee56dd66c | ||
|
|
d887b448c9 | ||
|
|
f099c88352 | ||
|
|
f98a429b55 | ||
|
|
645816c75f | ||
|
|
491fff2793 | ||
|
|
952e7f4083 | ||
|
|
56c418580c | ||
|
|
4134622b28 | ||
|
|
09b3f7c5e7 | ||
|
|
9fa2b22448 | ||
|
|
62d8190eef | ||
|
|
19284b171a | ||
|
|
29c60548cc | ||
|
|
17f147b5e0 | ||
|
|
7aa3d50cd6 | ||
|
|
b85abe1b79 | ||
|
|
b7bab6cfd1 | ||
|
|
b83b3737e9 | ||
|
|
42c4c705c9 | ||
|
|
cb41b31018 | ||
|
|
6f028c06ae | ||
|
|
bc25c31860 | ||
|
|
32b548eba0 | ||
|
|
f83e64ee7e | ||
|
|
2ee365447c | ||
|
|
e5ac725b85 | ||
|
|
d0cbb8d096 | ||
|
|
91f6235441 | ||
|
|
3c256564c6 | ||
|
|
53de4f32eb | ||
|
|
9effa78fdf | ||
|
|
ba5036e400 | ||
|
|
cd747a01ea | ||
|
|
ac4ef972fe | ||
|
|
857d10f0b2 | ||
|
|
b45fb57cb2 | ||
|
|
e1e2627f56 | ||
|
|
d1646f8216 | ||
|
|
02cfc46f90 | ||
|
|
0fb946c7d5 | ||
|
|
026ab438ad | ||
|
|
51afb966d5 | ||
|
|
68fb82f801 | ||
|
|
0830fb8943 | ||
|
|
2ed63e7c84 | ||
|
|
08a4497f2c | ||
|
|
85d79c5265 | ||
|
|
fe76b257b2 | ||
|
|
800de511ce | ||
|
|
82784f00a4 | ||
|
|
289a33451f | ||
|
|
ae496f556b | ||
|
|
762f13c708 | ||
|
|
a61bfc4173 | ||
|
|
c3d455a7c2 | ||
|
|
864e65fe92 | ||
|
|
385dd8a482 | ||
|
|
19860be486 | ||
|
|
4d6a680f23 | ||
|
|
f9cb4e8a34 | ||
|
|
07e77f2ce4 | ||
|
|
6dbc152810 | ||
|
|
a3580ca15c | ||
|
|
7a1ead7b56 | ||
|
|
f9d1a737c4 | ||
|
|
d9013157ad | ||
|
|
43f0ae0533 | ||
|
|
6d66c7d896 | ||
|
|
f327ab1590 | ||
|
|
47fc2f3371 | ||
|
|
d1197329f3 | ||
|
|
a0817307b1 | ||
|
|
43c3b83637 | ||
|
|
2a485e36c8 | ||
|
|
bc47c65e48 | ||
|
|
1ad5bc68e5 | ||
|
|
8a9a8ac6a7 | ||
|
|
b1742675c2 | ||
|
|
f564a2f554 | ||
|
|
0ede2e9973 | ||
|
|
5f5c963fa4 | ||
|
|
3d7fb1a804 | ||
|
|
dc36386c0d | ||
|
|
88a60b06e6 | ||
|
|
7273646be0 | ||
|
|
61883e5d4a | ||
|
|
90c12a97fa | ||
|
|
17fd9488f2 | ||
|
|
84262c782d | ||
|
|
8dbb3fd898 | ||
|
|
01d462d553 | ||
|
|
1d8924bc48 | ||
|
|
0ac439be14 | ||
|
|
23fb8311fe | ||
|
|
65adc5de1c | ||
|
|
13a8876a61 | ||
|
|
3897a41dd1 | ||
|
|
8c47c5ed65 | ||
|
|
3e39210cc0 | ||
|
|
2e98e8d146 | ||
|
|
1aea817f93 | ||
|
|
897d568032 | ||
|
|
a16ea3f034 | ||
|
|
c959f20204 | ||
|
|
8dfa05293c | ||
|
|
4685850eff | ||
|
|
dc53b293f1 | ||
|
|
1d9490c46f | ||
|
|
b301df6910 | ||
|
|
50a6bde4f2 | ||
|
|
dd5253301b | ||
|
|
b423d1cb58 | ||
|
|
91cc452e03 | ||
|
|
07168f0f5b | ||
|
|
08e528220c | ||
|
|
f5626fcd8b | ||
|
|
6482bbe6f4 | ||
|
|
b9fceb830f | ||
|
|
f37d1e18b2 | ||
|
|
bff6d9e68d | ||
|
|
41b42dbc8f | ||
|
|
fb0a91b454 | ||
|
|
2def648596 | ||
|
|
dc04e04f96 | ||
|
|
6f5d74a44e | ||
|
|
ce4f3dfff1 | ||
|
|
cae86d1943 | ||
|
|
0196997a4e | ||
|
|
f9d320e2b2 | ||
|
|
af33aa41bf | ||
|
|
f682793bbb | ||
|
|
3c3fca7766 | ||
|
|
4efc4d4e6e | ||
|
|
d52c629085 | ||
|
|
3e923ff41f | ||
|
|
54f23eeb9f | ||
|
|
c3c7948990 | ||
|
|
c7cfcbe69e | ||
|
|
01a9503f47 | ||
|
|
e6eafdaf14 | ||
|
|
c53a14f05e | ||
|
|
db4b5e863b | ||
|
|
b929113ea6 | ||
|
|
183112987e | ||
|
|
6bbd11c59b | ||
|
|
1274c74807 | ||
|
|
412dca0459 | ||
|
|
ae2725f6d1 | ||
|
|
6b9b6bbd68 | ||
|
|
a8e5e2f763 | ||
|
|
bdde968c61 | ||
|
|
5d2022549d | ||
|
|
3e6f345b8b | ||
|
|
bde56a22d1 | ||
|
|
0bcb776ac5 | ||
|
|
0f41f3ce50 | ||
|
|
46cce6559c | ||
|
|
b57582feea | ||
|
|
13d15388f0 | ||
|
|
58d22abd5a | ||
|
|
214a740345 | ||
|
|
a5eb61ef0e | ||
|
|
12683551a4 | ||
|
|
68427af337 | ||
|
|
33ceff861f | ||
|
|
a2d42dc77b | ||
|
|
1abf56474e | ||
|
|
a262dfdf5b | ||
|
|
26907acb56 | ||
|
|
0ee35dfbd9 | ||
|
|
a71e991383 | ||
|
|
1c63e506b8 | ||
|
|
f498d55dd6 | ||
|
|
1d46f8520d | ||
|
|
3b3ea98dea | ||
|
|
75ff8ea88a | ||
|
|
69e76bdb3a | ||
|
|
639e1810db | ||
|
|
ff5fab4984 | ||
|
|
ca3f6d4d14 | ||
|
|
c045c8e7a6 | ||
|
|
82465e8789 | ||
|
|
c0d3c92495 | ||
|
|
5c6ba60d51 | ||
|
|
f13978368f | ||
|
|
3d811c6979 | ||
|
|
a6f0163264 | ||
|
|
b33273e6d3 | ||
|
|
fed06bc025 | ||
|
|
cc6e555f25 | ||
|
|
b0fd837cdc | ||
|
|
95a6f3948f | ||
|
|
8df353ab75 | ||
|
|
535fce5f33 | ||
|
|
b588a8c325 | ||
|
|
253095cb93 | ||
|
|
9b85456f2e | ||
|
|
f6a9ecca03 | ||
|
|
2028fa308a | ||
|
|
a63e8b394f | ||
|
|
16e1185fdf | ||
|
|
9e4f34acd5 | ||
|
|
dc3cc1d4eb | ||
|
|
e8a9282180 | ||
|
|
58ed6b450f | ||
|
|
741d6a4a87 | ||
|
|
d2680298ff | ||
|
|
1ad1c5404f | ||
|
|
a9424cde22 | ||
|
|
9b145d6dfc | ||
|
|
b6965fac0b | ||
|
|
57dee6153b | ||
|
|
d65ff7add0 | ||
|
|
849675c539 | ||
|
|
fd14eeb9a7 | ||
|
|
2196f5e67a | ||
|
|
830093da3b | ||
|
|
fb70dac224 | ||
|
|
2180521004 | ||
|
|
682c21f37c | ||
|
|
b81c667e5f | ||
|
|
4b4bf1a1c8 | ||
|
|
65819cf723 | ||
|
|
cb5dcc5088 | ||
|
|
0d071e6e82 | ||
|
|
9aad840a78 | ||
|
|
617e2bdc4f | ||
|
|
88de2a2ee0 | ||
|
|
f502432fcc | ||
|
|
a052700934 | ||
|
|
74d48a0427 | ||
|
|
e344e05857 | ||
|
|
0b5681842e | ||
|
|
6ab5f06fc9 | ||
|
|
d55d30be3f | ||
|
|
efd630c8f1 | ||
|
|
2a1c9dbaf6 | ||
|
|
7801a980b5 | ||
|
|
0d42a41af3 | ||
|
|
ba6fdb83ae | ||
|
|
12d9ad1183 | ||
|
|
75fb5bc9d6 | ||
|
|
841af73248 | ||
|
|
2fd4bbc8b3 | ||
|
|
6aad62ee6b | ||
|
|
de8c7477b8 | ||
|
|
057d8ac5f5 | ||
|
|
d5dddade85 | ||
|
|
78529a4d56 | ||
|
|
f87e0a7888 | ||
|
|
2c8259e350 | ||
|
|
19f3b10f90 | ||
|
|
85c2c448d1 | ||
|
|
2b29bf6aa5 | ||
|
|
87e5e9bbe0 | ||
|
|
ce3de2baeb | ||
|
|
f10e20b78a | ||
|
|
6656e67085 | ||
|
|
5c08c7d65e | ||
|
|
0becff5320 | ||
|
|
4cda13f004 | ||
|
|
710bfa3e8f | ||
|
|
25122abed1 | ||
|
|
1d54214c55 | ||
|
|
0f449801e4 | ||
|
|
394be710a4 | ||
|
|
85683ea9fa | ||
|
|
17b0373c73 | ||
|
|
7320f47d60 | ||
|
|
667c511515 | ||
|
|
8586796a6d | ||
|
|
a3d499accf | ||
|
|
9e9b8628a4 | ||
|
|
efd5b59bda | ||
|
|
6d21950180 | ||
|
|
5d0f50677a | ||
|
|
7abccd8865 | ||
|
|
c2d961505e |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -19,4 +19,6 @@ Thumbs.db
|
||||
obj/
|
||||
[Rr]elease*/
|
||||
_ReSharper*/
|
||||
SIMPLSharpLogs/
|
||||
SIMPLSharpLogs/
|
||||
*.projectinfo
|
||||
essentials-framework/EssentialDMTestConfig/
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
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
|
||||
{
|
||||
|
||||
//public class ComPortConfig
|
||||
//{
|
||||
// //public string ContolPortDevKey { get; set; }
|
||||
|
||||
// //public uint ControlPortNumber { get; set; }
|
||||
|
||||
// [JsonConverter(typeof(ComSpecJsonConverter))]
|
||||
// public ComPort.ComPortSpec ComParams { get; set; }
|
||||
//}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
using System;
|
||||
|
||||
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("comment")]
|
||||
public string Comment { get; set; }
|
||||
|
||||
public InfoConfig()
|
||||
{
|
||||
Name = "";
|
||||
Date = DateTime.Now;
|
||||
Type = "";
|
||||
Version = "";
|
||||
Comment = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using System.Text;
|
||||
//using Crestron.SimplSharp;
|
||||
//using Crestron.SimplSharp.CrestronDataStore;
|
||||
//using Crestron.SimplSharpPro;
|
||||
|
||||
|
||||
//namespace PepperDash.Essentials.Core
|
||||
//{
|
||||
// public class Debug
|
||||
// {
|
||||
// public static uint Level { get; private set; }
|
||||
|
||||
// /// <summary>
|
||||
// /// This should called from the ControlSystem Initiailize method.
|
||||
// /// </summary>
|
||||
// public static void Initialize()
|
||||
// {
|
||||
// // Add command to console
|
||||
// CrestronConsole.AddNewConsoleCommand(SetDebugFromConsole, "appdebug",
|
||||
// "appdebug:P [0-2]: Sets the application's console debug message level",
|
||||
// ConsoleAccessLevelEnum.AccessOperator);
|
||||
|
||||
// uint level = 0;
|
||||
// var err = CrestronDataStoreStatic.GetGlobalUintValue("DebugLevel", out level);
|
||||
// if (err == CrestronDataStore.CDS_ERROR.CDS_SUCCESS)
|
||||
// SetDebugLevel(level);
|
||||
// else if (err == CrestronDataStore.CDS_ERROR.CDS_RECORD_NOT_FOUND)
|
||||
// CrestronDataStoreStatic.SetGlobalUintValue("DebugLevel", 0);
|
||||
// else
|
||||
// CrestronConsole.PrintLine("Error restoring console debug level setting: {0}", err);
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// Callback for console command
|
||||
// /// </summary>
|
||||
// /// <param name="levelString"></param>
|
||||
// public static void SetDebugFromConsole(string levelString)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// if (string.IsNullOrEmpty(levelString.Trim()))
|
||||
// {
|
||||
// CrestronConsole.PrintLine("AppDebug level = {0}", Level);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// SetDebugLevel(Convert.ToUInt32(levelString));
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
// CrestronConsole.PrintLine("Usage: appdebug:P [0-2]");
|
||||
// }
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// Sets the debug level
|
||||
// /// </summary>
|
||||
// /// <param name="level"> Valid values 0 (no debug), 1 (critical), 2 (all messages)</param>
|
||||
// public static void SetDebugLevel(uint level)
|
||||
// {
|
||||
// if (level <= 2)
|
||||
// {
|
||||
// Level = 2;
|
||||
// CrestronConsole.PrintLine("[Application {0}], Debug level set to {1}",
|
||||
// InitialParametersClass.ApplicationNumber, level);
|
||||
// var err = CrestronDataStoreStatic.SetGlobalUintValue("DebugLevel", level);
|
||||
// if(err != CrestronDataStore.CDS_ERROR.CDS_SUCCESS)
|
||||
// CrestronConsole.PrintLine("Error saving console debug level setting: {0}", err);
|
||||
// }
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// Prints message to console if current debug level is equal to or higher than the level of this message.
|
||||
// /// Uses CrestronConsole.PrintLine.
|
||||
// /// </summary>
|
||||
// /// <param name="level"></param>
|
||||
// /// <param name="format">Console format string</param>
|
||||
// /// <param name="items">Object parameters</param>
|
||||
// public static void Console(uint level, string format, params object[] items)
|
||||
// {
|
||||
// if (Level >= level)
|
||||
// CrestronConsole.PrintLine("App {0}:{1}", InitialParametersClass.ApplicationNumber,
|
||||
// string.Format(format, items));
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// Appends a device Key to the beginning of a message
|
||||
// /// </summary>
|
||||
// public static void Console(uint level, IKeyed dev, string format, params object[] items)
|
||||
// {
|
||||
// if (Level >= level)
|
||||
// Console(level, "[{0}] {1}", dev.Key, string.Format(format, items));
|
||||
// }
|
||||
|
||||
// public static void Console(uint level, IKeyed dev, ErrorLogLevel errorLogLevel,
|
||||
// string format, params object[] items)
|
||||
// {
|
||||
// if (Level >= level)
|
||||
// {
|
||||
// var str = string.Format("[{0}] {1}", dev.Key, string.Format(format, items));
|
||||
// Console(level, str);
|
||||
// LogError(errorLogLevel, str);
|
||||
// }
|
||||
// }
|
||||
|
||||
// public static void Console(uint level, ErrorLogLevel errorLogLevel,
|
||||
// string format, params object[] items)
|
||||
// {
|
||||
// if (Level >= level)
|
||||
// {
|
||||
// var str = string.Format(format, items);
|
||||
// Console(level, str);
|
||||
// LogError(errorLogLevel, str);
|
||||
// }
|
||||
// }
|
||||
|
||||
// public static void LogError(ErrorLogLevel errorLogLevel, string str)
|
||||
// {
|
||||
// string msg = string.Format("App {0}:{1}", InitialParametersClass.ApplicationNumber, str);
|
||||
// switch (errorLogLevel)
|
||||
// {
|
||||
// case ErrorLogLevel.Error:
|
||||
// ErrorLog.Error(msg);
|
||||
// break;
|
||||
// case ErrorLogLevel.Warning:
|
||||
// ErrorLog.Warn(msg);
|
||||
// break;
|
||||
// case ErrorLogLevel.Notice:
|
||||
// ErrorLog.Notice(msg);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// public enum ErrorLogLevel
|
||||
// {
|
||||
// Error, Warning, Notice, None
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -1,56 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
public interface IHasFeedback : IKeyed
|
||||
{
|
||||
/// <summary>
|
||||
/// This method shall return a list of all Output objects on a device,
|
||||
/// including all "aggregate" devices.
|
||||
/// </summary>
|
||||
List<Feedback> Feedbacks { get; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static class IHasFeedbackExtensions
|
||||
{
|
||||
public static void DumpFeedbacksToConsole(this IHasFeedback source, bool getCurrentStates)
|
||||
{
|
||||
var outputs = source.Feedbacks.OrderBy(x => x.Type);
|
||||
if (outputs != null)
|
||||
{
|
||||
Debug.Console(0, source, "\n\nAvailable outputs:");
|
||||
foreach (var o in outputs)
|
||||
{
|
||||
string val = "";
|
||||
if (getCurrentStates)
|
||||
{
|
||||
switch (o.Type)
|
||||
{
|
||||
case eCueType.Bool:
|
||||
val = " = " + o.BoolValue;
|
||||
break;
|
||||
case eCueType.Int:
|
||||
val = " = " + o.IntValue;
|
||||
break;
|
||||
case eCueType.String:
|
||||
val = " = " + o.StringValue;
|
||||
break;
|
||||
//case eOutputType.Other:
|
||||
// break;
|
||||
}
|
||||
}
|
||||
Debug.Console(0, "{0,-8} {1,5} {2}{3}", o.Type, o.Cue.Number,
|
||||
(string.IsNullOrEmpty(o.Cue.Name) ? "-none-" : o.Cue.Name), val);
|
||||
}
|
||||
}
|
||||
else
|
||||
Debug.Console(0, source, "No available outputs:");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
|
||||
//namespace PepperDash.Essentials.Core
|
||||
//{
|
||||
// //*********************************************************************************************************
|
||||
// /// <summary>
|
||||
// /// The core event and status-bearing class that most if not all device and connectors can derive from.
|
||||
// /// </summary>
|
||||
// public class Device : IKeyed
|
||||
// {
|
||||
// public string Key { get; protected set; }
|
||||
// public string Name { get; protected set; }
|
||||
// public bool Enabled { get; protected set; }
|
||||
// List<Action> _PreActivationActions;
|
||||
// List<Action> _PostActivationActions;
|
||||
|
||||
// public static Device DefaultDevice { get { return _DefaultDevice; } }
|
||||
// static Device _DefaultDevice = new Device("Default", "Default");
|
||||
|
||||
// /// <summary>
|
||||
// /// Base constructor for all Devices.
|
||||
// /// </summary>
|
||||
// /// <param name="key"></param>
|
||||
// public Device(string key)
|
||||
// {
|
||||
// Key = key;
|
||||
// if (key.Contains('.')) Debug.Console(0, this, "WARNING: Device name's should not include '.'");
|
||||
// Name = "";
|
||||
// }
|
||||
|
||||
// public Device(string key, string name) : this(key)
|
||||
// {
|
||||
// Name = name;
|
||||
// }
|
||||
|
||||
// public void AddPreActivationAction(Action act)
|
||||
// {
|
||||
// if (_PreActivationActions == null)
|
||||
// _PreActivationActions = new List<Action>();
|
||||
// _PreActivationActions.Add(act);
|
||||
// }
|
||||
|
||||
// public void AddPostActivationAction(Action act)
|
||||
// {
|
||||
// if (_PostActivationActions == null)
|
||||
// _PostActivationActions = new List<Action>();
|
||||
// _PostActivationActions.Add(act);
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// Gets this device ready to be used in the system. Runs any added pre-activation items, and
|
||||
// /// all post-activation at end. Classes needing additional logic to
|
||||
// /// run should override CustomActivate()
|
||||
// /// </summary>
|
||||
// public bool Activate()
|
||||
// {
|
||||
// if (_PreActivationActions != null)
|
||||
// _PreActivationActions.ForEach(a => a.Invoke());
|
||||
// var result = CustomActivate();
|
||||
// if(result && _PostActivationActions != null)
|
||||
// _PostActivationActions.ForEach(a => a.Invoke());
|
||||
// return result;
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// Called in between Pre and PostActivationActions when Activate() is called.
|
||||
// /// Override to provide addtitional setup when calling activation. Overriding classes
|
||||
// /// do not need to call base.CustomActivate()
|
||||
// /// </summary>
|
||||
// /// <returns>true if device activated successfully.</returns>
|
||||
// public virtual bool CustomActivate() { return true; }
|
||||
|
||||
// /// <summary>
|
||||
// /// Call to deactivate device - unlink events, etc. Overriding classes do not
|
||||
// /// need to call base.Deactivate()
|
||||
// /// </summary>
|
||||
// /// <returns></returns>
|
||||
// public virtual bool Deactivate() { return true; }
|
||||
|
||||
// /// <summary>
|
||||
// /// Helper method to check object for bool value false and fire an Action method
|
||||
// /// </summary>
|
||||
// /// <param name="o">Should be of type bool, others will be ignored</param>
|
||||
// /// <param name="a">Action to be run when o is false</param>
|
||||
// public void OnFalse(object o, Action a)
|
||||
// {
|
||||
// if (o is bool && !(bool)o) a();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -1,44 +0,0 @@
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using Crestron.SimplSharp;
|
||||
//using Crestron.SimplSharpPro;
|
||||
//using Crestron.SimplSharpPro.DeviceSupport;
|
||||
//using Crestron.SimplSharpPro.EthernetCommunication;
|
||||
//using Crestron.SimplSharpPro.UI;
|
||||
|
||||
//using PepperDash.Core;
|
||||
|
||||
|
||||
//namespace PepperDash.Essentials.Core
|
||||
//{
|
||||
|
||||
//[Obsolete]
|
||||
// public class PresentationDevice : Device, IPresentationSource
|
||||
// {
|
||||
// public PresentationSourceType Type { get; protected set; }
|
||||
// public string IconName { get { return "Blank"; } set { } }
|
||||
// public BoolFeedback HasPowerOnFeedback { get; protected set; }
|
||||
|
||||
// PresentationDevice()
|
||||
// : base("Default", "Default")
|
||||
// {
|
||||
// HasPowerOnFeedback = new BoolFeedback(CommonBoolCue.HasPowerFeedback, () => false);
|
||||
// Type = PresentationSourceType.None;
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// Returns a "default" presentation device, with no abilities.
|
||||
// /// </summary>
|
||||
// public static IPresentationSource Default
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// if (_Default == null)
|
||||
// _Default = new PresentationDevice();
|
||||
// return _Default;
|
||||
// }
|
||||
// }
|
||||
// static IPresentationSource _Default;
|
||||
// }
|
||||
//}
|
||||
@@ -1,52 +0,0 @@
|
||||
//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;
|
||||
|
||||
//namespace PepperDash.Essentials.Core
|
||||
//{
|
||||
|
||||
// public class DeviceConfig
|
||||
// {
|
||||
// public string Key { get; set; }
|
||||
// public string Name { get; set; }
|
||||
// public string Type { get; set; }
|
||||
// [JsonConverter(typeof(DevicePropertiesJsonConverter))]
|
||||
// public JToken Properties { get; set; }
|
||||
|
||||
|
||||
// }
|
||||
|
||||
// /// <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
|
||||
// /// </summary>
|
||||
// public class DevicePropertiesJsonConverter : JsonConverter
|
||||
// {
|
||||
// public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
// {
|
||||
// return JObject.Load(reader);
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// This will be hit with every value in the ComPortConfig class. We only need to
|
||||
// /// do custom conversion on the comspec items.
|
||||
// /// </summary>
|
||||
// public override bool CanConvert(Type objectType)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// public override bool CanRead { get { return true; } }
|
||||
// public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -1,50 +0,0 @@
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using System.Text;
|
||||
//using Crestron.SimplSharp;
|
||||
//using Crestron.SimplSharpPro;
|
||||
//using Crestron.SimplSharpPro.DeviceSupport;
|
||||
|
||||
//using PepperDash.Core;
|
||||
|
||||
|
||||
//namespace PepperDash.Essentials.Core
|
||||
//{
|
||||
// public abstract class DvdDeviceBase : Device, IPresentationSource, IHasCueActionList
|
||||
// {
|
||||
// public DvdDeviceBase(string key, string name)
|
||||
// : base(key, name)
|
||||
// {
|
||||
// HasPowerOnFeedback = new BoolFeedback(() => false);
|
||||
|
||||
// }
|
||||
|
||||
// #region IPresentationSource Members
|
||||
|
||||
// PresentationSourceType IPresentationSource.Type
|
||||
// {
|
||||
// get { return PresentationSourceType.Dvd; }
|
||||
// }
|
||||
|
||||
// public string IconName
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// return "DVD";
|
||||
// }
|
||||
// set { }
|
||||
// }
|
||||
|
||||
// public virtual BoolFeedback HasPowerOnFeedback { get; private set; }
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region IFunctionList Members
|
||||
|
||||
// public abstract List<CueActionPair> CueActionList { get; }
|
||||
|
||||
// #endregion
|
||||
|
||||
// }
|
||||
//}
|
||||
@@ -1,130 +0,0 @@
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using Crestron.SimplSharpPro;
|
||||
|
||||
//using PepperDash.Essentials.Core;
|
||||
|
||||
//using PepperDash.Core;
|
||||
|
||||
|
||||
//namespace PepperDash.Essentials.Core
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// This DVD class should cover most IR, one-way DVD and Bluray fuctions
|
||||
// /// </summary>
|
||||
// public class IrDvdBase : Device, IHasCueActionList,
|
||||
// IPresentationSource, IAttachVideoStatus, IHasFeedback, IRoutingOutputs
|
||||
// {
|
||||
// public PresentationSourceType Type { get; protected set; }
|
||||
// public string IconName { get; set; }
|
||||
|
||||
// public BoolFeedback HasPowerOnFeedback { get; private set; }
|
||||
// public IrOutputPortController IrPort { get; private set; }
|
||||
|
||||
// public RoutingOutputPort HdmiOut { get; private set; }
|
||||
|
||||
// #region IRoutingOutputs Members
|
||||
|
||||
// /// <summary>
|
||||
// /// Options: hdmi
|
||||
// /// </summary>
|
||||
// public RoutingPortCollection<RoutingOutputPort> OutputPorts { get; private set; }
|
||||
|
||||
// #endregion
|
||||
|
||||
// public IrDvdBase(string key, string name, IROutputPort port, IrDriverInfo driverInfo)
|
||||
// : base(key, name)
|
||||
// {
|
||||
// IrPort = new IrOutputPortController("ir-" + key, port, driverInfo.FileName);
|
||||
// Type = PresentationSourceType.Dvd;
|
||||
// IconName = "Bluray";
|
||||
// HasPowerOnFeedback = new BoolFeedback(CommonBoolCue.HasPowerFeedback, () => false);
|
||||
|
||||
// HdmiOut = new RoutingOutputPort("HDMI", eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, 0, this);
|
||||
// OutputPorts = new RoutingPortCollection<RoutingOutputPort>()
|
||||
// {
|
||||
// HdmiOut
|
||||
// };
|
||||
// CueActionList = IrPort.GetUOsForIrCommands(driverInfo.IrMap);
|
||||
// }
|
||||
|
||||
// public IrDvdBase(string key, string name, IROutputPort port, string irDriverFilepath)
|
||||
// : base(key, name)
|
||||
// {
|
||||
// IrPort = new IrOutputPortController("ir-" + key, port, irDriverFilepath);
|
||||
// Type = PresentationSourceType.Dvd;
|
||||
// IconName = "Bluray";
|
||||
// HasPowerOnFeedback = new BoolFeedback(CommonBoolCue.HasPowerFeedback, () => false);
|
||||
|
||||
// HdmiOut = new RoutingOutputPort("HDMI", eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, 0, this);
|
||||
// OutputPorts = new RoutingPortCollection<RoutingOutputPort>()
|
||||
// {
|
||||
// HdmiOut
|
||||
// };
|
||||
// var numToIr = new Dictionary<Cue, string>
|
||||
// {
|
||||
// { CommonBoolCue.Power, IROutputStandardCommands.IROut_POWER },
|
||||
// { CommonBoolCue.PowerOff, IROutputStandardCommands.IROut_POWER_OFF },
|
||||
// { CommonBoolCue.PowerOn, IROutputStandardCommands.IROut_POWER_ON },
|
||||
// { CommonBoolCue.Replay, IROutputStandardCommands.IROut_REPLAY },
|
||||
// { CommonBoolCue.Play, IROutputStandardCommands.IROut_PLAY },
|
||||
// { CommonBoolCue.Pause, IROutputStandardCommands.IROut_PAUSE },
|
||||
// { CommonBoolCue.Stop, IROutputStandardCommands.IROut_STOP },
|
||||
// { CommonBoolCue.ChapPrevious, IROutputStandardCommands.IROut_TRACK_MINUS },
|
||||
// { CommonBoolCue.ChapNext, IROutputStandardCommands.IROut_TRACK_PLUS },
|
||||
// { CommonBoolCue.Rewind, IROutputStandardCommands.IROut_RSCAN },
|
||||
// { CommonBoolCue.Ffwd, IROutputStandardCommands.IROut_FSCAN },
|
||||
// { CommonBoolCue.RStep, IROutputStandardCommands.IROut_R_STEP },
|
||||
// { CommonBoolCue.FStep, IROutputStandardCommands.IROut_F_STEP },
|
||||
// { CommonBoolCue.Exit, IROutputStandardCommands.IROut_EXIT },
|
||||
// { CommonBoolCue.Home, IROutputStandardCommands.IROut_HOME },
|
||||
// { CommonBoolCue.Menu, IROutputStandardCommands.IROut_MENU },
|
||||
// { CommonBoolCue.PopUp, IROutputStandardCommands.IROut_POPUPMENU },
|
||||
// { CommonBoolCue.Up, IROutputStandardCommands.IROut_UP_ARROW },
|
||||
// { CommonBoolCue.Down, IROutputStandardCommands.IROut_DN_ARROW },
|
||||
// { CommonBoolCue.Left, IROutputStandardCommands.IROut_LEFT_ARROW },
|
||||
// { CommonBoolCue.Right, IROutputStandardCommands.IROut_RIGHT_ARROW },
|
||||
// { CommonBoolCue.Select, IROutputStandardCommands.IROut_ENTER },
|
||||
// { CommonBoolCue.Info, IROutputStandardCommands.IROut_INFO },
|
||||
// { CommonBoolCue.Red, IROutputStandardCommands.IROut_RED },
|
||||
// { CommonBoolCue.Green, IROutputStandardCommands.IROut_GREEN },
|
||||
// { CommonBoolCue.Yellow, IROutputStandardCommands.IROut_YELLOW },
|
||||
// { CommonBoolCue.Blue, IROutputStandardCommands.IROut_BLUE },
|
||||
// { CommonBoolCue.Digit0, IROutputStandardCommands.IROut_0 },
|
||||
// { CommonBoolCue.Digit1, IROutputStandardCommands.IROut_1 },
|
||||
// { CommonBoolCue.Digit2, IROutputStandardCommands.IROut_2 },
|
||||
// { CommonBoolCue.Digit3, IROutputStandardCommands.IROut_3 },
|
||||
// { CommonBoolCue.Digit4, IROutputStandardCommands.IROut_4 },
|
||||
// { CommonBoolCue.Digit5, IROutputStandardCommands.IROut_5 },
|
||||
// { CommonBoolCue.Digit6, IROutputStandardCommands.IROut_6 },
|
||||
// { CommonBoolCue.Digit7, IROutputStandardCommands.IROut_7 },
|
||||
// { CommonBoolCue.Digit8, IROutputStandardCommands.IROut_8 },
|
||||
// { CommonBoolCue.Digit9, IROutputStandardCommands.IROut_9 },
|
||||
// { CommonBoolCue.Audio, "AUDIO" },
|
||||
// { CommonBoolCue.Subtitle, "SUBTITLE" },
|
||||
// { CommonBoolCue.Setup, "SETUP" },
|
||||
// };
|
||||
// CueActionList = IrPort.GetUOsForIrCommands(numToIr);
|
||||
// }
|
||||
|
||||
|
||||
// public List<Feedback> Feedbacks
|
||||
// {
|
||||
// get { return this.GetVideoStatuses().ToList(); }
|
||||
// }
|
||||
|
||||
|
||||
// #region IFunctionList Members
|
||||
|
||||
// public List<CueActionPair> CueActionList { get; set; }
|
||||
|
||||
// #endregion
|
||||
// }
|
||||
|
||||
// public class IrDriverInfo
|
||||
// {
|
||||
// public Dictionary<Cue, string> IrMap { get; set; }
|
||||
// public string FileName { get; set; }
|
||||
// }
|
||||
//}
|
||||
@@ -1,143 +0,0 @@
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using Crestron.SimplSharpPro;
|
||||
|
||||
//using PepperDash.Essentials.Core;
|
||||
//using PepperDash.Essentials.Core.Presets;
|
||||
|
||||
//using PepperDash.Core;
|
||||
|
||||
|
||||
//namespace PepperDash.Essentials.Core
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// This DVD class should cover most IR, one-way DVD and Bluray fuctions
|
||||
// /// </summary>
|
||||
// public class IrSetTopBoxBase : Device, IHasCueActionList,
|
||||
// IPresentationSource, IAttachVideoStatus, IHasFeedback, IRoutingOutputs, IHasSetTopBoxProperties
|
||||
// {
|
||||
// public PresentationSourceType Type { get; protected set; }
|
||||
// public string IconName { get; set; }
|
||||
|
||||
// public BoolFeedback HasPowerOnFeedback { get; private set; }
|
||||
// public IrOutputPortController IrPort { get; private set; }
|
||||
|
||||
// public DevicePresetsModel PresetsModel { get; private set; }
|
||||
|
||||
// #region IRoutingOutputs Members
|
||||
|
||||
// /// <summary>
|
||||
// /// Options: hdmi
|
||||
// /// </summary>
|
||||
// public RoutingPortCollection<RoutingOutputPort> OutputPorts { get; private set; }
|
||||
|
||||
// #endregion
|
||||
|
||||
// public IrSetTopBoxBase(string key, string name, IROutputPort port, string irDriverFilepath)
|
||||
// : base(key, name)
|
||||
// {
|
||||
// IrPort = new IrOutputPortController("ir-" + key, port, irDriverFilepath);
|
||||
// Type = PresentationSourceType.SetTopBox;
|
||||
// IconName = "TV";
|
||||
// HasPowerOnFeedback = new BoolFeedback(CommonBoolCue.HasPowerFeedback, () => false);
|
||||
// OutputPorts = new RoutingPortCollection<RoutingOutputPort>()
|
||||
// {
|
||||
// new RoutingOutputPort("HDMI", eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, 0, this)
|
||||
// };
|
||||
// }
|
||||
|
||||
// public void LoadPresets(string filePath)
|
||||
// {
|
||||
// //PresetsModel = new DevicePresetsModel(Key + "-presets", this, filePath);
|
||||
// //DeviceManager.AddDevice(PresetsModel);
|
||||
// }
|
||||
|
||||
// #region IDeviceWithOutputs Members
|
||||
|
||||
// public List<Feedback> Feedbacks
|
||||
// {
|
||||
// get { return this.GetVideoStatuses().ToList(); }
|
||||
// }
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region IFunctionList Members
|
||||
|
||||
// public List<CueActionPair> CueActionList
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// // This might be the best way to get the words back into functions
|
||||
// new BoolCueActionPair(CommonBoolCue.Power, b => IrPort.PressRelease(IROutputStandardCommands.IROut_POWER, b));
|
||||
// new BoolCueActionPair(CommonBoolCue.PowerOn, b => IrPort.PressRelease(IROutputStandardCommands.IROut_POWER_ON, b));
|
||||
// new BoolCueActionPair(CommonBoolCue.PowerOff, b => IrPort.PressRelease(IROutputStandardCommands.IROut_POWER_OFF, b));
|
||||
// new BoolCueActionPair(CommonBoolCue.ChannelUp, b => IrPort.PressRelease(IROutputStandardCommands.IROut_CH_PLUS, b));
|
||||
|
||||
// var numToIr = new Dictionary<Cue, string>
|
||||
// {
|
||||
// { CommonBoolCue.Power, IROutputStandardCommands.IROut_POWER },
|
||||
// { CommonBoolCue.PowerOn, IROutputStandardCommands.IROut_POWER_ON },
|
||||
// { CommonBoolCue.PowerOff, IROutputStandardCommands.IROut_POWER_OFF },
|
||||
// { CommonBoolCue.ChannelUp, IROutputStandardCommands.IROut_CH_PLUS },
|
||||
// { CommonBoolCue.ChannelDown, IROutputStandardCommands.IROut_CH_MINUS },
|
||||
// { CommonBoolCue.Last, IROutputStandardCommands.IROut_LAST },
|
||||
// { CommonBoolCue.Play, IROutputStandardCommands.IROut_PLAY },
|
||||
// { CommonBoolCue.Pause, IROutputStandardCommands.IROut_PAUSE },
|
||||
// { CommonBoolCue.Stop, IROutputStandardCommands.IROut_STOP },
|
||||
// { CommonBoolCue.ChapPrevious, IROutputStandardCommands.IROut_TRACK_MINUS },
|
||||
// { CommonBoolCue.ChapNext, IROutputStandardCommands.IROut_TRACK_PLUS },
|
||||
// { CommonBoolCue.Rewind, IROutputStandardCommands.IROut_RSCAN },
|
||||
// { CommonBoolCue.Ffwd, IROutputStandardCommands.IROut_FSCAN },
|
||||
// { CommonBoolCue.Replay, IROutputStandardCommands.IROut_REPLAY },
|
||||
// { CommonBoolCue.Advance, "ADVANCE" },
|
||||
// { CommonBoolCue.Record, IROutputStandardCommands.IROut_RECORD },
|
||||
// { CommonBoolCue.Exit, IROutputStandardCommands.IROut_EXIT },
|
||||
// { CommonBoolCue.Menu, IROutputStandardCommands.IROut_MENU },
|
||||
// { CommonBoolCue.List, IROutputStandardCommands.IROut_DVR },
|
||||
// { CommonBoolCue.Dvr, IROutputStandardCommands.IROut_DVR },
|
||||
// { CommonBoolCue.Back, IROutputStandardCommands.IROut_BACK },
|
||||
// { CommonBoolCue.Up, IROutputStandardCommands.IROut_UP_ARROW },
|
||||
// { CommonBoolCue.Down, IROutputStandardCommands.IROut_DN_ARROW },
|
||||
// { CommonBoolCue.Left, IROutputStandardCommands.IROut_LEFT_ARROW },
|
||||
// { CommonBoolCue.Right, IROutputStandardCommands.IROut_RIGHT_ARROW },
|
||||
// { CommonBoolCue.Select, IROutputStandardCommands.IROut_ENTER },
|
||||
// { CommonBoolCue.Guide, IROutputStandardCommands.IROut_GUIDE },
|
||||
// { CommonBoolCue.PageUp, IROutputStandardCommands.IROut_PAGE_UP },
|
||||
// { CommonBoolCue.PageDown, IROutputStandardCommands.IROut_PAGE_DOWN },
|
||||
// { CommonBoolCue.Info, IROutputStandardCommands.IROut_INFO },
|
||||
// { CommonBoolCue.Red, IROutputStandardCommands.IROut_RED },
|
||||
// { CommonBoolCue.Green, IROutputStandardCommands.IROut_GREEN },
|
||||
// { CommonBoolCue.Yellow, IROutputStandardCommands.IROut_YELLOW },
|
||||
// { CommonBoolCue.Blue, IROutputStandardCommands.IROut_BLUE },
|
||||
// { CommonBoolCue.Digit0, IROutputStandardCommands.IROut_0 },
|
||||
// { CommonBoolCue.Digit1, IROutputStandardCommands.IROut_1 },
|
||||
// { CommonBoolCue.Digit2, IROutputStandardCommands.IROut_2 },
|
||||
// { CommonBoolCue.Digit3, IROutputStandardCommands.IROut_3 },
|
||||
// { CommonBoolCue.Digit4, IROutputStandardCommands.IROut_4 },
|
||||
// { CommonBoolCue.Digit5, IROutputStandardCommands.IROut_5 },
|
||||
// { CommonBoolCue.Digit6, IROutputStandardCommands.IROut_6 },
|
||||
// { CommonBoolCue.Digit7, IROutputStandardCommands.IROut_7 },
|
||||
// { CommonBoolCue.Digit8, IROutputStandardCommands.IROut_8 },
|
||||
// { CommonBoolCue.Digit9, IROutputStandardCommands.IROut_9 },
|
||||
// { CommonBoolCue.Dash, "DASH" },
|
||||
// };
|
||||
// return IrPort.GetUOsForIrCommands(numToIr);
|
||||
// }
|
||||
// }
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region IHasSetTopBoxProperties Members
|
||||
|
||||
// public bool HasDpad { get; set; }
|
||||
|
||||
// public bool HasPreset { get; set; }
|
||||
|
||||
// public bool HasDvr { get; set; }
|
||||
|
||||
// public bool HasNumbers { get; set; }
|
||||
|
||||
// #endregion
|
||||
// }
|
||||
//}
|
||||
@@ -1,220 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
public abstract class Feedback
|
||||
{
|
||||
public event EventHandler<EventArgs> OutputChange;
|
||||
|
||||
public virtual bool BoolValue { get { return false; } }
|
||||
public virtual int IntValue { get { return 0; } }
|
||||
public virtual string StringValue { get { return ""; } }
|
||||
|
||||
public Cue Cue { get; private set; }
|
||||
|
||||
public abstract eCueType Type { get; }
|
||||
|
||||
protected Feedback()
|
||||
{
|
||||
}
|
||||
|
||||
protected Feedback(Cue cue)
|
||||
{
|
||||
Cue = cue;
|
||||
}
|
||||
|
||||
public abstract void FireUpdate();
|
||||
|
||||
protected void OnOutputChange()
|
||||
{
|
||||
if (OutputChange != null) OutputChange(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A Feedback whose output is derived from the return value of a provided Func.
|
||||
/// </summary>
|
||||
public class BoolFeedback : Feedback
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the current value of the feedback, derived from the ValueFunc
|
||||
/// </summary>
|
||||
public override bool BoolValue { get { return _BoolValue; } }
|
||||
bool _BoolValue;
|
||||
|
||||
public override eCueType Type { get { return eCueType.Bool; } }
|
||||
|
||||
public Func<bool> ValueFunc { get; private set; }
|
||||
/// <summary>
|
||||
/// The last value delivered on FireUpdate
|
||||
/// </summary>
|
||||
//public bool PreviousValue { get; private set; }
|
||||
List<BoolInputSig> LinkedInputSigs = new List<BoolInputSig>();
|
||||
List<BoolInputSig> LinkedComplementInputSigs = new List<BoolInputSig>();
|
||||
|
||||
public BoolFeedback(Func<bool> valueFunc)
|
||||
: this(Cue.DefaultBoolCue, valueFunc)
|
||||
{
|
||||
}
|
||||
|
||||
public BoolFeedback(Cue cue, Func<bool> valueFunc)
|
||||
: base(cue)
|
||||
{
|
||||
if (cue == null) throw new ArgumentNullException("cue");
|
||||
ValueFunc = valueFunc;
|
||||
}
|
||||
|
||||
public override void FireUpdate()
|
||||
{
|
||||
var newValue = ValueFunc.Invoke();
|
||||
if (newValue != _BoolValue)
|
||||
{
|
||||
_BoolValue = newValue;
|
||||
LinkedInputSigs.ForEach(s => UpdateSig(s));
|
||||
LinkedComplementInputSigs.ForEach(s => UpdateComplementSig(s));
|
||||
OnOutputChange();
|
||||
}
|
||||
}
|
||||
|
||||
public void LinkInputSig(BoolInputSig sig)
|
||||
{
|
||||
LinkedInputSigs.Add(sig);
|
||||
UpdateSig(sig);
|
||||
}
|
||||
|
||||
public void UnlinkInputSig(BoolInputSig sig)
|
||||
{
|
||||
LinkedInputSigs.Remove(sig);
|
||||
}
|
||||
|
||||
public void LinkComplementInputSig(BoolInputSig sig)
|
||||
{
|
||||
LinkedComplementInputSigs.Add(sig);
|
||||
UpdateComplementSig(sig);
|
||||
}
|
||||
|
||||
public void UnlinkComplementInputSig(BoolInputSig sig)
|
||||
{
|
||||
LinkedComplementInputSigs.Remove(sig);
|
||||
}
|
||||
|
||||
void UpdateSig(BoolInputSig sig)
|
||||
{
|
||||
sig.BoolValue = _BoolValue;
|
||||
}
|
||||
|
||||
void UpdateComplementSig(BoolInputSig sig)
|
||||
{
|
||||
sig.BoolValue = !_BoolValue;
|
||||
}
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
public class IntFeedback : Feedback
|
||||
{
|
||||
public override int IntValue { get { return _IntValue; } } // ValueFunc.Invoke(); } }
|
||||
int _IntValue;
|
||||
public ushort UShortValue { get { return (ushort)_IntValue; } }
|
||||
public override eCueType Type { get { return eCueType.Int; } }
|
||||
//public int PreviousValue { get; private set; }
|
||||
|
||||
Func<int> ValueFunc;
|
||||
List<UShortInputSig> LinkedInputSigs = new List<UShortInputSig>();
|
||||
|
||||
public IntFeedback(Func<int> valueFunc)
|
||||
: this(Cue.DefaultIntCue, valueFunc)
|
||||
{
|
||||
}
|
||||
|
||||
public IntFeedback(Cue cue, Func<int> valueFunc)
|
||||
: base(cue)
|
||||
{
|
||||
if (cue == null) throw new ArgumentNullException("cue");
|
||||
ValueFunc = valueFunc;
|
||||
}
|
||||
|
||||
public override void FireUpdate()
|
||||
{
|
||||
var newValue = ValueFunc.Invoke();
|
||||
if (newValue != _IntValue)
|
||||
{
|
||||
_IntValue = newValue;
|
||||
LinkedInputSigs.ForEach(s => UpdateSig(s));
|
||||
OnOutputChange();
|
||||
}
|
||||
}
|
||||
|
||||
public void LinkInputSig(UShortInputSig sig)
|
||||
{
|
||||
LinkedInputSigs.Add(sig);
|
||||
UpdateSig(sig);
|
||||
}
|
||||
|
||||
public void UnlinkInputSig(UShortInputSig sig)
|
||||
{
|
||||
LinkedInputSigs.Remove(sig);
|
||||
}
|
||||
|
||||
void UpdateSig(UShortInputSig sig)
|
||||
{
|
||||
sig.UShortValue = UShortValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
public class StringFeedback : Feedback
|
||||
{
|
||||
public override string StringValue { get { return _StringValue; } } // ValueFunc.Invoke(); } }
|
||||
string _StringValue;
|
||||
public override eCueType Type { get { return eCueType.String; } }
|
||||
//public string PreviousValue { get; private set; }
|
||||
public Func<string> ValueFunc { get; private set; }
|
||||
List<StringInputSig> LinkedInputSigs = new List<StringInputSig>();
|
||||
|
||||
public StringFeedback(Func<string> valueFunc)
|
||||
: this(Cue.DefaultStringCue, valueFunc)
|
||||
{
|
||||
}
|
||||
|
||||
public StringFeedback(Cue cue, Func<string> valueFunc)
|
||||
: base(cue)
|
||||
{
|
||||
if (cue == null) throw new ArgumentNullException("cue");
|
||||
ValueFunc = valueFunc;
|
||||
|
||||
}
|
||||
|
||||
public override void FireUpdate()
|
||||
{
|
||||
var newValue = ValueFunc.Invoke();
|
||||
if (newValue != _StringValue)
|
||||
{
|
||||
_StringValue = newValue;
|
||||
LinkedInputSigs.ForEach(s => UpdateSig(s));
|
||||
OnOutputChange();
|
||||
}
|
||||
}
|
||||
|
||||
public void LinkInputSig(StringInputSig sig)
|
||||
{
|
||||
LinkedInputSigs.Add(sig);
|
||||
UpdateSig(sig);
|
||||
}
|
||||
|
||||
public void UnlinkInputSig(StringInputSig sig)
|
||||
{
|
||||
LinkedInputSigs.Remove(sig);
|
||||
}
|
||||
|
||||
void UpdateSig(StringInputSig sig)
|
||||
{
|
||||
sig.StringValue = _StringValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharp.CrestronDataStore;
|
||||
using Crestron.SimplSharpPro;
|
||||
|
||||
//using PepperDash.Essentials.Core.Http;
|
||||
using PepperDash.Essentials.License;
|
||||
|
||||
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
public static class Global
|
||||
{
|
||||
public static CrestronControlSystem ControlSystem { get; set; }
|
||||
|
||||
public static LicenseManager LicenseManager { get; set; }
|
||||
|
||||
//public static EssentialsHttpServer HttpConfigServer
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// if (_HttpConfigServer == null)
|
||||
// _HttpConfigServer = new EssentialsHttpServer();
|
||||
// return _HttpConfigServer;
|
||||
// }
|
||||
//}
|
||||
//static EssentialsHttpServer _HttpConfigServer;
|
||||
|
||||
|
||||
static Global()
|
||||
{
|
||||
// Fire up CrestronDataStoreStatic
|
||||
var err = CrestronDataStoreStatic.InitCrestronDataStore();
|
||||
if (err != CrestronDataStore.CDS_ERROR.CDS_SUCCESS)
|
||||
{
|
||||
CrestronConsole.PrintLine("Error starting CrestronDataStoreStatic: {0}", err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -1,8 +0,0 @@
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyTitle("PepperDashEssentialsBase")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("PepperDashEssentialsBase")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||
[assembly: AssemblyVersion("1.0.0.*")]
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
namespace PepperDash.Essentials.Core.Routing
|
||||
{
|
||||
/// <summary>
|
||||
/// These should correspond directly with the portNames var in the config tool.
|
||||
/// </summary>
|
||||
public class RoutingPortNames
|
||||
{
|
||||
public const string AntennaIn = "antennaIn";
|
||||
public const string AnyAudioIn = "anyAudioIn";
|
||||
public const string AnyAudioOut = "anyAudioOut";
|
||||
public const string AnyOut = "anyOut";
|
||||
public const string AnyVideoIn = "anyVideoIn";
|
||||
public const string AnyVideoOut = "anyVideoOut";
|
||||
public const string BalancedAudioOut = "balancedAudioOut";
|
||||
public const string ComponentIn = "componentIn";
|
||||
public const string ComponentOut = "componentOut";
|
||||
public const string CompositeIn = "compositeIn";
|
||||
public const string CompositeOut = "compositeOut";
|
||||
public const string DisplayPortIn = "displayPortIn";
|
||||
public const string DisplayPortIn1 = "displayPortIn1";
|
||||
public const string DisplayPortIn2 = "displayPortIn2";
|
||||
public const string DisplayPortIn3 = "displayPortIn3";
|
||||
public const string DisplayPortOut = "displayPortOut";
|
||||
public const string DmIn = "dmIn";
|
||||
public const string DmOut = "dmOut";
|
||||
public const string DviIn = "dviIn";
|
||||
public const string DviOut = "dviOut";
|
||||
public const string HdmiIn = "hdmiIn";
|
||||
public const string HdmiIn1 = "hdmiIn1";
|
||||
public const string HdmiIn2 = "hdmiIn2";
|
||||
public const string HdmiIn3 = "hdmiIn3";
|
||||
public const string HdmiIn4 = "hdmiIn4";
|
||||
public const string HdmiIn5 = "hdmiIn5";
|
||||
public const string HdmiIn6 = "hdmiIn6";
|
||||
public const string HdmiOut = "hdmiOut";
|
||||
public const string RgbIn = "rgbIn";
|
||||
public const string VgaIn = "vgaIn";
|
||||
public const string VgaOut = "vgaOut";
|
||||
}
|
||||
}
|
||||
@@ -1,161 +0,0 @@
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper class for various Sig events
|
||||
/// </summary>
|
||||
public class SigHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Runs action when Sig is pressed
|
||||
/// </summary>
|
||||
/// <param name="sig"></param>
|
||||
public static void Pressed(Sig sig, Action act) { if (sig.BoolValue) act(); }
|
||||
|
||||
/// <summary>
|
||||
/// Runs action when Sig is released
|
||||
/// </summary>
|
||||
public static void Released(Sig sig, Action act) { if (!sig.BoolValue) act(); }
|
||||
|
||||
/// <summary>
|
||||
/// Safely sets an action to non-null sig
|
||||
/// </summary>
|
||||
public static void SetBoolOutAction(BoolOutputSig sig, Action<bool> a)
|
||||
{
|
||||
if (sig != null)
|
||||
sig.UserObject = a;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Safely clears action of non-null sig.
|
||||
/// </summary>
|
||||
public static void ClearBoolOutAction(BoolOutputSig sig)
|
||||
{
|
||||
if (sig != null)
|
||||
sig.UserObject = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Does a timed ramp, where the time is scaled proportional to the
|
||||
/// remaining range to cover
|
||||
/// </summary>
|
||||
/// <param name="sig">Ushort sig to scale</param>
|
||||
/// <param name="newLevel">Level to go to</param>
|
||||
/// <param name="time">In ms (not hundredths like Crestron Sig ramp function)</param>
|
||||
public static void RampTimeScaled(Sig sig, ushort newLevel, uint time)
|
||||
{
|
||||
ushort level = sig.UShortValue;
|
||||
int diff = Math.Abs(level - newLevel);
|
||||
uint scaledTime = (uint)(diff * time / 65535);
|
||||
Ramp(sig, newLevel, scaledTime);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ramps signal
|
||||
/// </summary>
|
||||
/// <param name="sig"></param>
|
||||
/// <param name="level"></param>
|
||||
/// <param name="time">In ms (not hundredths like Crestron Sig ramp function)</param>
|
||||
public static void Ramp(Sig sig, ushort level, uint time)
|
||||
{
|
||||
sig.CreateRamp(level, time / 10);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attaches to UShortInputSig and does incremental ramping of the signal
|
||||
/// </summary>
|
||||
public class UshortSigIncrementer
|
||||
{
|
||||
UShortInputSig TheSig;
|
||||
public ushort ChangeAmount { get; set; }
|
||||
public int MaxValue { get; set; }
|
||||
public int MinValue { get; set; }
|
||||
public uint RepeatDelay { get; set; }
|
||||
public uint RepeatTime { get; set; }
|
||||
bool SignedMode;
|
||||
CTimer Timer;
|
||||
|
||||
public UshortSigIncrementer(UShortInputSig sig, ushort changeAmount, int minValue, int maxValue, uint repeatDelay, uint repeatTime)
|
||||
{
|
||||
TheSig = sig;
|
||||
ChangeAmount = changeAmount;
|
||||
MaxValue = maxValue;
|
||||
MinValue = minValue;
|
||||
if (MinValue < 0 || MaxValue < 0) SignedMode = true;
|
||||
RepeatDelay = repeatDelay;
|
||||
RepeatTime = repeatTime;
|
||||
if (SignedMode && (MinValue < -32768 || MaxValue > 32767))
|
||||
Debug.Console(1, "UshortSigIncrementer has signed values that exceed range of -32768, 32767");
|
||||
}
|
||||
|
||||
public void StartUp()
|
||||
{
|
||||
if (Timer != null) return;
|
||||
Go(ChangeAmount);
|
||||
}
|
||||
|
||||
public void StartDown()
|
||||
{
|
||||
if (Timer != null) return;
|
||||
Go(-ChangeAmount);
|
||||
}
|
||||
|
||||
void Go(int change)
|
||||
{
|
||||
int level;
|
||||
if (SignedMode) level = TheSig.ShortValue;
|
||||
else level = TheSig.UShortValue;
|
||||
|
||||
// Fire once then pause
|
||||
int newLevel = level + change;
|
||||
bool atLimit = CheckLevel(newLevel, out newLevel);
|
||||
SetValue((ushort)newLevel);
|
||||
|
||||
|
||||
if (atLimit) // Don't go past end
|
||||
Stop();
|
||||
else if (Timer == null) // Only enter the timer if it's not already running
|
||||
Timer = new CTimer(o => { Go(change); }, null, RepeatDelay, RepeatTime);
|
||||
}
|
||||
|
||||
bool CheckLevel(int levelIn, out int levelOut)
|
||||
{
|
||||
bool IsAtLimit = false;
|
||||
if (levelIn > MaxValue)
|
||||
{
|
||||
levelOut = MaxValue;
|
||||
IsAtLimit = true;
|
||||
}
|
||||
else if (levelIn < MinValue)
|
||||
{
|
||||
levelOut = MinValue;
|
||||
IsAtLimit = true;
|
||||
}
|
||||
else
|
||||
levelOut = levelIn;
|
||||
return IsAtLimit;
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
if (Timer != null)
|
||||
Timer.Stop();
|
||||
Timer = null;
|
||||
}
|
||||
|
||||
void SetValue(ushort value)
|
||||
{
|
||||
//CrestronConsole.PrintLine("Increment level:{0} / {1}", value, (short)value);
|
||||
TheSig.UShortValue = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using System.Text;
|
||||
//using Crestron.SimplSharp;
|
||||
//using Crestron.SimplSharpPro;
|
||||
//using Crestron.SimplSharpPro.UI;
|
||||
|
||||
//namespace PepperDash.Essentials.Core
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// Controls the device/tech status list - links in to the first 10, 1, 5 statuses in an item's StatusProperties
|
||||
// /// </summary>
|
||||
// public class DeviceStatusListController : SubpageReferenceListController
|
||||
// {
|
||||
// Dictionary<uint, Device> Items = new Dictionary<uint, Device>();
|
||||
|
||||
// public DeviceStatusListController(SmartObject list)
|
||||
// {
|
||||
// TheList = new SubpageReferenceList(list, 10, 1, 5);
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// Attaches an item's StatusProperties to the list item.
|
||||
// /// THIS METHOD MAY BE BETTER ABSORBED INTO SOME OTHER CONTROLLER CLASS AS A
|
||||
// /// PSIG -> LIST ITEM ADAPTER
|
||||
// /// </summary>
|
||||
// /// <param name="index">List position</param>
|
||||
// /// <param name="device"></param>
|
||||
// public void AddItem(uint listIndex, Device device)
|
||||
// {
|
||||
// if (device == null) throw new ArgumentNullException("device");
|
||||
// Items[listIndex] = device;
|
||||
|
||||
// // Feedback - read the status properties and if there is room for them on the list sigs
|
||||
// // link them up.
|
||||
// //foreach (PValue statusPsig in device.StatusProperties)
|
||||
// //{
|
||||
// // uint num = statusPsig.Number;
|
||||
// // Sig listSig = null;
|
||||
// // switch (statusPsig.Type) // Switch on the PSig type and whether the PSig number is within the increment range
|
||||
// // {
|
||||
// // case eSigType.Bool:
|
||||
// // if (num > TheList.BoolIncrement) return;
|
||||
// // listSig = TheList.BoolInputSig(listIndex, num); // Pull the appropriate list sig.
|
||||
// // break;
|
||||
// // case eSigType.String:
|
||||
// // if (num > TheList.StringIncrement) return;
|
||||
// // listSig = TheList.StringInputSig(listIndex, num);
|
||||
// // break;
|
||||
// // case eSigType.UShort:
|
||||
// // if (num > TheList.UShortIncrement) return;
|
||||
// // listSig = TheList.UShortInputSig(listIndex, num);
|
||||
// // break;
|
||||
// // default:
|
||||
// // return;
|
||||
// // }
|
||||
// // if (listSig != null) // If we got a sig, plug it into the PSig for updates.
|
||||
// // statusPsig.AddLinkedSig(listSig, true);
|
||||
// //}
|
||||
|
||||
// // Press/other handlers - read the Commands and if there is room, add them as Sig handlers.
|
||||
// //foreach (var id in device.Commands.Keys)
|
||||
// //{
|
||||
// // var pValueNumber = id.Number;
|
||||
// // Sig listSig = null;
|
||||
// // // Switch on type of a command and if it's in range, get it's list Sig.
|
||||
// // switch (id.Type)
|
||||
// // {
|
||||
// // case eSigType.Bool:
|
||||
// // if (pValueNumber > TheList.BoolIncrement) return;
|
||||
// // listSig = TheList.BoolFeedbackSig(listIndex, pValueNumber);
|
||||
// // break;
|
||||
// // case eSigType.String:
|
||||
// // if (pValueNumber > TheList.StringIncrement) return;
|
||||
// // listSig = TheList.StringOutputSig(listIndex, pValueNumber);
|
||||
// // break;
|
||||
// // case eSigType.UShort:
|
||||
// // if (pValueNumber > TheList.UShortIncrement) return;
|
||||
// // listSig = TheList.UShortOutputSig(listIndex, pValueNumber);
|
||||
// // break;
|
||||
// // default:
|
||||
// // return;
|
||||
// // }
|
||||
// // if (listSig != null) // If we got a sig, add the command to its ChangeAction
|
||||
// // SigToAction.GetSigToActionUserObjectForSig(listSig).SigChangeAction += device.Commands[id];
|
||||
// // // This will need to be undone when detached MAKE A HELPER!!!!
|
||||
// //}
|
||||
|
||||
// // "Custom things" below
|
||||
// // Set the name on sig 1 - just an assignment. Don't
|
||||
// var nameSig = TheList.StringInputSig(listIndex, 1);
|
||||
// if (nameSig != null)
|
||||
// nameSig.StringValue = device.Key;
|
||||
|
||||
// // Map IsOnline bool to a 0 / 1 state analog icon
|
||||
// // Add an action to the online PValue that maps to a ushort sig on the list POTENTIAL LEAK HERE IF
|
||||
// // this isn't cleaned up on disconnect
|
||||
// var onlineSig = TheList.UShortInputSig(listIndex, 1);
|
||||
// //var onlinePValue = device.StatusProperties[Device.JoinIsOnline];
|
||||
// //if (onlineSig != null && onlinePValue != null)
|
||||
// // onlinePValue.AddChangeAction(pv => onlineSig.UShortValue = (ushort)(onlinePValue.BoolValue ? 1 : 0));
|
||||
// // //OR onlinePValue.AddLinkedSig(onlineSig, true);
|
||||
|
||||
// // Set the list length based on largest key
|
||||
// TheList.Count = (ushort)Items.Keys.DefaultIfEmpty().Max(); // The count will be the largest key or 0
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
//}
|
||||
@@ -1,112 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Extensions used for more-clear attachment of Actions to user objects on sigs
|
||||
/// </summary>
|
||||
public static class SigAndTriListExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Attaches Action to Sig's user object and returns the same Sig.
|
||||
/// </summary>
|
||||
/// <param name="sig">The BoolOutputSig to attach the Action to</param>
|
||||
/// <param name="a">An action to run when sig is pressed and when released</param>
|
||||
/// <returns>The Sig, sig</returns>
|
||||
public static BoolOutputSig SetBoolSigAction(this BoolOutputSig sig, Action<bool> a)
|
||||
{
|
||||
sig.UserObject = a;
|
||||
return sig;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attaches Action to Sig's user object and returns the same Sig.
|
||||
/// </summary>
|
||||
/// <param name="tl"></param>
|
||||
/// <param name="sigNum"></param>
|
||||
/// <param name="a"></param>
|
||||
/// <returns></returns>
|
||||
public static BoolOutputSig SetBoolSigAction(this BasicTriList tl, uint sigNum, Action<bool> a)
|
||||
{
|
||||
return tl.BooleanOutput[sigNum].SetBoolSigAction(a);
|
||||
}
|
||||
|
||||
public static BoolOutputSig SetSigTrueAction(this BasicTriList tl, uint sigNum, Action a)
|
||||
{
|
||||
return tl.BooleanOutput[sigNum].SetBoolSigAction(b => { if(b) a(); });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attaches a void Action to a TriList's output sig's UserObject, to be run on release
|
||||
/// </summary>
|
||||
/// <returns>The sig</returns>
|
||||
public static BoolOutputSig SetSigFalseAction(this BasicTriList tl, uint sigNum, Action a)
|
||||
{
|
||||
return tl.BooleanOutput[sigNum].SetBoolSigAction(b => { if (!b) a(); });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attaches a void Action to an output sig's UserObject, to be run on release
|
||||
/// </summary>
|
||||
/// <returns>The Sig</returns>
|
||||
public static BoolOutputSig SetSigFalseAction(this BoolOutputSig sig, Action a)
|
||||
{
|
||||
return sig.SetBoolSigAction(b => { if (!b) a(); });
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sig"></param>
|
||||
/// <param name="a"></param>
|
||||
/// <returns>The Sig</returns>
|
||||
public static UShortOutputSig SetUShortSigAction(this UShortOutputSig sig, Action<ushort> a)
|
||||
{
|
||||
sig.UserObject = a;
|
||||
return sig;
|
||||
}
|
||||
|
||||
public static UShortOutputSig SetUShortSigAction(this BasicTriList tl, uint sigNum, Action<ushort> a)
|
||||
{
|
||||
return tl.UShortOutput[sigNum].SetUShortSigAction(a);
|
||||
}
|
||||
|
||||
public static StringOutputSig SetStringSigAction(this StringOutputSig sig, Action<string> a)
|
||||
{
|
||||
sig.UserObject = a;
|
||||
return sig;
|
||||
}
|
||||
|
||||
public static StringOutputSig SetStringSigAction(this BasicTriList tl, uint sigNum, Action<string> a)
|
||||
{
|
||||
return tl.SetStringSigAction(sigNum, a);
|
||||
}
|
||||
|
||||
public static Sig ClearSigAction(this Sig sig)
|
||||
{
|
||||
sig.UserObject = null;
|
||||
return sig;
|
||||
}
|
||||
|
||||
public static BoolOutputSig ClearBoolSigAction(this BasicTriList tl, uint sigNum)
|
||||
{
|
||||
return ClearSigAction(tl.BooleanOutput[sigNum]) as BoolOutputSig;
|
||||
}
|
||||
|
||||
public static UShortOutputSig ClearUShortSigAction(this BasicTriList tl, uint sigNum)
|
||||
{
|
||||
return ClearSigAction(tl.UShortOutput[sigNum]) as UShortOutputSig;
|
||||
}
|
||||
|
||||
public static StringOutputSig ClearStringSigAction(this BasicTriList tl, uint sigNum)
|
||||
{
|
||||
return ClearSigAction(tl.StringOutput[sigNum]) as StringOutputSig;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,569 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.DM;
|
||||
using Crestron.SimplSharpPro.DM.Cards;
|
||||
using Crestron.SimplSharpPro.DM.Endpoints;
|
||||
using Crestron.SimplSharpPro.DM.Endpoints.Receivers;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.DM.Cards;
|
||||
|
||||
using PepperDash.Essentials.DM.Config;
|
||||
|
||||
namespace PepperDash.Essentials.DM
|
||||
{
|
||||
/// <summary>
|
||||
/// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions
|
||||
///
|
||||
/// </summary>
|
||||
public class DmChassisController : CrestronGenericBaseDevice, IRoutingInputsOutputs, IRouting//, ICardPortsDevice
|
||||
{
|
||||
public DmMDMnxn Chassis { get; private set; }
|
||||
|
||||
// Need a couple Lists of generic Backplane ports
|
||||
public RoutingPortCollection<RoutingInputPort> InputPorts { get; private set; }
|
||||
public RoutingPortCollection<RoutingOutputPort> OutputPorts { get; private set; }
|
||||
|
||||
//public Dictionary<uint, DmInputCardControllerBase> InputCards { get; private set; }
|
||||
//public Dictionary<uint, DmSingleOutputCardControllerBase> OutputCards { get; private set; }
|
||||
|
||||
public Dictionary<uint, string> InputNames { get; set; }
|
||||
public Dictionary<uint, string> OutputNames { get; set; }
|
||||
public Dictionary<uint, DmCardAudioOutputController> VolumeControls { get; private set; }
|
||||
|
||||
public const int RouteOffTime = 500;
|
||||
Dictionary<PortNumberType, CTimer> RouteOffTimers = new Dictionary<PortNumberType, CTimer>();
|
||||
|
||||
/// <summary>
|
||||
/// Factory method to create a new chassis controller from config data. Limited to 8x8 right now
|
||||
/// </summary>
|
||||
public static DmChassisController GetDmChassisController(string key, string name,
|
||||
string type, DMChassisPropertiesConfig properties)
|
||||
{
|
||||
try
|
||||
{
|
||||
type = type.ToLower();
|
||||
uint ipid = properties.Control.IpIdInt; // Convert.ToUInt16(properties.Id, 16);
|
||||
DmChassisController controller = null;
|
||||
if (type == "dmmd8x8")
|
||||
{
|
||||
controller = new DmChassisController(key, name, new DmMd8x8(ipid, Global.ControlSystem));
|
||||
// add the cards and port names
|
||||
foreach (var kvp in properties.InputSlots)
|
||||
controller.AddInputCard(kvp.Value, kvp.Key);
|
||||
foreach (var kvp in properties.OutputSlots)
|
||||
controller.AddOutputCard(kvp.Value, kvp.Key);
|
||||
foreach (var kvp in properties.VolumeControls)
|
||||
{
|
||||
// get the card
|
||||
// check it for an audio-compatible type
|
||||
// make a something-something that will make it work
|
||||
// retire to mountain village
|
||||
var outNum = kvp.Key;
|
||||
var card = controller.Chassis.Outputs[outNum].Card;
|
||||
Audio.Output audio = null;
|
||||
if (card is DmcHdo)
|
||||
audio = (card as DmcHdo).Audio;
|
||||
else if (card is Dmc4kHdo)
|
||||
audio = (card as Dmc4kHdo).Audio;
|
||||
if (audio == null)
|
||||
continue;
|
||||
// wire up the audio to something here...
|
||||
controller.AddVolumeControl(outNum, audio);
|
||||
}
|
||||
|
||||
controller.InputNames = properties.InputNames;
|
||||
controller.OutputNames = properties.OutputNames;
|
||||
return controller;
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.Console(0, "Error creating DM chassis:\r{0}", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="chassis"></param>
|
||||
public DmChassisController(string key, string name, DmMDMnxn chassis)
|
||||
: base(key, name, chassis)
|
||||
{
|
||||
Chassis = chassis;
|
||||
InputPorts = new RoutingPortCollection<RoutingInputPort>();
|
||||
OutputPorts = new RoutingPortCollection<RoutingOutputPort>();
|
||||
VolumeControls = new Dictionary<uint, DmCardAudioOutputController>();
|
||||
IsOnline.OutputChange += new EventHandler<EventArgs>(IsOnline_OutputChange);
|
||||
Chassis.DMOutputChange += new DMOutputEventHandler(Chassis_DMOutputChange);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="number"></param>
|
||||
public void AddInputCard(string type, uint number)
|
||||
{
|
||||
Debug.Console(2, this, "Adding input card '{0}', slot {1}", type, number);
|
||||
if (type == "dmc4kHd")
|
||||
{
|
||||
new Dmc4kHd(number, this.Chassis);
|
||||
AddHdmiInCardPorts(number);
|
||||
}
|
||||
else if (type == "dmc4kHdDsp")
|
||||
{
|
||||
new Dmc4kHdDsp(number, this.Chassis);
|
||||
AddHdmiInCardPorts(number);
|
||||
}
|
||||
else if (type == "dmc4kC")
|
||||
{
|
||||
new Dmc4kC(number, this.Chassis);
|
||||
AddDmInCardPorts(number);
|
||||
}
|
||||
else if (type == "dmc4kCDsp")
|
||||
{
|
||||
new Dmc4kCDsp(number, this.Chassis);
|
||||
AddDmInCardPorts(number);
|
||||
}
|
||||
else if (type == "dmcHd")
|
||||
{
|
||||
new DmcHd(number, this.Chassis);
|
||||
AddHdmiInCardPorts(number);
|
||||
}
|
||||
else if (type == "dmcHdDsp")
|
||||
{
|
||||
new DmcHdDsp(number, this.Chassis);
|
||||
AddHdmiInCardPorts(number);
|
||||
}
|
||||
|
||||
else if (type == "dmcC")
|
||||
{
|
||||
new DmcC(number, this.Chassis);
|
||||
AddDmInCardPorts(number);
|
||||
}
|
||||
else if (type == "dmcCDsp")
|
||||
{
|
||||
new DmcCDsp(number, this.Chassis);
|
||||
AddDmInCardPorts(number);
|
||||
}
|
||||
else if (type == "dmcS")
|
||||
{
|
||||
new DmcS(number, Chassis);
|
||||
AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.DmMmFiber);
|
||||
AddInCardLoopPorts(number);
|
||||
}
|
||||
else if (type == "dmcSDsp")
|
||||
{
|
||||
new DmcSDsp(number, Chassis);
|
||||
AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.DmMmFiber);
|
||||
AddInCardLoopPorts(number);
|
||||
}
|
||||
else if (type == "dmcS2")
|
||||
{
|
||||
new DmcS2(number, Chassis);
|
||||
AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.DmSmFiber);
|
||||
AddInCardLoopPorts(number);
|
||||
}
|
||||
else if (type == "dmcS2Dsp")
|
||||
{
|
||||
new DmcS2Dsp(number, Chassis);
|
||||
AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.DmSmFiber);
|
||||
AddInCardLoopPorts(number);
|
||||
}
|
||||
else if (type == "dmcSdi")
|
||||
{
|
||||
new DmcSdi(number, Chassis);
|
||||
AddInputPortWithDebug(number, "sdiIn", eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Sdi);
|
||||
AddOutputPortWithDebug(number, "sdiOut", eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Sdi, null);
|
||||
AddInCardLoopPorts(number);
|
||||
}
|
||||
}
|
||||
|
||||
void AddDmInCardPorts(uint number)
|
||||
{
|
||||
AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.DmCat);
|
||||
AddInCardLoopPorts(number);
|
||||
}
|
||||
|
||||
void AddHdmiInCardPorts(uint number)
|
||||
{
|
||||
AddInputPortWithDebug(number, "hdmiIn", eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi);
|
||||
AddInCardLoopPorts(number);
|
||||
}
|
||||
|
||||
void AddInCardLoopPorts(uint number)
|
||||
{
|
||||
AddOutputPortWithDebug(number, "hdmiLoopOut", eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, null);
|
||||
AddOutputPortWithDebug(number, "audioLoopOut", eRoutingSignalType.Audio, eRoutingPortConnectionType.Hdmi, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="number"></param>
|
||||
public void AddOutputCard(string type, uint number)
|
||||
{
|
||||
Debug.Console(2, this, "Adding output card '{0}', slot {1}", type, number);
|
||||
if (type == "dmc4kHdo")
|
||||
{
|
||||
new Dmc4kHdoSingle(number, Chassis);
|
||||
AddDmcHdoPorts(number);
|
||||
}
|
||||
else if (type == "dmcHdo")
|
||||
{
|
||||
new DmcHdoSingle(number, Chassis);
|
||||
AddDmcHdoPorts(number);
|
||||
}
|
||||
else if (type == "dmc4kCoHd")
|
||||
{
|
||||
new Dmc4kCoHdSingle(number, Chassis);
|
||||
AddDmcCoPorts(number);
|
||||
}
|
||||
else if (type == "dmcCoHd")
|
||||
{
|
||||
new DmcCoHdSingle(number, Chassis);
|
||||
AddDmcCoPorts(number);
|
||||
}
|
||||
else if (type == "dmcSoHd")
|
||||
{
|
||||
new DmcSoHdSingle(number, Chassis);
|
||||
AddOutputPortWithDebug(number, "dmOut1", eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.DmMmFiber, 2 * (number - 1) + 1);
|
||||
AddOutputPortWithDebug(number, "hdmiOut1", eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, 2 * (number - 1) + 1);
|
||||
AddOutputPortWithDebug(number, "dmOut2", eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.DmMmFiber, 2 * (number - 1) + 2);
|
||||
|
||||
}
|
||||
else if (type == "dmcS2oHd")
|
||||
{
|
||||
new DmcS2oHdSingle(number, Chassis);
|
||||
AddOutputPortWithDebug(number, "dmOut1", eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.DmSmFiber, 2 * (number - 1) + 1);
|
||||
AddOutputPortWithDebug(number, "hdmiOut1", eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, 2 * (number - 1) + 1);
|
||||
AddOutputPortWithDebug(number, "dmOut2", eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.DmSmFiber, 2 * (number - 1) + 2);
|
||||
}
|
||||
|
||||
else
|
||||
Debug.Console(1, this, " WARNING: Output card type '{0}' is not available", type);
|
||||
}
|
||||
|
||||
void AddDmcHdoPorts(uint number)
|
||||
{
|
||||
AddOutputPortWithDebug(number, "hdmiOut1", eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, 2 * (number - 1) + 1);
|
||||
AddOutputPortWithDebug(number, "audioOut1", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio, 2 * (number - 1) + 1);
|
||||
AddOutputPortWithDebug(number, "hdmiOut2", eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, 2 * (number - 1) + 2);
|
||||
AddOutputPortWithDebug(number, "audioOut2", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio, 2 * (number - 1) + 2);
|
||||
|
||||
}
|
||||
|
||||
void AddDmcCoPorts(uint number)
|
||||
{
|
||||
AddOutputPortWithDebug(number, "dmOut1", eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.DmCat, 2 * (number - 1) + 1);
|
||||
AddOutputPortWithDebug(number, "hdmiOut1", eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, 2 * (number - 1) + 1);
|
||||
AddOutputPortWithDebug(number, "dmOut2", eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.DmCat, 2 * (number - 1) + 2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
void AddInputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType)
|
||||
{
|
||||
Debug.Console(2, this, " Adding input port '{0}'", portName);
|
||||
InputPorts.Add(new RoutingInputPort(string.Format("card{0}--{1}", cardNum, portName),
|
||||
sigType, portType, cardNum, this));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
void AddOutputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, object selector)
|
||||
{
|
||||
Debug.Console(2, this, " Adding output port '{0}'", portName);
|
||||
OutputPorts.Add(new RoutingOutputPort(string.Format("card{0}--{1}", cardNum, portName),
|
||||
sigType, portType, selector, this));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
void AddVolumeControl(uint number, Audio.Output audio)
|
||||
{
|
||||
VolumeControls.Add(number, new DmCardAudioOutputController(audio));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
void Chassis_DMOutputChange(Switch device, DMOutputEventArgs args)
|
||||
{
|
||||
if (args.EventId == DMOutputEventIds.VolumeEventId &&
|
||||
VolumeControls.ContainsKey(args.Number))
|
||||
VolumeControls[args.Number].VolumeEventFromChassis();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="pnt"></param>
|
||||
void StartOffTimer(PortNumberType pnt)
|
||||
{
|
||||
if (RouteOffTimers.ContainsKey(pnt))
|
||||
return;
|
||||
RouteOffTimers[pnt] = new CTimer(o =>
|
||||
{
|
||||
ExecuteSwitch(0, pnt.Number, pnt.Type);
|
||||
}, RouteOffTime);
|
||||
}
|
||||
|
||||
// Send out sigs when coming online
|
||||
void IsOnline_OutputChange(object sender, EventArgs e)
|
||||
{
|
||||
if (IsOnline.BoolValue)
|
||||
{
|
||||
if (InputNames != null)
|
||||
foreach (var kvp in InputNames)
|
||||
Chassis.Inputs[kvp.Key].Name.StringValue = kvp.Value;
|
||||
if (OutputNames != null)
|
||||
foreach(var kvp in OutputNames)
|
||||
Chassis.Outputs[kvp.Key].Name.StringValue = kvp.Value;
|
||||
}
|
||||
}
|
||||
|
||||
#region IRouting Members
|
||||
|
||||
public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType sigType)
|
||||
{
|
||||
Debug.Console(0, this, "Making an awesome DM route from {0} to {1} {2}", inputSelector, outputSelector, sigType);
|
||||
|
||||
var input = Convert.ToUInt32(inputSelector); // Cast can sometimes fail
|
||||
var output = Convert.ToUInt32(outputSelector);
|
||||
// Check to see if there's an off timer waiting on this and if so, cancel
|
||||
var key = new PortNumberType(output, sigType);
|
||||
if (input == 0)
|
||||
{
|
||||
StartOffTimer(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(RouteOffTimers.ContainsKey(key))
|
||||
{
|
||||
Debug.Console(2, this, "{0} cancelling route off due to new source", output);
|
||||
RouteOffTimers[key].Stop();
|
||||
RouteOffTimers.Remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
Card.DMICard inCard = input == 0 ? null : Chassis.Inputs[input];
|
||||
|
||||
// NOTE THAT THESE ARE NOTS - TO CATCH THE AudioVideo TYPE
|
||||
if (sigType != eRoutingSignalType.Audio)
|
||||
{
|
||||
Chassis.VideoEnter.BoolValue = true;
|
||||
Chassis.Outputs[output].VideoOut = inCard;
|
||||
}
|
||||
|
||||
if (sigType != eRoutingSignalType.Video)
|
||||
{
|
||||
Chassis.AudioEnter.BoolValue = true;
|
||||
Chassis.Outputs[output].AudioOut = inCard;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
// void AddInUseTrackerToPort(RoutingOutputPort port, eRoutingSignalType sigType)
|
||||
// {
|
||||
// port.InUseTracker.InUseFeedback.OutputChange += (o, a) =>
|
||||
// {
|
||||
//#warning Can we add something here that will de-route based on breakaway, or does it even matter?
|
||||
// if (!port.InUseTracker.InUseFeedback.BoolValue)
|
||||
// this.ExecuteSwitch(0, port.Selector, sigType);
|
||||
// };
|
||||
// }
|
||||
|
||||
|
||||
//[Obsolete]
|
||||
//public void AddInputCard(uint slot, eDmInputCardType type)
|
||||
//{
|
||||
// var cardKey = Key + "-inputCard" + slot;
|
||||
// switch (type)
|
||||
// {
|
||||
// case eDmInputCardType.Dmc4kHd:
|
||||
// InputCards[slot] = new Dmc4kHdController(cardKey,
|
||||
// new Dmc4kHd(slot, this.Chassis), slot);
|
||||
// break;
|
||||
// case eDmInputCardType.Dmc4kHdDsp:
|
||||
// InputCards[slot] = new Dmc4kHdDspController(cardKey,
|
||||
// new Dmc4kHdDsp(slot, this.Chassis), slot);
|
||||
// break;
|
||||
// case eDmInputCardType.Dmc4kC:
|
||||
// InputCards[slot] = new Dmc4kCController(cardKey,
|
||||
// new Dmc4kC(slot, this.Chassis), slot);
|
||||
// break;
|
||||
// case eDmInputCardType.Dmc4kCDsp:
|
||||
// InputCards[slot] = new Dmc4kCDspController(cardKey,
|
||||
// new Dmc4kCDsp(slot, this.Chassis), slot);
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
|
||||
//[Obsolete]
|
||||
//public void AddOutputCard(uint cardSlot, eDmOutputCardType type)
|
||||
//{
|
||||
// var cardKey = Key + "-outputCard" + cardSlot;
|
||||
// switch (type)
|
||||
// {
|
||||
// case eDmOutputCardType.Dmc4kCoHd:
|
||||
// OutputCards[cardSlot] = new Dmc4kCoHdSingleOutputCard(cardKey,
|
||||
// new Dmc4kCoHdSingle(cardSlot, this.Chassis), cardSlot);
|
||||
// break;
|
||||
// case eDmOutputCardType.DmcCoHd:
|
||||
// OutputCards[cardSlot] = new Dmc4kHdoSingleOutputCard(cardKey,
|
||||
// new Dmc4kHdoSingle(cardSlot, this.Chassis), cardSlot);
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// Helper to get a specific port from a given attached card
|
||||
///// </summary>
|
||||
///// <param name="card">Named 'input-N' ('output-N' is not valid, as output cards have no inputs)</param>
|
||||
///// <param name="port">The port name on the card, for example 'hdmiOut'</param>
|
||||
///// <returns>Returns port or null if doesn't exist</returns>
|
||||
//public RoutingInputPort GetChildInputPort(string card, string port)
|
||||
//{
|
||||
// return GetChildPort(card, port, false) as RoutingInputPort;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// Helper to get a specific port from a given attached card
|
||||
///// </summary>
|
||||
///// <param name="card">Named 'input-N' or 'output-N'</param>
|
||||
///// <param name="port">The port name on the card, for example 'hdmiOut'</param>
|
||||
///// <returns>Returns port or null if doesn't exist</returns>
|
||||
//public RoutingOutputPort GetChildOutputPort(string card, string port)
|
||||
//{
|
||||
// return GetChildPort(card, port, true) as RoutingOutputPort;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// Helper for above methods
|
||||
///// </summary>
|
||||
//RoutingPort GetChildPort(string cardKey, string portKey, bool portIsOutput)
|
||||
//{
|
||||
// var cardTokens = cardKey.Split('-');
|
||||
// if (cardTokens.Length != 2)
|
||||
// {
|
||||
// Debug.Console(0, this, "WARNING: GetChildPort cannot get port. Card parameter must be 'input-N' or 'output-N'");
|
||||
// return null;
|
||||
// }
|
||||
// try
|
||||
// {
|
||||
// uint slotNum = Convert.ToUInt32(cardTokens[1]);
|
||||
// var cardType = cardTokens[0].ToLower();
|
||||
// if (cardType == "input" && InputCards.ContainsKey(slotNum))
|
||||
// {
|
||||
// var card = InputCards[slotNum];
|
||||
// if (portIsOutput)
|
||||
// return card.GetOutputPort(portKey);
|
||||
// else
|
||||
// return card.GetInputPort(portKey);
|
||||
// }
|
||||
// if (cardType == "output" && OutputCards.ContainsKey(slotNum))
|
||||
// {
|
||||
// var card = OutputCards[slotNum];
|
||||
// return card.GetOutputPort(portKey);
|
||||
// }
|
||||
// }
|
||||
// catch (Exception)
|
||||
// {
|
||||
// Debug.Console(0, this, "WARNING: GetChildPort cannot get port. Only integer card numbers are valid.");
|
||||
// }
|
||||
// return null;
|
||||
//}
|
||||
|
||||
//public override bool CustomActivate()
|
||||
//{
|
||||
// var tlc = TieLineCollection.Default;
|
||||
// // Take all cards and TieLine them together with the internal ports
|
||||
// for (uint i = 1; i <= Chassis.NumberOfInputs; i++)
|
||||
// {
|
||||
// // If there's a matching input card for a given input number...
|
||||
// // This test *shouldn't* be necessary if data is consistent
|
||||
// if (InputCards.ContainsKey(i))
|
||||
// {
|
||||
// // Get the ports to link
|
||||
// var cardAudio = InputCards[i].BackplaneAudioOut;
|
||||
// var chassisAudio = InputPorts.FirstOrDefault(p =>
|
||||
// (uint)p.Selector == i && p.Type == eRoutingSignalType.Audio);
|
||||
// if (chassisAudio != null)
|
||||
// tlc.Add(new TieLine(cardAudio, chassisAudio));
|
||||
// else
|
||||
// Debug.Console(0, this, Debug.ErrorLogLevel.Warning,
|
||||
// "Backplane audio tie line creation for input card {0} failed", i);
|
||||
|
||||
// // Repeat for video link
|
||||
// var cardVideo = InputCards[i].BackplaneVideoOut;
|
||||
// var chassisVideo = InputPorts.FirstOrDefault(p =>
|
||||
// (uint)p.Selector == i && p.Type == eRoutingSignalType.Video);
|
||||
// if (cardVideo != null)
|
||||
// tlc.Add(new TieLine(cardVideo, chassisVideo));
|
||||
// else
|
||||
// Debug.Console(0, this, Debug.ErrorLogLevel.Warning,
|
||||
// "Backplane video tie line creation for input card {0} failed", i);
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Loop through outputs and do it again - in pairs, because FYC
|
||||
// for (uint i = 1; i <= Chassis.NumberOfOutputs / 2; i += 1)
|
||||
// {
|
||||
// if (OutputCards.ContainsKey(i))
|
||||
// {
|
||||
// //Debug.Console(0, this, "Adding internal TieLines on output card {0}", OutputCards[i].Key);
|
||||
// // Left side of card
|
||||
// uint a = i * 2 - 1;
|
||||
// tlc.Add(new TieLine(
|
||||
// OutputPorts.First(p => (uint)p.Selector == a && p.Type == eRoutingSignalType.Audio),
|
||||
// OutputCards[i].BackplaneAudioIn1));
|
||||
// tlc.Add(new TieLine(
|
||||
// OutputPorts.First(p => (uint)p.Selector == a && p.Type == eRoutingSignalType.Video),
|
||||
// OutputCards[i].BackplaneVideoIn1));
|
||||
|
||||
// // Right side of card
|
||||
// uint b = i * 2;
|
||||
// tlc.Add(new TieLine(
|
||||
// OutputPorts.First(p => (uint)p.Selector == b && p.Type == eRoutingSignalType.Audio),
|
||||
// OutputCards[i].BackplaneAudioIn2));
|
||||
// tlc.Add(new TieLine(
|
||||
// OutputPorts.First(p => (uint)p.Selector == b && p.Type == eRoutingSignalType.Video),
|
||||
// OutputCards[i].BackplaneVideoIn2));
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Base does register and sets up comm monitoring.
|
||||
// return base.CustomActivate();
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
public struct PortNumberType
|
||||
{
|
||||
public uint Number { get; private set; }
|
||||
public eRoutingSignalType Type { get; private set; }
|
||||
|
||||
public PortNumberType(uint number, eRoutingSignalType type) : this()
|
||||
{
|
||||
Number = number;
|
||||
Type = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.DM;
|
||||
using Crestron.SimplSharpPro.DM.Endpoints;
|
||||
using Crestron.SimplSharpPro.DM.Endpoints.Receivers;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.DM.Config;
|
||||
|
||||
namespace PepperDash.Essentials.DM
|
||||
{
|
||||
public abstract class DmRmcControllerBase : CrestronGenericBaseDevice
|
||||
{
|
||||
public DmRmcControllerBase(string key, string name, EndpointReceiverBase device)
|
||||
: base(key, name, device)
|
||||
{ }
|
||||
}
|
||||
|
||||
public class DmRmcHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// A factory method for various DmTxControllers
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="props"></param>
|
||||
/// <returns></returns>
|
||||
public static DmRmcControllerBase GetDmRmcController(string key, string name, string typeName, DmRmcPropertiesConfig props)
|
||||
{
|
||||
// switch on type name... later...
|
||||
|
||||
typeName = typeName.ToLower();
|
||||
uint ipid = props.Control.IpIdInt; // Convert.ToUInt16(props.Id, 16);
|
||||
|
||||
|
||||
|
||||
// right here, we need to grab the tie line that associates this
|
||||
// RMC with a chassis or processor. If the RMC input's tie line is not
|
||||
// connected to a chassis, then it's parent is the processor.
|
||||
// If the RMC is connected to a chassis, then we need to grab the
|
||||
// output number from the tie line and use that to plug it in.
|
||||
// Example of chassis-connected:
|
||||
//{
|
||||
// "sourceKey": "dmMd8x8-1",
|
||||
// "sourcePort": "anyOut2",
|
||||
// "destinationKey": "dmRmc100C-2",
|
||||
// "destinationPort": "DmIn"
|
||||
//}
|
||||
|
||||
// Tx -> RMC link:
|
||||
//{
|
||||
// "sourceKey": "dmTx201C-1",
|
||||
// "sourcePort": "DmOut",
|
||||
// "destinationKey": "dmRmc100C-2",
|
||||
// "destinationPort": "DmIn"
|
||||
//}
|
||||
|
||||
var tlc = TieLineCollection.Default;
|
||||
// grab the tie line that has this key as
|
||||
// THIS DOESN'T WORK BECAUSE THE RMC THAT WE NEED (THIS) HASN'T BEEN MADE
|
||||
// YET AND THUS WILL NOT HAVE A TIE LINE...
|
||||
var inputTieLine = tlc.FirstOrDefault(t =>
|
||||
{
|
||||
var d = t.DestinationPort.ParentDevice;
|
||||
return d.Key.Equals(key, StringComparison.OrdinalIgnoreCase)
|
||||
&& d is DmChassisController;
|
||||
});
|
||||
|
||||
var pKey = props.ParentDeviceKey.ToLower();
|
||||
|
||||
|
||||
|
||||
|
||||
// Non-DM-chassis endpoints
|
||||
if (pKey == "processor")
|
||||
{
|
||||
// Catch constructor failures, mainly dues to IPID
|
||||
try
|
||||
{
|
||||
if (typeName.StartsWith("dmrmc100c"))
|
||||
return new DmRmc100CController(key, name, new DmRmc100C(ipid, Global.ControlSystem));
|
||||
if (typeName.StartsWith("dmrmcscalerc"))
|
||||
return new DmRmcScalerCController(key, name, new DmRmcScalerC(ipid, Global.ControlSystem));
|
||||
if (typeName.StartsWith("dmrmc4kscalerc"))
|
||||
return new DmRmc4kScalerCController(key, name, new DmRmc4kScalerC(ipid, Global.ControlSystem));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(0, "[{0}] WARNING: Cannot create DM-RMC device: {1}", key, e.Message);
|
||||
}
|
||||
|
||||
|
||||
Debug.Console(0, "Cannot create DM-RMC of type: '{0}'", typeName);
|
||||
}
|
||||
// Endpoints attached to DM Chassis
|
||||
else
|
||||
{
|
||||
var parentDev = DeviceManager.GetDeviceForKey(pKey);
|
||||
if (!(parentDev is DmChassisController))
|
||||
{
|
||||
Debug.Console(0, "Cannot create DM device '{0}'. '{1}' is not a DM Chassis.",
|
||||
key, pKey);
|
||||
return null;
|
||||
}
|
||||
|
||||
var chassis = (parentDev as DmChassisController).Chassis;
|
||||
var num = props.ParentOutputNumber;
|
||||
if (num <= 0 || num > chassis.NumberOfOutputs)
|
||||
{
|
||||
Debug.Console(0, "Cannot create DM device '{0}'. Output number '{1}' is out of range",
|
||||
key, num);
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (typeName.StartsWith("dmrmc100c"))
|
||||
return new DmRmc100CController(key, name, new DmRmc100C(ipid, chassis.Outputs[num]));
|
||||
if (typeName.StartsWith("dmrmcscalerc"))
|
||||
return new DmRmcScalerCController(key, name, new DmRmcScalerC(ipid, chassis.Outputs[num]));
|
||||
if (typeName.StartsWith("dmrmc4kscalerc"))
|
||||
return new DmRmc4kScalerCController(key, name, new DmRmc4kScalerC(ipid, chassis.Outputs[num]));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(0, "[{0}] WARNING: Cannot create DM-RMC device: {1}", key, e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.DM;
|
||||
using Crestron.SimplSharpPro.DM.Endpoints;
|
||||
using Crestron.SimplSharpPro.DM.Endpoints.Receivers;
|
||||
|
||||
using PepperDash.Essentials.Core;
|
||||
|
||||
namespace PepperDash.Essentials.DM
|
||||
{
|
||||
/// <summary>
|
||||
/// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions
|
||||
///
|
||||
/// </summary>
|
||||
public class DmRmcScalerCController : DmRmcControllerBase, IRoutingInputsOutputs,
|
||||
IIROutputPorts, IComPorts, ICec
|
||||
{
|
||||
public DmRmcScalerC Rmc { get; private set; }
|
||||
|
||||
public RoutingInputPort DmIn { get; private set; }
|
||||
public RoutingOutputPort HdmiOut { get; private set; }
|
||||
|
||||
public RoutingPortCollection<RoutingInputPort> InputPorts
|
||||
{
|
||||
get { return new RoutingPortCollection<RoutingInputPort> { DmIn }; }
|
||||
}
|
||||
|
||||
public RoutingPortCollection<RoutingOutputPort> OutputPorts
|
||||
{
|
||||
get { return new RoutingPortCollection<RoutingOutputPort> { HdmiOut }; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Make a Crestron RMC and put it in here
|
||||
/// </summary>
|
||||
public DmRmcScalerCController(string key, string name, DmRmcScalerC rmc)
|
||||
: base(key, name, rmc)
|
||||
{
|
||||
Rmc = rmc;
|
||||
DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo,
|
||||
eRoutingPortConnectionType.DmCat, 0, this);
|
||||
HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo,
|
||||
eRoutingPortConnectionType.Hdmi, null, this);
|
||||
}
|
||||
|
||||
public override bool CustomActivate()
|
||||
{
|
||||
// Base does register and sets up comm monitoring.
|
||||
return base.CustomActivate();
|
||||
}
|
||||
|
||||
#region IIROutputPorts Members
|
||||
public CrestronCollection<IROutputPort> IROutputPorts { get { return Rmc.IROutputPorts; } }
|
||||
public int NumberOfIROutputPorts { get { return Rmc.NumberOfIROutputPorts; } }
|
||||
#endregion
|
||||
|
||||
#region IComPorts Members
|
||||
public CrestronCollection<ComPort> ComPorts { get { return Rmc.ComPorts; } }
|
||||
public int NumberOfComPorts { get { return Rmc.NumberOfComPorts; } }
|
||||
#endregion
|
||||
|
||||
#region ICec Members
|
||||
/// <summary>
|
||||
/// Gets the CEC stream directly from the HDMI port.
|
||||
/// </summary>
|
||||
public Cec StreamCec { get { return Rmc.HdmiOutput.StreamCec; } }
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,196 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.DM;
|
||||
using Crestron.SimplSharpPro.DM.Endpoints;
|
||||
using Crestron.SimplSharpPro.DM.Endpoints.Transmitters;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.DM.Config;
|
||||
|
||||
namespace PepperDash.Essentials.DM
|
||||
{
|
||||
public class DmTx201SBasicController : DmTxControllerBase, IRoutingInputsOutputs, IHasFeedback
|
||||
{
|
||||
public DmTx201S Tx { get; private set; }
|
||||
|
||||
public RoutingInputPortWithVideoStatuses AnyVideoInput { get; private set; }
|
||||
public RoutingInputPortWithVideoStatuses HdmiInput { get; private set; }
|
||||
public RoutingInputPortWithVideoStatuses VgaInput { get; private set; }
|
||||
public RoutingOutputPort DmOutput { get; private set; }
|
||||
public StringFeedback ActiveVideoInputFeedback { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Helps get the "real" inputs, including when in Auto
|
||||
/// </summary>
|
||||
public DmTx200Base.eSourceSelection ActualVideoInput
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Digital ||
|
||||
Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Analog ||
|
||||
Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Disable)
|
||||
return Tx.VideoSourceFeedback;
|
||||
else // auto
|
||||
{
|
||||
if (Tx.HdmiInput.SyncDetectedFeedback.BoolValue)
|
||||
return DmTx200Base.eSourceSelection.Digital;
|
||||
else if (Tx.VgaInput.SyncDetectedFeedback.BoolValue)
|
||||
return DmTx200Base.eSourceSelection.Analog;
|
||||
else
|
||||
return DmTx200Base.eSourceSelection.Disable;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public RoutingPortCollection<RoutingInputPort> InputPorts
|
||||
{
|
||||
get
|
||||
{
|
||||
return new RoutingPortCollection<RoutingInputPort>
|
||||
{
|
||||
HdmiInput,
|
||||
VgaInput,
|
||||
AnyVideoInput
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public RoutingPortCollection<RoutingOutputPort> OutputPorts
|
||||
{
|
||||
get
|
||||
{
|
||||
return new RoutingPortCollection<RoutingOutputPort> { DmOutput };
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="tx"></param>
|
||||
public DmTx201SBasicController(string key, string name, DmTx201S tx)
|
||||
: base(key, name, tx)
|
||||
{
|
||||
Tx = tx;
|
||||
|
||||
//Can this be combined into helper somehow??
|
||||
var combinedFuncs = new VideoStatusFuncsWrapper
|
||||
{
|
||||
HdcpActiveFeedbackFunc = () =>
|
||||
ActualVideoInput == DmTx200Base.eSourceSelection.Digital
|
||||
&& tx.HdmiInput.VideoAttributes.HdcpActiveFeedback.BoolValue,
|
||||
|
||||
HdcpStateFeedbackFunc = () =>
|
||||
ActualVideoInput == DmTx200Base.eSourceSelection.Digital
|
||||
? tx.HdmiInput.VideoAttributes.HdcpStateFeedback.ToString()
|
||||
: "",
|
||||
|
||||
VideoResolutionFeedbackFunc = () =>
|
||||
ActualVideoInput == DmTx200Base.eSourceSelection.Digital
|
||||
? Tx.HdmiInput.VideoAttributes.GetVideoResolutionString()
|
||||
: Tx.VgaInput.VideoAttributes.GetVideoResolutionString(),
|
||||
|
||||
VideoSyncFeedbackFunc = () =>
|
||||
ActualVideoInput == DmTx200Base.eSourceSelection.Digital
|
||||
? HdmiInput.VideoStatus.VideoSyncFeedback.BoolValue
|
||||
: VgaInput.VideoStatus.VideoSyncFeedback.BoolValue
|
||||
};
|
||||
HdmiInput = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn,
|
||||
eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, 1, this,
|
||||
VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInput));
|
||||
VgaInput = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn,
|
||||
eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, 2, this,
|
||||
VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput));
|
||||
AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn,
|
||||
eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.None, 0, this, combinedFuncs);
|
||||
|
||||
DmOutput = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.AudioVideo,
|
||||
eRoutingPortConnectionType.DmCat, null, this);
|
||||
|
||||
ActiveVideoInputFeedback = new StringFeedback(new Cue("ActiveVideoInput", 0, eCueType.String),
|
||||
() => ActualVideoInput.ToString());
|
||||
}
|
||||
|
||||
public override bool CustomActivate()
|
||||
{
|
||||
Tx.HdmiInput.InputStreamChange += (o, a) => FireInputStreamChange(HdmiInput, a.EventId);
|
||||
Tx.HdmiInput.VideoAttributes.AttributeChange += (o, a) => FireVideoAttributeChange(HdmiInput, a.EventId);
|
||||
|
||||
Tx.VgaInput.InputStreamChange += (o, a) => FireInputStreamChange(VgaInput, a.EventId);
|
||||
Tx.VgaInput.VideoAttributes.AttributeChange += (o, a) => FireVideoAttributeChange(VgaInput, a.EventId);
|
||||
|
||||
// Base does register and sets up comm monitoring.
|
||||
return base.CustomActivate();
|
||||
}
|
||||
|
||||
void Tx_BaseEvent(GenericBase device, BaseEventArgs args)
|
||||
{
|
||||
var id = args.EventId;
|
||||
if (id == DmTx201S.VideoSourceFeedbackEventID)
|
||||
{
|
||||
Debug.Console(2, this, " Video Source: {0}", Tx.VideoSourceFeedback);
|
||||
}
|
||||
|
||||
// ------------------------------ incomplete -----------------------------------------
|
||||
else if (id == DmTx201S.AudioSourceFeedbackEventID)
|
||||
{
|
||||
Debug.Console(2, this, " Audio Source: {0}", Tx.AudioSourceFeedback);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Relays the input stream change to the appropriate RoutingInputPort.
|
||||
/// </summary>
|
||||
void FireInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId)
|
||||
{
|
||||
if (eventId == EndpointInputStreamEventIds.SyncDetectedFeedbackEventId)
|
||||
{
|
||||
inputPort.VideoStatus.VideoSyncFeedback.FireUpdate();
|
||||
AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Relays the VideoAttributes change to a RoutingInputPort
|
||||
/// </summary>
|
||||
void FireVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId)
|
||||
{
|
||||
//// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds
|
||||
//Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}",
|
||||
// args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType());
|
||||
switch (eventId)
|
||||
{
|
||||
case VideoAttributeEventIds.HdcpActiveFeedbackEventId:
|
||||
inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate();
|
||||
AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate();
|
||||
break;
|
||||
case VideoAttributeEventIds.HdcpStateFeedbackEventId:
|
||||
inputPort.VideoStatus.HdcpStateFeedback.FireUpdate();
|
||||
AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate();
|
||||
break;
|
||||
case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId:
|
||||
case VideoAttributeEventIds.VerticalResolutionFeedbackEventId:
|
||||
inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate();
|
||||
AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override List<Feedback> Feedbacks
|
||||
{
|
||||
get
|
||||
{
|
||||
List<Feedback> list = AnyVideoInput.VideoStatus.ToList();
|
||||
list.AddRange(base.Feedbacks);
|
||||
list.Add(ActiveVideoInputFeedback);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,237 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro;
|
||||
//using Crestron.SimplSharpPro.DeviceSupport;
|
||||
using Crestron.SimplSharpPro.DM;
|
||||
using Crestron.SimplSharpPro.DM.Endpoints;
|
||||
using Crestron.SimplSharpPro.DM.Endpoints.Transmitters;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.DM.Config;
|
||||
|
||||
namespace PepperDash.Essentials.DM
|
||||
{
|
||||
using eVst = Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType;
|
||||
|
||||
public class DmTx4k302CController : DmTxControllerBase, IRoutingInputsOutputs, IHasFeedback,
|
||||
IIROutputPorts, IComPorts
|
||||
{
|
||||
public DmTx4k302C Tx { get; private set; }
|
||||
|
||||
public RoutingInputPortWithVideoStatuses AnyVideoInput { get; private set; }
|
||||
public RoutingInputPortWithVideoStatuses HdmiIn1 { get; private set; }
|
||||
public RoutingInputPortWithVideoStatuses HdmiIn2 { get; private set; }
|
||||
public RoutingInputPortWithVideoStatuses VgaIn { get; private set; }
|
||||
public RoutingOutputPort DmOut { get; private set; }
|
||||
public RoutingOutputPort HdmiLoopOut { get; private set; }
|
||||
|
||||
public StringFeedback ActiveVideoInputFeedback { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Helps get the "real" inputs, including when in Auto
|
||||
/// </summary>
|
||||
public Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType ActualActiveVideoInput
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Tx.VideoSourceFeedback != eVst.Auto)
|
||||
return Tx.VideoSourceFeedback;
|
||||
else // auto
|
||||
{
|
||||
if (Tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue)
|
||||
return eVst.Hdmi1;
|
||||
else if (Tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue)
|
||||
return eVst.Hdmi2;
|
||||
else if (Tx.VgaInput.SyncDetectedFeedback.BoolValue)
|
||||
return eVst.Vga;
|
||||
else
|
||||
return eVst.AllDisabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public RoutingPortCollection<RoutingInputPort> InputPorts
|
||||
{
|
||||
get
|
||||
{
|
||||
return new RoutingPortCollection<RoutingInputPort>
|
||||
{
|
||||
HdmiIn1,
|
||||
HdmiIn2,
|
||||
VgaIn,
|
||||
AnyVideoInput
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public RoutingPortCollection<RoutingOutputPort> OutputPorts
|
||||
{
|
||||
get
|
||||
{
|
||||
return new RoutingPortCollection<RoutingOutputPort> { DmOut, HdmiLoopOut };
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="tx"></param>
|
||||
public DmTx4k302CController(string key, string name, DmTx4k302C tx)
|
||||
: base(key, name, tx)
|
||||
{
|
||||
Tx = tx;
|
||||
|
||||
HdmiIn1 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn1,
|
||||
eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, 1, this,
|
||||
VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[1]));
|
||||
HdmiIn2 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn2,
|
||||
eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, 2, this,
|
||||
VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[2]));
|
||||
VgaIn = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn,
|
||||
eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, 3, this,
|
||||
VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput));
|
||||
ActiveVideoInputFeedback = new StringFeedback(new Cue("ActiveVideoInput", 0, eCueType.String),
|
||||
() => ActualActiveVideoInput.ToString());
|
||||
|
||||
var combinedFuncs = new VideoStatusFuncsWrapper
|
||||
{
|
||||
HdcpActiveFeedbackFunc = () =>
|
||||
(ActualActiveVideoInput == eVst.Hdmi1
|
||||
&& tx.HdmiInputs[1].VideoAttributes.HdcpActiveFeedback.BoolValue)
|
||||
|| (ActualActiveVideoInput == eVst.Hdmi2
|
||||
&& tx.HdmiInputs[2].VideoAttributes.HdcpActiveFeedback.BoolValue),
|
||||
|
||||
HdcpStateFeedbackFunc = () =>
|
||||
{
|
||||
if (ActualActiveVideoInput == eVst.Hdmi1)
|
||||
return tx.HdmiInputs[1].VideoAttributes.HdcpStateFeedback.ToString();
|
||||
if (ActualActiveVideoInput == eVst.Hdmi2)
|
||||
return tx.HdmiInputs[2].VideoAttributes.HdcpStateFeedback.ToString();
|
||||
return "";
|
||||
},
|
||||
|
||||
VideoResolutionFeedbackFunc = () =>
|
||||
{
|
||||
if (ActualActiveVideoInput == eVst.Hdmi1)
|
||||
return tx.HdmiInputs[1].VideoAttributes.GetVideoResolutionString();
|
||||
if (ActualActiveVideoInput == eVst.Hdmi2)
|
||||
return tx.HdmiInputs[2].VideoAttributes.GetVideoResolutionString();
|
||||
if (ActualActiveVideoInput == eVst.Vga)
|
||||
return tx.VgaInput.VideoAttributes.GetVideoResolutionString();
|
||||
return "";
|
||||
},
|
||||
VideoSyncFeedbackFunc = () =>
|
||||
(ActualActiveVideoInput == eVst.Hdmi1
|
||||
&& tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue)
|
||||
|| (ActualActiveVideoInput == eVst.Hdmi2
|
||||
&& tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue)
|
||||
|| (ActualActiveVideoInput == eVst.Vga
|
||||
&& tx.VgaInput.SyncDetectedFeedback.BoolValue)
|
||||
};
|
||||
|
||||
AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn,
|
||||
eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.None, 0, this, combinedFuncs);
|
||||
|
||||
DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.AudioVideo,
|
||||
eRoutingPortConnectionType.DmCat, null, this);
|
||||
HdmiLoopOut = new RoutingOutputPort(DmPortName.HdmiLoopOut, eRoutingSignalType.AudioVideo,
|
||||
eRoutingPortConnectionType.Hdmi, null, this);
|
||||
}
|
||||
|
||||
public override bool CustomActivate()
|
||||
{
|
||||
// Link up all of these damned events to the various RoutingPorts via a helper handler
|
||||
Tx.HdmiInputs[1].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn1, a.EventId);
|
||||
Tx.HdmiInputs[1].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn1, a.EventId);
|
||||
|
||||
Tx.HdmiInputs[2].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn2, a.EventId);
|
||||
Tx.HdmiInputs[2].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn2, a.EventId);
|
||||
|
||||
Tx.VgaInput.InputStreamChange += (o, a) => FowardInputStreamChange(VgaIn, a.EventId);
|
||||
Tx.VgaInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(VgaIn, a.EventId);
|
||||
|
||||
// Base does register and sets up comm monitoring.
|
||||
return base.CustomActivate();
|
||||
}
|
||||
|
||||
void Tx_BaseEvent(GenericBase device, BaseEventArgs args)
|
||||
{
|
||||
var id = args.EventId;
|
||||
if (id == DmTx4k302C.VideoSourceFeedbackEventId)
|
||||
{
|
||||
Debug.Console(2, this, " Video Source: {0}", Tx.VideoSourceFeedback);
|
||||
}
|
||||
|
||||
// ------------------------------ incomplete -----------------------------------------
|
||||
else if (id == DmTx4k302C.AudioSourceFeedbackEventId)
|
||||
{
|
||||
Debug.Console(2, this, " Audio Source: {0}", Tx.AudioSourceFeedback);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Relays the input stream change to the appropriate RoutingInputPort.
|
||||
/// </summary>
|
||||
void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId)
|
||||
{
|
||||
if (eventId == EndpointInputStreamEventIds.SyncDetectedFeedbackEventId)
|
||||
{
|
||||
inputPort.VideoStatus.VideoSyncFeedback.FireUpdate();
|
||||
AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Relays the VideoAttributes change to a RoutingInputPort
|
||||
/// </summary>
|
||||
void ForwardVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId)
|
||||
{
|
||||
//// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds
|
||||
//Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}",
|
||||
// args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType());
|
||||
switch (eventId)
|
||||
{
|
||||
case VideoAttributeEventIds.HdcpActiveFeedbackEventId:
|
||||
inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate();
|
||||
AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate();
|
||||
break;
|
||||
case VideoAttributeEventIds.HdcpStateFeedbackEventId:
|
||||
inputPort.VideoStatus.HdcpStateFeedback.FireUpdate();
|
||||
AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate();
|
||||
break;
|
||||
case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId:
|
||||
case VideoAttributeEventIds.VerticalResolutionFeedbackEventId:
|
||||
inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate();
|
||||
AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override List<Feedback> Feedbacks
|
||||
{
|
||||
get
|
||||
{
|
||||
List<Feedback> list = AnyVideoInput.VideoStatus.ToList();
|
||||
list.AddRange(base.Feedbacks);
|
||||
list.Add(ActiveVideoInputFeedback);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
#region IIROutputPorts Members
|
||||
public CrestronCollection<IROutputPort> IROutputPorts { get { return Tx.IROutputPorts; } }
|
||||
public int NumberOfIROutputPorts { get { return Tx.NumberOfIROutputPorts; } }
|
||||
#endregion
|
||||
|
||||
#region IComPorts Members
|
||||
public CrestronCollection<ComPort> ComPorts { get { return Tx.ComPorts; } }
|
||||
public int NumberOfComPorts { get { return Tx.NumberOfComPorts; } }
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.DM;
|
||||
using Crestron.SimplSharpPro.DM.Endpoints;
|
||||
using Crestron.SimplSharpPro.DM.Endpoints.Transmitters;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.DM.Config;
|
||||
|
||||
namespace PepperDash.Essentials.DM
|
||||
{
|
||||
public class DmTxHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// A factory method for various DmTxControllers
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="props"></param>
|
||||
/// <returns></returns>
|
||||
public static DmTxControllerBase GetDmTxController(string key, string name, string typeName, DmTxPropertiesConfig props)
|
||||
{
|
||||
// switch on type name... later...
|
||||
|
||||
typeName = typeName.ToLower();
|
||||
//uint ipid = Convert.ToUInt16(props.Id, 16);
|
||||
var ipid = props.Control.IpIdInt;
|
||||
var pKey = props.ParentDeviceKey.ToLower();
|
||||
|
||||
if (pKey == "processor")
|
||||
{
|
||||
// Catch constructor failures, mainly dues to IPID
|
||||
try
|
||||
{
|
||||
if (typeName.StartsWith("dmtx201"))
|
||||
return new DmTx201SBasicController(key, name, new DmTx201C(ipid, Global.ControlSystem));
|
||||
if (typeName.StartsWith("dmtx4k302"))
|
||||
return new DmTx4k302CController(key, name, new DmTx4k302C(ipid, Global.ControlSystem));
|
||||
if (typeName.StartsWith("dmtx401"))
|
||||
return new DmTx401CController(key, name, new DmTx401C(ipid, Global.ControlSystem));
|
||||
Debug.Console(0, "{1} WARNING: Cannot create DM-TX of type: '{0}'", typeName, key);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(0, "[{0}] WARNING: Cannot create DM-TX device: {1}", key, e.Message);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var parentDev = DeviceManager.GetDeviceForKey(pKey);
|
||||
if (!(parentDev is DmChassisController))
|
||||
{
|
||||
Debug.Console(0, "Cannot create DM device '{0}'. '{1}' is not a DM Chassis.",
|
||||
key, pKey);
|
||||
return null;
|
||||
}
|
||||
|
||||
// Get the Crestron chassis and link stuff up
|
||||
var switchDev = parentDev as DmChassisController;
|
||||
var chassis = switchDev.Chassis;
|
||||
|
||||
var num = props.ParentInputNumber;
|
||||
if (num <= 0 || num > chassis.NumberOfInputs)
|
||||
{
|
||||
Debug.Console(0, "Cannot create DM device '{0}'. Input number '{1}' is out of range",
|
||||
key, num);
|
||||
return null;
|
||||
}
|
||||
|
||||
// Catch constructor failures, mainly dues to IPID
|
||||
try
|
||||
{
|
||||
if (typeName.StartsWith("dmtx201"))
|
||||
return new DmTx201SBasicController(key, name, new DmTx201S(ipid, chassis.Inputs[num]));
|
||||
|
||||
if (typeName.StartsWith("dmtx4k302"))
|
||||
return new DmTx4k302CController(key, name, new DmTx4k302C(ipid, chassis.Inputs[num]));
|
||||
|
||||
if (typeName.StartsWith("dmtx401"))
|
||||
return new DmTx401CController(key, name, new DmTx401C(ipid, chassis.Inputs[num]));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(0, "[{0}] WARNING: Cannot create DM-TX device: {1}", key, e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public abstract class DmTxControllerBase : CrestronGenericBaseDevice
|
||||
{
|
||||
public DmTxControllerBase(string key, string name, EndpointTransmitterBase hardware)
|
||||
: base(key, name, hardware) { }
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -1,27 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
using Crestron.SimplSharpPro.DM;
|
||||
using Crestron.SimplSharpPro.DM.Cards;
|
||||
|
||||
using PepperDash.Essentials.Core;
|
||||
|
||||
namespace PepperDash.Essentials.DM
|
||||
{
|
||||
public static class VideoAttributesBasicExtensions
|
||||
{
|
||||
public static string GetVideoResolutionString(this VideoAttributesBasic va)
|
||||
{
|
||||
ushort h = va.HorizontalResolutionFeedback.UShortValue;
|
||||
ushort v = va.VerticalResolutionFeedback.UShortValue;
|
||||
if (h == 0 || v == 0)
|
||||
return "n/a";
|
||||
else
|
||||
return string.Format("{0}x{1}", h, v);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyTitle("Essentials_DM")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Essentials_DM")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2016")]
|
||||
[assembly: AssemblyVersion("1.0.0.*")]
|
||||
|
||||
@@ -1,124 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Devices.Common.DSP
|
||||
{
|
||||
public abstract class DspBase : Device
|
||||
{
|
||||
public Dictionary<string, DspControlPoint> LevelControlPoints { get; private set; }
|
||||
|
||||
public Dictionary<string, DspControlPoint> DialerControlPoints { get; private set; }
|
||||
|
||||
public Dictionary<string, DspControlPoint> SwitcherControlPoints { get; private set; }
|
||||
|
||||
public abstract void RunPreset(string name);
|
||||
|
||||
public DspBase(string key, string name) :
|
||||
base(key, name) { }
|
||||
|
||||
|
||||
// in audio call feedback
|
||||
|
||||
// VOIP
|
||||
// Phone dialer
|
||||
}
|
||||
|
||||
// Fusion
|
||||
// Privacy state
|
||||
// Online state
|
||||
// level/mutes ?
|
||||
|
||||
// AC Log call stats
|
||||
|
||||
// Typical presets:
|
||||
// call default preset to restore levels and mutes
|
||||
|
||||
public abstract class DspControlPoint
|
||||
{
|
||||
//string Key { get; protected set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Main program
|
||||
// VTC
|
||||
// ATC
|
||||
// Mics, unusual
|
||||
|
||||
public interface IDspLevelControl : IBasicVolumeWithFeedback
|
||||
{
|
||||
/// <summary>
|
||||
/// In BiAmp: Instance Tag, QSC: Named Control, Polycom:
|
||||
/// </summary>
|
||||
string ControlPointTag { get; }
|
||||
int Index1 { get; }
|
||||
int Index2 { get; }
|
||||
bool HasMute { get; }
|
||||
bool HasLevel { get; }
|
||||
bool AutomaticUnmuteOnVolumeUp { get; }
|
||||
}
|
||||
|
||||
//public abstract class DspLevelControl : DspControlPoint, IBasicVolumeWithFeedback
|
||||
//{
|
||||
// protected abstract Func<bool> MuteFeedbackFunc { get; }
|
||||
// protected abstract Func<int> VolumeLevelFeedbackFunc { get; }
|
||||
|
||||
// public DspLevelControl(string id)
|
||||
// {
|
||||
// MuteFeedback = new BoolFeedback(MuteFeedbackFunc);
|
||||
// VolumeLevelFeedback = new IntFeedback(VolumeLevelFeedbackFunc);
|
||||
// }
|
||||
|
||||
// // Poll and listen for these
|
||||
// // Max value
|
||||
// // Min value
|
||||
// #region IBasicVolumeWithFeedback Members
|
||||
|
||||
// public BoolFeedback MuteFeedback { get; private set; }
|
||||
|
||||
// public abstract void MuteOff();
|
||||
|
||||
// public abstract void MuteOn();
|
||||
|
||||
// public abstract void SetVolume(ushort level);
|
||||
|
||||
// public IntFeedback VolumeLevelFeedback { get; private set; }
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region IBasicVolumeControls Members
|
||||
|
||||
// public abstract void MuteToggle();
|
||||
|
||||
// public abstract void VolumeDown(bool pressRelease);
|
||||
|
||||
// public abstract void VolumeUp(bool pressRelease);
|
||||
|
||||
// #endregion
|
||||
//}
|
||||
|
||||
// Privacy mute
|
||||
public abstract class DspMuteControl : DspControlPoint
|
||||
{
|
||||
protected abstract Func<bool> MuteFeedbackFunc { get; }
|
||||
|
||||
public DspMuteControl(string id)
|
||||
{
|
||||
MuteFeedback = new BoolFeedback(MuteFeedbackFunc);
|
||||
}
|
||||
|
||||
public BoolFeedback MuteFeedback { get; private set; }
|
||||
|
||||
public abstract void MuteOff();
|
||||
|
||||
public abstract void MuteOn();
|
||||
|
||||
public abstract void MuteToggle();
|
||||
}
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{892B761C-E479-44CE-BD74-243E9214AF13}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>PepperDash.Essentials.Devices.Common</RootNamespace>
|
||||
<AssemblyName>Essentials Devices Common</AssemblyName>
|
||||
<ProjectTypeGuids>{0B4745B0-194B-4BB6-8E21-E9057CA92300};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<PlatformFamilyName>WindowsCE</PlatformFamilyName>
|
||||
<PlatformID>E2BECB1F-8C8C-41ba-B736-9BE7D946A398</PlatformID>
|
||||
<OSVersion>5.0</OSVersion>
|
||||
<DeployDirSuffix>SmartDeviceProject1</DeployDirSuffix>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<NativePlatformName>Windows CE</NativePlatformName>
|
||||
<FormFactorID>
|
||||
</FormFactorID>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<AllowedReferenceRelatedFileExtensions>.allowedReferenceRelatedFileExtensions</AllowedReferenceRelatedFileExtensions>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<GenerateSerializationAssemblies>off</GenerateSerializationAssemblies>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<AllowedReferenceRelatedFileExtensions>.allowedReferenceRelatedFileExtensions</AllowedReferenceRelatedFileExtensions>
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<GenerateSerializationAssemblies>off</GenerateSerializationAssemblies>
|
||||
</PropertyGroup>
|
||||
<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>
|
||||
</Reference>
|
||||
<Reference Include="Crestron.SimplSharpPro.Gateways, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Gateways.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="PepperDash_Core, Version=1.0.6284.20368, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\PepperDash.Core\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PepperDash_Essentials_Core, Version=1.0.0.14500, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\Essentials Core\PepperDashEssentialsBase\bin\PepperDash_Essentials_Core.dll</HintPath>
|
||||
</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>
|
||||
<Private>False</Private>
|
||||
</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>
|
||||
<Private>False</Private>
|
||||
</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>
|
||||
</Reference>
|
||||
<Reference Include="SimplSharpPro, Version=1.5.2.4, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe</HintPath>
|
||||
<Private>False</Private>
|
||||
</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>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Crestron\Gateways\CenRfgwController.cs" />
|
||||
<Compile Include="Display\ComTcpDisplayBase.cs" />
|
||||
<Compile Include="Display\DeviceFactory.cs" />
|
||||
<Compile Include="Display\NecPaSeriesProjector.cs" />
|
||||
<Compile Include="Display\NECPSXMDisplay.cs" />
|
||||
<Compile Include="DSP\BiampTesira\BiampTesiraForteDspLevel.cs" />
|
||||
<Compile Include="DSP\BiampTesira\TesiraForteControlPoint.cs" />
|
||||
<Compile Include="DSP\BiampTesira\TesiraForteMuteControl.cs" />
|
||||
<Compile Include="DSP\DspBase.cs" />
|
||||
<Compile Include="DSP\BiampTesira\BiampTesiraForteDsp.cs" />
|
||||
<Compile Include="DSP\BiampTesira\BiampTesiraFortePropertiesConfig.cs" />
|
||||
<Compile Include="DSP\PolycomSoundStructure\SoundStructureBasics.cs" />
|
||||
<Compile Include="Factory\DeviceFactory.cs" />
|
||||
<Compile Include="PC\InRoomPc.cs" />
|
||||
<Compile Include="PC\Laptop.cs" />
|
||||
<Compile Include="SetTopBox\SetTopBoxPropertiesConfig.cs" />
|
||||
<Compile Include="Streaming\AppleTV.cs" />
|
||||
<Compile Include="Audio\GenericAudioOut.cs" />
|
||||
<Compile Include="DiscPlayer\IRDiscPlayerBase.cs" />
|
||||
<Compile Include="SetTopBox\IRSetTopBoxBase.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Streaming\Roku.cs" />
|
||||
<None Include="Properties\ControlSystem.cfg" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CompactFramework.CSharp.targets" />
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>rem S# Pro preparation will execute after these operations</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
Binary file not shown.
@@ -1,129 +0,0 @@
|
||||
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;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
|
||||
using PepperDash.Essentials.Devices.Common.DSP;
|
||||
|
||||
using PepperDash.Essentials.Devices.Common;
|
||||
|
||||
namespace PepperDash.Essentials.Devices.Common
|
||||
{
|
||||
public class DeviceFactory
|
||||
{
|
||||
public static IKeyed GetDevice(DeviceConfig dc)
|
||||
{
|
||||
var key = dc.Key;
|
||||
var name = dc.Name;
|
||||
var type = dc.Type;
|
||||
var properties = dc.Properties;
|
||||
|
||||
var typeName = dc.Type.ToLower();
|
||||
var groupName = dc.Group.ToLower();
|
||||
|
||||
if (typeName == "appletv")
|
||||
{
|
||||
//var ir = IRPortHelper.GetIrPort(properties);
|
||||
//if (ir != null)
|
||||
// return new AppleTV(key, name, ir.Port, ir.FileName);
|
||||
|
||||
var irCont = IRPortHelper.GetIrOutputPortController(dc);
|
||||
return new AppleTV(key, name, irCont);
|
||||
|
||||
}
|
||||
|
||||
else if (typeName == "basicirdisplay")
|
||||
{
|
||||
var ir = IRPortHelper.GetIrPort(properties);
|
||||
if (ir != null)
|
||||
return new BasicIrDisplay(key, name, ir.Port, ir.FileName);
|
||||
}
|
||||
|
||||
else if (typeName == "cenrfgwex")
|
||||
{
|
||||
return CenRfgwController.GetNewExGatewayController(key, name,
|
||||
properties.Value<string>("id"), properties.Value<string>("gatewayType"));
|
||||
}
|
||||
|
||||
else if (typeName == "cenerfgwpoe")
|
||||
{
|
||||
return CenRfgwController.GetNewErGatewayController(key, name,
|
||||
properties.Value<string>("id"), properties.Value<string>("gatewayType"));
|
||||
}
|
||||
|
||||
else if (typeName == "genericaudiooutwithvolume")
|
||||
{
|
||||
var zone = dc.Properties.Value<uint>("zone");
|
||||
return new GenericAudioOutWithVolume(key, name,
|
||||
dc.Properties.Value<string>("volumeDeviceKey"), zone);
|
||||
}
|
||||
|
||||
else if (groupName == "discplayer") // (typeName == "irbluray")
|
||||
{
|
||||
if (properties["control"]["method"].Value<string>() == "ir")
|
||||
{
|
||||
var irCont = IRPortHelper.GetIrOutputPortController(dc);
|
||||
return new IRBlurayBase(key, name, irCont);
|
||||
|
||||
//var ir = IRPortHelper.GetIrPort(properties);
|
||||
//if (ir != null)
|
||||
// return new IRBlurayBase(key, name, ir.Port, ir.FileName);
|
||||
}
|
||||
else if (properties["control"]["method"].Value<string>() == "com")
|
||||
{
|
||||
Debug.Console(0, "[{0}] COM Device type not implemented YET!", key);
|
||||
}
|
||||
}
|
||||
|
||||
else if (groupName == "settopbox") //(typeName == "irstbbase")
|
||||
{
|
||||
var irCont = IRPortHelper.GetIrOutputPortController(dc);
|
||||
var config = dc.Properties.ToObject<SetTopBoxPropertiesConfig>();
|
||||
var stb = new IRSetTopBoxBase(key, name, irCont, config);
|
||||
|
||||
//stb.HasDvr = properties.Value<bool>("hasDvr");
|
||||
var listName = properties.Value<string>("presetsList");
|
||||
if (listName != null)
|
||||
stb.LoadPresets(listName);
|
||||
return stb;
|
||||
}
|
||||
|
||||
else if (typeName == "laptop")
|
||||
{
|
||||
return new Laptop(key, name);
|
||||
}
|
||||
|
||||
else if (typeName == "inroompc")
|
||||
{
|
||||
return new InRoomPc(key, name);
|
||||
}
|
||||
|
||||
else if (typeName == "roku")
|
||||
{
|
||||
var irCont = IRPortHelper.GetIrOutputPortController(dc);
|
||||
return new Roku2(key, name, irCont);
|
||||
|
||||
//var ir = IRPortHelper.GetIrPort(properties);
|
||||
//if (ir != null)
|
||||
// return new Roku2(key, name, ir.Port, ir.FileName);
|
||||
}
|
||||
|
||||
else if (typeName == "biamptesira")
|
||||
{
|
||||
var comm = CommFactory.CreateCommForDevice(dc);
|
||||
var props = JsonConvert.DeserializeObject<BiampTesiraFortePropertiesConfig>(
|
||||
properties.ToString());
|
||||
return new BiampTesiraForteDsp(key, name, comm, props);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyTitle("Essentials_Devices_Common")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Essentials_Devices_Common")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2016")]
|
||||
[assembly: AssemblyVersion("1.0.0.*")]
|
||||
|
||||
@@ -1,152 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharp.CrestronIO;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
|
||||
namespace PepperDash.Essentials
|
||||
{
|
||||
/// <summary>
|
||||
/// Loads the ConfigObject from the file
|
||||
/// </summary>
|
||||
public class ConfigReader
|
||||
{
|
||||
public static EssentialsConfig ConfigObject { get; private set; }
|
||||
|
||||
public static void LoadConfig2()
|
||||
{
|
||||
Debug.Console(0, "Using unmerged system/template configs.");
|
||||
try
|
||||
{
|
||||
using (StreamReader fs = new StreamReader(string.Format(@"\NVRAM\program{0}\ConfigurationFile.json", InitialParametersClass.ApplicationNumber)))
|
||||
{
|
||||
var doubleObj = JObject.Parse(fs.ReadToEnd());
|
||||
ConfigObject = MergeConfigs(doubleObj).ToObject<EssentialsConfig>();
|
||||
|
||||
// Extract SystemUrl and TemplateUrl
|
||||
|
||||
if (doubleObj["system_url"] != null)
|
||||
{
|
||||
ConfigObject.SystemUrl = doubleObj["system_url"].Value<string>();
|
||||
}
|
||||
|
||||
if (doubleObj["template_url"] != null)
|
||||
{
|
||||
ConfigObject.TemplateUrl= doubleObj["template_url"].Value<string>();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(0, "Config failed: \r{0}", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static JObject MergeConfigs(JObject doubleConfig)
|
||||
{
|
||||
var system = JObject.FromObject(doubleConfig["system"]);
|
||||
var template = JObject.FromObject(doubleConfig["template"]);
|
||||
var merged = new JObject();
|
||||
|
||||
// Put together top-level objects
|
||||
if (system["info"] != null)
|
||||
merged.Add("info", Merge(template["info"], system["info"]));
|
||||
else
|
||||
merged.Add("info", template["info"]);
|
||||
|
||||
merged.Add("devices", MergeArraysOnTopLevelProperty(template["devices"] as JArray, system["devices"] as JArray, "uid"));
|
||||
|
||||
if (system["rooms"] == null)
|
||||
merged.Add("rooms", template["rooms"]);
|
||||
else
|
||||
merged.Add("rooms", MergeArraysOnTopLevelProperty(template["rooms"] as JArray, system["rooms"] as JArray, "key"));
|
||||
|
||||
if (system["sourceLists"] == null)
|
||||
merged.Add("sourceLists", template["sourceLists"]);
|
||||
else
|
||||
merged.Add("sourceLists", Merge(template["sourceLists"], system["sourceLists"]));
|
||||
|
||||
#warning Make tie lines merge appropriately
|
||||
if (template["tieLines"] != null)
|
||||
merged.Add("tieLines", template["tieLines"]);
|
||||
else if (system["tieLines"] != null)
|
||||
merged.Add("tieLines", system["tieLines"]);
|
||||
else
|
||||
merged.Add("tieLines", new JArray());
|
||||
|
||||
Debug.Console(0, "MERGED RESULT: \x0d\x0a{0}", merged);
|
||||
return merged;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Merges the contents of a base and a delta array, matching the entries on a top-level property
|
||||
/// given by propertyName. Returns a merge of them. Items in the delta array that do not have
|
||||
/// a matched item in base array will not be merged.
|
||||
/// </summary>
|
||||
static JArray MergeArraysOnTopLevelProperty(JArray a1, JArray a2, string propertyName)
|
||||
{
|
||||
var result = new JArray();
|
||||
if (a2 == null)
|
||||
result = a1;
|
||||
else if (a1 != null)
|
||||
{
|
||||
for (int i = 0; i < a1.Count(); i++)
|
||||
{
|
||||
var a1Dev = a1[i];
|
||||
// Try to get a system device and if found, merge it onto template
|
||||
var a2Match = a2.FirstOrDefault(t => t[propertyName].Equals(a1Dev[propertyName]));// t.Value<int>("uid") == tmplDev.Value<int>("uid"));
|
||||
if (a2Match != null)
|
||||
{
|
||||
var mergedItem = Merge(a1Dev, a2Match);// Merge(JObject.FromObject(a1Dev), JObject.FromObject(a2Match));
|
||||
result.Add(mergedItem);
|
||||
}
|
||||
else
|
||||
result.Add(a1Dev);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Helper for using with JTokens. Converts to JObject
|
||||
/// </summary>
|
||||
static JObject Merge(JToken t1, JToken t2)
|
||||
{
|
||||
return Merge(JObject.FromObject(t1), JObject.FromObject(t2));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Merge b ONTO a
|
||||
/// </summary>
|
||||
/// <param name="a"></param>
|
||||
/// <param name="b"></param>
|
||||
static JObject Merge(JObject o1, JObject o2)
|
||||
{
|
||||
//Console.WriteLine("Merging {0}\ronto {1}", o2, o1);
|
||||
foreach (var o2Prop in o2)
|
||||
{
|
||||
var o1Value = o1[o2Prop.Key];
|
||||
if (o1Value == null)
|
||||
o1.Add(o2Prop.Key, o2Prop.Value);
|
||||
else
|
||||
{
|
||||
JToken replacement = null;
|
||||
if (o2Prop.Value.HasValues && o1Value.HasValues) // Drill down
|
||||
replacement = Merge(JObject.FromObject(o1Value), JObject.FromObject(o2Prop.Value));
|
||||
else
|
||||
replacement = o2Prop.Value;
|
||||
o1[o2Prop.Key].Replace(replacement);
|
||||
}
|
||||
}
|
||||
return o1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,192 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.CrestronThread;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Core.PortalSync;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Devices.Common;
|
||||
using PepperDash.Essentials.DM;
|
||||
using PepperDash.Essentials.Fusion;
|
||||
|
||||
namespace PepperDash.Essentials
|
||||
{
|
||||
public class ControlSystem : CrestronControlSystem
|
||||
{
|
||||
PepperDashPortalSyncClient PortalSync;
|
||||
|
||||
public ControlSystem()
|
||||
: base()
|
||||
{
|
||||
Thread.MaxNumberOfUserThreads = 400;
|
||||
Global.ControlSystem = this;
|
||||
DeviceManager.Initialize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Git 'er goin'
|
||||
/// </summary>
|
||||
public override void InitializeSystem()
|
||||
{
|
||||
//CrestronConsole.AddNewConsoleCommand(s => GoWithLoad(), "go", "Reloads configuration file",
|
||||
// ConsoleAccessLevelEnum.AccessOperator);
|
||||
//CrestronConsole.AddNewConsoleCommand(s => TearDown(), "ungo", "Reloads configuration file",
|
||||
// ConsoleAccessLevelEnum.AccessOperator);
|
||||
CrestronConsole.AddNewConsoleCommand(s =>
|
||||
{
|
||||
foreach (var tl in TieLineCollection.Default)
|
||||
CrestronConsole.ConsoleCommandResponse(" {0}\r", tl);
|
||||
},
|
||||
"listtielines", "Prints out all tie lines", ConsoleAccessLevelEnum.AccessOperator);
|
||||
|
||||
GoWithLoad();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Do it, yo
|
||||
/// </summary>
|
||||
public void GoWithLoad()
|
||||
{
|
||||
// var thread = new Thread(o =>
|
||||
// {
|
||||
try
|
||||
{
|
||||
CrestronConsole.AddNewConsoleCommand(EnablePortalSync, "portalsync", "Loads Portal Sync",
|
||||
ConsoleAccessLevelEnum.AccessOperator);
|
||||
|
||||
//PortalSync = new PepperDashPortalSyncClient();
|
||||
|
||||
Debug.Console(0, "Starting Essentials load from configuration");
|
||||
ConfigReader.LoadConfig2();
|
||||
LoadDevices();
|
||||
LoadTieLines();
|
||||
LoadRooms();
|
||||
// FUSION - should go per room I believe. See CreateSystems in original Configuration.cs
|
||||
// ???
|
||||
|
||||
//Temp Cotija testing
|
||||
//CotijaSystemController CotijaInterface = new CotijaSystemController("WebClient1");
|
||||
|
||||
DeviceManager.ActivateAll();
|
||||
Debug.Console(0, "Essentials load complete\r" +
|
||||
"-------------------------------------------------------------");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(0, "FATAL INITIALIZE ERROR. System is in an inconsistent state:\r{0}", e);
|
||||
}
|
||||
// return null;
|
||||
// }, null);
|
||||
}
|
||||
|
||||
public void EnablePortalSync(string s)
|
||||
{
|
||||
if (s.ToLower() == "enable")
|
||||
{
|
||||
CrestronConsole.ConsoleCommandResponse("Portal Sync features enabled");
|
||||
PortalSync = new PepperDashPortalSyncClient();
|
||||
}
|
||||
}
|
||||
|
||||
public void TearDown()
|
||||
{
|
||||
Debug.Console(0, "Tearing down existing system");
|
||||
DeviceManager.DeactivateAll();
|
||||
|
||||
TieLineCollection.Default.Clear();
|
||||
|
||||
foreach (var key in DeviceManager.GetDevices())
|
||||
DeviceManager.RemoveDevice(key);
|
||||
|
||||
Debug.Console(0, "Tear down COMPLETE");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Reads all devices from config and adds them to DeviceManager
|
||||
/// </summary>
|
||||
public void LoadDevices()
|
||||
{
|
||||
foreach (var devConf in ConfigReader.ConfigObject.Devices)
|
||||
{
|
||||
Debug.Console(0, "Creating device '{0}'", devConf.Key);
|
||||
// Skip this to prevent unnecessary warnings
|
||||
if (devConf.Key == "processor")
|
||||
continue;
|
||||
|
||||
// Try local factory first
|
||||
var newDev = DeviceFactory.GetDevice(devConf);
|
||||
|
||||
// Then associated library factories
|
||||
if (newDev == null)
|
||||
newDev = PepperDash.Essentials.Devices.Common.DeviceFactory.GetDevice(devConf);
|
||||
if (newDev == null)
|
||||
newDev = PepperDash.Essentials.DM.DeviceFactory.GetDevice(devConf);
|
||||
if (newDev == null)
|
||||
newDev = PepperDash.Essentials.Devices.Displays.DisplayDeviceFactory.GetDevice(devConf);
|
||||
|
||||
if (newDev != null)
|
||||
DeviceManager.AddDevice(newDev);
|
||||
else
|
||||
Debug.Console(0, "WARNING: Cannot load unknown device type '{0}', key '{1}'.", devConf.Type, devConf.Key);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method to load tie lines. This should run after devices have loaded
|
||||
/// </summary>
|
||||
public void LoadTieLines()
|
||||
{
|
||||
// Make this reusable by clearing the TieLineCollection
|
||||
|
||||
var tlc = TieLineCollection.Default;
|
||||
tlc.Clear();
|
||||
foreach (var tieLineConfig in ConfigReader.ConfigObject.TieLines)
|
||||
{
|
||||
var newTL = tieLineConfig.GetTieLine();
|
||||
if (newTL != null)
|
||||
tlc.Add(newTL);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads all rooms from config and adds them to DeviceManager
|
||||
/// </summary>
|
||||
public void LoadRooms()
|
||||
{
|
||||
foreach (var roomConfig in ConfigReader.ConfigObject.Rooms)
|
||||
{
|
||||
var room = roomConfig.GetRoomObject();
|
||||
if (room != null)
|
||||
{
|
||||
if (room is EssentialsHuddleSpaceRoom)
|
||||
{
|
||||
DeviceManager.AddDevice(room);
|
||||
|
||||
Debug.Console(1, "Room is EssentialsHuddleSpaceRoom, attempting to add to DeviceManager with Fusion");
|
||||
DeviceManager.AddDevice(new EssentialsHuddleSpaceFusionSystemController((EssentialsHuddleSpaceRoom)room, 0xf1));
|
||||
|
||||
var cotija = DeviceManager.GetDeviceForKey("cotijaServer") as CotijaSystemController;
|
||||
|
||||
if (cotija != null)
|
||||
{
|
||||
cotija.CotijaRooms.Add(new CotijaEssentialsHuddleSpaceRoomBridge(cotija, room as EssentialsHuddleSpaceRoom));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Console(1, "Room is NOT EssentialsHuddleSpaceRoom, attempting to add to DeviceManager w/o Fusion");
|
||||
DeviceManager.AddDevice(room);
|
||||
}
|
||||
|
||||
#warning Add Fusion connector to room factory?
|
||||
|
||||
}
|
||||
else
|
||||
Debug.Console(0, "WARNING: Cannot create room from config, key '{0}'", roomConfig.Key);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using System.Text;
|
||||
//using Crestron.SimplSharp;
|
||||
//using Crestron.SimplSharpPro;
|
||||
|
||||
//using PepperDash.Core;
|
||||
//using PepperDash.Essentials.Core;
|
||||
|
||||
//namespace PepperDash.Essentials
|
||||
//{
|
||||
// //***************************************************************************************************
|
||||
// public abstract class EssentialsRoom : Room
|
||||
// {
|
||||
// public event EventHandler<EssentialsRoomSourceChangeEventArgs> PresentationSourceChange;
|
||||
// public event EventHandler<EssentialsRoomAudioDeviceChangeEventArgs> AudioDeviceWillChange;
|
||||
// public Dictionary<uint, Device> Sources { get; protected set; }
|
||||
|
||||
// public abstract BoolFeedback RoomIsOnStandby { get; protected set; }
|
||||
// public abstract BoolFeedback RoomIsOccupied { get; protected set; }
|
||||
|
||||
// public uint UnattendedShutdownTimeMs { get; set; }
|
||||
|
||||
// /// <summary>
|
||||
// /// For use when turning on room without a source selection - e.g. from
|
||||
// /// wake-on signal or occ sensor
|
||||
// /// </summary>
|
||||
// public SourceListItem DefaultPresentationSource { get; set; }
|
||||
|
||||
//#warning This might need more "guts" and shouldn't be public
|
||||
// public SourceListItem CurrentPresentationSourceInfo { get; set; }
|
||||
|
||||
// //public IPresentationSource CurrentPresentationSource { get; protected set; }
|
||||
// //{
|
||||
// // get
|
||||
// // {
|
||||
// // if (_CurrentPresentationSource == null)
|
||||
// // _CurrentPresentationSource = PresentationDevice.Default;
|
||||
// // return _CurrentPresentationSource;
|
||||
// // }
|
||||
// // protected set { _CurrentPresentationSource = value; }
|
||||
// //}
|
||||
// //IPresentationSource _CurrentPresentationSource;
|
||||
|
||||
// /// <summary>
|
||||
// /// The volume control device for this room - changing it will trigger event
|
||||
// /// </summary>
|
||||
// public IBasicVolumeControls CurrentAudioDevice
|
||||
// {
|
||||
// get { return _CurrentAudioDevice; }
|
||||
// protected set
|
||||
// {
|
||||
// if (value != _CurrentAudioDevice)
|
||||
// if (AudioDeviceWillChange != null)
|
||||
// AudioDeviceWillChange(this,
|
||||
// new EssentialsRoomAudioDeviceChangeEventArgs(this, _CurrentAudioDevice, value));
|
||||
// _CurrentAudioDevice = value;
|
||||
// }
|
||||
// }
|
||||
// IBasicVolumeControls _CurrentAudioDevice;
|
||||
|
||||
// public EssentialsRoom(string key, string name)
|
||||
// : base(key, name)
|
||||
// {
|
||||
// }
|
||||
|
||||
// public virtual void SelectSource(uint sourceNum) { }
|
||||
|
||||
// public virtual void SelectSource(IPresentationSource newSrc) { }
|
||||
|
||||
// /// <summary>
|
||||
// /// Make sure that this is called before changing the source
|
||||
// /// </summary>
|
||||
// protected void OnPresentationSourceChange(SourceListItem currentSource, SourceListItem newSource)
|
||||
// {
|
||||
// var handler = PresentationSourceChange;
|
||||
// if (handler != null)
|
||||
// PresentationSourceChange(this,
|
||||
// new EssentialsRoomSourceChangeEventArgs(this, currentSource, newSource));
|
||||
// }
|
||||
// }
|
||||
|
||||
//}
|
||||
@@ -1,378 +0,0 @@
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using System.Text;
|
||||
//using Crestron.SimplSharp;
|
||||
//using Crestron.SimplSharpPro;
|
||||
|
||||
//using PepperDash.Core;
|
||||
//using PepperDash.Essentials.Core;
|
||||
|
||||
//namespace PepperDash.Essentials
|
||||
//{
|
||||
// //***************************************************************************************************
|
||||
|
||||
// public class HuddleSpaceRoom : EssentialsRoom
|
||||
// {
|
||||
// public override BoolFeedback RoomIsOnFeedback { get; protected set; }
|
||||
// public override BoolFeedback IsWarmingUpFeedback { get; protected set; }
|
||||
// public override BoolFeedback IsCoolingDownFeedback { get; protected set; }
|
||||
// public override BoolFeedback RoomIsOnStandby { get; protected set; }
|
||||
// public override BoolFeedback RoomIsOccupied { get; protected set; }
|
||||
|
||||
// public override uint WarmupTime
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// if (_Display != null)
|
||||
// return _Display.WarmupTime;
|
||||
// return base.WarmupTime;
|
||||
// }
|
||||
// }
|
||||
// public override uint CooldownTime
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// if (_Display != null)
|
||||
// return _Display.CooldownTime;
|
||||
// return base.CooldownTime;
|
||||
// }
|
||||
// }
|
||||
|
||||
// bool NoDisplayRoomIsOn = false;
|
||||
|
||||
// public DisplayBase DefaultDisplay // PROTECT ---------------------------------------------
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// if (_Display == null)
|
||||
// _Display = TwoWayDisplayBase.DefaultDisplay;
|
||||
// return _Display;
|
||||
// }
|
||||
// set
|
||||
// {
|
||||
// // Disconnect current display
|
||||
// if (_Display != null)
|
||||
// {
|
||||
// _Display.PowerIsOnFeedback.OutputChange -= Display_Various_OutputChange;
|
||||
// _Display.IsCoolingDownFeedback.OutputChange -= Display_Various_OutputChange;
|
||||
// _Display.IsWarmingUpFeedback.OutputChange -= Display_Various_OutputChange;
|
||||
// }
|
||||
// _Display = value;
|
||||
// if (value != null)
|
||||
// {
|
||||
// _Display.PowerIsOnFeedback.OutputChange += Display_Various_OutputChange;
|
||||
// _Display.IsCoolingDownFeedback.OutputChange += Display_Various_OutputChange;
|
||||
// _Display.IsWarmingUpFeedback.OutputChange += Display_Various_OutputChange;
|
||||
// }
|
||||
// CurrentAudioDevice = (value as IBasicVolumeControls);
|
||||
// }
|
||||
// }
|
||||
// DisplayBase _Display;
|
||||
|
||||
// public IBasicVolumeControls DefaultVolumeControls
|
||||
// {
|
||||
// get { return DefaultDisplay as IBasicVolumeControls; }
|
||||
// }
|
||||
|
||||
|
||||
// public IntFeedback SourcesCount { get; private set; }
|
||||
// public StringFeedback CurrentSourceName { get; private set; }
|
||||
|
||||
// public string SourceListKey { get; set; }
|
||||
// string LastSourceKey;
|
||||
|
||||
// public HuddleSpaceRoom(string key, string name)
|
||||
// : base(key, name)
|
||||
// {
|
||||
// // Return the state of the display, unless no display, then return
|
||||
// // a local or default state.
|
||||
|
||||
// RoomIsOnFeedback = new BoolFeedback(RoomCue.RoomIsOn,
|
||||
// () => DefaultDisplay != null ? DefaultDisplay.PowerIsOnFeedback.BoolValue : NoDisplayRoomIsOn);
|
||||
// IsWarmingUpFeedback = new BoolFeedback(RoomCue.RoomIsWarmingUp,
|
||||
// () => DefaultDisplay != null ? DefaultDisplay.IsWarmingUpFeedback.BoolValue : false);
|
||||
// IsCoolingDownFeedback = new BoolFeedback(RoomCue.RoomIsCoolingDown,
|
||||
// () => DefaultDisplay != null ? DefaultDisplay.IsCoolingDownFeedback.BoolValue : false);
|
||||
// RoomIsOnStandby = new BoolFeedback(RoomCue.RoomIsOnStandby,
|
||||
// () => false);
|
||||
// RoomIsOccupied = new BoolFeedback(RoomCue.RoomIsOccupied,
|
||||
// () => true);
|
||||
|
||||
// Sources = new Dictionary<uint, Device>();
|
||||
|
||||
// SourcesCount = new IntFeedback(RoomCue.SourcesCount,
|
||||
// () => Sources.Count);
|
||||
// CurrentSourceName = new StringFeedback(() => CurrentPresentationSourceInfo.PreferredName);// CurrentPresentationSource.Name);
|
||||
// //CurrentSourceType = new IntOutput(RoomCue.CurrentSourceType,
|
||||
// // () => CurrentPresentationSource.Type);
|
||||
|
||||
// UnattendedShutdownTimeMs = 60000;
|
||||
// }
|
||||
|
||||
// public override void RoomOn()
|
||||
// {
|
||||
// Debug.Console(0, this, "Room on");
|
||||
// if (IsCoolingDownFeedback.BoolValue || IsWarmingUpFeedback.BoolValue)
|
||||
// {
|
||||
// Debug.Console(2, this, "Room is warming or cooling. Ignoring room on");
|
||||
// return;
|
||||
// }
|
||||
// if (!RoomIsOnFeedback.BoolValue)
|
||||
// {
|
||||
// // Setup callback when powerOn happens
|
||||
// EventHandler<EventArgs> oneTimeHandler = null;
|
||||
// oneTimeHandler = (o, a) =>
|
||||
// {
|
||||
// Debug.Console(0, this, "RoomOn received display power on: {0}",
|
||||
// DefaultDisplay.PowerIsOnFeedback.BoolValue);
|
||||
// // if it's power on
|
||||
// if (DefaultDisplay.PowerIsOnFeedback.BoolValue)
|
||||
// {
|
||||
// (DefaultDisplay as TwoWayDisplayBase).PowerIsOnFeedback.OutputChange -= oneTimeHandler;
|
||||
// Debug.Console(1, this, "Display has powered on");
|
||||
// RoomIsOnFeedback.FireUpdate();
|
||||
// //if (callback != null)
|
||||
// // callback();
|
||||
// }
|
||||
// };
|
||||
// DefaultDisplay.PowerIsOnFeedback.OutputChange += oneTimeHandler;
|
||||
// DefaultDisplay.PowerOn();
|
||||
// }
|
||||
// }
|
||||
|
||||
// public override void RoomOff()
|
||||
// {
|
||||
// if (!RoomIsOnFeedback.BoolValue)
|
||||
// {
|
||||
// Debug.Console(2, this, "Room is already off");
|
||||
// return;
|
||||
// }
|
||||
// Debug.Console(0, this, "Room off");
|
||||
// DefaultDisplay.PowerOff();
|
||||
|
||||
// //RoomIsOn.FireUpdate(); ---Display will provide this in huddle
|
||||
// //OnPresentationSourceChange(null);
|
||||
// //CurrentPresentationSource = null;
|
||||
// }
|
||||
|
||||
|
||||
// public override void SelectSource(uint sourceNum)
|
||||
// {
|
||||
// // Run this on a separate thread
|
||||
// new CTimer(o =>
|
||||
// {
|
||||
// var routeKey = "source-" + sourceNum;
|
||||
// Debug.Console(1, this, "Run room action '{0}'", routeKey);
|
||||
// if (string.IsNullOrEmpty(SourceListKey))
|
||||
// {
|
||||
// Debug.Console(1, this, "WARNING: No source/action list defined for this room");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // Try to get the list from the config object, using SourceListKey string
|
||||
// if (!ConfigReader.ConfigObject.SourceLists.ContainsKey(SourceListKey))
|
||||
// {
|
||||
// Debug.Console(1, this, "WARNING: Config source list '{0}' not found", SourceListKey);
|
||||
// return;
|
||||
// }
|
||||
// var list = ConfigReader.ConfigObject.SourceLists[SourceListKey];
|
||||
|
||||
// // Try to get the list item by it's string key
|
||||
// if (!list.ContainsKey(routeKey))
|
||||
// {
|
||||
// Debug.Console(1, this, "WARNING: No item '{0}' found on config list '{1}'",
|
||||
// routeKey, SourceListKey);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// var item = list[routeKey];
|
||||
// Debug.Console(2, this, "Action {0} has {1} steps",
|
||||
// item.SourceKey, item.RouteList.Count);
|
||||
|
||||
// // Let's run it
|
||||
// if (routeKey.ToLower() != "roomoff")
|
||||
// LastSourceKey = routeKey;
|
||||
|
||||
// foreach (var route in item.RouteList)
|
||||
// {
|
||||
// // if there is a $defaultAll on route, run two separate
|
||||
// if (route.DestinationKey.Equals("$defaultAll", StringComparison.OrdinalIgnoreCase))
|
||||
// {
|
||||
// var tempAudio = new SourceRouteListItem
|
||||
// {
|
||||
// DestinationKey = "$defaultDisplay",
|
||||
// SourceKey = route.SourceKey,
|
||||
// Type = eRoutingSignalType.Video
|
||||
// };
|
||||
// DoRoute(tempAudio);
|
||||
|
||||
// var tempVideo = new SourceRouteListItem
|
||||
// {
|
||||
// DestinationKey = "$defaultAudio",
|
||||
// SourceKey = route.SourceKey,
|
||||
// Type = eRoutingSignalType.Audio
|
||||
// };
|
||||
// DoRoute(tempVideo);
|
||||
// continue;
|
||||
// }
|
||||
// else
|
||||
// DoRoute(route);
|
||||
// }
|
||||
|
||||
// // Set volume control on room, using default if non provided
|
||||
// IBasicVolumeControls volDev = null;
|
||||
// // Handle special cases for volume control
|
||||
// if (string.IsNullOrEmpty(item.VolumeControlKey)
|
||||
// || item.VolumeControlKey.Equals("$defaultAudio", StringComparison.OrdinalIgnoreCase))
|
||||
// volDev = DefaultVolumeControls;
|
||||
// else if (item.VolumeControlKey.Equals("$defaultDisplay", StringComparison.OrdinalIgnoreCase))
|
||||
// volDev = DefaultDisplay as IBasicVolumeControls;
|
||||
// // Or a specific device, probably rarely used.
|
||||
// else
|
||||
// {
|
||||
// var dev = DeviceManager.GetDeviceForKey(item.VolumeControlKey);
|
||||
// if (dev is IBasicVolumeControls)
|
||||
// volDev = dev as IBasicVolumeControls;
|
||||
// else if (dev is IHasVolumeDevice)
|
||||
// volDev = (dev as IHasVolumeDevice).VolumeDevice;
|
||||
// }
|
||||
// CurrentAudioDevice = volDev;
|
||||
|
||||
// // store the name and UI info for routes
|
||||
// if (item.SourceKey != null)
|
||||
// CurrentPresentationSourceInfo = item;
|
||||
// // And finally, set the "control". This will trigger event
|
||||
// //CurrentControlDevice = DeviceManager.GetDeviceForKey(item.SourceKey) as Device;
|
||||
|
||||
// RoomIsOnFeedback.FireUpdate();
|
||||
|
||||
// }, 0); // end of CTimer
|
||||
|
||||
// //Debug.Console(1, this, "Checking for source {0}", sourceNum);
|
||||
// //if (Sources.ContainsKey(sourceNum))
|
||||
// //{
|
||||
// // var newSrc = Sources[sourceNum];
|
||||
// // if (!RoomIsOn.BoolValue)
|
||||
// // {
|
||||
// // EventHandler<EventArgs> oneTimeHandler = null;
|
||||
// // oneTimeHandler = (o, a) =>
|
||||
// // {
|
||||
// // RoomIsOn.OutputChange -= oneTimeHandler;
|
||||
// // FinishSourceSelection(newSrc);
|
||||
// // };
|
||||
// // RoomIsOn.OutputChange -= oneTimeHandler;
|
||||
// // RoomIsOn.OutputChange += oneTimeHandler;
|
||||
// // RoomOn();
|
||||
// // }
|
||||
// // else FinishSourceSelection(newSrc);
|
||||
// //}
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// ///
|
||||
// /// </summary>
|
||||
// /// <param name="route"></param>
|
||||
// /// <returns></returns>
|
||||
// bool DoRoute(SourceRouteListItem route)
|
||||
// {
|
||||
// IRoutingSinkNoSwitching dest = null;
|
||||
|
||||
// if (route.DestinationKey.Equals("$defaultDisplay", StringComparison.OrdinalIgnoreCase))
|
||||
// dest = DefaultDisplay;
|
||||
// else
|
||||
// dest = DeviceManager.GetDeviceForKey(route.DestinationKey) as IRoutingSinkNoSwitching;
|
||||
|
||||
// if (dest == null)
|
||||
// {
|
||||
// Debug.Console(1, this, "Cannot route, unknown destination '{0}'", route.DestinationKey);
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// if (route.SourceKey.Equals("$off", StringComparison.OrdinalIgnoreCase))
|
||||
// {
|
||||
// dest.ReleaseRoute();
|
||||
// if (dest is IPower)
|
||||
// (dest as IPower).PowerOff();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// var source = DeviceManager.GetDeviceForKey(route.SourceKey) as IRoutingOutputs;
|
||||
// if (source == null)
|
||||
// {
|
||||
// Debug.Console(1, this, "Cannot route unknown source '{0}' to {1}", route.SourceKey, route.DestinationKey);
|
||||
// return false;
|
||||
// }
|
||||
// dest.ReleaseAndMakeRoute(source, route.Type);
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// ///// <summary>
|
||||
// /////
|
||||
// ///// </summary>
|
||||
// ///// <param name="newSrc"></param>
|
||||
// //public override void SelectSource(IPresentationSource newSrc)
|
||||
// //{
|
||||
// // if (Sources.ContainsValue(newSrc))
|
||||
// // {
|
||||
// // if (!RoomIsOn.BoolValue)
|
||||
// // {
|
||||
// // EventHandler<EventArgs> oneTimeHandler = null;
|
||||
// // oneTimeHandler = (o, a) =>
|
||||
// // {
|
||||
// // RoomIsOn.OutputChange -= oneTimeHandler;
|
||||
// // FinishSourceSelection(newSrc);
|
||||
// // };
|
||||
// // RoomIsOn.OutputChange -= oneTimeHandler;
|
||||
// // RoomIsOn.OutputChange += oneTimeHandler;
|
||||
// // RoomOn();
|
||||
// // }
|
||||
// // else FinishSourceSelection(newSrc);
|
||||
// // }
|
||||
// //}
|
||||
|
||||
// void Display_Various_OutputChange(object sender, EventArgs e)
|
||||
// {
|
||||
// // Bounce through the output changes
|
||||
// if (sender == DefaultDisplay.PowerIsOnFeedback)
|
||||
// this.RoomIsOnFeedback.FireUpdate();
|
||||
// else if (sender == DefaultDisplay.IsCoolingDownFeedback)
|
||||
// this.IsCoolingDownFeedback.FireUpdate();
|
||||
// else if (sender == DefaultDisplay.IsWarmingUpFeedback)
|
||||
// this.IsWarmingUpFeedback.FireUpdate();
|
||||
// }
|
||||
|
||||
//// void FinishSourceSelection(IPresentationSource newSource)
|
||||
//// {
|
||||
//// Debug.Console(1, this, "Selecting source {0}", newSource.Key);
|
||||
//// // Notify anyone watching source that it's leaving
|
||||
//// OnPresentationSourceChange(newSource);
|
||||
//// CurrentPresentationSource = newSource;
|
||||
//// var routeableSource = CurrentPresentationSource as IRoutingOutputs;
|
||||
//// if (routeableSource != null)
|
||||
////#warning source route type will need clarification
|
||||
//// DefaultDisplay.GetRouteToSource(routeableSource, eRoutingSignalType.AudioVideo);
|
||||
//// else
|
||||
//// Debug.Console(1, this, "New selected source {0} is not routeable", CurrentPresentationSource);
|
||||
|
||||
//// CurrentSourceName.FireUpdate();
|
||||
//// //CurrentSourceType.FireUpdate();
|
||||
//// }
|
||||
|
||||
// public override List<Feedback> Feedbacks
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// var feedbacks = new List<Feedback>
|
||||
// {
|
||||
// SourcesCount,
|
||||
// CurrentSourceName,
|
||||
// //CurrentSourceType,
|
||||
// };
|
||||
// feedbacks.AddRange(base.Feedbacks);
|
||||
// return feedbacks;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -1,45 +0,0 @@
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using System.Text;
|
||||
//using Crestron.SimplSharp;
|
||||
//using Crestron.SimplSharpPro;
|
||||
|
||||
//using PepperDash.Core;
|
||||
//using PepperDash.Essentials.Core;
|
||||
|
||||
//namespace PepperDash.Essentials
|
||||
//{
|
||||
// public class EssentialsRoomSourceChangeEventArgs : EventArgs
|
||||
// {
|
||||
// public EssentialsRoom Room { get; private set; }
|
||||
// public SourceListItem OldSource { get; private set; }
|
||||
// public SourceListItem NewSource { get; private set; }
|
||||
|
||||
// public EssentialsRoomSourceChangeEventArgs(EssentialsRoom room,
|
||||
// SourceListItem oldSource, SourceListItem newSource)
|
||||
// {
|
||||
// Room = room;
|
||||
// OldSource = oldSource;
|
||||
// NewSource = newSource;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// public class EssentialsRoomAudioDeviceChangeEventArgs : EventArgs
|
||||
// {
|
||||
// public EssentialsRoom Room { get; private set; }
|
||||
// public IBasicVolumeControls OldDevice { get; private set; }
|
||||
// public IBasicVolumeControls NewDevice { get; private set; }
|
||||
|
||||
// public EssentialsRoomAudioDeviceChangeEventArgs(EssentialsRoom room,
|
||||
// IBasicVolumeControls oldDevice, IBasicVolumeControls newDevice)
|
||||
// {
|
||||
// Room = room;
|
||||
// OldDevice = oldDevice;
|
||||
// NewDevice = newDevice;
|
||||
// }
|
||||
// }
|
||||
|
||||
//}
|
||||
Binary file not shown.
@@ -1,8 +0,0 @@
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyTitle("PepperDashEssentials")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("PepperDashEssentials")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||
[assembly: AssemblyVersion("1.0.0.*")]
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
|
||||
namespace PepperDash.Essentials
|
||||
{
|
||||
public class CotijaConfig : DeviceConfig
|
||||
{
|
||||
public string serverUrl { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,256 +0,0 @@
|
||||
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.Room.Cotija;
|
||||
|
||||
namespace PepperDash.Essentials
|
||||
{
|
||||
public class CotijaEssentialsHuddleSpaceRoomBridge
|
||||
{
|
||||
CotijaSystemController Parent;
|
||||
|
||||
public EssentialsHuddleSpaceRoom Room { get; private set; }
|
||||
|
||||
public CotijaEssentialsHuddleSpaceRoomBridge(CotijaSystemController parent, EssentialsHuddleSpaceRoom room)
|
||||
{
|
||||
Parent = parent;
|
||||
Room = room;
|
||||
|
||||
// Source Changes and room off
|
||||
Parent.AddAction(string.Format(@"/room/{0}/status",Room.Key), new Action(() => Room_RoomFullStatus(Room)));
|
||||
Parent.AddAction(string.Format(@"/room/{0}/source", Room.Key), new Action<SourceSelectMessageContent>(c => room.RunRouteAction(c.SourceSelect)));
|
||||
Parent.AddAction(string.Format(@"/room/{0}/event/masterVolumeUpBtn", Room.Key), new PressAndHoldAction(b => room.CurrentVolumeControls.VolumeUp(b)));
|
||||
Parent.AddAction(string.Format(@"/room/{0}/event/masterVolumeDownBtn", Room.Key), new PressAndHoldAction(b => room.CurrentVolumeControls.VolumeDown(b)));
|
||||
Parent.AddAction(string.Format(@"/room/{0}/event/muteToggle", Room.Key), new Action(() => room.CurrentVolumeControls.MuteToggle()));
|
||||
|
||||
Room.CurrentSingleSourceChange += new SourceInfoChangeHandler(Room_CurrentSingleSourceChange);
|
||||
|
||||
Room.CurrentVolumeDeviceChange += new EventHandler<VolumeDeviceChangeEventArgs>(Room_CurrentVolumeDeviceChange);
|
||||
|
||||
Room.OnFeedback.OutputChange += new EventHandler<EventArgs>(OnFeedback_OutputChange);
|
||||
|
||||
// Registers for initial volume events, if possible
|
||||
var currentVolumeDevice = Room.CurrentVolumeControls;
|
||||
|
||||
if (currentVolumeDevice != null)
|
||||
{
|
||||
if (currentVolumeDevice is IBasicVolumeWithFeedback)
|
||||
{
|
||||
var newDev = currentVolumeDevice as IBasicVolumeWithFeedback;
|
||||
|
||||
newDev.MuteFeedback.OutputChange += new EventHandler<EventArgs>(VolumeLevelFeedback_OutputChange);
|
||||
newDev.VolumeLevelFeedback.OutputChange += new EventHandler<EventArgs>(VolumeLevelFeedback_OutputChange);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void OnFeedback_OutputChange(object sender, EventArgs e)
|
||||
{
|
||||
/* Example message
|
||||
* {
|
||||
"type":"/room/status",
|
||||
"content": {
|
||||
"isOn": false
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
JObject roomStatus = new JObject();
|
||||
|
||||
roomStatus.Add("isOn", (sender as BoolFeedback).BoolValue);
|
||||
|
||||
JObject message = new JObject();
|
||||
|
||||
message.Add("type", "/room/status/");
|
||||
message.Add("content", roomStatus);
|
||||
|
||||
Parent.PostToServer(Room, message);
|
||||
}
|
||||
|
||||
void Room_CurrentVolumeDeviceChange(object sender, VolumeDeviceChangeEventArgs e)
|
||||
{
|
||||
if (e.OldDev is IBasicVolumeWithFeedback)
|
||||
{
|
||||
var oldDev = e.OldDev as IBasicVolumeWithFeedback;
|
||||
|
||||
oldDev.MuteFeedback.OutputChange -= VolumeLevelFeedback_OutputChange;
|
||||
oldDev.VolumeLevelFeedback.OutputChange -= VolumeLevelFeedback_OutputChange;
|
||||
}
|
||||
|
||||
if (e.NewDev is IBasicVolumeWithFeedback)
|
||||
{
|
||||
var newDev = e.NewDev as IBasicVolumeWithFeedback;
|
||||
|
||||
newDev.MuteFeedback.OutputChange += new EventHandler<EventArgs>(VolumeLevelFeedback_OutputChange);
|
||||
newDev.VolumeLevelFeedback.OutputChange += new EventHandler<EventArgs>(VolumeLevelFeedback_OutputChange);
|
||||
}
|
||||
}
|
||||
|
||||
void VolumeLevelFeedback_OutputChange(object sender, EventArgs e)
|
||||
{
|
||||
/* Example message
|
||||
* {
|
||||
"type":"/room/status",
|
||||
"content": {
|
||||
"masterVolumeLevel": 12345,
|
||||
"masterVolumeMuteState": false
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
var huddleRoom = Room as EssentialsHuddleSpaceRoom;
|
||||
|
||||
if(huddleRoom.CurrentVolumeControls is IBasicVolumeWithFeedback)
|
||||
{
|
||||
JObject roomStatus = new JObject();
|
||||
|
||||
if (huddleRoom.CurrentVolumeControls is IBasicVolumeWithFeedback)
|
||||
{
|
||||
var currentVolumeConstrols = huddleRoom.CurrentVolumeControls as IBasicVolumeWithFeedback;
|
||||
roomStatus.Add("masterVolumeLevel", currentVolumeConstrols.VolumeLevelFeedback.IntValue);
|
||||
roomStatus.Add("masterVolumeMuteState", currentVolumeConstrols.MuteFeedback.BoolValue);
|
||||
}
|
||||
|
||||
JObject message = new JObject();
|
||||
|
||||
message.Add("type", "/room/status/");
|
||||
message.Add("content", roomStatus);
|
||||
|
||||
Parent.PostToServer(Room, message);
|
||||
}
|
||||
}
|
||||
|
||||
void Room_CurrentSingleSourceChange(EssentialsRoomBase room, PepperDash.Essentials.Core.SourceListItem info, ChangeType type)
|
||||
{
|
||||
/* 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);
|
||||
}
|
||||
|
||||
JObject roomStatus = new JObject();
|
||||
|
||||
var huddleRoom = room as EssentialsHuddleSpaceRoom;
|
||||
roomStatus.Add("selectedSourceKey", huddleRoom.CurrentSourceInfoKey);
|
||||
|
||||
JObject message = new JObject();
|
||||
|
||||
message.Add("type", "/room/status/");
|
||||
message.Add("content", roomStatus);
|
||||
|
||||
Parent.PostToServer(Room, 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Posts the full status of the room to the server
|
||||
/// </summary>
|
||||
/// <param name="room"></param>
|
||||
void Room_RoomFullStatus(EssentialsRoomBase room)
|
||||
{
|
||||
/* Example message
|
||||
* {
|
||||
"type":"/room/status",
|
||||
"content": {
|
||||
"selectedSourceKey": "off",
|
||||
"isOn": false,
|
||||
"masterVolumeLevel": 50,
|
||||
"masterVolumeMuteState": false
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
JObject roomStatus = new JObject();
|
||||
|
||||
var huddleRoom = room as EssentialsHuddleSpaceRoom;
|
||||
roomStatus.Add("isOn", huddleRoom.OnFeedback.BoolValue);
|
||||
roomStatus.Add("selectedSourceKey", huddleRoom.CurrentSourceInfoKey);
|
||||
|
||||
|
||||
if(huddleRoom.CurrentVolumeControls is IBasicVolumeWithFeedback)
|
||||
{
|
||||
var currentVolumeConstrols = huddleRoom.CurrentVolumeControls as IBasicVolumeWithFeedback;
|
||||
roomStatus.Add("masterVolumeLevel", currentVolumeConstrols.VolumeLevelFeedback.IntValue);
|
||||
roomStatus.Add("masterVolumeMuteState", currentVolumeConstrols.MuteFeedback.BoolValue);
|
||||
}
|
||||
|
||||
JObject message = new JObject();
|
||||
|
||||
message.Add("type", "/room/status/");
|
||||
message.Add("content", roomStatus);
|
||||
|
||||
Parent.PostToServer(Room, message);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class SourceSelectMessageContent
|
||||
{
|
||||
public string Destination { get; set; }
|
||||
public string SourceSelect { get; set; }
|
||||
}
|
||||
|
||||
public delegate void PressAndHoldAction(bool b);
|
||||
|
||||
}
|
||||
@@ -1,445 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharp.CrestronIO;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharp.Net.Http;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
|
||||
namespace PepperDash.Essentials
|
||||
{
|
||||
public class CotijaSystemController : Device
|
||||
{
|
||||
GenericHttpSseClient SseClient;
|
||||
|
||||
CCriticalSection FileLock;
|
||||
|
||||
CotijaConfig Config;
|
||||
|
||||
HttpClient Client;
|
||||
|
||||
Dictionary<string, Object> ActionDictionary = new Dictionary<string, Object>(StringComparer.InvariantCultureIgnoreCase);
|
||||
|
||||
Dictionary<string, CTimer> PushedActions = new Dictionary<string, CTimer>();
|
||||
|
||||
CTimer ServerHeartbeat;
|
||||
|
||||
long ServerHeartbeatInterval = 20000;
|
||||
|
||||
CTimer ServerReconnect;
|
||||
|
||||
long ServerReconnectInterval = 5000;
|
||||
|
||||
string SystemUuid;
|
||||
|
||||
public List<CotijaEssentialsHuddleSpaceRoomBridge> CotijaRooms { get; private set; }
|
||||
|
||||
long ButtonHeartbeatInterval = 1000;
|
||||
|
||||
public CotijaSystemController(string key, string name, CotijaConfig config) : base(key, name)
|
||||
{
|
||||
Config = config;
|
||||
|
||||
CotijaRooms = new List<CotijaEssentialsHuddleSpaceRoomBridge>();
|
||||
|
||||
CrestronConsole.AddNewConsoleCommand(RegisterSystemToServer, "InitializeHttpClient", "Initializes a new HTTP client connection to a specified URL", ConsoleAccessLevelEnum.AccessOperator);
|
||||
CrestronConsole.AddNewConsoleCommand(DisconnectSseClient, "CloseHttpClient", "Closes the active HTTP client", ConsoleAccessLevelEnum.AccessOperator);
|
||||
|
||||
AddPostActivationAction(() => RegisterSystemToServer(null));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an action to the dictionary
|
||||
/// </summary>
|
||||
/// <param name="key">The path of the API command</param>
|
||||
/// <param name="action">The action to be triggered by the commmand</param>
|
||||
public void AddAction(string key, object action)
|
||||
{
|
||||
if (!ActionDictionary.ContainsKey(key))
|
||||
{
|
||||
ActionDictionary.Add(key, action);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Console(1, this, "Cannot add action with key '{0}' because key already exists in ActionDictionary.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes and action from the dictionary
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
public void RemoveAction(string key)
|
||||
{
|
||||
if (ActionDictionary.ContainsKey(key))
|
||||
ActionDictionary.Remove(key);
|
||||
}
|
||||
|
||||
void ReconnectToServer(object o)
|
||||
{
|
||||
RegisterSystemToServer(null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers the room with the server
|
||||
/// </summary>
|
||||
/// <param name="url">URL of the server, including the port number, if not 80. Format: "serverUrlOrIp:port"</param>
|
||||
void RegisterSystemToServer(string command)
|
||||
{
|
||||
try
|
||||
{
|
||||
string filePath = string.Format(@"\NVRAM\Program{0}\configurationFile.json", Global.ControlSystem.ProgramNumber);
|
||||
string postBody = null;
|
||||
|
||||
if (string.IsNullOrEmpty(filePath))
|
||||
{
|
||||
Debug.Console(0, this, "Error reading file. No path specified.");
|
||||
return;
|
||||
}
|
||||
|
||||
FileLock = new CCriticalSection();
|
||||
|
||||
if (FileLock.TryEnter())
|
||||
{
|
||||
Debug.Console(1, this, "Reading configuration file to extract system UUID...");
|
||||
|
||||
postBody = File.ReadToEnd(filePath, Encoding.ASCII);
|
||||
|
||||
Debug.Console(2, this, "{0}", postBody);
|
||||
|
||||
FileLock.Leave();
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(postBody))
|
||||
{
|
||||
Debug.Console(1, "Post Body is null or empty");
|
||||
}
|
||||
else
|
||||
{
|
||||
Client = new HttpClient();
|
||||
|
||||
HttpClientRequest request = new HttpClientRequest();
|
||||
|
||||
Client.Verbose = true;
|
||||
Client.KeepAlive = true;
|
||||
|
||||
SystemUuid = Essentials.ConfigReader.ConfigObject.SystemUuid;
|
||||
|
||||
string url = string.Format("http://{0}/api/system/join/{1}", Config.serverUrl, SystemUuid);
|
||||
|
||||
request.Url.Parse(url);
|
||||
request.RequestType = RequestType.Post;
|
||||
request.Header.SetHeaderValue("Content-Type", "application/json");
|
||||
request.ContentString = postBody;
|
||||
|
||||
Client.DispatchAsync(request, PostConnectionCallback);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(0, this, "Error Initilizing Room: {0}", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Posts a message to the server from a room
|
||||
/// </summary>
|
||||
/// <param name="room">room from which the message originates</param>
|
||||
/// <param name="o">object to be serialized and sent in post body</param>
|
||||
public void PostToServer(EssentialsRoomBase room, JObject o)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Client == null)
|
||||
Client = new HttpClient();
|
||||
|
||||
//HttpClient client = new HttpClient();
|
||||
|
||||
HttpClientRequest request = new HttpClientRequest();
|
||||
|
||||
Client.Verbose = true;
|
||||
Client.KeepAlive = true;
|
||||
|
||||
string url = string.Format("http://{0}/api/room/{1}/status", Config.serverUrl, string.Format("{0}--{1}", SystemUuid, room.Key));
|
||||
|
||||
request.Url.Parse(url);
|
||||
request.RequestType = RequestType.Post;
|
||||
request.Header.SetHeaderValue("Content-Type", "application/json");
|
||||
request.KeepAlive = true;
|
||||
|
||||
// Ignore any null objects when serializing and remove formatting
|
||||
string ignored = JsonConvert.SerializeObject(o, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
|
||||
request.ContentString = ignored;
|
||||
|
||||
Debug.Console(1, this, "Posting to '{0}':\n{1}", url, request.ContentString);
|
||||
|
||||
Client.DispatchAsync(request, (r, err) => { if (r != null) { Debug.Console(1, this, "Status Response Code: {0}", r.Code); } });
|
||||
|
||||
StartReconnectTimer(ServerReconnectInterval, ServerReconnectInterval);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Debug.Console(1, this, "Error Posting to Server: {0}", e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disconnects the SSE Client and stops the heartbeat timer
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
void DisconnectSseClient(string command)
|
||||
{
|
||||
if(SseClient != null)
|
||||
SseClient.Disconnect();
|
||||
|
||||
if (ServerHeartbeat != null)
|
||||
{
|
||||
ServerHeartbeat.Stop();
|
||||
|
||||
ServerHeartbeat = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The callback that fires when we get a response from our registration attempt
|
||||
/// </summary>
|
||||
/// <param name="resp"></param>
|
||||
/// <param name="err"></param>
|
||||
void PostConnectionCallback(HttpClientResponse resp, HTTP_CALLBACK_ERROR err)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (resp != null && resp.Code == 200)
|
||||
{
|
||||
if(ServerReconnect != null)
|
||||
{
|
||||
ServerReconnect.Stop();
|
||||
|
||||
ServerReconnect = null;
|
||||
}
|
||||
|
||||
if (SseClient == null)
|
||||
{
|
||||
ConnectSseClient(null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (resp != null)
|
||||
Debug.Console(1, this, "Response from server: {0}\n{1}", resp.Code, err);
|
||||
else
|
||||
Debug.Console(1, this, "Null response received from server.");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(1, this, "Error Initializing SSE Client: {0}", e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes when we don't get a heartbeat message in time. Triggers reconnect.
|
||||
/// </summary>
|
||||
/// <param name="o"></param>
|
||||
void HeartbeatExpired(object o)
|
||||
{
|
||||
if (ServerHeartbeat != null)
|
||||
{
|
||||
Debug.Console(1, this, "Heartbeat Timer Expired.");
|
||||
|
||||
ServerHeartbeat.Stop();
|
||||
|
||||
ServerHeartbeat = null;
|
||||
}
|
||||
|
||||
StartReconnectTimer(ServerReconnectInterval, ServerReconnectInterval);
|
||||
}
|
||||
|
||||
void StartReconnectTimer(long dueTime, long repeatTime)
|
||||
{
|
||||
// Start the reconnect timer
|
||||
ServerReconnect = new CTimer(ReconnectToServer, null, dueTime, repeatTime);
|
||||
|
||||
ServerReconnect.Reset(dueTime, repeatTime);
|
||||
}
|
||||
|
||||
void StartHearbeatTimer(long dueTime, long repeatTime)
|
||||
{
|
||||
if (ServerHeartbeat == null)
|
||||
{
|
||||
ServerHeartbeat = new CTimer(HeartbeatExpired, null, dueTime, repeatTime);
|
||||
|
||||
Debug.Console(2, this, "Heartbeat Timer Started.");
|
||||
}
|
||||
|
||||
ServerHeartbeat.Reset(dueTime, repeatTime);
|
||||
|
||||
Debug.Console(2, this, "Heartbeat Timer Reset.");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Connects the SSE Client
|
||||
/// </summary>
|
||||
/// <param name="o"></param>
|
||||
void ConnectSseClient(object o)
|
||||
{
|
||||
Debug.Console(0, this, "Initializing SSE Client.");
|
||||
|
||||
if (SseClient == null)
|
||||
{
|
||||
SseClient = new GenericHttpSseClient(string.Format("{0}-SseClient", Key), Name);
|
||||
|
||||
CommunicationGather LineGathered = new CommunicationGather(SseClient, "\x0d\x0a");
|
||||
|
||||
LineGathered.LineReceived += new EventHandler<GenericCommMethodReceiveTextArgs>(LineGathered_LineReceived);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SseClient.IsConnected)
|
||||
{
|
||||
SseClient.Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
string uuid = Essentials.ConfigReader.ConfigObject.SystemUuid;
|
||||
|
||||
SseClient.Url = string.Format("http://{0}/api/system/stream/{1}", Config.serverUrl, uuid);
|
||||
|
||||
SseClient.Connect();
|
||||
}
|
||||
|
||||
|
||||
void LineGathered_LineReceived(object sender, GenericCommMethodReceiveTextArgs e)
|
||||
{
|
||||
//Debug.Console(1, this, "Received from Server: '{0}'", e.Text);
|
||||
|
||||
if(e.Text.IndexOf("data:") > -1)
|
||||
{
|
||||
var message = e.Text.Substring(6);
|
||||
|
||||
Debug.Console(1, this, "Message: '{0}'", message);
|
||||
|
||||
try
|
||||
{
|
||||
var messageObj = JObject.Parse(message);
|
||||
|
||||
var type = messageObj["type"].Value<string>();
|
||||
|
||||
if (type == "hello")
|
||||
{
|
||||
StartHearbeatTimer(ServerHeartbeatInterval, ServerHeartbeatInterval);
|
||||
}
|
||||
else if (type == "/system/heartbeat")
|
||||
{
|
||||
StartHearbeatTimer(ServerHeartbeatInterval, ServerHeartbeatInterval);
|
||||
}
|
||||
else if (type == "close")
|
||||
{
|
||||
SseClient.Disconnect();
|
||||
|
||||
// Start the reconnect timer
|
||||
ServerReconnect = new CTimer(ConnectSseClient, null, ServerReconnectInterval, ServerReconnectInterval);
|
||||
|
||||
ServerReconnect.Reset(ServerReconnectInterval, ServerReconnectInterval);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check path against Action dictionary
|
||||
if (ActionDictionary.ContainsKey(type))
|
||||
{
|
||||
var action = ActionDictionary[type];
|
||||
|
||||
if (action is Action)
|
||||
{
|
||||
(action as Action)();
|
||||
}
|
||||
else if (action is PressAndHoldAction)
|
||||
{
|
||||
var stateString = messageObj["content"]["state"].Value<string>();
|
||||
|
||||
// Look for a button press event
|
||||
if (!string.IsNullOrEmpty(stateString))
|
||||
{
|
||||
switch (stateString)
|
||||
{
|
||||
case "true":
|
||||
{
|
||||
if (!PushedActions.ContainsKey(type))
|
||||
{
|
||||
PushedActions.Add(type, new CTimer(o =>
|
||||
{
|
||||
(action as PressAndHoldAction)(false);
|
||||
PushedActions.Remove(type);
|
||||
}, null, ButtonHeartbeatInterval, ButtonHeartbeatInterval));
|
||||
}
|
||||
// Maybe add an else to reset the timer
|
||||
break;
|
||||
}
|
||||
case "held":
|
||||
{
|
||||
if (!PushedActions.ContainsKey(type))
|
||||
{
|
||||
PushedActions[type].Reset(ButtonHeartbeatInterval, ButtonHeartbeatInterval);
|
||||
}
|
||||
return;
|
||||
}
|
||||
case "false":
|
||||
{
|
||||
if (PushedActions.ContainsKey(type))
|
||||
{
|
||||
PushedActions[type].Stop();
|
||||
PushedActions.Remove(type);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
(action as PressAndHoldAction)(stateString == "true");
|
||||
}
|
||||
}
|
||||
else if (action is Action<bool>)
|
||||
{
|
||||
var stateString = messageObj["content"]["state"].Value<string>();
|
||||
|
||||
if (!string.IsNullOrEmpty(stateString))
|
||||
{
|
||||
(action as Action<bool>)(stateString == "true");
|
||||
}
|
||||
}
|
||||
else if (action is Action<ushort>)
|
||||
{
|
||||
(action as Action<ushort>)(messageObj["content"]["value"].Value<ushort>());
|
||||
}
|
||||
else if (action is Action<string>)
|
||||
{
|
||||
(action as Action<string>)(messageObj["content"]["value"].Value<string>());
|
||||
}
|
||||
else if (action is Action<SourceSelectMessageContent>)
|
||||
{
|
||||
(action as Action<SourceSelectMessageContent>)(messageObj["content"]
|
||||
.ToObject<SourceSelectMessageContent>());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
Debug.Console(1, this, "Unable to parse message: {0}", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,296 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
|
||||
namespace PepperDash.Essentials
|
||||
{
|
||||
public class EssentialsHuddleSpaceRoom : EssentialsRoomBase, IHasCurrentSourceInfoChange
|
||||
{
|
||||
public event EventHandler<VolumeDeviceChangeEventArgs> CurrentVolumeDeviceChange;
|
||||
public event SourceInfoChangeHandler CurrentSingleSourceChange;
|
||||
|
||||
public EssentialsRoomPropertiesConfig Config { get; private set; }
|
||||
|
||||
public IRoutingSinkWithSwitching DefaultDisplay { get; private set; }
|
||||
public IRoutingSinkNoSwitching DefaultAudioDevice { get; private set; }
|
||||
public IBasicVolumeControls DefaultVolumeControls { get; private set; }
|
||||
|
||||
public bool ExcludeFromGlobalFunctions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The config name of the source list
|
||||
/// </summary>
|
||||
public string SourceListKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If room is off, enables power on to last source. Default true
|
||||
/// </summary>
|
||||
public bool EnablePowerOnToLastSource { get; set; }
|
||||
string LastSourceKey;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public IBasicVolumeControls CurrentVolumeControls
|
||||
{
|
||||
get { return _CurrentAudioDevice; }
|
||||
set
|
||||
{
|
||||
if (value == _CurrentAudioDevice) return;
|
||||
|
||||
var oldDev = _CurrentAudioDevice;
|
||||
// derigister this room from the device, if it can
|
||||
if (oldDev is IInUseTracking)
|
||||
(oldDev as IInUseTracking).InUseTracker.RemoveUser(this, "audio");
|
||||
var handler = CurrentVolumeDeviceChange;
|
||||
if (handler != null)
|
||||
CurrentVolumeDeviceChange(this, new VolumeDeviceChangeEventArgs(oldDev, value, ChangeType.WillChange));
|
||||
_CurrentAudioDevice = value;
|
||||
if (handler != null)
|
||||
CurrentVolumeDeviceChange(this, new VolumeDeviceChangeEventArgs(oldDev, value, ChangeType.DidChange));
|
||||
// register this room with new device, if it can
|
||||
if (_CurrentAudioDevice is IInUseTracking)
|
||||
(_CurrentAudioDevice as IInUseTracking).InUseTracker.AddUser(this, "audio");
|
||||
}
|
||||
}
|
||||
IBasicVolumeControls _CurrentAudioDevice;
|
||||
|
||||
/// <summary>
|
||||
/// The SourceListItem last run - containing names and icons
|
||||
/// </summary>
|
||||
public SourceListItem CurrentSourceInfo
|
||||
{
|
||||
get { return _CurrentSourceInfo; }
|
||||
private set
|
||||
{
|
||||
if (value == _CurrentSourceInfo) return;
|
||||
|
||||
var handler = CurrentSingleSourceChange;
|
||||
// remove from in-use tracker, if so equipped
|
||||
if(_CurrentSourceInfo != null && _CurrentSourceInfo.SourceDevice is IInUseTracking)
|
||||
(_CurrentSourceInfo.SourceDevice as IInUseTracking).InUseTracker.RemoveUser(this, "control");
|
||||
|
||||
if (handler != null)
|
||||
handler(this, _CurrentSourceInfo, ChangeType.WillChange);
|
||||
|
||||
_CurrentSourceInfo = value;
|
||||
|
||||
// add to in-use tracking
|
||||
if (_CurrentSourceInfo != null && _CurrentSourceInfo.SourceDevice is IInUseTracking)
|
||||
(_CurrentSourceInfo.SourceDevice as IInUseTracking).InUseTracker.AddUser(this, "control");
|
||||
if (handler != null)
|
||||
handler(this, _CurrentSourceInfo, ChangeType.DidChange);
|
||||
}
|
||||
}
|
||||
SourceListItem _CurrentSourceInfo;
|
||||
|
||||
public string CurrentSourceInfoKey { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public BoolFeedback OnFeedback { 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)
|
||||
{
|
||||
Config = config;
|
||||
DefaultDisplay = defaultDisplay;
|
||||
DefaultAudioDevice = defaultAudio;
|
||||
if (defaultAudio is IBasicVolumeControls)
|
||||
DefaultVolumeControls = defaultAudio as IBasicVolumeControls;
|
||||
else if (defaultAudio is IHasVolumeDevice)
|
||||
DefaultVolumeControls = (defaultAudio as IHasVolumeDevice).VolumeDevice;
|
||||
CurrentVolumeControls = DefaultVolumeControls;
|
||||
|
||||
OnFeedback = new BoolFeedback(() =>
|
||||
{ return CurrentSourceInfo != null
|
||||
&& CurrentSourceInfo.Type == eSourceListItemType.Route; });
|
||||
SourceListKey = "default";
|
||||
EnablePowerOnToLastSource = true;
|
||||
}
|
||||
|
||||
public void RunRouteAction(string routeKey)
|
||||
{
|
||||
RunRouteAction(routeKey, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a source from config list SourceListKey and dynamically build and executes the
|
||||
/// route or commands
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
public void RunRouteAction(string routeKey, Action successCallback)
|
||||
{
|
||||
// Run this on a separate thread
|
||||
new CTimer(o =>
|
||||
{
|
||||
Debug.Console(1, this, "Run room action '{0}'", routeKey);
|
||||
var dict = ConfigReader.ConfigObject.GetSourceListForKey(SourceListKey);
|
||||
if(dict == null)
|
||||
{
|
||||
Debug.Console(1, this, "WARNING: Config source list '{0}' not found", SourceListKey);
|
||||
return;
|
||||
}
|
||||
|
||||
// Try to get the list item by it's string key
|
||||
if (!dict.ContainsKey(routeKey))
|
||||
{
|
||||
Debug.Console(1, this, "WARNING: No item '{0}' found on config list '{1}'",
|
||||
routeKey, SourceListKey);
|
||||
return;
|
||||
}
|
||||
|
||||
var item = dict[routeKey];
|
||||
Debug.Console(2, this, "Action {0} has {1} steps",
|
||||
item.SourceKey, item.RouteList.Count);
|
||||
|
||||
// Let's run it
|
||||
if (routeKey.ToLower() != "roomoff")
|
||||
{
|
||||
LastSourceKey = routeKey;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentSourceInfoKey = null;
|
||||
}
|
||||
|
||||
foreach (var route in item.RouteList)
|
||||
{
|
||||
// if there is a $defaultAll on route, run two separate
|
||||
if (route.DestinationKey.Equals("$defaultAll", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var tempAudio = new SourceRouteListItem
|
||||
{
|
||||
DestinationKey = "$defaultDisplay",
|
||||
SourceKey = route.SourceKey,
|
||||
Type = eRoutingSignalType.Video
|
||||
};
|
||||
DoRoute(tempAudio);
|
||||
|
||||
var tempVideo = new SourceRouteListItem
|
||||
{
|
||||
DestinationKey = "$defaultAudio",
|
||||
SourceKey = route.SourceKey,
|
||||
Type = eRoutingSignalType.Audio
|
||||
};
|
||||
DoRoute(tempVideo);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
DoRoute(route);
|
||||
}
|
||||
|
||||
// Set volume control on room, using default if non provided
|
||||
IBasicVolumeControls volDev = null;
|
||||
// Handle special cases for volume control
|
||||
if (string.IsNullOrEmpty(item.VolumeControlKey)
|
||||
|| item.VolumeControlKey.Equals("$defaultAudio", StringComparison.OrdinalIgnoreCase))
|
||||
volDev = DefaultVolumeControls;
|
||||
else if (item.VolumeControlKey.Equals("$defaultDisplay", StringComparison.OrdinalIgnoreCase))
|
||||
volDev = DefaultDisplay as IBasicVolumeControls;
|
||||
// Or a specific device, probably rarely used.
|
||||
else
|
||||
{
|
||||
var dev = DeviceManager.GetDeviceForKey(item.VolumeControlKey);
|
||||
if (dev is IBasicVolumeControls)
|
||||
volDev = dev as IBasicVolumeControls;
|
||||
else if (dev is IHasVolumeDevice)
|
||||
volDev = (dev as IHasVolumeDevice).VolumeDevice;
|
||||
}
|
||||
CurrentVolumeControls = volDev;
|
||||
|
||||
// store the name and UI info for routes
|
||||
if (item.SourceKey != null)
|
||||
{
|
||||
CurrentSourceInfoKey = routeKey;
|
||||
CurrentSourceInfo = item;
|
||||
}
|
||||
// And finally, set the "control". This will trigger event
|
||||
//CurrentControlDevice = DeviceManager.GetDeviceForKey(item.SourceKey) as Device;
|
||||
|
||||
OnFeedback.FireUpdate();
|
||||
|
||||
// report back when done
|
||||
if (successCallback != null)
|
||||
successCallback();
|
||||
|
||||
#warning Need to again handle special commands in here.
|
||||
|
||||
}, 0); // end of CTimer
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Will power the room on with the last-used source
|
||||
/// </summary>
|
||||
public void PowerOnToDefaultOrLastSource()
|
||||
{
|
||||
if (!EnablePowerOnToLastSource || LastSourceKey == null)
|
||||
return;
|
||||
RunRouteAction(LastSourceKey);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="route"></param>
|
||||
/// <returns></returns>
|
||||
bool DoRoute(SourceRouteListItem route)
|
||||
{
|
||||
IRoutingSinkNoSwitching dest = null;
|
||||
|
||||
if (route.DestinationKey.Equals("$defaultaudio", StringComparison.OrdinalIgnoreCase))
|
||||
dest = DefaultAudioDevice;
|
||||
else if (route.DestinationKey.Equals("$defaultDisplay", StringComparison.OrdinalIgnoreCase))
|
||||
dest = DefaultDisplay;
|
||||
else
|
||||
dest = DeviceManager.GetDeviceForKey(route.DestinationKey) as IRoutingSinkNoSwitching;
|
||||
|
||||
if (dest == null)
|
||||
{
|
||||
Debug.Console(1, this, "Cannot route, unknown destination '{0}'", route.DestinationKey);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (route.SourceKey.Equals("$off", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
dest.ReleaseRoute();
|
||||
if (dest is IPower)
|
||||
(dest as IPower).PowerOff();
|
||||
}
|
||||
else
|
||||
{
|
||||
var source = DeviceManager.GetDeviceForKey(route.SourceKey) as IRoutingOutputs;
|
||||
if (source == null)
|
||||
{
|
||||
Debug.Console(1, this, "Cannot route unknown source '{0}' to {1}", route.SourceKey, route.DestinationKey);
|
||||
return false;
|
||||
}
|
||||
dest.ReleaseAndMakeRoute(source, route.Type);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs "roomOff" action on all rooms not set to ExcludeFromGlobalFunctions
|
||||
/// </summary>
|
||||
public static void AllRoomsOff()
|
||||
{
|
||||
var allRooms = DeviceManager.AllDevices.Where(d =>
|
||||
d is EssentialsHuddleSpaceRoom && !(d as EssentialsHuddleSpaceRoom).ExcludeFromGlobalFunctions);
|
||||
foreach (var room in allRooms)
|
||||
(room as EssentialsHuddleSpaceRoom).RunRouteAction("roomOff");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,414 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
|
||||
namespace PepperDash.Essentials
|
||||
{
|
||||
public class EssentialsPresentationRoom : EssentialsRoomBase, IHasCurrentSourceInfoChange
|
||||
{
|
||||
public event EventHandler<VolumeDeviceChangeEventArgs> CurrentVolumeDeviceChange;
|
||||
public event SourceInfoChangeHandler CurrentSingleSourceChange;
|
||||
public event SourceInfoChangeHandler CurrentDisplay1SourceChange;
|
||||
public event SourceInfoChangeHandler CurrentDisplay2SourceChange;
|
||||
|
||||
public EssentialsPresentationRoomPropertiesConfig Config { get; private set; }
|
||||
|
||||
public Dictionary<uint, IRoutingSinkNoSwitching> Displays { get; private set; }
|
||||
|
||||
public IRoutingSinkNoSwitching DefaultAudioDevice { get; private set; }
|
||||
public IBasicVolumeControls DefaultVolumeControls { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The config name of the source list
|
||||
/// </summary>
|
||||
public string SourceListKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If room is off, enables power on to last source. Default true
|
||||
/// </summary>
|
||||
public bool EnablePowerOnToLastSource { get; set; }
|
||||
string LastSourceKey;
|
||||
|
||||
public enum eVideoRoutingMode
|
||||
{
|
||||
SelectSourceSelectDisplay, SourceToAllDisplays
|
||||
}
|
||||
|
||||
public eVideoRoutingMode VideoRoutingMode { get; set; }
|
||||
|
||||
public enum eAudioRoutingMode
|
||||
{
|
||||
AudioFollowsLastVideo, SelectAudioFromDisplay
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public IBasicVolumeControls CurrentVolumeControls
|
||||
{
|
||||
get { return _CurrentAudioDevice; }
|
||||
set
|
||||
{
|
||||
if (value == _CurrentAudioDevice) return;
|
||||
|
||||
var oldDev = _CurrentAudioDevice;
|
||||
// derigister this room from the device, if it can
|
||||
if (oldDev is IInUseTracking)
|
||||
(oldDev as IInUseTracking).InUseTracker.RemoveUser(this, "audio");
|
||||
var handler = CurrentVolumeDeviceChange;
|
||||
if (handler != null)
|
||||
CurrentVolumeDeviceChange(this, new VolumeDeviceChangeEventArgs(oldDev, value, ChangeType.WillChange));
|
||||
_CurrentAudioDevice = value;
|
||||
if (handler != null)
|
||||
CurrentVolumeDeviceChange(this, new VolumeDeviceChangeEventArgs(oldDev, value, ChangeType.DidChange));
|
||||
// register this room with new device, if it can
|
||||
if (_CurrentAudioDevice is IInUseTracking)
|
||||
(_CurrentAudioDevice as IInUseTracking).InUseTracker.AddUser(this, "audio");
|
||||
}
|
||||
}
|
||||
IBasicVolumeControls _CurrentAudioDevice;
|
||||
|
||||
/// <summary>
|
||||
/// The SourceListItem last run - containing names and icons. The complex setter is
|
||||
/// to add/remove this room to the source's InUseTracking, if it is capable
|
||||
/// </summary>
|
||||
public SourceListItem CurrentSingleSourceInfo
|
||||
{
|
||||
get { return _CurrentSingleSourceInfo; }
|
||||
private set
|
||||
{
|
||||
if (value == _CurrentSingleSourceInfo) return;
|
||||
|
||||
var handler = CurrentSingleSourceChange;
|
||||
// remove from in-use tracker, if so equipped
|
||||
if(_CurrentSingleSourceInfo != null && _CurrentSingleSourceInfo.SourceDevice is IInUseTracking)
|
||||
(_CurrentSingleSourceInfo.SourceDevice as IInUseTracking).InUseTracker.RemoveUser(this, "control");
|
||||
|
||||
if (handler != null)
|
||||
handler(this, _CurrentSingleSourceInfo, ChangeType.WillChange);
|
||||
|
||||
_CurrentSingleSourceInfo = value;
|
||||
|
||||
// add to in-use tracking
|
||||
if (_CurrentSingleSourceInfo != null && _CurrentSingleSourceInfo.SourceDevice is IInUseTracking)
|
||||
(_CurrentSingleSourceInfo.SourceDevice as IInUseTracking).InUseTracker.AddUser(this, "control");
|
||||
if (handler != null)
|
||||
handler(this, _CurrentSingleSourceInfo, ChangeType.DidChange);
|
||||
}
|
||||
}
|
||||
SourceListItem _CurrentSingleSourceInfo;
|
||||
|
||||
public SourceListItem Display1SourceInfo
|
||||
{
|
||||
get { return _Display1SourceInfo; }
|
||||
set
|
||||
{
|
||||
if (value == _Display1SourceInfo) return;
|
||||
|
||||
var handler = CurrentDisplay1SourceChange;
|
||||
if (handler != null)
|
||||
handler(this, _Display1SourceInfo, ChangeType.WillChange);
|
||||
|
||||
_Display1SourceInfo = value;
|
||||
|
||||
if (handler != null)
|
||||
handler(this, _Display1SourceInfo, ChangeType.DidChange);
|
||||
}
|
||||
}
|
||||
SourceListItem _Display1SourceInfo;
|
||||
|
||||
public SourceListItem Display2SourceInfo
|
||||
{
|
||||
get { return _Display2SourceInfo; }
|
||||
set
|
||||
{
|
||||
if (value == _Display2SourceInfo) return;
|
||||
|
||||
var handler = CurrentDisplay2SourceChange;
|
||||
if (handler != null)
|
||||
handler(this, _Display2SourceInfo, ChangeType.WillChange);
|
||||
|
||||
_Display2SourceInfo = value;
|
||||
|
||||
if (handler != null)
|
||||
handler(this, _Display2SourceInfo, ChangeType.DidChange);
|
||||
}
|
||||
}
|
||||
SourceListItem _Display2SourceInfo;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public BoolFeedback OnFeedback { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// If an audio dialer is available for this room
|
||||
/// </summary>
|
||||
public bool HasAudioDialer { get { return false; } }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="name"></param>
|
||||
public EssentialsPresentationRoom(string key, string name,
|
||||
Dictionary<uint, IRoutingSinkNoSwitching> displays,
|
||||
IBasicVolumeWithFeedback defaultVolume, EssentialsPresentationRoomPropertiesConfig config)
|
||||
: base(key, name)
|
||||
{
|
||||
Config = config;
|
||||
Displays = displays;
|
||||
|
||||
DefaultVolumeControls = defaultVolume;
|
||||
CurrentVolumeControls = defaultVolume;
|
||||
|
||||
//DefaultAudioDevice = defaultAudio;
|
||||
//if (defaultAudio is IBasicVolumeControls)
|
||||
// DefaultVolumeControls = defaultAudio as IBasicVolumeControls;
|
||||
//else if (defaultAudio is IHasVolumeDevice)
|
||||
// DefaultVolumeControls = (defaultAudio as IHasVolumeDevice).VolumeDevice;
|
||||
|
||||
OnFeedback = new BoolFeedback(() =>
|
||||
{ return (CurrentSingleSourceInfo != null
|
||||
&& CurrentSingleSourceInfo.Type != eSourceListItemType.Off)
|
||||
|| (Display1SourceInfo != null
|
||||
&& Display1SourceInfo.Type != eSourceListItemType.Off)
|
||||
|| (Display2SourceInfo != null
|
||||
&& Display2SourceInfo.Type != eSourceListItemType.Off);
|
||||
|
||||
});
|
||||
SourceListKey = "default";
|
||||
EnablePowerOnToLastSource = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run the same source to all destinations
|
||||
/// </summary>
|
||||
/// <param name="sourceItem"></param>
|
||||
public void RouteSourceToAllDestinations(SourceListItem sourceItem)
|
||||
{
|
||||
if (Config.Volumes.Master != null)
|
||||
{
|
||||
var audioDev = DeviceManager.GetDeviceForKey(Config.Volumes.Master.DeviceKey);
|
||||
if (audioDev is IBasicVolumeWithFeedback)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var display in Displays.Values)
|
||||
{
|
||||
if (sourceItem != null)
|
||||
DoVideoRoute(sourceItem.SourceKey, display.Key);
|
||||
else
|
||||
DoVideoRoute("$off", display.Key);
|
||||
}
|
||||
Display1SourceInfo = sourceItem;
|
||||
Display2SourceInfo = sourceItem;
|
||||
CurrentSingleSourceInfo = sourceItem;
|
||||
OnFeedback.FireUpdate();
|
||||
}
|
||||
|
||||
public void SourceToDisplay1(SourceListItem sourceItem)
|
||||
{
|
||||
DoVideoRoute(sourceItem.SourceKey, Displays[1].Key);
|
||||
Display1SourceInfo = sourceItem;
|
||||
OnFeedback.FireUpdate();
|
||||
}
|
||||
|
||||
public void SourceToDisplay2(SourceListItem sourceItem)
|
||||
{
|
||||
DoVideoRoute(sourceItem.SourceKey, Displays[2].Key);
|
||||
Display2SourceInfo = sourceItem;
|
||||
OnFeedback.FireUpdate();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Basic source -> destination routing
|
||||
/// </summary>
|
||||
void DoVideoRoute(string sourceKey, string destinationKey)
|
||||
{
|
||||
new CTimer(o =>
|
||||
{
|
||||
var dest = DeviceManager.GetDeviceForKey(destinationKey) as IRoutingSinkNoSwitching;
|
||||
if (dest == null)
|
||||
{
|
||||
Debug.Console(1, this, "Cannot route. Destination '{0}' not found", destinationKey);
|
||||
return;
|
||||
}
|
||||
// off is special case
|
||||
if (sourceKey.Equals("$off", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
dest.ReleaseRoute();
|
||||
if (dest is IPower)
|
||||
(dest as IPower).PowerOff();
|
||||
return;
|
||||
}
|
||||
|
||||
var source = DeviceManager.GetDeviceForKey(sourceKey) as IRoutingOutputs;
|
||||
if (source == null)
|
||||
{
|
||||
Debug.Console(1, this, "Cannot route. Source '{0}' not found", sourceKey);
|
||||
return;
|
||||
}
|
||||
dest.ReleaseAndMakeRoute(source, eRoutingSignalType.Video);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
|
||||
public void RunRouteAction(string routeKey)
|
||||
{
|
||||
RunRouteAction(routeKey, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a source from config list SourceListKey and dynamically build and executes the
|
||||
/// route or commands
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
public void RunRouteAction(string routeKey, Action successCallback)
|
||||
{
|
||||
// Run this on a separate thread
|
||||
new CTimer(o =>
|
||||
{
|
||||
Debug.Console(1, this, "Run room action '{0}'", routeKey);
|
||||
var dict = ConfigReader.ConfigObject.GetSourceListForKey(SourceListKey);
|
||||
if(dict == null)
|
||||
{
|
||||
Debug.Console(1, this, "WARNING: Config source list '{0}' not found", SourceListKey);
|
||||
return;
|
||||
}
|
||||
|
||||
// Try to get the list item by it's string key
|
||||
if (!dict.ContainsKey(routeKey))
|
||||
{
|
||||
Debug.Console(1, this, "WARNING: No item '{0}' found on config list '{1}'",
|
||||
routeKey, SourceListKey);
|
||||
return;
|
||||
}
|
||||
|
||||
var item = dict[routeKey];
|
||||
Debug.Console(2, this, "Action {0} has {1} steps",
|
||||
item.SourceKey, item.RouteList.Count);
|
||||
|
||||
// Let's run it
|
||||
if (routeKey.ToLower() != "roomoff")
|
||||
LastSourceKey = routeKey;
|
||||
|
||||
foreach (var route in item.RouteList)
|
||||
{
|
||||
// if there is a $defaultAll on route, run two separate
|
||||
if (route.DestinationKey.Equals("$defaultAll", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var tempAudio = new SourceRouteListItem
|
||||
{
|
||||
DestinationKey = "$defaultDisplay",
|
||||
SourceKey = route.SourceKey,
|
||||
Type = eRoutingSignalType.Video
|
||||
};
|
||||
DoRoute(tempAudio);
|
||||
|
||||
var tempVideo = new SourceRouteListItem
|
||||
{
|
||||
DestinationKey = "$defaultAudio",
|
||||
SourceKey = route.SourceKey,
|
||||
Type = eRoutingSignalType.Audio
|
||||
};
|
||||
DoRoute(tempVideo);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
DoRoute(route);
|
||||
}
|
||||
|
||||
// Set volume control on room, using default if non provided
|
||||
IBasicVolumeControls volDev = null;
|
||||
// Handle special cases for volume control
|
||||
if (string.IsNullOrEmpty(item.VolumeControlKey)
|
||||
|| item.VolumeControlKey.Equals("$defaultAudio", StringComparison.OrdinalIgnoreCase))
|
||||
volDev = DefaultVolumeControls;
|
||||
//else if (item.VolumeControlKey.Equals("$defaultDisplay", StringComparison.OrdinalIgnoreCase))
|
||||
// volDev = DefaultDisplay as IBasicVolumeControls;
|
||||
// Or a specific device, probably rarely used.
|
||||
else
|
||||
{
|
||||
var dev = DeviceManager.GetDeviceForKey(item.VolumeControlKey);
|
||||
if (dev is IBasicVolumeControls)
|
||||
volDev = dev as IBasicVolumeControls;
|
||||
else if (dev is IHasVolumeDevice)
|
||||
volDev = (dev as IHasVolumeDevice).VolumeDevice;
|
||||
}
|
||||
CurrentVolumeControls = volDev;
|
||||
|
||||
// store the name and UI info for routes
|
||||
if (item.SourceKey != null)
|
||||
CurrentSingleSourceInfo = item;
|
||||
// And finally, set the "control". This will trigger event
|
||||
//CurrentControlDevice = DeviceManager.GetDeviceForKey(item.SourceKey) as Device;
|
||||
|
||||
OnFeedback.FireUpdate();
|
||||
|
||||
// report back when done
|
||||
if (successCallback != null)
|
||||
successCallback();
|
||||
}, 0); // end of CTimer
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Will power the room on with the last-used source
|
||||
/// </summary>
|
||||
public void PowerOnToDefaultOrLastSource()
|
||||
{
|
||||
if (!EnablePowerOnToLastSource || LastSourceKey == null)
|
||||
return;
|
||||
RunRouteAction(LastSourceKey);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="route"></param>
|
||||
/// <returns></returns>
|
||||
bool DoRoute(SourceRouteListItem route)
|
||||
{
|
||||
IRoutingSinkNoSwitching dest = null;
|
||||
|
||||
if (route.DestinationKey.Equals("$defaultaudio", StringComparison.OrdinalIgnoreCase))
|
||||
dest = DefaultAudioDevice;
|
||||
//else if (route.DestinationKey.Equals("$defaultDisplay", StringComparison.OrdinalIgnoreCase))
|
||||
// dest = DefaultDisplay;
|
||||
else
|
||||
dest = DeviceManager.GetDeviceForKey(route.DestinationKey) as IRoutingSinkNoSwitching;
|
||||
|
||||
if (dest == null)
|
||||
{
|
||||
Debug.Console(1, this, "Cannot route, unknown destination '{0}'", route.DestinationKey);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (route.SourceKey.Equals("$off", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
dest.ReleaseRoute();
|
||||
if (dest is IPower)
|
||||
(dest as IPower).PowerOff();
|
||||
}
|
||||
else
|
||||
{
|
||||
var source = DeviceManager.GetDeviceForKey(route.SourceKey) as IRoutingOutputs;
|
||||
if (source == null)
|
||||
{
|
||||
Debug.Console(1, this, "Cannot route unknown source '{0}' to {1}", route.SourceKey, route.DestinationKey);
|
||||
return false;
|
||||
}
|
||||
dest.ReleaseAndMakeRoute(source, route.Type);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
|
||||
namespace PepperDash.Essentials
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public interface IHasCurrentSourceInfoChange
|
||||
{
|
||||
event SourceInfoChangeHandler CurrentSingleSourceChange;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class EssentialsRoomBase : Device
|
||||
{
|
||||
public EssentialsRoomBase(string key, string name) : base(key, name)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Crestron.SimplSharp;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using PepperDash.Essentials.DM;
|
||||
|
||||
namespace PepperDash.Essentials
|
||||
{
|
||||
public class EssentialsRoomConfig : DeviceConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns a room object from this config data
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Device GetRoomObject()
|
||||
{
|
||||
var typeName = Type.ToLower();
|
||||
if (typeName == "huddle")
|
||||
{
|
||||
var props = JsonConvert.DeserializeObject<EssentialsHuddleRoomPropertiesConfig>
|
||||
(this.Properties.ToString());
|
||||
var disp = DeviceManager.GetDeviceForKey(props.DefaultDisplayKey) as IRoutingSinkWithSwitching;
|
||||
var audio = DeviceManager.GetDeviceForKey(props.DefaultAudioKey) as IRoutingSinkNoSwitching;
|
||||
var huddle = new EssentialsHuddleSpaceRoom(Key, Name, disp, audio, props);
|
||||
huddle.SourceListKey = props.SourceListKey;
|
||||
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();
|
||||
|
||||
#warning Will need to define audio routing somewhere as well
|
||||
|
||||
var presRoom = new EssentialsPresentationRoom(Key, Name, displaysDict, masterVolumeControlDev, props);
|
||||
return presRoom;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class EssentialsRoomPropertiesConfig
|
||||
{
|
||||
public string HelpMessage { get; set; }
|
||||
public string Description { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class EssentialsHuddleRoomPropertiesConfig : EssentialsRoomPropertiesConfig
|
||||
{
|
||||
public string DefaultDisplayKey { get; set; }
|
||||
public string DefaultAudioKey { get; set; }
|
||||
public string SourceListKey { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class EssentialsPresentationRoomPropertiesConfig : EssentialsRoomPropertiesConfig
|
||||
{
|
||||
public string DefaultAudioBehavior { get; set; }
|
||||
public string DefaultAudioKey { get; set; }
|
||||
public string DefaultVideoBehavior { get; set; }
|
||||
public List<string> DisplayKeys { get; set; }
|
||||
public string SourceListKey { get; set; }
|
||||
public bool HasDsp { get; set; }
|
||||
public EssentialsPresentationVolumesConfig Volumes { get; set; }
|
||||
|
||||
public EssentialsPresentationRoomPropertiesConfig()
|
||||
{
|
||||
DisplayKeys = new List<string>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
|
||||
namespace PepperDash.Essentials
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class VolumeDeviceChangeEventArgs : EventArgs
|
||||
{
|
||||
public IBasicVolumeControls OldDev { get; private set; }
|
||||
public IBasicVolumeControls NewDev { get; private set; }
|
||||
public ChangeType Type { get; private set; }
|
||||
|
||||
public VolumeDeviceChangeEventArgs(IBasicVolumeControls oldDev, IBasicVolumeControls newDev, ChangeType type)
|
||||
{
|
||||
OldDev = oldDev;
|
||||
NewDev = newDev;
|
||||
Type = type;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The handler type for a Room's SourceInfoChange
|
||||
/// </summary>
|
||||
public delegate void SourceInfoChangeHandler(EssentialsRoomBase room, SourceListItem info, ChangeType type);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public enum ChangeType
|
||||
{
|
||||
WillChange, DidChange
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,353 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
|
||||
namespace PepperDash.Essentials
|
||||
{
|
||||
/// <summary>
|
||||
/// Where all UI element common joins are defined
|
||||
/// </summary>
|
||||
public class UIBoolJoin
|
||||
{
|
||||
/// <summary>
|
||||
/// 901
|
||||
/// </summary>
|
||||
public const uint VolumeUpPress = 901;
|
||||
/// <summary>
|
||||
/// 902
|
||||
/// </summary>
|
||||
public const uint VolumeDownPress = 902;
|
||||
|
||||
/// <summary>
|
||||
/// 3811
|
||||
/// </summary>
|
||||
public const uint VolumeSingleMute1Visible = 3811;
|
||||
/// <summary>
|
||||
/// 3812
|
||||
/// </summary>
|
||||
public const uint VolumeSlider1Press = 3812;
|
||||
/// <summary>
|
||||
/// 3813
|
||||
/// </summary>
|
||||
public const uint Volume1ProgramMutePressAndFB = 3813;
|
||||
/// <summary>
|
||||
/// 3871
|
||||
/// </summary>
|
||||
public const uint VolumeDualMute1Visible = 3871;
|
||||
/// <summary>
|
||||
/// 3874
|
||||
/// </summary>
|
||||
public const uint Volume1SpeechMutePressAndFB = 3874;
|
||||
/// <summary>
|
||||
/// 3875
|
||||
/// </summary>
|
||||
public const uint Volume1BackerVisibility = 3875;
|
||||
|
||||
/// <summary>
|
||||
/// 3821
|
||||
/// </summary>
|
||||
public const uint Volume2Visible = 3821;
|
||||
/// <summary>
|
||||
/// 3822
|
||||
/// </summary>
|
||||
public const uint VolumeSlider2Press = 3822;
|
||||
/// <summary>
|
||||
/// 3823
|
||||
/// </summary>
|
||||
public const uint Volume2MutePressAndFB = 3823;
|
||||
/// <summary>
|
||||
/// 3831
|
||||
/// </summary>
|
||||
public const uint Volume3Visible = 3831;
|
||||
/// <summary>
|
||||
/// 3832
|
||||
/// </summary>
|
||||
public const uint VolumeSlider3Press = 3832;
|
||||
/// <summary>
|
||||
/// 3833
|
||||
/// </summary>
|
||||
public const uint Volume3MutePressAndFB = 3833;
|
||||
/// <summary>
|
||||
/// 3841
|
||||
/// </summary>
|
||||
public const uint Volume4Visible = 3841;
|
||||
/// <summary>
|
||||
/// 3842
|
||||
/// </summary>
|
||||
public const uint VolumeSlider4Press = 3842;
|
||||
/// <summary>
|
||||
/// 3843
|
||||
/// </summary>
|
||||
public const uint Volume4MutePressAndFB = 3843;
|
||||
/// <summary>
|
||||
/// 3851
|
||||
/// </summary>
|
||||
public const uint Volume5Visible = 3851;
|
||||
/// <summary>
|
||||
/// 3852
|
||||
/// </summary>
|
||||
public const uint VolumeSlider5Press = 3852;
|
||||
/// <summary>
|
||||
/// 3853
|
||||
/// </summary>
|
||||
public const uint Volume5MutePressAndFB = 3853;
|
||||
/// <summary>
|
||||
/// 3861
|
||||
/// </summary>
|
||||
public const uint Volume6Visible = 3861;
|
||||
/// <summary>
|
||||
/// 3862
|
||||
/// </summary>
|
||||
public const uint VolumeSlider6Press = 3862;
|
||||
/// <summary>
|
||||
/// 3863
|
||||
/// </summary>
|
||||
public const uint Volume6MutePressAndFB = 3863;
|
||||
|
||||
/// <summary>
|
||||
/// 3870
|
||||
/// </summary>
|
||||
public const uint VolumesPageVisible = 3870;
|
||||
/// <summary>
|
||||
/// 3999
|
||||
/// </summary>
|
||||
public const uint GenericModalVisible = 3999;
|
||||
/// <summary>
|
||||
/// 12345
|
||||
/// </summary>
|
||||
public const uint AvNoControlsSubVisible = 12345;
|
||||
/// <summary>
|
||||
/// 15001
|
||||
/// </summary>
|
||||
public const uint StartPageVisible = 15001;
|
||||
/// <summary>
|
||||
/// 15002 Shows the start page in the source controls area of the screen
|
||||
/// </summary>
|
||||
public const uint TapToBeginVisible = 15002;
|
||||
/// <summary>
|
||||
/// 15003 Message text when no source is showing
|
||||
/// </summary>
|
||||
public const uint SelectASourceVisible = 15003;
|
||||
/// <summary>
|
||||
/// 15004
|
||||
/// </summary>
|
||||
public const uint RoomIsOn = 15004;
|
||||
/// <summary>
|
||||
/// 15005 Shows always-on volume control subpage with only audio mute
|
||||
/// </summary>
|
||||
public const uint VolumeControlsSingleMuteVisible = 15005;
|
||||
/// <summary>
|
||||
/// 15006 Shows always-on volume control subpage with mic and audio mutes
|
||||
/// </summary>
|
||||
public const uint VolumeControlsDualMuteVisible = 15006;
|
||||
/// <summary>
|
||||
/// 15010
|
||||
/// </summary>
|
||||
public const uint ShowPanelSetupPress = 15010;
|
||||
/// <summary>
|
||||
/// 15011
|
||||
/// </summary>
|
||||
public const uint TopBarVisible = 15011;
|
||||
/// <summary>
|
||||
/// 15012
|
||||
/// </summary>
|
||||
public const uint StagingPageVisible = 15012;
|
||||
/// <summary>
|
||||
/// 15013
|
||||
/// </summary>
|
||||
public const uint PowerOffStep1Visible = 15013;
|
||||
/// <summary>
|
||||
/// 15014
|
||||
/// </summary>
|
||||
public const uint PowerOffStep2Visible = 15014;
|
||||
/// <summary>
|
||||
/// 15015
|
||||
/// </summary>
|
||||
public const uint ShowPowerOffPress = 15015;
|
||||
/// <summary>
|
||||
/// 15016
|
||||
/// </summary>
|
||||
public const uint PowerOffMorePress = 15016;
|
||||
/// <summary>
|
||||
/// 15017
|
||||
/// </summary>
|
||||
public const uint StagingPageAdditionalArrowsVisible = 15017;
|
||||
/// <summary>
|
||||
/// 15020
|
||||
/// </summary>
|
||||
public const uint PanelSetupVisible = 15020;
|
||||
/// <summary>
|
||||
/// 15021
|
||||
/// </summary>
|
||||
public const uint SourceWaitOverlayVisible = 15021;
|
||||
/// <summary>
|
||||
/// 15022
|
||||
/// </summary>
|
||||
public const uint ActivityFooterVisible = 15022;
|
||||
/// <summary>
|
||||
/// 15023
|
||||
/// </summary>
|
||||
public const uint LightsHeaderButtonVisible = 15023;
|
||||
/// <summary>
|
||||
/// 15024
|
||||
/// </summary>
|
||||
public const uint CallRightHeaderButtonVisible = 15024;
|
||||
/// <summary>
|
||||
/// 15025
|
||||
/// </summary>
|
||||
public const uint CallLeftHeaderButtonVisible = 15025;
|
||||
/// <summary>
|
||||
/// 15026
|
||||
/// </summary>
|
||||
public const uint LightsHeaderButtonPress = 15026;
|
||||
/// <summary>
|
||||
/// 15027
|
||||
/// </summary>
|
||||
public const uint CallHeaderButtonPress = 15027;
|
||||
/// <summary>
|
||||
/// 15028 The gear button in header
|
||||
/// </summary>
|
||||
public const uint GearHeaderButtonPress = 15028;
|
||||
/// <summary>
|
||||
/// 15029 the room button in header
|
||||
/// </summary>
|
||||
public const uint RoomHeaderButtonPress = 15029;
|
||||
/// <summary>
|
||||
/// 15030 Visibility for room data popup
|
||||
/// </summary>
|
||||
public const uint RoomHeaderPageVisible = 15030;
|
||||
/// <summary>
|
||||
/// 15031
|
||||
/// </summary>
|
||||
public const uint AllRoomsOffPress = 15031;
|
||||
/// <summary>
|
||||
/// 15032
|
||||
/// </summary>
|
||||
public const uint DisplayPowerTogglePress = 15032;
|
||||
/// <summary>
|
||||
/// 15033
|
||||
/// </summary>
|
||||
public const uint PowerOffCancelPress = 15033;
|
||||
/// <summary>
|
||||
/// 15034
|
||||
/// </summary>
|
||||
public const uint PowerOffConfirmPress = 15034;
|
||||
/// <summary>
|
||||
/// 15035
|
||||
/// </summary>
|
||||
public const uint VolumeButtonPopupPress = 15035;
|
||||
/// <summary>
|
||||
/// 15035
|
||||
/// </summary>
|
||||
public const uint VolumeButtonPopupVisible = 15035;
|
||||
/// <summary>
|
||||
/// 15036
|
||||
/// </summary>
|
||||
public const uint VolumeGaugePopupVisible = 15036;
|
||||
/// <summary>
|
||||
/// 15040
|
||||
/// </summary>
|
||||
public const uint CallStatusPageVisible = 15040;
|
||||
/// <summary>
|
||||
/// 15041
|
||||
/// </summary>
|
||||
public const uint LightsPageVisible = 15041;
|
||||
/// <summary>
|
||||
/// 15042 Closes whichever interlocked modal is open
|
||||
/// </summary>
|
||||
public const uint InterlockedModalClosePress = 15042;
|
||||
/// <summary>
|
||||
/// 15043 Vis for modal backer for full-screen source
|
||||
/// </summary>
|
||||
public const uint SourceBackgroundOverlayVisible = 15043;
|
||||
/// <summary>
|
||||
/// 15044 Close button for source modal overlay
|
||||
/// </summary>
|
||||
public const uint SourceBackgroundOverlayClosePress = 15044;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 15051
|
||||
/// </summary>
|
||||
public const uint Display1SelectPressAndFb = 15051;
|
||||
/// <summary>
|
||||
/// 15052
|
||||
/// </summary>
|
||||
public const uint Display1ControlButtonEnable = 15052;
|
||||
/// <summary>
|
||||
/// 15053
|
||||
/// </summary>
|
||||
public const uint Display1ControlButtonPress = 15053;
|
||||
/// <summary>
|
||||
/// 15054
|
||||
/// </summary>
|
||||
public const uint Display1AudioButtonEnable = 15054;
|
||||
/// <summary>
|
||||
/// 15055
|
||||
/// </summary>
|
||||
public const uint Display1AudioButtonPressAndFb = 15055;
|
||||
/// <summary>
|
||||
/// 15056
|
||||
/// </summary>
|
||||
public const uint Display2SelectPressAndFb = 15056;
|
||||
/// <summary>
|
||||
/// 15057
|
||||
/// </summary>
|
||||
public const uint Display2ControlButtonEnable = 15057;
|
||||
/// <summary>
|
||||
/// 15058
|
||||
/// </summary>
|
||||
public const uint Display2ControlButtonPress = 15058;
|
||||
/// <summary>
|
||||
/// 15059
|
||||
/// </summary>
|
||||
public const uint Display2AudioButtonEnable = 15059;
|
||||
/// <summary>
|
||||
/// 15060
|
||||
/// </summary>
|
||||
public const uint Display2AudioButtonPressAndFb = 15060;
|
||||
|
||||
/// <summary>
|
||||
/// 15061 Reveals the dual-display subpage
|
||||
/// </summary>
|
||||
public const uint DualDisplayPageVisible = 15061;
|
||||
/// <summary>
|
||||
/// 15062 Reveals the toggle switch for the sharing mode
|
||||
/// </summary>
|
||||
public const uint ToggleSharingModeVisible = 15062;
|
||||
/// <summary>
|
||||
/// 15063 Press for the toggle mode switch
|
||||
/// </summary>
|
||||
public const uint ToggleSharingModePress = 15063;
|
||||
|
||||
/// <summary>
|
||||
/// 15085 Visibility join for help subpage
|
||||
/// </summary>
|
||||
public const uint HelpPageVisible = 15085;
|
||||
/// <summary>
|
||||
/// 15086 Press for help header button
|
||||
/// </summary>
|
||||
public const uint HelpPress = 15086;
|
||||
|
||||
/// <summary>
|
||||
/// 15088
|
||||
/// </summary>
|
||||
public const uint DateOnlyVisible = 15088;
|
||||
/// <summary>
|
||||
/// 15089
|
||||
/// </summary>
|
||||
public const uint TimeOnlyVisible = 15089;
|
||||
/// <summary>
|
||||
/// 15090
|
||||
/// </summary>
|
||||
public const uint DateAndTimeVisible = 15090;
|
||||
/// <summary>
|
||||
/// 15091
|
||||
/// </summary>
|
||||
public const uint SetupFullDistrib = 15091;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
namespace PepperDash.Essentials
|
||||
{
|
||||
public class UISmartObjectJoin
|
||||
{
|
||||
/// <summary>
|
||||
/// 3200 The staging, source-select list
|
||||
/// </summary>
|
||||
public const uint StagingListSRL = 3200;
|
||||
/// <summary>
|
||||
/// 15022 The main activity footer
|
||||
/// </summary>
|
||||
public const uint ActivityFooterSRL = 15022;
|
||||
}
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
|
||||
namespace PepperDash.Essentials
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class UIStringJoin
|
||||
{
|
||||
/// <summary>
|
||||
/// 3812
|
||||
/// </summary>
|
||||
public const uint AdvancedVolumeSlider1Text = 3812;
|
||||
/// <summary>
|
||||
/// 3822
|
||||
/// </summary>
|
||||
public const uint AdvancedVolumeSlider2Text = 3822;
|
||||
/// <summary>
|
||||
/// 3832
|
||||
/// </summary>
|
||||
public const uint AdvancedVolumeSlider3Text = 3832;
|
||||
/// <summary>
|
||||
/// 3842
|
||||
/// </summary>
|
||||
public const uint AdvancedVolumeSlider4Text = 3842;
|
||||
/// <summary>
|
||||
/// 3852
|
||||
/// </summary>
|
||||
public const uint AdvancedVolumeSlider5Text = 3852;
|
||||
/// <summary>
|
||||
/// 3862
|
||||
/// </summary>
|
||||
public const uint AdvancedVolumeSlider6Text = 3862;
|
||||
|
||||
/// <summary>
|
||||
/// 3901
|
||||
/// </summary>
|
||||
public const uint CurrentRoomName = 3901;
|
||||
/// <summary>
|
||||
/// 3902
|
||||
/// </summary>
|
||||
public const uint CurrentSourceName = 3902;
|
||||
/// <summary>
|
||||
/// 3903
|
||||
/// </summary>
|
||||
public const uint CurrentSourceIcon = 3903;
|
||||
/// <summary>
|
||||
/// 3911
|
||||
/// </summary>
|
||||
public const uint PowerOffMessage = 3911;
|
||||
/// <summary>
|
||||
/// 3912
|
||||
/// </summary>
|
||||
public const uint StartPageMessage = 3912;
|
||||
/// <summary>
|
||||
/// 3913
|
||||
/// </summary>
|
||||
public const uint StartActivityText = 3913;
|
||||
/// <summary>
|
||||
/// 3914 Title bar label for source overlay
|
||||
/// </summary>
|
||||
public const uint SourceBackgroundOverlayTitle = 3914;
|
||||
|
||||
/// <summary>
|
||||
/// 3922
|
||||
/// </summary>
|
||||
public const uint HelpMessage = 3922;
|
||||
|
||||
/// <summary>
|
||||
/// 3961 Name of source on display 1
|
||||
/// </summary>
|
||||
public const uint Display1SourceLabel = 3961;
|
||||
/// <summary>
|
||||
/// 3962 Title above display 1
|
||||
/// </summary>
|
||||
public const uint Display1TitleLabel = 3962;
|
||||
/// <summary>
|
||||
/// 3964 Name of source on display 2
|
||||
/// </summary>
|
||||
public const uint Display2SourceLabel = 3964;
|
||||
/// <summary>
|
||||
/// 3965 Title above display 2
|
||||
/// </summary>
|
||||
public const uint Display2TitleLabel = 3965;
|
||||
}
|
||||
}
|
||||
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 Core\PepperDashEssentialsBase\PepperDash_Essentials_Core.csproj", "{A49AD6C8-FC0A-4CC0-9089-DFB4CF92D2B5}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Essentials Devices Common", "..\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 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
|
||||
33
PepperDashEssentials/AppServer/CotijaConfig.cs
Normal file
33
PepperDashEssentials/AppServer/CotijaConfig.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace PepperDash.Essentials
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class CotijaConfig
|
||||
{
|
||||
[JsonProperty("serverUrl")]
|
||||
public string ServerUrl { get; set; }
|
||||
|
||||
[JsonProperty("clientAppUrl")]
|
||||
public string ClientAppUrl { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class CotijaDdvc01RoomBridgePropertiesConfig
|
||||
{
|
||||
[JsonProperty("eiscId")]
|
||||
public string EiscId { get; set; }
|
||||
}
|
||||
}
|
||||
148
PepperDashEssentials/AppServer/CotijaDdvc01DeviceBridge.cs
Normal file
148
PepperDashEssentials/AppServer/CotijaDdvc01DeviceBridge.cs
Normal file
@@ -0,0 +1,148 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro.EthernetCommunication;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Room.Cotija
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a generic device connection through to and EISC for DDVC01
|
||||
/// </summary>
|
||||
public class CotijaDdvc01DeviceBridge : Device, IChannel, INumericKeypad
|
||||
{
|
||||
/// <summary>
|
||||
/// EISC used to talk to Simpl
|
||||
/// </summary>
|
||||
ThreeSeriesTcpIpEthernetIntersystemCommunications EISC;
|
||||
|
||||
public CotijaDdvc01DeviceBridge(string key, string name, ThreeSeriesTcpIpEthernetIntersystemCommunications eisc)
|
||||
: base(key, name)
|
||||
{
|
||||
EISC = eisc;
|
||||
}
|
||||
|
||||
|
||||
#region IChannel Members
|
||||
|
||||
public void ChannelUp(bool pressRelease)
|
||||
{
|
||||
EISC.SetBool(1111, pressRelease);
|
||||
}
|
||||
|
||||
public void ChannelDown(bool pressRelease)
|
||||
{
|
||||
EISC.SetBool(1111, pressRelease);
|
||||
}
|
||||
|
||||
public void LastChannel(bool pressRelease)
|
||||
{
|
||||
EISC.SetBool(1111, pressRelease);
|
||||
}
|
||||
|
||||
public void Guide(bool pressRelease)
|
||||
{
|
||||
EISC.SetBool(1111, pressRelease);
|
||||
}
|
||||
|
||||
public void Info(bool pressRelease)
|
||||
{
|
||||
EISC.SetBool(1111, pressRelease);
|
||||
}
|
||||
|
||||
public void Exit(bool pressRelease)
|
||||
{
|
||||
EISC.SetBool(1111, pressRelease);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region INumericKeypad Members
|
||||
|
||||
public void Digit0(bool pressRelease)
|
||||
{
|
||||
EISC.SetBool(1111, pressRelease);
|
||||
}
|
||||
|
||||
public void Digit1(bool pressRelease)
|
||||
{
|
||||
EISC.SetBool(1111, pressRelease);
|
||||
}
|
||||
|
||||
public void Digit2(bool pressRelease)
|
||||
{
|
||||
EISC.SetBool(1111, pressRelease);
|
||||
}
|
||||
|
||||
public void Digit3(bool pressRelease)
|
||||
{
|
||||
EISC.SetBool(1111, pressRelease);
|
||||
}
|
||||
|
||||
public void Digit4(bool pressRelease)
|
||||
{
|
||||
EISC.SetBool(1111, pressRelease);
|
||||
}
|
||||
|
||||
public void Digit5(bool pressRelease)
|
||||
{
|
||||
EISC.SetBool(1111, pressRelease);
|
||||
}
|
||||
|
||||
public void Digit6(bool pressRelease)
|
||||
{
|
||||
EISC.SetBool(1111, pressRelease);
|
||||
}
|
||||
|
||||
public void Digit7(bool pressRelease)
|
||||
{
|
||||
EISC.SetBool(1111, pressRelease);
|
||||
}
|
||||
|
||||
public void Digit8(bool pressRelease)
|
||||
{
|
||||
EISC.SetBool(1111, pressRelease);
|
||||
}
|
||||
|
||||
public void Digit9(bool pressRelease)
|
||||
{
|
||||
EISC.SetBool(1111, pressRelease);
|
||||
}
|
||||
|
||||
public bool HasKeypadAccessoryButton1
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public string KeypadAccessoryButton1Label
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public void KeypadAccessoryButton1(bool pressRelease)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool HasKeypadAccessoryButton2
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public string KeypadAccessoryButton2Label
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public void KeypadAccessoryButton2(bool pressRelease)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
864
PepperDashEssentials/AppServer/CotijaSystemController.cs
Normal file
864
PepperDashEssentials/AppServer/CotijaSystemController.cs
Normal file
@@ -0,0 +1,864 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharp.CrestronIO;
|
||||
using Crestron.SimplSharp.Reflection;
|
||||
using Crestron.SimplSharpPro.CrestronThread;
|
||||
using Crestron.SimplSharp.CrestronWebSocketClient;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharp.Net.Http;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using PepperDash.Essentials.Room.Cotija;
|
||||
using PepperDash.Essentials.AppServer.Messengers;
|
||||
|
||||
namespace PepperDash.Essentials
|
||||
{
|
||||
public class CotijaSystemController : Device
|
||||
{
|
||||
WebSocketClient WSClient;
|
||||
|
||||
//bool LinkUp;
|
||||
|
||||
/// <summary>
|
||||
/// Prevents post operations from stomping on each other and getting lost
|
||||
/// </summary>
|
||||
CEvent PostLockEvent = new CEvent(true, true);
|
||||
|
||||
CEvent RegisterLockEvent = new CEvent(true, true);
|
||||
|
||||
public CotijaConfig Config { get; private set; }
|
||||
|
||||
Dictionary<string, Object> ActionDictionary = new Dictionary<string, Object>(StringComparer.InvariantCultureIgnoreCase);
|
||||
|
||||
Dictionary<string, CTimer> PushedActions = new Dictionary<string, CTimer>();
|
||||
|
||||
public ConfigMessenger ConfigMessenger { get; private set; }
|
||||
|
||||
CTimer ServerHeartbeatCheckTimer;
|
||||
|
||||
long ServerHeartbeatInterval = 20000;
|
||||
|
||||
CTimer ServerReconnectTimer;
|
||||
|
||||
long ServerReconnectInterval = 5000;
|
||||
|
||||
DateTime LastAckMessage;
|
||||
|
||||
public string SystemUuid;
|
||||
|
||||
List<CotijaBridgeBase> RoomBridges = new List<CotijaBridgeBase>();
|
||||
|
||||
long ButtonHeartbeatInterval = 1000;
|
||||
|
||||
/// <summary>
|
||||
/// Used for tracking HTTP debugging
|
||||
/// </summary>
|
||||
bool HttpDebugEnabled;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="config"></param>
|
||||
public CotijaSystemController(string key, string name, CotijaConfig config) : base(key, name)
|
||||
{
|
||||
Config = config;
|
||||
|
||||
SystemUuid = ConfigReader.ConfigObject.SystemUuid;
|
||||
|
||||
Debug.Console(0, this, "Mobile UI controller initializing for server:{0}", config.ServerUrl);
|
||||
|
||||
CrestronConsole.AddNewConsoleCommand(AuthorizeSystem,
|
||||
"mobileauth", "Authorizes system to talk to cotija server", ConsoleAccessLevelEnum.AccessOperator);
|
||||
CrestronConsole.AddNewConsoleCommand(s => ShowInfo(),
|
||||
"mobileinfo", "Shows information for current mobile control session", ConsoleAccessLevelEnum.AccessOperator);
|
||||
CrestronConsole.AddNewConsoleCommand(s => {
|
||||
s = s.Trim();
|
||||
if(!string.IsNullOrEmpty(s))
|
||||
{
|
||||
HttpDebugEnabled = (s.Trim() != "0");
|
||||
}
|
||||
CrestronConsole.ConsoleCommandResponse("HTTP Debug {0}", HttpDebugEnabled ? "Enabled" : "Disabled");
|
||||
},
|
||||
"mobilehttpdebug", "1 enables more verbose HTTP response debugging", ConsoleAccessLevelEnum.AccessOperator);
|
||||
CrestronConsole.AddNewConsoleCommand(TestHttpRequest,
|
||||
"mobilehttprequest", "Tests an HTTP get to URL given", ConsoleAccessLevelEnum.AccessOperator);
|
||||
|
||||
CrestronConsole.AddNewConsoleCommand(PrintActionDictionaryPaths, "mobileshowactionpaths",
|
||||
"Prints the paths in the Action Dictionary", ConsoleAccessLevelEnum.AccessOperator);
|
||||
CrestronConsole.AddNewConsoleCommand(s => ConnectWebsocketClient(), "mobileconnect",
|
||||
"Forces connect of websocket", ConsoleAccessLevelEnum.AccessOperator);
|
||||
CrestronConsole.AddNewConsoleCommand(s => CleanUpWebsocketClient(), "mobiledisco",
|
||||
"Disconnects websocket", ConsoleAccessLevelEnum.AccessOperator);
|
||||
|
||||
CrestronConsole.AddNewConsoleCommand(s => ParseStreamRx(s), "mobilesimulateaction", "Simulates a message from the server", ConsoleAccessLevelEnum.AccessOperator);
|
||||
|
||||
CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
|
||||
CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(CrestronEnvironment_EthernetEventHandler);
|
||||
|
||||
// Config Messenger
|
||||
var cmKey = Key + "-config";
|
||||
ConfigMessenger = new ConfigMessenger(cmKey, "/config");
|
||||
ConfigMessenger.RegisterWithAppServer(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If config rooms is empty or null then go
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override bool CustomActivate()
|
||||
{
|
||||
if (ConfigReader.ConfigObject.Rooms == null || ConfigReader.ConfigObject.Rooms.Count == 0)
|
||||
{
|
||||
Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Config contains no rooms. Registering with Server.");
|
||||
RegisterSystemToServer();
|
||||
}
|
||||
|
||||
return base.CustomActivate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="ethernetEventArgs"></param>
|
||||
void CrestronEnvironment_EthernetEventHandler(EthernetEventArgs args)
|
||||
{
|
||||
Debug.Console(1, this, Debug.ErrorLogLevel.Warning, "Ethernet status change, port {0}: {1}",
|
||||
args.EthernetAdapter, args.EthernetEventType);
|
||||
|
||||
if (args.EthernetEventType == eEthernetEventType.LinkDown && WSClient != null && args.EthernetAdapter == WSClient.EthernetAdapter)
|
||||
{
|
||||
CleanUpWebsocketClient();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends message to server to indicate the system is shutting down
|
||||
/// </summary>
|
||||
/// <param name="programEventType"></param>
|
||||
void CrestronEnvironment_ProgramStatusEventHandler(eProgramStatusEventType programEventType)
|
||||
{
|
||||
if (programEventType == eProgramStatusEventType.Stopping
|
||||
&& WSClient != null
|
||||
&& WSClient.Connected)
|
||||
{
|
||||
CleanUpWebsocketClient();
|
||||
}
|
||||
}
|
||||
|
||||
public void PrintActionDictionaryPaths(object o)
|
||||
{
|
||||
Debug.Console(0, this, "ActionDictionary Contents:");
|
||||
|
||||
foreach (var item in ActionDictionary)
|
||||
{
|
||||
Debug.Console(0, this, "{0}", item.Key);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an action to the dictionary
|
||||
/// </summary>
|
||||
/// <param name="key">The path of the API command</param>
|
||||
/// <param name="action">The action to be triggered by the commmand</param>
|
||||
public void AddAction(string key, object action)
|
||||
{
|
||||
if (!ActionDictionary.ContainsKey(key))
|
||||
{
|
||||
ActionDictionary.Add(key, action);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Console(1, this, "Cannot add action with key '{0}' because key already exists in ActionDictionary.", key);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes an action from the dictionary
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
public void RemoveAction(string key)
|
||||
{
|
||||
if (ActionDictionary.ContainsKey(key))
|
||||
ActionDictionary.Remove(key);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="bridge"></param>
|
||||
public void AddBridge(CotijaBridgeBase bridge)
|
||||
{
|
||||
RoomBridges.Add(bridge);
|
||||
var b = bridge as IDelayedConfiguration;
|
||||
if (b != null)
|
||||
{
|
||||
Debug.Console(0, this, "Adding room bridge with delayed configuration");
|
||||
b.ConfigurationIsReady += new EventHandler<EventArgs>(bridge_ConfigurationIsReady);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Console(0, this, "Adding room bridge and sending configuration");
|
||||
//SystemUuid = ConfigReader.ConfigObject.SystemUuid;
|
||||
RegisterSystemToServer();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void bridge_ConfigurationIsReady(object sender, EventArgs e)
|
||||
{
|
||||
Debug.Console(1, this, "Bridge ready. Registering");
|
||||
//SystemUuid = ConfigReader.ConfigObject.SystemUuid;
|
||||
// send the configuration object to the server
|
||||
RegisterSystemToServer();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="o"></param>
|
||||
void ReconnectToServerTimerCallback(object o)
|
||||
{
|
||||
RegisterSystemToServer();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies system connection with servers
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
void AuthorizeSystem(string code)
|
||||
{
|
||||
//SystemUuid = ConfigReader.ConfigObject.SystemUuid;
|
||||
|
||||
if (string.IsNullOrEmpty(SystemUuid))
|
||||
{
|
||||
CrestronConsole.ConsoleCommandResponse("System does not have a UUID. Please ensure proper portal-format configuration is loaded and restart.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(code))
|
||||
{
|
||||
CrestronConsole.ConsoleCommandResponse("Please enter a user code to authorize a system");
|
||||
return;
|
||||
}
|
||||
|
||||
var req = new HttpClientRequest();
|
||||
string url = string.Format("http://{0}/api/system/grantcode/{1}/{2}", Config.ServerUrl, code, SystemUuid);
|
||||
Debug.Console(0, this, "Authorizing to: {0}", url);
|
||||
|
||||
if (string.IsNullOrEmpty(Config.ServerUrl))
|
||||
{
|
||||
CrestronConsole.ConsoleCommandResponse("Config URL address is not set. Check portal configuration");
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
req.Url.Parse(url);
|
||||
new HttpClient().DispatchAsync(req, (r, e) =>
|
||||
{
|
||||
CheckHttpDebug(r, e);
|
||||
if (e == HTTP_CALLBACK_ERROR.COMPLETED)
|
||||
{
|
||||
if (r.Code == 200)
|
||||
{
|
||||
Debug.Console(0, "System authorized, sending config.");
|
||||
#warning This registration may need to wait for config ready. Maybe.
|
||||
RegisterSystemToServer();
|
||||
}
|
||||
else if (r.Code == 404)
|
||||
{
|
||||
if (r.ContentString.Contains("codeNotFound"))
|
||||
{
|
||||
Debug.Console(0, "Authorization failed, code not found for system UUID {0}", SystemUuid);
|
||||
}
|
||||
else if (r.ContentString.Contains("uuidNotFound"))
|
||||
{
|
||||
Debug.Console(0, "Authorization failed, uuid {0} not found. Check Essentials configuration is correct",
|
||||
SystemUuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
Debug.Console(0, this, "Error {0} in authorizing system", e);
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(0, this, "Error in authorizing: {0}", e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dumps info in response to console command.
|
||||
/// </summary>
|
||||
void ShowInfo()
|
||||
{
|
||||
var url = Config != null ? Config.ServerUrl : "No config";
|
||||
string name;
|
||||
string code;
|
||||
if (RoomBridges != null && RoomBridges.Count > 0)
|
||||
{
|
||||
name = RoomBridges[0].RoomName;
|
||||
code = RoomBridges[0].UserCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
name = "No config";
|
||||
code = "Not available";
|
||||
}
|
||||
var conn = WSClient == null ? "No client" : (WSClient.Connected ? "Yes" : "No");
|
||||
var secSinceLastAck = DateTime.Now - LastAckMessage;
|
||||
|
||||
|
||||
CrestronConsole.ConsoleCommandResponse(@"Mobile Control Information:
|
||||
Server address: {0}
|
||||
System Name: {1}
|
||||
System URL: {2}
|
||||
System UUID: {3}
|
||||
System User code: {4}
|
||||
Connected?: {5}
|
||||
Seconds Since Last Ack: {6}"
|
||||
, url, name, ConfigReader.ConfigObject.SystemUrl, SystemUuid,
|
||||
code, conn, secSinceLastAck.Seconds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers the room with the server
|
||||
/// </summary>
|
||||
/// <param name="url">URL of the server, including the port number, if not 80. Format: "serverUrlOrIp:port"</param>
|
||||
void RegisterSystemToServer()
|
||||
{
|
||||
ConnectWebsocketClient();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Connects the Websocket Client
|
||||
/// </summary>
|
||||
/// <param name="o"></param>
|
||||
void ConnectWebsocketClient()
|
||||
{
|
||||
|
||||
Debug.Console(1, this, "Initializing Stream client to server.");
|
||||
|
||||
if (WSClient != null)
|
||||
{
|
||||
Debug.Console(1, this, "Cleaning up previous socket");
|
||||
CleanUpWebsocketClient();
|
||||
}
|
||||
|
||||
WSClient = new WebSocketClient();
|
||||
WSClient.URL = string.Format("wss://{0}/system/join/{1}", Config.ServerUrl, this.SystemUuid);
|
||||
WSClient.ConnectionCallBack = Websocket_ConnectCallback;
|
||||
WSClient.ConnectAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="code"></param>
|
||||
/// <returns></returns>
|
||||
int Websocket_ConnectCallback(WebSocketClient.WEBSOCKET_RESULT_CODES code)
|
||||
{
|
||||
if (code == WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_SUCCESS)
|
||||
{
|
||||
StopServerReconnectTimer();
|
||||
Debug.Console(1, this, "Websocket connected");
|
||||
WSClient.DisconnectCallBack = Websocket_DisconnectCallback;
|
||||
WSClient.SendCallBack = Websocket_SendCallback;
|
||||
WSClient.ReceiveCallBack = Websocket_ReceiveCallback;
|
||||
WSClient.ReceiveAsync();
|
||||
SendMessageObjectToServer(new
|
||||
{
|
||||
type = "hello"
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (code == WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_HTTP_HANDSHAKE_TOKEN_ERROR)
|
||||
{
|
||||
// This is the case when app server is running behind a websever and app server is down
|
||||
Debug.Console(1, this, Debug.ErrorLogLevel.Warning, "Web socket connection failed. Check that app server is running behind web server");
|
||||
}
|
||||
else if (code == WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_SOCKET_CONNECTION_FAILED)
|
||||
{
|
||||
// this will be the case when webserver is unreachable
|
||||
Debug.Console(1, this, Debug.ErrorLogLevel.Warning, "Web socket connection failed");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Console(1, this, Debug.ErrorLogLevel.Warning, "Web socket connection failure: {0}", code);
|
||||
}
|
||||
StartServerReconnectTimer();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// After a "hello" from the server, sends config and stuff
|
||||
/// </summary>
|
||||
void SendInitialMessage()
|
||||
{
|
||||
Debug.Console(1, this, "Sending initial join message");
|
||||
var confObject = ConfigReader.ConfigObject;
|
||||
confObject.Info.RuntimeInfo.AppName = Assembly.GetExecutingAssembly().GetName().Name;
|
||||
var version = Assembly.GetExecutingAssembly().GetName().Version;
|
||||
confObject.Info.RuntimeInfo.AssemblyVersion = string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Build);
|
||||
|
||||
var msg = new
|
||||
{
|
||||
type = "join",
|
||||
content = new
|
||||
{
|
||||
config = confObject
|
||||
}
|
||||
};
|
||||
SendMessageObjectToServer(msg);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends any object type to server
|
||||
/// </summary>
|
||||
/// <param name="o"></param>
|
||||
public void SendMessageObjectToServer(object o)
|
||||
{
|
||||
SendMessageToServer(JObject.FromObject(o));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a message to the server from a room
|
||||
/// </summary>
|
||||
/// <param name="room">room from which the message originates</param>
|
||||
/// <param name="o">object to be serialized and sent in post body</param>
|
||||
public void SendMessageToServer(JObject o)
|
||||
{
|
||||
if (WSClient != null && WSClient.Connected)
|
||||
{
|
||||
string message = JsonConvert.SerializeObject(o, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
|
||||
|
||||
if (!message.Contains("/system/heartbeat"))
|
||||
Debug.Console(1, this, "Message TX: {0}", message);
|
||||
//else
|
||||
// Debug.Console(1, this, "TX messages contains /system/heartbeat");
|
||||
|
||||
var messageBytes = System.Text.Encoding.UTF8.GetBytes(message);
|
||||
var result = WSClient.Send(messageBytes, (uint)messageBytes.Length, WebSocketClient.WEBSOCKET_PACKET_TYPES.LWS_WS_OPCODE_07__TEXT_FRAME);
|
||||
if (result != WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_SUCCESS)
|
||||
{
|
||||
Debug.Console(1, this, "Socket send result error: {0}", result);
|
||||
}
|
||||
}
|
||||
else if (WSClient == null)
|
||||
{
|
||||
Debug.Console(1, this, "Cannot send. Not connected.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disconnects the SSE Client and stops the heartbeat timer
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
void CleanUpWebsocketClient()
|
||||
{
|
||||
Debug.Console(1, this, "Disconnecting websocket");
|
||||
if (WSClient != null)
|
||||
{
|
||||
WSClient.SendCallBack = null;
|
||||
WSClient.ReceiveCallBack = null;
|
||||
WSClient.ConnectionCallBack = null;
|
||||
WSClient.DisconnectCallBack = null;
|
||||
if (WSClient.Connected)
|
||||
{
|
||||
WSClient.Disconnect();
|
||||
}
|
||||
WSClient = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="dueTime"></param>
|
||||
/// <param name="repeatTime"></param>
|
||||
void StartServerReconnectTimer()
|
||||
{
|
||||
StopServerReconnectTimer();
|
||||
ServerReconnectTimer = new CTimer(ReconnectToServerTimerCallback, ServerReconnectInterval);
|
||||
Debug.Console(1, this, "Reconnect Timer Started.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Does what it says
|
||||
/// </summary>
|
||||
void StopServerReconnectTimer()
|
||||
{
|
||||
if (ServerReconnectTimer != null)
|
||||
{
|
||||
ServerReconnectTimer.Stop();
|
||||
ServerReconnectTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes when we don't get a heartbeat message in time. Triggers reconnect.
|
||||
/// </summary>
|
||||
/// <param name="o">For CTimer callback. Not used</param>
|
||||
void HeartbeatExpiredTimerCallback(object o)
|
||||
{
|
||||
Debug.Console(1, this, "Heartbeat Timer Expired.");
|
||||
if (ServerHeartbeatCheckTimer != null)
|
||||
{
|
||||
ServerHeartbeatCheckTimer.Stop();
|
||||
ServerHeartbeatCheckTimer = null;
|
||||
}
|
||||
CleanUpWebsocketClient();
|
||||
StartServerReconnectTimer();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="dueTime"></param>
|
||||
/// <param name="repeatTime"></param>
|
||||
void ResetOrStartHearbeatTimer()
|
||||
{
|
||||
if (ServerHeartbeatCheckTimer == null)
|
||||
{
|
||||
ServerHeartbeatCheckTimer = new CTimer(HeartbeatExpiredTimerCallback, null, ServerHeartbeatInterval, ServerHeartbeatInterval);
|
||||
Debug.Console(1, this, "Heartbeat Timer Started.");
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerHeartbeatCheckTimer.Reset(ServerHeartbeatInterval, ServerHeartbeatInterval);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Waits two and goes again
|
||||
/// </summary>
|
||||
void ReconnectStreamClient()
|
||||
{
|
||||
new CTimer(o => ConnectWebsocketClient(), 2000);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="code"></param>
|
||||
/// <returns></returns>
|
||||
int Websocket_DisconnectCallback(WebSocketClient.WEBSOCKET_RESULT_CODES code, object o)
|
||||
{
|
||||
Debug.Console(1, this, Debug.ErrorLogLevel.Warning, "Websocket disconnected with code: {0}", code);
|
||||
|
||||
if (ServerHeartbeatCheckTimer != null)
|
||||
ServerHeartbeatCheckTimer.Stop();
|
||||
// Start the reconnect timer
|
||||
StartServerReconnectTimer();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Resets reconnect timer and updates usercode
|
||||
/// </summary>
|
||||
/// <param name="content"></param>
|
||||
void HandleHeartBeat(JToken content)
|
||||
{
|
||||
SendMessageToServer(JObject.FromObject(new
|
||||
{
|
||||
type = "/system/heartbeatAck"
|
||||
}));
|
||||
|
||||
var code = content["userCode"];
|
||||
if(code != null)
|
||||
{
|
||||
foreach (var b in RoomBridges)
|
||||
{
|
||||
b.SetUserCode(code.Value<string>());
|
||||
}
|
||||
}
|
||||
ResetOrStartHearbeatTimer();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Outputs debug info when enabled
|
||||
/// </summary>
|
||||
/// <param name="req"></param>
|
||||
/// <param name="r"></param>
|
||||
/// <param name="e"></param>
|
||||
void CheckHttpDebug(HttpClientResponse r, HTTP_CALLBACK_ERROR e)
|
||||
{
|
||||
if (HttpDebugEnabled)
|
||||
{
|
||||
try
|
||||
{
|
||||
Debug.Console(0, this, "------ Begin HTTP Debug ---------------------------------------");
|
||||
if (r != null)
|
||||
{
|
||||
Debug.Console(0, this, "HTTP Response URL: {0}", r.ResponseUrl != null ? r.ResponseUrl.ToString() : "NONE");
|
||||
Debug.Console(0, this, "HTTP Response code: {0}", r.Code);
|
||||
Debug.Console(0, this, "HTTP Response content: \r{0}", r.ContentString);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Console(0, this, "No HTTP response");
|
||||
}
|
||||
Debug.Console(0, this, "HTTP Response 'error' {0}", e);
|
||||
Debug.Console(0, this, "------ End HTTP Debug -----------------------------------------");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.Console(0, this, "HttpDebugError: {0}", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="length"></param>
|
||||
/// <param name="opcode"></param>
|
||||
/// <param name="err"></param>
|
||||
int Websocket_ReceiveCallback(byte[] data, uint length, WebSocketClient.WEBSOCKET_PACKET_TYPES opcode,
|
||||
WebSocketClient.WEBSOCKET_RESULT_CODES err)
|
||||
{
|
||||
if (opcode == WebSocketClient.WEBSOCKET_PACKET_TYPES.LWS_WS_OPCODE_07__TEXT_FRAME)
|
||||
{
|
||||
var rx = System.Text.Encoding.UTF8.GetString(data, 0, (int)length);
|
||||
if (rx.Length > 0)
|
||||
ParseStreamRx(rx);
|
||||
WSClient.ReceiveAsync();
|
||||
}
|
||||
|
||||
else if (opcode == WebSocketClient.WEBSOCKET_PACKET_TYPES.LWS_WS_OPCODE_07__CLOSE)
|
||||
{
|
||||
Debug.Console(1, this, "Websocket disconnect received from remote");
|
||||
CleanUpWebsocketClient();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Console(1, this, "websocket rx opcode/err {0}/{1}", opcode, err);
|
||||
WSClient.ReceiveAsync();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Callback to catch possible errors in sending via the websocket
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
int Websocket_SendCallback(Crestron.SimplSharp.CrestronWebSocketClient.WebSocketClient.WEBSOCKET_RESULT_CODES result)
|
||||
{
|
||||
if(result != WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_SUCCESS)
|
||||
Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "SendCallback questionable result: {0}", result);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void ParseStreamRx(string message)
|
||||
{
|
||||
if(string.IsNullOrEmpty(message))
|
||||
return;
|
||||
|
||||
if (!message.Contains("/system/heartbeat"))
|
||||
{
|
||||
Debug.Console(1, this, "Message RX: {0}", message);
|
||||
}
|
||||
else
|
||||
{
|
||||
LastAckMessage = DateTime.Now;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var messageObj = JObject.Parse(message);
|
||||
|
||||
var type = messageObj["type"].Value<string>();
|
||||
|
||||
if (type == "hello")
|
||||
{
|
||||
SendInitialMessage();
|
||||
ResetOrStartHearbeatTimer();
|
||||
}
|
||||
else if (type == "/system/heartbeat")
|
||||
{
|
||||
HandleHeartBeat(messageObj["content"]);
|
||||
}
|
||||
else if (type == "raw")
|
||||
{
|
||||
var wrapper = messageObj["content"].ToObject<DeviceActionWrapper>();
|
||||
DeviceJsonApi.DoDeviceAction(wrapper);
|
||||
}
|
||||
else if (type == "close")
|
||||
{
|
||||
Debug.Console(1, this, "Received close message from server.");
|
||||
// DisconnectWebsocketClient();
|
||||
|
||||
if (ServerHeartbeatCheckTimer != null)
|
||||
ServerHeartbeatCheckTimer.Stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check path against Action dictionary
|
||||
if (ActionDictionary.ContainsKey(type))
|
||||
{
|
||||
var action = ActionDictionary[type];
|
||||
|
||||
if (action is Action)
|
||||
{
|
||||
(action as Action)();
|
||||
}
|
||||
else if (action is PressAndHoldAction)
|
||||
{
|
||||
var stateString = messageObj["content"]["state"].Value<string>();
|
||||
|
||||
// Look for a button press event
|
||||
if (!string.IsNullOrEmpty(stateString))
|
||||
{
|
||||
switch (stateString)
|
||||
{
|
||||
case "true":
|
||||
{
|
||||
if (!PushedActions.ContainsKey(type))
|
||||
{
|
||||
PushedActions.Add(type, new CTimer(o =>
|
||||
{
|
||||
(action as PressAndHoldAction)(false);
|
||||
PushedActions.Remove(type);
|
||||
}, null, ButtonHeartbeatInterval, ButtonHeartbeatInterval));
|
||||
}
|
||||
// Maybe add an else to reset the timer
|
||||
break;
|
||||
}
|
||||
case "held":
|
||||
{
|
||||
if (PushedActions.ContainsKey(type))
|
||||
{
|
||||
PushedActions[type].Reset(ButtonHeartbeatInterval, ButtonHeartbeatInterval);
|
||||
}
|
||||
return;
|
||||
}
|
||||
case "false":
|
||||
{
|
||||
if (PushedActions.ContainsKey(type))
|
||||
{
|
||||
PushedActions[type].Stop();
|
||||
PushedActions.Remove(type);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
(action as PressAndHoldAction)(stateString == "true");
|
||||
}
|
||||
}
|
||||
else if (action is Action<bool>)
|
||||
{
|
||||
var stateString = messageObj["content"]["state"].Value<string>();
|
||||
|
||||
if (!string.IsNullOrEmpty(stateString))
|
||||
{
|
||||
(action as Action<bool>)(stateString == "true");
|
||||
}
|
||||
}
|
||||
else if (action is Action<ushort>)
|
||||
{
|
||||
(action as Action<ushort>)(messageObj["content"]["value"].Value<ushort>());
|
||||
}
|
||||
else if (action is Action<string>)
|
||||
{
|
||||
(action as Action<string>)(messageObj["content"]["value"].Value<string>());
|
||||
}
|
||||
else if (action is Action<SourceSelectMessageContent>)
|
||||
{
|
||||
(action as Action<SourceSelectMessageContent>)(messageObj["content"]
|
||||
.ToObject<SourceSelectMessageContent>());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Console(1, this, "-- Warning: Incoming message has no registered handler");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
//Debug.Console(1, "SseMessageLengthBeforeFailureCount: {0}", SseMessageLengthBeforeFailureCount);
|
||||
//SseMessageLengthBeforeFailureCount = 0;
|
||||
Debug.Console(1, this, "Unable to parse message: {0}", err);
|
||||
}
|
||||
}
|
||||
|
||||
void TestHttpRequest(string s)
|
||||
{
|
||||
{
|
||||
s = s.Trim();
|
||||
if (string.IsNullOrEmpty(s))
|
||||
{
|
||||
PrintTestHttpRequestUsage();
|
||||
return;
|
||||
}
|
||||
var tokens = s.Split(' ');
|
||||
if (tokens.Length < 2)
|
||||
{
|
||||
CrestronConsole.ConsoleCommandResponse("Too few paramaters\r");
|
||||
PrintTestHttpRequestUsage();
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var url = tokens[1];
|
||||
if (tokens[0].ToLower() == "get")
|
||||
{
|
||||
var resp = new HttpClient().Get(url);
|
||||
CrestronConsole.ConsoleCommandResponse("RESPONSE:\r{0}\r\r", resp);
|
||||
}
|
||||
else if (tokens[0].ToLower() == "post")
|
||||
{
|
||||
var resp = new HttpClient().Post(url, new byte[] { });
|
||||
CrestronConsole.ConsoleCommandResponse("RESPONSE:\r{0}\r\r", resp);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
CrestronConsole.ConsoleCommandResponse("Only get or post supported\r");
|
||||
PrintTestHttpRequestUsage();
|
||||
}
|
||||
}
|
||||
catch (HttpException e)
|
||||
{
|
||||
CrestronConsole.ConsoleCommandResponse("Exception in request:\r");
|
||||
CrestronConsole.ConsoleCommandResponse("Response URL: {0}\r", e.Response.ResponseUrl);
|
||||
CrestronConsole.ConsoleCommandResponse("Response Error Code: {0}\r", e.Response.Code);
|
||||
CrestronConsole.ConsoleCommandResponse("Response body: {0}\r", e.Response.ContentString);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void PrintTestHttpRequestUsage()
|
||||
{
|
||||
CrestronConsole.ConsoleCommandResponse("Usage: mobilehttprequest:N get/post url\r");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,37 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Room.Cotija
|
||||
{
|
||||
public static class IChannelExtensions
|
||||
{
|
||||
public static void LinkActions(this IChannel dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.AddAction(prefix + "chanup", new PressAndHoldAction(dev.ChannelUp));
|
||||
controller.AddAction(prefix + "chandown", new PressAndHoldAction(dev.ChannelDown));
|
||||
controller.AddAction(prefix + "lastchan", new PressAndHoldAction(dev.LastChannel));
|
||||
controller.AddAction(prefix + "guide", new PressAndHoldAction(dev.Guide));
|
||||
controller.AddAction(prefix + "info", new PressAndHoldAction(dev.Info));
|
||||
controller.AddAction(prefix + "exit", new PressAndHoldAction(dev.Exit));
|
||||
}
|
||||
|
||||
public static void UnlinkActions(this IChannel dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.RemoveAction(prefix + "chanup");
|
||||
controller.RemoveAction(prefix + "chandown");
|
||||
controller.RemoveAction(prefix + "lastchan");
|
||||
controller.RemoveAction(prefix + "guide");
|
||||
controller.RemoveAction(prefix + "info");
|
||||
controller.RemoveAction(prefix + "exit");
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Room.Cotija
|
||||
{
|
||||
public static class IChannelExtensions
|
||||
{
|
||||
public static void LinkActions(this IChannel dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.AddAction(prefix + "chanUp", new PressAndHoldAction(dev.ChannelUp));
|
||||
controller.AddAction(prefix + "chanDown", new PressAndHoldAction(dev.ChannelDown));
|
||||
controller.AddAction(prefix + "lastChan", new PressAndHoldAction(dev.LastChannel));
|
||||
controller.AddAction(prefix + "guide", new PressAndHoldAction(dev.Guide));
|
||||
controller.AddAction(prefix + "info", new PressAndHoldAction(dev.Info));
|
||||
controller.AddAction(prefix + "exit", new PressAndHoldAction(dev.Exit));
|
||||
}
|
||||
|
||||
public static void UnlinkActions(this IChannel dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.RemoveAction(prefix + "chanUp");
|
||||
controller.RemoveAction(prefix + "chanDown");
|
||||
controller.RemoveAction(prefix + "lastChan");
|
||||
controller.RemoveAction(prefix + "guide");
|
||||
controller.RemoveAction(prefix + "info");
|
||||
controller.RemoveAction(prefix + "exit");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Room.Cotija
|
||||
{
|
||||
public static class IColorExtensions
|
||||
{
|
||||
public static void LinkActions(this IColor dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.AddAction(prefix + "red", new PressAndHoldAction(dev.Red));
|
||||
controller.AddAction(prefix + "green", new PressAndHoldAction(dev.Green));
|
||||
controller.AddAction(prefix + "yellow", new PressAndHoldAction(dev.Yellow));
|
||||
controller.AddAction(prefix + "blue", new PressAndHoldAction(dev.Blue));
|
||||
}
|
||||
|
||||
public static void UnlinkActions(this IColor dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.RemoveAction(prefix + "red");
|
||||
controller.RemoveAction(prefix + "green");
|
||||
controller.RemoveAction(prefix + "yellow");
|
||||
controller.RemoveAction(prefix + "blue");
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Room.Cotija
|
||||
{
|
||||
public static class IColorExtensions
|
||||
{
|
||||
public static void LinkActions(this IColor dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.AddAction(prefix + "red", new PressAndHoldAction(dev.Red));
|
||||
controller.AddAction(prefix + "green", new PressAndHoldAction(dev.Green));
|
||||
controller.AddAction(prefix + "yellow", new PressAndHoldAction(dev.Yellow));
|
||||
controller.AddAction(prefix + "blue", new PressAndHoldAction(dev.Blue));
|
||||
}
|
||||
|
||||
public static void UnlinkActions(this IColor dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.RemoveAction(prefix + "red");
|
||||
controller.RemoveAction(prefix + "green");
|
||||
controller.RemoveAction(prefix + "yellow");
|
||||
controller.RemoveAction(prefix + "blue");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,39 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Room.Cotija
|
||||
{
|
||||
public static class IDPadExtensions
|
||||
{
|
||||
public static void LinkActions(this IDPad dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.AddAction(prefix + "up", new PressAndHoldAction(dev.Up));
|
||||
controller.AddAction(prefix + "down", new PressAndHoldAction(dev.Down));
|
||||
controller.AddAction(prefix + "left", new PressAndHoldAction(dev.Left));
|
||||
controller.AddAction(prefix + "right", new PressAndHoldAction(dev.Right));
|
||||
controller.AddAction(prefix + "select", new PressAndHoldAction(dev.Select));
|
||||
controller.AddAction(prefix + "menu", new PressAndHoldAction(dev.Menu));
|
||||
controller.AddAction(prefix + "exit", new PressAndHoldAction(dev.Exit));
|
||||
}
|
||||
|
||||
public static void UnlinkActions(this IDPad dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.RemoveAction(prefix + "up");
|
||||
controller.RemoveAction(prefix + "down");
|
||||
controller.RemoveAction(prefix + "left");
|
||||
controller.RemoveAction(prefix + "right");
|
||||
controller.RemoveAction(prefix + "select");
|
||||
controller.RemoveAction(prefix + "menu");
|
||||
controller.RemoveAction(prefix + "exit");
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Room.Cotija
|
||||
{
|
||||
public static class IDPadExtensions
|
||||
{
|
||||
public static void LinkActions(this IDPad dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.AddAction(prefix + "up", new PressAndHoldAction(dev.Up));
|
||||
controller.AddAction(prefix + "down", new PressAndHoldAction(dev.Down));
|
||||
controller.AddAction(prefix + "left", new PressAndHoldAction(dev.Left));
|
||||
controller.AddAction(prefix + "right", new PressAndHoldAction(dev.Right));
|
||||
controller.AddAction(prefix + "select", new PressAndHoldAction(dev.Select));
|
||||
controller.AddAction(prefix + "menu", new PressAndHoldAction(dev.Menu));
|
||||
controller.AddAction(prefix + "exit", new PressAndHoldAction(dev.Exit));
|
||||
}
|
||||
|
||||
public static void UnlinkActions(this IDPad dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.RemoveAction(prefix + "up");
|
||||
controller.RemoveAction(prefix + "down");
|
||||
controller.RemoveAction(prefix + "left");
|
||||
controller.RemoveAction(prefix + "right");
|
||||
controller.RemoveAction(prefix + "select");
|
||||
controller.RemoveAction(prefix + "menu");
|
||||
controller.RemoveAction(prefix + "exit");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Room.Cotija
|
||||
{
|
||||
public static class IDvrExtensions
|
||||
{
|
||||
public static void LinkActions(this IDvr dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.AddAction(prefix + "dvrlist", new PressAndHoldAction(dev.DvrList));
|
||||
controller.AddAction(prefix + "record", new PressAndHoldAction(dev.Record));
|
||||
}
|
||||
|
||||
public static void UnlinkActions(this IDvr dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.RemoveAction(prefix + "dvrlist");
|
||||
controller.RemoveAction(prefix + "record");
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Room.Cotija
|
||||
{
|
||||
public static class IDvrExtensions
|
||||
{
|
||||
public static void LinkActions(this IDvr dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.AddAction(prefix + "dvrlist", new PressAndHoldAction(dev.DvrList));
|
||||
controller.AddAction(prefix + "record", new PressAndHoldAction(dev.Record));
|
||||
}
|
||||
|
||||
public static void UnlinkActions(this IDvr dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.RemoveAction(prefix + "dvrlist");
|
||||
controller.RemoveAction(prefix + "record");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,50 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Room.Cotija
|
||||
{
|
||||
public static class INumericExtensions
|
||||
{
|
||||
public static void LinkActions(this INumericKeypad dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.AddAction(prefix + "num0", new PressAndHoldAction(dev.Digit0));
|
||||
controller.AddAction(prefix + "num1", new PressAndHoldAction(dev.Digit1));
|
||||
controller.AddAction(prefix + "num2", new PressAndHoldAction(dev.Digit2));
|
||||
controller.AddAction(prefix + "num3", new PressAndHoldAction(dev.Digit3));
|
||||
controller.AddAction(prefix + "num4", new PressAndHoldAction(dev.Digit4));
|
||||
controller.AddAction(prefix + "num5", new PressAndHoldAction(dev.Digit5));
|
||||
controller.AddAction(prefix + "num6", new PressAndHoldAction(dev.Digit6));
|
||||
controller.AddAction(prefix + "num7", new PressAndHoldAction(dev.Digit0));
|
||||
controller.AddAction(prefix + "num8", new PressAndHoldAction(dev.Digit0));
|
||||
controller.AddAction(prefix + "num9", new PressAndHoldAction(dev.Digit0));
|
||||
controller.AddAction(prefix + "dash", new PressAndHoldAction(dev.KeypadAccessoryButton1));
|
||||
controller.AddAction(prefix + "enter", new PressAndHoldAction(dev.KeypadAccessoryButton2));
|
||||
#warning Deal with the Accessory functions on the numpad later
|
||||
}
|
||||
|
||||
public static void UnlinkActions(this INumericKeypad dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.RemoveAction(prefix + "num0");
|
||||
controller.RemoveAction(prefix + "num1");
|
||||
controller.RemoveAction(prefix + "num2");
|
||||
controller.RemoveAction(prefix + "num3");
|
||||
controller.RemoveAction(prefix + "num4");
|
||||
controller.RemoveAction(prefix + "num5");
|
||||
controller.RemoveAction(prefix + "num6");
|
||||
controller.RemoveAction(prefix + "num7");
|
||||
controller.RemoveAction(prefix + "num8");
|
||||
controller.RemoveAction(prefix + "num9");
|
||||
controller.RemoveAction(prefix + "dash");
|
||||
controller.RemoveAction(prefix + "enter");
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Room.Cotija
|
||||
{
|
||||
public static class INumericExtensions
|
||||
{
|
||||
public static void LinkActions(this INumericKeypad dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.AddAction(prefix + "num0", new PressAndHoldAction(dev.Digit0));
|
||||
controller.AddAction(prefix + "num1", new PressAndHoldAction(dev.Digit1));
|
||||
controller.AddAction(prefix + "num2", new PressAndHoldAction(dev.Digit2));
|
||||
controller.AddAction(prefix + "num3", new PressAndHoldAction(dev.Digit3));
|
||||
controller.AddAction(prefix + "num4", new PressAndHoldAction(dev.Digit4));
|
||||
controller.AddAction(prefix + "num5", new PressAndHoldAction(dev.Digit5));
|
||||
controller.AddAction(prefix + "num6", new PressAndHoldAction(dev.Digit6));
|
||||
controller.AddAction(prefix + "num7", new PressAndHoldAction(dev.Digit0));
|
||||
controller.AddAction(prefix + "num8", new PressAndHoldAction(dev.Digit0));
|
||||
controller.AddAction(prefix + "num9", new PressAndHoldAction(dev.Digit0));
|
||||
controller.AddAction(prefix + "numDash", new PressAndHoldAction(dev.KeypadAccessoryButton1));
|
||||
controller.AddAction(prefix + "numEnter", new PressAndHoldAction(dev.KeypadAccessoryButton2));
|
||||
// Deal with the Accessory functions on the numpad later
|
||||
}
|
||||
|
||||
public static void UnlinkActions(this INumericKeypad dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.RemoveAction(prefix + "num0");
|
||||
controller.RemoveAction(prefix + "num1");
|
||||
controller.RemoveAction(prefix + "num2");
|
||||
controller.RemoveAction(prefix + "num3");
|
||||
controller.RemoveAction(prefix + "num4");
|
||||
controller.RemoveAction(prefix + "num5");
|
||||
controller.RemoveAction(prefix + "num6");
|
||||
controller.RemoveAction(prefix + "num7");
|
||||
controller.RemoveAction(prefix + "num8");
|
||||
controller.RemoveAction(prefix + "num9");
|
||||
controller.RemoveAction(prefix + "numDash");
|
||||
controller.RemoveAction(prefix + "numEnter");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Room.Cotija
|
||||
{
|
||||
public static class IPowerExtensions
|
||||
{
|
||||
public static void LinkActions(this IPower dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.AddAction(prefix + "poweron", new Action(dev.PowerOn));
|
||||
controller.AddAction(prefix + "poweroff", new Action(dev.PowerOff));
|
||||
controller.AddAction(prefix + "powertoggle", new Action(dev.PowerToggle));
|
||||
}
|
||||
|
||||
public static void UnlinkActions(this IPower dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.RemoveAction(prefix + "poweron");
|
||||
controller.RemoveAction(prefix + "poweroff");
|
||||
controller.RemoveAction(prefix + "powertoggle");
|
||||
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Room.Cotija
|
||||
{
|
||||
public static class IPowerExtensions
|
||||
{
|
||||
public static void LinkActions(this IPower dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.AddAction(prefix + "powerOn", new Action(dev.PowerOn));
|
||||
controller.AddAction(prefix + "powerOff", new Action(dev.PowerOff));
|
||||
controller.AddAction(prefix + "powerToggle", new Action(dev.PowerToggle));
|
||||
}
|
||||
|
||||
public static void UnlinkActions(this IPower dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.RemoveAction(prefix + "powerOn");
|
||||
controller.RemoveAction(prefix + "powerOff");
|
||||
controller.RemoveAction(prefix + "powerToggle");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Room.Cotija
|
||||
{
|
||||
public static class ISetTopBoxControlsExtensions
|
||||
{
|
||||
public static void LinkActions(this ISetTopBoxControls dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.AddAction(prefix + "dvrlist", new PressAndHoldAction(dev.DvrList));
|
||||
controller.AddAction(prefix + "replay", new PressAndHoldAction(dev.Replay));
|
||||
}
|
||||
|
||||
public static void UnlinkActions(this ISetTopBoxControls dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.RemoveAction(prefix + "dvrlist");
|
||||
controller.RemoveAction(prefix + "replay");
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Room.Cotija
|
||||
{
|
||||
public static class ISetTopBoxControlsExtensions
|
||||
{
|
||||
public static void LinkActions(this ISetTopBoxControls dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.AddAction(prefix + "dvrList", new PressAndHoldAction(dev.DvrList));
|
||||
controller.AddAction(prefix + "replay", new PressAndHoldAction(dev.Replay));
|
||||
}
|
||||
|
||||
public static void UnlinkActions(this ISetTopBoxControls dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.RemoveAction(prefix + "dvrList");
|
||||
controller.RemoveAction(prefix + "replay");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,41 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Room.Cotija
|
||||
{
|
||||
public static class ITransportExtensions
|
||||
{
|
||||
public static void LinkActions(this ITransport dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.AddAction(prefix + "play", new PressAndHoldAction(dev.Play));
|
||||
controller.AddAction(prefix + "pause", new PressAndHoldAction(dev.Pause));
|
||||
controller.AddAction(prefix + "stop", new PressAndHoldAction(dev.Stop));
|
||||
controller.AddAction(prefix + "prevtrack", new PressAndHoldAction(dev.ChapPlus));
|
||||
controller.AddAction(prefix + "nexttrack", new PressAndHoldAction(dev.ChapMinus));
|
||||
controller.AddAction(prefix + "rewind", new PressAndHoldAction(dev.Rewind));
|
||||
controller.AddAction(prefix + "ffwd", new PressAndHoldAction(dev.FFwd));
|
||||
controller.AddAction(prefix + "record", new PressAndHoldAction(dev.Record));
|
||||
}
|
||||
|
||||
public static void UnlinkActions(this ITransport dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.RemoveAction(prefix + "play");
|
||||
controller.RemoveAction(prefix + "pause");
|
||||
controller.RemoveAction(prefix + "stop");
|
||||
controller.RemoveAction(prefix + "prevtrack");
|
||||
controller.RemoveAction(prefix + "nexttrack");
|
||||
controller.RemoveAction(prefix + "rewind");
|
||||
controller.RemoveAction(prefix + "ffwd");
|
||||
controller.RemoveAction(prefix + "record");
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Room.Cotija
|
||||
{
|
||||
public static class ITransportExtensions
|
||||
{
|
||||
public static void LinkActions(this ITransport dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.AddAction(prefix + "play", new PressAndHoldAction(dev.Play));
|
||||
controller.AddAction(prefix + "pause", new PressAndHoldAction(dev.Pause));
|
||||
controller.AddAction(prefix + "stop", new PressAndHoldAction(dev.Stop));
|
||||
controller.AddAction(prefix + "prevTrack", new PressAndHoldAction(dev.ChapPlus));
|
||||
controller.AddAction(prefix + "nextTrack", new PressAndHoldAction(dev.ChapMinus));
|
||||
controller.AddAction(prefix + "rewind", new PressAndHoldAction(dev.Rewind));
|
||||
controller.AddAction(prefix + "ffwd", new PressAndHoldAction(dev.FFwd));
|
||||
controller.AddAction(prefix + "record", new PressAndHoldAction(dev.Record));
|
||||
}
|
||||
|
||||
public static void UnlinkActions(this ITransport dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.RemoveAction(prefix + "play");
|
||||
controller.RemoveAction(prefix + "pause");
|
||||
controller.RemoveAction(prefix + "stop");
|
||||
controller.RemoveAction(prefix + "prevTrack");
|
||||
controller.RemoveAction(prefix + "nextTrack");
|
||||
controller.RemoveAction(prefix + "rewind");
|
||||
controller.RemoveAction(prefix + "ffwd");
|
||||
controller.RemoveAction(prefix + "record");
|
||||
}
|
||||
}
|
||||
}
|
||||
60
PepperDashEssentials/AppServer/Interfaces.cs
Normal file
60
PepperDashEssentials/AppServer/Interfaces.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
using PepperDash.Essentials.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Room.Cotija
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a room whose configuration is derived from runtime data,
|
||||
/// perhaps from another program, and that the data may not be fully
|
||||
/// available at startup.
|
||||
/// </summary>
|
||||
public interface IDelayedConfiguration
|
||||
{
|
||||
event EventHandler<EventArgs> ConfigurationIsReady;
|
||||
}
|
||||
}
|
||||
|
||||
namespace PepperDash.Essentials
|
||||
{
|
||||
/// <summary>
|
||||
/// For rooms with a single presentation source, change event
|
||||
/// </summary>
|
||||
public interface IHasCurrentSourceInfoChange
|
||||
{
|
||||
string CurrentSourceInfoKey { get; }
|
||||
SourceListItem CurrentSourceInfo { get; }
|
||||
event SourceInfoChangeHandler CurrentSingleSourceChange;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// For rooms with routing
|
||||
/// </summary>
|
||||
public interface IRunRouteAction
|
||||
{
|
||||
void RunRouteAction(string routeKey);
|
||||
|
||||
void RunRouteAction(string routeKey, Action successCallback);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For rooms that default presentation only routing
|
||||
/// </summary>
|
||||
public interface IRunDefaultPresentRoute
|
||||
{
|
||||
bool RunDefaultPresentRoute();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For rooms that have default presentation and calling routes
|
||||
/// </summary>
|
||||
public interface IRunDefaultCallRoute : IRunDefaultPresentRoute
|
||||
{
|
||||
bool RunDefaultCallRoute();
|
||||
}
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,373 @@
|
||||
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.Cameras;
|
||||
using PepperDash.Essentials.Devices.Common.VideoCodec;
|
||||
|
||||
namespace PepperDash.Essentials.AppServer.Messengers
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides a messaging bridge for a VideoCodecBase device
|
||||
/// </summary>
|
||||
public class VideoCodecBaseMessenger : MessengerBase
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public VideoCodecBase Codec { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="codec"></param>
|
||||
public VideoCodecBaseMessenger(string key, VideoCodecBase codec, string messagePath)
|
||||
: base(key, messagePath)
|
||||
{
|
||||
if (codec == null)
|
||||
throw new ArgumentNullException("codec");
|
||||
|
||||
Codec = codec;
|
||||
codec.CallStatusChange += new EventHandler<CodecCallStatusItemChangeEventArgs>(codec_CallStatusChange);
|
||||
codec.IsReadyChange += new EventHandler<EventArgs>(codec_IsReadyChange);
|
||||
|
||||
var dirCodec = codec as IHasDirectory;
|
||||
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>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void dirCodec_DirectoryResultReturned(object sender, DirectoryEventArgs e)
|
||||
{
|
||||
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>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void codec_IsReadyChange(object sender, EventArgs e)
|
||||
{
|
||||
PostStatusMessage(new
|
||||
{
|
||||
isReady = true
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called from base's RegisterWithAppServer method
|
||||
/// </summary>
|
||||
/// <param name="appServerController"></param>
|
||||
protected override void CustomRegisterWithAppServer(CotijaSystemController 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)));
|
||||
appServerController.AddAction("/device/videoCodec/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);
|
||||
}));
|
||||
|
||||
// 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));
|
||||
appServerController.AddAction(MessagePath + "/sharingStart", new Action(Codec.StartSharing));
|
||||
appServerController.AddAction(MessagePath + "/sharingStop", new Action(Codec.StopSharing));
|
||||
appServerController.AddAction(MessagePath + "/standbyOn", new Action(Codec.StandbyActivate));
|
||||
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()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
void DirectorySearch(string s)
|
||||
{
|
||||
var dirCodec = Codec as IHasDirectory;
|
||||
if (dirCodec != null)
|
||||
{
|
||||
dirCodec.SearchDirectory(s);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
void GetDirectory(string id)
|
||||
{
|
||||
var dirCodec = Codec as IHasDirectory;
|
||||
if(dirCodec == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
dirCodec.GetDirectoryFolderContents(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
void GetDirectoryRoot()
|
||||
{
|
||||
var dirCodec = Codec as IHasDirectory;
|
||||
if (dirCodec == null)
|
||||
{
|
||||
// do something else?
|
||||
return;
|
||||
}
|
||||
if (!dirCodec.PhonebookSyncState.InitialSyncComplete)
|
||||
{
|
||||
PostStatusMessage(new
|
||||
{
|
||||
initialSyncComplete = false
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
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>
|
||||
void codec_CallStatusChange(object sender, CodecCallStatusItemChangeEventArgs e)
|
||||
{
|
||||
SendVtcFullMessageObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
void SendIsReady()
|
||||
{
|
||||
PostStatusMessage(new
|
||||
{
|
||||
isReady = Codec.IsReady
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method to build call status for vtc
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
void SendVtcFullMessageObject()
|
||||
{
|
||||
if (!Codec.IsReady)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var info = Codec.CodecInfo;
|
||||
PostStatusMessage(new
|
||||
{
|
||||
isInCall = Codec.IsInCall,
|
||||
privacyModeIsOn = Codec.PrivacyModeIsOnFeedback.BoolValue,
|
||||
sharingContentIsOn = Codec.SharingContentIsOnFeedback.BoolValue,
|
||||
sharingSource = Codec.SharingSourceFeedback.StringValue,
|
||||
standbyIsOn = Codec.StandbyIsOnFeedback.StringValue,
|
||||
calls = Codec.ActiveCalls,
|
||||
info = new
|
||||
{
|
||||
autoAnswerEnabled = info.AutoAnswerEnabled,
|
||||
e164Alias = info.E164Alias,
|
||||
h323Id = info.H323Id,
|
||||
ipAddress = info.IpAddress,
|
||||
sipPhoneNumber = info.SipPhoneNumber,
|
||||
sipURI = info.SipUri
|
||||
},
|
||||
showSelfViewByDefault = Codec.ShowSelfViewByDefault,
|
||||
hasDirectory = Codec is IHasDirectory,
|
||||
hasDirectorySearch = true,
|
||||
hasRecents = Codec is IHasCallHistory,
|
||||
hasCameras = Codec is IHasCodecCameras
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
|
||||
namespace PepperDash.Essentials
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public abstract class CotijaBridgeBase: Device
|
||||
{
|
||||
public CotijaSystemController Parent { get; private set; }
|
||||
|
||||
public string UserCode { get; private set; }
|
||||
|
||||
public abstract string RoomName { get; }
|
||||
|
||||
public CotijaBridgeBase(string key, string name)
|
||||
: base(key, name)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the parent. Does nothing else. Override to add functionality such
|
||||
/// as adding actions to parent
|
||||
/// </summary>
|
||||
/// <param name="parent"></param>
|
||||
public virtual void AddParent(CotijaSystemController parent)
|
||||
{
|
||||
Parent = parent;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the UserCode on the bridge object. Called from controller. A changed code will
|
||||
/// fire method UserCodeChange. Override that to handle changes
|
||||
/// </summary>
|
||||
/// <param name="code"></param>
|
||||
public void SetUserCode(string code)
|
||||
{
|
||||
var changed = UserCode != code;
|
||||
UserCode = code;
|
||||
if (changed)
|
||||
{
|
||||
UserCodeChange();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Empty method in base class. Override this to add functionality
|
||||
/// when code changes
|
||||
/// </summary>
|
||||
protected virtual void UserCodeChange()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,882 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharp.Reflection;
|
||||
using Crestron.SimplSharpPro.EthernetCommunication;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
namespace PepperDash.Essentials.Room.Cotija
|
||||
{
|
||||
public class CotijaDdvc01RoomBridge : CotijaBridgeBase, IDelayedConfiguration
|
||||
{
|
||||
public class BoolJoin
|
||||
{
|
||||
/// <summary>
|
||||
/// 301
|
||||
/// </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 ActivityShare = 51;
|
||||
/// <summary>
|
||||
/// 52
|
||||
/// </summary>
|
||||
public const uint ActivityPhoneCall = 52;
|
||||
/// <summary>
|
||||
/// 53
|
||||
/// </summary>
|
||||
public const uint ActivityVideoCall = 53;
|
||||
|
||||
/// <summary>
|
||||
/// 1
|
||||
/// </summary>
|
||||
public const uint MasterVolumeIsMuted = 1;
|
||||
/// <summary>
|
||||
/// 1
|
||||
/// </summary>
|
||||
public const uint MasterVolumeMuteToggle = 1;
|
||||
/// <summary>
|
||||
/// 1
|
||||
/// </summary>
|
||||
public const uint VolumeMutesJoinStart = 1;
|
||||
/// <summary>
|
||||
/// 61
|
||||
/// </summary>
|
||||
public const uint ShutdownCancel = 61;
|
||||
/// <summary>
|
||||
/// 62
|
||||
/// </summary>
|
||||
public const uint ShutdownEnd = 62;
|
||||
/// <summary>
|
||||
/// 63
|
||||
/// </summary>
|
||||
public const uint ShutdownStart = 63;
|
||||
/// <summary>
|
||||
/// 72
|
||||
/// </summary>
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// </summary>
|
||||
public const uint ConfigRoomName = 501;
|
||||
/// <summary>
|
||||
/// 502
|
||||
/// </summary>
|
||||
public const uint ConfigHelpMessage = 502;
|
||||
/// <summary>
|
||||
/// 503
|
||||
/// </summary>
|
||||
public const uint ConfigHelpNumber = 503;
|
||||
/// <summary>
|
||||
/// 504
|
||||
/// </summary>
|
||||
public const uint ConfigRoomPhoneNumber = 504;
|
||||
/// <summary>
|
||||
/// 505
|
||||
/// </summary>
|
||||
public const uint ConfigRoomURI = 505;
|
||||
/// <summary>
|
||||
/// 401
|
||||
/// </summary>
|
||||
public const uint UserCodeToSystem = 401;
|
||||
/// <summary>
|
||||
/// 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>
|
||||
/// Fires when config is ready to go
|
||||
/// </summary>
|
||||
public event EventHandler<EventArgs> ConfigurationIsReady;
|
||||
|
||||
public ThreeSeriesTcpIpEthernetIntersystemCommunications EISC { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool ConfigIsLoaded { get; private set; }
|
||||
|
||||
public override string RoomName
|
||||
{
|
||||
get {
|
||||
var name = EISC.StringOutput[StringJoin.ConfigRoomName].StringValue;
|
||||
return string.IsNullOrEmpty(name) ? "Not Loaded" : name;
|
||||
}
|
||||
}
|
||||
|
||||
CotijaDdvc01DeviceBridge SourceBridge;
|
||||
|
||||
Ddvc01AtcMessenger AtcMessenger;
|
||||
Ddvc01VtcMessenger VtcMessenger;
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="ipId"></param>
|
||||
public CotijaDdvc01RoomBridge(string key, string name, uint ipId)
|
||||
: base(key, name)
|
||||
{
|
||||
try
|
||||
{
|
||||
EISC = new ThreeSeriesTcpIpEthernetIntersystemCommunications(ipId, "127.0.0.2", Global.ControlSystem);
|
||||
var reg = EISC.Register();
|
||||
if (reg != Crestron.SimplSharpPro.eDeviceRegistrationUnRegistrationResponse.Success)
|
||||
Debug.Console(0, this, "Cannot connect EISC at IPID {0}: \r{1}", ipId, reg);
|
||||
|
||||
SourceBridge = new CotijaDdvc01DeviceBridge(key + "-sourceBridge", "DDVC01 source bridge", EISC);
|
||||
DeviceManager.AddDevice(SourceBridge);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finish wiring up everything after all devices are created. The base class will hunt down the related
|
||||
/// parent controller and link them up.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override bool CustomActivate()
|
||||
{
|
||||
Debug.Console(0, this, "Final activation. Setting up actions and feedbacks");
|
||||
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) =>
|
||||
{
|
||||
Debug.Console(1, this, "DDVC EISC online={0}. Config is ready={1}", a.DeviceOnLine, EISC.BooleanOutput[BoolJoin.ConfigIsReady].BoolValue);
|
||||
if (a.DeviceOnLine && EISC.BooleanOutput[BoolJoin.ConfigIsReady].BoolValue)
|
||||
LoadConfigValues();
|
||||
};
|
||||
// load config if it's already there
|
||||
if (EISC.IsOnline && EISC.BooleanOutput[BoolJoin.ConfigIsReady].BoolValue) // || EISC.BooleanInput[BoolJoin.ConfigIsReady].BoolValue)
|
||||
LoadConfigValues();
|
||||
|
||||
|
||||
CrestronConsole.AddNewConsoleCommand(s =>
|
||||
{
|
||||
for (uint i = 1; i < 1000; i++)
|
||||
{
|
||||
if (s.ToLower().Equals("b"))
|
||||
{
|
||||
CrestronConsole.ConsoleCommandResponse("D{0,6} {1} - ", i, EISC.BooleanOutput[i].BoolValue);
|
||||
}
|
||||
else if (s.ToLower().Equals("u"))
|
||||
{
|
||||
CrestronConsole.ConsoleCommandResponse("U{0,6} {1,8} - ", i, EISC.UShortOutput[i].UShortValue);
|
||||
}
|
||||
else if (s.ToLower().Equals("s"))
|
||||
{
|
||||
var val = EISC.StringOutput[i].StringValue;
|
||||
if(!string.IsNullOrEmpty(val))
|
||||
CrestronConsole.ConsoleCommandResponse("S{0,6} {1}\r", i, EISC.StringOutput[i].StringValue);
|
||||
}
|
||||
|
||||
}
|
||||
}, "mobilebridgedump", "Dumps DDVC01 bridge EISC data b,u,s", ConsoleAccessLevelEnum.AccessOperator);
|
||||
|
||||
return base.CustomActivate();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Setup the actions to take place on various incoming API calls
|
||||
/// </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));
|
||||
|
||||
Parent.AddAction(@"/room/room1/source", new Action<SourceSelectMessageContent>(c =>
|
||||
{
|
||||
EISC.SetString(StringJoin.SelectedSourceKey, c.SourceListItem);
|
||||
EISC.PulseBool(BoolJoin.SourceHasChanged);
|
||||
}));
|
||||
|
||||
Parent.AddAction(@"/room/room1/defaultsource", new Action(() =>
|
||||
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)));
|
||||
Parent.AddAction(@"/room/room1/shutdownEnd", new Action(() =>
|
||||
EISC.PulseBool(BoolJoin.ShutdownEnd)));
|
||||
Parent.AddAction(@"/room/room1/shutdownCancel", new Action(() =>
|
||||
EISC.PulseBool(BoolJoin.ShutdownCancel)));
|
||||
}
|
||||
|
||||
/// <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>
|
||||
void SetupFeedbacks()
|
||||
{
|
||||
// Power
|
||||
EISC.SetBoolSigAction(BoolJoin.RoomIsOn, b =>
|
||||
PostStatusMessage(new
|
||||
{
|
||||
isOn = b
|
||||
}));
|
||||
|
||||
// Source change things
|
||||
EISC.SetSigTrueAction(BoolJoin.SourceHasChanged, () =>
|
||||
PostStatusMessage(new
|
||||
{
|
||||
selectedSourceKey = EISC.StringOutput[StringJoin.SelectedSourceKey].StringValue
|
||||
}));
|
||||
|
||||
// Volume things
|
||||
EISC.SetUShortSigAction(UshortJoin.MasterVolumeLevel, u =>
|
||||
PostStatusMessage(new
|
||||
{
|
||||
volumes = new
|
||||
{
|
||||
master = new
|
||||
{
|
||||
level = u
|
||||
}
|
||||
}
|
||||
}));
|
||||
EISC.SetBoolSigAction(BoolJoin.MasterVolumeIsMuted, b =>
|
||||
PostStatusMessage(new
|
||||
{
|
||||
volumes = new
|
||||
{
|
||||
master = new
|
||||
{
|
||||
muted = b
|
||||
}
|
||||
}
|
||||
}));
|
||||
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
|
||||
EISC.SetSigTrueAction(BoolJoin.ShutdownCancel, new Action(() =>
|
||||
PostMessage("/room/shutdown/", new
|
||||
{
|
||||
state = "wasCancelled"
|
||||
})));
|
||||
EISC.SetSigTrueAction(BoolJoin.ShutdownEnd, new Action(() =>
|
||||
PostMessage("/room/shutdown/", new
|
||||
{
|
||||
state = "hasFinished"
|
||||
})));
|
||||
EISC.SetSigTrueAction(BoolJoin.ShutdownStart, new Action(() =>
|
||||
PostMessage("/room/shutdown/", new
|
||||
{
|
||||
state = "hasStarted",
|
||||
duration = EISC.UShortOutput[UshortJoin.ShutdownPromptDuration].UShortValue
|
||||
})));
|
||||
|
||||
// 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>
|
||||
/// Reads in config values when the Simpl program is ready
|
||||
/// </summary>
|
||||
void LoadConfigValues()
|
||||
{
|
||||
Debug.Console(1, this, "Loading configuration from DDVC01 EISC bridge");
|
||||
ConfigIsLoaded = false;
|
||||
|
||||
var co = ConfigReader.ConfigObject;
|
||||
|
||||
co.Info.RuntimeInfo.AppName = Assembly.GetExecutingAssembly().GetName().Name;
|
||||
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)
|
||||
// always start fresh in case simpl changed
|
||||
co.Rooms = new List<DeviceConfig>();
|
||||
var rm = new DeviceConfig();
|
||||
if (co.Rooms.Count == 0)
|
||||
{
|
||||
Debug.Console(0, this, "Adding room to config");
|
||||
co.Rooms.Add(rm);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Console(0, this, "Replacing Room[0] in config");
|
||||
co.Rooms[0] = rm;
|
||||
}
|
||||
rm.Name = EISC.StringOutput[StringJoin.ConfigRoomName].StringValue;
|
||||
rm.Key = "room1";
|
||||
rm.Type = "ddvc01";
|
||||
|
||||
DDVC01RoomPropertiesConfig rmProps;
|
||||
if (rm.Properties == null)
|
||||
rmProps = new DDVC01RoomPropertiesConfig();
|
||||
else
|
||||
rmProps = JsonConvert.DeserializeObject<DDVC01RoomPropertiesConfig>(rm.Properties.ToString());
|
||||
|
||||
rmProps.Help = new EssentialsHelpPropertiesConfig();
|
||||
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[StringJoin.ConfigRoomPhoneNumber].StringValue;
|
||||
rmProps.RoomURI = EISC.StringOutput[StringJoin.ConfigRoomURI].StringValue;
|
||||
rmProps.SpeedDials = new List<DDVC01SpeedDial>();
|
||||
|
||||
// This MAY need a check
|
||||
rmProps.AudioCodecKey = "audioCodec";
|
||||
rmProps.VideoCodecKey = "videoCodec";
|
||||
|
||||
// volume control names
|
||||
var volCount = EISC.UShortOutput[UshortJoin.VolumeSliderCount].UShortValue;
|
||||
|
||||
//// use Volumes object or?
|
||||
//rmProps.VolumeSliderNames = new List<string>();
|
||||
//for(uint i = 701; i <= 700 + volCount; i++)
|
||||
//{
|
||||
// rmProps.VolumeSliderNames.Add(EISC.StringInput[i].StringValue);
|
||||
//}
|
||||
|
||||
// There should be cotija devices in here, I think...
|
||||
if(co.Devices == null)
|
||||
co.Devices = new List<DeviceConfig>();
|
||||
|
||||
// clear out previous DDVC devices
|
||||
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);
|
||||
|
||||
// Source list! This might be brutal!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
var groupMap = GetSourceGroupDictionary();
|
||||
|
||||
co.SourceLists = new Dictionary<string,Dictionary<string,SourceListItem>>();
|
||||
var newSl = new Dictionary<string, SourceListItem>();
|
||||
// add "none" source if VTC present
|
||||
|
||||
if (!string.IsNullOrEmpty(rmProps.VideoCodecKey))
|
||||
{
|
||||
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[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 + 10,
|
||||
SourceKey = key,
|
||||
Type = eSourceListItemType.Route,
|
||||
DisableCodecSharing = disableShare,
|
||||
};
|
||||
newSl.Add(key, newSLI);
|
||||
|
||||
string group = "genericsource";
|
||||
if (groupMap.ContainsKey(type))
|
||||
{
|
||||
group = groupMap[type];
|
||||
}
|
||||
|
||||
// add dev to devices list
|
||||
var devConf = new DeviceConfig {
|
||||
Group = group,
|
||||
Key = key,
|
||||
Name = name,
|
||||
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;
|
||||
if (handler != null)
|
||||
{
|
||||
handler(this, new EventArgs());
|
||||
}
|
||||
|
||||
ConfigIsLoaded = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
void SendFullStatus()
|
||||
{
|
||||
if (ConfigIsLoaded)
|
||||
{
|
||||
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
|
||||
|
||||
// Create auxFaders
|
||||
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[1].StringValue,
|
||||
true,
|
||||
"something.png");
|
||||
volumes.Master.HasPrivacyMute = true;
|
||||
volumes.Master.PrivacyMuted = EISC.BooleanOutput[BoolJoin.PrivacyMute].BoolValue;
|
||||
|
||||
volumes.AuxFaders = auxFaderDict;
|
||||
|
||||
PostStatusMessage(new
|
||||
{
|
||||
activityMode = GetActivityMode(),
|
||||
isOn = EISC.BooleanOutput[BoolJoin.RoomIsOn].BoolValue,
|
||||
selectedSourceKey = EISC.StringOutput[StringJoin.SelectedSourceKey].StringValue,
|
||||
volumes = volumes
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
PostStatusMessage(new
|
||||
{
|
||||
error = "systemNotReady"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <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>
|
||||
/// <param name="contentObject">The contents of the content object</param>
|
||||
void PostStatusMessage(object contentObject)
|
||||
{
|
||||
Parent.SendMessageToServer(JObject.FromObject(new
|
||||
{
|
||||
type = "/room/status/",
|
||||
content = contentObject
|
||||
}));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="messageType"></param>
|
||||
/// <param name="contentObject"></param>
|
||||
void PostMessage(string messageType, object contentObject)
|
||||
{
|
||||
Parent.SendMessageToServer(JObject.FromObject(new
|
||||
{
|
||||
type = messageType,
|
||||
content = contentObject
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="currentDevice"></param>
|
||||
/// <param name="args"></param>
|
||||
void EISC_SigChange(object currentDevice, Crestron.SimplSharpPro.SigEventArgs args)
|
||||
{
|
||||
if (Debug.Level >= 1)
|
||||
Debug.Console(1, this, "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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the mapping of types to groups, for setting up devices.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Dictionary<string, string> GetSourceGroupDictionary()
|
||||
{
|
||||
//type, group
|
||||
var d = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
{ "laptop", "pc" },
|
||||
{ "wireless", "genericsource" },
|
||||
{ "iptv", "settopbox" }
|
||||
|
||||
};
|
||||
return d;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// updates the usercode from server
|
||||
/// </summary>
|
||||
protected override void UserCodeChange()
|
||||
{
|
||||
Debug.Console(1, this, "Server user code changed: {0}", UserCode);
|
||||
EISC.StringInput[StringJoin.UserCodeToSystem].StringValue = UserCode;
|
||||
EISC.StringInput[StringJoin.ServerUrl].StringValue = Parent.Config.ClientAppUrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,490 @@
|
||||
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.AppServer.Messengers;
|
||||
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
|
||||
{
|
||||
public class CotijaEssentialsHuddleSpaceRoomBridge : CotijaBridgeBase
|
||||
{
|
||||
|
||||
public EssentialsRoomBase Room { get; private set; }
|
||||
|
||||
public VideoCodecBaseMessenger VCMessenger { get; private set; }
|
||||
|
||||
public AudioCodecBaseMessenger ACMessenger { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public override string RoomName
|
||||
{
|
||||
get
|
||||
{
|
||||
return Room.Name;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="parent"></param>
|
||||
/// <param name="room"></param>
|
||||
public CotijaEssentialsHuddleSpaceRoomBridge(EssentialsRoomBase room):
|
||||
base("mobileControlBridge-essentialsHuddle", "Essentials Mobile Control Bridge-Huddle")
|
||||
{
|
||||
Room = room;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override of base: calls base to add parent and then registers actions and events.
|
||||
/// </summary>
|
||||
/// <param name="parent"></param>
|
||||
public override void AddParent(CotijaSystemController parent)
|
||||
{
|
||||
base.AddParent(parent);
|
||||
|
||||
// we add actions to the messaging system with a path, and a related action. Custom action
|
||||
// content objects can be handled in the controller's LineReceived method - and perhaps other
|
||||
// sub-controller parsing could be attached to these classes, so that the systemController
|
||||
// doesn't need to know about everything.
|
||||
|
||||
// Source Changes and room off
|
||||
Parent.AddAction(string.Format(@"/room/{0}/status", Room.Key), new Action(() => SendFullStatus(Room)));
|
||||
|
||||
var routeRoom = Room as IRunRouteAction;
|
||||
if(routeRoom != null)
|
||||
Parent.AddAction(string.Format(@"/room/{0}/source", Room.Key), new Action<SourceSelectMessageContent>(c =>
|
||||
routeRoom.RunRouteAction(c.SourceListItem)));
|
||||
|
||||
var defaultRoom = Room as IRunDefaultPresentRoute;
|
||||
if(defaultRoom != null)
|
||||
Parent.AddAction(string.Format(@"/room/{0}/defaultsource", Room.Key), new Action(() => defaultRoom.RunDefaultPresentRoute()));
|
||||
|
||||
var volumeRoom = Room as IHasCurrentVolumeControls;
|
||||
if (volumeRoom != null)
|
||||
{
|
||||
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/muteToggle", Room.Key), new Action(() =>
|
||||
volumeRoom.CurrentVolumeControls.MuteToggle()));
|
||||
volumeRoom.CurrentVolumeDeviceChange += new EventHandler<VolumeDeviceChangeEventArgs>(Room_CurrentVolumeDeviceChange);
|
||||
|
||||
// Registers for initial volume events, if possible
|
||||
var currentVolumeDevice = volumeRoom.CurrentVolumeControls as IBasicVolumeWithFeedback;
|
||||
if (currentVolumeDevice != null)
|
||||
{
|
||||
currentVolumeDevice.MuteFeedback.OutputChange += MuteFeedback_OutputChange;
|
||||
currentVolumeDevice.VolumeLevelFeedback.OutputChange += VolumeLevelFeedback_OutputChange;
|
||||
}
|
||||
}
|
||||
|
||||
var sscRoom = Room as IHasCurrentSourceInfoChange;
|
||||
if(sscRoom != null)
|
||||
sscRoom.CurrentSingleSourceChange += new SourceInfoChangeHandler(Room_CurrentSingleSourceChange);
|
||||
|
||||
var vcRoom = Room as IHasVideoCodec;
|
||||
if (vcRoom != null && vcRoom.VideoCodec != null)
|
||||
{
|
||||
var codec = vcRoom.VideoCodec;
|
||||
var key = vcRoom.VideoCodec.Key + "-" + parent.Key;
|
||||
VCMessenger = new VideoCodecBaseMessenger(key, vcRoom.VideoCodec, "/device/videoCodec");
|
||||
VCMessenger.RegisterWithAppServer(Parent);
|
||||
|
||||
vcRoom.IsSharingFeedback.OutputChange += new EventHandler<FeedbackEventArgs>(IsSharingFeedback_OutputChange);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
Parent.AddAction(string.Format(@"/room/{0}/activityVideo", Room.Key), new Action(()=>defCallRm.RunDefaultCallRoute()));
|
||||
}
|
||||
|
||||
Parent.AddAction(string.Format(@"/room/{0}/shutdownStart", Room.Key), new Action(() => Room.StartShutdown(eShutdownType.Manual)));
|
||||
Parent.AddAction(string.Format(@"/room/{0}/shutdownEnd", Room.Key), new Action(() => Room.ShutdownPromptTimer.Finish()));
|
||||
Parent.AddAction(string.Format(@"/room/{0}/shutdownCancel", Room.Key), new Action(() => Room.ShutdownPromptTimer.Cancel()));
|
||||
|
||||
Room.OnFeedback.OutputChange += OnFeedback_OutputChange;
|
||||
Room.IsCoolingDownFeedback.OutputChange += IsCoolingDownFeedback_OutputChange;
|
||||
Room.IsWarmingUpFeedback.OutputChange += IsWarmingUpFeedback_OutputChange;
|
||||
|
||||
Room.ShutdownPromptTimer.HasStarted += ShutdownPromptTimer_HasStarted;
|
||||
Room.ShutdownPromptTimer.HasFinished += ShutdownPromptTimer_HasFinished;
|
||||
Room.ShutdownPromptTimer.WasCancelled += ShutdownPromptTimer_WasCancelled;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void IsSharingFeedback_OutputChange(object sender, FeedbackEventArgs e)
|
||||
{
|
||||
// sharing source
|
||||
string shareText;
|
||||
bool isSharing;
|
||||
#warning This share update needs to happen on source change as well!
|
||||
var vcRoom = Room as IHasVideoCodec;
|
||||
var srcInfoRoom = Room as IHasCurrentSourceInfoChange;
|
||||
if (vcRoom.VideoCodec.SharingContentIsOnFeedback.BoolValue && srcInfoRoom.CurrentSourceInfo != null)
|
||||
{
|
||||
|
||||
shareText = srcInfoRoom.CurrentSourceInfo.PreferredName;
|
||||
isSharing = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
shareText = "None";
|
||||
isSharing = false;
|
||||
}
|
||||
|
||||
PostStatusMessage(new
|
||||
{
|
||||
share = new
|
||||
{
|
||||
currentShareText = shareText,
|
||||
isSharing = isSharing
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
///// <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
|
||||
/// </summary>
|
||||
/// <param name="contentObject">The contents of the content object</param>
|
||||
void PostStatusMessage(object contentObject)
|
||||
{
|
||||
Parent.SendMessageToServer(JObject.FromObject(new
|
||||
{
|
||||
type = "/room/status/",
|
||||
content = contentObject
|
||||
}));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handler for cancelled shutdown
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void ShutdownPromptTimer_WasCancelled(object sender, EventArgs e)
|
||||
{
|
||||
JObject roomStatus = new JObject();
|
||||
roomStatus.Add("state", "wasCancelled");
|
||||
JObject message = new JObject();
|
||||
message.Add("type", "/room/shutdown/");
|
||||
message.Add("content", roomStatus);
|
||||
Parent.SendMessageToServer(message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handler for when shutdown finishes
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void ShutdownPromptTimer_HasFinished(object sender, EventArgs e)
|
||||
{
|
||||
JObject roomStatus = new JObject();
|
||||
roomStatus.Add("state", "hasFinished");
|
||||
JObject message = new JObject();
|
||||
message.Add("type", "/room/shutdown/");
|
||||
message.Add("content", roomStatus);
|
||||
Parent.SendMessageToServer(message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handler for when shutdown starts
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void ShutdownPromptTimer_HasStarted(object sender, EventArgs e)
|
||||
{
|
||||
JObject roomStatus = new JObject();
|
||||
roomStatus.Add("state", "hasStarted");
|
||||
roomStatus.Add("duration", Room.ShutdownPromptTimer.SecondsToCount);
|
||||
JObject message = new JObject();
|
||||
message.Add("type", "/room/shutdown/");
|
||||
message.Add("content", roomStatus);
|
||||
Parent.SendMessageToServer(message);
|
||||
// equivalent JS message:
|
||||
// Post( { type: '/room/status/', content: { shutdown: 'hasStarted', duration: Room.ShutdownPromptTimer.SecondsToCount })
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void IsWarmingUpFeedback_OutputChange(object sender, FeedbackEventArgs e)
|
||||
{
|
||||
PostStatusMessage(new
|
||||
{
|
||||
isWarmingUp = e.BoolValue
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void IsCoolingDownFeedback_OutputChange(object sender, FeedbackEventArgs e)
|
||||
{
|
||||
PostStatusMessage(new
|
||||
{
|
||||
isCoolingDown = e.BoolValue
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void OnFeedback_OutputChange(object sender, FeedbackEventArgs e)
|
||||
{
|
||||
PostStatusMessage(new
|
||||
{
|
||||
isOn = e.BoolValue
|
||||
});
|
||||
}
|
||||
|
||||
void Room_CurrentVolumeDeviceChange(object sender, VolumeDeviceChangeEventArgs e)
|
||||
{
|
||||
if (e.OldDev is IBasicVolumeWithFeedback)
|
||||
{
|
||||
var oldDev = e.OldDev as IBasicVolumeWithFeedback;
|
||||
oldDev.MuteFeedback.OutputChange -= MuteFeedback_OutputChange;
|
||||
oldDev.VolumeLevelFeedback.OutputChange -= VolumeLevelFeedback_OutputChange;
|
||||
}
|
||||
|
||||
if (e.NewDev is IBasicVolumeWithFeedback)
|
||||
{
|
||||
var newDev = e.NewDev as IBasicVolumeWithFeedback;
|
||||
newDev.MuteFeedback.OutputChange += MuteFeedback_OutputChange;
|
||||
newDev.VolumeLevelFeedback.OutputChange += VolumeLevelFeedback_OutputChange;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event handler for mute changes
|
||||
/// </summary>
|
||||
void MuteFeedback_OutputChange(object sender, FeedbackEventArgs e)
|
||||
{
|
||||
PostStatusMessage(new
|
||||
{
|
||||
volumes = new
|
||||
{
|
||||
master = new
|
||||
{
|
||||
muted = e.BoolValue
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles Volume changes on room
|
||||
/// </summary>
|
||||
void VolumeLevelFeedback_OutputChange(object sender, FeedbackEventArgs e)
|
||||
{
|
||||
PostStatusMessage(new
|
||||
{
|
||||
volumes = new
|
||||
{
|
||||
master = new
|
||||
{
|
||||
level = e.IntValue
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void Room_CurrentSingleSourceChange(EssentialsRoomBase room, PepperDash.Essentials.Core.SourceListItem info, ChangeType type)
|
||||
{
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
else // did change
|
||||
{
|
||||
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);
|
||||
|
||||
var srcRm = room as IHasCurrentSourceInfoChange;
|
||||
PostStatusMessage(new
|
||||
{
|
||||
selectedSourceKey = srcRm.CurrentSourceInfoKey
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Posts the full status of the room to the server
|
||||
/// </summary>
|
||||
/// <param name="room"></param>
|
||||
void SendFullStatus(EssentialsRoomBase room)
|
||||
{
|
||||
var sourceKey = room is IHasCurrentSourceInfoChange ? (room as IHasCurrentSourceInfoChange).CurrentSourceInfoKey : null;
|
||||
|
||||
var rmVc = room as IHasCurrentVolumeControls;
|
||||
var volumes = new Volumes();
|
||||
if (rmVc != null)
|
||||
{
|
||||
var vc = rmVc.CurrentVolumeControls as IBasicVolumeWithFeedback;
|
||||
if (vc != null)
|
||||
{
|
||||
volumes.Master = new Volume("master", vc.VolumeLevelFeedback.UShortValue, vc.MuteFeedback.BoolValue, "Volume", true, "");
|
||||
}
|
||||
}
|
||||
|
||||
PostStatusMessage(new
|
||||
{
|
||||
//calls = GetCallsMessageObject(),
|
||||
isOn = room.OnFeedback.BoolValue,
|
||||
selectedSourceKey = sourceKey,
|
||||
//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 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>
|
||||
///
|
||||
/// </summary>
|
||||
public class SourceSelectMessageContent
|
||||
{
|
||||
public string SourceListItem { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="b"></param>
|
||||
public delegate void PressAndHoldAction(bool b);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
namespace PepperDash.Essentials.Room.Cotija
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Contains all of the default joins that map to API funtions
|
||||
/// </summary>
|
||||
public class SourceDeviceMapDictionary : Dictionary<string, uint>
|
||||
{
|
||||
|
||||
public SourceDeviceMapDictionary(): base()
|
||||
{
|
||||
var dictionary = new Dictionary<string, uint>
|
||||
{
|
||||
{"preset01", 101},
|
||||
{"preset02", 102},
|
||||
{"preset03", 103},
|
||||
{"preset04", 104},
|
||||
{"preset05", 105},
|
||||
{"preset06", 106},
|
||||
{"preset07", 107},
|
||||
{"preset08", 108},
|
||||
{"preset09", 109},
|
||||
{"preset10", 110},
|
||||
{"preset11", 111},
|
||||
{"preset12", 112},
|
||||
{"preset13", 113},
|
||||
{"preset14", 114},
|
||||
{"preset15", 115},
|
||||
{"preset16", 116},
|
||||
{"preset17", 117},
|
||||
{"preset18", 118},
|
||||
{"preset19", 119},
|
||||
{"preset20", 120},
|
||||
{"preset21", 121},
|
||||
{"preset22", 122},
|
||||
{"preset23", 123},
|
||||
{"preset24", 124},
|
||||
|
||||
{"num0", 130},
|
||||
{"num1", 131},
|
||||
{"num2", 132},
|
||||
{"num3", 133},
|
||||
{"num4", 134},
|
||||
{"num5", 135},
|
||||
{"num6", 136},
|
||||
{"num7", 137},
|
||||
{"num8", 138},
|
||||
{"num9", 139},
|
||||
{"numDash", 140},
|
||||
{"numEnter", 141},
|
||||
{"chanUp", 142},
|
||||
{"chanDown", 143},
|
||||
{"lastChan", 144},
|
||||
{"exit", 145},
|
||||
{"powerToggle", 146},
|
||||
{"red", 147},
|
||||
{"green", 148},
|
||||
{"yellow", 149},
|
||||
{"blue", 150},
|
||||
{"video", 151},
|
||||
{"previous", 152},
|
||||
{"next", 153},
|
||||
{"rewind", 154},
|
||||
{"ffwd", 155},
|
||||
{"closedCaption", 156},
|
||||
{"stop", 157},
|
||||
{"pause", 158},
|
||||
{"up", 159},
|
||||
{"down", 160},
|
||||
{"left", 161},
|
||||
{"right", 162},
|
||||
{"settings", 163},
|
||||
{"info", 164},
|
||||
{"return", 165},
|
||||
{"guide", 166},
|
||||
{"reboot", 167},
|
||||
{"dvrList", 168},
|
||||
{"replay", 169},
|
||||
{"play", 170},
|
||||
{"select", 171},
|
||||
{"record", 172},
|
||||
{"menu", 173},
|
||||
{"topMenu", 174},
|
||||
{"prevTrack", 175},
|
||||
{"nextTrack", 176},
|
||||
{"powerOn", 177},
|
||||
{"powerOff", 178},
|
||||
{"dot", 179}
|
||||
|
||||
};
|
||||
|
||||
foreach (var item in dictionary)
|
||||
{
|
||||
this.Add(item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
62
PepperDashEssentials/AppServer/Volumes.cs
Normal file
62
PepperDashEssentials/AppServer/Volumes.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace PepperDash.Essentials.Room.Cotija
|
||||
{
|
||||
public class Volumes
|
||||
{
|
||||
[JsonProperty("master")]
|
||||
public Volume Master { get; set; }
|
||||
|
||||
[JsonProperty("auxFaders")]
|
||||
public Dictionary<string, Volume> AuxFaders { get; set; }
|
||||
|
||||
public Volumes()
|
||||
{
|
||||
AuxFaders = new Dictionary<string, Volume>();
|
||||
}
|
||||
}
|
||||
|
||||
public class Volume
|
||||
{
|
||||
[JsonProperty("key")]
|
||||
public string Key { get; set; }
|
||||
|
||||
[JsonProperty("level")]
|
||||
public ushort Level { get; set; }
|
||||
|
||||
[JsonProperty("muted")]
|
||||
public bool Muted { get; set; }
|
||||
|
||||
[JsonProperty("label")]
|
||||
public string Label { get; set; }
|
||||
|
||||
[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; }
|
||||
|
||||
public Volume(string key, ushort level, bool muted, string label, bool hasMute, string muteIcon)
|
||||
{
|
||||
Key = key;
|
||||
Level = level;
|
||||
Muted = muted;
|
||||
Label = label;
|
||||
HasMute = hasMute;
|
||||
MuteIcon = muteIcon;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ namespace PepperDash.Essentials
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class EssentialsPresentationVolumesConfig
|
||||
public class EssentialsRoomVolumesConfig
|
||||
{
|
||||
public EssentialsVolumeLevelConfig Master { get; set; }
|
||||
public EssentialsVolumeLevelConfig Program { get; set; }
|
||||
@@ -25,7 +25,6 @@ namespace PepperDash.Essentials
|
||||
public EssentialsVolumeLevelConfig AudioCallTx { get; set; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
271
PepperDashEssentials/Bridges/BridgeBase.cs
Normal file
271
PepperDashEssentials/Bridges/BridgeBase.cs
Normal file
@@ -0,0 +1,271 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for all bridge class variants
|
||||
/// </summary>
|
||||
public class BridgeBase : Device
|
||||
{
|
||||
public BridgeApi Api { get; private set; }
|
||||
|
||||
public BridgeBase(string key) :
|
||||
base(key)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Base class for bridge API variants
|
||||
/// </summary>
|
||||
public abstract class BridgeApi : Device
|
||||
{
|
||||
public BridgeApi(string key) :
|
||||
base(key)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bridge API using EISC
|
||||
/// </summary>
|
||||
public class EiscApi : BridgeApi
|
||||
{
|
||||
public EiscApiPropertiesConfig PropertiesConfig { get; private set; }
|
||||
|
||||
public ThreeSeriesTcpIpEthernetIntersystemCommunications Eisc { get; private set; }
|
||||
|
||||
public EiscApi(DeviceConfig dc) :
|
||||
base(dc.Key)
|
||||
{
|
||||
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 DmpsRoutingController)
|
||||
{
|
||||
(device as DmpsRoutingController).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>
|
||||
/// Handles incoming sig changes
|
||||
/// </summary>
|
||||
/// <param name="currentDevice"></param>
|
||||
/// <param name="args"></param>
|
||||
void Eisc_SigChange(object currentDevice, Crestron.SimplSharpPro.SigEventArgs args)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Debug.Level >= 1)
|
||||
Debug.Console(1, this, "EiscApi change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue);
|
||||
var uo = args.Sig.UserObject;
|
||||
if (uo != null)
|
||||
{
|
||||
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>)
|
||||
(uo as Action<ushort>)(args.Sig.UShortValue);
|
||||
else if (uo is Action<string>)
|
||||
(uo as Action<string>)(args.Sig.StringValue);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(2, this, "Error in Eisc_SigChange handler: {0}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class EiscApiPropertiesConfig
|
||||
{
|
||||
[JsonProperty("control")]
|
||||
public EssentialsControlPropertiesConfig Control { get; set; }
|
||||
|
||||
[JsonProperty("devices")]
|
||||
public List<ApiDevice> Devices { get; set; }
|
||||
|
||||
|
||||
public class ApiDevice
|
||||
{
|
||||
[JsonProperty("deviceKey")]
|
||||
public string DeviceKey { get; set; }
|
||||
|
||||
[JsonProperty("joinStart")]
|
||||
public uint JoinStart { get; set; }
|
||||
|
||||
[JsonProperty("joinMapKey")]
|
||||
public string JoinMapKey { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
139
PepperDashEssentials/Bridges/BridgeFactory.cs
Normal file
139
PepperDashEssentials/Bridges/BridgeFactory.cs
Normal file
@@ -0,0 +1,139 @@
|
||||
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 PepperDash.Essentials.Bridges;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.EthernetCommunication;
|
||||
|
||||
namespace PepperDash.Essentials
|
||||
{
|
||||
public class BridgeFactory
|
||||
{
|
||||
public static IKeyed GetDevice(DeviceConfig dc)
|
||||
{
|
||||
// ? why is this static JTA 2018-06-13?
|
||||
|
||||
var key = dc.Key;
|
||||
var name = dc.Name;
|
||||
var type = dc.Type;
|
||||
var properties = dc.Properties;
|
||||
var propAnon = new { };
|
||||
|
||||
var typeName = dc.Type.ToLower();
|
||||
var groupName = dc.Group.ToLower();
|
||||
|
||||
//Debug.Console(2, "Name {0}, Key {1}, Type {2}, Properties {3}", name, key, type, properties.ToString());
|
||||
|
||||
if (typeName == "eiscapi")
|
||||
{
|
||||
return new EiscApi(dc);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class CommBridge : Device
|
||||
{
|
||||
public CommBridgeProperties Properties { get; private set; }
|
||||
|
||||
public List<IBasicCommunication> CommDevices { get; private set; }
|
||||
|
||||
public CommBridge(string key, string name, JToken properties)
|
||||
: base(key, name)
|
||||
{
|
||||
Properties = JsonConvert.DeserializeObject<CommBridgeProperties>(properties.ToString());
|
||||
}
|
||||
|
||||
public override bool CustomActivate()
|
||||
{
|
||||
// Create EiscApis
|
||||
if (Properties.Eiscs != null)
|
||||
{
|
||||
foreach (var eisc in Properties.Eiscs)
|
||||
{
|
||||
var ApiEisc = new BridgeApiEisc(eisc.IpId, eisc.Hostname);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var deviceKey in Properties.CommDevices)
|
||||
{
|
||||
var device = DeviceManager.GetDeviceForKey(deviceKey);
|
||||
|
||||
if (device != null)
|
||||
{
|
||||
Debug.Console(0, "deviceKey {0} Found in Device Manager", device.Key);
|
||||
CommDevices.Add(device as IBasicCommunication);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Console(0, "deviceKey {0} Not Found in Device Manager", deviceKey);
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate through all the CommDevices and link up their Actions and Feedbacks
|
||||
|
||||
Debug.Console(0, "Bridge {0} Activated", this.Name);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class EiscBridgeProperties
|
||||
{
|
||||
public string ParentDeviceKey { get; set; }
|
||||
public eApiType ApiType { get; set; }
|
||||
public List<EiscProperties> Eiscs { get; set; }
|
||||
public string ApiOverrideFilePath { get; set; }
|
||||
|
||||
public class EiscProperties
|
||||
{
|
||||
public string IpId { get; set; }
|
||||
public string Hostname { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
public class CommBridgeProperties : EiscBridgeProperties
|
||||
{
|
||||
public List<string> CommDevices { get; set; }
|
||||
}
|
||||
|
||||
public enum eApiType { Eisc = 0 }
|
||||
|
||||
public class BridgeApiEisc
|
||||
{
|
||||
public uint Ipid { get; private set; }
|
||||
public ThreeSeriesTcpIpEthernetIntersystemCommunications Eisc { get; private set; }
|
||||
|
||||
public BridgeApiEisc(string ipid, string hostname)
|
||||
{
|
||||
Ipid = (UInt32)int.Parse(ipid, System.Globalization.NumberStyles.HexNumber);
|
||||
Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(Ipid, hostname, Global.ControlSystem);
|
||||
Eisc.Register();
|
||||
Eisc.SigChange += Eisc_SigChange;
|
||||
Debug.Console(0, "BridgeApiEisc Created at Ipid {0}", ipid);
|
||||
}
|
||||
void Eisc_SigChange(object currentDevice, Crestron.SimplSharpPro.SigEventArgs args)
|
||||
{
|
||||
if (Debug.Level >= 1)
|
||||
Debug.Console(1, "BridgeApiEisc change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue);
|
||||
var uo = args.Sig.UserObject;
|
||||
if (uo is Action<bool>)
|
||||
(uo as Action<bool>)(args.Sig.BoolValue);
|
||||
else if (uo is Action<ushort>)
|
||||
(uo as Action<ushort>)(args.Sig.UShortValue);
|
||||
else if (uo is Action<string>)
|
||||
(uo as Action<string>)(args.Sig.StringValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
285
PepperDashEssentials/Bridges/DmChassisControllerBridge.cs
Normal file
285
PepperDashEssentials/Bridges/DmChassisControllerBridge.cs
Normal file
@@ -0,0 +1,285 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
using Crestron.SimplSharpPro.DM;
|
||||
using Crestron.SimplSharpPro.DM.Endpoints;
|
||||
using Crestron.SimplSharpPro.DM.Endpoints.Transmitters;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
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]);
|
||||
|
||||
trilist.SetUShortSigAction(joinMap.SystemId, new Action<ushort>(o => dmChassis.Chassis.SystemId.UShortValue = o));
|
||||
trilist.SetSigTrueAction(joinMap.SystemId, new Action(() => dmChassis.Chassis.ApplySystemId()));
|
||||
|
||||
dmChassis.SystemIdFeebdack.LinkInputSig(trilist.UShortInput[joinMap.SystemId]);
|
||||
dmChassis.SystemIdBusyFeedback.LinkInputSig(trilist.BooleanInput[joinMap.SystemId]);
|
||||
|
||||
// Link up outputs
|
||||
for (uint i = 1; i <= dmChassis.Chassis.NumberOfOutputs; 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)));
|
||||
trilist.SetUShortSigAction(joinMap.OutputUsb + ioSlot, new Action<ushort>(o => dmChassis.ExecuteSwitch(o, ioSlot, eRoutingSignalType.UsbOutput)));
|
||||
trilist.SetUShortSigAction(joinMap.InputUsb + ioSlot, new Action<ushort>(o => dmChassis.ExecuteSwitch(o, ioSlot, eRoutingSignalType.UsbInput)));
|
||||
|
||||
if (dmChassis.TxDictionary.ContainsKey(ioSlot))
|
||||
{
|
||||
Debug.Console(2, "Creating Tx Feedbacks {0}", ioSlot);
|
||||
var txKey = dmChassis.TxDictionary[ioSlot];
|
||||
var basicTxDevice = DeviceManager.GetDeviceForKey(txKey) as BasicDmTxControllerBase;
|
||||
|
||||
var txDevice = basicTxDevice as DmTxControllerBase;
|
||||
|
||||
if (dmChassis.Chassis is DmMd8x8Cpu3 || dmChassis.Chassis is DmMd8x8Cpu3rps
|
||||
|| dmChassis.Chassis is DmMd16x16Cpu3 || dmChassis.Chassis is DmMd16x16Cpu3rps
|
||||
|| dmChassis.Chassis is DmMd32x32Cpu3 || dmChassis.Chassis is DmMd32x32Cpu3rps)
|
||||
{
|
||||
dmChassis.InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (txDevice != null)
|
||||
{
|
||||
txDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]);
|
||||
}
|
||||
}
|
||||
|
||||
if(basicTxDevice != null && txDevice == null)
|
||||
trilist.BooleanInput[joinMap.TxAdvancedIsPresent + ioSlot].BoolValue = true;
|
||||
|
||||
|
||||
if (txDevice != null)
|
||||
{
|
||||
txDevice.AnyVideoInput.VideoStatus.VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]);
|
||||
}
|
||||
else
|
||||
{
|
||||
var inputPort = dmChassis.InputPorts[string.Format("inputCard{0}--hdmiIn", ioSlot)];
|
||||
if(inputPort != null)
|
||||
{
|
||||
var hdmiInPort = inputPort.Port;
|
||||
|
||||
if (hdmiInPort != null)
|
||||
{
|
||||
if (hdmiInPort is HdmiInputWithCEC)
|
||||
{
|
||||
var hdmiInPortWCec = hdmiInPort as HdmiInputWithCEC;
|
||||
|
||||
if (hdmiInPortWCec.HdcpSupportedLevel != eHdcpSupportedLevel.Unknown)
|
||||
{
|
||||
SetHdcpCapabilityAction(true, hdmiInPortWCec, joinMap.HdcpSupportState + ioSlot, trilist);
|
||||
}
|
||||
|
||||
dmChassis.InputCardHdcpCapabilityFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.HdcpSupportState + ioSlot]);
|
||||
|
||||
trilist.UShortInput[joinMap.HdcpSupportCapability + ioSlot].UShortValue = (ushort)dmChassis.InputCardHdcpCapabilityTypes[ioSlot];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dmChassis.VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus + ioSlot]);
|
||||
|
||||
var inputPort = dmChassis.InputPorts[string.Format("inputCard{0}-hdmiIn", ioSlot)].Port as EndpointHdmiInput;
|
||||
|
||||
if (inputPort != null)
|
||||
{
|
||||
//trilist.SetUShortSigAction((joinMap.HdcpSupport + ioSlot), u =>
|
||||
}
|
||||
}
|
||||
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;
|
||||
if (dmChassis.Chassis is DmMd8x8Cpu3 || dmChassis.Chassis is DmMd8x8Cpu3rps
|
||||
|| dmChassis.Chassis is DmMd16x16Cpu3 || dmChassis.Chassis is DmMd16x16Cpu3rps
|
||||
|| dmChassis.Chassis is DmMd32x32Cpu3 || dmChassis.Chassis is DmMd32x32Cpu3rps)
|
||||
{
|
||||
dmChassis.OutputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]);
|
||||
}
|
||||
else if (RxDevice != null)
|
||||
{
|
||||
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.UsbOutputRoutedToFeebacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputUsb + ioSlot]);
|
||||
dmChassis.UsbInputRoutedToFeebacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.InputUsb + 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]);
|
||||
}
|
||||
}
|
||||
|
||||
static void SetHdcpCapabilityAction(bool hdcpTypeSimple, HdmiInputWithCEC 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.HdcpReceiveCapability = (eHdcpCapabilityType)s;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
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 DmChassisControllerJoinMap : JoinMapBase
|
||||
{
|
||||
//Digital
|
||||
public uint SystemId { get; set; }
|
||||
public uint IsOnline { get; set; }
|
||||
public uint OutputUsb { get; set; }
|
||||
public uint InputUsb { get; set; }
|
||||
public uint VideoSyncStatus { get; set; }
|
||||
public uint InputEndpointOnline { get; set; }
|
||||
public uint OutputEndpointOnline { get; set; }
|
||||
public uint TxAdvancedIsPresent { get; set; } // indicates that there is an attached transmitter that should be bridged to be interacted with
|
||||
|
||||
//Analog
|
||||
public uint OutputVideo { get; set; }
|
||||
public uint OutputAudio { get; set; }
|
||||
public uint HdcpSupportState { get; set; }
|
||||
public uint HdcpSupportCapability { get; set; }
|
||||
|
||||
//SErial
|
||||
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 DmChassisControllerJoinMap()
|
||||
{
|
||||
SystemId = 10;
|
||||
//Digital
|
||||
IsOnline = 11;
|
||||
VideoSyncStatus = 100; //101-299
|
||||
InputEndpointOnline = 500; //501-699
|
||||
OutputEndpointOnline = 700; //701-899
|
||||
TxAdvancedIsPresent = 1000; //1001-1199
|
||||
|
||||
//Analog
|
||||
OutputVideo = 100; //101-299
|
||||
OutputAudio = 300; //301-499
|
||||
OutputUsb = 500; //501-699
|
||||
InputUsb = 700; //701-899
|
||||
VideoSyncStatus = 100; //101-299
|
||||
HdcpSupportState = 1000; //1001-1199
|
||||
HdcpSupportCapability = 1200; //1201-1399
|
||||
|
||||
|
||||
//Serial
|
||||
InputNames = 100; //101-299
|
||||
OutputNames = 300; //301-499
|
||||
OutputCurrentVideoInputNames = 2000; //2001-2199
|
||||
OutputCurrentAudioInputNames = 2200; //2201-2399
|
||||
InputCurrentResolution = 2400; // 2401-2599
|
||||
InputEndpointOnline = 500; //501-699
|
||||
OutputEndpointOnline = 700; //701-899
|
||||
HdcpSupportState = 1000; //1001-1199
|
||||
HdcpSupportCapability = 1200; //1201-1399
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void OffsetJoinNumbers(uint joinStart)
|
||||
{
|
||||
var joinOffset = joinStart - 1;
|
||||
|
||||
SystemId = SystemId + joinOffset;
|
||||
IsOnline = IsOnline + joinOffset;
|
||||
OutputVideo = OutputVideo + joinOffset;
|
||||
OutputAudio = OutputAudio + joinOffset;
|
||||
OutputUsb = OutputUsb + joinOffset;
|
||||
InputUsb = InputUsb + 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;
|
||||
HdcpSupportState = HdcpSupportState + 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]);
|
||||
trilist.UShortInput[joinMap.HdcpSupportCapability].UShortValue = (ushort)tx.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
177
PepperDashEssentials/Bridges/DmpsRoutingControllerBridge.cs
Normal file
177
PepperDashEssentials/Bridges/DmpsRoutingControllerBridge.cs
Normal file
@@ -0,0 +1,177 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro.DeviceSupport;
|
||||
using Crestron.SimplSharpPro.DM;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.DM;
|
||||
|
||||
namespace PepperDash.Essentials.Bridges
|
||||
{
|
||||
public static class DmpsRoutingControllerApiExtentions
|
||||
{
|
||||
public static void LinkToApi(this DmpsRoutingController dmpsRouter, BasicTriList trilist, uint joinStart, string joinMapKey)
|
||||
{
|
||||
var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as DmpsRoutingControllerJoinMap;
|
||||
|
||||
if (joinMap == null)
|
||||
joinMap = new DmpsRoutingControllerJoinMap();
|
||||
|
||||
joinMap.OffsetJoinNumbers(joinStart);
|
||||
|
||||
Debug.Console(1, dmpsRouter, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
||||
|
||||
// Link up outputs
|
||||
for (uint i = 1; i <= dmpsRouter.Dmps.NumberOfSwitcherInputs; i++)
|
||||
{
|
||||
Debug.Console(2, dmpsRouter, "Linking Input Card {0}", i);
|
||||
|
||||
var ioSlot = i;
|
||||
|
||||
//if (dmpsRouter.TxDictionary.ContainsKey(ioSlot))
|
||||
//{
|
||||
// Debug.Console(2, "Creating Tx Feedbacks {0}", ioSlot);
|
||||
// var TxKey = dmpsRouter.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(dmpsRouter.VideoInputSyncFeedbacks[ioSlot] != null)
|
||||
dmpsRouter.VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus + ioSlot]);
|
||||
|
||||
if (dmpsRouter.InputNameFeedbacks[ioSlot] != null)
|
||||
dmpsRouter.InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputNames + ioSlot]);
|
||||
|
||||
trilist.SetStringSigAction(joinMap.InputNames + ioSlot, new Action<string>(s =>
|
||||
{
|
||||
var inputCard = dmpsRouter.Dmps.SwitcherInputs[ioSlot] as DMInput;
|
||||
|
||||
if (inputCard != null)
|
||||
{
|
||||
if (inputCard.NameFeedback != null && !string.IsNullOrEmpty(inputCard.NameFeedback.StringValue) && inputCard.NameFeedback.StringValue != s)
|
||||
if(inputCard.Name != null)
|
||||
inputCard.Name.StringValue = s;
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
if(dmpsRouter.InputEndpointOnlineFeedbacks[ioSlot] != null)
|
||||
dmpsRouter.InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]);
|
||||
}
|
||||
|
||||
for (uint i = 1; i <= dmpsRouter.Dmps.NumberOfSwitcherOutputs; i++)
|
||||
{
|
||||
Debug.Console(2, dmpsRouter, "Linking Output Card {0}", i);
|
||||
|
||||
var ioSlot = i;
|
||||
// Control
|
||||
trilist.SetUShortSigAction(joinMap.OutputVideo + ioSlot, new Action<ushort>(o => dmpsRouter.ExecuteSwitch(o, ioSlot, eRoutingSignalType.Video)));
|
||||
trilist.SetUShortSigAction(joinMap.OutputAudio + ioSlot, new Action<ushort>(o => dmpsRouter.ExecuteSwitch(o, ioSlot, eRoutingSignalType.Audio)));
|
||||
|
||||
trilist.SetStringSigAction(joinMap.OutputNames + ioSlot, new Action<string>(s =>
|
||||
{
|
||||
var outputCard = dmpsRouter.Dmps.SwitcherOutputs[ioSlot] as DMOutput;
|
||||
|
||||
//Debug.Console(2, dmpsRouter, "Output Name String Sig Action for Output Card {0}", ioSlot);
|
||||
|
||||
if (outputCard != null)
|
||||
{
|
||||
//Debug.Console(2, dmpsRouter, "Card Type: {0}", outputCard.CardInputOutputType);
|
||||
|
||||
if (!(outputCard is Crestron.SimplSharpPro.DM.Cards.Card.Dmps3CodecOutput) && outputCard.NameFeedback != null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(outputCard.NameFeedback.StringValue))
|
||||
{
|
||||
//Debug.Console(2, dmpsRouter, "NameFeedabck: {0}", outputCard.NameFeedback.StringValue);
|
||||
|
||||
if (outputCard.NameFeedback.StringValue != s && outputCard.Name != null)
|
||||
{
|
||||
outputCard.Name.StringValue = s;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
// Feedback
|
||||
if(dmpsRouter.VideoOutputFeedbacks[ioSlot] != null)
|
||||
dmpsRouter.VideoOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputVideo + ioSlot]);
|
||||
if (dmpsRouter.AudioOutputFeedbacks[ioSlot] != null)
|
||||
dmpsRouter.AudioOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputAudio + ioSlot]);
|
||||
if (dmpsRouter.OutputNameFeedbacks[ioSlot] != null)
|
||||
dmpsRouter.OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputNames + ioSlot]);
|
||||
if (dmpsRouter.OutputVideoRouteNameFeedbacks[ioSlot] != null)
|
||||
dmpsRouter.OutputVideoRouteNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentVideoInputNames + ioSlot]);
|
||||
if (dmpsRouter.OutputAudioRouteNameFeedbacks[ioSlot] != null)
|
||||
dmpsRouter.OutputAudioRouteNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentAudioInputNames + ioSlot]);
|
||||
if (dmpsRouter.OutputEndpointOnlineFeedbacks[ioSlot] != null)
|
||||
dmpsRouter.OutputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class DmpsRoutingControllerJoinMap : JoinMapBase
|
||||
{
|
||||
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 DmpsRoutingControllerJoinMap()
|
||||
{;
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user