Compare commits
450 Commits
Author | SHA1 | Date |
---|---|---|
|
e6ef1ff395 | |
|
8e9a57bcd3 | |
|
4dc988c5bb | |
|
bc081cfe63 | |
|
6c8d2d712d | |
|
b4a974a33e | |
|
b21b899303 | |
|
5597aea828 | |
|
5d31bf0020 | |
|
91ad944c46 | |
|
cb63194fc6 | |
|
7f8a9d4289 | |
|
8e8fac92d1 | |
|
7e24c70454 | |
|
a9f20ebf36 | |
|
4b8c8ee842 | |
|
5bad15a79a | |
|
9b7d1a3e5c | |
|
5f7fa6287f | |
|
2af8b4b209 | |
|
66096fa2ea | |
|
18875a01c6 | |
|
7d2c2b9d09 | |
|
67a290a02a | |
|
63f4278b2b | |
|
6778f871db | |
|
edc72a5486 | |
|
2779258111 | |
|
da735779b4 | |
|
b7e2e912f4 | |
|
d34172d8e9 | |
|
f30ce78f9d | |
|
ed767aedb5 | |
|
ab35895cb3 | |
|
1e2b65644d | |
|
3f58bbc617 | |
|
c1da7b53a2 | |
|
4181c22995 | |
|
d31ac53bd1 | |
|
9b954852aa | |
|
3758916fb5 | |
|
25c1395655 | |
|
440edd7b18 | |
|
a2f045841f | |
|
c890107e1e | |
|
a5df1650b9 | |
|
173ce499bc | |
|
33412b0588 | |
|
3c5e31a961 | |
|
39676f9a06 | |
|
0f893d94c4 | |
|
b08f5094d5 | |
|
70e046eeb7 | |
|
58d0742187 | |
|
f84e8b741a | |
|
fcf24b5539 | |
|
128a4d2ded | |
|
b14d24e650 | |
|
7995665c6b | |
|
a22906d3c2 | |
|
042533dc85 | |
|
5fbefeecbf | |
|
a9772ff081 | |
|
cdf983c7c6 | |
|
03f886580f | |
|
a06e2869b9 | |
|
6bafb263de | |
|
493ff5fbf6 | |
|
c29e0880ac | |
|
986c7a915b | |
|
68b1b8b819 | |
|
382ba56fa7 | |
|
24d6685047 | |
|
565d2ecceb | |
|
c4456e458f | |
|
f707dedc91 | |
|
702fc4680d | |
|
99b63150ac | |
|
6e7c226c57 | |
|
c8e5f7b742 | |
|
0cf147d185 | |
|
cf1514f53e | |
|
af3843a8ef | |
|
91ce2dd450 | |
|
71c9efae42 | |
|
08ce0d792b | |
|
754ef17b74 | |
|
5d4fec8c81 | |
|
1e0338a77f | |
|
e6b9628746 | |
|
6f68081dc5 | |
|
66b18dd351 | |
|
b5f5b6461a | |
|
6dd29d9596 | |
|
29ba125534 | |
|
144af1414c | |
|
06906eca42 | |
|
0d47748d6a | |
|
b1c8192625 | |
|
d2c7781d79 | |
|
37d4f50ef4 | |
|
082ac85c5c | |
|
cfca56ba48 | |
|
c7cb4ddbc5 | |
|
7f98d6028b | |
|
401822a7bb | |
|
173ba06590 | |
|
2677118bad | |
|
8e90456d87 | |
|
0b880a5e79 | |
|
082dbc0826 | |
|
5eccbbf6df | |
|
513deb7a0a | |
|
2b24dc647c | |
|
f8e5968f30 | |
|
18b8c84fff | |
|
1d6ccb7838 | |
|
a7a63a3be7 | |
|
153ef9eceb | |
|
eec7765e73 | |
|
03f2b55762 | |
|
6714374639 | |
|
b6b1f5d5ba | |
|
d7a10f9737 | |
|
d778adc7d0 | |
|
dcbb57f732 | |
|
24452794a9 | |
|
24fe1e8773 | |
|
b30c637c10 | |
|
f16795b11c | |
|
141d27599f | |
|
86c88c4ac2 | |
|
fbab0c043a | |
|
1a01a4f05e | |
|
b0305ae6da | |
|
dd4834de04 | |
|
2d90c127a3 | |
|
51d440fccc | |
|
2e3ed56bb3 | |
|
4be57f3128 | |
|
de6f0d0495 | |
|
98e1e73163 | |
|
1ae524ff31 | |
|
010927c5ca | |
|
3346bf01af | |
|
788cac7d50 | |
|
4c0fa2ba41 | |
|
83209f466f | |
|
10c452c1b3 | |
|
a8a33a823a | |
|
e7e7f86ab3 | |
|
386285d48c | |
|
c4119ab7cc | |
|
176643f148 | |
|
8b235bb6b0 | |
|
8a170f65ca | |
|
2f56dd4b8a | |
|
699c2dbec8 | |
|
dac720863d | |
|
3b03eb70fb | |
|
a173cf0d7c | |
|
55b39e7db3 | |
|
505a2a71e7 | |
|
fb51716e3a | |
|
bdd74fa90a | |
|
8631250b9e | |
|
c9f35ffe90 | |
|
18d6e2c7cd | |
|
f47ea2d382 | |
|
0cc167b3a6 | |
|
5133295f38 | |
|
621948fbac | |
|
4539c6d897 | |
|
a7db072dc6 | |
|
58ce079330 | |
|
dd03583a27 | |
|
3feaea74bf | |
|
1d6cbe5c53 | |
|
318f931dbf | |
|
5400518ea6 | |
|
f73a1e3931 | |
|
60d7ab4b5e | |
|
95cde2907a | |
|
35b67f1815 | |
|
f958789b20 | |
|
4beef04a3f | |
|
6d379d284b | |
|
2c21110b97 | |
|
777db577d7 | |
|
bf320216cf | |
|
b48c498574 | |
|
0b71da8e7b | |
|
c0d6cbccec | |
|
95ede98623 | |
|
3881dd4891 | |
|
71e4bea384 | |
|
83aa3099c4 | |
|
672db32917 | |
|
80a9c23f4d | |
|
49ad3c28a8 | |
|
a29c85628c | |
|
3ec93ab3b1 | |
|
10c29d3af1 | |
|
41840b90c8 | |
|
c89e865d3d | |
|
c6ec54bd06 | |
|
af3b1b8cbb | |
|
86273a9f09 | |
|
ba0241a811 | |
|
1bd73876b4 | |
|
cc806cbe52 | |
|
8f7a40075a | |
|
64faaa9427 | |
|
d44c67ce80 | |
|
144b408092 | |
|
d2390dca30 | |
|
503a8ec92f | |
|
ca22a3ba4b | |
|
ef54e61494 | |
|
b1745c786b | |
|
83efbc18c7 | |
|
f47396e48c | |
|
03c27a9226 | |
|
08655898d4 | |
|
5d347d23e4 | |
|
a25d93ec55 | |
|
bbf0cbd1c6 | |
|
4aceeac1c2 | |
|
1f5bb85304 | |
|
087fd3f763 | |
|
daece3b45a | |
|
9705505285 | |
|
9016062f70 | |
|
a6de66eb66 | |
|
6ada6b08ed | |
|
710e178ba2 | |
|
9e7990851e | |
|
ae34558f18 | |
|
c1a51f1ce8 | |
|
13702a3d5b | |
|
6b66cfe03f | |
|
cbc876c57c | |
|
7813a8c904 | |
|
5f941e91b5 | |
|
d262ed418d | |
|
2e9db4d667 | |
|
bd9317dd8f | |
|
461add1cda | |
|
1528dec668 | |
|
fff9d5d410 | |
|
231c354cb1 | |
|
4e0149e752 | |
|
5c6b9191e5 | |
|
77a0f7d8a0 | |
|
9faae6fc36 | |
|
3689eb7528 | |
|
210dc85558 | |
|
174b900cd8 | |
|
fbe954280f | |
|
142c990a0e | |
|
790ea3d551 | |
|
c6b8592490 | |
|
f67e011d5e | |
|
a4bc54482d | |
|
be50eb6fcf | |
|
a7d784583a | |
|
7af1f739e4 | |
|
3e247703a8 | |
|
c7e338ebff | |
|
cc2af435d5 | |
|
87695b173d | |
|
722ff9c05e | |
|
51114df576 | |
|
9126bc82c0 | |
|
e09fe7d42f | |
|
234e69c7a2 | |
|
d7017af245 | |
|
f49c70ead6 | |
|
9a89dbe6a5 | |
|
844bb286a5 | |
|
4eceecf139 | |
|
95e2e997e5 | |
|
346c303edb | |
|
908fe52ad8 | |
|
3fd1e47b7b | |
|
d41f082839 | |
|
2047ce4f76 | |
|
3ef56cab21 | |
|
6b77b98aad | |
|
211101cd6b | |
|
e27cae353f | |
|
b12a08e47a | |
|
9b298ac676 | |
|
52acb97e08 | |
|
78450e9e6a | |
|
dc746fe6f4 | |
|
0e3bc563a7 | |
|
d0ef5d410d | |
|
d9aa7dc698 | |
|
70ab8cb527 | |
|
512f6c86ad | |
|
d23eb290d9 | |
|
648bca5b2e | |
|
5db5d477e4 | |
|
7741134917 | |
|
3c19cd35cf | |
|
85832d18f6 | |
|
5f0da91659 | |
|
e1bf69e622 | |
|
d9290f7262 | |
|
81b6846261 | |
|
a57519adce | |
|
02639466ee | |
|
6e2795d380 | |
|
8e35596088 | |
|
0162d012c5 | |
|
47fb673b78 | |
|
f296488bc2 | |
|
f5392aea9f | |
|
24b1301f9f | |
|
1290a8f324 | |
|
e64277e438 | |
|
c9bcb74a9f | |
|
42db1f81b8 | |
|
7222952eba | |
|
744f10c948 | |
|
b50704a6a8 | |
|
c152806511 | |
|
4d9454daf2 | |
|
e754c65602 | |
|
b672921c84 | |
|
6116ada2fd | |
|
d7baa4d17b | |
|
ebc5504998 | |
|
c5e66a6f40 | |
|
cff558ef9a | |
|
325837d93e | |
|
135540b261 | |
|
49464cd25a | |
|
d0fe54b429 | |
|
2dce6f4b08 | |
|
99794d04c2 | |
|
cc06655cd6 | |
|
ab6f517d27 | |
|
682167db48 | |
|
f127dc1128 | |
|
0b816ae8e1 | |
|
c600fea4e1 | |
|
92067bdbef | |
|
c181e003a3 | |
|
597137670d | |
|
3036aebbc4 | |
|
cbe6477af2 | |
|
c2546d2bc5 | |
|
46be1bfd3b | |
|
1029885047 | |
|
164bde8cce | |
|
41504caac9 | |
|
9b34b4e026 | |
|
95612c1d18 | |
|
0829ec9081 | |
|
ef0d246901 | |
|
622a8a7c42 | |
|
925659ba4b | |
|
20c9287ac2 | |
|
8aaa2b8940 | |
|
30bd35e21d | |
|
0c2e39f0b2 | |
|
cbd7001228 | |
|
dec96ec9be | |
|
3942cd05be | |
|
ee1e9c9feb | |
|
fcb77232ec | |
|
1fcbec7466 | |
|
98f2c7a24a | |
|
787e6ed06e | |
|
bb5b7c7897 | |
|
42b3aa767d | |
|
b20a6084e6 | |
|
d9a8576701 | |
|
69273d2a1c | |
|
755ea757f7 | |
|
81fc54af8d | |
|
4281ca4390 | |
|
3419172535 | |
|
206c266b08 | |
|
5026cf869f | |
|
d5ecd9e057 | |
|
72b5077356 | |
|
6601c030f7 | |
|
3ec1373f08 | |
|
b29478cb58 | |
|
fe61e63e76 | |
|
ee0ab663d7 | |
|
1964d6002d | |
|
f55b72044c | |
|
3f759f5678 | |
|
6582154ec6 | |
|
9d0545aa4f | |
|
ea055d6e56 | |
|
bc48765b35 | |
|
70c2c695f0 | |
|
8ec5816364 | |
|
c33c6e24f6 | |
|
b0ca15bd8d | |
|
76799bd66d | |
|
18dbb72a54 | |
|
c0ec81c0f9 | |
|
c3661d6ff1 | |
|
c0f056cd8d | |
|
2924efe39f | |
|
e275539fb0 | |
|
4c13c54815 | |
|
62a66f5f6d | |
|
3a435933e3 | |
|
78f7ac0e68 | |
|
28dc19fc32 | |
|
585c47d6c7 | |
|
04a0330327 | |
|
dae4e65aee | |
|
129647b863 | |
|
2f9201716a | |
|
f9d716552b | |
|
818c8453ee | |
|
f7a3c52260 | |
|
9d3bf24627 | |
|
c77201ef4e | |
|
f585aa2a5a | |
|
96e0ce6050 | |
|
17d4ff459f | |
|
c15c376a2f | |
|
22bed4632b | |
|
8b5faaa1a4 | |
|
81d94fd727 | |
|
bbfe6fc657 | |
|
467a5c06d6 | |
|
9dce9fb1f2 | |
|
e1c8ba1320 | |
|
4ef318c55e | |
|
7f7513809a | |
|
b3bb07454f | |
|
faad084b2b | |
|
3e528c23a5 | |
|
6fed941441 | |
|
6fee5a803c | |
|
2861bc52fd | |
|
8c14a06b96 | |
|
3e0ac3f0d0 | |
|
394fbe2323 | |
|
11267796ba |
|
@ -3,4 +3,12 @@
|
||||||
*.Parent
|
*.Parent
|
||||||
|
|
||||||
node_modules
|
node_modules
|
||||||
dist
|
dist
|
||||||
|
|
||||||
|
*.svd
|
||||||
|
*debug_custom.json
|
||||||
|
*debug.cfg
|
||||||
|
|
||||||
|
notes/mphd
|
||||||
|
|
||||||
|
./lib
|
|
@ -0,0 +1,9 @@
|
||||||
|
[submodule "scad/common"]
|
||||||
|
path = scad/common
|
||||||
|
url = https://git.sixteenmillimeter.com/modules/common.git
|
||||||
|
[submodule "scad/sprocketed_roller"]
|
||||||
|
path = scad/sprocketed_roller
|
||||||
|
url = https://git.sixteenmillimeter.com/modules/sprocketed_roller.git
|
||||||
|
[submodule "scad/MCAD"]
|
||||||
|
path = scad/MCAD
|
||||||
|
url = https://github.com/openscad/MCAD.git
|
180
Readme.md
180
Readme.md
|
@ -1,87 +1,93 @@
|
||||||
# mcopy
|
# mcopy
|
||||||
|
|
||||||
An open platform for controlling small-gauge film optical printers (16mm, Super8, 8mm).
|
An open platform for controlling small-gauge film optical printers (16mm, Super8, 8mm).
|
||||||
|
|
||||||
-------
|
## [Project Home - git.sixteenmillimeter.com/16mm/mcopy](https://git.sixteenmillimeter.com/16mm/mcopy)
|
||||||
1. <a href="#intro">Introduction</a>
|
|
||||||
2. <a href="#downloads">Downloads</a>
|
* Github Mirror - [github.com/sixteenmillimeter/mcopy](https://github.com/sixteenmillimeter/mcopy)
|
||||||
1. <a href="#usage">Usage</a>
|
* Gitlab Mirror - [gitlab.com/16mm/mcopy](https://gitlab.com/16mm/mcopy)
|
||||||
2. <a href="#software">Software</a>
|
|
||||||
3. <a href="#firmware">Firmware</a>
|
-------
|
||||||
3. <a href="#hardware">Hardware</a>
|
1. <a href="#intro">Introduction</a>
|
||||||
4. <a href="#why">Why?</a>
|
2. <a href="#downloads">Downloads</a>
|
||||||
|
1. <a href="#usage">Usage</a>
|
||||||
-------
|
2. <a href="#software">Software</a>
|
||||||
|
3. <a href="#firmware">Firmware</a>
|
||||||
## Introduction <a name="intro"></a>
|
3. <a href="#hardware">Hardware</a>
|
||||||
|
4. <a href="#why">Why?</a>
|
||||||
The `mcopy` project is comprised of software and hardware for optical printers, built with re-purposed broken projectors.
|
|
||||||
|
-------
|
||||||
#### Components
|
|
||||||
|
## Introduction <a name="intro"></a>
|
||||||
* Sequencer desktop app
|
|
||||||
* Scripting language, called `mscript`, for orchestrating complex sequences
|
The `mcopy` project is comprised of software and hardware for optical printers, built with re-purposed broken projectors.
|
||||||
* Arduino firmware for projectors, cameras, lights and existing printers
|
|
||||||
* 3D models of parts used for modifying projectors and printers
|
#### Components
|
||||||
* Schematics for simple Arduino-based electronics
|
|
||||||
* Filmout feature for digitally transferring video and images to analog film
|
* Sequencer desktop app
|
||||||
* Interoperability with the [intval3](https://github.com/sixteenmillimeter/intval3) intervalometer
|
* Scripting language, called `mscript`, for orchestrating complex sequences
|
||||||
|
* Arduino firmware for projectors, cameras, lights and existing printers
|
||||||
## Downloads <a name="downloads"></a>
|
* 3D models of parts used for modifying projectors and printers
|
||||||
|
* Schematics for simple Arduino-based electronics
|
||||||
### Latest Installers
|
* Filmout feature for digitally transferring video and images to analog film
|
||||||
|
* Interoperability with the [intval3](https://github.com/sixteenmillimeter/intval3) intervalometer
|
||||||
* [1.6.7](https://github.com/sixteenmillimeter/mcopy/releases/tag/1.6.7) for macOS and Linux (.deb)
|
|
||||||
|
## Downloads <a name="downloads"></a>
|
||||||
### Older Versions
|
|
||||||
* [1.6.4](https://github.com/sixteenmillimeter/mcopy/releases/tag/1.6.4) for macOS, Linux (.deb) and Windows (.msi)
|
### Latest Installers
|
||||||
* [1.6.2](https://github.com/sixteenmillimeter/mcopy/releases/tag/1.6.2) for macOS
|
|
||||||
* [1.6.1](https://github.com/sixteenmillimeter/mcopy/releases/tag/1.6.1) for macOS
|
* [1.6.9](https://github.com/sixteenmillimeter/mcopy/releases/tag/1.6.9) for macOS, Linux (.deb) and Windows (.msi)
|
||||||
* [1.5.2](https://github.com/sixteenmillimeter/mcopy/releases/tag/1.5.2) for macOS
|
|
||||||
* [1.4.9](https://github.com/sixteenmillimeter/mcopy/releases/tag/1.4.9) for macOS and Linux (.deb)
|
### Older Versions
|
||||||
* [1.2.0](https://github.com/sixteenmillimeter/mcopy/releases/tag/1.2.0) for macOS and Linux (.deb)
|
* [1.6.7](https://github.com/sixteenmillimeter/mcopy/releases/tag/1.6.7) for macOS and Linux (.deb)
|
||||||
* [1.0.3](https://github.com/sixteenmillimeter/mcopy/releases/tag/1.0.3) for macOS and Linux (.deb)
|
* [1.6.4](https://github.com/sixteenmillimeter/mcopy/releases/tag/1.6.4) for macOS, Linux (.deb) and Windows (.msi)
|
||||||
|
* [1.6.2](https://github.com/sixteenmillimeter/mcopy/releases/tag/1.6.2) for macOS
|
||||||
For Windows, you can [install from source](https://github.com/sixteenmillimeter/mcopy/tree/master/app#mcopy-desktop-app) for now.
|
* [1.6.1](https://github.com/sixteenmillimeter/mcopy/releases/tag/1.6.1) for macOS
|
||||||
|
* [1.5.2](https://github.com/sixteenmillimeter/mcopy/releases/tag/1.5.2) for macOS
|
||||||
## Usage <a name="usage"></a>
|
* [1.4.9](https://github.com/sixteenmillimeter/mcopy/releases/tag/1.4.9) for macOS and Linux (.deb)
|
||||||
|
* [1.2.0](https://github.com/sixteenmillimeter/mcopy/releases/tag/1.2.0) for macOS and Linux (.deb)
|
||||||
The software requires your hardware to be in place before the mcopy control app is useful.
|
* [1.0.3](https://github.com/sixteenmillimeter/mcopy/releases/tag/1.0.3) for macOS and Linux (.deb)
|
||||||
|
|
||||||
![mcopy app](docs/mcopy.png?raw=true "mcopy app")
|
For Windows, you can [install from source](https://github.com/sixteenmillimeter/mcopy/tree/master/app#mcopy-desktop-app) for now.
|
||||||
|
|
||||||
## Software <a name="software"></a>
|
## Usage <a name="usage"></a>
|
||||||
|
|
||||||
The mcopy desktop app is an Electron-based project which can be built for Linux, Windows and macOS.
|
The software requires your hardware to be in place before the mcopy control app is useful.
|
||||||
Pre-built packages will be made available for macOS, initially, with the other two target platforms to follow.
|
|
||||||
To build the desktop app from source, see the [installation and running instructions](https://github.com/sixteenmillimeter/mcopy/tree/master/app#mcopy-desktop-app).
|
![mcopy app](docs/mcopy.png?raw=true "mcopy app")
|
||||||
The desktop software also interoperates with two related projects; the Bluetooth + Wifi capable, Raspberry Pi-based [INTVAL3](https://github.com/sixteenmillimeter/intval3) and the Arduino-based [intval2](https://github.com/sixteenmillimeter/intval2).
|
|
||||||
|
## Software <a name="software"></a>
|
||||||
## Firmware <a name="firmware"></a>
|
|
||||||
|
The mcopy desktop app is an Electron-based project which can be built for Linux, Windows and macOS.
|
||||||
This project contains Arduino formware for controlling:
|
Pre-built packages will be made available for macOS, initially, with the other two target platforms to follow.
|
||||||
|
To build the desktop app from source, see the [installation and running instructions](https://github.com/sixteenmillimeter/mcopy/tree/master/app#mcopy-desktop-app).
|
||||||
* a projector
|
The desktop software also interoperates with two related projects; the Bluetooth + Wifi capable, Raspberry Pi-based [INTVAL3](https://github.com/sixteenmillimeter/intval3) and the Arduino-based [intval2](https://github.com/sixteenmillimeter/intval2).
|
||||||
* a camera (see [intval2](https://github.com/sixteenmillimeter/intval2) for more info)
|
|
||||||
* a light
|
## Firmware <a name="firmware"></a>
|
||||||
* a projector + a camera
|
|
||||||
* a projector + a light
|
This project contains Arduino formware for controlling:
|
||||||
* a camera + a light
|
|
||||||
* a camera + a projector + a light
|
* a projector
|
||||||
|
* a camera (see [intval2](https://github.com/sixteenmillimeter/intval2) for more info)
|
||||||
Using a simple serial interface, this modular platform can be used to control DIY components, modified existing optical printers or a mixture of components.
|
* a light
|
||||||
The desktop app can connect to multiple serial devices, so your mcopy optical printer can be built from various designs that suit your hardware tastes/needs/available parts.
|
* a projector + a camera
|
||||||
|
* a projector + a light
|
||||||
|
* a camera + a light
|
||||||
## Hardware <a name="hardware"></a>
|
* a camera + a projector + a light
|
||||||
|
|
||||||
All non-electronic hardware for this project is available as plaintext OpenSCAD files and 3D print-able .STL files.
|
Using a simple serial interface, this modular platform can be used to control DIY components, modified existing optical printers or a mixture of components.
|
||||||
The hardware component of this project is aimed at modifying broken Bell & Howell projectors into USB serial-controlled projectors to be used in optical printing.
|
The desktop app can connect to multiple serial devices, so your mcopy optical printer can be built from various designs that suit your hardware tastes/needs/available parts.
|
||||||
|
|
||||||
As a secondary capability, this desktop software and firmware package can be used to replace the sequencers for early-model JK optical printers, with some modification.
|
|
||||||
|
## Hardware <a name="hardware"></a>
|
||||||
|
|
||||||
## Why? <a name="why"></a>
|
All non-electronic hardware for this project is available as plaintext OpenSCAD files and 3D print-able .STL files.
|
||||||
|
The hardware component of this project is aimed at modifying broken Bell & Howell projectors into USB serial-controlled projectors to be used in optical printing.
|
||||||
I'm interested in expanding the viability and access of the 16mm film format and to repurpose thre rising tide of discarded film technology.
|
|
||||||
|
As a secondary capability, this desktop software and firmware package can be used to replace the sequencers for early-model JK optical printers, with some modification.
|
||||||
|
|
||||||
|
|
||||||
|
## Why? <a name="why"></a>
|
||||||
|
|
||||||
|
I'm interested in expanding the viability and access of the 16mm film format and to repurpose thre rising tide of discarded film technology.
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
node_modules/*
|
node_modules/*
|
||||||
logs/*
|
logs/*
|
||||||
data/transfer*.json
|
data/transfer*.json
|
||||||
|
.appleId*
|
||||||
|
.applePwd*
|
||||||
|
.appleIdentity*
|
||||||
|
|
108
app/css/app.css
108
app/css/app.css
|
@ -194,8 +194,8 @@ button:focus {
|
||||||
width: 66px;
|
width: 66px;
|
||||||
height: 66px;
|
height: 66px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 7px;
|
top: 14px / 2;
|
||||||
left: 7px;
|
left: 14px / 2;
|
||||||
}
|
}
|
||||||
.dial-wrapper input {
|
.dial-wrapper input {
|
||||||
margin-top: 94px;
|
margin-top: 94px;
|
||||||
|
@ -210,10 +210,10 @@ button:focus {
|
||||||
top: 0;
|
top: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
width: 40px;
|
width: 80px / 2;
|
||||||
}
|
}
|
||||||
.dial-container.dial-container1 {
|
.dial-container.dial-container1 {
|
||||||
left: 40px;
|
left: 80px / 2;
|
||||||
}
|
}
|
||||||
.dial-container.dial-container1 .dial-wedge {
|
.dial-container.dial-container1 .dial-wedge {
|
||||||
transform: rotateZ(0deg);
|
transform: rotateZ(0deg);
|
||||||
|
@ -227,16 +227,16 @@ button:focus {
|
||||||
.dial-container.dial-container2 .dial-wedge {
|
.dial-container.dial-container2 .dial-wedge {
|
||||||
transform: rotateZ(0deg);
|
transform: rotateZ(0deg);
|
||||||
border-radius: 80px 0 0 80px;
|
border-radius: 80px 0 0 80px;
|
||||||
transform-origin: 40px 40px;
|
transform-origin: 80px/2 80px/2;
|
||||||
}
|
}
|
||||||
.dial-wedge {
|
.dial-wedge {
|
||||||
height: 80px;
|
height: 80px;
|
||||||
width: 40px;
|
width: 80px / 2;
|
||||||
}
|
}
|
||||||
.dial-marker {
|
.dial-marker {
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
height: 7px;
|
height: 14px / 2;
|
||||||
width: 7px;
|
width: 14px / 2;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: calc(50% - (14px * 2));
|
left: calc(50% - (14px * 2));
|
||||||
|
@ -367,6 +367,7 @@ button:focus {
|
||||||
float: right;
|
float: right;
|
||||||
width: 90px;
|
width: 90px;
|
||||||
margin-right: 60px;
|
margin-right: 60px;
|
||||||
|
height: 32px;
|
||||||
}
|
}
|
||||||
#seq_stats {
|
#seq_stats {
|
||||||
width: 40%;
|
width: 40%;
|
||||||
|
@ -484,6 +485,9 @@ button:focus {
|
||||||
#sequence #projector_second_backward > div {
|
#sequence #projector_second_backward > div {
|
||||||
color: #bf2e39;
|
color: #bf2e39;
|
||||||
}
|
}
|
||||||
|
#sequence #black input[type=checkbox]:checked {
|
||||||
|
background: white;
|
||||||
|
}
|
||||||
#sequence input[type=checkbox] {
|
#sequence input[type=checkbox] {
|
||||||
-webkit-appearance: none;
|
-webkit-appearance: none;
|
||||||
-moz-appearance: none;
|
-moz-appearance: none;
|
||||||
|
@ -500,6 +504,10 @@ button:focus {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
#sequence input[type=checkbox].disabled {
|
||||||
|
cursor: not-allowed;
|
||||||
|
border-color: #646464;
|
||||||
|
}
|
||||||
#sequence .L {
|
#sequence .L {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 35px;
|
width: 35px;
|
||||||
|
@ -627,6 +635,11 @@ button:focus {
|
||||||
background: #AB1A25;
|
background: #AB1A25;
|
||||||
border-color: #AB1A25;
|
border-color: #AB1A25;
|
||||||
}
|
}
|
||||||
|
.cmd:active.capper,
|
||||||
|
.cmd.active.capper {
|
||||||
|
background: white;
|
||||||
|
color: #272b30;
|
||||||
|
}
|
||||||
.cmd:active i,
|
.cmd:active i,
|
||||||
.cmd.active i {
|
.cmd.active i {
|
||||||
color: #272b30;
|
color: #272b30;
|
||||||
|
@ -650,14 +663,44 @@ button:focus {
|
||||||
::-webkit-scrollbar-thumb:window-inactive {
|
::-webkit-scrollbar-thumb:window-inactive {
|
||||||
background: rgba(0, 0, 0, 0.05);
|
background: rgba(0, 0, 0, 0.05);
|
||||||
}
|
}
|
||||||
|
#settings h4 {
|
||||||
|
margin-bottom: 1px;
|
||||||
|
}
|
||||||
#settings > div {
|
#settings > div {
|
||||||
width: 300px;
|
width: 300px;
|
||||||
margin: 0 auto;
|
}
|
||||||
|
#settings > div.left {
|
||||||
|
float: left;
|
||||||
|
padding-left: 30px;
|
||||||
|
}
|
||||||
|
#settings > div.right {
|
||||||
|
float: right;
|
||||||
|
padding-right: 30px;
|
||||||
|
}
|
||||||
|
#settings > div.right input[type=number] {
|
||||||
|
min-width: 200px;
|
||||||
|
width: 200px;
|
||||||
|
}
|
||||||
|
#settings > div.right input[readonly] {
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
#settings > div.right .spacer {
|
||||||
|
height: 62px;
|
||||||
|
}
|
||||||
|
#settings > div.right .proj_time {
|
||||||
|
height: 111px;
|
||||||
|
}
|
||||||
|
#settings > div.right .cam_time {
|
||||||
|
height: 111px;
|
||||||
|
}
|
||||||
|
#settings > div.right > div {
|
||||||
|
width: 270px;
|
||||||
}
|
}
|
||||||
#settings > div > div {
|
#settings > div > div {
|
||||||
width: 360px;
|
width: 360px;
|
||||||
}
|
}
|
||||||
#settings input[type=text],
|
#settings input[type=text],
|
||||||
|
#settings input[type=number],
|
||||||
#settings select {
|
#settings select {
|
||||||
display: block;
|
display: block;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
|
@ -672,33 +715,43 @@ button:focus {
|
||||||
padding: 6px 12px;
|
padding: 6px 12px;
|
||||||
font-size: 21px;
|
font-size: 21px;
|
||||||
min-width: 300px;
|
min-width: 300px;
|
||||||
|
max-width: 300px;
|
||||||
}
|
}
|
||||||
#settings input[type=text] span,
|
#settings input[type=text] span,
|
||||||
|
#settings input[type=number] span,
|
||||||
#settings select span {
|
#settings select span {
|
||||||
display: block;
|
display: block;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
font-weight: 200;
|
font-weight: 200;
|
||||||
}
|
}
|
||||||
#settings input[type=text]:active,
|
#settings input[type=text]:active,
|
||||||
|
#settings input[type=number]:active,
|
||||||
#settings select:active,
|
#settings select:active,
|
||||||
#settings input[type=text] .active,
|
#settings input[type=text] .active,
|
||||||
|
#settings input[type=number] .active,
|
||||||
#settings select .active {
|
#settings select .active {
|
||||||
background: #fff;
|
background: #fff;
|
||||||
color: #272b30;
|
color: #272b30;
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
#settings input[type=text]:focus,
|
#settings input[type=text]:focus,
|
||||||
|
#settings input[type=number]:focus,
|
||||||
#settings select:focus {
|
#settings select:focus {
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
#settings input[type=text].active,
|
#settings input[type=text].active,
|
||||||
|
#settings input[type=number].active,
|
||||||
#settings select.active {
|
#settings select.active {
|
||||||
border-color: #DAE035;
|
border-color: #DAE035;
|
||||||
color: #DAE035;
|
color: #DAE035;
|
||||||
}
|
}
|
||||||
|
#settings input[type=text] {
|
||||||
|
width: 200px;
|
||||||
|
}
|
||||||
#settings button {
|
#settings button {
|
||||||
margin-top: -1px;
|
margin-top: 0px;
|
||||||
float: right;
|
float: right;
|
||||||
|
padding: 8px 16px 9px;
|
||||||
}
|
}
|
||||||
#settings input[type=radio] {
|
#settings input[type=radio] {
|
||||||
float: right;
|
float: right;
|
||||||
|
@ -707,6 +760,17 @@ button:focus {
|
||||||
#settings .spacer {
|
#settings .spacer {
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
#settings #version {
|
||||||
|
position: absolute;
|
||||||
|
right: 20px;
|
||||||
|
bottom: 10px;
|
||||||
|
z-index: 1000;
|
||||||
|
height: 14px;
|
||||||
|
width: auto;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 14px;
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
.cm-s-monokai.CodeMirror {
|
.cm-s-monokai.CodeMirror {
|
||||||
background: #272b30 !important;
|
background: #272b30 !important;
|
||||||
}
|
}
|
||||||
|
@ -839,20 +903,22 @@ button:focus {
|
||||||
#filmout_position_wrap input {
|
#filmout_position_wrap input {
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
|
width: 308px !important;
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
#filmout_position_wrap button,
|
#filmout_position_wrap button,
|
||||||
#filmout_position_wrap input {
|
#filmout_position_wrap input {
|
||||||
float: left;
|
float: left;
|
||||||
}
|
}
|
||||||
#filmout_position_wrap > div {
|
#filmout_position_wrap > div {
|
||||||
width: 410px;
|
width: 425px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
#filmout_functions {
|
#filmout_functions {
|
||||||
padding-top: 5px;
|
padding-top: 5px;
|
||||||
}
|
}
|
||||||
#filmout_functions > div {
|
#filmout_functions > div {
|
||||||
width: 410px;
|
width: 425px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
#filmout_stats_video,
|
#filmout_stats_video,
|
||||||
|
@ -874,6 +940,12 @@ button:focus {
|
||||||
#filmout_stats_monitor {
|
#filmout_stats_monitor {
|
||||||
right: 5px;
|
right: 5px;
|
||||||
}
|
}
|
||||||
|
.hide {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.show {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
#screens {
|
#screens {
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
|
@ -1126,19 +1198,23 @@ button:focus {
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
.cam2,
|
.cam2,
|
||||||
.proj2 {
|
.proj2,
|
||||||
|
.black {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
.cam2 > *,
|
.cam2 > *,
|
||||||
.proj2 > * {
|
.proj2 > *,
|
||||||
|
.black > * {
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
}
|
}
|
||||||
.cam2.on,
|
.cam2.on,
|
||||||
.proj2.on {
|
.proj2.on,
|
||||||
|
.black.on {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
.cam2.on > *,
|
.cam2.on > *,
|
||||||
.proj2.on > * {
|
.proj2.on > *,
|
||||||
|
.black.on > * {
|
||||||
visibility: visible;
|
visibility: visible;
|
||||||
}
|
}
|
||||||
#overlay {
|
#overlay {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"version": "1.6.8",
|
"version": "1.8.120",
|
||||||
"ext_port": 1111,
|
"ext_port": 1111,
|
||||||
"profiles": {
|
"profiles": {
|
||||||
"mcopy": {
|
"mcopy": {
|
||||||
|
@ -15,8 +15,8 @@
|
||||||
"momentary": 0
|
"momentary": 0
|
||||||
},
|
},
|
||||||
"black": {
|
"black": {
|
||||||
"before": 0,
|
"before": 100,
|
||||||
"after": 0
|
"after": 100
|
||||||
},
|
},
|
||||||
"light": false
|
"light": false
|
||||||
},
|
},
|
||||||
|
@ -178,7 +178,24 @@
|
||||||
"cameras": "4",
|
"cameras": "4",
|
||||||
"camera_projectors_identifier": "5",
|
"camera_projectors_identifier": "5",
|
||||||
"cameras_projector_identifier": "6",
|
"cameras_projector_identifier": "6",
|
||||||
"cameras_projectors_identifier": "7"
|
"cameras_projectors_identifier": "7",
|
||||||
|
"capper_identifier": "C",
|
||||||
|
"camera_capper_identifier": "8",
|
||||||
|
"camera_capper_projector_identifier": "9",
|
||||||
|
"camera_capper_projectors_identifier": "0",
|
||||||
|
"capper_on": "A",
|
||||||
|
"capper_off": "B",
|
||||||
|
"camera_open_forward": "J",
|
||||||
|
"camera_open_backward": "K",
|
||||||
|
"camera_close_forward": "L",
|
||||||
|
"camera_close_backward": "M",
|
||||||
|
"takeup_forward": "D",
|
||||||
|
"takeup_backward": "F",
|
||||||
|
"error": "E",
|
||||||
|
"camera_exposure": "G",
|
||||||
|
"state": "H",
|
||||||
|
"home": "I",
|
||||||
|
"offset": "O"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,16 @@
|
||||||
body.meter {
|
body.meter {
|
||||||
background: rgb(117, 117, 117);
|
background: rgb(117, 117, 117);
|
||||||
}
|
}
|
||||||
|
body.meter #img,
|
||||||
|
body.meter #can {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
body.image #can{
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
body.image #img {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
#img {
|
#img {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
/*background-image: url(".../img/background.jpg");*/
|
/*background-image: url(".../img/background.jpg");*/
|
||||||
|
@ -46,35 +56,48 @@
|
||||||
</canvas>
|
</canvas>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
const { remote, ipcRenderer } = require('electron')
|
const { ipcRenderer } = require('electron')
|
||||||
|
const remote = require('@electron/remote')
|
||||||
let imgTmp;
|
let imgTmp;
|
||||||
|
function delay (ms) {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
return setTimeout(resolve, ms)
|
||||||
|
})
|
||||||
|
}
|
||||||
async function setImage (src) {
|
async function setImage (src) {
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
imgTmp = new Image()
|
imgTmp = new Image()
|
||||||
let img = document.getElementById('img')
|
let img = document.getElementById('img')
|
||||||
let body = document.querySelector('body')
|
let body = document.querySelector('body')
|
||||||
if (body.classList.contains('meter')) {
|
body.className = ''
|
||||||
body.classList.remove('meter')
|
body.classList.add('image')
|
||||||
}
|
|
||||||
imgTmp.onload = function () {
|
imgTmp.onload = function () {
|
||||||
img.style.backgroundImage = `url('${src}')`;
|
img.style.backgroundImage = `url('${src}')`
|
||||||
return resolve(src);
|
return resolve(src)
|
||||||
};
|
}
|
||||||
imgTmp.src = src;
|
imgTmp.src = src
|
||||||
});
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function setBlank () {
|
||||||
|
let img = document.getElementById('img')
|
||||||
|
img.style.background = ''
|
||||||
|
img.style.backgroundUrl = ''
|
||||||
|
img.style.backgroundColor = 'black'
|
||||||
}
|
}
|
||||||
async function onMeter () {
|
async function onMeter () {
|
||||||
console.log('meter')
|
console.log('meter')
|
||||||
const body = document.querySelector('body')
|
const body = document.querySelector('body')
|
||||||
if (!body.classList.contains('meter')) {
|
body.className = ''
|
||||||
body.classList.add('meter')
|
body.classList.add('meter')
|
||||||
}
|
|
||||||
}
|
}
|
||||||
async function onFocus () {
|
async function onFocus () {
|
||||||
console.log('focus')
|
console.log('focus')
|
||||||
const can = document.getElementById('can')
|
const can = document.getElementById('can')
|
||||||
const dpr = window.devicePixelRatio || 1
|
const dpr = window.devicePixelRatio || 1
|
||||||
|
const body = document.querySelector('body')
|
||||||
let ctx;
|
let ctx;
|
||||||
|
body.className = ''
|
||||||
if (!can.classList.contains('show')) {
|
if (!can.classList.contains('show')) {
|
||||||
can.classList.add('show')
|
can.classList.add('show')
|
||||||
}
|
}
|
||||||
|
@ -122,7 +145,9 @@
|
||||||
const can = document.getElementById('can')
|
const can = document.getElementById('can')
|
||||||
const dpr = window.devicePixelRatio || 1
|
const dpr = window.devicePixelRatio || 1
|
||||||
const screen = window.outerWidth / window.outerHeight
|
const screen = window.outerWidth / window.outerHeight
|
||||||
let ctx;
|
const body = document.querySelector('body')
|
||||||
|
let ctx
|
||||||
|
body.className = ''
|
||||||
if (!can.classList.contains('show')) {
|
if (!can.classList.contains('show')) {
|
||||||
can.classList.add('show')
|
can.classList.add('show')
|
||||||
}
|
}
|
||||||
|
@ -131,7 +156,7 @@
|
||||||
can.width = (window.innerHeight * arg.ratio) * dpr
|
can.width = (window.innerHeight * arg.ratio) * dpr
|
||||||
can.height = window.innerHeight * dpr
|
can.height = window.innerHeight * dpr
|
||||||
} else {
|
} else {
|
||||||
can.width =window.innerWidth * dpr
|
can.width = window.innerWidth * dpr
|
||||||
can.height = (window.innerWidth / arg.ratio) * dpr
|
can.height = (window.innerWidth / arg.ratio) * dpr
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -145,7 +170,7 @@
|
||||||
can.style.width = `${window.innerHeight * arg.ratio}px`
|
can.style.width = `${window.innerHeight * arg.ratio}px`
|
||||||
can.style.height = `${window.innerHeight}px`
|
can.style.height = `${window.innerHeight}px`
|
||||||
} else {
|
} else {
|
||||||
can.style.width = `${window.inneWidth}px`
|
can.style.width = `${window.innerWidth}px`
|
||||||
can.style.height = `${window.innerWidth / arg.ratio}px`
|
can.style.height = `${window.innerWidth / arg.ratio}px`
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -208,18 +233,28 @@
|
||||||
}
|
}
|
||||||
async function onDigital (event, arg) {
|
async function onDigital (event, arg) {
|
||||||
if (arg.src) {
|
if (arg.src) {
|
||||||
|
if (arg.exposure) {
|
||||||
|
setBlank()
|
||||||
|
await delay(10)
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
await setImage(arg.src)
|
await setImage(arg.src)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
}
|
}
|
||||||
ipcRenderer.send('display_load', { src : arg.src });
|
if (arg.exposure) {
|
||||||
|
await delay(arg.exposure)
|
||||||
|
setBlank()
|
||||||
|
}
|
||||||
|
ipcRenderer.send('display_load', { src : arg.src })
|
||||||
}
|
}
|
||||||
return event.returnValue = true
|
return event.returnValue = true
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onEscape (evt) {
|
async function onEscape (evt) {
|
||||||
let isEscape = false
|
let isEscape = false
|
||||||
let win
|
let win
|
||||||
|
|
||||||
evt = evt || window.event
|
evt = evt || window.event
|
||||||
|
|
||||||
if ('key' in evt) {
|
if ('key' in evt) {
|
||||||
|
@ -227,6 +262,7 @@
|
||||||
} else {
|
} else {
|
||||||
isEscape = (evt.keyCode == 27)
|
isEscape = (evt.keyCode == 27)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isEscape) {
|
if (isEscape) {
|
||||||
win = remote.getCurrentWindow()
|
win = remote.getCurrentWindow()
|
||||||
win.close()
|
win.close()
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>com.apple.security.cs.allow-jit</key>
|
||||||
|
<true/>
|
||||||
|
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
|
||||||
|
<true/>
|
||||||
|
<key>com.apple.security.cs.debugger</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
|
@ -13,7 +13,7 @@
|
||||||
</head>
|
</head>
|
||||||
<body onload="init();" style="background:#272b30;">
|
<body onload="init();" style="background:#272b30;">
|
||||||
<nav id="toolbar"></nav>
|
<nav id="toolbar"></nav>
|
||||||
<div id="screens">
|
<div id="screens" class="hide">
|
||||||
<div id="sequencer" class="screen" style="display: block;">
|
<div id="sequencer" class="screen" style="display: block;">
|
||||||
<div id="counters">
|
<div id="counters">
|
||||||
<div class="cam">
|
<div class="cam">
|
||||||
|
@ -45,6 +45,8 @@
|
||||||
<div id="camera_second_backward" class="row cam2" y="2"></div>
|
<div id="camera_second_backward" class="row cam2" y="2"></div>
|
||||||
<div id="projector_backward" class="row" y="1"></div>
|
<div id="projector_backward" class="row" y="1"></div>
|
||||||
<div id="projector_second_backward" class="row proj2" y="3"></div>
|
<div id="projector_second_backward" class="row proj2" y="3"></div>
|
||||||
|
|
||||||
|
<div id="black" class="row black"></div>
|
||||||
|
|
||||||
<div id="light_set" class="row spacer"></div>
|
<div id="light_set" class="row spacer"></div>
|
||||||
<div id="numbers" class="row"></div>
|
<div id="numbers" class="row"></div>
|
||||||
|
@ -60,6 +62,8 @@
|
||||||
<div><span>PROJ </span><i class="fa fa-minus"></i></div>
|
<div><span>PROJ </span><i class="fa fa-minus"></i></div>
|
||||||
<div class="proj2"><span>PROJ2 </span><i class="fa fa-minus"></i></div>
|
<div class="proj2"><span>PROJ2 </span><i class="fa fa-minus"></i></div>
|
||||||
|
|
||||||
|
<div class="black"><span>BLANK </span><i class="fa fa-times"></i></div>
|
||||||
|
|
||||||
<div class="spacer"><span>LIGHT</span></div>
|
<div class="spacer"><span>LIGHT</span></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -144,20 +148,34 @@
|
||||||
<i class="fa fa-step-backward"></i>
|
<i class="fa fa-step-backward"></i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="hide">
|
||||||
<button id="cmd_black_forward" onclick="cmd.black_forward();" class="cmd fwd">
|
<button id="cmd_black_forward" onclick="cmd.black_forward();" class="cmd fwd">
|
||||||
<i class="fa fa-times-circle"></i>
|
<i class="fa fa-times-circle"></i>
|
||||||
BLANK +1
|
BLANK +1
|
||||||
<i class="fa fa-step-forward"></i>
|
<i class="fa fa-step-forward"></i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="hide">
|
||||||
<button id="cmd_black_backward" onclick="cmd.black_backward();" class="cmd bwd">
|
<button id="cmd_black_backward" onclick="cmd.black_backward();" class="cmd bwd">
|
||||||
<i class="fa fa-times-circle"></i>
|
<i class="fa fa-times-circle"></i>
|
||||||
BLANK -1
|
BLANK -1
|
||||||
<i class="fa fa-step-backward"></i>
|
<i class="fa fa-step-backward"></i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="hide">
|
||||||
|
<button id="cmd_capper_on" onclick="cmd.capper_on();" class="cmd capper">
|
||||||
|
<i class="fa fa-times-circle"></i>
|
||||||
|
CAPPER ON
|
||||||
|
<i class="fa fa-eye"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="hide">
|
||||||
|
<button id="cmd_capper_off" onclick="cmd.capper_off();" class="cmd capper active">
|
||||||
|
<i class="fa fa-eye"></i>
|
||||||
|
CAPPER OFF
|
||||||
|
<i class="fa fa-eye"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<div>
|
||||||
|
@ -389,7 +407,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="settings" class="screen">
|
<div id="settings" class="screen">
|
||||||
<div>
|
<div class="left">
|
||||||
<div>
|
<div>
|
||||||
<h4>Devices</h4>
|
<h4>Devices</h4>
|
||||||
<select id="devices">
|
<select id="devices">
|
||||||
|
@ -419,6 +437,13 @@
|
||||||
<input type="text" id="intval" name="intval" placeholder="INTVAL3 URL"/>
|
<input type="text" id="intval" name="intval" placeholder="INTVAL3 URL"/>
|
||||||
<input type="radio" id="camera_type_intval" name="camera_type" value="intval" onclick="devices.intval();" />
|
<input type="radio" id="camera_type_intval" name="camera_type" value="intval" onclick="devices.intval();" />
|
||||||
</div>
|
</div>
|
||||||
|
<div class="spacer">
|
||||||
|
<input type="text" id="processing" name="processing" placeholder="PROCESSING URL" />
|
||||||
|
<input type="radio" id="camera_type_processing" name="camera_type" value="processing" onclick="devices.processing();" />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div id="version"></div>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h4>Light</h4>
|
<h4>Light</h4>
|
||||||
<select id="light_device">
|
<select id="light_device">
|
||||||
|
@ -432,6 +457,19 @@
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="right">
|
||||||
|
<div class="spacer"></div>
|
||||||
|
<div class="proj_time">
|
||||||
|
<h4>Projector Time (ms)</h4>
|
||||||
|
<input type="number" readonly id="proj_time" value="0" />
|
||||||
|
<button id="submit_proj_time" class="hide">✓</button>
|
||||||
|
</div>
|
||||||
|
<div class="cam_time">
|
||||||
|
<h4>Camera Time (ms)</h4>
|
||||||
|
<input type="number" readonly id="cam_time" value="0" />
|
||||||
|
<button id="submit_cam_time" class="hide" onclick="cam.exposure($('#cam_time').val());">✓</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="overlay" onclick="gui.overlay(false);gui.spinner(false);"></div>
|
<div id="overlay" onclick="gui.overlay(false);gui.spinner(false);"></div>
|
||||||
|
|
|
@ -2474,8 +2474,9 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
!function(a,b){"object"==typeof exports?module.exports=b():"function"==typeof define&&define.amd?define(b):a.Spinner=b()}(this,function(){"use strict";function a(a,b){var c,d=document.createElement(a||"div");for(c in b)d[c]=b[c];return d}function b(a){for(var b=1,c=arguments.length;c>b;b++)a.appendChild(arguments[b]);return a}function c(a,b,c,d){var e=["opacity",b,~~(100*a),c,d].join("-"),f=.01+c/d*100,g=Math.max(1-(1-a)/b*(100-f),a),h=j.substring(0,j.indexOf("Animation")).toLowerCase(),i=h&&"-"+h+"-"||"";return l[e]||(m.insertRule("@"+i+"keyframes "+e+"{0%{opacity:"+g+"}"+f+"%{opacity:"+a+"}"+(f+.01)+"%{opacity:1}"+(f+b)%100+"%{opacity:"+a+"}100%{opacity:"+g+"}}",m.cssRules.length),l[e]=1),e}function d(a,b){var c,d,e=a.style;for(b=b.charAt(0).toUpperCase()+b.slice(1),d=0;d<k.length;d++)if(c=k[d]+b,void 0!==e[c])return c;return void 0!==e[b]?b:void 0}function e(a,b){for(var c in b)a.style[d(a,c)||c]=b[c];return a}function f(a){for(var b=1;b<arguments.length;b++){var c=arguments[b];for(var d in c)void 0===a[d]&&(a[d]=c[d])}return a}function g(a,b){return"string"==typeof a?a:a[b%a.length]}function h(a){this.opts=f(a||{},h.defaults,n)}function i(){function c(b,c){return a("<"+b+' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">',c)}m.addRule(".spin-vml","behavior:url(#default#VML)"),h.prototype.lines=function(a,d){function f(){return e(c("group",{coordsize:k+" "+k,coordorigin:-j+" "+-j}),{width:k,height:k})}function h(a,h,i){b(m,b(e(f(),{rotation:360/d.lines*a+"deg",left:~~h}),b(e(c("roundrect",{arcsize:d.corners}),{width:j,height:d.width,left:d.radius,top:-d.width>>1,filter:i}),c("fill",{color:g(d.color,a),opacity:d.opacity}),c("stroke",{opacity:0}))))}var i,j=d.length+d.width,k=2*j,l=2*-(d.width+d.length)+"px",m=e(f(),{position:"absolute",top:l,left:l});if(d.shadow)for(i=1;i<=d.lines;i++)h(i,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(i=1;i<=d.lines;i++)h(i);return b(a,m)},h.prototype.opacity=function(a,b,c,d){var e=a.firstChild;d=d.shadow&&d.lines||0,e&&b+d<e.childNodes.length&&(e=e.childNodes[b+d],e=e&&e.firstChild,e=e&&e.firstChild,e&&(e.opacity=c))}}var j,k=["webkit","Moz","ms","O"],l={},m=function(){var c=a("style",{type:"text/css"});return b(document.getElementsByTagName("head")[0],c),c.sheet||c.styleSheet}(),n={lines:12,length:7,width:5,radius:10,rotate:0,corners:1,color:"#000",direction:1,speed:1,trail:100,opacity:.25,fps:20,zIndex:2e9,className:"spinner",top:"50%",left:"50%",position:"absolute"};h.defaults={},f(h.prototype,{spin:function(b){this.stop();{var c=this,d=c.opts,f=c.el=e(a(0,{className:d.className}),{position:d.position,width:0,zIndex:d.zIndex});d.radius+d.length+d.width}if(e(f,{left:d.left,top:d.top}),b&&b.insertBefore(f,b.firstChild||null),f.setAttribute("role","progressbar"),c.lines(f,c.opts),!j){var g,h=0,i=(d.lines-1)*(1-d.direction)/2,k=d.fps,l=k/d.speed,m=(1-d.opacity)/(l*d.trail/100),n=l/d.lines;!function o(){h++;for(var a=0;a<d.lines;a++)g=Math.max(1-(h+(d.lines-a)*n)%l*m,d.opacity),c.opacity(f,a*d.direction+i,g,d);c.timeout=c.el&&setTimeout(o,~~(1e3/k))}()}return c},stop:function(){var a=this.el;return a&&(clearTimeout(this.timeout),a.parentNode&&a.parentNode.removeChild(a),this.el=void 0),this},lines:function(d,f){function h(b,c){return e(a(),{position:"absolute",width:f.length+f.width+"px",height:f.width+"px",background:b,boxShadow:c,transformOrigin:"left",transform:"rotate("+~~(360/f.lines*k+f.rotate)+"deg) translate("+f.radius+"px,0)",borderRadius:(f.corners*f.width>>1)+"px"})}for(var i,k=0,l=(f.lines-1)*(1-f.direction)/2;k<f.lines;k++)i=e(a(),{position:"absolute",top:1+~(f.width/2)+"px",transform:f.hwaccel?"translate3d(0,0,0)":"",opacity:f.opacity,animation:j&&c(f.opacity,f.trail,l+k*f.direction,f.lines)+" "+1/f.speed+"s linear infinite"}),f.shadow&&b(i,e(h("#000","0 0 4px #000"),{top:"2px"})),b(d,b(i,h(g(f.color,k),"0 0 1px rgba(0,0,0,.1)")));return d},opacity:function(a,b,c){b<a.childNodes.length&&(a.childNodes[b].style.opacity=c)}});var o=e(a("group"),{behavior:"url(#default#VML)"});return!d(o,"transform")&&o.adj?i():j=d(o,"animation"),h});
|
!function(a,b){"object"==typeof exports?module.exports=b():"function"==typeof define&&define.amd?define(b):a.Spinner=b()}(this,function(){"use strict";function a(a,b){var c,d=document.createElement(a||"div");for(c in b)d[c]=b[c];return d}function b(a){for(var b=1,c=arguments.length;c>b;b++)a.appendChild(arguments[b]);return a}function c(a,b,c,d){var e=["opacity",b,~~(100*a),c,d].join("-"),f=.01+c/d*100,g=Math.max(1-(1-a)/b*(100-f),a),h=j.substring(0,j.indexOf("Animation")).toLowerCase(),i=h&&"-"+h+"-"||"";return l[e]||(m.insertRule("@"+i+"keyframes "+e+"{0%{opacity:"+g+"}"+f+"%{opacity:"+a+"}"+(f+.01)+"%{opacity:1}"+(f+b)%100+"%{opacity:"+a+"}100%{opacity:"+g+"}}",m.cssRules.length),l[e]=1),e}function d(a,b){var c,d,e=a.style;for(b=b.charAt(0).toUpperCase()+b.slice(1),d=0;d<k.length;d++)if(c=k[d]+b,void 0!==e[c])return c;return void 0!==e[b]?b:void 0}function e(a,b){for(var c in b)a.style[d(a,c)||c]=b[c];return a}function f(a){for(var b=1;b<arguments.length;b++){var c=arguments[b];for(var d in c)void 0===a[d]&&(a[d]=c[d])}return a}function g(a,b){return"string"==typeof a?a:a[b%a.length]}function h(a){this.opts=f(a||{},h.defaults,n)}function i(){function c(b,c){return a("<"+b+' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">',c)}m.addRule(".spin-vml","behavior:url(#default#VML)"),h.prototype.lines=function(a,d){function f(){return e(c("group",{coordsize:k+" "+k,coordorigin:-j+" "+-j}),{width:k,height:k})}function h(a,h,i){b(m,b(e(f(),{rotation:360/d.lines*a+"deg",left:~~h}),b(e(c("roundrect",{arcsize:d.corners}),{width:j,height:d.width,left:d.radius,top:-d.width>>1,filter:i}),c("fill",{color:g(d.color,a),opacity:d.opacity}),c("stroke",{opacity:0}))))}var i,j=d.length+d.width,k=2*j,l=2*-(d.width+d.length)+"px",m=e(f(),{position:"absolute",top:l,left:l});if(d.shadow)for(i=1;i<=d.lines;i++)h(i,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(i=1;i<=d.lines;i++)h(i);return b(a,m)},h.prototype.opacity=function(a,b,c,d){var e=a.firstChild;d=d.shadow&&d.lines||0,e&&b+d<e.childNodes.length&&(e=e.childNodes[b+d],e=e&&e.firstChild,e=e&&e.firstChild,e&&(e.opacity=c))}}var j,k=["webkit","Moz","ms","O"],l={},m=function(){var c=a("style",{type:"text/css"});return b(document.getElementsByTagName("head")[0],c),c.sheet||c.styleSheet}(),n={lines:12,length:7,width:5,radius:10,rotate:0,corners:1,color:"#000",direction:1,speed:1,trail:100,opacity:.25,fps:20,zIndex:2e9,className:"spinner",top:"50%",left:"50%",position:"absolute"};h.defaults={},f(h.prototype,{spin:function(b){this.stop();{var c=this,d=c.opts,f=c.el=e(a(0,{className:d.className}),{position:d.position,width:0,zIndex:d.zIndex});d.radius+d.length+d.width}if(e(f,{left:d.left,top:d.top}),b&&b.insertBefore(f,b.firstChild||null),f.setAttribute("role","progressbar"),c.lines(f,c.opts),!j){var g,h=0,i=(d.lines-1)*(1-d.direction)/2,k=d.fps,l=k/d.speed,m=(1-d.opacity)/(l*d.trail/100),n=l/d.lines;!function o(){h++;for(var a=0;a<d.lines;a++)g=Math.max(1-(h+(d.lines-a)*n)%l*m,d.opacity),c.opacity(f,a*d.direction+i,g,d);c.timeout=c.el&&setTimeout(o,~~(1e3/k))}()}return c},stop:function(){var a=this.el;return a&&(clearTimeout(this.timeout),a.parentNode&&a.parentNode.removeChild(a),this.el=void 0),this},lines:function(d,f){function h(b,c){return e(a(),{position:"absolute",width:f.length+f.width+"px",height:f.width+"px",background:b,boxShadow:c,transformOrigin:"left",transform:"rotate("+~~(360/f.lines*k+f.rotate)+"deg) translate("+f.radius+"px,0)",borderRadius:(f.corners*f.width>>1)+"px"})}for(var i,k=0,l=(f.lines-1)*(1-f.direction)/2;k<f.lines;k++)i=e(a(),{position:"absolute",top:1+~(f.width/2)+"px",transform:f.hwaccel?"translate3d(0,0,0)":"",opacity:f.opacity,animation:j&&c(f.opacity,f.trail,l+k*f.direction,f.lines)+" "+1/f.speed+"s linear infinite"}),f.shadow&&b(i,e(h("#000","0 0 4px #000"),{top:"2px"})),b(d,b(i,h(g(f.color,k),"0 0 1px rgba(0,0,0,.1)")));return d},opacity:function(a,b,c){b<a.childNodes.length&&(a.childNodes[b].style.opacity=c)}});var o=e(a("group"),{behavior:"url(#default#VML)"});return!d(o,"transform")&&o.adj?i():j=d(o,"animation"),h});
|
||||||
const mcopy = {};
|
const mcopy = {};
|
||||||
|
|
||||||
const { remote, ipcRenderer } = require('electron');
|
const remote = require('@electron/remote');
|
||||||
const dialog = require('electron').remote.dialog;
|
const { ipcRenderer } = require('electron');
|
||||||
|
const { dialog } = remote;
|
||||||
const notifier = require('node-notifier');
|
const notifier = require('node-notifier');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const uuid = require('uuid').v4;
|
const uuid = require('uuid').v4;
|
||||||
|
@ -2495,8 +2496,12 @@ const cmd = require('./lib/ui/cmd.js');
|
||||||
const devices = require('./lib/ui/devices.js');
|
const devices = require('./lib/ui/devices.js');
|
||||||
const filmout = require('./lib/ui/filmout.js');
|
const filmout = require('./lib/ui/filmout.js');
|
||||||
const mse = require('./lib/ui/mscript.js');
|
const mse = require('./lib/ui/mscript.js');
|
||||||
|
const capper = require('./lib/ui/capper.js');
|
||||||
|
const timing = require('./lib/ui/timing.js');
|
||||||
const Mscript = require('./lib/mscript');
|
const Mscript = require('./lib/mscript');
|
||||||
const { delay } = require('./lib/delay');
|
const { delay } = require('./lib/delay');
|
||||||
|
const alertObj = require('./lib/ui/alert.js');
|
||||||
|
const { Log } = require('./lib/log');
|
||||||
|
|
||||||
let log;
|
let log;
|
||||||
|
|
||||||
|
@ -2511,9 +2516,10 @@ mcopy.state = {
|
||||||
async function init () {
|
async function init () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
log = await require('log')({})
|
log = await Log({ label : 'ui' })
|
||||||
|
|
||||||
nav.init();
|
nav.init();
|
||||||
|
gui.init();
|
||||||
grid.init();
|
grid.init();
|
||||||
mse.mscript.init();
|
mse.mscript.init();
|
||||||
mse.console.init();
|
mse.console.init();
|
||||||
|
@ -2524,4 +2530,7 @@ async function init () {
|
||||||
proj.init();
|
proj.init();
|
||||||
cam.init();
|
cam.init();
|
||||||
seq.init();
|
seq.init();
|
||||||
|
capper.init();
|
||||||
|
alertObj.init();
|
||||||
|
timing.init();
|
||||||
};
|
};
|
|
@ -10,6 +10,13 @@
|
||||||
@import "./mscript.less";
|
@import "./mscript.less";
|
||||||
@import "./filmout.less";
|
@import "./filmout.less";
|
||||||
|
|
||||||
|
.hide {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.show {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
#screens{
|
#screens{
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
|
@ -168,7 +175,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.cam2,
|
.cam2,
|
||||||
.proj2{
|
.proj2,
|
||||||
|
.black{
|
||||||
display : none;
|
display : none;
|
||||||
> * {
|
> * {
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
|
|
|
@ -42,6 +42,10 @@
|
||||||
background: @BACKWARD;
|
background: @BACKWARD;
|
||||||
border-color: @BACKWARD;
|
border-color: @BACKWARD;
|
||||||
}
|
}
|
||||||
|
&.capper{
|
||||||
|
background: white;
|
||||||
|
color: @BG;
|
||||||
|
}
|
||||||
i{
|
i{
|
||||||
color: @BG;
|
color: @BG;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,12 +75,14 @@
|
||||||
input{
|
input{
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
|
width: 308px !important;
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
button, input{
|
button, input{
|
||||||
float: left;
|
float: left;
|
||||||
}
|
}
|
||||||
> div{
|
> div{
|
||||||
width: 410px;
|
width: 425px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,7 +90,7 @@
|
||||||
#filmout_functions{
|
#filmout_functions{
|
||||||
padding-top: 5px;
|
padding-top: 5px;
|
||||||
> div{
|
> div{
|
||||||
width: 410px;
|
width: 425px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
float: right;
|
float: right;
|
||||||
width: 90px;
|
width: 90px;
|
||||||
margin-right: 60px;
|
margin-right: 60px;
|
||||||
|
height: 32px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#seq_stats{
|
#seq_stats{
|
||||||
|
@ -126,6 +127,13 @@
|
||||||
color: @BACKWARD + @SECOND;
|
color: @BACKWARD + @SECOND;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#black{
|
||||||
|
input[type=checkbox]{
|
||||||
|
&:checked{
|
||||||
|
background: white;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
input[type=checkbox]{
|
input[type=checkbox]{
|
||||||
-webkit-appearance: none;
|
-webkit-appearance: none;
|
||||||
-moz-appearance: none;
|
-moz-appearance: none;
|
||||||
|
@ -141,6 +149,10 @@
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
&.disabled{
|
||||||
|
cursor: not-allowed;
|
||||||
|
border-color: rgb(100, 100, 100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.L{
|
.L{
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
|
|
@ -1,25 +1,61 @@
|
||||||
#settings{
|
#settings{
|
||||||
|
h4{
|
||||||
|
margin-bottom: 1px;
|
||||||
|
}
|
||||||
> div{
|
> div{
|
||||||
width: 300px;
|
width: 300px;
|
||||||
margin: 0 auto;
|
&.left{
|
||||||
|
float: left;
|
||||||
|
padding-left: 30px;
|
||||||
|
}
|
||||||
|
&.right{
|
||||||
|
float: right;
|
||||||
|
padding-right: 30px;
|
||||||
|
input[type=number] {
|
||||||
|
min-width: 200px;
|
||||||
|
width: 200px;
|
||||||
|
}
|
||||||
|
input[readonly]{
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
.spacer{
|
||||||
|
height: 62px;
|
||||||
|
}
|
||||||
|
.proj_time{
|
||||||
|
height: 111px;
|
||||||
|
}
|
||||||
|
.cam_time{
|
||||||
|
height: 111px;
|
||||||
|
}
|
||||||
|
& > div {
|
||||||
|
width: 270px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
> div > div{
|
> div > div{
|
||||||
width: 360px;
|
width: 360px;
|
||||||
}
|
}
|
||||||
input[type=text], select{
|
input[type=text],
|
||||||
|
input[type=number],
|
||||||
|
select{
|
||||||
.button();
|
.button();
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: 6px 12px;
|
padding: 6px 12px;
|
||||||
font-size: 21px;
|
font-size: 21px;
|
||||||
min-width: 300px;
|
min-width: 300px;
|
||||||
|
max-width: 300px;
|
||||||
&.active{
|
&.active{
|
||||||
border-color: @SELECTED;
|
border-color: @SELECTED;
|
||||||
color: @SELECTED;
|
color: @SELECTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
input[type=text]{
|
||||||
|
width: 200px;
|
||||||
|
}
|
||||||
button{
|
button{
|
||||||
margin-top: -1px;
|
margin-top: 0px;
|
||||||
float: right;
|
float: right;
|
||||||
|
padding: 8px 16px 9px;
|
||||||
}
|
}
|
||||||
input[type=radio]{
|
input[type=radio]{
|
||||||
float: right;
|
float: right;
|
||||||
|
@ -28,4 +64,15 @@
|
||||||
.spacer{
|
.spacer{
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
#version{
|
||||||
|
position: absolute;
|
||||||
|
right: 20px;
|
||||||
|
bottom: 10px;
|
||||||
|
z-index: 1000;
|
||||||
|
height: 14px;
|
||||||
|
width: auto;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 14px;
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
<a name="module_lib/alert"></a>
|
||||||
|
|
||||||
|
## lib/alert
|
||||||
|
|
||||||
|
* [lib/alert](#module_lib/alert)
|
||||||
|
* [~Alert](#module_lib/alert..Alert)
|
||||||
|
* [.init()](#module_lib/alert..Alert+init)
|
||||||
|
* [.listen()](#module_lib/alert..Alert+listen)
|
||||||
|
* [.listener()](#module_lib/alert..Alert+listener)
|
||||||
|
* [.start()](#module_lib/alert..Alert+start)
|
||||||
|
|
||||||
|
<a name="module_lib/alert..Alert"></a>
|
||||||
|
|
||||||
|
### lib/alert~Alert
|
||||||
|
Class for pushing an alert to the UI from the backend.
|
||||||
|
|
||||||
|
**Kind**: inner class of [<code>lib/alert</code>](#module_lib/alert)
|
||||||
|
|
||||||
|
* [~Alert](#module_lib/alert..Alert)
|
||||||
|
* [.init()](#module_lib/alert..Alert+init)
|
||||||
|
* [.listen()](#module_lib/alert..Alert+listen)
|
||||||
|
* [.listener()](#module_lib/alert..Alert+listener)
|
||||||
|
* [.start()](#module_lib/alert..Alert+start)
|
||||||
|
|
||||||
|
<a name="module_lib/alert..Alert+init"></a>
|
||||||
|
|
||||||
|
#### alert.init()
|
||||||
|
**Kind**: instance method of [<code>Alert</code>](#module_lib/alert..Alert)
|
||||||
|
<a name="module_lib/alert..Alert+listen"></a>
|
||||||
|
|
||||||
|
#### alert.listen()
|
||||||
|
**Kind**: instance method of [<code>Alert</code>](#module_lib/alert..Alert)
|
||||||
|
<a name="module_lib/alert..Alert+listener"></a>
|
||||||
|
|
||||||
|
#### alert.listener()
|
||||||
|
**Kind**: instance method of [<code>Alert</code>](#module_lib/alert..Alert)
|
||||||
|
<a name="module_lib/alert..Alert+start"></a>
|
||||||
|
|
||||||
|
#### alert.start()
|
||||||
|
**Kind**: instance method of [<code>Alert</code>](#module_lib/alert..Alert)
|
|
@ -0,0 +1,29 @@
|
||||||
|
import type { WebContents } from 'electron';
|
||||||
|
/** @module lib/alert */
|
||||||
|
/**
|
||||||
|
* Class for pushing an alert to the UI from the backend.
|
||||||
|
*/
|
||||||
|
export declare class Alert {
|
||||||
|
private ipc;
|
||||||
|
private log;
|
||||||
|
private id;
|
||||||
|
private cb;
|
||||||
|
private ui;
|
||||||
|
constructor(ui: WebContents);
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private init;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private listen;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private listener;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
start(cmd: string): Promise<number>;
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
'use strict';
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.Alert = void 0;
|
||||||
|
const electron_1 = require("electron");
|
||||||
|
const log_1 = require("log");
|
||||||
|
/** @module lib/alert */
|
||||||
|
/**
|
||||||
|
* Class for pushing an alert to the UI from the backend.
|
||||||
|
*/
|
||||||
|
class Alert {
|
||||||
|
constructor(ui) {
|
||||||
|
this.ipc = electron_1.ipcMain;
|
||||||
|
this.id = 'alert';
|
||||||
|
this.cb = null;
|
||||||
|
this.ui = ui;
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
async init() {
|
||||||
|
this.log = await (0, log_1.Log)({ label: this.id });
|
||||||
|
this.listen();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
listen() {
|
||||||
|
this.ipc.on(this.id, this.listener.bind(this));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
async listener(event, arg) {
|
||||||
|
if (this.cb !== null) {
|
||||||
|
try {
|
||||||
|
await this.cb(arg.state, arg.id);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.log.error(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
event.returnValue = true;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
async start(cmd) {
|
||||||
|
const start = +new Date();
|
||||||
|
const msg = (cmd + '').replace('ALERT', '').replace('Alert', '').replace('alert', '').trim();
|
||||||
|
this.ui.send(this.id, { msg });
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
this.cb = function () {
|
||||||
|
const ms = (+new Date()) - start;
|
||||||
|
return resolve(ms);
|
||||||
|
};
|
||||||
|
}.bind(this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.Alert = Alert;
|
||||||
|
module.exports = { Alert };
|
||||||
|
//# sourceMappingURL=index.js.map
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/alert/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,uCAAmC;AAEnC,6BAA0B;AAI1B,wBAAwB;AAExB;;GAEG;AAEH,MAAa,KAAK;IAOjB,YAAc,EAAgB;QANtB,QAAG,GAAoB,kBAAO,CAAA;QAE9B,OAAE,GAAY,OAAO,CAAA;QACrB,OAAE,GAAc,IAAI,CAAA;QAI3B,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;QACZ,IAAI,CAAC,IAAI,EAAE,CAAA;IACZ,CAAC;IAED;;QAEI;IACI,KAAK,CAAC,IAAI;QACjB,IAAI,CAAC,GAAG,GAAG,MAAM,IAAA,SAAG,EAAC,EAAE,KAAK,EAAG,IAAI,CAAC,EAAE,EAAE,CAAC,CAAA;QACzC,IAAI,CAAC,MAAM,EAAE,CAAA;IACd,CAAC;IAED;;QAEI;IACI,MAAM;QACb,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IAC/C,CAAC;IAED;;QAEI;IACI,KAAK,CAAC,QAAQ,CAAE,KAAoB,EAAE,GAAS;QACtD,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI,EAAE;YACrB,IAAI;gBACH,MAAM,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC,CAAA;aAChC;YAAC,OAAO,GAAG,EAAE;gBACb,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;aACnB;SACD;QACD,KAAK,CAAC,WAAW,GAAG,IAAI,CAAA;IACzB,CAAC;IAED;;QAEI;IACG,KAAK,CAAC,KAAK,CAAE,GAAY;QAC/B,MAAM,KAAK,GAAY,CAAC,IAAI,IAAI,EAAE,CAAC;QACnC,MAAM,GAAG,GAAY,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;QACrG,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,CAAA;QAC9B,OAAO,IAAI,OAAO,CAAC,UAAU,OAAkB,EAAE,MAAiB;YACjE,IAAI,CAAC,EAAE,GAAG;gBACT,MAAM,EAAE,GAAY,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC;gBAC1C,OAAO,OAAO,CAAC,EAAE,CAAC,CAAC;YACpB,CAAC,CAAA;QACF,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACf,CAAC;CACD;AAvDD,sBAuDC;AAED,MAAM,CAAC,OAAO,GAAG,EAAE,KAAK,EAAE,CAAA"}
|
|
@ -1,43 +1,146 @@
|
||||||
<a name="Arduino"></a>
|
## Modules
|
||||||
|
|
||||||
## Arduino
|
<dl>
|
||||||
Class representing the arduino communication features
|
<dt><a href="#module_lib/arduino">lib/arduino</a></dt>
|
||||||
|
<dd></dd>
|
||||||
|
</dl>
|
||||||
|
|
||||||
**Kind**: global class
|
## Constants
|
||||||
|
|
||||||
* [Arduino](#Arduino)
|
<dl>
|
||||||
* [.enumerate()](#Arduino+enumerate) ⇒ <code>Promise</code>
|
<dt><a href="#delay_1">delay_1</a></dt>
|
||||||
* [.sendAsync(device, cmd)](#Arduino+sendAsync) ⇒ <code>Promise</code>
|
<dd><p>2023-07-16 Clarification</p>
|
||||||
* [.writeAsync(device, str)](#Arduino+writeAsync) ⇒ <code>Promise</code>
|
<p>Previous versions of this script intermingled and even
|
||||||
* [.openArduino(device)](#Arduino+openArduino) ⇒ <code>Promise</code>
|
swapped the usage of the terms 'serial' and 'device'.
|
||||||
* [.closeArduino(device)](#Arduino+closeArduino) ⇒ <code>Promise</code>
|
From here on out, the terms will be used as such:</p>
|
||||||
|
<p>serial - a hardware address of a serial port
|
||||||
|
device - common name of a type of mcopy device (eg. camera,
|
||||||
|
projector, light) that is aliased to a serial port</p>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
|
||||||
<a name="Arduino+enumerate"></a>
|
<a name="module_lib/arduino"></a>
|
||||||
|
|
||||||
### arduino.enumerate() ⇒ <code>Promise</code>
|
## lib/arduino
|
||||||
|
|
||||||
|
* [lib/arduino](#module_lib/arduino)
|
||||||
|
* [~Arduino](#module_lib/arduino..Arduino)
|
||||||
|
* [.enumerate()](#module_lib/arduino..Arduino+enumerate) ⇒ <code>Promise</code>
|
||||||
|
* [.sendAsync(device, cmd)](#module_lib/arduino..Arduino+sendAsync) ⇒ <code>Promise</code>
|
||||||
|
* [.send(device, cmd)](#module_lib/arduino..Arduino+send) ⇒ <code>Promise.<(boolean\|string)></code>
|
||||||
|
* [.sendString(device, str)](#module_lib/arduino..Arduino+sendString) ⇒ <code>Promise.<(boolean\|string)></code>
|
||||||
|
* [.stateAsync()](#module_lib/arduino..Arduino+stateAsync)
|
||||||
|
* [.state()](#module_lib/arduino..Arduino+state)
|
||||||
|
* [.writeAsync(device, str)](#module_lib/arduino..Arduino+writeAsync) ⇒ <code>Promise</code>
|
||||||
|
* [.end(serial, data)](#module_lib/arduino..Arduino+end) ⇒ <code>any</code>
|
||||||
|
* [.aliasSerial(device, serial)](#module_lib/arduino..Arduino+aliasSerial)
|
||||||
|
* [.connect(device, serial, confirm)](#module_lib/arduino..Arduino+connect) ⇒ <code>Promise.<string></code>
|
||||||
|
* [.confirmEnd(data)](#module_lib/arduino..Arduino+confirmEnd)
|
||||||
|
* [.verify()](#module_lib/arduino..Arduino+verify) ⇒ <code>Promise.<boolean></code>
|
||||||
|
* [.distinguish()](#module_lib/arduino..Arduino+distinguish) ⇒ <code>Promise.<string></code>
|
||||||
|
* [.close()](#module_lib/arduino..Arduino+close) ⇒ <code>Promise.<boolean></code>
|
||||||
|
* [.fakeConnect(serial)](#module_lib/arduino..Arduino+fakeConnect) ⇒ <code>Promise.<boolean></code>
|
||||||
|
* [.openArduino(device)](#module_lib/arduino..Arduino+openArduino) ⇒ <code>Promise</code>
|
||||||
|
* [.closeArduino(device)](#module_lib/arduino..Arduino+closeArduino) ⇒ <code>Promise</code>
|
||||||
|
|
||||||
|
<a name="module_lib/arduino..Arduino"></a>
|
||||||
|
|
||||||
|
### lib/arduino~Arduino
|
||||||
|
Class representing the arduino communication features.
|
||||||
|
|
||||||
|
**Kind**: inner class of [<code>lib/arduino</code>](#module_lib/arduino)
|
||||||
|
|
||||||
|
* [~Arduino](#module_lib/arduino..Arduino)
|
||||||
|
* [.enumerate()](#module_lib/arduino..Arduino+enumerate) ⇒ <code>Promise</code>
|
||||||
|
* [.sendAsync(device, cmd)](#module_lib/arduino..Arduino+sendAsync) ⇒ <code>Promise</code>
|
||||||
|
* [.send(device, cmd)](#module_lib/arduino..Arduino+send) ⇒ <code>Promise.<(boolean\|string)></code>
|
||||||
|
* [.sendString(device, str)](#module_lib/arduino..Arduino+sendString) ⇒ <code>Promise.<(boolean\|string)></code>
|
||||||
|
* [.stateAsync()](#module_lib/arduino..Arduino+stateAsync)
|
||||||
|
* [.state()](#module_lib/arduino..Arduino+state)
|
||||||
|
* [.writeAsync(device, str)](#module_lib/arduino..Arduino+writeAsync) ⇒ <code>Promise</code>
|
||||||
|
* [.end(serial, data)](#module_lib/arduino..Arduino+end) ⇒ <code>any</code>
|
||||||
|
* [.aliasSerial(device, serial)](#module_lib/arduino..Arduino+aliasSerial)
|
||||||
|
* [.connect(device, serial, confirm)](#module_lib/arduino..Arduino+connect) ⇒ <code>Promise.<string></code>
|
||||||
|
* [.confirmEnd(data)](#module_lib/arduino..Arduino+confirmEnd)
|
||||||
|
* [.verify()](#module_lib/arduino..Arduino+verify) ⇒ <code>Promise.<boolean></code>
|
||||||
|
* [.distinguish()](#module_lib/arduino..Arduino+distinguish) ⇒ <code>Promise.<string></code>
|
||||||
|
* [.close()](#module_lib/arduino..Arduino+close) ⇒ <code>Promise.<boolean></code>
|
||||||
|
* [.fakeConnect(serial)](#module_lib/arduino..Arduino+fakeConnect) ⇒ <code>Promise.<boolean></code>
|
||||||
|
* [.openArduino(device)](#module_lib/arduino..Arduino+openArduino) ⇒ <code>Promise</code>
|
||||||
|
* [.closeArduino(device)](#module_lib/arduino..Arduino+closeArduino) ⇒ <code>Promise</code>
|
||||||
|
|
||||||
|
<a name="module_lib/arduino..Arduino+enumerate"></a>
|
||||||
|
|
||||||
|
#### arduino.enumerate() ⇒ <code>Promise</code>
|
||||||
Enumerate all connected devices that might be Arduinos
|
Enumerate all connected devices that might be Arduinos
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Arduino</code>](#Arduino)
|
**Kind**: instance method of [<code>Arduino</code>](#module_lib/arduino..Arduino)
|
||||||
**Returns**: <code>Promise</code> - Resolves after enumerating
|
**Returns**: <code>Promise</code> - Resolves after enumerating
|
||||||
<a name="Arduino+sendAsync"></a>
|
<a name="module_lib/arduino..Arduino+sendAsync"></a>
|
||||||
|
|
||||||
### arduino.sendAsync(device, cmd) ⇒ <code>Promise</code>
|
#### arduino.sendAsync(device, cmd) ⇒ <code>Promise</code>
|
||||||
Send a command to an Arduino using async/await
|
Send a command to an Arduino using async/await
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Arduino</code>](#Arduino)
|
**Kind**: instance method of [<code>Arduino</code>](#module_lib/arduino..Arduino)
|
||||||
**Returns**: <code>Promise</code> - Resolves after sending
|
**Returns**: <code>Promise</code> - Resolves after sending
|
||||||
|
|
||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| device | <code>string</code> | Arduino identifier |
|
| device | <code>string</code> | The Arduino device identifier |
|
||||||
| cmd | <code>string</code> | Single character command to send |
|
| cmd | <code>string</code> | Single character command to send |
|
||||||
|
|
||||||
<a name="Arduino+writeAsync"></a>
|
<a name="module_lib/arduino..Arduino+send"></a>
|
||||||
|
|
||||||
### arduino.writeAsync(device, str) ⇒ <code>Promise</code>
|
#### arduino.send(device, cmd) ⇒ <code>Promise.<(boolean\|string)></code>
|
||||||
|
Sends a command to the specified Arduino and waits for a response.
|
||||||
|
Handles the communication lock to prevent sending multiple commands simultaneously.
|
||||||
|
Emits an 'arduino_send' event after successfully sending the command.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Arduino</code>](#module_lib/arduino..Arduino)
|
||||||
|
**Returns**: <code>Promise.<(boolean\|string)></code> - Returns 'false' if the communication is locked, otherwise returns the response from the device.
|
||||||
|
**Throws**:
|
||||||
|
|
||||||
|
- <code>Error</code> Throws an error if the sendAsync method encounters an error.
|
||||||
|
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| device | <code>string</code> | The Arduino device identifier. |
|
||||||
|
| cmd | <code>string</code> | The command to be sent to the Arduino. |
|
||||||
|
|
||||||
|
<a name="module_lib/arduino..Arduino+sendString"></a>
|
||||||
|
|
||||||
|
#### arduino.sendString(device, str) ⇒ <code>Promise.<(boolean\|string)></code>
|
||||||
|
Sends a string to the specified Arduino.
|
||||||
|
Handles different types of devices, including fake devices for testing purposes.
|
||||||
|
Waits for a specified delay before sending the string.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Arduino</code>](#module_lib/arduino..Arduino)
|
||||||
|
**Returns**: <code>Promise.<(boolean\|string)></code> - Returns 'true' if the string is sent successfully, otherwise returns an error message.
|
||||||
|
**Throws**:
|
||||||
|
|
||||||
|
- <code>Error</code> Throws an error if the writeAsync method encounters an error.
|
||||||
|
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| device | <code>string</code> | The Arduino device identifier. |
|
||||||
|
| str | <code>string</code> | The string to be sent to the Arduino. |
|
||||||
|
|
||||||
|
<a name="module_lib/arduino..Arduino+stateAsync"></a>
|
||||||
|
|
||||||
|
#### arduino.stateAsync()
|
||||||
|
**Kind**: instance method of [<code>Arduino</code>](#module_lib/arduino..Arduino)
|
||||||
|
<a name="module_lib/arduino..Arduino+state"></a>
|
||||||
|
|
||||||
|
#### arduino.state()
|
||||||
|
**Kind**: instance method of [<code>Arduino</code>](#module_lib/arduino..Arduino)
|
||||||
|
<a name="module_lib/arduino..Arduino+writeAsync"></a>
|
||||||
|
|
||||||
|
#### arduino.writeAsync(device, str) ⇒ <code>Promise</code>
|
||||||
Send a string to an Arduino using async/await
|
Send a string to an Arduino using async/await
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Arduino</code>](#Arduino)
|
**Kind**: instance method of [<code>Arduino</code>](#module_lib/arduino..Arduino)
|
||||||
**Returns**: <code>Promise</code> - Resolves after sending
|
**Returns**: <code>Promise</code> - Resolves after sending
|
||||||
|
|
||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
|
@ -45,27 +148,149 @@ Send a string to an Arduino using async/await
|
||||||
| device | <code>string</code> | Arduino identifier |
|
| device | <code>string</code> | Arduino identifier |
|
||||||
| str | <code>string</code> | String to send |
|
| str | <code>string</code> | String to send |
|
||||||
|
|
||||||
<a name="Arduino+openArduino"></a>
|
<a name="module_lib/arduino..Arduino+end"></a>
|
||||||
|
|
||||||
### arduino.openArduino(device) ⇒ <code>Promise</code>
|
#### arduino.end(serial, data) ⇒ <code>any</code>
|
||||||
|
Handles the end of communication with the Arduino.
|
||||||
|
Calculates the time taken for the communication, executes the callback,
|
||||||
|
and emits an 'arduino_end' event. Handles errors and stray data received.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Arduino</code>](#module_lib/arduino..Arduino)
|
||||||
|
**Returns**: <code>any</code> - The time taken for the communication in milliseconds.
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| serial | <code>string</code> | The serial address of the Arduino device. |
|
||||||
|
| data | <code>string</code> | The data received from the Arduino. |
|
||||||
|
|
||||||
|
<a name="module_lib/arduino..Arduino+aliasSerial"></a>
|
||||||
|
|
||||||
|
#### arduino.aliasSerial(device, serial)
|
||||||
|
Associates an alias with an Arduinos serial address.
|
||||||
|
Used to map multi-purpose devices onto the same serial connection.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Arduino</code>](#module_lib/arduino..Arduino)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| device | <code>string</code> | The serial number of the target Arduino. |
|
||||||
|
| serial | <code>string</code> | The alias to be associated with the target device. |
|
||||||
|
|
||||||
|
<a name="module_lib/arduino..Arduino+connect"></a>
|
||||||
|
|
||||||
|
#### arduino.connect(device, serial, confirm) ⇒ <code>Promise.<string></code>
|
||||||
|
Connects to an Arduino using its serial number.
|
||||||
|
Sets up the SerialPort instance and path for the device, and handles data communication.
|
||||||
|
Handles opening the connection and emitting 'arduino_end' or 'confirmEnd' events upon receiving data.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Arduino</code>](#module_lib/arduino..Arduino)
|
||||||
|
**Returns**: <code>Promise.<string></code> - Resolves with the device path if the connection is successful.
|
||||||
|
**Throws**:
|
||||||
|
|
||||||
|
- <code>Error</code> Rejects with an error message if the connection fails.
|
||||||
|
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| device | <code>string</code> | The device identifier (common name). |
|
||||||
|
| serial | <code>string</code> | The serial address of the target Arduino (e.g., COM port on Windows). |
|
||||||
|
| confirm | <code>function</code> | A callback function to be executed upon receiving confirmation data. |
|
||||||
|
|
||||||
|
<a name="module_lib/arduino..Arduino+confirmEnd"></a>
|
||||||
|
|
||||||
|
#### arduino.confirmEnd(data)
|
||||||
|
Handles the confirmation data received from an Arduino.
|
||||||
|
Executes the confirmation callback function if the received data is present in the list of expected values.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Arduino</code>](#module_lib/arduino..Arduino)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| data | <code>string</code> | The data received from the Arduino. |
|
||||||
|
|
||||||
|
<a name="module_lib/arduino..Arduino+verify"></a>
|
||||||
|
|
||||||
|
#### arduino.verify() ⇒ <code>Promise.<boolean></code>
|
||||||
|
Verifies the connection to an Arduino by sending a connect command.
|
||||||
|
The confirmation callback checks if the received data matches the expected connect command.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Arduino</code>](#module_lib/arduino..Arduino)
|
||||||
|
**Returns**: <code>Promise.<boolean></code> - Resolves with 'true' if the connection is verified successfully.
|
||||||
|
**Throws**:
|
||||||
|
|
||||||
|
- <code>Error</code> Rejects with an error message if the connection verification fails.
|
||||||
|
|
||||||
|
<a name="module_lib/arduino..Arduino+distinguish"></a>
|
||||||
|
|
||||||
|
#### arduino.distinguish() ⇒ <code>Promise.<string></code>
|
||||||
|
Distinguishes the type of Arduino connected.
|
||||||
|
Sends a command to the device to identify its type and resolves the promise with the received type.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Arduino</code>](#module_lib/arduino..Arduino)
|
||||||
|
**Returns**: <code>Promise.<string></code> - Resolves with the type of the connected Arduino-based device.
|
||||||
|
**Throws**:
|
||||||
|
|
||||||
|
- <code>Error</code> Rejects with an error message if the distinguish operation fails.
|
||||||
|
|
||||||
|
<a name="module_lib/arduino..Arduino+close"></a>
|
||||||
|
|
||||||
|
#### arduino.close() ⇒ <code>Promise.<boolean></code>
|
||||||
|
Closes the connection to an Arduino.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Arduino</code>](#module_lib/arduino..Arduino)
|
||||||
|
**Returns**: <code>Promise.<boolean></code> - Resolves with 'true' if the connection is closed successfully.
|
||||||
|
**Throws**:
|
||||||
|
|
||||||
|
- <code>Error</code> Throws an error if the closeArduino method encounters an error.
|
||||||
|
|
||||||
|
<a name="module_lib/arduino..Arduino+fakeConnect"></a>
|
||||||
|
|
||||||
|
#### arduino.fakeConnect(serial) ⇒ <code>Promise.<boolean></code>
|
||||||
|
Establishes a fake connection to an Arduino for testing purposes.
|
||||||
|
Creates a fake SerialPort instance with custom write and string methods.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Arduino</code>](#module_lib/arduino..Arduino)
|
||||||
|
**Returns**: <code>Promise.<boolean></code> - Resolves with 'true' if the fake connection is established successfully.
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| serial | <code>string</code> | The device identifier of the fake Arduino. |
|
||||||
|
|
||||||
|
<a name="module_lib/arduino..Arduino+openArduino"></a>
|
||||||
|
|
||||||
|
#### arduino.openArduino(device) ⇒ <code>Promise</code>
|
||||||
Connect to an Arduino using async/await
|
Connect to an Arduino using async/await
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Arduino</code>](#Arduino)
|
**Kind**: instance method of [<code>Arduino</code>](#module_lib/arduino..Arduino)
|
||||||
**Returns**: <code>Promise</code> - Resolves after opening
|
**Returns**: <code>Promise</code> - Resolves after opening
|
||||||
|
|
||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| device | <code>string</code> | Arduino identifier |
|
| device | <code>string</code> | Arduino identifier |
|
||||||
|
|
||||||
<a name="Arduino+closeArduino"></a>
|
<a name="module_lib/arduino..Arduino+closeArduino"></a>
|
||||||
|
|
||||||
### arduino.closeArduino(device) ⇒ <code>Promise</code>
|
#### arduino.closeArduino(device) ⇒ <code>Promise</code>
|
||||||
Close a connection to an Arduino using async/await
|
Close a connection to an Arduino using async/await
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Arduino</code>](#Arduino)
|
**Kind**: instance method of [<code>Arduino</code>](#module_lib/arduino..Arduino)
|
||||||
**Returns**: <code>Promise</code> - Resolves after closing
|
**Returns**: <code>Promise</code> - Resolves after closing
|
||||||
|
|
||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| device | <code>string</code> | Arduino identifier |
|
| device | <code>string</code> | Arduino identifier |
|
||||||
|
|
||||||
|
<a name="delay_1"></a>
|
||||||
|
|
||||||
|
## delay\_1
|
||||||
|
2023-07-16 Clarification
|
||||||
|
|
||||||
|
Previous versions of this script intermingled and even
|
||||||
|
swapped the usage of the terms 'serial' and 'device'.
|
||||||
|
From here on out, the terms will be used as such:
|
||||||
|
|
||||||
|
serial - a hardware address of a serial port
|
||||||
|
device - common name of a type of mcopy device (eg. camera,
|
||||||
|
projector, light) that is aliased to a serial port
|
||||||
|
|
||||||
|
**Kind**: global constant
|
||||||
|
|
|
@ -0,0 +1,179 @@
|
||||||
|
/// <reference types="node" />
|
||||||
|
import type { EventEmitter } from 'events';
|
||||||
|
import type { Config } from 'cfg';
|
||||||
|
/** @module lib/arduino */
|
||||||
|
/**
|
||||||
|
* Class representing the arduino communication features.
|
||||||
|
*/
|
||||||
|
export declare class Arduino {
|
||||||
|
private log;
|
||||||
|
private eventEmitter;
|
||||||
|
private cfg;
|
||||||
|
private path;
|
||||||
|
private known;
|
||||||
|
private serial;
|
||||||
|
private baud;
|
||||||
|
private queue;
|
||||||
|
private timer;
|
||||||
|
private locks;
|
||||||
|
private confirmExec;
|
||||||
|
private errorState;
|
||||||
|
private keys;
|
||||||
|
private values;
|
||||||
|
alias: any;
|
||||||
|
stateStr: any;
|
||||||
|
hasState: any;
|
||||||
|
constructor(cfg: Config, ee: EventEmitter, errorState: Function);
|
||||||
|
init(): Promise<void>;
|
||||||
|
/**
|
||||||
|
* Enumerate all connected devices that might be Arduinos
|
||||||
|
*
|
||||||
|
* @async
|
||||||
|
* @returns {Promise} Resolves after enumerating
|
||||||
|
**/
|
||||||
|
enumerate(): Promise<string[]>;
|
||||||
|
/**
|
||||||
|
* Send a command to an Arduino using async/await
|
||||||
|
*
|
||||||
|
* @param {string} device The Arduino device identifier
|
||||||
|
* @param {string} cmd Single character command to send
|
||||||
|
*
|
||||||
|
* @async
|
||||||
|
* @returns {Promise} Resolves after sending
|
||||||
|
**/
|
||||||
|
private sendAsync;
|
||||||
|
/**
|
||||||
|
* Sends a command to the specified Arduino and waits for a response.
|
||||||
|
* Handles the communication lock to prevent sending multiple commands simultaneously.
|
||||||
|
* Emits an 'arduino_send' event after successfully sending the command.
|
||||||
|
*
|
||||||
|
* @async
|
||||||
|
* @param {string} device - The Arduino device identifier.
|
||||||
|
* @param {string} cmd - The command to be sent to the Arduino.
|
||||||
|
* @returns {Promise<boolean|string>} Returns 'false' if the communication is locked, otherwise returns the response from the device.
|
||||||
|
* @throws {Error} Throws an error if the sendAsync method encounters an error.
|
||||||
|
**/
|
||||||
|
send(device: string, cmd: string): Promise<number>;
|
||||||
|
/**
|
||||||
|
* Sends a string to the specified Arduino.
|
||||||
|
* Handles different types of devices, including fake devices for testing purposes.
|
||||||
|
* Waits for a specified delay before sending the string.
|
||||||
|
*
|
||||||
|
* @async
|
||||||
|
* @param {string} device - The Arduino device identifier.
|
||||||
|
* @param {string} str - The string to be sent to the Arduino.
|
||||||
|
* @returns {Promise<boolean|string>} Returns 'true' if the string is sent successfully, otherwise returns an error message.
|
||||||
|
* @throws {Error} Throws an error if the writeAsync method encounters an error.
|
||||||
|
**/
|
||||||
|
sendString(device: string, str: string): Promise<number>;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private stateAsync;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
state(device: string, confirm?: boolean): Promise<string>;
|
||||||
|
/**
|
||||||
|
* Send a string to an Arduino using async/await
|
||||||
|
*
|
||||||
|
* @param {string} device Arduino identifier
|
||||||
|
* @param {string} str String to send
|
||||||
|
*
|
||||||
|
* @returns {Promise} Resolves after sending
|
||||||
|
**/
|
||||||
|
private writeAsync;
|
||||||
|
/**
|
||||||
|
* Handles the end of communication with the Arduino.
|
||||||
|
* Calculates the time taken for the communication, executes the callback,
|
||||||
|
* and emits an 'arduino_end' event. Handles errors and stray data received.
|
||||||
|
*
|
||||||
|
* @param {string} serial - The serial address of the Arduino device.
|
||||||
|
* @param {string} data - The data received from the Arduino.
|
||||||
|
* @returns {any} The time taken for the communication in milliseconds.
|
||||||
|
**/
|
||||||
|
private end;
|
||||||
|
private error;
|
||||||
|
/**
|
||||||
|
* Associates an alias with an Arduinos serial address.
|
||||||
|
* Used to map multi-purpose devices onto the same serial connection.
|
||||||
|
*
|
||||||
|
* @param {string} device - The serial number of the target Arduino.
|
||||||
|
* @param {string} serial - The alias to be associated with the target device.
|
||||||
|
**/
|
||||||
|
aliasSerial(device: string, serial: string): void;
|
||||||
|
/**
|
||||||
|
* Connects to an Arduino using its serial number.
|
||||||
|
* Sets up the SerialPort instance and path for the device, and handles data communication.
|
||||||
|
* Handles opening the connection and emitting 'arduino_end' or 'confirmEnd' events upon receiving data.
|
||||||
|
*
|
||||||
|
* @async
|
||||||
|
* @param {string} device - The device identifier (common name).
|
||||||
|
* @param {string} serial - The serial address of the target Arduino (e.g., COM port on Windows).
|
||||||
|
* @param {function} confirm - A callback function to be executed upon receiving confirmation data.
|
||||||
|
* @returns {Promise<string>} Resolves with the device path if the connection is successful.
|
||||||
|
* @throws {Error} Rejects with an error message if the connection fails.
|
||||||
|
**/
|
||||||
|
connect(device: string, serial: string, confirm: any): Promise<any>;
|
||||||
|
/**
|
||||||
|
* Handles the confirmation data received from an Arduino.
|
||||||
|
* Executes the confirmation callback function if the received data is present in the list of expected values.
|
||||||
|
*
|
||||||
|
* @param {string} data - The data received from the Arduino.
|
||||||
|
**/
|
||||||
|
private confirmEnd;
|
||||||
|
/**
|
||||||
|
* Verifies the connection to an Arduino by sending a connect command.
|
||||||
|
* The confirmation callback checks if the received data matches the expected connect command.
|
||||||
|
*
|
||||||
|
* @async
|
||||||
|
* @returns {Promise<boolean>} Resolves with 'true' if the connection is verified successfully.
|
||||||
|
* @throws {Error} Rejects with an error message if the connection verification fails.
|
||||||
|
**/
|
||||||
|
verify(): Promise<unknown>;
|
||||||
|
/**
|
||||||
|
* Distinguishes the type of Arduino connected.
|
||||||
|
* Sends a command to the device to identify its type and resolves the promise with the received type.
|
||||||
|
*
|
||||||
|
* @async
|
||||||
|
* @returns {Promise<string>} Resolves with the type of the connected Arduino-based device.
|
||||||
|
* @throws {Error} Rejects with an error message if the distinguish operation fails.
|
||||||
|
**/
|
||||||
|
distinguish(): Promise<string>;
|
||||||
|
/**
|
||||||
|
* Closes the connection to an Arduino.
|
||||||
|
*
|
||||||
|
* @async
|
||||||
|
* @returns {Promise<boolean>} Resolves with 'true' if the connection is closed successfully.
|
||||||
|
* @throws {Error} Throws an error if the closeArduino method encounters an error.
|
||||||
|
**/
|
||||||
|
close(): Promise<boolean>;
|
||||||
|
/**
|
||||||
|
* Establishes a fake connection to an Arduino for testing purposes.
|
||||||
|
* Creates a fake SerialPort instance with custom write and string methods.
|
||||||
|
*
|
||||||
|
* @async
|
||||||
|
* @param {string} serial - The device identifier of the fake Arduino.
|
||||||
|
* @returns {Promise<boolean>} Resolves with 'true' if the fake connection is established successfully.
|
||||||
|
**/
|
||||||
|
fakeConnect(device: string): Promise<boolean>;
|
||||||
|
/**
|
||||||
|
* Connect to an Arduino using async/await
|
||||||
|
*
|
||||||
|
* @param {string} device Arduino identifier
|
||||||
|
*
|
||||||
|
* @returns {Promise} Resolves after opening
|
||||||
|
**/
|
||||||
|
private openArduino;
|
||||||
|
/**
|
||||||
|
* Close a connection to an Arduino using async/await
|
||||||
|
*
|
||||||
|
* @param {string} device Arduino identifier
|
||||||
|
*
|
||||||
|
* @returns {Promise} Resolves after closing
|
||||||
|
**/
|
||||||
|
private closeArduino;
|
||||||
|
private lock;
|
||||||
|
private unlock;
|
||||||
|
private isLocked;
|
||||||
|
}
|
|
@ -1,16 +1,25 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
//import Log = require('log');
|
exports.Arduino = void 0;
|
||||||
|
/**
|
||||||
|
* 2023-07-16 Clarification
|
||||||
|
*
|
||||||
|
* Previous versions of this script intermingled and even
|
||||||
|
* swapped the usage of the terms 'serial' and 'device'.
|
||||||
|
* From here on out, the terms will be used as such:
|
||||||
|
*
|
||||||
|
* serial - a hardware address of a serial port
|
||||||
|
* device - common name of a type of mcopy device (eg. camera,
|
||||||
|
* projector, light) that is aliased to a serial port
|
||||||
|
*
|
||||||
|
**/
|
||||||
const delay_1 = require("delay");
|
const delay_1 = require("delay");
|
||||||
const SerialPort = require('serialport');
|
const log_1 = require("log");
|
||||||
const Readline = SerialPort.parsers.Readline;
|
const { SerialPort } = require('serialport');
|
||||||
const exec = require('child_process').exec;
|
const { ReadlineParser } = require('@serialport/parser-readline');
|
||||||
const parser = new Readline('');
|
const parser = new ReadlineParser({ delimiter: '\r\n' });
|
||||||
const newlineRe = new RegExp('\n', 'g');
|
const newlineRe = new RegExp('\n', 'g');
|
||||||
const returnRe = new RegExp('\r', 'g');
|
const returnRe = new RegExp('\r', 'g');
|
||||||
let eventEmitter;
|
|
||||||
let cfg;
|
|
||||||
let arduino;
|
|
||||||
const KNOWN = [
|
const KNOWN = [
|
||||||
'/dev/tty.usbmodem1a161',
|
'/dev/tty.usbmodem1a161',
|
||||||
'/dev/tty.usbserial-A800f8dk',
|
'/dev/tty.usbserial-A800f8dk',
|
||||||
|
@ -21,30 +30,36 @@ const KNOWN = [
|
||||||
'/dev/ttyACM0',
|
'/dev/ttyACM0',
|
||||||
'COM3'
|
'COM3'
|
||||||
];
|
];
|
||||||
|
/** @module lib/arduino */
|
||||||
/**
|
/**
|
||||||
* Class representing the arduino communication features
|
* Class representing the arduino communication features.
|
||||||
**/
|
*/
|
||||||
class Arduino {
|
class Arduino {
|
||||||
constructor(errorState) {
|
constructor(cfg, ee, errorState) {
|
||||||
this.path = {};
|
this.path = {};
|
||||||
this.known = KNOWN;
|
this.known = KNOWN;
|
||||||
this.alias = {};
|
this.serial = {};
|
||||||
this.serial = { connect: {}, projector: {}, camera: {}, light: {} };
|
|
||||||
this.baud = 57600;
|
this.baud = 57600;
|
||||||
this.queue = {};
|
this.queue = {};
|
||||||
this.timer = 0;
|
this.timer = 0;
|
||||||
this.lock = false;
|
|
||||||
this.locks = {};
|
this.locks = {};
|
||||||
|
this.alias = {};
|
||||||
|
this.stateStr = {};
|
||||||
|
this.hasState = {};
|
||||||
|
this.cfg = cfg;
|
||||||
|
this.eventEmitter = ee;
|
||||||
this.errorState = errorState;
|
this.errorState = errorState;
|
||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
async init() {
|
async init() {
|
||||||
const Log = require('log');
|
this.log = await (0, log_1.Log)({ label: 'arduino' });
|
||||||
this.log = await Log({ label: 'arduino' });
|
this.keys = Object.keys(this.cfg.arduino.cmd);
|
||||||
|
this.values = this.keys.map((key) => this.cfg.arduino.cmd[key]);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Enumerate all connected devices that might be Arduinos
|
* Enumerate all connected devices that might be Arduinos
|
||||||
*
|
*
|
||||||
|
* @async
|
||||||
* @returns {Promise} Resolves after enumerating
|
* @returns {Promise} Resolves after enumerating
|
||||||
**/
|
**/
|
||||||
async enumerate() {
|
async enumerate() {
|
||||||
|
@ -85,63 +100,149 @@ class Arduino {
|
||||||
/**
|
/**
|
||||||
* Send a command to an Arduino using async/await
|
* Send a command to an Arduino using async/await
|
||||||
*
|
*
|
||||||
* @param {string} device Arduino identifier
|
* @param {string} device The Arduino device identifier
|
||||||
* @param {string} cmd Single character command to send
|
* @param {string} cmd Single character command to send
|
||||||
*
|
*
|
||||||
|
* @async
|
||||||
* @returns {Promise} Resolves after sending
|
* @returns {Promise} Resolves after sending
|
||||||
**/
|
**/
|
||||||
async sendAsync(device, cmd) {
|
async sendAsync(device, cmd) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
//this.log.info(`sendAsync ${cmd} -> ${device}`)
|
||||||
this.queue[cmd] = (ms) => {
|
this.queue[cmd] = (ms) => {
|
||||||
return resolve(ms);
|
return resolve(ms);
|
||||||
};
|
};
|
||||||
return this.serial[device].write(cmd, (err, results) => {
|
//this.log.info(`Device: ${device}`)
|
||||||
|
return this.serial[this.alias[device]].write(cmd, (err, results) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
//console.error(err)
|
//this.log.error(err)
|
||||||
return reject(err);
|
return reject(err);
|
||||||
}
|
}
|
||||||
//
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
async send(serial, cmd) {
|
/**
|
||||||
const device = this.alias[serial];
|
* Sends a command to the specified Arduino and waits for a response.
|
||||||
let results;
|
* Handles the communication lock to prevent sending multiple commands simultaneously.
|
||||||
console.log(`${cmd} -> ${serial}`);
|
* Emits an 'arduino_send' event after successfully sending the command.
|
||||||
if (this.locks[serial]) {
|
*
|
||||||
return false;
|
* @async
|
||||||
|
* @param {string} device - The Arduino device identifier.
|
||||||
|
* @param {string} cmd - The command to be sent to the Arduino.
|
||||||
|
* @returns {Promise<boolean|string>} Returns 'false' if the communication is locked, otherwise returns the response from the device.
|
||||||
|
* @throws {Error} Throws an error if the sendAsync method encounters an error.
|
||||||
|
**/
|
||||||
|
async send(device, cmd) {
|
||||||
|
const serial = this.alias[device];
|
||||||
|
let ms;
|
||||||
|
this.log.info(`send ${cmd} -> ${device}`);
|
||||||
|
if (this.isLocked(serial)) {
|
||||||
|
this.log.error(`send Serial ${serial} is locked`);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
this.timer = new Date().getTime();
|
this.timer = new Date().getTime();
|
||||||
this.locks[serial] = true;
|
this.lock(serial);
|
||||||
await delay_1.delay(cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
try {
|
try {
|
||||||
results = await this.sendAsync(device, cmd);
|
ms = await this.sendAsync(device, cmd);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
return console.error(e);
|
this.log.error(`Failed to send to ${device} @ ${serial}`, e);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
this.locks[serial] = false;
|
this.unlock(serial);
|
||||||
await eventEmitter.emit('arduino_send', cmd);
|
await this.eventEmitter.emit('arduino_send', cmd);
|
||||||
return results;
|
return ms;
|
||||||
}
|
}
|
||||||
async string(serial, str) {
|
/**
|
||||||
const device = this.alias[serial];
|
* Sends a string to the specified Arduino.
|
||||||
let writeSuccess;
|
* Handles different types of devices, including fake devices for testing purposes.
|
||||||
await delay_1.delay(cfg.arduino.serialDelay);
|
* Waits for a specified delay before sending the string.
|
||||||
if (typeof this.serial[device].fake !== 'undefined'
|
*
|
||||||
&& this.serial[device].fake) {
|
* @async
|
||||||
return this.serial[device].string(str);
|
* @param {string} device - The Arduino device identifier.
|
||||||
|
* @param {string} str - The string to be sent to the Arduino.
|
||||||
|
* @returns {Promise<boolean|string>} Returns 'true' if the string is sent successfully, otherwise returns an error message.
|
||||||
|
* @throws {Error} Throws an error if the writeAsync method encounters an error.
|
||||||
|
**/
|
||||||
|
async sendString(device, str) {
|
||||||
|
let ms;
|
||||||
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
|
if (typeof this.serial[this.alias[device]].fake !== 'undefined'
|
||||||
|
&& this.serial[this.alias[device]].fake) {
|
||||||
|
return this.serial[this.alias[device]].string(str);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
this.log.info(`sendString ${str} -> ${device}`);
|
||||||
try {
|
try {
|
||||||
writeSuccess = await this.writeAsync(device, str);
|
ms = await this.writeAsync(device, str);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
return console.error(e);
|
this.log.error(`Error sending string to ${device}`, e);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
return writeSuccess;
|
this.unlock(this.alias[device]);
|
||||||
|
return ms;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
async stateAsync(device, confirm = false) {
|
||||||
|
const cmd = this.cfg.arduino.cmd.state;
|
||||||
|
const serial = confirm ? this.alias['connect'] : this.alias[device];
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
this.queue[cmd] = (state) => {
|
||||||
|
this.stateStr[device] = state;
|
||||||
|
if (confirm) {
|
||||||
|
this.hasState[device] = true;
|
||||||
|
this.log.info(`Device ${device} supports state [${state}]`);
|
||||||
|
}
|
||||||
|
return resolve(state);
|
||||||
|
};
|
||||||
|
if (confirm) {
|
||||||
|
setTimeout(function () {
|
||||||
|
if (typeof this.queue[cmd] !== 'undefined') {
|
||||||
|
delete this.queue[cmd];
|
||||||
|
this.hasState[device] = false;
|
||||||
|
this.log.info(`Device ${device} does not support state`);
|
||||||
|
return resolve(null);
|
||||||
|
}
|
||||||
|
}.bind(this), 1000);
|
||||||
|
}
|
||||||
|
this.log.info(`stateAsync ${cmd} -> ${device}`);
|
||||||
|
return this.serial[serial].write(cmd, (err, results) => {
|
||||||
|
if (err) {
|
||||||
|
//this.log.error(err)
|
||||||
|
return reject(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
async state(device, confirm = false) {
|
||||||
|
const serial = confirm ? this.alias['connect'] : this.alias[device];
|
||||||
|
let results;
|
||||||
|
if (this.isLocked(serial)) {
|
||||||
|
this.log.warn(`state Serial ${serial} is locked`);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
this.timer = new Date().getTime();
|
||||||
|
this.lock(serial);
|
||||||
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
|
try {
|
||||||
|
results = await this.stateAsync(device, confirm);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
this.log.error(`Error getting state from ${device}`, e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
this.unlock(serial);
|
||||||
|
await this.eventEmitter.emit('arduino_state', this.cfg.arduino.cmd.state);
|
||||||
|
return results;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Send a string to an Arduino using async/await
|
* Send a string to an Arduino using async/await
|
||||||
*
|
*
|
||||||
|
@ -152,7 +253,7 @@ class Arduino {
|
||||||
**/
|
**/
|
||||||
async writeAsync(device, str) {
|
async writeAsync(device, str) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.serial[device].write(str, function (err, results) {
|
this.serial[this.alias[device]].write(str, function (err, results) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return reject(err);
|
return reject(err);
|
||||||
}
|
}
|
||||||
|
@ -160,59 +261,104 @@ class Arduino {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Handles the end of communication with the Arduino.
|
||||||
|
* Calculates the time taken for the communication, executes the callback,
|
||||||
|
* and emits an 'arduino_end' event. Handles errors and stray data received.
|
||||||
|
*
|
||||||
|
* @param {string} serial - The serial address of the Arduino device.
|
||||||
|
* @param {string} data - The data received from the Arduino.
|
||||||
|
* @returns {any} The time taken for the communication in milliseconds.
|
||||||
|
**/
|
||||||
end(serial, data) {
|
end(serial, data) {
|
||||||
const end = new Date().getTime();
|
const end = new Date().getTime();
|
||||||
const ms = end - this.timer;
|
const ms = end - this.timer;
|
||||||
let complete;
|
let complete;
|
||||||
console.log(`${serial} -> ${data}`);
|
//this.log.info(`end ${serial} -> ${data}`)
|
||||||
if (this.queue[data] !== undefined) {
|
if (this.queue[data] !== undefined) {
|
||||||
this.locks[serial] = false;
|
this.unlock(serial);
|
||||||
complete = this.queue[data](ms); //execute callback
|
complete = this.queue[data](ms); //execute callback
|
||||||
eventEmitter.emit('arduino_end', data);
|
this.eventEmitter.emit('arduino_end', data);
|
||||||
delete this.queue[data];
|
delete this.queue[data];
|
||||||
}
|
}
|
||||||
else if (data === 'E') {
|
else if (data[0] === this.cfg.arduino.cmd.state) {
|
||||||
|
//this.log.info(`end serial -> ${serial}`)
|
||||||
|
this.unlock(serial);
|
||||||
|
complete = this.queue[this.cfg.arduino.cmd.state](data);
|
||||||
|
this.eventEmitter.emit('arduino_end', data);
|
||||||
|
delete this.queue[this.cfg.arduino.cmd.state];
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
else if (data[0] === this.cfg.arduino.cmd.error) {
|
||||||
|
this.log.error(`Received error from device ${serial}`);
|
||||||
|
this.unlock(serial);
|
||||||
|
this.error(serial, data);
|
||||||
//error state
|
//error state
|
||||||
//stop sequence
|
//stop sequence
|
||||||
//throw error in ui
|
//throw error in ui
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//console.log('Received stray "' + data + '"'); //silent to user
|
this.log.info('Received stray "' + data + '"'); //silent to user
|
||||||
}
|
}
|
||||||
return ms;
|
return ms;
|
||||||
}
|
}
|
||||||
aliasSerial(serial, device) {
|
error(serial, data) {
|
||||||
//this.log.info(`Making "${serial}" an alias of ${device}`);
|
this.log.error("ERROR", data);
|
||||||
this.alias[serial] = device;
|
|
||||||
}
|
}
|
||||||
async connect(serial, device, confirm) {
|
/**
|
||||||
|
* Associates an alias with an Arduinos serial address.
|
||||||
|
* Used to map multi-purpose devices onto the same serial connection.
|
||||||
|
*
|
||||||
|
* @param {string} device - The serial number of the target Arduino.
|
||||||
|
* @param {string} serial - The alias to be associated with the target device.
|
||||||
|
**/
|
||||||
|
aliasSerial(device, serial) {
|
||||||
|
//this.log.info(`Making "${serial}" an alias of ${device}`)
|
||||||
|
this.alias[device] = serial;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Connects to an Arduino using its serial number.
|
||||||
|
* Sets up the SerialPort instance and path for the device, and handles data communication.
|
||||||
|
* Handles opening the connection and emitting 'arduino_end' or 'confirmEnd' events upon receiving data.
|
||||||
|
*
|
||||||
|
* @async
|
||||||
|
* @param {string} device - The device identifier (common name).
|
||||||
|
* @param {string} serial - The serial address of the target Arduino (e.g., COM port on Windows).
|
||||||
|
* @param {function} confirm - A callback function to be executed upon receiving confirmation data.
|
||||||
|
* @returns {Promise<string>} Resolves with the device path if the connection is successful.
|
||||||
|
* @throws {Error} Rejects with an error message if the connection fails.
|
||||||
|
**/
|
||||||
|
async connect(device, serial, confirm) {
|
||||||
|
//this.log.info(`connect device ${device}`)
|
||||||
|
//this.log.info(`connect serial ${serial}`)
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
let connectSuccess;
|
let connectSuccess;
|
||||||
this.path[serial] = device;
|
this.path[device] = serial;
|
||||||
this.alias[serial] = device;
|
this.aliasSerial(device, serial);
|
||||||
this.serial[device] = new SerialPort(this.path[serial], {
|
this.serial[serial] = new SerialPort({
|
||||||
|
path: serial,
|
||||||
autoOpen: false,
|
autoOpen: false,
|
||||||
baudRate: cfg.arduino.baud,
|
baudRate: this.cfg.arduino.baud,
|
||||||
parser: parser
|
parser
|
||||||
});
|
});
|
||||||
this.locks[device] = false;
|
this.unlock(serial);
|
||||||
try {
|
try {
|
||||||
connectSuccess = await this.openArduino(device);
|
connectSuccess = await this.openArduino(device);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
console.error('failed to open: ' + e);
|
this.log.error(`Failed to open ${device} @ ${serial}: ` + e);
|
||||||
return reject(e);
|
return reject(e);
|
||||||
}
|
}
|
||||||
//console.log(`Opened connection with ${this.path[serial]} as ${serial}`);
|
this.log.info(`Opened connection with ${this.path[device]} as ${device}`);
|
||||||
if (!confirm) {
|
if (!confirm) {
|
||||||
this.serial[device].on('data', async (data) => {
|
this.serial[this.alias[device]].on('data', async (data) => {
|
||||||
let d = data.toString('utf8');
|
let d = data.toString('utf8');
|
||||||
d = d.replace(newlineRe, '').replace(returnRe, '');
|
d = d.replace(newlineRe, '').replace(returnRe, '');
|
||||||
return this.end(serial, d);
|
return this.end(serial, d);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.serial[device].on('data', async (data) => {
|
this.serial[this.alias[device]].on('data', async (data) => {
|
||||||
let d = data.toString('utf8');
|
let d = data.toString('utf8');
|
||||||
d = d.replace(newlineRe, '').replace(returnRe, '');
|
d = d.replace(newlineRe, '').replace(returnRe, '');
|
||||||
return await this.confirmEnd(d);
|
return await this.confirmEnd(d);
|
||||||
|
@ -221,46 +367,47 @@ class Arduino {
|
||||||
return resolve(this.path[serial]);
|
return resolve(this.path[serial]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Handles the confirmation data received from an Arduino.
|
||||||
|
* Executes the confirmation callback function if the received data is present in the list of expected values.
|
||||||
|
*
|
||||||
|
* @param {string} data - The data received from the Arduino.
|
||||||
|
**/
|
||||||
confirmEnd(data) {
|
confirmEnd(data) {
|
||||||
//console.dir(data)
|
if (this.values.indexOf(data) !== -1 && typeof this.confirmExec === 'function') {
|
||||||
if (data === cfg.arduino.cmd.connect
|
|
||||||
|| data === cfg.arduino.cmd.projector_identifier
|
|
||||||
|| data === cfg.arduino.cmd.camera_identifier
|
|
||||||
|| data === cfg.arduino.cmd.light_identifier
|
|
||||||
|| data === cfg.arduino.cmd.projector_light_identifier
|
|
||||||
|| data === cfg.arduino.cmd.projector_camera_light_identifier
|
|
||||||
|| data === cfg.arduino.cmd.projector_camera_identifier
|
|
||||||
|| data === cfg.arduino.cmd.projector_second_identifier
|
|
||||||
|| data === cfg.arduino.cmd.projectors_identifier
|
|
||||||
|| data === cfg.arduino.cmd.projector_second_forward
|
|
||||||
|| data === cfg.arduino.cmd.projector_second_backward
|
|
||||||
|| data === cfg.arduino.cmd.projector_second
|
|
||||||
|| data === cfg.arduino.cmd.projectors
|
|
||||||
|| data === cfg.arduino.cmd.camera_second_identifier
|
|
||||||
|| data === cfg.arduino.cmd.cameras_identifier
|
|
||||||
|| data === cfg.arduino.cmd.camera_second_forward
|
|
||||||
|| data === cfg.arduino.cmd.camera_second_backward
|
|
||||||
|| data === cfg.arduino.cmd.camera_second
|
|
||||||
|| data === cfg.arduino.cmd.cameras) {
|
|
||||||
this.confirmExec(null, data);
|
this.confirmExec(null, data);
|
||||||
this.confirmExec = {};
|
this.confirmExec = null;
|
||||||
|
this.unlock(this.alias['connect']);
|
||||||
|
}
|
||||||
|
else if (data[0] === this.cfg.arduino.cmd.state) {
|
||||||
|
this.queue[this.cfg.arduino.cmd.state](data);
|
||||||
|
delete this.queue[this.cfg.arduino.cmd.state];
|
||||||
|
this.unlock(this.alias['connect']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Verifies the connection to an Arduino by sending a connect command.
|
||||||
|
* The confirmation callback checks if the received data matches the expected connect command.
|
||||||
|
*
|
||||||
|
* @async
|
||||||
|
* @returns {Promise<boolean>} Resolves with 'true' if the connection is verified successfully.
|
||||||
|
* @throws {Error} Rejects with an error message if the connection verification fails.
|
||||||
|
**/
|
||||||
async verify() {
|
async verify() {
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
const device = this.alias['connect'];
|
const device = 'connect';
|
||||||
let writeSuccess;
|
let writeSuccess;
|
||||||
this.confirmExec = function (err, data) {
|
this.confirmExec = function (err, data) {
|
||||||
if (data === cfg.arduino.cmd.connect) {
|
if (data === this.cfg.arduino.cmd.connect) {
|
||||||
return resolve(true);
|
return resolve(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return reject('Wrong data returned');
|
return reject('Wrong data returned');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
await delay_1.delay(cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
try {
|
try {
|
||||||
writeSuccess = await this.sendAsync(device, cfg.arduino.cmd.connect);
|
writeSuccess = await this.sendAsync(device, this.cfg.arduino.cmd.connect);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
return reject(e);
|
return reject(e);
|
||||||
|
@ -268,64 +415,92 @@ class Arduino {
|
||||||
return resolve(writeSuccess);
|
return resolve(writeSuccess);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Distinguishes the type of Arduino connected.
|
||||||
|
* Sends a command to the device to identify its type and resolves the promise with the received type.
|
||||||
|
*
|
||||||
|
* @async
|
||||||
|
* @returns {Promise<string>} Resolves with the type of the connected Arduino-based device.
|
||||||
|
* @throws {Error} Rejects with an error message if the distinguish operation fails.
|
||||||
|
**/
|
||||||
async distinguish() {
|
async distinguish() {
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
const device = this.alias['connect'];
|
const device = 'connect';
|
||||||
let writeSuccess;
|
let writeSuccess;
|
||||||
let type;
|
let type;
|
||||||
this.confirmExec = function (err, data) {
|
this.confirmExec = function (err, data) {
|
||||||
if (data === cfg.arduino.cmd.projector_identifier) {
|
if (data === this.cfg.arduino.cmd.projector_identifier) {
|
||||||
type = 'projector';
|
type = 'projector';
|
||||||
}
|
}
|
||||||
else if (data === cfg.arduino.cmd.camera_identifier) {
|
else if (data === this.cfg.arduino.cmd.camera_identifier) {
|
||||||
type = 'camera';
|
type = 'camera';
|
||||||
}
|
}
|
||||||
else if (data === cfg.arduino.cmd.light_identifier) {
|
else if (data === this.cfg.arduino.cmd.light_identifier) {
|
||||||
type = 'light';
|
type = 'light';
|
||||||
}
|
}
|
||||||
else if (data === cfg.arduino.cmd.projector_light_identifier) {
|
else if (data === this.cfg.arduino.cmd.projector_light_identifier) {
|
||||||
type = 'projector,light';
|
type = 'projector,light';
|
||||||
}
|
}
|
||||||
else if (data === cfg.arduino.cmd.projector_camera_light_identifier) {
|
else if (data === this.cfg.arduino.cmd.projector_camera_light_identifier) {
|
||||||
type = 'projector,camera,light';
|
type = 'projector,camera,light';
|
||||||
}
|
}
|
||||||
else if (data === cfg.arduino.cmd.projector_camera_identifier) {
|
else if (data === this.cfg.arduino.cmd.projector_camera_identifier) {
|
||||||
type = 'projector,camera';
|
type = 'projector,camera';
|
||||||
}
|
}
|
||||||
else if (data === cfg.arduino.cmd.projector_second_identifier) {
|
else if (data === this.cfg.arduino.cmd.projector_second_identifier) {
|
||||||
type = 'projector_second';
|
type = 'projector_second';
|
||||||
}
|
}
|
||||||
else if (data === cfg.arduino.cmd.projectors_identifier) {
|
else if (data === this.cfg.arduino.cmd.projectors_identifier) {
|
||||||
type = 'projector,projector_second';
|
type = 'projector,projector_second';
|
||||||
}
|
}
|
||||||
else if (data === cfg.arduino.cmd.camera_second_identifier) {
|
else if (data === this.cfg.arduino.cmd.camera_second_identifier) {
|
||||||
type = 'camera_second';
|
type = 'camera_second';
|
||||||
}
|
}
|
||||||
else if (data === cfg.arduino.cmd.cameras_identifier) {
|
else if (data === this.cfg.arduino.cmd.cameras_identifier) {
|
||||||
type = 'camera,camera_second';
|
type = 'camera,camera_second';
|
||||||
}
|
}
|
||||||
else if (data === cfg.arduino.cmd.camera_projectors_identifier) {
|
else if (data === this.cfg.arduino.cmd.camera_projectors_identifier) {
|
||||||
type = 'camera,projector,projector_second';
|
type = 'camera,projector,projector_second';
|
||||||
}
|
}
|
||||||
else if (data === cfg.arduino.cmd.cameras_projector_identifier) {
|
else if (data === this.cfg.arduino.cmd.cameras_projector_identifier) {
|
||||||
type = 'camera,camera_second,projector';
|
type = 'camera,camera_second,projector';
|
||||||
}
|
}
|
||||||
else if (data === cfg.arduino.cmd.cameras_projectors_identifier) {
|
else if (data === this.cfg.arduino.cmd.cameras_projectors_identifier) {
|
||||||
type = 'camera,camera_second,projector,projector_second';
|
type = 'camera,camera_second,projector,projector_second';
|
||||||
}
|
}
|
||||||
|
else if (data === this.cfg.arduino.cmd.capper_identifier) {
|
||||||
|
type = 'capper';
|
||||||
|
}
|
||||||
|
else if (data === this.cfg.arduino.cmd.camera_capper_identifier) {
|
||||||
|
type = 'camera,capper';
|
||||||
|
}
|
||||||
|
else if (data === this.cfg.arduino.cmd.camera_capper_projector_identifier) {
|
||||||
|
type = 'camera,capper,projector';
|
||||||
|
}
|
||||||
|
else if (data === this.cfg.arduino.cmd.camera_capper_projectors_identifier) {
|
||||||
|
type = 'camera,capper,projector,projector_second';
|
||||||
|
}
|
||||||
return resolve(type);
|
return resolve(type);
|
||||||
};
|
};
|
||||||
await delay_1.delay(cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
try {
|
try {
|
||||||
writeSuccess = await this.sendAsync(device, cfg.arduino.cmd.mcopy_identifier);
|
writeSuccess = await this.sendAsync(device, this.cfg.arduino.cmd.mcopy_identifier);
|
||||||
|
this.log.info(writeSuccess);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
return reject(e);
|
return reject(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Closes the connection to an Arduino.
|
||||||
|
*
|
||||||
|
* @async
|
||||||
|
* @returns {Promise<boolean>} Resolves with 'true' if the connection is closed successfully.
|
||||||
|
* @throws {Error} Throws an error if the closeArduino method encounters an error.
|
||||||
|
**/
|
||||||
async close() {
|
async close() {
|
||||||
const device = this.alias['connect'];
|
const device = 'connect';
|
||||||
let closeSuccess;
|
let closeSuccess;
|
||||||
try {
|
try {
|
||||||
closeSuccess = await this.closeArduino(device);
|
closeSuccess = await this.closeArduino(device);
|
||||||
|
@ -335,31 +510,40 @@ class Arduino {
|
||||||
}
|
}
|
||||||
return closeSuccess;
|
return closeSuccess;
|
||||||
}
|
}
|
||||||
;
|
/**
|
||||||
async fakeConnect(serial) {
|
* Establishes a fake connection to an Arduino for testing purposes.
|
||||||
const device = '/dev/fake';
|
* Creates a fake SerialPort instance with custom write and string methods.
|
||||||
this.alias[serial] = device;
|
*
|
||||||
this.serial[device] = {
|
* @async
|
||||||
|
* @param {string} serial - The device identifier of the fake Arduino.
|
||||||
|
* @returns {Promise<boolean>} Resolves with 'true' if the fake connection is established successfully.
|
||||||
|
**/
|
||||||
|
async fakeConnect(device) {
|
||||||
|
const serial = '/dev/fake';
|
||||||
|
this.aliasSerial(device, serial);
|
||||||
|
this.serial[serial] = {
|
||||||
write: async function (cmd, cb) {
|
write: async function (cmd, cb) {
|
||||||
const t = {
|
const t = {
|
||||||
c: cfg.arduino.cam.time + cfg.arduino.cam.delay,
|
c: this.cfg.arduino.cam.time + this.cfg.arduino.cam.delay,
|
||||||
p: cfg.arduino.proj.time + cfg.arduino.proj.delay
|
p: this.cfg.arduino.proj.time + this.cfg.arduino.proj.delay,
|
||||||
|
A: 180,
|
||||||
|
B: 180
|
||||||
};
|
};
|
||||||
let timeout = t[cmd];
|
let timeout = t[cmd];
|
||||||
if (typeof timeout === 'undefined')
|
if (typeof timeout === 'undefined')
|
||||||
timeout = 10;
|
timeout = 10;
|
||||||
arduino.timer = +new Date();
|
this.timer = +new Date();
|
||||||
await delay_1.delay(timeout);
|
await (0, delay_1.delay)(timeout);
|
||||||
arduino.end(serial, cmd);
|
this.end(serial, cmd);
|
||||||
return cb();
|
return cb();
|
||||||
},
|
}.bind(this),
|
||||||
string: async function (str) {
|
string: async function (str) {
|
||||||
//do nothing
|
//do nothing
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
fake: true
|
fake: true
|
||||||
};
|
};
|
||||||
//console.log('Connected to fake arduino! Not real! Does not exist!');
|
//this.log.info('Connected to fake arduino! Not real! Does not exist!')
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -371,7 +555,7 @@ class Arduino {
|
||||||
**/
|
**/
|
||||||
async openArduino(device) {
|
async openArduino(device) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
return this.serial[device].open((err) => {
|
return this.serial[this.alias[device]].open((err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return reject(err);
|
return reject(err);
|
||||||
}
|
}
|
||||||
|
@ -388,7 +572,7 @@ class Arduino {
|
||||||
**/
|
**/
|
||||||
async closeArduino(device) {
|
async closeArduino(device) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
return this.serial[device].close((err) => {
|
return this.serial[this.alias[device]].close((err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return reject(err);
|
return reject(err);
|
||||||
}
|
}
|
||||||
|
@ -396,13 +580,18 @@ class Arduino {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
lock(serial) {
|
||||||
|
//this.log.info(`Locked serial ${serial}`)
|
||||||
|
this.locks[serial] = true;
|
||||||
|
}
|
||||||
|
unlock(serial) {
|
||||||
|
//this.log.info(`Unlocked serial ${serial}`)
|
||||||
|
this.locks[serial] = false;
|
||||||
|
}
|
||||||
|
isLocked(serial) {
|
||||||
|
return typeof this.locks[serial] !== 'undefined' && this.locks[serial] === true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (typeof module !== 'undefined' && module.parent) {
|
exports.Arduino = Arduino;
|
||||||
module.exports = function (c, ee, errorState) {
|
module.exports = { Arduino };
|
||||||
eventEmitter = ee;
|
|
||||||
cfg = c;
|
|
||||||
arduino = new Arduino(errorState);
|
|
||||||
return arduino;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=index.js.map
|
//# sourceMappingURL=index.js.map
|
File diff suppressed because one or more lines are too long
|
@ -1,49 +1,76 @@
|
||||||
<a name="Camera"></a>
|
<a name="module_lib/cam"></a>
|
||||||
|
|
||||||
## Camera
|
## lib/cam
|
||||||
class representing camera functions
|
|
||||||
|
|
||||||
**Kind**: global class
|
* [lib/cam](#module_lib/cam)
|
||||||
|
* [~Camera](#module_lib/cam..Camera)
|
||||||
|
* [.init()](#module_lib/cam..Camera+init)
|
||||||
|
* [.listen()](#module_lib/cam..Camera+listen)
|
||||||
|
* [.set()](#module_lib/cam..Camera+set)
|
||||||
|
* [.cap()](#module_lib/cam..Camera+cap)
|
||||||
|
* [.move()](#module_lib/cam..Camera+move)
|
||||||
|
* [.exposure()](#module_lib/cam..Camera+exposure)
|
||||||
|
* [.connectIntval()](#module_lib/cam..Camera+connectIntval)
|
||||||
|
* [.connectProcessing()](#module_lib/cam..Camera+connectProcessing)
|
||||||
|
* [.listener()](#module_lib/cam..Camera+listener)
|
||||||
|
* [.end()](#module_lib/cam..Camera+end)
|
||||||
|
|
||||||
* [Camera](#Camera)
|
<a name="module_lib/cam..Camera"></a>
|
||||||
* [.init()](#Camera+init)
|
|
||||||
* [.listen()](#Camera+listen)
|
|
||||||
* [.set()](#Camera+set)
|
|
||||||
* [.move()](#Camera+move)
|
|
||||||
* [.exposure()](#Camera+exposure)
|
|
||||||
* [.connectIntval()](#Camera+connectIntval)
|
|
||||||
* [.listener()](#Camera+listener)
|
|
||||||
* [.end()](#Camera+end)
|
|
||||||
|
|
||||||
<a name="Camera+init"></a>
|
### lib/cam~Camera
|
||||||
|
Class representing camera functions.
|
||||||
|
|
||||||
### camera.init()
|
**Kind**: inner class of [<code>lib/cam</code>](#module_lib/cam)
|
||||||
**Kind**: instance method of [<code>Camera</code>](#Camera)
|
|
||||||
<a name="Camera+listen"></a>
|
|
||||||
|
|
||||||
### camera.listen()
|
* [~Camera](#module_lib/cam..Camera)
|
||||||
**Kind**: instance method of [<code>Camera</code>](#Camera)
|
* [.init()](#module_lib/cam..Camera+init)
|
||||||
<a name="Camera+set"></a>
|
* [.listen()](#module_lib/cam..Camera+listen)
|
||||||
|
* [.set()](#module_lib/cam..Camera+set)
|
||||||
|
* [.cap()](#module_lib/cam..Camera+cap)
|
||||||
|
* [.move()](#module_lib/cam..Camera+move)
|
||||||
|
* [.exposure()](#module_lib/cam..Camera+exposure)
|
||||||
|
* [.connectIntval()](#module_lib/cam..Camera+connectIntval)
|
||||||
|
* [.connectProcessing()](#module_lib/cam..Camera+connectProcessing)
|
||||||
|
* [.listener()](#module_lib/cam..Camera+listener)
|
||||||
|
* [.end()](#module_lib/cam..Camera+end)
|
||||||
|
|
||||||
### camera.set()
|
<a name="module_lib/cam..Camera+init"></a>
|
||||||
**Kind**: instance method of [<code>Camera</code>](#Camera)
|
|
||||||
<a name="Camera+move"></a>
|
|
||||||
|
|
||||||
### camera.move()
|
#### camera.init()
|
||||||
**Kind**: instance method of [<code>Camera</code>](#Camera)
|
**Kind**: instance method of [<code>Camera</code>](#module_lib/cam..Camera)
|
||||||
<a name="Camera+exposure"></a>
|
<a name="module_lib/cam..Camera+listen"></a>
|
||||||
|
|
||||||
### camera.exposure()
|
#### camera.listen()
|
||||||
**Kind**: instance method of [<code>Camera</code>](#Camera)
|
**Kind**: instance method of [<code>Camera</code>](#module_lib/cam..Camera)
|
||||||
<a name="Camera+connectIntval"></a>
|
<a name="module_lib/cam..Camera+set"></a>
|
||||||
|
|
||||||
### camera.connectIntval()
|
#### camera.set()
|
||||||
**Kind**: instance method of [<code>Camera</code>](#Camera)
|
**Kind**: instance method of [<code>Camera</code>](#module_lib/cam..Camera)
|
||||||
<a name="Camera+listener"></a>
|
<a name="module_lib/cam..Camera+cap"></a>
|
||||||
|
|
||||||
### camera.listener()
|
#### camera.cap()
|
||||||
**Kind**: instance method of [<code>Camera</code>](#Camera)
|
**Kind**: instance method of [<code>Camera</code>](#module_lib/cam..Camera)
|
||||||
<a name="Camera+end"></a>
|
<a name="module_lib/cam..Camera+move"></a>
|
||||||
|
|
||||||
### camera.end()
|
#### camera.move()
|
||||||
**Kind**: instance method of [<code>Camera</code>](#Camera)
|
**Kind**: instance method of [<code>Camera</code>](#module_lib/cam..Camera)
|
||||||
|
<a name="module_lib/cam..Camera+exposure"></a>
|
||||||
|
|
||||||
|
#### camera.exposure()
|
||||||
|
**Kind**: instance method of [<code>Camera</code>](#module_lib/cam..Camera)
|
||||||
|
<a name="module_lib/cam..Camera+connectIntval"></a>
|
||||||
|
|
||||||
|
#### camera.connectIntval()
|
||||||
|
**Kind**: instance method of [<code>Camera</code>](#module_lib/cam..Camera)
|
||||||
|
<a name="module_lib/cam..Camera+connectProcessing"></a>
|
||||||
|
|
||||||
|
#### camera.connectProcessing()
|
||||||
|
**Kind**: instance method of [<code>Camera</code>](#module_lib/cam..Camera)
|
||||||
|
<a name="module_lib/cam..Camera+listener"></a>
|
||||||
|
|
||||||
|
#### camera.listener()
|
||||||
|
**Kind**: instance method of [<code>Camera</code>](#module_lib/cam..Camera)
|
||||||
|
<a name="module_lib/cam..Camera+end"></a>
|
||||||
|
|
||||||
|
#### camera.end()
|
||||||
|
**Kind**: instance method of [<code>Camera</code>](#module_lib/cam..Camera)
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
import type { Arduino } from 'arduino';
|
||||||
|
import type { FilmOut } from 'filmout';
|
||||||
|
import type { Config } from 'cfg';
|
||||||
|
import type { WebContents } from 'electron';
|
||||||
|
interface CameraState {
|
||||||
|
pos: number;
|
||||||
|
dir: boolean;
|
||||||
|
capper: boolean;
|
||||||
|
}
|
||||||
|
/** @module lib/cam */
|
||||||
|
/**
|
||||||
|
* Class representing camera functions.
|
||||||
|
*/
|
||||||
|
export declare class Camera {
|
||||||
|
state: CameraState;
|
||||||
|
arduino: Arduino;
|
||||||
|
private intval;
|
||||||
|
private processing;
|
||||||
|
private log;
|
||||||
|
private cfg;
|
||||||
|
private filmout;
|
||||||
|
private ui;
|
||||||
|
private ipc;
|
||||||
|
private id;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
constructor(arduino: Arduino, cfg: Config, ui: WebContents, filmout: FilmOut, second?: boolean);
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private init;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private listen;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
set(dir: boolean, id: string): Promise<number>;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
cap(state: boolean, id: string): Promise<number>;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
move(id: string): Promise<number>;
|
||||||
|
both(id: string): Promise<number>;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
exposure(exposure: number, id: string): Promise<number>;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private connectIntval;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private connectProcessing;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private listener;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private end;
|
||||||
|
}
|
||||||
|
export {};
|
|
@ -1,7 +1,15 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.Camera = void 0;
|
||||||
|
const electron_1 = require("electron");
|
||||||
const intval_1 = require("intval");
|
const intval_1 = require("intval");
|
||||||
/** class representing camera functions **/
|
const processing_1 = require("processing");
|
||||||
|
const delay_1 = require("delay");
|
||||||
|
const log_1 = require("log");
|
||||||
|
/** @module lib/cam */
|
||||||
|
/**
|
||||||
|
* Class representing camera functions.
|
||||||
|
*/
|
||||||
class Camera {
|
class Camera {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -9,10 +17,13 @@ class Camera {
|
||||||
constructor(arduino, cfg, ui, filmout, second = false) {
|
constructor(arduino, cfg, ui, filmout, second = false) {
|
||||||
this.state = {
|
this.state = {
|
||||||
pos: 0,
|
pos: 0,
|
||||||
dir: true
|
dir: true,
|
||||||
|
capper: false
|
||||||
};
|
};
|
||||||
this.arduino = null;
|
this.arduino = null;
|
||||||
this.intval = null;
|
this.intval = null;
|
||||||
|
this.processing = null;
|
||||||
|
this.ipc = electron_1.ipcMain;
|
||||||
this.id = 'camera';
|
this.id = 'camera';
|
||||||
this.arduino = arduino;
|
this.arduino = arduino;
|
||||||
this.cfg = cfg;
|
this.cfg = cfg;
|
||||||
|
@ -26,9 +37,7 @@ class Camera {
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
async init() {
|
async init() {
|
||||||
const Log = require('log');
|
this.log = await (0, log_1.Log)({ label: this.id });
|
||||||
this.log = await Log({ label: this.id });
|
|
||||||
this.ipc = require('electron').ipcMain;
|
|
||||||
this.listen();
|
this.listen();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -37,6 +46,7 @@ class Camera {
|
||||||
listen() {
|
listen() {
|
||||||
this.ipc.on(this.id, this.listener.bind(this));
|
this.ipc.on(this.id, this.listener.bind(this));
|
||||||
this.ipc.on('intval', this.connectIntval.bind(this));
|
this.ipc.on('intval', this.connectIntval.bind(this));
|
||||||
|
this.ipc.on('processing', this.connectProcessing.bind(this));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -51,7 +61,15 @@ class Camera {
|
||||||
cmd = this.cfg.arduino.cmd[`${this.id}_backward`];
|
cmd = this.cfg.arduino.cmd[`${this.id}_backward`];
|
||||||
}
|
}
|
||||||
this.state.dir = dir;
|
this.state.dir = dir;
|
||||||
if (this.intval) {
|
if (this.processing) {
|
||||||
|
try {
|
||||||
|
ms = await this.processing.setDir(dir);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.log.error(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (this.intval) {
|
||||||
try {
|
try {
|
||||||
ms = await this.intval.setDir(dir);
|
ms = await this.intval.setDir(dir);
|
||||||
}
|
}
|
||||||
|
@ -72,18 +90,47 @@ class Camera {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
async move(frame, id) {
|
async cap(state, id) {
|
||||||
|
let cmd;
|
||||||
|
let ms;
|
||||||
|
if (state) {
|
||||||
|
cmd = this.cfg.arduino.cmd[`${this.id}_forward`];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cmd = this.cfg.arduino.cmd[`${this.id}_backward`];
|
||||||
|
}
|
||||||
|
this.state.capper = state;
|
||||||
|
try {
|
||||||
|
ms = await this.arduino.send(this.id, cmd);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.log.error(err);
|
||||||
|
}
|
||||||
|
return await this.end(cmd, id, ms);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
async move(id) {
|
||||||
const cmd = this.cfg.arduino.cmd[this.id];
|
const cmd = this.cfg.arduino.cmd[this.id];
|
||||||
let ms;
|
let ms;
|
||||||
if (this.filmout.state.enabled) {
|
if (this.filmout.state.enabled) {
|
||||||
await this.filmout.start();
|
await this.filmout.start();
|
||||||
}
|
}
|
||||||
if (this.intval) {
|
if (this.processing) {
|
||||||
|
try {
|
||||||
|
ms = await this.processing.move();
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.log.error(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (this.intval) {
|
||||||
try {
|
try {
|
||||||
ms = await this.intval.move();
|
ms = await this.intval.move();
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error(err);
|
this.log.error(`Error moving intval ${this.id}: ${id}`, err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -101,14 +148,14 @@ class Camera {
|
||||||
//this.log.info('Camera move time', { ms });
|
//this.log.info('Camera move time', { ms });
|
||||||
return this.end(cmd, id, ms);
|
return this.end(cmd, id, ms);
|
||||||
}
|
}
|
||||||
async both(frame, id) {
|
async both(id) {
|
||||||
const cmd = this.cfg.arduino.cmd[id];
|
const cmd = this.cfg.arduino.cmd[id];
|
||||||
let ms;
|
let ms;
|
||||||
try {
|
try {
|
||||||
ms = await this.arduino.send(this.id, cmd);
|
ms = await this.arduino.send(this.id, cmd);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error(`Error moving ${this.id}`, err);
|
this.log.error(`Error moving both ${this.id}: ${id}`, err);
|
||||||
}
|
}
|
||||||
//this.log.info('Cameras move time', { ms });
|
//this.log.info('Cameras move time', { ms });
|
||||||
return await this.end(cmd, id, ms);
|
return await this.end(cmd, id, ms);
|
||||||
|
@ -116,11 +163,55 @@ class Camera {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
exposure(exposure, id) {
|
async exposure(exposure, id) {
|
||||||
let cmd = 'E';
|
const cmd = this.cfg.arduino.cmd.camera_exposure;
|
||||||
this.intval.setExposure(this.id, exposure, (ms) => {
|
const str = `${exposure}`;
|
||||||
this.end(cmd, id, ms);
|
const started = +new Date();
|
||||||
});
|
let ms;
|
||||||
|
let confirmState;
|
||||||
|
let parts;
|
||||||
|
let confirmExposure;
|
||||||
|
if (this.intval) {
|
||||||
|
return this.intval.setExposure(exposure, (ms) => {
|
||||||
|
this.ui.send('timing', { c: 'c', ms: exposure });
|
||||||
|
return this.end(cmd, id, ms);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (this.arduino.hasState[this.id]) {
|
||||||
|
try {
|
||||||
|
ms = this.arduino.send(this.id, cmd);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.log.error('Error sending camera exposure command', err);
|
||||||
|
}
|
||||||
|
await (0, delay_1.delay)(1);
|
||||||
|
try {
|
||||||
|
ms = await this.arduino.sendString(this.id, str);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.log.error('Error sending camera exposure string', err);
|
||||||
|
}
|
||||||
|
await ms;
|
||||||
|
await (0, delay_1.delay)(1);
|
||||||
|
try {
|
||||||
|
confirmState = await this.arduino.state(this.id, false);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.log.error(`Error confirming set state`, err);
|
||||||
|
}
|
||||||
|
parts = this.arduino.stateStr[this.id].split('G');
|
||||||
|
if (parts.length > 1) {
|
||||||
|
parts = parts[1].split('H');
|
||||||
|
confirmExposure = parseInt(parts[0]);
|
||||||
|
if (!isNaN(confirmExposure)) {
|
||||||
|
this.log.info(`Exposure successfully set to ${confirmExposure}ms`);
|
||||||
|
this.ui.send('timing', { c: 'c', ms: exposure });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ms = (+new Date()) - started;
|
||||||
|
return await this.end(cmd, id, ms);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -129,6 +220,7 @@ class Camera {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (arg.connect) {
|
if (arg.connect) {
|
||||||
this.intval = new intval_1.Intval(arg.url);
|
this.intval = new intval_1.Intval(arg.url);
|
||||||
|
this.processing = null;
|
||||||
this.intval.connect((err, ms, state) => {
|
this.intval.connect((err, ms, state) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
this.ui.send('intval', { connected: false });
|
this.ui.send('intval', { connected: false });
|
||||||
|
@ -148,6 +240,17 @@ class Camera {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
async connectProcessing(event, arg) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
this.processing = new processing_1.Processing(arg.url);
|
||||||
|
this.intval = null;
|
||||||
|
this.ui.send('processing', { connected: true, url: arg.url });
|
||||||
|
return resolve(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
@ -160,9 +263,9 @@ class Camera {
|
||||||
this.log.error(err);
|
this.log.error(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (typeof arg.frame !== 'undefined') {
|
else if (typeof arg.move !== 'undefined') {
|
||||||
try {
|
try {
|
||||||
await this.move(arg.frame, arg.id);
|
await this.move(arg.id);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error(err);
|
this.log.error(err);
|
||||||
|
@ -171,6 +274,22 @@ class Camera {
|
||||||
else if (typeof arg.val !== 'undefined') {
|
else if (typeof arg.val !== 'undefined') {
|
||||||
this.state.pos = arg.val;
|
this.state.pos = arg.val;
|
||||||
}
|
}
|
||||||
|
else if (typeof arg.capper !== 'undefined') {
|
||||||
|
try {
|
||||||
|
await this.cap(arg.capper, arg.id);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.log.error(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (typeof arg.exposure !== 'undefined') {
|
||||||
|
try {
|
||||||
|
await this.exposure(arg.exposure, arg.id);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.log.error(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
event.returnValue = true;
|
event.returnValue = true;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -213,12 +332,15 @@ class Camera {
|
||||||
else if (cmd === this.cfg.arduino.cmd.camerass) {
|
else if (cmd === this.cfg.arduino.cmd.camerass) {
|
||||||
message += 'Cameras both MOVED 1 frame each';
|
message += 'Cameras both MOVED 1 frame each';
|
||||||
}
|
}
|
||||||
|
else if (cmd === this.cfg.arduino.camera_exposure) {
|
||||||
|
message += 'Camera set exposure';
|
||||||
|
}
|
||||||
message += ` ${ms}ms`;
|
message += ` ${ms}ms`;
|
||||||
this.log.info(message);
|
this.log.info(message);
|
||||||
this.ui.send(this.id, { cmd: cmd, id: id, ms: ms });
|
await this.ui.send(this.id, { cmd: cmd, id: id, ms: ms });
|
||||||
|
return ms;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.exports = function (arduino, cfg, ui, filmout, second) {
|
exports.Camera = Camera;
|
||||||
return new Camera(arduino, cfg, ui, filmout, second);
|
module.exports = { Camera };
|
||||||
};
|
|
||||||
//# sourceMappingURL=index.js.map
|
//# sourceMappingURL=index.js.map
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,46 @@
|
||||||
|
<a name="module_lib/capper"></a>
|
||||||
|
|
||||||
|
## lib/capper
|
||||||
|
|
||||||
|
* [lib/capper](#module_lib/capper)
|
||||||
|
* [~Capper](#module_lib/capper..Capper)
|
||||||
|
* [.init()](#module_lib/capper..Capper+init)
|
||||||
|
* [.listen()](#module_lib/capper..Capper+listen)
|
||||||
|
* [.capper()](#module_lib/capper..Capper+capper)
|
||||||
|
* [.listener()](#module_lib/capper..Capper+listener)
|
||||||
|
* [.end()](#module_lib/capper..Capper+end)
|
||||||
|
|
||||||
|
<a name="module_lib/capper..Capper"></a>
|
||||||
|
|
||||||
|
### lib/capper~Capper
|
||||||
|
Class representing capper functions.
|
||||||
|
|
||||||
|
**Kind**: inner class of [<code>lib/capper</code>](#module_lib/capper)
|
||||||
|
|
||||||
|
* [~Capper](#module_lib/capper..Capper)
|
||||||
|
* [.init()](#module_lib/capper..Capper+init)
|
||||||
|
* [.listen()](#module_lib/capper..Capper+listen)
|
||||||
|
* [.capper()](#module_lib/capper..Capper+capper)
|
||||||
|
* [.listener()](#module_lib/capper..Capper+listener)
|
||||||
|
* [.end()](#module_lib/capper..Capper+end)
|
||||||
|
|
||||||
|
<a name="module_lib/capper..Capper+init"></a>
|
||||||
|
|
||||||
|
#### capper.init()
|
||||||
|
**Kind**: instance method of [<code>Capper</code>](#module_lib/capper..Capper)
|
||||||
|
<a name="module_lib/capper..Capper+listen"></a>
|
||||||
|
|
||||||
|
#### capper.listen()
|
||||||
|
**Kind**: instance method of [<code>Capper</code>](#module_lib/capper..Capper)
|
||||||
|
<a name="module_lib/capper..Capper+capper"></a>
|
||||||
|
|
||||||
|
#### capper.capper()
|
||||||
|
**Kind**: instance method of [<code>Capper</code>](#module_lib/capper..Capper)
|
||||||
|
<a name="module_lib/capper..Capper+listener"></a>
|
||||||
|
|
||||||
|
#### capper.listener()
|
||||||
|
**Kind**: instance method of [<code>Capper</code>](#module_lib/capper..Capper)
|
||||||
|
<a name="module_lib/capper..Capper+end"></a>
|
||||||
|
|
||||||
|
#### capper.end()
|
||||||
|
**Kind**: instance method of [<code>Capper</code>](#module_lib/capper..Capper)
|
|
@ -0,0 +1,45 @@
|
||||||
|
import type { FilmOut } from 'filmout';
|
||||||
|
import type { Arduino } from 'arduino';
|
||||||
|
import type { WebContents } from 'electron';
|
||||||
|
interface CapperState {
|
||||||
|
capper: boolean;
|
||||||
|
}
|
||||||
|
/** @module lib/capper */
|
||||||
|
/**
|
||||||
|
* Class representing capper functions.
|
||||||
|
*/
|
||||||
|
export declare class Capper {
|
||||||
|
private state;
|
||||||
|
private arduino;
|
||||||
|
private log;
|
||||||
|
private cfg;
|
||||||
|
private filmout;
|
||||||
|
private ui;
|
||||||
|
private ipc;
|
||||||
|
private id;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
constructor(arduino: Arduino, cfg: any, ui: WebContents, filmout: FilmOut);
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private init;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private listen;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
capper(state: boolean, id: string): Promise<number>;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private listener;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private end;
|
||||||
|
}
|
||||||
|
export type { CapperState };
|
|
@ -0,0 +1,94 @@
|
||||||
|
'use strict';
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.Capper = void 0;
|
||||||
|
const electron_1 = require("electron");
|
||||||
|
const log_1 = require("log");
|
||||||
|
/** @module lib/capper */
|
||||||
|
/**
|
||||||
|
* Class representing capper functions.
|
||||||
|
*/
|
||||||
|
class Capper {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
constructor(arduino, cfg, ui, filmout) {
|
||||||
|
this.state = {
|
||||||
|
capper: false
|
||||||
|
};
|
||||||
|
this.arduino = null;
|
||||||
|
this.ipc = electron_1.ipcMain;
|
||||||
|
this.id = 'capper';
|
||||||
|
this.arduino = arduino;
|
||||||
|
this.cfg = cfg;
|
||||||
|
this.ui = ui;
|
||||||
|
this.filmout = filmout;
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
async init() {
|
||||||
|
this.log = await (0, log_1.Log)({ label: this.id });
|
||||||
|
this.listen();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
listen() {
|
||||||
|
this.ipc.on(this.id, this.listener.bind(this));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
async capper(state, id) {
|
||||||
|
let cmd;
|
||||||
|
let ms;
|
||||||
|
if (state) {
|
||||||
|
cmd = this.cfg.arduino.cmd[`${this.id}_on`];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cmd = this.cfg.arduino.cmd[`${this.id}_off`];
|
||||||
|
}
|
||||||
|
this.state.capper = state;
|
||||||
|
try {
|
||||||
|
ms = await this.arduino.send(this.id, cmd);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.log.error(err);
|
||||||
|
}
|
||||||
|
return await this.end(cmd, id, ms);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
async listener(event, arg) {
|
||||||
|
if (typeof arg.state !== 'undefined') {
|
||||||
|
try {
|
||||||
|
await this.capper(arg.state, arg.id);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.log.error(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
event.returnValue = true;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
async end(cmd, id, ms) {
|
||||||
|
let message = '';
|
||||||
|
if (cmd === this.cfg.arduino.cmd.capper_on) {
|
||||||
|
message = 'Capper set to ON';
|
||||||
|
}
|
||||||
|
else if (cmd === this.cfg.arduino.cmd.capper_off) {
|
||||||
|
message = 'Capper set to OFF';
|
||||||
|
}
|
||||||
|
message += ` ${ms}ms`;
|
||||||
|
this.log.info(message);
|
||||||
|
await this.ui.send(this.id, { cmd: cmd, id: id, ms: ms });
|
||||||
|
return ms;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.Capper = Capper;
|
||||||
|
module.exports = { Capper };
|
||||||
|
//# sourceMappingURL=index.js.map
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/capper/index.ts"],"names":[],"mappings":"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"}
|
|
@ -0,0 +1,30 @@
|
||||||
|
interface ConfigCommands {
|
||||||
|
[key: string]: string;
|
||||||
|
}
|
||||||
|
interface ConfigDeviceProfile {
|
||||||
|
time: number;
|
||||||
|
delay: number;
|
||||||
|
momentary: number;
|
||||||
|
}
|
||||||
|
interface ConfigBlackProfile {
|
||||||
|
before: number;
|
||||||
|
after: number;
|
||||||
|
}
|
||||||
|
interface ConfigProfile {
|
||||||
|
label: string;
|
||||||
|
cam: ConfigDeviceProfile;
|
||||||
|
proj?: ConfigDeviceProfile;
|
||||||
|
black?: ConfigBlackProfile;
|
||||||
|
light: boolean;
|
||||||
|
}
|
||||||
|
interface ConfigProfiles {
|
||||||
|
[key: string]: ConfigProfile;
|
||||||
|
}
|
||||||
|
interface Config {
|
||||||
|
version: string;
|
||||||
|
ext_port: number;
|
||||||
|
profiles: ConfigProfiles;
|
||||||
|
cmd: ConfigCommands;
|
||||||
|
arduino: any;
|
||||||
|
}
|
||||||
|
export type { Config };
|
|
@ -0,0 +1,3 @@
|
||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
//# sourceMappingURL=index.js.map
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cfg/index.ts"],"names":[],"mappings":""}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,267 @@
|
||||||
|
<a name="module_lib/cmd"></a>
|
||||||
|
|
||||||
|
## lib/cmd
|
||||||
|
|
||||||
|
* [lib/cmd](#module_lib/cmd)
|
||||||
|
* [~Assign all connected devices and mock devices as private classes.](#module_lib/cmd..Assign all connected devices and mock devices as private classes.)
|
||||||
|
* [new Assign all connected devices and mock devices as private classes.(cfg, proj, cam, light, alert, cam2, proj2, capper)](#new_module_lib/cmd..Assign all connected devices and mock devices as private classes._new)
|
||||||
|
* [~Commands](#module_lib/cmd..Commands)
|
||||||
|
* [.projector_forward()](#module_lib/cmd..Commands+projector_forward) ⇒ <code>integer</code>
|
||||||
|
* [.projector_backward()](#module_lib/cmd..Commands+projector_backward) ⇒ <code>integer</code>
|
||||||
|
* [.camera_forward(cmd)](#module_lib/cmd..Commands+camera_forward) ⇒ <code>integer</code>
|
||||||
|
* [.black_forward()](#module_lib/cmd..Commands+black_forward) ⇒ <code>integer</code>
|
||||||
|
* [.camera_backward(cmd)](#module_lib/cmd..Commands+camera_backward) ⇒ <code>integer</code>
|
||||||
|
* [.black_backward()](#module_lib/cmd..Commands+black_backward) ⇒ <code>integer</code>
|
||||||
|
* [.camera_second_forward(cmd)](#module_lib/cmd..Commands+camera_second_forward) ⇒ <code>integer</code>
|
||||||
|
* [.camera_second_backward(cmd)](#module_lib/cmd..Commands+camera_second_backward) ⇒ <code>integer</code>
|
||||||
|
* [.cameras_forward(cmd)](#module_lib/cmd..Commands+cameras_forward) ⇒ <code>integer</code>
|
||||||
|
* [.cameras_backward(cmd)](#module_lib/cmd..Commands+cameras_backward) ⇒ <code>integer</code>
|
||||||
|
* [.camera_forward_camera_second_backward(cmd)](#module_lib/cmd..Commands+camera_forward_camera_second_backward) ⇒ <code>integer</code>
|
||||||
|
* [.camera_backward_camera_second_forward(cmd)](#module_lib/cmd..Commands+camera_backward_camera_second_forward) ⇒ <code>integer</code>
|
||||||
|
* [.projector_second_forward()](#module_lib/cmd..Commands+projector_second_forward) ⇒ <code>integer</code>
|
||||||
|
* [.projector_second_backward()](#module_lib/cmd..Commands+projector_second_backward) ⇒ <code>integer</code>
|
||||||
|
* [.projectors_forward()](#module_lib/cmd..Commands+projectors_forward) ⇒ <code>integer</code>
|
||||||
|
* [.projectors_backward()](#module_lib/cmd..Commands+projectors_backward) ⇒ <code>integer</code>
|
||||||
|
* [.projector_forward_projector_second_backward()](#module_lib/cmd..Commands+projector_forward_projector_second_backward) ⇒ <code>integer</code>
|
||||||
|
* [.projector_backward_projector_second_forward()](#module_lib/cmd..Commands+projector_backward_projector_second_forward) ⇒ <code>integer</code>
|
||||||
|
* [.alert()](#module_lib/cmd..Commands+alert) ⇒ <code>integer</code>
|
||||||
|
* [.pause()](#module_lib/cmd..Commands+pause) ⇒ <code>integer</code>
|
||||||
|
* [.camera_exposure()](#module_lib/cmd..Commands+camera_exposure)
|
||||||
|
|
||||||
|
<a name="module_lib/cmd..Assign all connected devices and mock devices as private classes."></a>
|
||||||
|
|
||||||
|
### lib/cmd~Assign all connected devices and mock devices as private classes.
|
||||||
|
**Kind**: inner class of [<code>lib/cmd</code>](#module_lib/cmd)
|
||||||
|
<a name="new_module_lib/cmd..Assign all connected devices and mock devices as private classes._new"></a>
|
||||||
|
|
||||||
|
#### new Assign all connected devices and mock devices as private classes.(cfg, proj, cam, light, alert, cam2, proj2, capper)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| cfg | <code>object</code> | Configuration object |
|
||||||
|
| proj | <code>object</code> | Projector 1 |
|
||||||
|
| cam | <code>object</code> | Camera 1 |
|
||||||
|
| light | <code>object</code> | Light source |
|
||||||
|
| alert | <code>object</code> | Alert object |
|
||||||
|
| cam2 | <code>object</code> | (optional) Camera 2 |
|
||||||
|
| proj2 | <code>object</code> | (optional) Projector 2 |
|
||||||
|
| capper | <code>object</code> | Capper object |
|
||||||
|
|
||||||
|
<a name="module_lib/cmd..Commands"></a>
|
||||||
|
|
||||||
|
### lib/cmd~Commands
|
||||||
|
Class representing all commands bundled into methods.
|
||||||
|
|
||||||
|
**Kind**: inner class of [<code>lib/cmd</code>](#module_lib/cmd)
|
||||||
|
|
||||||
|
* [~Commands](#module_lib/cmd..Commands)
|
||||||
|
* [.projector_forward()](#module_lib/cmd..Commands+projector_forward) ⇒ <code>integer</code>
|
||||||
|
* [.projector_backward()](#module_lib/cmd..Commands+projector_backward) ⇒ <code>integer</code>
|
||||||
|
* [.camera_forward(cmd)](#module_lib/cmd..Commands+camera_forward) ⇒ <code>integer</code>
|
||||||
|
* [.black_forward()](#module_lib/cmd..Commands+black_forward) ⇒ <code>integer</code>
|
||||||
|
* [.camera_backward(cmd)](#module_lib/cmd..Commands+camera_backward) ⇒ <code>integer</code>
|
||||||
|
* [.black_backward()](#module_lib/cmd..Commands+black_backward) ⇒ <code>integer</code>
|
||||||
|
* [.camera_second_forward(cmd)](#module_lib/cmd..Commands+camera_second_forward) ⇒ <code>integer</code>
|
||||||
|
* [.camera_second_backward(cmd)](#module_lib/cmd..Commands+camera_second_backward) ⇒ <code>integer</code>
|
||||||
|
* [.cameras_forward(cmd)](#module_lib/cmd..Commands+cameras_forward) ⇒ <code>integer</code>
|
||||||
|
* [.cameras_backward(cmd)](#module_lib/cmd..Commands+cameras_backward) ⇒ <code>integer</code>
|
||||||
|
* [.camera_forward_camera_second_backward(cmd)](#module_lib/cmd..Commands+camera_forward_camera_second_backward) ⇒ <code>integer</code>
|
||||||
|
* [.camera_backward_camera_second_forward(cmd)](#module_lib/cmd..Commands+camera_backward_camera_second_forward) ⇒ <code>integer</code>
|
||||||
|
* [.projector_second_forward()](#module_lib/cmd..Commands+projector_second_forward) ⇒ <code>integer</code>
|
||||||
|
* [.projector_second_backward()](#module_lib/cmd..Commands+projector_second_backward) ⇒ <code>integer</code>
|
||||||
|
* [.projectors_forward()](#module_lib/cmd..Commands+projectors_forward) ⇒ <code>integer</code>
|
||||||
|
* [.projectors_backward()](#module_lib/cmd..Commands+projectors_backward) ⇒ <code>integer</code>
|
||||||
|
* [.projector_forward_projector_second_backward()](#module_lib/cmd..Commands+projector_forward_projector_second_backward) ⇒ <code>integer</code>
|
||||||
|
* [.projector_backward_projector_second_forward()](#module_lib/cmd..Commands+projector_backward_projector_second_forward) ⇒ <code>integer</code>
|
||||||
|
* [.alert()](#module_lib/cmd..Commands+alert) ⇒ <code>integer</code>
|
||||||
|
* [.pause()](#module_lib/cmd..Commands+pause) ⇒ <code>integer</code>
|
||||||
|
* [.camera_exposure()](#module_lib/cmd..Commands+camera_exposure)
|
||||||
|
|
||||||
|
<a name="module_lib/cmd..Commands+projector_forward"></a>
|
||||||
|
|
||||||
|
#### commands.projector\_forward() ⇒ <code>integer</code>
|
||||||
|
Move the projector one frame forward
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Commands</code>](#module_lib/cmd..Commands)
|
||||||
|
**Returns**: <code>integer</code> - Length of action in ms
|
||||||
|
<a name="module_lib/cmd..Commands+projector_backward"></a>
|
||||||
|
|
||||||
|
#### commands.projector\_backward() ⇒ <code>integer</code>
|
||||||
|
Move the projector one frame backward
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Commands</code>](#module_lib/cmd..Commands)
|
||||||
|
**Returns**: <code>integer</code> - Length of action in ms
|
||||||
|
<a name="module_lib/cmd..Commands+camera_forward"></a>
|
||||||
|
|
||||||
|
#### commands.camera\_forward(cmd) ⇒ <code>integer</code>
|
||||||
|
Move the camera one frame forward
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Commands</code>](#module_lib/cmd..Commands)
|
||||||
|
**Returns**: <code>integer</code> - Length of action in ms
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| cmd | <code>object</code> | Full cmd object |
|
||||||
|
|
||||||
|
<a name="module_lib/cmd..Commands+black_forward"></a>
|
||||||
|
|
||||||
|
#### commands.black\_forward() ⇒ <code>integer</code>
|
||||||
|
Move the camera one frame forward with light off
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Commands</code>](#module_lib/cmd..Commands)
|
||||||
|
**Returns**: <code>integer</code> - Length of action in ms
|
||||||
|
<a name="module_lib/cmd..Commands+camera_backward"></a>
|
||||||
|
|
||||||
|
#### commands.camera\_backward(cmd) ⇒ <code>integer</code>
|
||||||
|
Move the camera one frame backward
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Commands</code>](#module_lib/cmd..Commands)
|
||||||
|
**Returns**: <code>integer</code> - Length of action in ms
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| cmd | <code>object</code> | Full cmd object |
|
||||||
|
|
||||||
|
<a name="module_lib/cmd..Commands+black_backward"></a>
|
||||||
|
|
||||||
|
#### commands.black\_backward() ⇒ <code>integer</code>
|
||||||
|
Move the camera one frame forward, light set to black or off
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Commands</code>](#module_lib/cmd..Commands)
|
||||||
|
**Returns**: <code>integer</code> - Length of action in ms
|
||||||
|
<a name="module_lib/cmd..Commands+camera_second_forward"></a>
|
||||||
|
|
||||||
|
#### commands.camera\_second\_forward(cmd) ⇒ <code>integer</code>
|
||||||
|
Move the second camera one frame forward
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Commands</code>](#module_lib/cmd..Commands)
|
||||||
|
**Returns**: <code>integer</code> - Length of action in ms
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| cmd | <code>object</code> | Full cmd object |
|
||||||
|
|
||||||
|
<a name="module_lib/cmd..Commands+camera_second_backward"></a>
|
||||||
|
|
||||||
|
#### commands.camera\_second\_backward(cmd) ⇒ <code>integer</code>
|
||||||
|
Move the second camera one frame backward
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Commands</code>](#module_lib/cmd..Commands)
|
||||||
|
**Returns**: <code>integer</code> - Length of action in ms
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| cmd | <code>object</code> | Full cmd object |
|
||||||
|
|
||||||
|
<a name="module_lib/cmd..Commands+cameras_forward"></a>
|
||||||
|
|
||||||
|
#### commands.cameras\_forward(cmd) ⇒ <code>integer</code>
|
||||||
|
Move the both cameras one frame forward
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Commands</code>](#module_lib/cmd..Commands)
|
||||||
|
**Returns**: <code>integer</code> - Length of action in ms
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| cmd | <code>object</code> | Full cmd object |
|
||||||
|
|
||||||
|
<a name="module_lib/cmd..Commands+cameras_backward"></a>
|
||||||
|
|
||||||
|
#### commands.cameras\_backward(cmd) ⇒ <code>integer</code>
|
||||||
|
Move the both cameras one frame backward
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Commands</code>](#module_lib/cmd..Commands)
|
||||||
|
**Returns**: <code>integer</code> - Length of action in ms
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| cmd | <code>object</code> | Full cmd object |
|
||||||
|
|
||||||
|
<a name="module_lib/cmd..Commands+camera_forward_camera_second_backward"></a>
|
||||||
|
|
||||||
|
#### commands.camera\_forward\_camera\_second\_backward(cmd) ⇒ <code>integer</code>
|
||||||
|
Move first camera one frame forward and rewind secondary camera one frame backward
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Commands</code>](#module_lib/cmd..Commands)
|
||||||
|
**Returns**: <code>integer</code> - Length of action in ms
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| cmd | <code>object</code> | Full cmd object |
|
||||||
|
|
||||||
|
<a name="module_lib/cmd..Commands+camera_backward_camera_second_forward"></a>
|
||||||
|
|
||||||
|
#### commands.camera\_backward\_camera\_second\_forward(cmd) ⇒ <code>integer</code>
|
||||||
|
Rewind first camera one frame backward and move secondary camera one frame forward
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Commands</code>](#module_lib/cmd..Commands)
|
||||||
|
**Returns**: <code>integer</code> - Length of action in ms
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| cmd | <code>object</code> | Full cmd object |
|
||||||
|
|
||||||
|
<a name="module_lib/cmd..Commands+projector_second_forward"></a>
|
||||||
|
|
||||||
|
#### commands.projector\_second\_forward() ⇒ <code>integer</code>
|
||||||
|
Move the secondary projector forward one frame
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Commands</code>](#module_lib/cmd..Commands)
|
||||||
|
**Returns**: <code>integer</code> - Length of action in ms
|
||||||
|
<a name="module_lib/cmd..Commands+projector_second_backward"></a>
|
||||||
|
|
||||||
|
#### commands.projector\_second\_backward() ⇒ <code>integer</code>
|
||||||
|
Rewind the secondary projector backward one frame
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Commands</code>](#module_lib/cmd..Commands)
|
||||||
|
**Returns**: <code>integer</code> - Length of action in ms
|
||||||
|
<a name="module_lib/cmd..Commands+projectors_forward"></a>
|
||||||
|
|
||||||
|
#### commands.projectors\_forward() ⇒ <code>integer</code>
|
||||||
|
Move the both projectors forward one frame
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Commands</code>](#module_lib/cmd..Commands)
|
||||||
|
**Returns**: <code>integer</code> - Length of action in ms
|
||||||
|
<a name="module_lib/cmd..Commands+projectors_backward"></a>
|
||||||
|
|
||||||
|
#### commands.projectors\_backward() ⇒ <code>integer</code>
|
||||||
|
Rewind both projectors backwards one frame
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Commands</code>](#module_lib/cmd..Commands)
|
||||||
|
**Returns**: <code>integer</code> - Length of action in ms
|
||||||
|
<a name="module_lib/cmd..Commands+projector_forward_projector_second_backward"></a>
|
||||||
|
|
||||||
|
#### commands.projector\_forward\_projector\_second\_backward() ⇒ <code>integer</code>
|
||||||
|
Move the primary projector forward one frame and rewind the secondary projector
|
||||||
|
one frame backwards.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Commands</code>](#module_lib/cmd..Commands)
|
||||||
|
**Returns**: <code>integer</code> - Length of action in ms
|
||||||
|
<a name="module_lib/cmd..Commands+projector_backward_projector_second_forward"></a>
|
||||||
|
|
||||||
|
#### commands.projector\_backward\_projector\_second\_forward() ⇒ <code>integer</code>
|
||||||
|
Rewind the primary projector backwards one frame and move the secondary
|
||||||
|
projector forward one frame.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Commands</code>](#module_lib/cmd..Commands)
|
||||||
|
**Returns**: <code>integer</code> - Length of action in ms
|
||||||
|
<a name="module_lib/cmd..Commands+alert"></a>
|
||||||
|
|
||||||
|
#### commands.alert() ⇒ <code>integer</code>
|
||||||
|
Throws an alert to pause a sequence
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Commands</code>](#module_lib/cmd..Commands)
|
||||||
|
**Returns**: <code>integer</code> - Length of action in ms
|
||||||
|
<a name="module_lib/cmd..Commands+pause"></a>
|
||||||
|
|
||||||
|
#### commands.pause() ⇒ <code>integer</code>
|
||||||
|
Pauses a sequence for a length of time
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Commands</code>](#module_lib/cmd..Commands)
|
||||||
|
**Returns**: <code>integer</code> - Length of action in ms
|
||||||
|
<a name="module_lib/cmd..Commands+camera_exposure"></a>
|
||||||
|
|
||||||
|
#### commands.camera\_exposure()
|
||||||
|
Sets the camera exposure (if supported).
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Commands</code>](#module_lib/cmd..Commands)
|
|
@ -0,0 +1,179 @@
|
||||||
|
import type { Projector } from 'proj';
|
||||||
|
import type { Camera } from 'cam';
|
||||||
|
import type { Light } from 'light';
|
||||||
|
import type { Capper } from 'capper';
|
||||||
|
import type { Alert } from 'alert';
|
||||||
|
import type { Config } from 'cfg';
|
||||||
|
/** @module lib/cmd */
|
||||||
|
/**
|
||||||
|
* Class representing all commands bundled into methods.
|
||||||
|
*/
|
||||||
|
export declare class Commands {
|
||||||
|
proj: Projector;
|
||||||
|
cam: Camera;
|
||||||
|
light: Light;
|
||||||
|
cam2: Camera;
|
||||||
|
proj2: Projector;
|
||||||
|
capper: Capper;
|
||||||
|
alertObj: Alert;
|
||||||
|
private cfg;
|
||||||
|
private ipc;
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* Assign all connected devices and mock devices as private classes.
|
||||||
|
*
|
||||||
|
* @param {object} cfg Configuration object
|
||||||
|
* @param {object} proj Projector 1
|
||||||
|
* @param {object} cam Camera 1
|
||||||
|
* @param {object} light Light source
|
||||||
|
* @param {object} alert Alert object
|
||||||
|
* @param {object} cam2 (optional) Camera 2
|
||||||
|
* @param {object} proj2 (optional) Projector 2
|
||||||
|
* @param {object} capper Capper object
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
constructor(cfg: Config, proj: Projector, cam: Camera, light: Light, alert: Alert, cam2?: Camera, proj2?: Projector, capper?: Capper);
|
||||||
|
/**
|
||||||
|
* Move the projector one frame forward
|
||||||
|
*
|
||||||
|
* @returns {integer} Length of action in ms
|
||||||
|
**/
|
||||||
|
projector_forward(): Promise<number>;
|
||||||
|
/**
|
||||||
|
* Move the projector one frame backward
|
||||||
|
*
|
||||||
|
* @returns {integer} Length of action in ms
|
||||||
|
**/
|
||||||
|
projector_backward(): Promise<number>;
|
||||||
|
/**
|
||||||
|
* Move the camera one frame forward
|
||||||
|
*
|
||||||
|
* @param {object} cmd Full cmd object
|
||||||
|
*
|
||||||
|
* @returns {integer} Length of action in ms
|
||||||
|
**/
|
||||||
|
camera_forward(): Promise<number>;
|
||||||
|
/**
|
||||||
|
* Move the camera one frame forward with light off
|
||||||
|
*
|
||||||
|
* @returns {integer} Length of action in ms
|
||||||
|
**/
|
||||||
|
black_forward(): Promise<number>;
|
||||||
|
/**
|
||||||
|
* Move the camera one frame backward
|
||||||
|
*
|
||||||
|
* @param {object} cmd Full cmd object
|
||||||
|
*
|
||||||
|
* @returns {integer} Length of action in ms
|
||||||
|
**/
|
||||||
|
camera_backward(): Promise<number>;
|
||||||
|
/**
|
||||||
|
* Move the camera one frame forward, light set to black or off
|
||||||
|
*
|
||||||
|
* @returns {integer} Length of action in ms
|
||||||
|
**/
|
||||||
|
black_backward(): Promise<number>;
|
||||||
|
/**
|
||||||
|
* Move the second camera one frame forward
|
||||||
|
*
|
||||||
|
* @param {object} cmd Full cmd object
|
||||||
|
*
|
||||||
|
* @returns {integer} Length of action in ms
|
||||||
|
**/
|
||||||
|
camera_second_forward(): Promise<number>;
|
||||||
|
/**
|
||||||
|
* Move the second camera one frame backward
|
||||||
|
*
|
||||||
|
* @param {object} cmd Full cmd object
|
||||||
|
*
|
||||||
|
* @returns {integer} Length of action in ms
|
||||||
|
**/
|
||||||
|
camera_second_backward(): Promise<number>;
|
||||||
|
/**
|
||||||
|
* Move the both cameras one frame forward
|
||||||
|
*
|
||||||
|
* @param {object} cmd Full cmd object
|
||||||
|
*
|
||||||
|
* @returns {integer} Length of action in ms
|
||||||
|
**/
|
||||||
|
cameras_forward(): Promise<number>;
|
||||||
|
/**
|
||||||
|
* Move the both cameras one frame backward
|
||||||
|
*
|
||||||
|
* @param {object} cmd Full cmd object
|
||||||
|
*
|
||||||
|
* @returns {integer} Length of action in ms
|
||||||
|
**/
|
||||||
|
cameras_backward(): Promise<number>;
|
||||||
|
/**
|
||||||
|
* Move first camera one frame forward and rewind secondary camera one frame backward
|
||||||
|
*
|
||||||
|
* @param {object} cmd Full cmd object
|
||||||
|
*
|
||||||
|
* @returns {integer} Length of action in ms
|
||||||
|
**/
|
||||||
|
camera_forward_camera_second_backward(): Promise<number>;
|
||||||
|
/**
|
||||||
|
* Rewind first camera one frame backward and move secondary camera one frame forward
|
||||||
|
*
|
||||||
|
* @param {object} cmd Full cmd object
|
||||||
|
*
|
||||||
|
* @returns {integer} Length of action in ms
|
||||||
|
**/
|
||||||
|
camera_backward_camera_second_forward(): Promise<number>;
|
||||||
|
/**
|
||||||
|
* Move the secondary projector forward one frame
|
||||||
|
*
|
||||||
|
* @returns {integer} Length of action in ms
|
||||||
|
**/
|
||||||
|
projector_second_forward(): Promise<number>;
|
||||||
|
/**
|
||||||
|
* Rewind the secondary projector backward one frame
|
||||||
|
*
|
||||||
|
* @returns {integer} Length of action in ms
|
||||||
|
**/
|
||||||
|
projector_second_backward(): Promise<number>;
|
||||||
|
/**
|
||||||
|
* Move the both projectors forward one frame
|
||||||
|
*
|
||||||
|
* @returns {integer} Length of action in ms
|
||||||
|
**/
|
||||||
|
projectors_forward(): Promise<number>;
|
||||||
|
/**
|
||||||
|
* Rewind both projectors backwards one frame
|
||||||
|
*
|
||||||
|
* @returns {integer} Length of action in ms
|
||||||
|
**/
|
||||||
|
projectors_backward(): Promise<number>;
|
||||||
|
/**
|
||||||
|
* Move the primary projector forward one frame and rewind the secondary projector
|
||||||
|
* one frame backwards.
|
||||||
|
*
|
||||||
|
* @returns {integer} Length of action in ms
|
||||||
|
**/
|
||||||
|
projector_forward_projector_second_backward(): Promise<number>;
|
||||||
|
/**
|
||||||
|
* Rewind the primary projector backwards one frame and move the secondary
|
||||||
|
* projector forward one frame.
|
||||||
|
*
|
||||||
|
* @returns {integer} Length of action in ms
|
||||||
|
**/
|
||||||
|
projector_backward_projector_second_forward(): Promise<number>;
|
||||||
|
/**
|
||||||
|
* Throws an alert to pause a sequence
|
||||||
|
*
|
||||||
|
* @returns {integer} Length of action in ms
|
||||||
|
**/
|
||||||
|
alert(cmd: any): Promise<number>;
|
||||||
|
/**
|
||||||
|
* Pauses a sequence for a length of time
|
||||||
|
*
|
||||||
|
* @returns {integer} Length of action in ms
|
||||||
|
**/
|
||||||
|
pause(cmd: any): Promise<number>;
|
||||||
|
/**
|
||||||
|
* Sets the camera exposure (if supported).
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
camera_exposure(cmd: any): Promise<number>;
|
||||||
|
}
|
|
@ -1,7 +1,13 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.Commands = void 0;
|
||||||
|
const electron_1 = require("electron");
|
||||||
const uuid_1 = require("uuid");
|
const uuid_1 = require("uuid");
|
||||||
const delay_1 = require("delay");
|
const delay_1 = require("delay");
|
||||||
|
/** @module lib/cmd */
|
||||||
|
/**
|
||||||
|
* Class representing all commands bundled into methods.
|
||||||
|
*/
|
||||||
class Commands {
|
class Commands {
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
|
@ -11,19 +17,25 @@ class Commands {
|
||||||
* @param {object} proj Projector 1
|
* @param {object} proj Projector 1
|
||||||
* @param {object} cam Camera 1
|
* @param {object} cam Camera 1
|
||||||
* @param {object} light Light source
|
* @param {object} light Light source
|
||||||
|
* @param {object} alert Alert object
|
||||||
* @param {object} cam2 (optional) Camera 2
|
* @param {object} cam2 (optional) Camera 2
|
||||||
* @param {object} proj2 {optional} Projector 2
|
* @param {object} proj2 (optional) Projector 2
|
||||||
|
* @param {object} capper Capper object
|
||||||
|
*
|
||||||
**/
|
**/
|
||||||
constructor(cfg, proj, cam, light, cam2 = null, proj2 = null) {
|
constructor(cfg, proj, cam, light, alert, cam2 = null, proj2 = null, capper = null) {
|
||||||
|
this.ipc = electron_1.ipcMain;
|
||||||
this.cfg = cfg;
|
this.cfg = cfg;
|
||||||
this.proj = proj;
|
this.proj = proj;
|
||||||
this.cam = cam;
|
this.cam = cam;
|
||||||
this.light = light;
|
this.light = light;
|
||||||
if (cam2)
|
this.alertObj = alert;
|
||||||
|
if (cam2 !== null)
|
||||||
this.cam2 = cam2;
|
this.cam2 = cam2;
|
||||||
if (proj2)
|
if (proj2 !== null)
|
||||||
this.proj2 = proj2;
|
this.proj2 = proj2;
|
||||||
this.ipc = require('electron').ipcMain;
|
if (capper !== null)
|
||||||
|
this.capper = capper;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Move the projector one frame forward
|
* Move the projector one frame forward
|
||||||
|
@ -31,14 +43,15 @@ class Commands {
|
||||||
* @returns {integer} Length of action in ms
|
* @returns {integer} Length of action in ms
|
||||||
**/
|
**/
|
||||||
async projector_forward() {
|
async projector_forward() {
|
||||||
|
const id = (0, uuid_1.v4)();
|
||||||
let ms;
|
let ms;
|
||||||
try {
|
try {
|
||||||
if (!this.proj.state.dir) {
|
if (!this.proj.state.dir) {
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.proj.set(true);
|
await this.proj.set(true, id);
|
||||||
}
|
}
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
ms = await this.proj.move();
|
ms = await this.proj.move(id);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
throw err;
|
throw err;
|
||||||
|
@ -51,14 +64,15 @@ class Commands {
|
||||||
* @returns {integer} Length of action in ms
|
* @returns {integer} Length of action in ms
|
||||||
**/
|
**/
|
||||||
async projector_backward() {
|
async projector_backward() {
|
||||||
|
const id = (0, uuid_1.v4)();
|
||||||
let ms;
|
let ms;
|
||||||
try {
|
try {
|
||||||
if (this.proj.state.dir) {
|
if (this.proj.state.dir) {
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.proj.set(false);
|
await this.proj.set(false, id);
|
||||||
}
|
}
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
ms = await this.proj.move();
|
ms = await this.proj.move(id);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
throw err;
|
throw err;
|
||||||
|
@ -68,24 +82,25 @@ class Commands {
|
||||||
/**
|
/**
|
||||||
* Move the camera one frame forward
|
* Move the camera one frame forward
|
||||||
*
|
*
|
||||||
* @param {array} rgb Color to set light for frame
|
* @param {object} cmd Full cmd object
|
||||||
*
|
*
|
||||||
* @returns {integer} Length of action in ms
|
* @returns {integer} Length of action in ms
|
||||||
**/
|
**/
|
||||||
async camera_forward(rgb = [255, 255, 255]) {
|
async camera_forward() {
|
||||||
const id = uuid_1.v4();
|
const id = (0, uuid_1.v4)();
|
||||||
const off = [0, 0, 0];
|
const off = [0, 0, 0];
|
||||||
|
let rgb = [255, 255, 255];
|
||||||
let ms;
|
let ms;
|
||||||
try {
|
try {
|
||||||
if (!this.cam.state.dir) {
|
if (!this.cam.state.dir) {
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.cam.set(true);
|
await this.cam.set(true, id);
|
||||||
}
|
}
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.light.set(rgb, id);
|
await this.light.set(rgb, id);
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
ms = await this.cam.move();
|
ms = await this.cam.move(id);
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.light.set(off, id);
|
await this.light.set(off, id);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
@ -99,20 +114,27 @@ class Commands {
|
||||||
* @returns {integer} Length of action in ms
|
* @returns {integer} Length of action in ms
|
||||||
**/
|
**/
|
||||||
async black_forward() {
|
async black_forward() {
|
||||||
const id = uuid_1.v4();
|
const id = (0, uuid_1.v4)();
|
||||||
const off = [0, 0, 0];
|
const off = [0, 0, 0];
|
||||||
let ms;
|
let ms = 0;
|
||||||
try {
|
try {
|
||||||
if (!this.cam.state.dir) {
|
if (!this.cam.state.dir) {
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.cam.set(true);
|
await this.cam.set(true, id);
|
||||||
}
|
}
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
|
if (this.capper) {
|
||||||
|
ms += await this.capper.capper(true, id);
|
||||||
|
}
|
||||||
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.light.set(off, id); //make sure set to off
|
await this.light.set(off, id); //make sure set to off
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
ms = await this.cam.move();
|
ms += await this.cam.move(id);
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.light.set(off, id);
|
await this.light.set(off, id);
|
||||||
|
if (this.capper) {
|
||||||
|
ms += await this.capper.capper(false, id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
throw err;
|
throw err;
|
||||||
|
@ -122,24 +144,25 @@ class Commands {
|
||||||
/**
|
/**
|
||||||
* Move the camera one frame backward
|
* Move the camera one frame backward
|
||||||
*
|
*
|
||||||
* @param {array} rgb Color to set light for frame
|
* @param {object} cmd Full cmd object
|
||||||
*
|
*
|
||||||
* @returns {integer} Length of action in ms
|
* @returns {integer} Length of action in ms
|
||||||
**/
|
**/
|
||||||
async camera_backward(rgb = [255, 255, 255]) {
|
async camera_backward() {
|
||||||
const id = uuid_1.v4();
|
const id = (0, uuid_1.v4)();
|
||||||
const off = [0, 0, 0];
|
const off = [0, 0, 0];
|
||||||
|
let rgb = [255, 255, 255];
|
||||||
let ms;
|
let ms;
|
||||||
try {
|
try {
|
||||||
if (this.cam.state.dir) {
|
if (this.cam.state.dir) {
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.cam.set(false);
|
await this.cam.set(false, id);
|
||||||
}
|
}
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.light.set(rgb, id);
|
await this.light.set(rgb, id);
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
ms = await this.cam.move();
|
ms = await this.cam.move(id);
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.light.set(off, id);
|
await this.light.set(off, id);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
@ -153,20 +176,26 @@ class Commands {
|
||||||
* @returns {integer} Length of action in ms
|
* @returns {integer} Length of action in ms
|
||||||
**/
|
**/
|
||||||
async black_backward() {
|
async black_backward() {
|
||||||
const id = uuid_1.v4();
|
const id = (0, uuid_1.v4)();
|
||||||
const off = [0, 0, 0];
|
const off = [0, 0, 0];
|
||||||
let ms;
|
let ms = 0;
|
||||||
try {
|
try {
|
||||||
if (this.cam.state.dir) {
|
if (this.cam.state.dir) {
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.cam.set(false);
|
await this.cam.set(false, id);
|
||||||
}
|
}
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
if (this.capper) {
|
||||||
|
ms += await this.capper.capper(true, id);
|
||||||
|
}
|
||||||
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.light.set(off, id); //make sure set to off
|
await this.light.set(off, id); //make sure set to off
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
ms = await this.cam.move();
|
ms += await this.cam.move(id);
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.light.set(off, id);
|
await this.light.set(off, id);
|
||||||
|
if (this.capper) {
|
||||||
|
ms += await this.capper.capper(false, id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
throw err;
|
throw err;
|
||||||
|
@ -176,24 +205,25 @@ class Commands {
|
||||||
/**
|
/**
|
||||||
* Move the second camera one frame forward
|
* Move the second camera one frame forward
|
||||||
*
|
*
|
||||||
* @param {array} rgb Color to set light for frame
|
* @param {object} cmd Full cmd object
|
||||||
*
|
*
|
||||||
* @returns {integer} Length of action in ms
|
* @returns {integer} Length of action in ms
|
||||||
**/
|
**/
|
||||||
async camera_second_forward(rgb = [255, 255, 255]) {
|
async camera_second_forward() {
|
||||||
const id = uuid_1.v4();
|
const id = (0, uuid_1.v4)();
|
||||||
const off = [0, 0, 0];
|
const off = [0, 0, 0];
|
||||||
|
let rgb = [255, 255, 255];
|
||||||
let ms;
|
let ms;
|
||||||
try {
|
try {
|
||||||
if (!this.cam2.state.dir) {
|
if (!this.cam2.state.dir) {
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.cam2.set(true);
|
await this.cam2.set(true, id);
|
||||||
}
|
}
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.light.set(rgb, id);
|
await this.light.set(rgb, id);
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
ms = await this.cam2.move();
|
ms = await this.cam2.move(id);
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.light.set(off, id);
|
await this.light.set(off, id);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
@ -204,24 +234,25 @@ class Commands {
|
||||||
/**
|
/**
|
||||||
* Move the second camera one frame backward
|
* Move the second camera one frame backward
|
||||||
*
|
*
|
||||||
* @param {array} rgb Color to set light for frame
|
* @param {object} cmd Full cmd object
|
||||||
*
|
*
|
||||||
* @returns {integer} Length of action in ms
|
* @returns {integer} Length of action in ms
|
||||||
**/
|
**/
|
||||||
async camera_second_backward(rgb = [255, 255, 255]) {
|
async camera_second_backward() {
|
||||||
const id = uuid_1.v4();
|
const id = (0, uuid_1.v4)();
|
||||||
const off = [0, 0, 0];
|
const off = [0, 0, 0];
|
||||||
|
let rgb = [255, 255, 255];
|
||||||
let ms;
|
let ms;
|
||||||
try {
|
try {
|
||||||
if (this.cam2.state.dir) {
|
if (this.cam2.state.dir) {
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.cam2.set(false);
|
await this.cam2.set(false, id);
|
||||||
}
|
}
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.light.set(rgb, id);
|
await this.light.set(rgb, id);
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
ms = await this.cam2.move();
|
ms = await this.cam2.move(id);
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.light.set(off, id);
|
await this.light.set(off, id);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
@ -232,37 +263,36 @@ class Commands {
|
||||||
/**
|
/**
|
||||||
* Move the both cameras one frame forward
|
* Move the both cameras one frame forward
|
||||||
*
|
*
|
||||||
* @param {array} rgb Color to set light for frame
|
* @param {object} cmd Full cmd object
|
||||||
*
|
*
|
||||||
* @returns {integer} Length of action in ms
|
* @returns {integer} Length of action in ms
|
||||||
**/
|
**/
|
||||||
async cameras_forward(rgb = [255, 255, 255]) {
|
async cameras_forward() {
|
||||||
const id = uuid_1.v4();
|
const id = (0, uuid_1.v4)();
|
||||||
const off = [0, 0, 0];
|
const off = [0, 0, 0];
|
||||||
|
let rgb = [255, 255, 255];
|
||||||
let both;
|
let both;
|
||||||
let ms;
|
let ms;
|
||||||
try {
|
try {
|
||||||
if (!this.cam.state.dir) {
|
if (!this.cam.state.dir) {
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.cam.set(true);
|
await this.cam.set(true, id);
|
||||||
}
|
}
|
||||||
if (!this.cam2.state.dir) {
|
if (!this.cam2.state.dir) {
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.cam2.set(true);
|
await this.cam2.set(true, id);
|
||||||
}
|
}
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.light.set(rgb, id);
|
await this.light.set(rgb, id);
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) {
|
if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) {
|
||||||
ms = await this.cam.both();
|
ms = await this.cam.both(id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.cam.move();
|
both = await Promise.all([this.cam.move(id), this.cam2.move(id)]);
|
||||||
this.cam2.move();
|
|
||||||
both = [await this.cam.move, await this.cam2.move];
|
|
||||||
ms = Math.max(...both);
|
ms = Math.max(...both);
|
||||||
}
|
}
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.light.set(off, id);
|
await this.light.set(off, id);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
@ -273,37 +303,36 @@ class Commands {
|
||||||
/**
|
/**
|
||||||
* Move the both cameras one frame backward
|
* Move the both cameras one frame backward
|
||||||
*
|
*
|
||||||
* @param {array} rgb Color to set light for frame
|
* @param {object} cmd Full cmd object
|
||||||
*
|
*
|
||||||
* @returns {integer} Length of action in ms
|
* @returns {integer} Length of action in ms
|
||||||
**/
|
**/
|
||||||
async cameras_backward(rgb = [255, 255, 255]) {
|
async cameras_backward() {
|
||||||
const id = uuid_1.v4();
|
const id = (0, uuid_1.v4)();
|
||||||
const off = [0, 0, 0];
|
const off = [0, 0, 0];
|
||||||
|
let rgb = [255, 255, 255];
|
||||||
let both;
|
let both;
|
||||||
let ms;
|
let ms;
|
||||||
try {
|
try {
|
||||||
if (this.cam.state.dir) {
|
if (this.cam.state.dir) {
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.cam.set(false);
|
await this.cam.set(false, id);
|
||||||
}
|
}
|
||||||
if (this.cam2.state.dir) {
|
if (this.cam2.state.dir) {
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.cam2.set(false);
|
await this.cam2.set(false, id);
|
||||||
}
|
}
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.light.set(rgb, id);
|
await this.light.set(rgb, id);
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) {
|
if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) {
|
||||||
ms = await this.cam.both();
|
ms = await this.cam.both(id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.cam.move();
|
both = await Promise.all([this.cam.move(id), this.cam2.move(id)]);
|
||||||
this.cam2.move();
|
|
||||||
both = [await this.cam.move, await this.cam2.move];
|
|
||||||
ms = Math.max(...both);
|
ms = Math.max(...both);
|
||||||
}
|
}
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.light.set(off, id);
|
await this.light.set(off, id);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
@ -314,37 +343,36 @@ class Commands {
|
||||||
/**
|
/**
|
||||||
* Move first camera one frame forward and rewind secondary camera one frame backward
|
* Move first camera one frame forward and rewind secondary camera one frame backward
|
||||||
*
|
*
|
||||||
* @param {array} rgb Color to set light for frames
|
* @param {object} cmd Full cmd object
|
||||||
*
|
*
|
||||||
* @returns {integer} Length of action in ms
|
* @returns {integer} Length of action in ms
|
||||||
**/
|
**/
|
||||||
async camera_forward_camera_second_backward(rgb = [255, 255, 255]) {
|
async camera_forward_camera_second_backward() {
|
||||||
const id = uuid_1.v4();
|
const id = (0, uuid_1.v4)();
|
||||||
const off = [0, 0, 0];
|
const off = [0, 0, 0];
|
||||||
|
let rgb = [255, 255, 255];
|
||||||
let both;
|
let both;
|
||||||
let ms;
|
let ms;
|
||||||
try {
|
try {
|
||||||
if (!this.cam.state.dir) {
|
if (!this.cam.state.dir) {
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.cam.set(true);
|
await this.cam.set(true, id);
|
||||||
}
|
}
|
||||||
if (this.cam2.state.dir) {
|
if (this.cam2.state.dir) {
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.cam2.set(false);
|
await this.cam2.set(false, id);
|
||||||
}
|
}
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.light.set(rgb, id);
|
await this.light.set(rgb, id);
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) {
|
if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) {
|
||||||
ms = await this.cam.both();
|
ms = await this.cam.both(id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.cam.move();
|
both = await Promise.all([this.cam.move(id), this.cam2.move(id)]);
|
||||||
this.cam2.move();
|
|
||||||
both = [await this.cam.move, await this.cam2.move];
|
|
||||||
ms = Math.max(...both);
|
ms = Math.max(...both);
|
||||||
}
|
}
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.light.set(off, id);
|
await this.light.set(off, id);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
@ -355,37 +383,36 @@ class Commands {
|
||||||
/**
|
/**
|
||||||
* Rewind first camera one frame backward and move secondary camera one frame forward
|
* Rewind first camera one frame backward and move secondary camera one frame forward
|
||||||
*
|
*
|
||||||
* @param {array} rgb Color to set light for frame
|
* @param {object} cmd Full cmd object
|
||||||
*
|
*
|
||||||
* @returns {integer} Length of action in ms
|
* @returns {integer} Length of action in ms
|
||||||
**/
|
**/
|
||||||
async camera_backward_camera_second_forward(rgb = [255, 255, 255]) {
|
async camera_backward_camera_second_forward() {
|
||||||
const id = uuid_1.v4();
|
const id = (0, uuid_1.v4)();
|
||||||
const off = [0, 0, 0];
|
const off = [0, 0, 0];
|
||||||
|
let rgb = [255, 255, 255];
|
||||||
let both;
|
let both;
|
||||||
let ms;
|
let ms;
|
||||||
try {
|
try {
|
||||||
if (this.cam.state.dir) {
|
if (this.cam.state.dir) {
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.cam.set(false);
|
await this.cam.set(false, id);
|
||||||
}
|
}
|
||||||
if (!this.cam2.state.dir) {
|
if (!this.cam2.state.dir) {
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.cam2.set(true);
|
await this.cam2.set(true, id);
|
||||||
}
|
}
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.light.set(rgb, id);
|
await this.light.set(rgb, id);
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) {
|
if (this.cam && this.cam2 && this.cam.arduino.alias.camera === this.cam.arduino.alias.camera_second) {
|
||||||
ms = await this.cam.both();
|
ms = await this.cam.both(id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.cam.move();
|
both = await Promise.all([this.cam.move(id), this.cam2.move(id)]);
|
||||||
this.cam.move();
|
|
||||||
both = [await this.cam.move, await this.proj2.move];
|
|
||||||
ms = Math.max(...both);
|
ms = Math.max(...both);
|
||||||
}
|
}
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.light.set(off, id);
|
await this.light.set(off, id);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
@ -399,14 +426,15 @@ class Commands {
|
||||||
* @returns {integer} Length of action in ms
|
* @returns {integer} Length of action in ms
|
||||||
**/
|
**/
|
||||||
async projector_second_forward() {
|
async projector_second_forward() {
|
||||||
|
const id = (0, uuid_1.v4)();
|
||||||
let ms;
|
let ms;
|
||||||
try {
|
try {
|
||||||
if (!this.proj2.state.dir) {
|
if (!this.proj2.state.dir) {
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.proj2.set(true);
|
await this.proj2.set(true, id);
|
||||||
}
|
}
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
ms = await this.proj2.move();
|
ms = await this.proj2.move(id);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
throw err;
|
throw err;
|
||||||
|
@ -419,14 +447,15 @@ class Commands {
|
||||||
* @returns {integer} Length of action in ms
|
* @returns {integer} Length of action in ms
|
||||||
**/
|
**/
|
||||||
async projector_second_backward() {
|
async projector_second_backward() {
|
||||||
|
const id = (0, uuid_1.v4)();
|
||||||
let ms;
|
let ms;
|
||||||
try {
|
try {
|
||||||
if (this.proj2.state.dir) {
|
if (this.proj2.state.dir) {
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.proj2.set(false);
|
await this.proj2.set(false, id);
|
||||||
}
|
}
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
ms = await this.proj2.move();
|
ms = await this.proj2.move(id);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
throw err;
|
throw err;
|
||||||
|
@ -439,25 +468,24 @@ class Commands {
|
||||||
* @returns {integer} Length of action in ms
|
* @returns {integer} Length of action in ms
|
||||||
**/
|
**/
|
||||||
async projectors_forward() {
|
async projectors_forward() {
|
||||||
|
const id = (0, uuid_1.v4)();
|
||||||
let both;
|
let both;
|
||||||
let ms;
|
let ms;
|
||||||
try {
|
try {
|
||||||
if (!this.proj.state.dir) {
|
if (!this.proj.state.dir) {
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.proj.set(true);
|
await this.proj.set(true, id);
|
||||||
}
|
}
|
||||||
if (!this.proj2.state.dir) {
|
if (!this.proj2.state.dir) {
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.proj2.set(true);
|
await this.proj2.set(true, id);
|
||||||
}
|
}
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
if (this.proj && this.proj2 && this.proj.arduino.alias.projector === this.proj.arduino.alias.projector_second) {
|
if (this.proj && this.proj2 && this.proj.arduino.alias.projector === this.proj.arduino.alias.projector_second) {
|
||||||
ms = await this.proj.both();
|
ms = await this.proj.both(id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.proj.move();
|
both = await Promise.all([this.proj.move(id), this.proj2.move(id)]);
|
||||||
this.proj2.move();
|
|
||||||
both = [await this.proj.move, await this.proj2.move];
|
|
||||||
ms = Math.max(...both);
|
ms = Math.max(...both);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -472,26 +500,24 @@ class Commands {
|
||||||
* @returns {integer} Length of action in ms
|
* @returns {integer} Length of action in ms
|
||||||
**/
|
**/
|
||||||
async projectors_backward() {
|
async projectors_backward() {
|
||||||
|
const id = (0, uuid_1.v4)();
|
||||||
let both;
|
let both;
|
||||||
let ms;
|
let ms;
|
||||||
try {
|
try {
|
||||||
if (this.proj.state.dir) {
|
if (this.proj.state.dir) {
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.proj.set(false);
|
await this.proj.set(false, id);
|
||||||
}
|
}
|
||||||
if (this.proj2.state.dir) {
|
if (this.proj2.state.dir) {
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.proj2.set(false);
|
await this.proj2.set(false, id);
|
||||||
}
|
}
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
//run one projector without await?
|
|
||||||
if (this.proj && this.proj2 && this.proj.arduino.alias.projector === this.proj.arduino.alias.projector_second) {
|
if (this.proj && this.proj2 && this.proj.arduino.alias.projector === this.proj.arduino.alias.projector_second) {
|
||||||
ms = await this.proj.both();
|
ms = await this.proj.both(id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.proj.move();
|
both = await Promise.all([this.proj.move(id), this.proj2.move(id)]);
|
||||||
this.proj2.move();
|
|
||||||
both = [await this.proj.move, await this.proj2.move];
|
|
||||||
ms = Math.max(...both);
|
ms = Math.max(...both);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -507,26 +533,24 @@ class Commands {
|
||||||
* @returns {integer} Length of action in ms
|
* @returns {integer} Length of action in ms
|
||||||
**/
|
**/
|
||||||
async projector_forward_projector_second_backward() {
|
async projector_forward_projector_second_backward() {
|
||||||
|
const id = (0, uuid_1.v4)();
|
||||||
let both;
|
let both;
|
||||||
let ms;
|
let ms;
|
||||||
try {
|
try {
|
||||||
if (!this.proj.state.dir) {
|
if (!this.proj.state.dir) {
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.proj.set(true);
|
await this.proj.set(true, id);
|
||||||
}
|
}
|
||||||
if (this.proj2.state.dir) {
|
if (this.proj2.state.dir) {
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.proj2.set(false);
|
await this.proj2.set(false, id);
|
||||||
}
|
}
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
//run one projector without await?
|
|
||||||
if (this.proj && this.proj2 && this.proj.arduino.alias.projector === this.proj.arduino.alias.projector_second) {
|
if (this.proj && this.proj2 && this.proj.arduino.alias.projector === this.proj.arduino.alias.projector_second) {
|
||||||
ms = await this.proj.both();
|
ms = await this.proj.both(id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.proj.move();
|
both = await Promise.all([this.proj.move(id), this.proj2.move(id)]);
|
||||||
this.proj2.move();
|
|
||||||
both = [await this.proj.move, await this.proj2.move];
|
|
||||||
ms = Math.max(...both);
|
ms = Math.max(...both);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -542,26 +566,24 @@ class Commands {
|
||||||
* @returns {integer} Length of action in ms
|
* @returns {integer} Length of action in ms
|
||||||
**/
|
**/
|
||||||
async projector_backward_projector_second_forward() {
|
async projector_backward_projector_second_forward() {
|
||||||
|
const id = (0, uuid_1.v4)();
|
||||||
let both;
|
let both;
|
||||||
let ms;
|
let ms;
|
||||||
try {
|
try {
|
||||||
if (this.proj.state.dir) {
|
if (this.proj.state.dir) {
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.proj.set(false);
|
await this.proj.set(false, id);
|
||||||
}
|
}
|
||||||
if (!this.proj2.state.dir) {
|
if (!this.proj2.state.dir) {
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
await this.proj2.set(true);
|
await this.proj2.set(true, id);
|
||||||
}
|
}
|
||||||
await delay_1.delay(this.cfg.arduino.serialDelay);
|
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
|
||||||
//run one projector without await?
|
|
||||||
if (this.proj && this.proj2 && this.proj.arduino.alias.projector === this.proj.arduino.alias.projector_second) {
|
if (this.proj && this.proj2 && this.proj.arduino.alias.projector === this.proj.arduino.alias.projector_second) {
|
||||||
ms = await this.proj.both();
|
ms = await this.proj.both(id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.proj.move();
|
both = await Promise.all([this.proj.move(id), this.proj2.move(id)]);
|
||||||
this.proj2.move();
|
|
||||||
both = [await this.proj.move, await this.proj2.move];
|
|
||||||
ms = Math.max(...both);
|
ms = Math.max(...both);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -570,8 +592,54 @@ class Commands {
|
||||||
}
|
}
|
||||||
return ms;
|
return ms;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Throws an alert to pause a sequence
|
||||||
|
*
|
||||||
|
* @returns {integer} Length of action in ms
|
||||||
|
**/
|
||||||
|
async alert(cmd) {
|
||||||
|
const id = (0, uuid_1.v4)();
|
||||||
|
let ms;
|
||||||
|
try {
|
||||||
|
ms = await this.alertObj.start(cmd.light); //change this meta
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
return ms;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Pauses a sequence for a length of time
|
||||||
|
*
|
||||||
|
* @returns {integer} Length of action in ms
|
||||||
|
**/
|
||||||
|
async pause(cmd) {
|
||||||
|
const id = (0, uuid_1.v4)();
|
||||||
|
let ms;
|
||||||
|
try {
|
||||||
|
ms = await (0, delay_1.delay)(cmd.light * 1000); //delay is in seconds
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
return ms;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Sets the camera exposure (if supported).
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
async camera_exposure(cmd) {
|
||||||
|
const id = (0, uuid_1.v4)();
|
||||||
|
let ms;
|
||||||
|
try {
|
||||||
|
ms = await this.cam.exposure(cmd.light, id);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
return ms;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
module.exports = function (cfg, proj, cam, light, cam2, proj2) {
|
exports.Commands = Commands;
|
||||||
return new Commands(cfg, proj, cam, light, cam2, proj2);
|
module.exports = { Commands };
|
||||||
};
|
|
||||||
//# sourceMappingURL=index.js.map
|
//# sourceMappingURL=index.js.map
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,8 @@
|
||||||
|
/**
|
||||||
|
* Delay in an async/await function
|
||||||
|
*
|
||||||
|
* @param {integer} ms Milliseconds to delay for
|
||||||
|
*
|
||||||
|
* @returns {Promise} Promise to resolve after timeout
|
||||||
|
**/
|
||||||
|
export declare function delay(ms: number): Promise<number>;
|
|
@ -1,4 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.delay = void 0;
|
||||||
/**
|
/**
|
||||||
* Delay in an async/await function
|
* Delay in an async/await function
|
||||||
*
|
*
|
||||||
|
@ -8,8 +10,9 @@
|
||||||
**/
|
**/
|
||||||
function delay(ms) {
|
function delay(ms) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
return setTimeout(resolve, ms);
|
return setTimeout(() => { resolve(ms); }, ms);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
module.exports.delay = delay;
|
exports.delay = delay;
|
||||||
|
module.exports = { delay };
|
||||||
//# sourceMappingURL=index.js.map
|
//# sourceMappingURL=index.js.map
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/delay/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb;;;;;;IAMI;AAEJ,SAAS,KAAK,CAAE,EAAW;IAC1B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAa,EAAE,EAAE;QACpC,OAAO,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC"}
|
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/delay/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb;;;;;;IAMI;AAEJ,SAAgB,KAAK,CAAE,EAAW;IACjC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAa,EAAE,EAAE;QACpC,OAAO,UAAU,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC,CAAA,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;AACJ,CAAC;AAJD,sBAIC;AAED,MAAM,CAAC,OAAO,GAAG,EAAE,KAAK,EAAE,CAAC"}
|
|
@ -1,74 +1,116 @@
|
||||||
<a name="Devices"></a>
|
<a name="module_lib/devices"></a>
|
||||||
|
|
||||||
## Devices
|
## lib/devices
|
||||||
class representing the device discovery features
|
|
||||||
|
|
||||||
**Kind**: global class
|
* [lib/devices](#module_lib/devices)
|
||||||
|
* [~Devices](#module_lib/devices..Devices)
|
||||||
|
* [new Devices()](#new_module_lib/devices..Devices_new)
|
||||||
|
* [.init()](#module_lib/devices..Devices+init)
|
||||||
|
* [.listen()](#module_lib/devices..Devices+listen)
|
||||||
|
* [.listener()](#module_lib/devices..Devices+listener)
|
||||||
|
* [.enumerate()](#module_lib/devices..Devices+enumerate)
|
||||||
|
* [.favor()](#module_lib/devices..Devices+favor)
|
||||||
|
* [.distinguish()](#module_lib/devices..Devices+distinguish)
|
||||||
|
* [.fakeProjector()](#module_lib/devices..Devices+fakeProjector)
|
||||||
|
* [.fakeCamera()](#module_lib/devices..Devices+fakeCamera)
|
||||||
|
* [.fakeLight()](#module_lib/devices..Devices+fakeLight)
|
||||||
|
* [.fakeCapper()](#module_lib/devices..Devices+fakeCapper)
|
||||||
|
* [.connectDevice()](#module_lib/devices..Devices+connectDevice)
|
||||||
|
* [.all()](#module_lib/devices..Devices+all)
|
||||||
|
* [.remember()](#module_lib/devices..Devices+remember)
|
||||||
|
* [.ready()](#module_lib/devices..Devices+ready)
|
||||||
|
|
||||||
* [Devices](#Devices)
|
<a name="module_lib/devices..Devices"></a>
|
||||||
* [.init()](#Devices+init)
|
|
||||||
* [.listen()](#Devices+listen)
|
|
||||||
* [.listener()](#Devices+listener)
|
|
||||||
* [.enumerate()](#Devices+enumerate)
|
|
||||||
* [.favor()](#Devices+favor)
|
|
||||||
* [.distinguish()](#Devices+distinguish)
|
|
||||||
* [.fakeProjector()](#Devices+fakeProjector)
|
|
||||||
* [.fakeCamera()](#Devices+fakeCamera)
|
|
||||||
* [.fakeLight()](#Devices+fakeLight)
|
|
||||||
* [.connectDevice()](#Devices+connectDevice)
|
|
||||||
* [.all()](#Devices+all)
|
|
||||||
* [.remember()](#Devices+remember)
|
|
||||||
* [.ready()](#Devices+ready)
|
|
||||||
|
|
||||||
<a name="Devices+init"></a>
|
### lib/devices~Devices
|
||||||
|
Class representing the device discovery features.
|
||||||
|
|
||||||
### devices.init()
|
**Kind**: inner class of [<code>lib/devices</code>](#module_lib/devices)
|
||||||
**Kind**: instance method of [<code>Devices</code>](#Devices)
|
|
||||||
<a name="Devices+listen"></a>
|
|
||||||
|
|
||||||
### devices.listen()
|
* [~Devices](#module_lib/devices..Devices)
|
||||||
**Kind**: instance method of [<code>Devices</code>](#Devices)
|
* [new Devices()](#new_module_lib/devices..Devices_new)
|
||||||
<a name="Devices+listener"></a>
|
* [.init()](#module_lib/devices..Devices+init)
|
||||||
|
* [.listen()](#module_lib/devices..Devices+listen)
|
||||||
|
* [.listener()](#module_lib/devices..Devices+listener)
|
||||||
|
* [.enumerate()](#module_lib/devices..Devices+enumerate)
|
||||||
|
* [.favor()](#module_lib/devices..Devices+favor)
|
||||||
|
* [.distinguish()](#module_lib/devices..Devices+distinguish)
|
||||||
|
* [.fakeProjector()](#module_lib/devices..Devices+fakeProjector)
|
||||||
|
* [.fakeCamera()](#module_lib/devices..Devices+fakeCamera)
|
||||||
|
* [.fakeLight()](#module_lib/devices..Devices+fakeLight)
|
||||||
|
* [.fakeCapper()](#module_lib/devices..Devices+fakeCapper)
|
||||||
|
* [.connectDevice()](#module_lib/devices..Devices+connectDevice)
|
||||||
|
* [.all()](#module_lib/devices..Devices+all)
|
||||||
|
* [.remember()](#module_lib/devices..Devices+remember)
|
||||||
|
* [.ready()](#module_lib/devices..Devices+ready)
|
||||||
|
|
||||||
### devices.listener()
|
<a name="new_module_lib/devices..Devices_new"></a>
|
||||||
**Kind**: instance method of [<code>Devices</code>](#Devices)
|
|
||||||
<a name="Devices+enumerate"></a>
|
|
||||||
|
|
||||||
### devices.enumerate()
|
#### new Devices()
|
||||||
**Kind**: instance method of [<code>Devices</code>](#Devices)
|
Constructor assigns arduino, settings, UI browser window and cam objects
|
||||||
<a name="Devices+favor"></a>
|
locally to this class for reference.
|
||||||
|
|
||||||
### devices.favor()
|
<a name="module_lib/devices..Devices+init"></a>
|
||||||
**Kind**: instance method of [<code>Devices</code>](#Devices)
|
|
||||||
<a name="Devices+distinguish"></a>
|
|
||||||
|
|
||||||
### devices.distinguish()
|
#### devices.init()
|
||||||
**Kind**: instance method of [<code>Devices</code>](#Devices)
|
Initialize the log for "devices". Establish an ipc connection to the UI.
|
||||||
<a name="Devices+fakeProjector"></a>
|
Start listening on that ipc connection.
|
||||||
|
|
||||||
### devices.fakeProjector()
|
**Kind**: instance method of [<code>Devices</code>](#module_lib/devices..Devices)
|
||||||
**Kind**: instance method of [<code>Devices</code>](#Devices)
|
<a name="module_lib/devices..Devices+listen"></a>
|
||||||
<a name="Devices+fakeCamera"></a>
|
|
||||||
|
|
||||||
### devices.fakeCamera()
|
#### devices.listen()
|
||||||
**Kind**: instance method of [<code>Devices</code>](#Devices)
|
Listen to the "profile" channel for messages from the UI.
|
||||||
<a name="Devices+fakeLight"></a>
|
|
||||||
|
|
||||||
### devices.fakeLight()
|
**Kind**: instance method of [<code>Devices</code>](#module_lib/devices..Devices)
|
||||||
**Kind**: instance method of [<code>Devices</code>](#Devices)
|
<a name="module_lib/devices..Devices+listener"></a>
|
||||||
<a name="Devices+connectDevice"></a>
|
|
||||||
|
|
||||||
### devices.connectDevice()
|
#### devices.listener()
|
||||||
**Kind**: instance method of [<code>Devices</code>](#Devices)
|
The "profile" channel callback. If a profile is changed, set it in the
|
||||||
<a name="Devices+all"></a>
|
local settings object.
|
||||||
|
|
||||||
### devices.all()
|
**Kind**: instance method of [<code>Devices</code>](#module_lib/devices..Devices)
|
||||||
**Kind**: instance method of [<code>Devices</code>](#Devices)
|
<a name="module_lib/devices..Devices+enumerate"></a>
|
||||||
<a name="Devices+remember"></a>
|
|
||||||
|
|
||||||
### devices.remember()
|
#### devices.enumerate()
|
||||||
**Kind**: instance method of [<code>Devices</code>](#Devices)
|
**Kind**: instance method of [<code>Devices</code>](#module_lib/devices..Devices)
|
||||||
<a name="Devices+ready"></a>
|
<a name="module_lib/devices..Devices+favor"></a>
|
||||||
|
|
||||||
### devices.ready()
|
#### devices.favor()
|
||||||
**Kind**: instance method of [<code>Devices</code>](#Devices)
|
**Kind**: instance method of [<code>Devices</code>](#module_lib/devices..Devices)
|
||||||
|
<a name="module_lib/devices..Devices+distinguish"></a>
|
||||||
|
|
||||||
|
#### devices.distinguish()
|
||||||
|
**Kind**: instance method of [<code>Devices</code>](#module_lib/devices..Devices)
|
||||||
|
<a name="module_lib/devices..Devices+fakeProjector"></a>
|
||||||
|
|
||||||
|
#### devices.fakeProjector()
|
||||||
|
**Kind**: instance method of [<code>Devices</code>](#module_lib/devices..Devices)
|
||||||
|
<a name="module_lib/devices..Devices+fakeCamera"></a>
|
||||||
|
|
||||||
|
#### devices.fakeCamera()
|
||||||
|
**Kind**: instance method of [<code>Devices</code>](#module_lib/devices..Devices)
|
||||||
|
<a name="module_lib/devices..Devices+fakeLight"></a>
|
||||||
|
|
||||||
|
#### devices.fakeLight()
|
||||||
|
**Kind**: instance method of [<code>Devices</code>](#module_lib/devices..Devices)
|
||||||
|
<a name="module_lib/devices..Devices+fakeCapper"></a>
|
||||||
|
|
||||||
|
#### devices.fakeCapper()
|
||||||
|
**Kind**: instance method of [<code>Devices</code>](#module_lib/devices..Devices)
|
||||||
|
<a name="module_lib/devices..Devices+connectDevice"></a>
|
||||||
|
|
||||||
|
#### devices.connectDevice()
|
||||||
|
**Kind**: instance method of [<code>Devices</code>](#module_lib/devices..Devices)
|
||||||
|
<a name="module_lib/devices..Devices+all"></a>
|
||||||
|
|
||||||
|
#### devices.all()
|
||||||
|
**Kind**: instance method of [<code>Devices</code>](#module_lib/devices..Devices)
|
||||||
|
<a name="module_lib/devices..Devices+remember"></a>
|
||||||
|
|
||||||
|
#### devices.remember()
|
||||||
|
**Kind**: instance method of [<code>Devices</code>](#module_lib/devices..Devices)
|
||||||
|
<a name="module_lib/devices..Devices+ready"></a>
|
||||||
|
|
||||||
|
#### devices.ready()
|
||||||
|
**Kind**: instance method of [<code>Devices</code>](#module_lib/devices..Devices)
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
import type { Settings } from 'settings';
|
||||||
|
import type { Arduino } from 'arduino';
|
||||||
|
import type { BrowserWindow } from 'electron';
|
||||||
|
interface Device {
|
||||||
|
serial: string;
|
||||||
|
device: string;
|
||||||
|
}
|
||||||
|
/** @module lib/devices */
|
||||||
|
/**
|
||||||
|
* Class representing the device discovery features.
|
||||||
|
*/
|
||||||
|
export declare class Devices {
|
||||||
|
settings: Settings;
|
||||||
|
connected: any;
|
||||||
|
private arduino;
|
||||||
|
private log;
|
||||||
|
private ui;
|
||||||
|
private ipc;
|
||||||
|
private mainWindow;
|
||||||
|
/**
|
||||||
|
* Constructor assigns arduino, settings, UI browser window and cam objects
|
||||||
|
* locally to this class for reference.
|
||||||
|
**/
|
||||||
|
constructor(arduino: Arduino, settings: Settings, mainWindow: BrowserWindow);
|
||||||
|
/**
|
||||||
|
* Initialize the log for "devices". Establish an ipc connection to the UI.
|
||||||
|
* Start listening on that ipc connection.
|
||||||
|
**/
|
||||||
|
private init;
|
||||||
|
/**
|
||||||
|
* Listen to the "profile" channel for messages from the UI.
|
||||||
|
**/
|
||||||
|
private listen;
|
||||||
|
/**
|
||||||
|
* The "profile" channel callback. If a profile is changed, set it in the
|
||||||
|
* local settings object.
|
||||||
|
**/
|
||||||
|
private listener;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
enumerate(): Promise<boolean>;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private favor;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private distinguish;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private fakeProjector;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private fakeCamera;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private fakeLight;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private fakeCapper;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private connectDevice;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private all;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private remember;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private ready;
|
||||||
|
}
|
||||||
|
export type { Device };
|
|
@ -1,24 +1,25 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.Devices = void 0;
|
||||||
|
const electron_1 = require("electron");
|
||||||
const delay_1 = require("delay");
|
const delay_1 = require("delay");
|
||||||
const Log = require("log");
|
const log_1 = require("log");
|
||||||
|
/** @module lib/devices */
|
||||||
/**
|
/**
|
||||||
* class representing the device discovery features
|
* Class representing the device discovery features.
|
||||||
*
|
*/
|
||||||
*
|
|
||||||
**/
|
|
||||||
class Devices {
|
class Devices {
|
||||||
/**
|
/**
|
||||||
* Constructor assigns arduino, settings, UI browser window and cam objects
|
* Constructor assigns arduino, settings, UI browser window and cam objects
|
||||||
* locally to this class for reference.
|
* locally to this class for reference.
|
||||||
**/
|
**/
|
||||||
constructor(arduino, settings, mainWindow, cam) {
|
constructor(arduino, settings, mainWindow) {
|
||||||
this.connected = {};
|
this.connected = {};
|
||||||
|
this.ipc = electron_1.ipcMain;
|
||||||
this.arduino = arduino;
|
this.arduino = arduino;
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
this.mainWindow = mainWindow;
|
this.mainWindow = mainWindow;
|
||||||
this.ui = this.mainWindow.webContents;
|
this.ui = this.mainWindow.webContents;
|
||||||
this.cam = cam;
|
|
||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -26,57 +27,64 @@ class Devices {
|
||||||
* Start listening on that ipc connection.
|
* Start listening on that ipc connection.
|
||||||
**/
|
**/
|
||||||
async init() {
|
async init() {
|
||||||
this.log = await Log({ label: 'devices' });
|
this.log = await (0, log_1.Log)({ label: 'devices' });
|
||||||
this.ipc = require('electron').ipcMain;
|
|
||||||
this.listen();
|
this.listen();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Listen to the "profile" channel for messages from the UI.
|
* Listen to the "profile" channel for messages from the UI.
|
||||||
**/
|
**/
|
||||||
listen() {
|
listen() {
|
||||||
this.ipc.on('profile', this.listener.bind(this));
|
this.ipc.handle('profile', this.listener.bind(this));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* The "profile" channel callback. If a profile is changed, set it in the
|
* The "profile" channel callback. If a profile is changed, set it in the
|
||||||
* local settings object.
|
* local settings object.
|
||||||
**/
|
**/
|
||||||
listener(event, arg) {
|
async listener(event, arg) {
|
||||||
this.log.info(`Saving profile ${arg.profile}`, 'SETTINGS', false, false);
|
if (typeof arg.profile !== 'undefined') {
|
||||||
this.settings.update('profile', arg.profile);
|
this.log.info(`Saving profile ${arg.profile}`, 'SETTINGS', false, false);
|
||||||
this.settings.save();
|
this.settings.update('profile', arg.profile);
|
||||||
|
await this.settings.save();
|
||||||
|
}
|
||||||
|
if (typeof arg.timing !== 'undefined') {
|
||||||
|
this.log.info(`Saving timing info`, 'SETTINGS', false, false);
|
||||||
|
this.settings.update('timing', arg.timing);
|
||||||
|
await this.settings.save();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
async enumerate() {
|
async enumerate() {
|
||||||
let devices;
|
let serials;
|
||||||
try {
|
try {
|
||||||
devices = await this.arduino.enumerate();
|
serials = await this.arduino.enumerate();
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.warn(err, 'SERIAL', false, true);
|
this.log.warn(err, 'SERIAL', false, true);
|
||||||
await delay_1.delay(1000);
|
await (0, delay_1.delay)(1000);
|
||||||
return this.all([]);
|
return this.all([]);
|
||||||
}
|
}
|
||||||
this.log.info(`Found ${devices.length} USB devices`, 'SERIAL', true, true);
|
this.log.info(`Found ${serials.length} USB devices`, 'SERIAL', true, true);
|
||||||
devices = this.favor(devices);
|
serials = this.favor(serials);
|
||||||
return await this.all(devices);
|
return await this.all(serials);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
favor(devices) {
|
favor(serials) {
|
||||||
const past = this.settings.state.devices.filter((device) => {
|
const past = this.settings.state.devices.filter((device) => {
|
||||||
if (device.arduino) {
|
if (device.serial) {
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
}).map((device) => {
|
}).map((device) => {
|
||||||
return device.arduino;
|
return device.serial;
|
||||||
});
|
});
|
||||||
if (past.length === 0) {
|
if (past.length === 0) {
|
||||||
return devices;
|
return serials;
|
||||||
}
|
}
|
||||||
devices.sort((a, b) => {
|
serials.sort((a, b) => {
|
||||||
if (past.indexOf(a) !== -1 && past.indexOf(b) === -1) {
|
if (past.indexOf(a) !== -1 && past.indexOf(b) === -1) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -85,23 +93,24 @@ class Devices {
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
return devices;
|
return serials;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
async distinguish(device) {
|
async distinguish(serial) {
|
||||||
let connectSuccess;
|
let connectSuccess;
|
||||||
let verifySuccess;
|
let verifySuccess;
|
||||||
let type;
|
let device;
|
||||||
|
//this.log.info(`distinguish() ${serial}`)
|
||||||
try {
|
try {
|
||||||
connectSuccess = await this.arduino.connect('connect', device, true);
|
connectSuccess = await this.arduino.connect('connect', serial, true);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error('Error connecting', err);
|
this.log.error('Error connecting', err);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
await delay_1.delay(2000);
|
await (0, delay_1.delay)(2000);
|
||||||
try {
|
try {
|
||||||
verifySuccess = await this.arduino.verify();
|
verifySuccess = await this.arduino.verify();
|
||||||
}
|
}
|
||||||
|
@ -109,18 +118,25 @@ class Devices {
|
||||||
this.log.error('Error verifying device', err);
|
this.log.error('Error verifying device', err);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
this.log.info(`Verified ${device} as mcopy device`, 'SERIAL', true, true);
|
this.log.info(`Verified ${serial} as mcopy device`, 'SERIAL', true, true);
|
||||||
await delay_1.delay(1000);
|
await (0, delay_1.delay)(1000);
|
||||||
try {
|
try {
|
||||||
type = await this.arduino.distinguish();
|
device = await this.arduino.distinguish();
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error('Error distinguishing device', err);
|
this.log.error('Error distinguishing device', err);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
this.remember('arduino', device, type);
|
this.remember(device, serial, 'arduino');
|
||||||
this.log.info(`Determined ${device} to be ${type}`, 'SERIAL', true, true);
|
this.log.info(`Determined ${device} to be ${device}`, 'SERIAL', true, true);
|
||||||
return type;
|
await (0, delay_1.delay)(100);
|
||||||
|
try {
|
||||||
|
await this.arduino.state(device, true);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.log.error('Error checking state capability', err);
|
||||||
|
}
|
||||||
|
return device;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -131,24 +147,24 @@ class Devices {
|
||||||
await this.arduino.fakeConnect('projector');
|
await this.arduino.fakeConnect('projector');
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(err);
|
this.log.error(`Error connecting to fake PROjECTOR device`, 'SERIAL', true, true);
|
||||||
this.log.error(`Error connecting to fake PRONECTOR device`, 'SERIAL', true, true);
|
this.log.error(err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.log.info('Connected to fake PROJECTOR device', 'SERIAL', true, true);
|
this.log.info('Connected to fake PROJECTOR device', 'SERIAL', true, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
async fakeCamera() {
|
async fakeCamera() {
|
||||||
this.connected.camera = '/dev/fake';
|
this.connected.camera = '/dev/fake';
|
||||||
try {
|
try {
|
||||||
await this.arduino.fakeConnect('camera');
|
await this.arduino.fakeConnect('camera');
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(err);
|
|
||||||
this.log.error(`Error connecting to fake CAMERA device`, 'SERIAL', true, true);
|
this.log.error(`Error connecting to fake CAMERA device`, 'SERIAL', true, true);
|
||||||
|
this.log.error(err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.log.info('Connected to fake CAMERA device', 'SERIAL', true, true);
|
this.log.info('Connected to fake CAMERA device', 'SERIAL', true, true);
|
||||||
|
@ -163,17 +179,33 @@ class Devices {
|
||||||
await this.arduino.fakeConnect('light');
|
await this.arduino.fakeConnect('light');
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(err);
|
|
||||||
this.log.error(`Error connecting to fake LIGHT device`, 'SERIAL', true, true);
|
this.log.error(`Error connecting to fake LIGHT device`, 'SERIAL', true, true);
|
||||||
|
this.log.error(err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.log.info('Connected to fake LIGHT device', 'SERIAL', true, true);
|
this.log.info('Connected to fake LIGHT device', 'SERIAL', true, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
async connectDevice(device, type) {
|
async fakeCapper() {
|
||||||
|
this.connected.capper = '/dev/fake';
|
||||||
|
try {
|
||||||
|
await this.arduino.fakeConnect('capper');
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.log.error(`Error connecting to fake CAPPER device`, 'SERIAL', true, true);
|
||||||
|
this.log.error(err);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this.log.info('Connected to fake CAPPER device', 'SERIAL', true, true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
async connectDevice(device, serial) {
|
||||||
let closeSuccess;
|
let closeSuccess;
|
||||||
let connectSuccess;
|
let connectSuccess;
|
||||||
try {
|
try {
|
||||||
|
@ -183,10 +215,10 @@ class Devices {
|
||||||
this.log.error('Error closing arduino connection', err);
|
this.log.error('Error closing arduino connection', err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (type === 'projector') {
|
if (device === 'projector') {
|
||||||
this.connected.projector = device;
|
this.connected.projector = serial;
|
||||||
try {
|
try {
|
||||||
connectSuccess = await this.arduino.connect('projector', device, false);
|
connectSuccess = await this.arduino.connect('projector', serial, false);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error('Error connecting to projector', err);
|
this.log.error('Error connecting to projector', err);
|
||||||
|
@ -194,10 +226,10 @@ class Devices {
|
||||||
}
|
}
|
||||||
this.log.info(`Connected to ${device} as PROJECTOR`, 'SERIAL', true, true);
|
this.log.info(`Connected to ${device} as PROJECTOR`, 'SERIAL', true, true);
|
||||||
}
|
}
|
||||||
else if (type === 'camera') {
|
else if (device === 'camera') {
|
||||||
this.connected.camera = device;
|
this.connected.camera = serial;
|
||||||
try {
|
try {
|
||||||
connectSuccess = await this.arduino.connect('camera', device, false);
|
connectSuccess = await this.arduino.connect('camera', serial, false);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error('Error connecting to camera', err);
|
this.log.error('Error connecting to camera', err);
|
||||||
|
@ -205,10 +237,10 @@ class Devices {
|
||||||
}
|
}
|
||||||
this.log.info(`Connected to ${device} as CAMERA`, 'SERIAL', true, true);
|
this.log.info(`Connected to ${device} as CAMERA`, 'SERIAL', true, true);
|
||||||
}
|
}
|
||||||
else if (type === 'light') {
|
else if (device === 'light') {
|
||||||
this.connected.light = device;
|
this.connected.light = serial;
|
||||||
try {
|
try {
|
||||||
connectSuccess = await this.arduino.connect('light', device, false);
|
connectSuccess = await this.arduino.connect('light', serial, false);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error('Error connecting to light', err);
|
this.log.error('Error connecting to light', err);
|
||||||
|
@ -216,12 +248,12 @@ class Devices {
|
||||||
}
|
}
|
||||||
this.log.info(`Connected to ${device} as LIGHT`, 'SERIAL', true, true);
|
this.log.info(`Connected to ${device} as LIGHT`, 'SERIAL', true, true);
|
||||||
}
|
}
|
||||||
else if (type === 'projector,light') {
|
else if (device === 'projector,light') {
|
||||||
this.connected.projector = device;
|
this.connected.projector = serial;
|
||||||
this.connected.light = device;
|
this.connected.light = serial;
|
||||||
this.arduino.aliasSerial('light', device);
|
this.arduino.aliasSerial('light', serial);
|
||||||
try {
|
try {
|
||||||
connectSuccess = await this.arduino.connect('projector', device, false);
|
connectSuccess = await this.arduino.connect('projector', serial, false);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error('Error connecting to projector and light', err);
|
this.log.error('Error connecting to projector and light', err);
|
||||||
|
@ -229,14 +261,14 @@ class Devices {
|
||||||
}
|
}
|
||||||
this.log.info(`Connected to ${device} as PROJECTOR + LIGHT`, 'SERIAL', true, true);
|
this.log.info(`Connected to ${device} as PROJECTOR + LIGHT`, 'SERIAL', true, true);
|
||||||
}
|
}
|
||||||
else if (type === 'projector,camera,light') {
|
else if (device === 'projector,camera,light') {
|
||||||
this.connected.projector = device;
|
this.connected.projector = serial;
|
||||||
this.connected.camera = device;
|
this.connected.camera = serial;
|
||||||
this.connected.light = device;
|
this.connected.light = serial;
|
||||||
this.arduino.aliasSerial('camera', device);
|
this.arduino.aliasSerial('camera', serial);
|
||||||
this.arduino.aliasSerial('light', device);
|
this.arduino.aliasSerial('light', serial);
|
||||||
try {
|
try {
|
||||||
connectSuccess = await this.arduino.connect('projector', device, false);
|
connectSuccess = await this.arduino.connect('projector', serial, false);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error('Error connecting to projector, camera and light', err);
|
this.log.error('Error connecting to projector, camera and light', err);
|
||||||
|
@ -244,12 +276,12 @@ class Devices {
|
||||||
}
|
}
|
||||||
this.log.info(`Connected to ${device} as PROJECTOR + CAMERA + LIGHT`, 'SERIAL', true, true);
|
this.log.info(`Connected to ${device} as PROJECTOR + CAMERA + LIGHT`, 'SERIAL', true, true);
|
||||||
}
|
}
|
||||||
else if (type === 'projector,camera') {
|
else if (device === 'projector,camera') {
|
||||||
this.connected.projector = device;
|
this.connected.projector = serial;
|
||||||
this.connected.camera = device;
|
this.connected.camera = serial;
|
||||||
this.arduino.aliasSerial('camera', device);
|
this.arduino.aliasSerial('camera', serial);
|
||||||
try {
|
try {
|
||||||
connectSuccess = await this.arduino.connect('projector', device, false);
|
connectSuccess = await this.arduino.connect('projector', serial, false);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error('Error connecting to projector and camera', err);
|
this.log.error('Error connecting to projector and camera', err);
|
||||||
|
@ -257,10 +289,10 @@ class Devices {
|
||||||
}
|
}
|
||||||
this.log.info(`Connected to ${device} as PROJECTOR + CAMERA`, 'SERIAL', true, true);
|
this.log.info(`Connected to ${device} as PROJECTOR + CAMERA`, 'SERIAL', true, true);
|
||||||
}
|
}
|
||||||
else if (type === 'projector_second') {
|
else if (device === 'projector_second') {
|
||||||
this.connected.projector_second = device;
|
this.connected.projector_second = serial;
|
||||||
try {
|
try {
|
||||||
connectSuccess = await this.arduino.connect('projector_second', device, false);
|
connectSuccess = await this.arduino.connect('projector_second', serial, false);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error('Error connecting to secondary projector', err);
|
this.log.error('Error connecting to secondary projector', err);
|
||||||
|
@ -268,115 +300,171 @@ class Devices {
|
||||||
}
|
}
|
||||||
this.log.info(`Connected to ${device} as PROJECTOR_SECOND`, 'SERIAL', true, true);
|
this.log.info(`Connected to ${device} as PROJECTOR_SECOND`, 'SERIAL', true, true);
|
||||||
}
|
}
|
||||||
else if (type === 'projector,projector_second') {
|
else if (device === 'projector,projector_second') {
|
||||||
this.connected.projector = device;
|
this.connected.projector = serial;
|
||||||
this.connected.projector_second = device;
|
this.connected.projector_second = serial;
|
||||||
this.arduino.aliasSerial('projector_second', device);
|
this.arduino.aliasSerial('projector_second', serial);
|
||||||
try {
|
try {
|
||||||
connectSuccess = await this.arduino.connect('projector', device, false);
|
connectSuccess = await this.arduino.connect('projector', serial, false);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error('Error connecting to projector and secondary projector', err);
|
this.log.error('Error connecting to projector and secondary projector', err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (type === 'camera_second') {
|
else if (device === 'camera_second') {
|
||||||
this.connected.camera_second = device;
|
this.connected.camera_second = serial;
|
||||||
try {
|
try {
|
||||||
connectSuccess = await this.arduino.connect('camera_second', device, false);
|
connectSuccess = await this.arduino.connect('camera_second', serial, false);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(err);
|
this.log.error(err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (type === 'camera,camera_second') {
|
else if (device === 'camera,camera_second') {
|
||||||
this.connected.camera = device;
|
this.connected.camera = serial;
|
||||||
this.connected.camera_second = device;
|
this.connected.camera_second = serial;
|
||||||
this.arduino.aliasSerial('camera_second', device);
|
this.arduino.aliasSerial('camera_second', serial);
|
||||||
try {
|
try {
|
||||||
connectSuccess = await this.arduino.connect('camera', device, false);
|
connectSuccess = await this.arduino.connect('camera', serial, false);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error('Error connecting to camera, camera_secondary and projector', err);
|
this.log.error('Error connecting to camera, camera_secondary and projector', err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ('camera,projector,projector_second') {
|
else if (device === 'camera,projector,projector_second') {
|
||||||
this.connected.camera = device;
|
this.connected.camera = serial;
|
||||||
this.connected.projector = device;
|
this.connected.projector = serial;
|
||||||
this.connected.projector_second = device;
|
this.connected.projector_second = serial;
|
||||||
this.arduino.aliasSerial('projector', device);
|
this.arduino.aliasSerial('projector', serial);
|
||||||
this.arduino.aliasSerial('projector_second', device);
|
this.arduino.aliasSerial('projector_second', serial);
|
||||||
try {
|
try {
|
||||||
connectSuccess = await this.arduino.connect('camera', device, false);
|
connectSuccess = await this.arduino.connect('camera', serial, false);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error('Error connecting to camera, projector and projector_second', err);
|
this.log.error('Error connecting to camera, projector and projector_second', err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ('camera,camera_second,projector') {
|
else if (device === 'camera,camera_second,projector') {
|
||||||
this.connected.camera = device;
|
this.connected.camera = serial;
|
||||||
this.connected.camera_second = device;
|
this.connected.camera_second = serial;
|
||||||
this.connected.projector = device;
|
this.connected.projector = serial;
|
||||||
this.arduino.aliasSerial('camera_second', device);
|
this.arduino.aliasSerial('camera_second', serial);
|
||||||
this.arduino.aliasSerial('projector', device);
|
this.arduino.aliasSerial('projector', serial);
|
||||||
try {
|
try {
|
||||||
connectSuccess = await this.arduino.connect('camera', device, false);
|
connectSuccess = await this.arduino.connect('camera', serial, false);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error('Error connecting to camera, camera_second and projector', err);
|
this.log.error('Error connecting to camera, camera_second and projector', err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ('camera,camera_second,projector,projector_second') {
|
else if (device === 'camera,camera_second,projector,projector_second') {
|
||||||
this.connected.camera = device;
|
this.connected.camera = serial;
|
||||||
this.connected.camera_second = device;
|
this.connected.camera_second = serial;
|
||||||
this.connected.projector = device;
|
this.connected.projector = serial;
|
||||||
this.connected.projector_second = device;
|
this.connected.projector_second = serial;
|
||||||
this.arduino.aliasSerial('camera_second', device);
|
this.arduino.aliasSerial('camera_second', serial);
|
||||||
this.arduino.aliasSerial('projector', device);
|
this.arduino.aliasSerial('projector', serial);
|
||||||
this.arduino.aliasSerial('projector_second', device);
|
this.arduino.aliasSerial('projector_second', serial);
|
||||||
try {
|
try {
|
||||||
connectSuccess = await this.arduino.connect('camera', device, false);
|
connectSuccess = await this.arduino.connect('camera', serial, false);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error('Error connecting to camera, camera_second, projector and projector_second', err);
|
this.log.error('Error connecting to camera, camera_second, projector and projector_second', err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (device === 'capper') {
|
||||||
|
this.connected.capper = serial;
|
||||||
|
try {
|
||||||
|
connectSuccess = await this.arduino.connect('capper', serial, false);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.log.error('Error connecting capper', err);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (device === 'camera,capper') {
|
||||||
|
this.connected.camera = serial;
|
||||||
|
this.connected.capper = serial;
|
||||||
|
this.arduino.aliasSerial('capper', serial);
|
||||||
|
try {
|
||||||
|
connectSuccess = await this.arduino.connect('camera', serial, false);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.log.error('Error connecting to camera and capper', err);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (device === 'camera,capper,projector') {
|
||||||
|
this.connected.camera = serial;
|
||||||
|
this.connected.capper = serial;
|
||||||
|
this.connected.projector = serial;
|
||||||
|
this.arduino.aliasSerial('capper', serial);
|
||||||
|
this.arduino.aliasSerial('projector', serial);
|
||||||
|
try {
|
||||||
|
connectSuccess = await this.arduino.connect('camera', serial, false);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.log.error('Error connecting to camera, capper and projector', err);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (device === 'camera,capper,projector,projector_second') {
|
||||||
|
this.connected.camera = serial;
|
||||||
|
this.connected.capper = serial;
|
||||||
|
this.connected.projector = serial;
|
||||||
|
this.connected.projector_second = serial;
|
||||||
|
this.arduino.aliasSerial('capper', serial);
|
||||||
|
this.arduino.aliasSerial('projector', serial);
|
||||||
|
this.arduino.aliasSerial('projector_second', serial);
|
||||||
|
try {
|
||||||
|
connectSuccess = await this.arduino.connect('camera', serial, false);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.log.error('Error connecting to camera, capper, projector and projector_second', err);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
return connectSuccess;
|
return connectSuccess;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
//Cases for 1 or 2 arduinos connected
|
//Cases for 1 or 2 arduinos connected
|
||||||
async all(devices) {
|
async all(serials) {
|
||||||
let c = {};
|
let c = {};
|
||||||
let p = {};
|
let p = {};
|
||||||
let l = {};
|
let l = {};
|
||||||
let type;
|
let device;
|
||||||
let d;
|
let d;
|
||||||
let cs = {};
|
let cs = {};
|
||||||
let ps = {};
|
let ps = {};
|
||||||
|
let capper = {};
|
||||||
let checklist = [];
|
let checklist = [];
|
||||||
|
let exposure;
|
||||||
|
let parts;
|
||||||
this.connected = {
|
this.connected = {
|
||||||
projector: false,
|
projector: false,
|
||||||
camera: false,
|
camera: false,
|
||||||
light: false,
|
light: false,
|
||||||
projector_second: false
|
projector_second: false,
|
||||||
|
capper: false
|
||||||
};
|
};
|
||||||
for (let device of devices) {
|
for (let serial of serials) {
|
||||||
try {
|
try {
|
||||||
type = await this.distinguish(device);
|
device = await this.distinguish(serial);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error('Error distinguishing device', err);
|
this.log.error('Error distinguishing device', err);
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await this.connectDevice(device, type);
|
await this.connectDevice(device, serial);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error('Error connecting to device', err);
|
this.log.error('Error connecting to device', err);
|
||||||
|
@ -387,56 +475,82 @@ class Devices {
|
||||||
if (!this.connected.projector) {
|
if (!this.connected.projector) {
|
||||||
await this.fakeProjector();
|
await this.fakeProjector();
|
||||||
}
|
}
|
||||||
|
else if (this.arduino.hasState['projector']) {
|
||||||
|
p.state = true;
|
||||||
|
}
|
||||||
p.arduino = this.connected.projector;
|
p.arduino = this.connected.projector;
|
||||||
if (!this.connected.camera) {
|
if (!this.connected.camera) {
|
||||||
await this.fakeCamera();
|
await this.fakeCamera();
|
||||||
}
|
}
|
||||||
|
else if (this.arduino.hasState['camera']) {
|
||||||
|
if (device.indexOf('camera') !== -1) {
|
||||||
|
parts = this.arduino.stateStr[device].split('G');
|
||||||
|
if (parts.length > 1) {
|
||||||
|
parts = parts[1].split('H');
|
||||||
|
exposure = parseInt(parts[0]);
|
||||||
|
if (!isNaN(exposure)) {
|
||||||
|
this.log.info(`Timing for [${device}] = ${exposure}`);
|
||||||
|
this.ui.send('timing', { c: 'c', ms: exposure });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
c.state = true;
|
||||||
|
c.exposure = true;
|
||||||
|
}
|
||||||
c.arduino = this.connected.camera;
|
c.arduino = this.connected.camera;
|
||||||
if (!this.connected.light) {
|
if (!this.connected.light) {
|
||||||
await this.fakeLight();
|
await this.fakeLight();
|
||||||
}
|
}
|
||||||
l.arduino = this.connected.light;
|
l.arduino = this.connected.light;
|
||||||
if (this.connected.camera_second) {
|
if (this.connected.camera_second) {
|
||||||
cs = { arduino: this.connected.camera_second };
|
cs.arduino = this.connected.camera_second;
|
||||||
}
|
}
|
||||||
if (this.connected.projector_second) {
|
if (this.connected.projector_second) {
|
||||||
ps = { arduino: this.connected.projector_second };
|
ps.arduino = this.connected.projector_second;
|
||||||
|
}
|
||||||
|
if (this.connected.capper) {
|
||||||
|
capper.arduino = this.connected.capper;
|
||||||
}
|
}
|
||||||
if (this.settings.state.camera && this.settings.state.camera.intval) {
|
if (this.settings.state.camera && this.settings.state.camera.intval) {
|
||||||
c.intval = this.settings.state.camera.intval;
|
c.intval = this.settings.state.camera.intval;
|
||||||
}
|
}
|
||||||
return this.ready(p, c, l, cs, ps);
|
return this.ready(p, c, l, cs, ps, capper);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
remember(which, device, type) {
|
remember(device, serial, type) {
|
||||||
let deviceEntry;
|
let deviceEntry;
|
||||||
const match = this.settings.state.devices.filter((dev) => {
|
const match = this.settings.state.devices.filter((dev) => {
|
||||||
if (dev[which] && dev[which] === device) {
|
if (typeof dev.device !== 'undefined' && dev.device === device &&
|
||||||
|
typeof dev.serial !== 'undefined' && dev.serial === serial) {
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (match.length === 0) {
|
if (match.length === 0) {
|
||||||
deviceEntry = {
|
deviceEntry = {
|
||||||
type: type
|
device,
|
||||||
|
type,
|
||||||
|
serial
|
||||||
};
|
};
|
||||||
deviceEntry[which] = device;
|
|
||||||
this.settings.state.devices.push(deviceEntry);
|
this.settings.state.devices.push(deviceEntry);
|
||||||
this.settings.update('devices', this.settings.state.devices);
|
this.settings.update('devices', this.settings.state.devices);
|
||||||
this.settings.save();
|
this.settings.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
ready(projector, camera, light, camera_second, projector_second) {
|
ready(projector, camera, light, camera_second, projector_second, capper) {
|
||||||
let args = {
|
let args = {
|
||||||
camera,
|
camera,
|
||||||
projector,
|
projector,
|
||||||
light,
|
light,
|
||||||
profile: this.settings.state.profile
|
profile: this.settings.state.profile
|
||||||
};
|
};
|
||||||
|
if (this.settings.state.timing) {
|
||||||
|
args.timing = this.settings.state.timing;
|
||||||
|
}
|
||||||
if (projector_second && projector_second.arduino) {
|
if (projector_second && projector_second.arduino) {
|
||||||
args.projector_second = projector_second;
|
args.projector_second = projector_second;
|
||||||
this.settings.update('projector_second', projector_second);
|
this.settings.update('projector_second', projector_second);
|
||||||
|
@ -452,6 +566,11 @@ class Devices {
|
||||||
this.mainWindow.setSize(800, 800);
|
this.mainWindow.setSize(800, 800);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (capper && capper.arduino) {
|
||||||
|
args.capper = capper;
|
||||||
|
this.mainWindow.setSize(800, 800);
|
||||||
|
this.settings.update('capper', capper);
|
||||||
|
}
|
||||||
this.settings.update('camera', camera);
|
this.settings.update('camera', camera);
|
||||||
this.settings.update('projector', projector);
|
this.settings.update('projector', projector);
|
||||||
this.settings.update('light', light);
|
this.settings.update('light', light);
|
||||||
|
@ -460,7 +579,6 @@ class Devices {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.exports = function (arduino, settings, mainWindow, cam) {
|
exports.Devices = Devices;
|
||||||
return new Devices(arduino, settings, mainWindow, cam);
|
module.exports = { Devices };
|
||||||
};
|
|
||||||
//# sourceMappingURL=index.js.map
|
//# sourceMappingURL=index.js.map
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,9 @@
|
||||||
|
<a name="module_lib/display"></a>
|
||||||
|
|
||||||
|
## lib/display
|
||||||
|
<a name="module_lib/display..electron_1"></a>
|
||||||
|
|
||||||
|
### lib/display~electron\_1
|
||||||
|
Provides features for displaying a full screen display of images for the digital module.
|
||||||
|
|
||||||
|
**Kind**: inner constant of [<code>lib/display</code>](#module_lib/display)
|
|
@ -0,0 +1,18 @@
|
||||||
|
import type { System } from 'system';
|
||||||
|
export declare class Display {
|
||||||
|
private platform;
|
||||||
|
private displays;
|
||||||
|
private display;
|
||||||
|
private tmpdir;
|
||||||
|
private wv;
|
||||||
|
constructor(sys: System);
|
||||||
|
open(): Promise<void>;
|
||||||
|
show(src: string): Promise<void>;
|
||||||
|
showPath(pathStr: string): Promise<unknown>;
|
||||||
|
hide(): void;
|
||||||
|
close(): Promise<boolean>;
|
||||||
|
focus(): Promise<boolean>;
|
||||||
|
field(ratio: number): Promise<boolean>;
|
||||||
|
meter(): Promise<boolean>;
|
||||||
|
change(id: string): void;
|
||||||
|
}
|
|
@ -1,23 +1,28 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.Display = void 0;
|
||||||
|
/**
|
||||||
|
* @module lib/display */
|
||||||
/**
|
/**
|
||||||
* @module display
|
|
||||||
* Provides features for displaying a full screen display of images for the digital module.
|
* Provides features for displaying a full screen display of images for the digital module.
|
||||||
**/
|
**/
|
||||||
|
const electron_1 = require("electron");
|
||||||
const path_1 = require("path");
|
const path_1 = require("path");
|
||||||
const url_1 = require("url");
|
const url_1 = require("url");
|
||||||
const delay_1 = require("delay");
|
const delay_1 = require("delay");
|
||||||
const { BrowserWindow } = require('electron');
|
const log_1 = require("log");
|
||||||
class WebView {
|
class WebView {
|
||||||
constructor(platform, display) {
|
constructor(platform, display) {
|
||||||
this.opened = false;
|
this.opened = false;
|
||||||
this.showing = false;
|
this.showing = false;
|
||||||
this.loadWait = {};
|
this.loadWait = {};
|
||||||
|
this.ipc = electron_1.ipcMain;
|
||||||
const prefs = {
|
const prefs = {
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: true,
|
nodeIntegration: true,
|
||||||
allowRunningInsecureContent: false,
|
allowRunningInsecureContent: false,
|
||||||
enableRemoteModule: true
|
//enableRemoteModule: true,
|
||||||
|
contextIsolation: false
|
||||||
},
|
},
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
|
@ -25,16 +30,18 @@ class WebView {
|
||||||
minHeight: 600 //,
|
minHeight: 600 //,
|
||||||
//icon: path.join(__dirname, '../../assets/icons/icon.png')
|
//icon: path.join(__dirname, '../../assets/icons/icon.png')
|
||||||
};
|
};
|
||||||
const pagePath = path_1.normalize(path_1.join(__dirname, '../../display.html'));
|
const pagePath = (0, path_1.normalize)((0, path_1.join)(__dirname, '../../display.html'));
|
||||||
const pageUrl = url_1.format({
|
const pageUrl = (0, url_1.format)({
|
||||||
pathname: pagePath,
|
pathname: pagePath,
|
||||||
protocol: 'file:'
|
protocol: 'file:'
|
||||||
});
|
});
|
||||||
|
this.init();
|
||||||
if (!display.primary) {
|
if (!display.primary) {
|
||||||
prefs.x = display.x + 50;
|
prefs.x = display.x + 50;
|
||||||
prefs.y = display.y + 50;
|
prefs.y = display.y + 50;
|
||||||
}
|
}
|
||||||
this.digitalWindow = new BrowserWindow(prefs);
|
this.digitalWindow = new electron_1.BrowserWindow(prefs);
|
||||||
|
require('@electron/remote/main').enable(this.digitalWindow.webContents);
|
||||||
this.digitalWindow.loadURL(pageUrl);
|
this.digitalWindow.loadURL(pageUrl);
|
||||||
if (process.argv.indexOf('-d') !== -1 || process.argv.indexOf('--dev') !== -1) {
|
if (process.argv.indexOf('-d') !== -1 || process.argv.indexOf('--dev') !== -1) {
|
||||||
this.digitalWindow.webContents.openDevTools();
|
this.digitalWindow.webContents.openDevTools();
|
||||||
|
@ -46,30 +53,32 @@ class WebView {
|
||||||
//this.digitalWindow.hide();
|
//this.digitalWindow.hide();
|
||||||
this.platform = platform;
|
this.platform = platform;
|
||||||
this.display = display;
|
this.display = display;
|
||||||
this.ipc = require('electron').ipcMain;
|
|
||||||
this.ipc.on('display_load', this.onLoad.bind(this));
|
this.ipc.on('display_load', this.onLoad.bind(this));
|
||||||
}
|
}
|
||||||
|
async init() {
|
||||||
|
this.log = await (0, log_1.Log)({ label: 'devices' });
|
||||||
|
}
|
||||||
async open() {
|
async open() {
|
||||||
this.digitalWindow.show();
|
this.digitalWindow.show();
|
||||||
this.showing = true;
|
this.showing = true;
|
||||||
this.opened = true;
|
this.opened = true;
|
||||||
await this.digitalWindow.setFullScreen(true);
|
await this.digitalWindow.setFullScreen(true);
|
||||||
await delay_1.delay(300);
|
await (0, delay_1.delay)(300);
|
||||||
if (this.platform === 'osx') {
|
if (this.platform === 'osx') {
|
||||||
await delay_1.delay(300); //give macs an extra 300ms to open fullscreen
|
await (0, delay_1.delay)(300); //give macs an extra 300ms to open fullscreen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async show(src) {
|
async show(src) {
|
||||||
const normalSrc = path_1.normalize(path_1.join(src));
|
const normalSrc = (0, path_1.normalize)((0, path_1.join)(src));
|
||||||
if (!this.digitalWindow) {
|
if (!this.digitalWindow) {
|
||||||
console.warn(`Cannot show "${src}" because window does not exist`);
|
this.log.warn(`Cannot show "${src}" because window does not exist`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
this.digitalWindow.webContents.send('display', { src: normalSrc });
|
this.digitalWindow.webContents.send('display', { src: normalSrc });
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(err);
|
this.log.error(err);
|
||||||
}
|
}
|
||||||
this.showing = true;
|
this.showing = true;
|
||||||
return new Promise(function (resolve) {
|
return new Promise(function (resolve) {
|
||||||
|
@ -84,41 +93,41 @@ class WebView {
|
||||||
}
|
}
|
||||||
async focus() {
|
async focus() {
|
||||||
if (!this.digitalWindow) {
|
if (!this.digitalWindow) {
|
||||||
console.warn(`Cannot show focus screen because window does not exist`);
|
this.log.warn(`Cannot show focus screen because window does not exist`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
await delay_1.delay(500);
|
await (0, delay_1.delay)(500);
|
||||||
try {
|
try {
|
||||||
this.digitalWindow.webContents.send('focus', { focus: true });
|
this.digitalWindow.webContents.send('focus', { focus: true });
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(err);
|
this.log.error(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async field(ratio) {
|
async field(ratio) {
|
||||||
if (!this.digitalWindow) {
|
if (!this.digitalWindow) {
|
||||||
console.warn(`Cannot show field guide because window does not exist`);
|
this.log.warn(`Cannot show field guide because window does not exist`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
await delay_1.delay(500);
|
await (0, delay_1.delay)(500);
|
||||||
try {
|
try {
|
||||||
this.digitalWindow.webContents.send('field', { field: true, ratio });
|
this.digitalWindow.webContents.send('field', { field: true, ratio });
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(err);
|
this.log.error(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async meter() {
|
async meter() {
|
||||||
if (!this.digitalWindow) {
|
if (!this.digitalWindow) {
|
||||||
console.warn(`Cannot show meter screen because window does not exist`);
|
this.log.warn(`Cannot show meter screen because window does not exist`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
await delay_1.delay(500);
|
await (0, delay_1.delay)(500);
|
||||||
try {
|
try {
|
||||||
this.digitalWindow.webContents.send('meter', { meter: true });
|
this.digitalWindow.webContents.send('meter', { meter: true });
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(err);
|
this.log.error(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hide() {
|
hide() {
|
||||||
|
@ -143,7 +152,7 @@ class Display {
|
||||||
constructor(sys) {
|
constructor(sys) {
|
||||||
this.platform = sys.platform;
|
this.platform = sys.platform;
|
||||||
this.displays = sys.displays;
|
this.displays = sys.displays;
|
||||||
this.tmpdir = path_1.join(sys.tmp, 'mcopy_digital');
|
this.tmpdir = (0, path_1.join)(sys.tmp, 'mcopy_digital');
|
||||||
this.display = this.displays.find((display) => {
|
this.display = this.displays.find((display) => {
|
||||||
if (display.primary)
|
if (display.primary)
|
||||||
return true;
|
return true;
|
||||||
|
@ -185,7 +194,6 @@ class Display {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.exports = function (sys) {
|
exports.Display = Display;
|
||||||
return new Display(sys);
|
module.exports = { Display };
|
||||||
};
|
|
||||||
//# sourceMappingURL=index.js.map
|
//# sourceMappingURL=index.js.map
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,17 @@
|
||||||
|
interface ExecOutput {
|
||||||
|
stdout: string;
|
||||||
|
stderr: string;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Promisified child_process.exec
|
||||||
|
*
|
||||||
|
* @param cmd
|
||||||
|
* @param arg
|
||||||
|
* @param opts See child_process.exec node docs
|
||||||
|
* @param {stream.Writable} opts.stdout If defined, child process stdout will be piped to it.
|
||||||
|
* @param {stream.Writable} opts.stderr If defined, child process stderr will be piped to it.
|
||||||
|
*
|
||||||
|
* @returns {Promise<{ stdout: string, stderr: stderr }>}
|
||||||
|
*/
|
||||||
|
export declare function exec(...args: string[]): Promise<ExecOutput>;
|
||||||
|
export type { ExecOutput };
|
|
@ -1,5 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
const execRaw = require('child_process').exec;
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.exec = void 0;
|
||||||
|
const child_process_1 = require("child_process");
|
||||||
/**
|
/**
|
||||||
* Promisified child_process.exec
|
* Promisified child_process.exec
|
||||||
*
|
*
|
||||||
|
@ -28,7 +30,7 @@ async function exec(...args) {
|
||||||
opts = { maxBuffer: 1024 * 1024 };
|
opts = { maxBuffer: 1024 * 1024 };
|
||||||
}
|
}
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const child = execRaw(cmd, opts, (err, stdout, stderr) => err ? reject(err) : resolve({
|
const child = (0, child_process_1.exec)(cmd, opts, (err, stdout, stderr) => err ? reject(err) : resolve({
|
||||||
stdout,
|
stdout,
|
||||||
stderr
|
stderr
|
||||||
}));
|
}));
|
||||||
|
@ -40,5 +42,6 @@ async function exec(...args) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
module.exports.exec = exec;
|
exports.exec = exec;
|
||||||
|
module.exports = { exec };
|
||||||
//# sourceMappingURL=index.js.map
|
//# sourceMappingURL=index.js.map
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exec/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,IAAI,CAAA;AAE7C;;;;;;;;;;GAUG;AACH,KAAK,UAAU,IAAI,CAAC,GAAG,IAAe;IACrC,IAAI,GAAG,GAAY,IAAI,CAAC,CAAC,CAAC,CAAA;IAC1B,IAAI,IAAI,GAAY,IAAI,CAAA;IACxB,IAAI,IAAI,GAAS,IAAI,CAAA;IAErB,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;QAC1D,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;KACd;IACD,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;QACjD,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;KACd;SAAM,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;QACvC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;KACd;IACD,IAAI,IAAI,KAAK,IAAI,EAAE;QAClB,IAAI,GAAG,EAAE,SAAS,EAAG,IAAI,GAAG,IAAI,EAAE,CAAA;KAClC;IACE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACtC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE,IAAI,EACjC,CAAC,GAAW,EAAE,MAAe,EAAE,MAAc,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;YAC7E,MAAM;YACN,MAAM;SACN,CAAC,CAAC,CAAC;QACC,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAClC;QACD,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAClC;IACL,CAAC,CAAC,CAAC;AACP,CAAC;AAED,MAAM,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAA"}
|
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exec/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;;;AAEZ,iDAA+C;AAO/C;;;;;;;;;;GAUG;AACI,KAAK,UAAU,IAAI,CAAC,GAAG,IAAe;IAC5C,IAAI,GAAG,GAAY,IAAI,CAAC,CAAC,CAAC,CAAA;IAC1B,IAAI,IAAI,GAAY,IAAI,CAAA;IACxB,IAAI,IAAI,GAAS,IAAI,CAAA;IAErB,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;QAC1D,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;KACd;IACD,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;QACjD,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;KACd;SAAM,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;QACvC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;KACd;IACD,IAAI,IAAI,KAAK,IAAI,EAAE;QAClB,IAAI,GAAG,EAAE,SAAS,EAAG,IAAI,GAAG,IAAI,EAAE,CAAA;KAClC;IACE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAkB,EAAE,MAAiB,EAAE,EAAE;QAC5D,MAAM,KAAK,GAAG,IAAA,oBAAO,EAAC,GAAG,EAAE,IAAI,EACjC,CAAC,GAAW,EAAE,MAAe,EAAE,MAAc,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;YAC7E,MAAM;YACN,MAAM;SACN,CAAC,CAAC,CAAC;QACC,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAClC;QACD,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAClC;IACL,CAAC,CAAC,CAAC;AACP,CAAC;AA7BD,oBA6BC;AAED,MAAM,CAAC,OAAO,GAAG,EAAE,IAAI,EAAE,CAAA"}
|
|
@ -0,0 +1,8 @@
|
||||||
|
/**
|
||||||
|
* Exit process with either a 0 code or other
|
||||||
|
* specified failure code. Print message to console first.
|
||||||
|
*
|
||||||
|
* @param {string} msg Reason for exit
|
||||||
|
* @param {integer} code process exit code, default 0
|
||||||
|
**/
|
||||||
|
declare function exit(msg: string, code?: number): void;
|
|
@ -16,5 +16,5 @@ function exit(msg, code = 0) {
|
||||||
process.exit(code);
|
process.exit(code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.exports.exit = exit;
|
module.exports = { exit };
|
||||||
//# sourceMappingURL=index.js.map
|
//# sourceMappingURL=index.js.map
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exit/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb;;;;;;IAMI;AAEJ,SAAS,IAAI,CAAE,GAAY,EAAE,OAAgB,CAAC;IAC7C,IAAI,IAAI,KAAK,CAAC,EAAE;QACf,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACjB,OAAO,CAAC,IAAI,EAAE,CAAC;KACf;SAAM;QACN,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACnB;AACF,CAAC;AAED,MAAM,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC"}
|
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exit/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb;;;;;;IAMI;AAEJ,SAAS,IAAI,CAAE,GAAY,EAAE,OAAgB,CAAC;IAC7C,IAAI,IAAI,KAAK,CAAC,EAAE;QACf,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACjB,OAAO,CAAC,IAAI,EAAE,CAAC;KACf;SAAM;QACN,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACnB;AACF,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,EAAE,IAAI,EAAE,CAAC"}
|
|
@ -0,0 +1,138 @@
|
||||||
|
## Modules
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><a href="#module_ffmpeg">ffmpeg</a></dt>
|
||||||
|
<dd></dd>
|
||||||
|
<dt><a href="#module_lib/ffmpeg">lib/ffmpeg</a></dt>
|
||||||
|
<dd></dd>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<a name="module_ffmpeg"></a>
|
||||||
|
|
||||||
|
## ffmpeg
|
||||||
|
<a name="module_lib/ffmpeg"></a>
|
||||||
|
|
||||||
|
## lib/ffmpeg
|
||||||
|
|
||||||
|
* [lib/ffmpeg](#module_lib/ffmpeg)
|
||||||
|
* [~Creates an ffmpeg class](#module_lib/ffmpeg..Creates an ffmpeg class)
|
||||||
|
* [new Creates an ffmpeg class(sys)](#new_module_lib/ffmpeg..Creates an ffmpeg class_new)
|
||||||
|
* [~FFMPEG](#module_lib/ffmpeg..FFMPEG)
|
||||||
|
* [.init()](#module_lib/ffmpeg..FFMPEG+init)
|
||||||
|
* [.padded_frame(i)](#module_lib/ffmpeg..FFMPEG+padded_frame) ⇒ <code>string</code>
|
||||||
|
* [.parseStderr(line)](#module_lib/ffmpeg..FFMPEG+parseStderr)
|
||||||
|
* [.frame(state, light)](#module_lib/ffmpeg..FFMPEG+frame) ⇒ <code>string</code>
|
||||||
|
* [.frames(video, obj)](#module_lib/ffmpeg..FFMPEG+frames) ⇒ <code>?</code>
|
||||||
|
* [.clear(frame)](#module_lib/ffmpeg..FFMPEG+clear) ⇒ <code>boolean</code>
|
||||||
|
* [.clearAll()](#module_lib/ffmpeg..FFMPEG+clearAll)
|
||||||
|
* [.checkDir()](#module_lib/ffmpeg..FFMPEG+checkDir)
|
||||||
|
|
||||||
|
<a name="module_lib/ffmpeg..Creates an ffmpeg class"></a>
|
||||||
|
|
||||||
|
### lib/ffmpeg~Creates an ffmpeg class
|
||||||
|
**Kind**: inner class of [<code>lib/ffmpeg</code>](#module_lib/ffmpeg)
|
||||||
|
<a name="new_module_lib/ffmpeg..Creates an ffmpeg class_new"></a>
|
||||||
|
|
||||||
|
#### new Creates an ffmpeg class(sys)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| sys | <code>object</code> | System object to be used to get temp directory |
|
||||||
|
|
||||||
|
<a name="module_lib/ffmpeg..FFMPEG"></a>
|
||||||
|
|
||||||
|
### lib/ffmpeg~FFMPEG
|
||||||
|
Class representing all ffmpeg features.
|
||||||
|
|
||||||
|
**Kind**: inner class of [<code>lib/ffmpeg</code>](#module_lib/ffmpeg)
|
||||||
|
|
||||||
|
* [~FFMPEG](#module_lib/ffmpeg..FFMPEG)
|
||||||
|
* [.init()](#module_lib/ffmpeg..FFMPEG+init)
|
||||||
|
* [.padded_frame(i)](#module_lib/ffmpeg..FFMPEG+padded_frame) ⇒ <code>string</code>
|
||||||
|
* [.parseStderr(line)](#module_lib/ffmpeg..FFMPEG+parseStderr)
|
||||||
|
* [.frame(state, light)](#module_lib/ffmpeg..FFMPEG+frame) ⇒ <code>string</code>
|
||||||
|
* [.frames(video, obj)](#module_lib/ffmpeg..FFMPEG+frames) ⇒ <code>?</code>
|
||||||
|
* [.clear(frame)](#module_lib/ffmpeg..FFMPEG+clear) ⇒ <code>boolean</code>
|
||||||
|
* [.clearAll()](#module_lib/ffmpeg..FFMPEG+clearAll)
|
||||||
|
* [.checkDir()](#module_lib/ffmpeg..FFMPEG+checkDir)
|
||||||
|
|
||||||
|
<a name="module_lib/ffmpeg..FFMPEG+init"></a>
|
||||||
|
|
||||||
|
#### ffmpeG.init()
|
||||||
|
Async method to call async functions from constructor
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>FFMPEG</code>](#module_lib/ffmpeg..FFMPEG)
|
||||||
|
<a name="module_lib/ffmpeg..FFMPEG+padded_frame"></a>
|
||||||
|
|
||||||
|
#### ffmpeG.padded\_frame(i) ⇒ <code>string</code>
|
||||||
|
Add padding to a number to 5 places. Return a string.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>FFMPEG</code>](#module_lib/ffmpeg..FFMPEG)
|
||||||
|
**Returns**: <code>string</code> - Padded string
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| i | <code>integer</code> | Integer to pad |
|
||||||
|
|
||||||
|
<a name="module_lib/ffmpeg..FFMPEG+parseStderr"></a>
|
||||||
|
|
||||||
|
#### ffmpeG.parseStderr(line)
|
||||||
|
Parse the stderr output of ffmpeg
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>FFMPEG</code>](#module_lib/ffmpeg..FFMPEG)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| line | <code>string</code> | Stderr line |
|
||||||
|
|
||||||
|
<a name="module_lib/ffmpeg..FFMPEG+frame"></a>
|
||||||
|
|
||||||
|
#### ffmpeG.frame(state, light) ⇒ <code>string</code>
|
||||||
|
Render a single frame from a video or image to a png.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>FFMPEG</code>](#module_lib/ffmpeg..FFMPEG)
|
||||||
|
**Returns**: <code>string</code> - Path of frame
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| state | <code>object</code> | State object containing file data |
|
||||||
|
| light | <code>object</code> | Object containing color information for frame |
|
||||||
|
|
||||||
|
<a name="module_lib/ffmpeg..FFMPEG+frames"></a>
|
||||||
|
|
||||||
|
#### ffmpeG.frames(video, obj) ⇒ <code>?</code>
|
||||||
|
Render all frames in a video to the temp directory.
|
||||||
|
Not in use.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>FFMPEG</code>](#module_lib/ffmpeg..FFMPEG)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| video | <code>string</code> | Path to video |
|
||||||
|
| obj | <code>object</code> | Not sure |
|
||||||
|
|
||||||
|
<a name="module_lib/ffmpeg..FFMPEG+clear"></a>
|
||||||
|
|
||||||
|
#### ffmpeG.clear(frame) ⇒ <code>boolean</code>
|
||||||
|
Clears a specific frame from the tmp directory
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>FFMPEG</code>](#module_lib/ffmpeg..FFMPEG)
|
||||||
|
**Returns**: <code>boolean</code> - True if successful, false if not
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| frame | <code>integer</code> | Integer of frame to clear |
|
||||||
|
|
||||||
|
<a name="module_lib/ffmpeg..FFMPEG+clearAll"></a>
|
||||||
|
|
||||||
|
#### ffmpeG.clearAll()
|
||||||
|
Deletes all frames in temp directory.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>FFMPEG</code>](#module_lib/ffmpeg..FFMPEG)
|
||||||
|
<a name="module_lib/ffmpeg..FFMPEG+checkDir"></a>
|
||||||
|
|
||||||
|
#### ffmpeG.checkDir()
|
||||||
|
Checks if mcopy temp directory exists. If it doesn't,
|
||||||
|
creates it.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>FFMPEG</code>](#module_lib/ffmpeg..FFMPEG)
|
|
@ -0,0 +1,89 @@
|
||||||
|
import type { FilmOutState } from 'filmout';
|
||||||
|
import type { System } from 'system';
|
||||||
|
import type { LightState } from 'light';
|
||||||
|
interface StdErr {
|
||||||
|
frame: number;
|
||||||
|
fps: number;
|
||||||
|
time: string;
|
||||||
|
speed: number;
|
||||||
|
size: string;
|
||||||
|
remaining?: number;
|
||||||
|
progress?: number;
|
||||||
|
estimated?: number;
|
||||||
|
}
|
||||||
|
/** @module lib/ffmpeg */
|
||||||
|
/**
|
||||||
|
* Class representing all ffmpeg features.
|
||||||
|
*/
|
||||||
|
export declare class FFMPEG {
|
||||||
|
private bin;
|
||||||
|
private log;
|
||||||
|
private id;
|
||||||
|
private TMPDIR;
|
||||||
|
private child;
|
||||||
|
onProgress: Function;
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* Creates an ffmpeg class
|
||||||
|
*
|
||||||
|
* @param {object} sys System object to be used to get temp directory
|
||||||
|
**/
|
||||||
|
constructor(sys: System);
|
||||||
|
/**
|
||||||
|
* Async method to call async functions from constructor
|
||||||
|
**/
|
||||||
|
init(): Promise<void>;
|
||||||
|
/**
|
||||||
|
* Add padding to a number to 5 places. Return a string.
|
||||||
|
*
|
||||||
|
* @param {integer} i Integer to pad
|
||||||
|
*
|
||||||
|
* @returns {string} Padded string
|
||||||
|
**/
|
||||||
|
private padded_frame;
|
||||||
|
/**
|
||||||
|
* Parse the stderr output of ffmpeg
|
||||||
|
*
|
||||||
|
* @param {string} line Stderr line
|
||||||
|
**/
|
||||||
|
private parseStderr;
|
||||||
|
/**
|
||||||
|
* Render a single frame from a video or image to a png.
|
||||||
|
*
|
||||||
|
* @param {object} state State object containing file data
|
||||||
|
* @param {object} light Object containing color information for frame
|
||||||
|
*
|
||||||
|
* @returns {string} Path of frame
|
||||||
|
**/
|
||||||
|
frame(state: FilmOutState, light: LightState): Promise<string>;
|
||||||
|
/**
|
||||||
|
* Render all frames in a video to the temp directory.
|
||||||
|
* Not in use.
|
||||||
|
*
|
||||||
|
* @param {string} video Path to video
|
||||||
|
* @param {object} obj Not sure
|
||||||
|
*
|
||||||
|
* @returns {?}
|
||||||
|
**/
|
||||||
|
frames(state: FilmOutState): Promise<unknown>;
|
||||||
|
cancel(): void;
|
||||||
|
/**
|
||||||
|
* Clears a specific frame from the tmp directory
|
||||||
|
*
|
||||||
|
* @param {integer} frame Integer of frame to clear
|
||||||
|
*
|
||||||
|
* @returns {boolean} True if successful, false if not
|
||||||
|
**/
|
||||||
|
clear(state: any): Promise<boolean>;
|
||||||
|
/**
|
||||||
|
* Deletes all frames in temp directory.
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
clearAll(): Promise<void>;
|
||||||
|
/**
|
||||||
|
* Checks if mcopy temp directory exists. If it doesn't,
|
||||||
|
* creates it.
|
||||||
|
**/
|
||||||
|
private checkDir;
|
||||||
|
}
|
||||||
|
export type { StdErr };
|
|
@ -1,35 +1,16 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.FFMPEG = void 0;
|
||||||
/** @module ffmpeg **/
|
/** @module ffmpeg **/
|
||||||
const path_1 = require("path");
|
const path_1 = require("path");
|
||||||
const fs_extra_1 = require("fs-extra");
|
const fs_extra_1 = require("fs-extra");
|
||||||
const exec_1 = require("exec");
|
const exec_1 = require("exec");
|
||||||
const child_process_1 = require("child_process");
|
const child_process_1 = require("child_process");
|
||||||
async function spawnAsync(bin, args) {
|
const log_1 = require("log");
|
||||||
return new Promise((resolve, reject) => {
|
/** @module lib/ffmpeg */
|
||||||
const child = child_process_1.spawn(bin, args);
|
/**
|
||||||
let stdout = '';
|
* Class representing all ffmpeg features.
|
||||||
let stderr = '';
|
*/
|
||||||
child.on('exit', (code) => {
|
|
||||||
if (code === 0) {
|
|
||||||
return resolve({ stdout, stderr });
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.error(`Process exited with code: ${code}`);
|
|
||||||
console.error(stderr);
|
|
||||||
return reject(stderr);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
child.stdout.on('data', (data) => {
|
|
||||||
stdout += data;
|
|
||||||
});
|
|
||||||
child.stderr.on('data', (data) => {
|
|
||||||
stderr += data;
|
|
||||||
});
|
|
||||||
return child;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/** @class FFMPEG **/
|
|
||||||
class FFMPEG {
|
class FFMPEG {
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
|
@ -41,15 +22,14 @@ class FFMPEG {
|
||||||
this.id = 'ffmpeg';
|
this.id = 'ffmpeg';
|
||||||
this.onProgress = () => { };
|
this.onProgress = () => { };
|
||||||
this.bin = sys.deps.ffmpeg;
|
this.bin = sys.deps.ffmpeg;
|
||||||
this.TMPDIR = path_1.join(sys.tmp, 'mcopy_digital');
|
this.TMPDIR = (0, path_1.join)(sys.tmp, 'mcopy_digital');
|
||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Async method to call async functions from constructor
|
* Async method to call async functions from constructor
|
||||||
**/
|
**/
|
||||||
async init() {
|
async init() {
|
||||||
const Log = require('log');
|
this.log = await (0, log_1.Log)({ label: this.id });
|
||||||
this.log = await Log({ label: this.id });
|
|
||||||
await this.checkDir();
|
await this.checkDir();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -74,21 +54,30 @@ class FFMPEG {
|
||||||
**/
|
**/
|
||||||
parseStderr(line) {
|
parseStderr(line) {
|
||||||
//frame= 6416 fps= 30 q=31.0 size= 10251kB time=00:03:34.32 bitrate= 391.8kbits/s speed= 1x
|
//frame= 6416 fps= 30 q=31.0 size= 10251kB time=00:03:34.32 bitrate= 391.8kbits/s speed= 1x
|
||||||
let obj = {};
|
const obj = {
|
||||||
|
frame: 0,
|
||||||
|
fps: 0,
|
||||||
|
time: '',
|
||||||
|
speed: 0,
|
||||||
|
size: ''
|
||||||
|
};
|
||||||
|
let frameStr;
|
||||||
|
let fpsStr;
|
||||||
|
let speedStr;
|
||||||
if (line.substring(0, 'frame='.length) === 'frame=') {
|
if (line.substring(0, 'frame='.length) === 'frame=') {
|
||||||
try {
|
try {
|
||||||
obj.frame = line.split('frame=')[1].split('fps=')[0];
|
frameStr = line.split('frame=')[1].split('fps=')[0];
|
||||||
obj.frame = parseInt(obj.frame);
|
obj.frame = parseInt(frameStr);
|
||||||
obj.fps = line.split('fps=')[1].split('q=')[0];
|
fpsStr = line.split('fps=')[1].split('q=')[0];
|
||||||
obj.fps = parseFloat(obj.fps);
|
obj.fps = parseFloat(fpsStr);
|
||||||
obj.time = line.split('time=')[1].split('bitrate=')[0];
|
obj.time = line.split('time=')[1].split('bitrate=')[0];
|
||||||
obj.speed = line.split('speed=')[1].trim().replace('x', '');
|
speedStr = line.split('speed=')[1].trim().replace('x', '');
|
||||||
obj.speed = parseFloat(obj.speed);
|
obj.speed = parseFloat(speedStr);
|
||||||
obj.size = line.split('size=')[1].split('time=')[0].trim();
|
obj.size = line.split('size=')[1].split('time=')[0].trim();
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(err);
|
this.log.error('Error parsing stderr line', err);
|
||||||
console.log(line);
|
this.log.info(line);
|
||||||
process.exit();
|
process.exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,7 +101,7 @@ class FFMPEG {
|
||||||
const padded = this.padded_frame(frameNum);
|
const padded = this.padded_frame(frameNum);
|
||||||
let ext = 'png';
|
let ext = 'png';
|
||||||
let rgb = light.color;
|
let rgb = light.color;
|
||||||
let rgba = {};
|
let rgba;
|
||||||
let tmpoutput;
|
let tmpoutput;
|
||||||
let cmd;
|
let cmd;
|
||||||
let output;
|
let output;
|
||||||
|
@ -124,9 +113,9 @@ class FFMPEG {
|
||||||
if (w && h) {
|
if (w && h) {
|
||||||
scale = `,scale=trunc(ih*dar):${h}`; //:force_original_aspect_ratio=decrease,pad=${w}:${h}:(ow-iw)/2:(oh-ih)/2
|
scale = `,scale=trunc(ih*dar):${h}`; //:force_original_aspect_ratio=decrease,pad=${w}:${h}:(ow-iw)/2:(oh-ih)/2
|
||||||
}
|
}
|
||||||
tmpoutput = path_1.join(this.TMPDIR, `${state.hash}-export-${padded}.${ext}`);
|
tmpoutput = (0, path_1.join)(this.TMPDIR, `${state.hash}-export-${padded}.${ext}`);
|
||||||
try {
|
try {
|
||||||
fileExists = await fs_extra_1.exists(tmpoutput);
|
fileExists = await (0, fs_extra_1.exists)(tmpoutput);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
//
|
//
|
||||||
|
@ -136,14 +125,14 @@ class FFMPEG {
|
||||||
return tmpoutput;
|
return tmpoutput;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
cmd = `${this.bin} -y -i "${video}" -vf "select='gte(n\\,${frameNum})'${scale}" -vframes 1 -compression_algo raw -pix_fmt rgb24 -crf 0 "${tmpoutput}"`;
|
cmd = `${this.bin} -hwaccel auto -y -i "${video}" -vf "select='gte(n\\,${frameNum})'${scale}" -vframes 1 -compression_algo raw -pix_fmt rgb24 -crf 0 "${tmpoutput}"`;
|
||||||
//cmd2 = `${this.convert} "${tmpoutput}" -resize ${w}x${h} -size ${w}x${h} xc:"rgb(${rgb[0]},${rgb[1]},${rgb[2]})" +swap -compose Darken -composite "${tmpoutput}"`;
|
//cmd2 = `${this.convert} "${tmpoutput}" -resize ${w}x${h} -size ${w}x${h} xc:"rgb(${rgb[0]},${rgb[1]},${rgb[2]})" +swap -compose Darken -composite "${tmpoutput}"`;
|
||||||
//ffmpeg -i "${video}" -ss 00:00:07.000 -vframes 1 "export-${time}.jpg"
|
//ffmpeg -i "${video}" -ss 00:00:07.000 -vframes 1 "export-${time}.jpg"
|
||||||
//ffmpeg -i "${video}" -compression_algo raw -pix_fmt rgb24 "export-%05d.tiff"
|
//ffmpeg -i "${video}" -compression_algo raw -pix_fmt rgb24 "export-%05d.tiff"
|
||||||
//-vf "select=gte(n\,${frame})" -compression_algo raw -pix_fmt rgb24 "export-${padded}.png"
|
//-vf "select=gte(n\,${frame})" -compression_algo raw -pix_fmt rgb24 "export-${padded}.png"
|
||||||
try {
|
try {
|
||||||
this.log.info(cmd);
|
this.log.info(cmd);
|
||||||
output = await exec_1.exec(cmd);
|
output = await (0, exec_1.exec)(cmd);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error(err);
|
this.log.error(err);
|
||||||
|
@ -152,7 +141,7 @@ class FFMPEG {
|
||||||
this.log.info(`"${output.stdout.trim()}"`);
|
this.log.info(`"${output.stdout.trim()}"`);
|
||||||
if (rgb[0] !== 255 || rgb[1] !== 255 || rgb[2] !== 255) {
|
if (rgb[0] !== 255 || rgb[1] !== 255 || rgb[2] !== 255) {
|
||||||
rgb = rgb.map((e) => {
|
rgb = rgb.map((e) => {
|
||||||
return parseInt(e);
|
return typeof e === 'string' ? parseInt(e) : e;
|
||||||
});
|
});
|
||||||
rgba = { r: rgb[0], g: rgb[1], b: rgb[2], a: 255 };
|
rgba = { r: rgb[0], g: rgb[1], b: rgb[2], a: 255 };
|
||||||
try {
|
try {
|
||||||
|
@ -179,12 +168,14 @@ class FFMPEG {
|
||||||
const h = state.info.height;
|
const h = state.info.height;
|
||||||
const tmppath = this.TMPDIR;
|
const tmppath = this.TMPDIR;
|
||||||
let ext = 'png';
|
let ext = 'png';
|
||||||
let tmpoutput = path_1.join(tmppath, `${state.hash}-export-%08d.${ext}`);
|
let tmpoutput = (0, path_1.join)(tmppath, `${state.hash}-export-%08d.${ext}`);
|
||||||
let args;
|
let args;
|
||||||
let output;
|
let output;
|
||||||
let estimated = -1;
|
let estimated = -1;
|
||||||
//cmd = `${this.bin} -y -i "${video}" -vf "${scale}" -compression_algo raw -pix_fmt rgb24 -crf 0 "${tmpoutput}"`;
|
//cmd = `${this.bin} -y -i "${video}" -vf "${scale}" -compression_algo raw -pix_fmt rgb24 -crf 0 "${tmpoutput}"`;
|
||||||
args = [
|
args = [
|
||||||
|
'-hwaccel',
|
||||||
|
'auto',
|
||||||
'-y',
|
'-y',
|
||||||
'-i', video
|
'-i', video
|
||||||
];
|
];
|
||||||
|
@ -201,7 +192,7 @@ class FFMPEG {
|
||||||
//console.dir(args)
|
//console.dir(args)
|
||||||
//console.dir(state)
|
//console.dir(state)
|
||||||
try {
|
try {
|
||||||
await fs_extra_1.mkdir(tmppath);
|
await (0, fs_extra_1.mkdir)(tmppath);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
if (err.code && err.code === 'EEXIST') {
|
if (err.code && err.code === 'EEXIST') {
|
||||||
|
@ -216,20 +207,20 @@ class FFMPEG {
|
||||||
let stdout = '';
|
let stdout = '';
|
||||||
let stderr = '';
|
let stderr = '';
|
||||||
this.log.info(`${this.bin} ${args.join(' ')}`);
|
this.log.info(`${this.bin} ${args.join(' ')}`);
|
||||||
this.child = child_process_1.spawn(this.bin, args);
|
this.child = (0, child_process_1.spawn)(this.bin, args);
|
||||||
this.child.on('exit', (code) => {
|
this.child.on('exit', function (code) {
|
||||||
//console.log('GOT TO EXIT');
|
//console.log('GOT TO EXIT');
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
console.log(stderr);
|
this.log.info(stderr);
|
||||||
console.log(stdout);
|
this.log.info(stdout);
|
||||||
return resolve(true);
|
return resolve(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.error(`Process exited with code: ${code}`);
|
this.log.error(`Process exited with code: ${code}`);
|
||||||
console.error(stderr);
|
this.log.error(stderr);
|
||||||
return reject(stderr + stdout);
|
return reject(stderr + stdout);
|
||||||
}
|
}
|
||||||
});
|
}.bind(this));
|
||||||
this.child.stdout.on('data', (data) => {
|
this.child.stdout.on('data', (data) => {
|
||||||
const line = data.toString();
|
const line = data.toString();
|
||||||
stdout += line;
|
stdout += line;
|
||||||
|
@ -273,9 +264,9 @@ class FFMPEG {
|
||||||
let ext = 'png';
|
let ext = 'png';
|
||||||
let tmppath;
|
let tmppath;
|
||||||
let fileExists;
|
let fileExists;
|
||||||
tmppath = path_1.join(this.TMPDIR, `${state.hash}-export-${padded}.${ext}`);
|
tmppath = (0, path_1.join)(this.TMPDIR, `${state.hash}-export-${padded}.${ext}`);
|
||||||
try {
|
try {
|
||||||
fileExists = await fs_extra_1.exists(tmppath);
|
fileExists = await (0, fs_extra_1.exists)(tmppath);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error(err);
|
this.log.error(err);
|
||||||
|
@ -283,7 +274,7 @@ class FFMPEG {
|
||||||
if (!fileExists)
|
if (!fileExists)
|
||||||
return false;
|
return false;
|
||||||
try {
|
try {
|
||||||
await fs_extra_1.unlink(tmppath);
|
await (0, fs_extra_1.unlink)(tmppath);
|
||||||
this.log.info(`Cleared frame ${tmppath}`);
|
this.log.info(`Cleared frame ${tmppath}`);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
@ -299,7 +290,7 @@ class FFMPEG {
|
||||||
const tmppath = this.TMPDIR;
|
const tmppath = this.TMPDIR;
|
||||||
let files;
|
let files;
|
||||||
try {
|
try {
|
||||||
files = await fs_extra_1.readdir(tmppath);
|
files = await (0, fs_extra_1.readdir)(tmppath);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error(err);
|
this.log.error(err);
|
||||||
|
@ -313,7 +304,7 @@ class FFMPEG {
|
||||||
if (files) {
|
if (files) {
|
||||||
files.forEach(async (file, index) => {
|
files.forEach(async (file, index) => {
|
||||||
try {
|
try {
|
||||||
await fs_extra_1.unlink(path_1.join(tmppath, file));
|
await (0, fs_extra_1.unlink)((0, path_1.join)(tmppath, file));
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error(err);
|
this.log.error(err);
|
||||||
|
@ -328,14 +319,14 @@ class FFMPEG {
|
||||||
async checkDir() {
|
async checkDir() {
|
||||||
let fileExists;
|
let fileExists;
|
||||||
try {
|
try {
|
||||||
fileExists = await fs_extra_1.exists(this.TMPDIR);
|
fileExists = await (0, fs_extra_1.exists)(this.TMPDIR);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error('Error checking for tmp dir', err);
|
this.log.error('Error checking for tmp dir', err);
|
||||||
}
|
}
|
||||||
if (!fileExists) {
|
if (!fileExists) {
|
||||||
try {
|
try {
|
||||||
await fs_extra_1.mkdir(this.TMPDIR);
|
await (0, fs_extra_1.mkdir)(this.TMPDIR);
|
||||||
this.log.info(`Created tmpdir ${this.TMPDIR}`);
|
this.log.info(`Created tmpdir ${this.TMPDIR}`);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
@ -350,7 +341,6 @@ class FFMPEG {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.exports = (sys) => {
|
exports.FFMPEG = FFMPEG;
|
||||||
return new FFMPEG(sys);
|
module.exports = { FFMPEG };
|
||||||
};
|
|
||||||
//# sourceMappingURL=index.js.map
|
//# sourceMappingURL=index.js.map
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,54 @@
|
||||||
|
<a name="module_lib/ffprobe"></a>
|
||||||
|
|
||||||
|
## lib/ffprobe
|
||||||
|
|
||||||
|
* [lib/ffprobe](#module_lib/ffprobe)
|
||||||
|
* [~FFPROBE](#module_lib/ffprobe..FFPROBE)
|
||||||
|
* [.parseFps()](#module_lib/ffprobe..FFPROBE+parseFps)
|
||||||
|
* [.info(video)](#module_lib/ffprobe..FFPROBE+info) ⇒ <code>object</code>
|
||||||
|
* [.frames(video)](#module_lib/ffprobe..FFPROBE+frames) ⇒ <code>integer</code>
|
||||||
|
|
||||||
|
<a name="module_lib/ffprobe..FFPROBE"></a>
|
||||||
|
|
||||||
|
### lib/ffprobe~FFPROBE
|
||||||
|
Class representing all ffprobe features.
|
||||||
|
|
||||||
|
**Kind**: inner class of [<code>lib/ffprobe</code>](#module_lib/ffprobe)
|
||||||
|
|
||||||
|
* [~FFPROBE](#module_lib/ffprobe..FFPROBE)
|
||||||
|
* [.parseFps()](#module_lib/ffprobe..FFPROBE+parseFps)
|
||||||
|
* [.info(video)](#module_lib/ffprobe..FFPROBE+info) ⇒ <code>object</code>
|
||||||
|
* [.frames(video)](#module_lib/ffprobe..FFPROBE+frames) ⇒ <code>integer</code>
|
||||||
|
|
||||||
|
<a name="module_lib/ffprobe..FFPROBE+parseFps"></a>
|
||||||
|
|
||||||
|
#### ffprobE.parseFps()
|
||||||
|
Parse the fps entry into a float representing the fps of a video
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>FFPROBE</code>](#module_lib/ffprobe..FFPROBE)
|
||||||
|
<a name="module_lib/ffprobe..FFPROBE+info"></a>
|
||||||
|
|
||||||
|
#### ffprobE.info(video) ⇒ <code>object</code>
|
||||||
|
Get info on a video in json format. Use for filmout.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>FFPROBE</code>](#module_lib/ffprobe..FFPROBE)
|
||||||
|
**Returns**: <code>object</code> - Video info in an object
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| video | <code>string</code> | Path to video |
|
||||||
|
|
||||||
|
<a name="module_lib/ffprobe..FFPROBE+frames"></a>
|
||||||
|
|
||||||
|
#### ffprobE.frames(video) ⇒ <code>integer</code>
|
||||||
|
Count the number of frames in the video using one of two methods.
|
||||||
|
The first uses -select_streams and is very fast. The second uses
|
||||||
|
-count_frames and is VERY slow.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>FFPROBE</code>](#module_lib/ffprobe..FFPROBE)
|
||||||
|
**Returns**: <code>integer</code> - Number of frames in video
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| video | <code>string</code> | Path to video |
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
import type { System } from 'system';
|
||||||
|
/** @module lib/ffprobe */
|
||||||
|
/**
|
||||||
|
* Class representing all ffprobe features.
|
||||||
|
*/
|
||||||
|
export declare class FFPROBE {
|
||||||
|
private bin;
|
||||||
|
private log;
|
||||||
|
constructor(sys: System);
|
||||||
|
private init;
|
||||||
|
/**
|
||||||
|
* Parse the fps entry into a float representing the fps of a video
|
||||||
|
**/
|
||||||
|
private parseFps;
|
||||||
|
/**
|
||||||
|
* Get info on a video in json format. Use for filmout.
|
||||||
|
*
|
||||||
|
* @param {string} video Path to video
|
||||||
|
*
|
||||||
|
* @returns {object} Video info in an object
|
||||||
|
**/
|
||||||
|
info(video: string): Promise<any>;
|
||||||
|
/**
|
||||||
|
* Count the number of frames in the video using one of two methods.
|
||||||
|
* The first uses -select_streams and is very fast. The second uses
|
||||||
|
* -count_frames and is VERY slow.
|
||||||
|
*
|
||||||
|
* @param {string} video Path to video
|
||||||
|
*
|
||||||
|
* @returns {integer} Number of frames in video
|
||||||
|
**/
|
||||||
|
frames(video: string): Promise<any>;
|
||||||
|
}
|
|
@ -1,14 +1,21 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
/** @module FFPROBE **/
|
exports.FFPROBE = void 0;
|
||||||
const fs_extra_1 = require("fs-extra");
|
const fs_extra_1 = require("fs-extra");
|
||||||
const path_1 = require("path");
|
const path_1 = require("path");
|
||||||
const exec_1 = require("exec");
|
const exec_1 = require("exec");
|
||||||
//const spawn = require('spawn');
|
const log_1 = require("log");
|
||||||
//const exit = require('exit');
|
/** @module lib/ffprobe */
|
||||||
|
/**
|
||||||
|
* Class representing all ffprobe features.
|
||||||
|
*/
|
||||||
class FFPROBE {
|
class FFPROBE {
|
||||||
constructor(sys) {
|
constructor(sys) {
|
||||||
this.bin = sys.deps.ffprobe;
|
this.bin = sys.deps.ffprobe;
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
|
async init() {
|
||||||
|
this.log = await (0, log_1.Log)({ label: 'ffprobe' });
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Parse the fps entry into a float representing the fps of a video
|
* Parse the fps entry into a float representing the fps of a video
|
||||||
|
@ -39,29 +46,31 @@ class FFPROBE {
|
||||||
let json;
|
let json;
|
||||||
let vid; //whether video has stream with video data
|
let vid; //whether video has stream with video data
|
||||||
try {
|
try {
|
||||||
fileExists = await fs_extra_1.exists(video);
|
fileExists = await (0, fs_extra_1.exists)(video);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
return exit(err, 5);
|
return exit(err, 5);
|
||||||
}
|
}
|
||||||
if (!fileExists) {
|
if (!fileExists) {
|
||||||
//return exit(`File ${video} does not exist`, 6);
|
//return exit(`File ${video} does not exist`, 6);
|
||||||
console.error(new Error(`File ${video} does not exist`));
|
this.log.error(new Error(`File ${video} does not exist`));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
console.log(cmd);
|
this.log.info(cmd);
|
||||||
raw = await exec_1.exec(cmd);
|
raw = await (0, exec_1.exec)(cmd);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
//return exit(err, 7);
|
//return exit(err, 7);
|
||||||
console.error(err);
|
this.log.error(err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
json = JSON.parse(raw.stdout);
|
json = JSON.parse(raw.stdout);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
this.log.error('Error parsing stdout', err);
|
||||||
|
this.log.error(raw.stdout);
|
||||||
return raw.stdout;
|
return raw.stdout;
|
||||||
}
|
}
|
||||||
if (json.format && json.format.duration) {
|
if (json.format && json.format.duration) {
|
||||||
|
@ -90,7 +99,7 @@ class FFPROBE {
|
||||||
* @returns {integer} Number of frames in video
|
* @returns {integer} Number of frames in video
|
||||||
**/
|
**/
|
||||||
async frames(video) {
|
async frames(video) {
|
||||||
const ext = path_1.extname(video.toLowerCase());
|
const ext = (0, path_1.extname)(video.toLowerCase());
|
||||||
let cmd = `${this.bin} -v error -select_streams v:0 -show_entries stream=nb_frames -of default=nokey=1:noprint_wrappers=1 "${video}"`;
|
let cmd = `${this.bin} -v error -select_streams v:0 -show_entries stream=nb_frames -of default=nokey=1:noprint_wrappers=1 "${video}"`;
|
||||||
let backup_cmd = `${this.bin} -v error -count_frames -select_streams v:0 -show_entries stream=nb_read_frames -of default=nokey=1:noprint_wrappers=1 "${video}"`;
|
let backup_cmd = `${this.bin} -v error -count_frames -select_streams v:0 -show_entries stream=nb_read_frames -of default=nokey=1:noprint_wrappers=1 "${video}"`;
|
||||||
let gif_cmd = `identify -format "%n\n" "${video}" | head -1`;
|
let gif_cmd = `identify -format "%n\n" "${video}" | head -1`;
|
||||||
|
@ -98,11 +107,11 @@ class FFPROBE {
|
||||||
let raw;
|
let raw;
|
||||||
let frames;
|
let frames;
|
||||||
try {
|
try {
|
||||||
fileExists = await fs_extra_1.exists(video);
|
fileExists = await (0, fs_extra_1.exists)(video);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
//return exit(err, 5);
|
//return exit(err, 5);
|
||||||
console.error(err);
|
this.log.error(err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!fileExists) {
|
if (!fileExists) {
|
||||||
|
@ -117,11 +126,11 @@ class FFPROBE {
|
||||||
cmd = gif_cmd;
|
cmd = gif_cmd;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
console.log(cmd);
|
this.log.info(cmd);
|
||||||
raw = await exec_1.exec(cmd);
|
raw = await (0, exec_1.exec)(cmd);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(err);
|
this.log.error(err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -133,12 +142,11 @@ class FFPROBE {
|
||||||
return frames;
|
return frames;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
exports.FFPROBE = FFPROBE;
|
||||||
/*
|
/*
|
||||||
function map (obj : any) {
|
function map (obj : any) {
|
||||||
console.dir(obj);
|
console.dir(obj);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
module.exports = (sys) => {
|
module.exports = { FFPROBE };
|
||||||
return new FFPROBE(sys);
|
|
||||||
};
|
|
||||||
//# sourceMappingURL=index.js.map
|
//# sourceMappingURL=index.js.map
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ffprobe/index.ts"],"names":[],"mappings":"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"}
|
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ffprobe/index.ts"],"names":[],"mappings":"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"}
|
|
@ -1,44 +1,227 @@
|
||||||
<a name="Digital"></a>
|
<a name="module_lib/filmout"></a>
|
||||||
|
|
||||||
## Digital
|
## lib/filmout
|
||||||
**Kind**: global class
|
|
||||||
|
|
||||||
* [Digital](#Digital)
|
* [lib/filmout](#module_lib/filmout)
|
||||||
* [.init()](#Digital+init)
|
* [~FilmOut](#module_lib/filmout..FilmOut)
|
||||||
* [.listen()](#Digital+listen)
|
* [.init()](#module_lib/filmout..FilmOut+init)
|
||||||
* [.set()](#Digital+set)
|
* [.listen()](#module_lib/filmout..FilmOut+listen)
|
||||||
* [.move()](#Digital+move)
|
* [.hash(data)](#module_lib/filmout..FilmOut+hash)
|
||||||
* [.start()](#Digital+start)
|
* [.set(dir)](#module_lib/filmout..FilmOut+set)
|
||||||
* [.end()](#Digital+end)
|
* [.move()](#module_lib/filmout..FilmOut+move) ⇒ <code>number</code>
|
||||||
* [.connectDigital()](#Digital+connectDigital)
|
* [.start()](#module_lib/filmout..FilmOut+start)
|
||||||
|
* [.end()](#module_lib/filmout..FilmOut+end)
|
||||||
|
* [.onConnect(evt, arg)](#module_lib/filmout..FilmOut+onConnect) ⇒ <code>boolean</code>
|
||||||
|
* [.onPreExport(evt, arg)](#module_lib/filmout..FilmOut+onPreExport) ⇒ <code>any</code>
|
||||||
|
* [.isGifAnimated(pathStr)](#module_lib/filmout..FilmOut+isGifAnimated) ⇒ <code>boolean</code>
|
||||||
|
* [.stillInfo(pathStr)](#module_lib/filmout..FilmOut+stillInfo) ⇒ <code>object</code>
|
||||||
|
* [.dirInfo(images)](#module_lib/filmout..FilmOut+dirInfo) ⇒ <code>object</code>
|
||||||
|
* [.dirList(pathStr)](#module_lib/filmout..FilmOut+dirList) ⇒ <code>array</code>
|
||||||
|
* [.previewFrame(evt, arg)](#module_lib/filmout..FilmOut+previewFrame)
|
||||||
|
* [.preview(evt, arg)](#module_lib/filmout..FilmOut+preview)
|
||||||
|
* [.focus()](#module_lib/filmout..FilmOut+focus)
|
||||||
|
* [.field()](#module_lib/filmout..FilmOut+field)
|
||||||
|
* [.meter()](#module_lib/filmout..FilmOut+meter)
|
||||||
|
* [.close()](#module_lib/filmout..FilmOut+close)
|
||||||
|
* [.onDisplay()](#module_lib/filmout..FilmOut+onDisplay)
|
||||||
|
|
||||||
<a name="Digital+init"></a>
|
<a name="module_lib/filmout..FilmOut"></a>
|
||||||
|
|
||||||
### digital.init()
|
### lib/filmout~FilmOut
|
||||||
**Kind**: instance method of [<code>Digital</code>](#Digital)
|
Class representing all filmout features.
|
||||||
<a name="Digital+listen"></a>
|
|
||||||
|
|
||||||
### digital.listen()
|
**Kind**: inner class of [<code>lib/filmout</code>](#module_lib/filmout)
|
||||||
**Kind**: instance method of [<code>Digital</code>](#Digital)
|
|
||||||
<a name="Digital+set"></a>
|
|
||||||
|
|
||||||
### digital.set()
|
* [~FilmOut](#module_lib/filmout..FilmOut)
|
||||||
**Kind**: instance method of [<code>Digital</code>](#Digital)
|
* [.init()](#module_lib/filmout..FilmOut+init)
|
||||||
<a name="Digital+move"></a>
|
* [.listen()](#module_lib/filmout..FilmOut+listen)
|
||||||
|
* [.hash(data)](#module_lib/filmout..FilmOut+hash)
|
||||||
|
* [.set(dir)](#module_lib/filmout..FilmOut+set)
|
||||||
|
* [.move()](#module_lib/filmout..FilmOut+move) ⇒ <code>number</code>
|
||||||
|
* [.start()](#module_lib/filmout..FilmOut+start)
|
||||||
|
* [.end()](#module_lib/filmout..FilmOut+end)
|
||||||
|
* [.onConnect(evt, arg)](#module_lib/filmout..FilmOut+onConnect) ⇒ <code>boolean</code>
|
||||||
|
* [.onPreExport(evt, arg)](#module_lib/filmout..FilmOut+onPreExport) ⇒ <code>any</code>
|
||||||
|
* [.isGifAnimated(pathStr)](#module_lib/filmout..FilmOut+isGifAnimated) ⇒ <code>boolean</code>
|
||||||
|
* [.stillInfo(pathStr)](#module_lib/filmout..FilmOut+stillInfo) ⇒ <code>object</code>
|
||||||
|
* [.dirInfo(images)](#module_lib/filmout..FilmOut+dirInfo) ⇒ <code>object</code>
|
||||||
|
* [.dirList(pathStr)](#module_lib/filmout..FilmOut+dirList) ⇒ <code>array</code>
|
||||||
|
* [.previewFrame(evt, arg)](#module_lib/filmout..FilmOut+previewFrame)
|
||||||
|
* [.preview(evt, arg)](#module_lib/filmout..FilmOut+preview)
|
||||||
|
* [.focus()](#module_lib/filmout..FilmOut+focus)
|
||||||
|
* [.field()](#module_lib/filmout..FilmOut+field)
|
||||||
|
* [.meter()](#module_lib/filmout..FilmOut+meter)
|
||||||
|
* [.close()](#module_lib/filmout..FilmOut+close)
|
||||||
|
* [.onDisplay()](#module_lib/filmout..FilmOut+onDisplay)
|
||||||
|
|
||||||
### digital.move()
|
<a name="module_lib/filmout..FilmOut+init"></a>
|
||||||
**Kind**: instance method of [<code>Digital</code>](#Digital)
|
|
||||||
<a name="Digital+start"></a>
|
|
||||||
|
|
||||||
### digital.start()
|
#### filmOut.init()
|
||||||
**Kind**: instance method of [<code>Digital</code>](#Digital)
|
Async function for requiring log, ipcMain and bind events.
|
||||||
<a name="Digital+end"></a>
|
|
||||||
|
|
||||||
### digital.end()
|
**Kind**: instance method of [<code>FilmOut</code>](#module_lib/filmout..FilmOut)
|
||||||
**Kind**: instance method of [<code>Digital</code>](#Digital)
|
<a name="module_lib/filmout..FilmOut+listen"></a>
|
||||||
<a name="Digital+connectDigital"></a>
|
|
||||||
|
|
||||||
### digital.connectDigital()
|
#### filmOut.listen()
|
||||||
Use a file as the "digital" source on "projector"
|
**Kind**: instance method of [<code>FilmOut</code>](#module_lib/filmout..FilmOut)
|
||||||
|
<a name="module_lib/filmout..FilmOut+hash"></a>
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Digital</code>](#Digital)
|
#### filmOut.hash(data)
|
||||||
|
Create a hash of a string.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>FilmOut</code>](#module_lib/filmout..FilmOut)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| data | <code>string</code> | Data to produce hash of |
|
||||||
|
|
||||||
|
<a name="module_lib/filmout..FilmOut+set"></a>
|
||||||
|
|
||||||
|
#### filmOut.set(dir)
|
||||||
|
Sets filmout direction.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>FilmOut</code>](#module_lib/filmout..FilmOut)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| dir | <code>boolean</code> | Direction of filmout |
|
||||||
|
|
||||||
|
<a name="module_lib/filmout..FilmOut+move"></a>
|
||||||
|
|
||||||
|
#### filmOut.move() ⇒ <code>number</code>
|
||||||
|
Moves filmout a frame at a time.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>FilmOut</code>](#module_lib/filmout..FilmOut)
|
||||||
|
**Returns**: <code>number</code> - Time since start
|
||||||
|
<a name="module_lib/filmout..FilmOut+start"></a>
|
||||||
|
|
||||||
|
#### filmOut.start()
|
||||||
|
Begin the process of exporting single frames from the video for display.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>FilmOut</code>](#module_lib/filmout..FilmOut)
|
||||||
|
<a name="module_lib/filmout..FilmOut+end"></a>
|
||||||
|
|
||||||
|
#### filmOut.end()
|
||||||
|
Ends the filmout process and closes the display.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>FilmOut</code>](#module_lib/filmout..FilmOut)
|
||||||
|
<a name="module_lib/filmout..FilmOut+onConnect"></a>
|
||||||
|
|
||||||
|
#### filmOut.onConnect(evt, arg) ⇒ <code>boolean</code>
|
||||||
|
Use a video file as a film out source on "projector"
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>FilmOut</code>](#module_lib/filmout..FilmOut)
|
||||||
|
**Returns**: <code>boolean</code> - Success state
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| evt | <code>object</code> | Original connect event |
|
||||||
|
| arg | <code>object</code> | Arguments from ipc message |
|
||||||
|
|
||||||
|
<a name="module_lib/filmout..FilmOut+onPreExport"></a>
|
||||||
|
|
||||||
|
#### filmOut.onPreExport(evt, arg) ⇒ <code>any</code>
|
||||||
|
Pre-export all frames from video for display.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>FilmOut</code>](#module_lib/filmout..FilmOut)
|
||||||
|
**Returns**: <code>any</code> - UI send call
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| evt | <code>object</code> | IPC event |
|
||||||
|
| arg | <code>object</code> | IPC args |
|
||||||
|
|
||||||
|
<a name="module_lib/filmout..FilmOut+isGifAnimated"></a>
|
||||||
|
|
||||||
|
#### filmOut.isGifAnimated(pathStr) ⇒ <code>boolean</code>
|
||||||
|
Return true if gif is animated, false if it is a still
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>FilmOut</code>](#module_lib/filmout..FilmOut)
|
||||||
|
**Returns**: <code>boolean</code> - Whether or not gif is animated
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| pathStr | <code>string</code> | Path to gif to check |
|
||||||
|
|
||||||
|
<a name="module_lib/filmout..FilmOut+stillInfo"></a>
|
||||||
|
|
||||||
|
#### filmOut.stillInfo(pathStr) ⇒ <code>object</code>
|
||||||
|
Return information on a still image using the Jimp module
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>FilmOut</code>](#module_lib/filmout..FilmOut)
|
||||||
|
**Returns**: <code>object</code> - Info about still from sharp
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| pathStr | <code>string</code> | Path to gif to check |
|
||||||
|
|
||||||
|
<a name="module_lib/filmout..FilmOut+dirInfo"></a>
|
||||||
|
|
||||||
|
#### filmOut.dirInfo(images) ⇒ <code>object</code>
|
||||||
|
Return information on the first still image found in a
|
||||||
|
directory using the Jimp module.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>FilmOut</code>](#module_lib/filmout..FilmOut)
|
||||||
|
**Returns**: <code>object</code> - Info about first image
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| images | <code>array</code> | List of image paths |
|
||||||
|
|
||||||
|
<a name="module_lib/filmout..FilmOut+dirList"></a>
|
||||||
|
|
||||||
|
#### filmOut.dirList(pathStr) ⇒ <code>array</code>
|
||||||
|
Returns a list of images within a directory, filtered
|
||||||
|
for supported types and sorted.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>FilmOut</code>](#module_lib/filmout..FilmOut)
|
||||||
|
**Returns**: <code>array</code> - Array of image paths
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| pathStr | <code>string</code> | Path to directory |
|
||||||
|
|
||||||
|
<a name="module_lib/filmout..FilmOut+previewFrame"></a>
|
||||||
|
|
||||||
|
#### filmOut.previewFrame(evt, arg)
|
||||||
|
Preview a frame from the selected video.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>FilmOut</code>](#module_lib/filmout..FilmOut)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| evt | <code>object</code> | Original event |
|
||||||
|
| arg | <code>object</code> | Arguments from message |
|
||||||
|
|
||||||
|
<a name="module_lib/filmout..FilmOut+preview"></a>
|
||||||
|
|
||||||
|
#### filmOut.preview(evt, arg)
|
||||||
|
Open a single frame in a display window to preview filmout.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>FilmOut</code>](#module_lib/filmout..FilmOut)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| evt | <code>object</code> | Original event |
|
||||||
|
| arg | <code>object</code> | Arguments from message |
|
||||||
|
|
||||||
|
<a name="module_lib/filmout..FilmOut+focus"></a>
|
||||||
|
|
||||||
|
#### filmOut.focus()
|
||||||
|
**Kind**: instance method of [<code>FilmOut</code>](#module_lib/filmout..FilmOut)
|
||||||
|
<a name="module_lib/filmout..FilmOut+field"></a>
|
||||||
|
|
||||||
|
#### filmOut.field()
|
||||||
|
**Kind**: instance method of [<code>FilmOut</code>](#module_lib/filmout..FilmOut)
|
||||||
|
<a name="module_lib/filmout..FilmOut+meter"></a>
|
||||||
|
|
||||||
|
#### filmOut.meter()
|
||||||
|
**Kind**: instance method of [<code>FilmOut</code>](#module_lib/filmout..FilmOut)
|
||||||
|
<a name="module_lib/filmout..FilmOut+close"></a>
|
||||||
|
|
||||||
|
#### filmOut.close()
|
||||||
|
**Kind**: instance method of [<code>FilmOut</code>](#module_lib/filmout..FilmOut)
|
||||||
|
<a name="module_lib/filmout..FilmOut+onDisplay"></a>
|
||||||
|
|
||||||
|
#### filmOut.onDisplay()
|
||||||
|
**Kind**: instance method of [<code>FilmOut</code>](#module_lib/filmout..FilmOut)
|
||||||
|
|
|
@ -0,0 +1,173 @@
|
||||||
|
import type { Server } from 'server';
|
||||||
|
import type { Display } from 'display';
|
||||||
|
import type { Light } from 'light';
|
||||||
|
import type { FFMPEG } from 'ffmpeg';
|
||||||
|
import type { FFPROBE } from 'ffprobe';
|
||||||
|
import type { WebContents, IpcMainEvent } from 'electron';
|
||||||
|
interface FilmOutState {
|
||||||
|
hash: string;
|
||||||
|
frame: number;
|
||||||
|
frames: number;
|
||||||
|
fps: number;
|
||||||
|
seconds: number;
|
||||||
|
still: boolean;
|
||||||
|
path: string;
|
||||||
|
fileName: string;
|
||||||
|
directory: boolean;
|
||||||
|
info: any;
|
||||||
|
dir: boolean;
|
||||||
|
enabled: boolean;
|
||||||
|
files: string[];
|
||||||
|
}
|
||||||
|
/** @module lib/filmout */
|
||||||
|
/**
|
||||||
|
* Class representing all filmout features.
|
||||||
|
*/
|
||||||
|
export declare class FilmOut {
|
||||||
|
private id;
|
||||||
|
private videoExtensions;
|
||||||
|
private stillExtensions;
|
||||||
|
private sequenceExtensions;
|
||||||
|
private gifExtension;
|
||||||
|
state: FilmOutState;
|
||||||
|
private ffmpeg;
|
||||||
|
private ffprobe;
|
||||||
|
private light;
|
||||||
|
private ipc;
|
||||||
|
private ui;
|
||||||
|
private log;
|
||||||
|
display: Display;
|
||||||
|
server: Server;
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* Builds FilmOut class with display, ffmpeg, ffprobe, ui and light as internal properties.
|
||||||
|
*
|
||||||
|
* @param {object} display Display object for showing frames
|
||||||
|
* @param {object} ffmpeg FFMPEG wrapper
|
||||||
|
* @param {object} ffprobe FFPROBE wrapper for file info
|
||||||
|
* @param {object} ui Electron ui object
|
||||||
|
* @param {object} light Light device object
|
||||||
|
**/
|
||||||
|
constructor(display: Display, server: Server, ffmpeg: FFMPEG, ffprobe: FFPROBE, ui: WebContents, light: Light);
|
||||||
|
/**
|
||||||
|
* Async function for requiring log, ipcMain and bind events.
|
||||||
|
**/
|
||||||
|
private init;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private listen;
|
||||||
|
/**
|
||||||
|
* Create a hash of a string.
|
||||||
|
*
|
||||||
|
* @param {string} data Data to produce hash of
|
||||||
|
*/
|
||||||
|
private hash;
|
||||||
|
/**
|
||||||
|
* Sets filmout direction.
|
||||||
|
*
|
||||||
|
* @param {boolean} dir Direction of filmout
|
||||||
|
**/
|
||||||
|
set(dir: boolean): void;
|
||||||
|
/**
|
||||||
|
* Moves filmout a frame at a time.
|
||||||
|
*
|
||||||
|
* @returns {number} Time since start
|
||||||
|
**/
|
||||||
|
move(): Promise<number>;
|
||||||
|
/**
|
||||||
|
* Begin the process of exporting single frames from the video for display.
|
||||||
|
**/
|
||||||
|
start(): Promise<void>;
|
||||||
|
/**
|
||||||
|
* Ends the filmout process and closes the display.
|
||||||
|
**/
|
||||||
|
end(): Promise<void>;
|
||||||
|
/**
|
||||||
|
* Use a video file as a film out source on "projector"
|
||||||
|
*
|
||||||
|
* @param {object} evt Original connect event
|
||||||
|
* @param {object} arg Arguments from ipc message
|
||||||
|
*
|
||||||
|
* @returns {boolean} Success state
|
||||||
|
**/
|
||||||
|
onConnect(evt: IpcMainEvent, arg: any): Promise<boolean>;
|
||||||
|
/**
|
||||||
|
* Pre-export all frames from video for display.
|
||||||
|
*
|
||||||
|
* @param {object} evt IPC event
|
||||||
|
* @param {object} arg IPC args
|
||||||
|
*
|
||||||
|
* @returns {any} UI send call
|
||||||
|
*/
|
||||||
|
onPreExport(evt: IpcMainEvent, arg: any): Promise<any>;
|
||||||
|
/**
|
||||||
|
* Return true if gif is animated, false if it is a still
|
||||||
|
*
|
||||||
|
* @param {string} pathStr Path to gif to check
|
||||||
|
*
|
||||||
|
* @returns {boolean} Whether or not gif is animated
|
||||||
|
**/
|
||||||
|
isGifAnimated(pathStr: string): Promise<boolean>;
|
||||||
|
/**
|
||||||
|
* Return information on a still image using the Jimp module
|
||||||
|
*
|
||||||
|
* @param {string} pathStr Path to gif to check
|
||||||
|
*
|
||||||
|
* @returns {object} Info about still from sharp
|
||||||
|
**/
|
||||||
|
stillInfo(pathStr: string): Promise<any>;
|
||||||
|
/**
|
||||||
|
* Return information on the first still image found in a
|
||||||
|
* directory using the Jimp module.
|
||||||
|
*
|
||||||
|
* @param {array} images List of image paths
|
||||||
|
*
|
||||||
|
* @returns {object} Info about first image
|
||||||
|
**/
|
||||||
|
dirInfo(images: string[]): Promise<any>;
|
||||||
|
/**
|
||||||
|
* Returns a list of images within a directory, filtered
|
||||||
|
* for supported types and sorted.
|
||||||
|
*
|
||||||
|
* @param {string} pathStr Path to directory
|
||||||
|
*
|
||||||
|
* @returns {array} Array of image paths
|
||||||
|
**/
|
||||||
|
dirList(pathStr: string): Promise<string[]>;
|
||||||
|
/**
|
||||||
|
* Preview a frame from the selected video.
|
||||||
|
*
|
||||||
|
* @param {object} evt Original event
|
||||||
|
* @param {object} arg Arguments from message
|
||||||
|
**/
|
||||||
|
previewFrame(evt: IpcMainEvent, arg: any): Promise<void>;
|
||||||
|
/**
|
||||||
|
* Open a single frame in a display window to preview filmout.
|
||||||
|
*
|
||||||
|
* @param {object} evt Original event
|
||||||
|
* @param {object} arg Arguments from message
|
||||||
|
**/
|
||||||
|
preview(evt: IpcMainEvent, arg: any): Promise<void>;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
focus(evt: IpcMainEvent, arg: any): Promise<void>;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
field(evt: IpcMainEvent, arg: any): Promise<void>;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
meter(evt: IpcMainEvent, arg: any): Promise<void>;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
close(evt: IpcMainEvent, arg: any): Promise<void>;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
onDisplay(evt: IpcMainEvent, arg: any): void;
|
||||||
|
}
|
||||||
|
export type { FilmOutState };
|
|
@ -3,15 +3,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.FilmOut = void 0;
|
||||||
|
const electron_1 = require("electron");
|
||||||
const animated_gif_detector_1 = __importDefault(require("animated-gif-detector"));
|
const animated_gif_detector_1 = __importDefault(require("animated-gif-detector"));
|
||||||
const path_1 = require("path");
|
const path_1 = require("path");
|
||||||
const fs_extra_1 = require("fs-extra");
|
const fs_extra_1 = require("fs-extra");
|
||||||
const delay_1 = require("delay");
|
const delay_1 = require("delay");
|
||||||
const crypto_1 = require("crypto");
|
const crypto_1 = require("crypto");
|
||||||
const frame_1 = __importDefault(require("frame"));
|
const frame_1 = require("frame");
|
||||||
|
const log_1 = require("log");
|
||||||
|
/** @module lib/filmout */
|
||||||
/**
|
/**
|
||||||
* @module FilmOut
|
* Class representing all filmout features.
|
||||||
**/
|
*/
|
||||||
class FilmOut {
|
class FilmOut {
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
|
@ -23,15 +27,18 @@ class FilmOut {
|
||||||
* @param {object} ui Electron ui object
|
* @param {object} ui Electron ui object
|
||||||
* @param {object} light Light device object
|
* @param {object} light Light device object
|
||||||
**/
|
**/
|
||||||
constructor(display, ffmpeg, ffprobe, ui, light) {
|
constructor(display, server, ffmpeg, ffprobe, ui, light) {
|
||||||
this.id = 'filmout';
|
this.id = 'filmout';
|
||||||
this.videoExtensions = ['.mpg', '.mpeg', '.mov', '.mkv', '.avi', '.mp4'];
|
this.videoExtensions = ['.mpg', '.mpeg', '.mov', '.mkv', '.avi', '.mp4'];
|
||||||
this.stillExtensions = ['.tif', '.tiff', '.png', '.jpg', '.jpeg', '.bmp'];
|
this.stillExtensions = ['.tif', '.tiff', '.png', '.jpg', '.jpeg', '.bmp'];
|
||||||
this.sequenceExtensions = ['.png', '.jpg', '.jpeg'];
|
this.sequenceExtensions = ['.png', '.jpg', '.jpeg'];
|
||||||
this.gifExtension = '.gif';
|
this.gifExtension = '.gif';
|
||||||
this.state = {
|
this.state = {
|
||||||
|
hash: null,
|
||||||
frame: 0,
|
frame: 0,
|
||||||
frames: 0,
|
frames: 0,
|
||||||
|
fps: 24,
|
||||||
|
seconds: 0,
|
||||||
still: false,
|
still: false,
|
||||||
path: null,
|
path: null,
|
||||||
fileName: null,
|
fileName: null,
|
||||||
|
@ -41,7 +48,9 @@ class FilmOut {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
files: []
|
files: []
|
||||||
};
|
};
|
||||||
|
this.ipc = electron_1.ipcMain;
|
||||||
this.display = display;
|
this.display = display;
|
||||||
|
this.server = server;
|
||||||
this.ffmpeg = ffmpeg;
|
this.ffmpeg = ffmpeg;
|
||||||
this.ffprobe = ffprobe;
|
this.ffprobe = ffprobe;
|
||||||
this.ui = ui;
|
this.ui = ui;
|
||||||
|
@ -52,9 +61,7 @@ class FilmOut {
|
||||||
* Async function for requiring log, ipcMain and bind events.
|
* Async function for requiring log, ipcMain and bind events.
|
||||||
**/
|
**/
|
||||||
async init() {
|
async init() {
|
||||||
const Log = require('log');
|
this.log = await (0, log_1.Log)({ label: this.id });
|
||||||
this.log = await Log({ label: this.id });
|
|
||||||
this.ipc = require('electron').ipcMain;
|
|
||||||
this.listen();
|
this.listen();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -80,7 +87,7 @@ class FilmOut {
|
||||||
* @param {string} data Data to produce hash of
|
* @param {string} data Data to produce hash of
|
||||||
*/
|
*/
|
||||||
hash(data) {
|
hash(data) {
|
||||||
return crypto_1.createHash('sha1').update(data).digest('hex');
|
return (0, crypto_1.createHash)('sha1').update(data).digest('hex');
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Sets filmout direction.
|
* Sets filmout direction.
|
||||||
|
@ -92,11 +99,13 @@ class FilmOut {
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Moves filmout a frame at a time.
|
* Moves filmout a frame at a time.
|
||||||
|
*
|
||||||
|
* @returns {number} Time since start
|
||||||
**/
|
**/
|
||||||
async move() {
|
async move() {
|
||||||
let start = +new Date();
|
let start = +new Date();
|
||||||
if (this.state.still) {
|
if (this.state.still) {
|
||||||
return false;
|
return -1;
|
||||||
}
|
}
|
||||||
if (this.state.dir) {
|
if (this.state.dir) {
|
||||||
this.state.frame++;
|
this.state.frame++;
|
||||||
|
@ -121,14 +130,18 @@ class FilmOut {
|
||||||
this.log.error(err, 'FILMOUT', true, true);
|
this.log.error(err, 'FILMOUT', true, true);
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
if (this.server.displayImage(path)) {
|
||||||
|
await (0, delay_1.delay)(20);
|
||||||
|
return;
|
||||||
|
}
|
||||||
await this.display.show(path);
|
await this.display.show(path);
|
||||||
await delay_1.delay(20);
|
await (0, delay_1.delay)(20);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Ends the filmout process and closes the display.
|
* Ends the filmout process and closes the display.
|
||||||
**/
|
**/
|
||||||
async end() {
|
async end() {
|
||||||
await delay_1.delay(20);
|
await (0, delay_1.delay)(20);
|
||||||
this.display.hide();
|
this.display.hide();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -136,6 +149,8 @@ class FilmOut {
|
||||||
*
|
*
|
||||||
* @param {object} evt Original connect event
|
* @param {object} evt Original connect event
|
||||||
* @param {object} arg Arguments from ipc message
|
* @param {object} arg Arguments from ipc message
|
||||||
|
*
|
||||||
|
* @returns {boolean} Success state
|
||||||
**/
|
**/
|
||||||
async onConnect(evt, arg) {
|
async onConnect(evt, arg) {
|
||||||
let frames = 0;
|
let frames = 0;
|
||||||
|
@ -145,13 +160,13 @@ class FilmOut {
|
||||||
let stats;
|
let stats;
|
||||||
let frameList;
|
let frameList;
|
||||||
try {
|
try {
|
||||||
stats = await fs_extra_1.lstat(arg.path);
|
stats = await (0, fs_extra_1.lstat)(arg.path);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error(err, 'FILMOUT', true, true);
|
this.log.error(err, 'FILMOUT', true, true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ext = path_1.extname(arg.fileName.toLowerCase());
|
ext = (0, path_1.extname)(arg.fileName.toLowerCase());
|
||||||
if (stats.isDirectory()) {
|
if (stats.isDirectory()) {
|
||||||
this.state.directory = true;
|
this.state.directory = true;
|
||||||
this.state.still = false;
|
this.state.still = false;
|
||||||
|
@ -240,7 +255,6 @@ class FilmOut {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.dir(info);
|
|
||||||
this.state.frame = 0;
|
this.state.frame = 0;
|
||||||
this.state.path = arg.path;
|
this.state.path = arg.path;
|
||||||
this.state.fileName = arg.fileName;
|
this.state.fileName = arg.fileName;
|
||||||
|
@ -265,13 +279,16 @@ class FilmOut {
|
||||||
this.log.info(`Opened ${this.state.fileName}`, 'FILMOUT', true, true);
|
this.log.info(`Opened ${this.state.fileName}`, 'FILMOUT', true, true);
|
||||||
this.log.info(`Frames : ${frames}`, 'FILMOUT', true, true);
|
this.log.info(`Frames : ${frames}`, 'FILMOUT', true, true);
|
||||||
this.state.enabled = true;
|
this.state.enabled = true;
|
||||||
return await this.ui.send(this.id, { valid: true, state: JSON.stringify(this.state) });
|
await this.ui.send(this.id, { valid: true, state: JSON.stringify(this.state) });
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Pre-export all frames from video for display.
|
* Pre-export all frames from video for display.
|
||||||
*
|
*
|
||||||
* @param {object} evt IPC event
|
* @param {object} evt IPC event
|
||||||
* @param {object} arg IPC args
|
* @param {object} arg IPC args
|
||||||
|
*
|
||||||
|
* @returns {any} UI send call
|
||||||
*/
|
*/
|
||||||
async onPreExport(evt, arg) {
|
async onPreExport(evt, arg) {
|
||||||
if (!this.state.path) {
|
if (!this.state.path) {
|
||||||
|
@ -295,13 +312,13 @@ class FilmOut {
|
||||||
async isGifAnimated(pathStr) {
|
async isGifAnimated(pathStr) {
|
||||||
let gifBuffer;
|
let gifBuffer;
|
||||||
try {
|
try {
|
||||||
gifBuffer = await fs_extra_1.readFile(pathStr);
|
gifBuffer = await (0, fs_extra_1.readFile)(pathStr);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error(err, 'FILMOUT', true, true);
|
this.log.error(err, 'FILMOUT', true, true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return animated_gif_detector_1.default(gifBuffer);
|
return (0, animated_gif_detector_1.default)(gifBuffer);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Return information on a still image using the Jimp module
|
* Return information on a still image using the Jimp module
|
||||||
|
@ -313,7 +330,7 @@ class FilmOut {
|
||||||
async stillInfo(pathStr) {
|
async stillInfo(pathStr) {
|
||||||
let info;
|
let info;
|
||||||
try {
|
try {
|
||||||
info = await frame_1.default.info(pathStr);
|
info = await frame_1.Frame.info(pathStr);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error(err, 'FILMOUT', true, true);
|
this.log.error(err, 'FILMOUT', true, true);
|
||||||
|
@ -349,13 +366,13 @@ class FilmOut {
|
||||||
async dirList(pathStr) {
|
async dirList(pathStr) {
|
||||||
let frameList = [];
|
let frameList = [];
|
||||||
try {
|
try {
|
||||||
frameList = await fs_extra_1.readdir(pathStr);
|
frameList = await (0, fs_extra_1.readdir)(pathStr);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error(err, 'FILMOUT', true, true);
|
this.log.error(err, 'FILMOUT', true, true);
|
||||||
}
|
}
|
||||||
frameList = frameList.filter((fileName) => {
|
frameList = frameList.filter((fileName) => {
|
||||||
let ext = path_1.extname(fileName);
|
let ext = (0, path_1.extname)(fileName);
|
||||||
if (this.sequenceExtensions.indexOf(ext) !== -1) {
|
if (this.sequenceExtensions.indexOf(ext) !== -1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -363,7 +380,7 @@ class FilmOut {
|
||||||
});
|
});
|
||||||
frameList.sort();
|
frameList.sort();
|
||||||
frameList = frameList.map((fileName) => {
|
frameList = frameList.map((fileName) => {
|
||||||
return path_1.join(pathStr, fileName);
|
return (0, path_1.join)(pathStr, fileName);
|
||||||
});
|
});
|
||||||
return frameList;
|
return frameList;
|
||||||
}
|
}
|
||||||
|
@ -405,6 +422,9 @@ class FilmOut {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
if (await this.server.displayImage(path)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
await this.display.open();
|
await this.display.open();
|
||||||
await this.display.show(path);
|
await this.display.show(path);
|
||||||
}
|
}
|
||||||
|
@ -418,6 +438,9 @@ class FilmOut {
|
||||||
async focus(evt, arg) {
|
async focus(evt, arg) {
|
||||||
this.log.info(`Showing focus screen`);
|
this.log.info(`Showing focus screen`);
|
||||||
try {
|
try {
|
||||||
|
if (await this.server.cmdAll('focus')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
await this.display.open();
|
await this.display.open();
|
||||||
await this.display.focus();
|
await this.display.focus();
|
||||||
}
|
}
|
||||||
|
@ -432,6 +455,9 @@ class FilmOut {
|
||||||
const ratio = arg.ratio;
|
const ratio = arg.ratio;
|
||||||
this.log.info(`Showing field guide screen`);
|
this.log.info(`Showing field guide screen`);
|
||||||
try {
|
try {
|
||||||
|
if (await this.server.cmdAll('field', { ratio })) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
await this.display.open();
|
await this.display.open();
|
||||||
await this.display.field(ratio);
|
await this.display.field(ratio);
|
||||||
}
|
}
|
||||||
|
@ -445,6 +471,9 @@ class FilmOut {
|
||||||
async meter(evt, arg) {
|
async meter(evt, arg) {
|
||||||
this.log.info(`Showing meter screen`);
|
this.log.info(`Showing meter screen`);
|
||||||
try {
|
try {
|
||||||
|
if (await this.server.cmdAll('meter')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
await this.display.open();
|
await this.display.open();
|
||||||
await this.display.meter();
|
await this.display.meter();
|
||||||
}
|
}
|
||||||
|
@ -457,6 +486,9 @@ class FilmOut {
|
||||||
**/
|
**/
|
||||||
async close(evt, arg) {
|
async close(evt, arg) {
|
||||||
try {
|
try {
|
||||||
|
if (await this.server.cmdAll('blank')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
await this.display.hide();
|
await this.display.hide();
|
||||||
await this.display.close();
|
await this.display.close();
|
||||||
}
|
}
|
||||||
|
@ -472,7 +504,6 @@ class FilmOut {
|
||||||
this.log.info(`Changing the display to ${arg.display}`);
|
this.log.info(`Changing the display to ${arg.display}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.exports = (display, ffmpeg, ffprobe, ui, light) => {
|
exports.FilmOut = FilmOut;
|
||||||
return new FilmOut(display, ffmpeg, ffprobe, ui, light);
|
module.exports = { FilmOut };
|
||||||
};
|
|
||||||
//# sourceMappingURL=index.js.map
|
//# sourceMappingURL=index.js.map
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,9 @@
|
||||||
|
<a name="module_lib/frame"></a>
|
||||||
|
|
||||||
|
## lib/frame
|
||||||
|
<a name="module_lib/frame..Frame"></a>
|
||||||
|
|
||||||
|
### lib/frame~Frame
|
||||||
|
Class representing the static Frame module.
|
||||||
|
|
||||||
|
**Kind**: inner class of [<code>lib/frame</code>](#module_lib/frame)
|
|
@ -0,0 +1,19 @@
|
||||||
|
interface RGBA {
|
||||||
|
r: number;
|
||||||
|
g: number;
|
||||||
|
b: number;
|
||||||
|
a: number;
|
||||||
|
}
|
||||||
|
/** @module lib/frame */
|
||||||
|
/**
|
||||||
|
* Class representing the static Frame module.
|
||||||
|
*/
|
||||||
|
export declare class Frame {
|
||||||
|
static info(imagePath: string): Promise<{
|
||||||
|
width: any;
|
||||||
|
height: any;
|
||||||
|
}>;
|
||||||
|
static solidColor(width: number, height: number, color: RGBA): Promise<unknown>;
|
||||||
|
static blend(inPath: any, color: RGBA, imagePath: string): Promise<string>;
|
||||||
|
}
|
||||||
|
export type { RGBA };
|
|
@ -3,7 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.Frame = void 0;
|
||||||
const jimp_1 = __importDefault(require("jimp"));
|
const jimp_1 = __importDefault(require("jimp"));
|
||||||
|
/** @module lib/frame */
|
||||||
|
/**
|
||||||
|
* Class representing the static Frame module.
|
||||||
|
*/
|
||||||
class Frame {
|
class Frame {
|
||||||
static async info(imagePath) {
|
static async info(imagePath) {
|
||||||
let image;
|
let image;
|
||||||
|
@ -65,6 +70,6 @@ class Frame {
|
||||||
return imagePath;
|
return imagePath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.default = Frame;
|
exports.Frame = Frame;
|
||||||
module.exports = Frame;
|
module.exports = { Frame };
|
||||||
//# sourceMappingURL=index.js.map
|
//# sourceMappingURL=index.js.map
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/frame/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;AAEb,gDAAwB;AASxB,MAAqB,KAAK;IACzB,MAAM,CAAC,KAAK,CAAC,IAAI,CAAE,SAAkB;QACpC,IAAI,KAAW,CAAC;QAChB,IAAI;YACH,KAAK,GAAG,MAAM,cAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SACnC;QAAC,OAAO,GAAG,EAAE;YACb,MAAM,GAAG,CAAC;SACV;QACD,OAAO;YACN,KAAK,EAAG,KAAK,CAAC,MAAM,CAAC,KAAK;YAC1B,MAAM,EAAG,KAAK,CAAC,MAAM,CAAC,MAAM;SAC5B,CAAC;IACH,CAAC;IACD,MAAM,CAAC,KAAK,CAAC,UAAU,CAAE,KAAc,EAAE,MAAe,EAAE,KAAY;QACrE,YAAY;QACZ,MAAM,QAAQ,GAAY,cAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;QAC7E,OAAO,IAAI,OAAO,CAAC,CAAC,OAAkB,EAAE,MAAiB,EAAE,EAAE;YAC5D,OAAO,IAAI,cAAI,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;gBACrD,IAAI,GAAG,EAAE;oBACR,OAAO,MAAM,CAAC,GAAG,CAAC,CAAA;iBAClB;gBACD,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;YACzB,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,KAAK,CAAE,MAAY,EAAE,KAAY,EAAE,SAAkB;QACjE,oKAAoK;QACpK,MAAM,OAAO,GAAS;YACrB,IAAI,EAAE,cAAI,CAAC,YAAY;YACvB,aAAa,EAAE,GAAG;YAClB,WAAW,EAAE,GAAG;SAChB,CAAC;QACF,IAAI,KAAc,CAAC;QACnB,IAAI,MAAe,CAAC;QACpB,IAAI,MAAY,CAAC;QACjB,IAAI,GAAS,CAAC;QAEd,IAAI;YACH,GAAG,GAAG,MAAM,cAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAC9B;QAAC,OAAO,GAAG,EAAE;YACb,MAAM,GAAG,CAAC;SACV;QAED,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC;QACzB,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC;QAE3B,IAAI;YACH,MAAM,GAAG,MAAM,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;SACtD;QAAC,OAAO,GAAG,EAAE;YACb,MAAM,GAAG,CAAC;SACV;QAED,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;QAErC,IAAI;YACH,MAAM,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;SACnC;QAAC,OAAO,GAAG,EAAE;YACb,MAAM,GAAG,CAAC;SACV;QAED,OAAO,SAAS,CAAC;IAClB,CAAC;CACD;AA/DD,wBA+DC;AAED,MAAM,CAAC,OAAO,GAAG,KAAK,CAAA"}
|
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/frame/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;AAEb,gDAAwB;AASxB,wBAAwB;AAExB;;GAEG;AAEH,MAAa,KAAK;IACjB,MAAM,CAAC,KAAK,CAAC,IAAI,CAAE,SAAkB;QACpC,IAAI,KAAW,CAAC;QAChB,IAAI;YACH,KAAK,GAAG,MAAM,cAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SACnC;QAAC,OAAO,GAAG,EAAE;YACb,MAAM,GAAG,CAAC;SACV;QACD,OAAO;YACN,KAAK,EAAG,KAAK,CAAC,MAAM,CAAC,KAAK;YAC1B,MAAM,EAAG,KAAK,CAAC,MAAM,CAAC,MAAM;SAC5B,CAAC;IACH,CAAC;IACD,MAAM,CAAC,KAAK,CAAC,UAAU,CAAE,KAAc,EAAE,MAAe,EAAE,KAAY;QACrE,YAAY;QACZ,MAAM,QAAQ,GAAY,cAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;QAC7E,OAAO,IAAI,OAAO,CAAC,CAAC,OAAkB,EAAE,MAAiB,EAAE,EAAE;YAC5D,OAAO,IAAI,cAAI,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;gBACrD,IAAI,GAAG,EAAE;oBACR,OAAO,MAAM,CAAC,GAAG,CAAC,CAAA;iBAClB;gBACD,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;YACzB,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,KAAK,CAAE,MAAY,EAAE,KAAY,EAAE,SAAkB;QACjE,oKAAoK;QACpK,MAAM,OAAO,GAAS;YACrB,IAAI,EAAE,cAAI,CAAC,YAAY;YACvB,aAAa,EAAE,GAAG;YAClB,WAAW,EAAE,GAAG;SAChB,CAAC;QACF,IAAI,KAAc,CAAC;QACnB,IAAI,MAAe,CAAC;QACpB,IAAI,MAAY,CAAC;QACjB,IAAI,GAAS,CAAC;QAEd,IAAI;YACH,GAAG,GAAG,MAAM,cAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAC9B;QAAC,OAAO,GAAG,EAAE;YACb,MAAM,GAAG,CAAC;SACV;QAED,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC;QACzB,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC;QAE3B,IAAI;YACH,MAAM,GAAG,MAAM,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;SACtD;QAAC,OAAO,GAAG,EAAE;YACb,MAAM,GAAG,CAAC;SACV;QAED,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;QAErC,IAAI;YACH,MAAM,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;SACnC;QAAC,OAAO,GAAG,EAAE;YACb,MAAM,GAAG,CAAC;SACV;QAED,OAAO,SAAS,CAAC;IAClB,CAAC;CACD;AA/DD,sBA+DC;AAED,MAAM,CAAC,OAAO,GAAG,EAAE,KAAK,EAAE,CAAA"}
|
|
@ -0,0 +1,9 @@
|
||||||
|
<a name="module_lib/intval"></a>
|
||||||
|
|
||||||
|
## lib/intval
|
||||||
|
<a name="module_lib/intval..Intval"></a>
|
||||||
|
|
||||||
|
### lib/intval~Intval
|
||||||
|
Class representing all intval3 camera features.
|
||||||
|
|
||||||
|
**Kind**: inner class of [<code>lib/intval</code>](#module_lib/intval)
|
|
@ -0,0 +1,12 @@
|
||||||
|
/** @module lib/intval */
|
||||||
|
/**
|
||||||
|
* Class representing all intval3 camera features.
|
||||||
|
*/
|
||||||
|
export declare class Intval {
|
||||||
|
private _baseUrl;
|
||||||
|
constructor(url: string);
|
||||||
|
move(): Promise<number>;
|
||||||
|
setDir(dir: boolean): Promise<number>;
|
||||||
|
setExposure(exposure: number, cb: Function): Promise<number>;
|
||||||
|
connect(cb: Function): void;
|
||||||
|
}
|
|
@ -1,15 +1,44 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||||
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||||
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||||
|
}
|
||||||
|
Object.defineProperty(o, k2, desc);
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.Intval = void 0;
|
||||||
|
const request = __importStar(require("request"));
|
||||||
|
/** @module lib/intval */
|
||||||
|
/**
|
||||||
|
* Class representing all intval3 camera features.
|
||||||
|
*/
|
||||||
class Intval {
|
class Intval {
|
||||||
constructor(url) {
|
constructor(url) {
|
||||||
this._baseUrl = `http://${url}`;
|
this._baseUrl = `http://${url}`;
|
||||||
this.req = require('request');
|
|
||||||
}
|
}
|
||||||
async move() {
|
async move() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const timeStart = +new Date();
|
const timeStart = +new Date();
|
||||||
const url = `${this._baseUrl}/frame`;
|
const url = `${this._baseUrl}/frame`;
|
||||||
//console.log(url)
|
//console.log(url)
|
||||||
return this.req(url, (err, res, body) => {
|
return request(url, (err, res, body) => {
|
||||||
let ms = (+new Date()) - timeStart;
|
let ms = (+new Date()) - timeStart;
|
||||||
if (err) {
|
if (err) {
|
||||||
return reject(err);
|
return reject(err);
|
||||||
|
@ -23,7 +52,7 @@ class Intval {
|
||||||
const timeStart = +new Date();
|
const timeStart = +new Date();
|
||||||
const url = `${this._baseUrl}/dir?dir=${dir}`;
|
const url = `${this._baseUrl}/dir?dir=${dir}`;
|
||||||
//console.log(url)
|
//console.log(url)
|
||||||
return this.req(url, (err, res, body) => {
|
return request(url, (err, res, body) => {
|
||||||
let ms = (+new Date()) - timeStart;
|
let ms = (+new Date()) - timeStart;
|
||||||
if (err) {
|
if (err) {
|
||||||
return reject(err);
|
return reject(err);
|
||||||
|
@ -36,8 +65,7 @@ class Intval {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const timeStart = +new Date();
|
const timeStart = +new Date();
|
||||||
const url = `${this._baseUrl}/exposure?exposure=${exposure}`;
|
const url = `${this._baseUrl}/exposure?exposure=${exposure}`;
|
||||||
//console.log(url)
|
return request(url, (err, res, body) => {
|
||||||
return this.req(url, (err, res, body) => {
|
|
||||||
let ms = (+new Date()) - timeStart;
|
let ms = (+new Date()) - timeStart;
|
||||||
if (err) {
|
if (err) {
|
||||||
return reject(err);
|
return reject(err);
|
||||||
|
@ -54,15 +82,15 @@ class Intval {
|
||||||
uri: url,
|
uri: url,
|
||||||
timeout: 5000
|
timeout: 5000
|
||||||
};
|
};
|
||||||
this.req(opts, (err, res, body) => {
|
request(opts, (err, res, body) => {
|
||||||
let ms = (+new Date()) - timeStart;
|
let ms = (+new Date()) - timeStart;
|
||||||
if (err) {
|
if (err) {
|
||||||
//console.error(err)
|
|
||||||
return cb(err, ms);
|
return cb(err, ms);
|
||||||
}
|
}
|
||||||
cb(null, ms, body);
|
cb(null, ms, body);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.exports.Intval = Intval;
|
exports.Intval = Intval;
|
||||||
|
module.exports = { Intval };
|
||||||
//# sourceMappingURL=index.js.map
|
//# sourceMappingURL=index.js.map
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/intval/index.ts"],"names":[],"mappings":"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"}
|
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/intval/index.ts"],"names":[],"mappings":"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"}
|
|
@ -1,32 +1,46 @@
|
||||||
<a name="Light"></a>
|
<a name="module_lib/light"></a>
|
||||||
|
|
||||||
## Light
|
## lib/light
|
||||||
**Kind**: global class
|
|
||||||
|
|
||||||
* [Light](#Light)
|
* [lib/light](#module_lib/light)
|
||||||
* [.init()](#Light+init)
|
* [~Light](#module_lib/light..Light)
|
||||||
* [.listen()](#Light+listen)
|
* [.init()](#module_lib/light..Light+init)
|
||||||
* [.listener()](#Light+listener)
|
* [.listen()](#module_lib/light..Light+listen)
|
||||||
* [.set()](#Light+set)
|
* [.listener()](#module_lib/light..Light+listener)
|
||||||
* [.end()](#Light+end)
|
* [.set()](#module_lib/light..Light+set)
|
||||||
|
* [.end()](#module_lib/light..Light+end)
|
||||||
|
|
||||||
<a name="Light+init"></a>
|
<a name="module_lib/light..Light"></a>
|
||||||
|
|
||||||
### light.init()
|
### lib/light~Light
|
||||||
**Kind**: instance method of [<code>Light</code>](#Light)
|
Class representing the all light features.
|
||||||
<a name="Light+listen"></a>
|
|
||||||
|
|
||||||
### light.listen()
|
**Kind**: inner class of [<code>lib/light</code>](#module_lib/light)
|
||||||
**Kind**: instance method of [<code>Light</code>](#Light)
|
|
||||||
<a name="Light+listener"></a>
|
|
||||||
|
|
||||||
### light.listener()
|
* [~Light](#module_lib/light..Light)
|
||||||
**Kind**: instance method of [<code>Light</code>](#Light)
|
* [.init()](#module_lib/light..Light+init)
|
||||||
<a name="Light+set"></a>
|
* [.listen()](#module_lib/light..Light+listen)
|
||||||
|
* [.listener()](#module_lib/light..Light+listener)
|
||||||
|
* [.set()](#module_lib/light..Light+set)
|
||||||
|
* [.end()](#module_lib/light..Light+end)
|
||||||
|
|
||||||
### light.set()
|
<a name="module_lib/light..Light+init"></a>
|
||||||
**Kind**: instance method of [<code>Light</code>](#Light)
|
|
||||||
<a name="Light+end"></a>
|
|
||||||
|
|
||||||
### light.end()
|
#### light.init()
|
||||||
**Kind**: instance method of [<code>Light</code>](#Light)
|
**Kind**: instance method of [<code>Light</code>](#module_lib/light..Light)
|
||||||
|
<a name="module_lib/light..Light+listen"></a>
|
||||||
|
|
||||||
|
#### light.listen()
|
||||||
|
**Kind**: instance method of [<code>Light</code>](#module_lib/light..Light)
|
||||||
|
<a name="module_lib/light..Light+listener"></a>
|
||||||
|
|
||||||
|
#### light.listener()
|
||||||
|
**Kind**: instance method of [<code>Light</code>](#module_lib/light..Light)
|
||||||
|
<a name="module_lib/light..Light+set"></a>
|
||||||
|
|
||||||
|
#### light.set()
|
||||||
|
**Kind**: instance method of [<code>Light</code>](#module_lib/light..Light)
|
||||||
|
<a name="module_lib/light..Light+end"></a>
|
||||||
|
|
||||||
|
#### light.end()
|
||||||
|
**Kind**: instance method of [<code>Light</code>](#module_lib/light..Light)
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
import type { Arduino } from 'arduino';
|
||||||
|
import type { Config } from 'cfg';
|
||||||
|
import type { WebContents } from 'electron';
|
||||||
|
interface LightState {
|
||||||
|
color: number[];
|
||||||
|
}
|
||||||
|
/** @module lib/light */
|
||||||
|
/**
|
||||||
|
* Class representing the all light features.
|
||||||
|
*/
|
||||||
|
export declare class Light {
|
||||||
|
state: LightState;
|
||||||
|
private arduino;
|
||||||
|
private cfg;
|
||||||
|
private ui;
|
||||||
|
private log;
|
||||||
|
private ipc;
|
||||||
|
private enabled;
|
||||||
|
private id;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
constructor(arduino: Arduino, cfg: Config, ui: WebContents);
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private init;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private listen;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private listener;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
set(rgb: number[], id: string, on?: boolean): Promise<number>;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private end;
|
||||||
|
}
|
||||||
|
export type { LightState };
|
|
@ -1,13 +1,20 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.Light = void 0;
|
||||||
|
const electron_1 = require("electron");
|
||||||
const delay_1 = require("delay");
|
const delay_1 = require("delay");
|
||||||
const Log = require("log");
|
const log_1 = require("log");
|
||||||
|
/** @module lib/light */
|
||||||
|
/**
|
||||||
|
* Class representing the all light features.
|
||||||
|
*/
|
||||||
class Light {
|
class Light {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
constructor(arduino, cfg, ui) {
|
constructor(arduino, cfg, ui) {
|
||||||
this.state = { color: [0, 0, 0] };
|
this.state = { color: [0, 0, 0] };
|
||||||
|
this.ipc = electron_1.ipcMain;
|
||||||
this.enabled = true;
|
this.enabled = true;
|
||||||
this.id = 'light';
|
this.id = 'light';
|
||||||
this.arduino = arduino;
|
this.arduino = arduino;
|
||||||
|
@ -19,15 +26,14 @@ class Light {
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
async init() {
|
async init() {
|
||||||
this.log = await Log({ label: this.id });
|
this.log = await (0, log_1.Log)({ label: this.id });
|
||||||
this.ipc = require('electron').ipcMain;
|
|
||||||
this.listen();
|
this.listen();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
listen() {
|
listen() {
|
||||||
this.ipc.on(this.id, this.listener.bind(this));
|
this.ipc.handle(this.id, this.listener.bind(this));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -47,7 +53,6 @@ class Light {
|
||||||
else if (typeof arg.disable !== 'undefined') {
|
else if (typeof arg.disable !== 'undefined') {
|
||||||
this.enabled = false;
|
this.enabled = false;
|
||||||
}
|
}
|
||||||
event.returnValue = true;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -62,36 +67,34 @@ class Light {
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error('Error sending light command', err);
|
this.log.error('Error sending light command', err);
|
||||||
}
|
}
|
||||||
await delay_1.delay(1);
|
await (0, delay_1.delay)(1);
|
||||||
try {
|
try {
|
||||||
this.arduino.string(this.id, str);
|
ms += await this.arduino.sendString(this.id, str);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error('Error sending light string', err);
|
this.log.error('Error sending light string', err);
|
||||||
}
|
}
|
||||||
await delay_1.delay(1);
|
await (0, delay_1.delay)(1);
|
||||||
await ms;
|
ms += 2;
|
||||||
return await this.end(rgb, id, ms);
|
await this.end(rgb, id, ms);
|
||||||
|
return ms;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
async end(rgb, id, ms) {
|
async end(rgb, id, ms) {
|
||||||
let res;
|
let res;
|
||||||
//console.trace()
|
|
||||||
this.log.info(`Light set to ${rgb.join(',')}`, 'LIGHT', true, true);
|
this.log.info(`Light set to ${rgb.join(',')}`, 'LIGHT', true, true);
|
||||||
try {
|
try {
|
||||||
//console.dir({ rgb, id, ms })
|
|
||||||
res = await this.ui.send(this.id, { rgb, id, ms });
|
res = await this.ui.send(this.id, { rgb, id, ms });
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(err);
|
this.log.error(`Error ending light`, err);
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.exports = function (arduino, cfg, ui) {
|
exports.Light = Light;
|
||||||
return new Light(arduino, cfg, ui);
|
module.exports = { Light };
|
||||||
};
|
|
||||||
//# sourceMappingURL=index.js.map
|
//# sourceMappingURL=index.js.map
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/light/index.ts"],"names":[],"mappings":"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"}
|
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/light/index.ts"],"names":[],"mappings":"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"}
|
|
@ -1,3 +1,16 @@
|
||||||
|
## Functions
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><a href="#logFile">logFile()</a> ⇒ <code>string</code></dt>
|
||||||
|
<dd><p>Determine the location of the log file based on the operating system
|
||||||
|
and return as an absolute string from os.homedir()</p>
|
||||||
|
</dd>
|
||||||
|
<dt><a href="#Log">Log(arg)</a> ⇒ <code>object</code></dt>
|
||||||
|
<dd><p>Create and return the logger transport based on settings determined in
|
||||||
|
arguments object</p>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
|
||||||
<a name="logFile"></a>
|
<a name="logFile"></a>
|
||||||
|
|
||||||
## logFile() ⇒ <code>string</code>
|
## logFile() ⇒ <code>string</code>
|
||||||
|
@ -6,3 +19,16 @@ and return as an absolute string from os.homedir()
|
||||||
|
|
||||||
**Kind**: global function
|
**Kind**: global function
|
||||||
**Returns**: <code>string</code> - Path to log file
|
**Returns**: <code>string</code> - Path to log file
|
||||||
|
<a name="Log"></a>
|
||||||
|
|
||||||
|
## Log(arg) ⇒ <code>object</code>
|
||||||
|
Create and return the logger transport based on settings determined in
|
||||||
|
arguments object
|
||||||
|
|
||||||
|
**Kind**: global function
|
||||||
|
**Returns**: <code>object</code> - Logger transport
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| arg | <code>object</code> | Arguments from process |
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
import type { Logger } from 'winston';
|
||||||
|
/**
|
||||||
|
* Create and return the logger transport based on settings determined in
|
||||||
|
* arguments object
|
||||||
|
*
|
||||||
|
* @param {object} arg Arguments from process
|
||||||
|
*
|
||||||
|
* @returns {object} Logger transport
|
||||||
|
**/
|
||||||
|
export declare function Log(arg: any): Promise<Logger>;
|
|
@ -1,11 +1,11 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.Log = void 0;
|
||||||
const winston_1 = require("winston");
|
const winston_1 = require("winston");
|
||||||
const path_1 = require("path");
|
const path_1 = require("path");
|
||||||
const fs_extra_1 = require("fs-extra");
|
const fs_extra_1 = require("fs-extra");
|
||||||
const os_1 = require("os");
|
const os_1 = require("os");
|
||||||
const logTime = 'MM/DD/YY-HH:mm:ss';
|
const logTime = 'MM/DD/YY-HH:mm:ss';
|
||||||
let transport;
|
|
||||||
/**
|
/**
|
||||||
* Determine the location of the log file based on the operating system
|
* Determine the location of the log file based on the operating system
|
||||||
* and return as an absolute string from os.homedir()
|
* and return as an absolute string from os.homedir()
|
||||||
|
@ -13,34 +13,34 @@ let transport;
|
||||||
* @returns {string} Path to log file
|
* @returns {string} Path to log file
|
||||||
**/
|
**/
|
||||||
async function logFile() {
|
async function logFile() {
|
||||||
const homeDir = os_1.homedir();
|
const homeDir = (0, os_1.homedir)();
|
||||||
const linuxDir = `/.mcopy/`;
|
const linuxDir = `/.mcopy/`;
|
||||||
const macDir = `/Library/Logs/mcopy/`;
|
const macDir = `/Library/Logs/mcopy/`;
|
||||||
const winDir = `/AppData/Roaming/mcopy/`;
|
const winDir = `/AppData/Roaming/mcopy/`;
|
||||||
let logPath = path_1.normalize(path_1.join(homeDir, linuxDir));
|
let logPath = (0, path_1.normalize)((0, path_1.join)(homeDir, linuxDir));
|
||||||
let dirExists;
|
let dirExists;
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
logPath = path_1.normalize(path_1.join(homeDir, macDir));
|
logPath = (0, path_1.normalize)((0, path_1.join)(homeDir, macDir));
|
||||||
}
|
}
|
||||||
else if (process.platform === 'win32') {
|
else if (process.platform === 'win32') {
|
||||||
logPath = path_1.normalize(path_1.join(homeDir, winDir));
|
logPath = (0, path_1.normalize)((0, path_1.join)(homeDir, winDir));
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
dirExists = await fs_extra_1.exists(logPath);
|
dirExists = await (0, fs_extra_1.exists)(logPath);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
if (!dirExists) {
|
if (!dirExists) {
|
||||||
try {
|
try {
|
||||||
await fs_extra_1.mkdir(logPath);
|
await (0, fs_extra_1.mkdir)(logPath);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(`Error creating directory for mcopy log file, ${logPath}`);
|
console.error(`Error creating directory for mcopy log file, ${logPath}`);
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return path_1.join(logPath, 'mcopy.log');
|
return (0, path_1.join)(logPath, 'mcopy.log');
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Create and return the logger transport based on settings determined in
|
* Create and return the logger transport based on settings determined in
|
||||||
|
@ -50,7 +50,8 @@ async function logFile() {
|
||||||
*
|
*
|
||||||
* @returns {object} Logger transport
|
* @returns {object} Logger transport
|
||||||
**/
|
**/
|
||||||
module.exports = async function (arg) {
|
async function Log(arg) {
|
||||||
|
let transport;
|
||||||
let consoleFormat = {
|
let consoleFormat = {
|
||||||
colorize: true
|
colorize: true
|
||||||
};
|
};
|
||||||
|
@ -58,28 +59,21 @@ module.exports = async function (arg) {
|
||||||
filename: await logFile(),
|
filename: await logFile(),
|
||||||
json: true
|
json: true
|
||||||
};
|
};
|
||||||
if (arg && arg.quiet) {
|
if (arg && arg.label) {
|
||||||
transport = {
|
consoleFormat.label = arg.label;
|
||||||
info: function () { return false; },
|
fileFormat.label = arg.label;
|
||||||
warn: function () { return false; },
|
|
||||||
error: function () { return false; }
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (arg && arg.label) {
|
|
||||||
consoleFormat.label = arg.label;
|
|
||||||
fileFormat.label = arg.label;
|
|
||||||
}
|
|
||||||
transport = winston_1.createLogger({
|
|
||||||
format: winston_1.format.combine(winston_1.format.label({ label: arg.label || 'mcopy' }), winston_1.format.timestamp({
|
|
||||||
format: 'YYYY-MM-DD HH:mm:ss'
|
|
||||||
}), winston_1.format.printf((info) => `${info.timestamp} [${info.label}] ${info.level}: ${info.message}` + (info.splat !== undefined ? `${info.splat}` : " "))),
|
|
||||||
transports: [
|
|
||||||
new (winston_1.transports.Console)(consoleFormat),
|
|
||||||
new (winston_1.transports.File)(fileFormat)
|
|
||||||
]
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
transport = (0, winston_1.createLogger)({
|
||||||
|
format: winston_1.format.combine(winston_1.format.label({ label: arg.label || 'mcopy' }), winston_1.format.timestamp({
|
||||||
|
format: 'YYYY-MM-DD HH:mm:ss'
|
||||||
|
}), winston_1.format.printf((info) => `${info.timestamp} [${info.label}] ${info.level}: ${info.message}` + (info.splat !== undefined ? `${info.splat}` : " "))),
|
||||||
|
transports: [
|
||||||
|
new (winston_1.transports.Console)(consoleFormat),
|
||||||
|
new (winston_1.transports.File)(fileFormat)
|
||||||
|
]
|
||||||
|
});
|
||||||
return transport;
|
return transport;
|
||||||
};
|
}
|
||||||
|
exports.Log = Log;
|
||||||
|
module.exports = { Log };
|
||||||
//# sourceMappingURL=index.js.map
|
//# sourceMappingURL=index.js.map
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/log/index.ts"],"names":[],"mappings":"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"}
|
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/log/index.ts"],"names":[],"mappings":"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"}
|
|
@ -3,57 +3,83 @@
|
||||||
## lib/mscript
|
## lib/mscript
|
||||||
|
|
||||||
* [lib/mscript](#module_lib/mscript)
|
* [lib/mscript](#module_lib/mscript)
|
||||||
|
* [~Create new Mscript interpreter](#module_lib/mscript..Create new Mscript interpreter)
|
||||||
* [~Mscript](#module_lib/mscript..Mscript)
|
* [~Mscript](#module_lib/mscript..Mscript)
|
||||||
* [.clear()](#module_lib/mscript..Mscript+clear)
|
* [.clear()](#module_lib/mscript..Mscript+clear)
|
||||||
* [.interpret()](#module_lib/mscript..Mscript+interpret)
|
* [.interpret(text, callback)](#module_lib/mscript..Mscript+interpret) ⇒ <code>object</code>
|
||||||
* [.basic_cmd()](#module_lib/mscript..Mscript+basic_cmd)
|
* [.variable(line)](#module_lib/mscript..Mscript+variable)
|
||||||
* [.new_loop()](#module_lib/mscript..Mscript+new_loop)
|
* [.variable_replace(line)](#module_lib/mscript..Mscript+variable_replace) ⇒ <code>string</code>
|
||||||
* [.end_loop()](#module_lib/mscript..Mscript+end_loop)
|
* [.basic_cmd(line, short)](#module_lib/mscript..Mscript+basic_cmd)
|
||||||
* [.move_cam()](#module_lib/mscript..Mscript+move_cam)
|
* [.new_loop(line, fade)](#module_lib/mscript..Mscript+new_loop)
|
||||||
* [.move_proj()](#module_lib/mscript..Mscript+move_proj)
|
* [.end_loop(line)](#module_lib/mscript..Mscript+end_loop)
|
||||||
* [.set_state()](#module_lib/mscript..Mscript+set_state)
|
* [.move_cam(line)](#module_lib/mscript..Mscript+move_cam)
|
||||||
* [.last_loop()](#module_lib/mscript..Mscript+last_loop)
|
* [.move_cam2(line)](#module_lib/mscript..Mscript+move_cam2)
|
||||||
* [.parent_loop()](#module_lib/mscript..Mscript+parent_loop)
|
* [.move_proj(line)](#module_lib/mscript..Mscript+move_proj)
|
||||||
* [.loop_count()](#module_lib/mscript..Mscript+loop_count)
|
* [.move_proj2(line)](#module_lib/mscript..Mscript+move_proj2)
|
||||||
* [.fade()](#module_lib/mscript..Mscript+fade)
|
* [.set_state(line)](#module_lib/mscript..Mscript+set_state)
|
||||||
* [.fade_count()](#module_lib/mscript..Mscript+fade_count)
|
* [.last_loop()](#module_lib/mscript..Mscript+last_loop) ⇒ <code>object</code>
|
||||||
* [.fade_start()](#module_lib/mscript..Mscript+fade_start)
|
* [.parent_loop()](#module_lib/mscript..Mscript+parent_loop) ⇒ <code>object</code>
|
||||||
* [.fade_end()](#module_lib/mscript..Mscript+fade_end)
|
* [.loop_count()](#module_lib/mscript..Mscript+loop_count) ⇒ <code>integer</code>
|
||||||
* [.update()](#module_lib/mscript..Mscript+update)
|
* [.fade(line)](#module_lib/mscript..Mscript+fade)
|
||||||
* [.str_to_arr()](#module_lib/mscript..Mscript+str_to_arr)
|
* [.fade_count(str)](#module_lib/mscript..Mscript+fade_count)
|
||||||
* [.light_to_arr()](#module_lib/mscript..Mscript+light_to_arr)
|
* [.fade_start(str)](#module_lib/mscript..Mscript+fade_start) ⇒ <code>array</code>
|
||||||
* [.light_state()](#module_lib/mscript..Mscript+light_state)
|
* [.fade_end(str)](#module_lib/mscript..Mscript+fade_end) ⇒ <code>array</code>
|
||||||
* [.fail()](#module_lib/mscript..Mscript+fail)
|
* [.fade_rgb(start, end, len, x)](#module_lib/mscript..Mscript+fade_rgb) ⇒ <code>array</code>
|
||||||
* [~startsWith()](#module_lib/mscript..startsWith)
|
* [.rgb(str)](#module_lib/mscript..Mscript+rgb)
|
||||||
|
* [.rgb_str(arr)](#module_lib/mscript..Mscript+rgb_str) ⇒ <code>string</code>
|
||||||
|
* [.update(cmd)](#module_lib/mscript..Mscript+update)
|
||||||
|
* [.str_to_arr(str, cmd)](#module_lib/mscript..Mscript+str_to_arr) ⇒ <code>array</code>
|
||||||
|
* [.light_to_arr(str, cmd)](#module_lib/mscript..Mscript+light_to_arr) ⇒ <code>array</code>
|
||||||
|
* [.light_state(Color)](#module_lib/mscript..Mscript+light_state)
|
||||||
|
* [.delay(line)](#module_lib/mscript..Mscript+delay)
|
||||||
|
* [.alert(line)](#module_lib/mscript..Mscript+alert)
|
||||||
|
* [.pause(line)](#module_lib/mscript..Mscript+pause)
|
||||||
|
* [.fail(msg)](#module_lib/mscript..Mscript+fail)
|
||||||
|
* [.contains(arr, arr2)](#module_lib/mscript..Mscript+contains) ⇒ <code>boolean</code>
|
||||||
|
|
||||||
|
<a name="module_lib/mscript..Create new Mscript interpreter"></a>
|
||||||
|
|
||||||
|
### lib/mscript~Create new Mscript interpreter
|
||||||
|
**Kind**: inner class of [<code>lib/mscript</code>](#module_lib/mscript)
|
||||||
<a name="module_lib/mscript..Mscript"></a>
|
<a name="module_lib/mscript..Mscript"></a>
|
||||||
|
|
||||||
### lib/mscript~Mscript
|
### lib/mscript~Mscript
|
||||||
class Mscript
|
Class representing the mscript language.
|
||||||
|
|
||||||
**Kind**: inner class of [<code>lib/mscript</code>](#module_lib/mscript)
|
**Kind**: inner class of [<code>lib/mscript</code>](#module_lib/mscript)
|
||||||
|
|
||||||
* [~Mscript](#module_lib/mscript..Mscript)
|
* [~Mscript](#module_lib/mscript..Mscript)
|
||||||
* [.clear()](#module_lib/mscript..Mscript+clear)
|
* [.clear()](#module_lib/mscript..Mscript+clear)
|
||||||
* [.interpret()](#module_lib/mscript..Mscript+interpret)
|
* [.interpret(text, callback)](#module_lib/mscript..Mscript+interpret) ⇒ <code>object</code>
|
||||||
* [.basic_cmd()](#module_lib/mscript..Mscript+basic_cmd)
|
* [.variable(line)](#module_lib/mscript..Mscript+variable)
|
||||||
* [.new_loop()](#module_lib/mscript..Mscript+new_loop)
|
* [.variable_replace(line)](#module_lib/mscript..Mscript+variable_replace) ⇒ <code>string</code>
|
||||||
* [.end_loop()](#module_lib/mscript..Mscript+end_loop)
|
* [.basic_cmd(line, short)](#module_lib/mscript..Mscript+basic_cmd)
|
||||||
* [.move_cam()](#module_lib/mscript..Mscript+move_cam)
|
* [.new_loop(line, fade)](#module_lib/mscript..Mscript+new_loop)
|
||||||
* [.move_proj()](#module_lib/mscript..Mscript+move_proj)
|
* [.end_loop(line)](#module_lib/mscript..Mscript+end_loop)
|
||||||
* [.set_state()](#module_lib/mscript..Mscript+set_state)
|
* [.move_cam(line)](#module_lib/mscript..Mscript+move_cam)
|
||||||
* [.last_loop()](#module_lib/mscript..Mscript+last_loop)
|
* [.move_cam2(line)](#module_lib/mscript..Mscript+move_cam2)
|
||||||
* [.parent_loop()](#module_lib/mscript..Mscript+parent_loop)
|
* [.move_proj(line)](#module_lib/mscript..Mscript+move_proj)
|
||||||
* [.loop_count()](#module_lib/mscript..Mscript+loop_count)
|
* [.move_proj2(line)](#module_lib/mscript..Mscript+move_proj2)
|
||||||
* [.fade()](#module_lib/mscript..Mscript+fade)
|
* [.set_state(line)](#module_lib/mscript..Mscript+set_state)
|
||||||
* [.fade_count()](#module_lib/mscript..Mscript+fade_count)
|
* [.last_loop()](#module_lib/mscript..Mscript+last_loop) ⇒ <code>object</code>
|
||||||
* [.fade_start()](#module_lib/mscript..Mscript+fade_start)
|
* [.parent_loop()](#module_lib/mscript..Mscript+parent_loop) ⇒ <code>object</code>
|
||||||
* [.fade_end()](#module_lib/mscript..Mscript+fade_end)
|
* [.loop_count()](#module_lib/mscript..Mscript+loop_count) ⇒ <code>integer</code>
|
||||||
* [.update()](#module_lib/mscript..Mscript+update)
|
* [.fade(line)](#module_lib/mscript..Mscript+fade)
|
||||||
* [.str_to_arr()](#module_lib/mscript..Mscript+str_to_arr)
|
* [.fade_count(str)](#module_lib/mscript..Mscript+fade_count)
|
||||||
* [.light_to_arr()](#module_lib/mscript..Mscript+light_to_arr)
|
* [.fade_start(str)](#module_lib/mscript..Mscript+fade_start) ⇒ <code>array</code>
|
||||||
* [.light_state()](#module_lib/mscript..Mscript+light_state)
|
* [.fade_end(str)](#module_lib/mscript..Mscript+fade_end) ⇒ <code>array</code>
|
||||||
* [.fail()](#module_lib/mscript..Mscript+fail)
|
* [.fade_rgb(start, end, len, x)](#module_lib/mscript..Mscript+fade_rgb) ⇒ <code>array</code>
|
||||||
|
* [.rgb(str)](#module_lib/mscript..Mscript+rgb)
|
||||||
|
* [.rgb_str(arr)](#module_lib/mscript..Mscript+rgb_str) ⇒ <code>string</code>
|
||||||
|
* [.update(cmd)](#module_lib/mscript..Mscript+update)
|
||||||
|
* [.str_to_arr(str, cmd)](#module_lib/mscript..Mscript+str_to_arr) ⇒ <code>array</code>
|
||||||
|
* [.light_to_arr(str, cmd)](#module_lib/mscript..Mscript+light_to_arr) ⇒ <code>array</code>
|
||||||
|
* [.light_state(Color)](#module_lib/mscript..Mscript+light_state)
|
||||||
|
* [.delay(line)](#module_lib/mscript..Mscript+delay)
|
||||||
|
* [.alert(line)](#module_lib/mscript..Mscript+alert)
|
||||||
|
* [.pause(line)](#module_lib/mscript..Mscript+pause)
|
||||||
|
* [.fail(msg)](#module_lib/mscript..Mscript+fail)
|
||||||
|
* [.contains(arr, arr2)](#module_lib/mscript..Mscript+contains) ⇒ <code>boolean</code>
|
||||||
|
|
||||||
<a name="module_lib/mscript..Mscript+clear"></a>
|
<a name="module_lib/mscript..Mscript+clear"></a>
|
||||||
|
|
||||||
|
@ -63,124 +89,343 @@ Clear the state of the script
|
||||||
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
||||||
<a name="module_lib/mscript..Mscript+interpret"></a>
|
<a name="module_lib/mscript..Mscript+interpret"></a>
|
||||||
|
|
||||||
#### mscript.interpret()
|
#### mscript.interpret(text, callback) ⇒ <code>object</code>
|
||||||
Main function, accepts multi-line string, parses into lines
|
Main function, accepts multi-line string, parses into lines
|
||||||
and interprets the instructions from the text. Returns an array
|
and interprets the instructions from the text. Returns an array
|
||||||
of steps to be fed into the mcopy.
|
of steps to be fed into the mcopy sequence.
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
||||||
|
**Returns**: <code>object</code> - if callback is not provided
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| text | <code>string</code> | Mscript text to interpret |
|
||||||
|
| callback | <code>function</code> | Function to call when string is interpreted |
|
||||||
|
|
||||||
|
<a name="module_lib/mscript..Mscript+variable"></a>
|
||||||
|
|
||||||
|
#### mscript.variable(line)
|
||||||
|
Interprets variables for complex sequence behavior.
|
||||||
|
TODO: Fully implement, add test coverage
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| line | <code>string</code> | Line containing a variable assignment |
|
||||||
|
|
||||||
|
<a name="module_lib/mscript..Mscript+variable_replace"></a>
|
||||||
|
|
||||||
|
#### mscript.variable\_replace(line) ⇒ <code>string</code>
|
||||||
|
Replace variable with value at time of interpretation
|
||||||
|
TODO: Implement this please
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
||||||
|
**Returns**: <code>string</code> - New string to be interpreted
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| line | <code>string</code> | Line containing variable to be replaced with value |
|
||||||
|
|
||||||
<a name="module_lib/mscript..Mscript+basic_cmd"></a>
|
<a name="module_lib/mscript..Mscript+basic_cmd"></a>
|
||||||
|
|
||||||
#### mscript.basic\_cmd()
|
#### mscript.basic\_cmd(line, short)
|
||||||
Apply a basic two character command
|
Interpret a basic two character command
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| line | <code>string</code> | Line of script to interpret |
|
||||||
|
| short | <code>string</code> | The short command to use |
|
||||||
|
|
||||||
<a name="module_lib/mscript..Mscript+new_loop"></a>
|
<a name="module_lib/mscript..Mscript+new_loop"></a>
|
||||||
|
|
||||||
#### mscript.new\_loop()
|
#### mscript.new\_loop(line, fade)
|
||||||
Start a new loop
|
Start a new loop
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| line | <code>string</code> | Line to evaluate as either loop or fade |
|
||||||
|
| fade | <code>boolean</code> | Flag as true if fade |
|
||||||
|
|
||||||
<a name="module_lib/mscript..Mscript+end_loop"></a>
|
<a name="module_lib/mscript..Mscript+end_loop"></a>
|
||||||
|
|
||||||
#### mscript.end\_loop()
|
#### mscript.end\_loop(line)
|
||||||
Close the most recent loop
|
Close the most recent loop
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| line | <code>string</code> | Line to interpret |
|
||||||
|
|
||||||
<a name="module_lib/mscript..Mscript+move_cam"></a>
|
<a name="module_lib/mscript..Mscript+move_cam"></a>
|
||||||
|
|
||||||
#### mscript.move\_cam()
|
#### mscript.move\_cam(line)
|
||||||
Move camera to explicitly-defined frame
|
Move camera to explicitly-defined frame
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| line | <code>string</code> | Line to interpret with camera move statement |
|
||||||
|
|
||||||
|
<a name="module_lib/mscript..Mscript+move_cam2"></a>
|
||||||
|
|
||||||
|
#### mscript.move\_cam2(line)
|
||||||
|
Move secondary camera to explicitly-defined frame
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| line | <code>string</code> | Line to interpret with camera move statement |
|
||||||
|
|
||||||
<a name="module_lib/mscript..Mscript+move_proj"></a>
|
<a name="module_lib/mscript..Mscript+move_proj"></a>
|
||||||
|
|
||||||
#### mscript.move\_proj()
|
#### mscript.move\_proj(line)
|
||||||
Move projector to explicitly-defined frame
|
Move projector to explicitly-defined frame
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| line | <code>string</code> | Line containing `move` statement to interpret |
|
||||||
|
|
||||||
|
<a name="module_lib/mscript..Mscript+move_proj2"></a>
|
||||||
|
|
||||||
|
#### mscript.move\_proj2(line)
|
||||||
|
Move projector to explicitly-defined frame
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| line | <code>string</code> | Line containing `move` statement to interpret |
|
||||||
|
|
||||||
<a name="module_lib/mscript..Mscript+set_state"></a>
|
<a name="module_lib/mscript..Mscript+set_state"></a>
|
||||||
|
|
||||||
#### mscript.set\_state()
|
#### mscript.set\_state(line)
|
||||||
Set the state of either the cam or projector
|
Set the state of either the cam or projector
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| line | <code>string</code> | String containing set statement |
|
||||||
|
|
||||||
<a name="module_lib/mscript..Mscript+last_loop"></a>
|
<a name="module_lib/mscript..Mscript+last_loop"></a>
|
||||||
|
|
||||||
#### mscript.last\_loop()
|
#### mscript.last\_loop() ⇒ <code>object</code>
|
||||||
Return the last loop
|
Return the last loop
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
||||||
<a name="module_lib/mscript..Mscript+parent_loop"></a>
|
<a name="module_lib/mscript..Mscript+parent_loop"></a>
|
||||||
|
|
||||||
#### mscript.parent\_loop()
|
#### mscript.parent\_loop() ⇒ <code>object</code>
|
||||||
Return the second-last loop
|
Return the second-last loop
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
||||||
|
**Returns**: <code>object</code> - Loop array
|
||||||
<a name="module_lib/mscript..Mscript+loop_count"></a>
|
<a name="module_lib/mscript..Mscript+loop_count"></a>
|
||||||
|
|
||||||
#### mscript.loop\_count()
|
#### mscript.loop\_count() ⇒ <code>integer</code>
|
||||||
Extract the loop count integer from a LOOP cmd
|
Extract the loop count integer from a LOOP cmd
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
||||||
|
**Returns**: <code>integer</code> - Loop count in string parsed into integer
|
||||||
<a name="module_lib/mscript..Mscript+fade"></a>
|
<a name="module_lib/mscript..Mscript+fade"></a>
|
||||||
|
|
||||||
#### mscript.fade()
|
#### mscript.fade(line)
|
||||||
Execute a fade of frame length, from color to another color
|
Execute a fade of frame length, from color to another color
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| line | <code>string</code> | Line containing a fade initiator |
|
||||||
|
|
||||||
<a name="module_lib/mscript..Mscript+fade_count"></a>
|
<a name="module_lib/mscript..Mscript+fade_count"></a>
|
||||||
|
|
||||||
#### mscript.fade\_count()
|
#### mscript.fade\_count(str)
|
||||||
Extract the fade length integer from a FADE cmd
|
Extract the fade length integer from a FADE cmd
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| str | <code>string</code> | Line containing the length of fade in frames |
|
||||||
|
|
||||||
<a name="module_lib/mscript..Mscript+fade_start"></a>
|
<a name="module_lib/mscript..Mscript+fade_start"></a>
|
||||||
|
|
||||||
#### mscript.fade\_start()
|
#### mscript.fade\_start(str) ⇒ <code>array</code>
|
||||||
Extract the start color from a string
|
Extract the start color from a string
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
||||||
|
**Returns**: <code>array</code> - Array containing RGB color values
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| str | <code>string</code> | Line containing the start color value in a fade initiator |
|
||||||
|
|
||||||
<a name="module_lib/mscript..Mscript+fade_end"></a>
|
<a name="module_lib/mscript..Mscript+fade_end"></a>
|
||||||
|
|
||||||
#### mscript.fade\_end()
|
#### mscript.fade\_end(str) ⇒ <code>array</code>
|
||||||
Extract the end color from a string
|
Extract the end color from a string
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
||||||
|
**Returns**: <code>array</code> - Array containing RGB color values
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| str | <code>string</code> | Line containing the end color value in a fade initiator |
|
||||||
|
|
||||||
|
<a name="module_lib/mscript..Mscript+fade_rgb"></a>
|
||||||
|
|
||||||
|
#### mscript.fade\_rgb(start, end, len, x) ⇒ <code>array</code>
|
||||||
|
Determine the state of a fade at a particular frame in the sequence, x
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
||||||
|
**Returns**: <code>array</code> - Array containing RGB color values
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| start | <code>array</code> | Color the fade starts at |
|
||||||
|
| end | <code>array</code> | Color the fade finishes at |
|
||||||
|
| len | <code>integer</code> | Total length of the fade in frames |
|
||||||
|
| x | <code>integer</code> | Position of the fade to get color value of |
|
||||||
|
|
||||||
|
<a name="module_lib/mscript..Mscript+rgb"></a>
|
||||||
|
|
||||||
|
#### mscript.rgb(str)
|
||||||
|
Parse string into array of RGB color values. 0-255 octet.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| str | <code>string</code> | String containing only color values as `#,#,#` |
|
||||||
|
|
||||||
|
<a name="module_lib/mscript..Mscript+rgb_str"></a>
|
||||||
|
|
||||||
|
#### mscript.rgb\_str(arr) ⇒ <code>string</code>
|
||||||
|
Cast RGB color values as string
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
||||||
|
**Returns**: <code>string</code> - String of RGB values
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| arr | <code>array</code> | Array to join into string |
|
||||||
|
|
||||||
<a name="module_lib/mscript..Mscript+update"></a>
|
<a name="module_lib/mscript..Mscript+update"></a>
|
||||||
|
|
||||||
#### mscript.update()
|
#### mscript.update(cmd)
|
||||||
Increase the state of a specific object, such as the camera/projector,
|
Increase the state of a specific object, such as the camera/projector,
|
||||||
by the value defined in val
|
by the value defined in val.
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| cmd | <code>string</code> | String representing command to interpret and update state |
|
||||||
|
|
||||||
<a name="module_lib/mscript..Mscript+str_to_arr"></a>
|
<a name="module_lib/mscript..Mscript+str_to_arr"></a>
|
||||||
|
|
||||||
#### mscript.str\_to\_arr()
|
#### mscript.str\_to\_arr(str, cmd) ⇒ <code>array</code>
|
||||||
Split string on command, extract any integers from string
|
Split string on command, turn into array of commands
|
||||||
|
as long as count variable. Default 1.
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
||||||
|
**Returns**: <code>array</code> - Array containing commands
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| str | <code>string</code> | String to split |
|
||||||
|
| cmd | <code>string</code> | String representing command to split at |
|
||||||
|
|
||||||
<a name="module_lib/mscript..Mscript+light_to_arr"></a>
|
<a name="module_lib/mscript..Mscript+light_to_arr"></a>
|
||||||
|
|
||||||
#### mscript.light\_to\_arr()
|
#### mscript.light\_to\_arr(str, cmd) ⇒ <code>array</code>
|
||||||
Split a string on a command to extract data for light array
|
Split a string on a command to extract data for light array
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
||||||
|
**Returns**: <code>array</code> - An RGB array containing the color values
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| str | <code>string</code> | String containing light command |
|
||||||
|
| cmd | <code>string</code> | String representing command |
|
||||||
|
|
||||||
<a name="module_lib/mscript..Mscript+light_state"></a>
|
<a name="module_lib/mscript..Mscript+light_state"></a>
|
||||||
|
|
||||||
#### mscript.light\_state()
|
#### mscript.light\_state(Color)
|
||||||
Split a string to extract an rgb color value
|
Split a string to extract an rgb color value
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| Color | <code>string</code> | string assign to color property |
|
||||||
|
|
||||||
|
<a name="module_lib/mscript..Mscript+delay"></a>
|
||||||
|
|
||||||
|
#### mscript.delay(line)
|
||||||
|
Interpret a delay command
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| line | <code>string</code> | String containing delay command |
|
||||||
|
|
||||||
|
<a name="module_lib/mscript..Mscript+alert"></a>
|
||||||
|
|
||||||
|
#### mscript.alert(line)
|
||||||
|
Interpret an alert command
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| line | <code>string</code> | String containing alert message |
|
||||||
|
|
||||||
|
<a name="module_lib/mscript..Mscript+pause"></a>
|
||||||
|
|
||||||
|
#### mscript.pause(line)
|
||||||
|
Interpret an pause command
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| line | <code>string</code> | String containing alert message |
|
||||||
|
|
||||||
<a name="module_lib/mscript..Mscript+fail"></a>
|
<a name="module_lib/mscript..Mscript+fail"></a>
|
||||||
|
|
||||||
#### mscript.fail()
|
#### mscript.fail(msg)
|
||||||
Throw an error with specific message
|
Throw an error with specific message
|
||||||
|
|
||||||
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
||||||
<a name="module_lib/mscript..startsWith"></a>
|
|
||||||
|
|
||||||
### lib/mscript~startsWith()
|
| Param | Type | Description |
|
||||||
startswith function from lodash, do not want the entire lib for this
|
| --- | --- | --- |
|
||||||
|
| msg | <code>string</code> | Error message to print |
|
||||||
|
|
||||||
|
<a name="module_lib/mscript..Mscript+contains"></a>
|
||||||
|
|
||||||
|
#### mscript.contains(arr, arr2) ⇒ <code>boolean</code>
|
||||||
|
Determine if array contains matching elements of
|
||||||
|
another array
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Mscript</code>](#module_lib/mscript..Mscript)
|
||||||
|
**Returns**: <code>boolean</code> - Whether arr contains elements in arr2
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| arr | <code>Array</code> | Original array to compare |
|
||||||
|
| arr2 | <code>Array</code> | Array to compare elements from |
|
||||||
|
|
||||||
**Kind**: inner method of [<code>lib/mscript</code>](#module_lib/mscript)
|
|
||||||
|
|
|
@ -0,0 +1,260 @@
|
||||||
|
interface MscriptOutput {
|
||||||
|
success: boolean;
|
||||||
|
arr: string[];
|
||||||
|
meta: string[];
|
||||||
|
cam: number;
|
||||||
|
proj: number;
|
||||||
|
cam2?: number;
|
||||||
|
proj2?: number;
|
||||||
|
}
|
||||||
|
interface RGB extends Array<number> {
|
||||||
|
[index: number]: number;
|
||||||
|
}
|
||||||
|
/** @module lib/mscript */
|
||||||
|
/**
|
||||||
|
* Class representing the mscript language.
|
||||||
|
*/
|
||||||
|
export default class Mscript {
|
||||||
|
private output;
|
||||||
|
private lines;
|
||||||
|
private cam;
|
||||||
|
private cam2;
|
||||||
|
private proj;
|
||||||
|
private proj2;
|
||||||
|
private color;
|
||||||
|
private loops;
|
||||||
|
private rec;
|
||||||
|
private two;
|
||||||
|
private three;
|
||||||
|
private four;
|
||||||
|
private arr;
|
||||||
|
private meta;
|
||||||
|
private target;
|
||||||
|
private dist;
|
||||||
|
private variables;
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* Create new Mscript interpreter
|
||||||
|
**/
|
||||||
|
constructor();
|
||||||
|
/**
|
||||||
|
* Clear the state of the script
|
||||||
|
*/
|
||||||
|
private clear;
|
||||||
|
/**
|
||||||
|
* Main function, accepts multi-line string, parses into lines
|
||||||
|
* and interprets the instructions from the text. Returns an array
|
||||||
|
* of steps to be fed into the mcopy sequence.
|
||||||
|
*
|
||||||
|
* @param {string} text Mscript text to interpret
|
||||||
|
* @param {function} callback Function to call when string is interpreted
|
||||||
|
*
|
||||||
|
* @returns {object} if callback is not provided
|
||||||
|
*/
|
||||||
|
interpret(text: string): void | MscriptOutput;
|
||||||
|
/**
|
||||||
|
* Interprets variables for complex sequence behavior.
|
||||||
|
* TODO: Fully implement, add test coverage
|
||||||
|
*
|
||||||
|
* @param {string} line Line containing a variable assignment
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private variable;
|
||||||
|
/**
|
||||||
|
* Replace variable with value at time of interpretation
|
||||||
|
* TODO: Implement this please
|
||||||
|
*
|
||||||
|
* @param {string} line Line containing variable to be replaced with value
|
||||||
|
*
|
||||||
|
* @returns {string} New string to be interpreted
|
||||||
|
**/
|
||||||
|
private variable_replace;
|
||||||
|
/**
|
||||||
|
* Interpret a basic two character command
|
||||||
|
*
|
||||||
|
* @param {string} line Line of script to interpret
|
||||||
|
* @param {string} short The short command to use
|
||||||
|
*/
|
||||||
|
private basic_cmd;
|
||||||
|
/**
|
||||||
|
* Start a new loop
|
||||||
|
*
|
||||||
|
* @param {string} line Line to evaluate as either loop or fade
|
||||||
|
* @param {boolean} fade Flag as true if fade
|
||||||
|
*/
|
||||||
|
private new_loop;
|
||||||
|
/**
|
||||||
|
* Close the most recent loop
|
||||||
|
*
|
||||||
|
* @param {string} line Line to interpret
|
||||||
|
*/
|
||||||
|
private end_loop;
|
||||||
|
/**
|
||||||
|
* Move camera to explicitly-defined frame
|
||||||
|
*
|
||||||
|
* @param {string} line Line to interpret with camera move statement
|
||||||
|
*/
|
||||||
|
private move_cam;
|
||||||
|
/**
|
||||||
|
* Move secondary camera to explicitly-defined frame
|
||||||
|
*
|
||||||
|
* @param {string} line Line to interpret with camera move statement
|
||||||
|
*/
|
||||||
|
private move_cam2;
|
||||||
|
/**
|
||||||
|
* Move projector to explicitly-defined frame
|
||||||
|
*
|
||||||
|
* @param {string} line Line containing `move` statement to interpret
|
||||||
|
*/
|
||||||
|
private move_proj;
|
||||||
|
/**
|
||||||
|
* Move projector to explicitly-defined frame
|
||||||
|
*
|
||||||
|
* @param {string} line Line containing `move` statement to interpret
|
||||||
|
*/
|
||||||
|
private move_proj2;
|
||||||
|
/**
|
||||||
|
* Set the state of either the cam or projector
|
||||||
|
*
|
||||||
|
* @param line {string} String containing set statement
|
||||||
|
*/
|
||||||
|
private set_state;
|
||||||
|
/**
|
||||||
|
* Return the last loop
|
||||||
|
*
|
||||||
|
* @returns {object}
|
||||||
|
*/
|
||||||
|
private last_loop;
|
||||||
|
/**
|
||||||
|
* Return the second-last loop
|
||||||
|
*
|
||||||
|
* @returns {object} Loop array
|
||||||
|
*/
|
||||||
|
private parent_loop;
|
||||||
|
/**
|
||||||
|
* Extract the loop count integer from a LOOP cmd
|
||||||
|
*
|
||||||
|
* @returns {integer} Loop count in string parsed into integer
|
||||||
|
*/
|
||||||
|
private loop_count;
|
||||||
|
/**
|
||||||
|
* Execute a fade of frame length, from color to another color
|
||||||
|
*
|
||||||
|
* @param {string} line Line containing a fade initiator
|
||||||
|
*/
|
||||||
|
private fade;
|
||||||
|
/**
|
||||||
|
* Extract the fade length integer from a FADE cmd
|
||||||
|
*
|
||||||
|
* @param {string} str Line containing the length of fade in frames
|
||||||
|
*/
|
||||||
|
private fade_count;
|
||||||
|
/**
|
||||||
|
* Extract the start color from a string
|
||||||
|
*
|
||||||
|
* @param {string} str Line containing the start color value in a fade initiator
|
||||||
|
*
|
||||||
|
* @returns {array} Array containing RGB color values
|
||||||
|
*/
|
||||||
|
private fade_start;
|
||||||
|
/**
|
||||||
|
* Extract the end color from a string
|
||||||
|
*
|
||||||
|
* @param {string} str Line containing the end color value in a fade initiator
|
||||||
|
*
|
||||||
|
* @returns {array} Array containing RGB color values
|
||||||
|
*/
|
||||||
|
private fade_end;
|
||||||
|
/**
|
||||||
|
* Determine the state of a fade at a particular frame in the sequence, x
|
||||||
|
*
|
||||||
|
* @param {array} start Color the fade starts at
|
||||||
|
* @param {array} end Color the fade finishes at
|
||||||
|
* @param {integer} len Total length of the fade in frames
|
||||||
|
* @param {integer} x Position of the fade to get color value of
|
||||||
|
*
|
||||||
|
* @returns {array} Array containing RGB color values
|
||||||
|
*/
|
||||||
|
private fade_rgb;
|
||||||
|
/**
|
||||||
|
* Parse string into array of RGB color values. 0-255 octet.
|
||||||
|
*
|
||||||
|
* @param {string} str String containing only color values as `#,#,#`
|
||||||
|
**/
|
||||||
|
private rgb;
|
||||||
|
/**
|
||||||
|
* Cast RGB color values as string
|
||||||
|
*
|
||||||
|
* @param {array} arr Array to join into string
|
||||||
|
*
|
||||||
|
* @returns {string} String of RGB values
|
||||||
|
**/
|
||||||
|
private rgb_str;
|
||||||
|
/**
|
||||||
|
* Increase the state of a specific object, such as the camera/projector,
|
||||||
|
* by the value defined in val.
|
||||||
|
*
|
||||||
|
* @param {string} cmd String representing command to interpret and update state
|
||||||
|
*/
|
||||||
|
private update;
|
||||||
|
/**
|
||||||
|
* Split string on command, turn into array of commands
|
||||||
|
* as long as count variable. Default 1.
|
||||||
|
*
|
||||||
|
* @param {string} str String to split
|
||||||
|
* @param {string} cmd String representing command to split at
|
||||||
|
*
|
||||||
|
* @returns {array} Array containing commands
|
||||||
|
*/
|
||||||
|
private str_to_arr;
|
||||||
|
/**
|
||||||
|
* Split a string on a command to extract data for light array
|
||||||
|
*
|
||||||
|
* @param {string} str String containing light command
|
||||||
|
* @param {string} cmd String representing command
|
||||||
|
*
|
||||||
|
* @returns {array} An RGB array containing the color values
|
||||||
|
*/
|
||||||
|
private light_to_arr;
|
||||||
|
/**
|
||||||
|
* Split a string to extract an rgb color value
|
||||||
|
*
|
||||||
|
* @param {string} Color string assign to color property
|
||||||
|
*/
|
||||||
|
private light_state;
|
||||||
|
/**
|
||||||
|
* Interpret a delay command
|
||||||
|
*
|
||||||
|
* @param {string} line String containing delay command
|
||||||
|
**/
|
||||||
|
private delay;
|
||||||
|
/**
|
||||||
|
* Interpret an alert command
|
||||||
|
*
|
||||||
|
* @param {string} line String containing alert message
|
||||||
|
**/
|
||||||
|
private alert;
|
||||||
|
/**
|
||||||
|
* Interpret an pause command
|
||||||
|
*
|
||||||
|
* @param {string} line String containing alert message
|
||||||
|
**/
|
||||||
|
private pause;
|
||||||
|
/**
|
||||||
|
* Throw an error with specific message
|
||||||
|
*
|
||||||
|
* @param {string} msg Error message to print
|
||||||
|
*/
|
||||||
|
private fail;
|
||||||
|
/**
|
||||||
|
* Determine if array contains matching elements of
|
||||||
|
* another array
|
||||||
|
*
|
||||||
|
* @param {Array} arr Original array to compare
|
||||||
|
* @param {Array} arr2 Array to compare elements from
|
||||||
|
*
|
||||||
|
* @returns {boolean} Whether arr contains elements in arr2
|
||||||
|
**/
|
||||||
|
private contains;
|
||||||
|
}
|
||||||
|
export type { RGB };
|
|
@ -1,4 +1,5 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const BLACK = '0,0,0';
|
const BLACK = '0,0,0';
|
||||||
const WHITE = '255,255,255';
|
const WHITE = '255,255,255';
|
||||||
const CMD = [
|
const CMD = [
|
||||||
|
@ -7,7 +8,35 @@ const CMD = [
|
||||||
'BF',
|
'BF',
|
||||||
'CB',
|
'CB',
|
||||||
'PB',
|
'PB',
|
||||||
'BB'
|
'BB',
|
||||||
|
'C2F',
|
||||||
|
'C2B',
|
||||||
|
'CCF',
|
||||||
|
'CCB',
|
||||||
|
'P2F',
|
||||||
|
'P2B',
|
||||||
|
'PPF',
|
||||||
|
'PPB',
|
||||||
|
'CFCB',
|
||||||
|
'CBCF',
|
||||||
|
'PFPB',
|
||||||
|
'PBPF'
|
||||||
|
];
|
||||||
|
const CAMERA_SECONDARY = [
|
||||||
|
'C2F',
|
||||||
|
'C2B',
|
||||||
|
'CCF',
|
||||||
|
'CCB',
|
||||||
|
'CFCB',
|
||||||
|
'CBCF'
|
||||||
|
];
|
||||||
|
const PROJECTOR_SECONDARY = [
|
||||||
|
'P2F',
|
||||||
|
'P2B',
|
||||||
|
'PPF',
|
||||||
|
'PPB',
|
||||||
|
'PFPB',
|
||||||
|
'PBPF'
|
||||||
];
|
];
|
||||||
const ALTS = {
|
const ALTS = {
|
||||||
'CF': ['CAMERA FORWARD', 'CAM FORWARD'],
|
'CF': ['CAMERA FORWARD', 'CAM FORWARD'],
|
||||||
|
@ -17,38 +46,40 @@ const ALTS = {
|
||||||
'PB': ['PROJECTOR FORWARD', 'PROJ FORWARD', 'PROJECTOR BACK', 'PROJ BACK'],
|
'PB': ['PROJECTOR FORWARD', 'PROJ FORWARD', 'PROJECTOR BACK', 'PROJ BACK'],
|
||||||
'BB': ['BLACK BACKWARD', 'BLACK BACK', 'BLANK BACK'],
|
'BB': ['BLACK BACKWARD', 'BLACK BACK', 'BLANK BACK'],
|
||||||
'L ': ['LIGHT', 'COLOR', 'LAMP'],
|
'L ': ['LIGHT', 'COLOR', 'LAMP'],
|
||||||
'F ': ['FADE']
|
'F ': ['FADE'],
|
||||||
|
'C2F': ['CAMERA2 FORWARD', 'CAM2 FORWARD'],
|
||||||
|
'C2B': ['CAMERA2 BACKWARD', 'CAM2 BACKWARD', 'CAMERA2 BACK', 'CAM2 BACK'],
|
||||||
|
'CCF': ['CAMERAS FORWARD', 'CAMS FORWARD'],
|
||||||
|
'CCB': ['CAMERAS BACKWARD', 'CAMS BACKWARD', 'CAMERAS BACK', 'CAMS BACK'],
|
||||||
|
'P2F': ['PROJECTOR2 FORWARD', 'PROJ2 FORWARD'],
|
||||||
|
'P2B': ['PROJECTOR2 BACKWARD', 'PROJ2 BACKWARD', 'PROJECTOR2 BACK', 'PROJ2 BACK'],
|
||||||
|
'PPF': ['PROJECTORS FORWARD', 'PROJS FORWARD'],
|
||||||
|
'PPB': ['PROJECTORS BACKWARD', 'PROJS BACKWARD', 'PROJECTORS BACK', 'PROJS BACK'],
|
||||||
|
'CFCB': [],
|
||||||
|
'CBCF': [],
|
||||||
|
'PFPB': [],
|
||||||
|
'PBPF': []
|
||||||
};
|
};
|
||||||
|
const DELAY = 'DELAY';
|
||||||
const PAUSE = 'PAUSE';
|
const PAUSE = 'PAUSE';
|
||||||
const ALERT = 'ALERT';
|
const ALERT = 'ALERT';
|
||||||
/** helper functions */
|
/** @module lib/mscript */
|
||||||
/** startswith function from lodash, do not want the entire lib for this
|
/**
|
||||||
* @param str {string} Text to evaluate
|
* Class representing the mscript language.
|
||||||
* @param target {string} Text to compare string against
|
*/
|
||||||
* @param position {integer} Position in the string to make comparison at
|
|
||||||
*
|
|
||||||
* @returns {boolean} True for match, false for no match
|
|
||||||
**/
|
|
||||||
function startsWith(str, target, position) {
|
|
||||||
const { length } = str;
|
|
||||||
position = position == null ? 0 : position;
|
|
||||||
if (position < 0) {
|
|
||||||
position = 0;
|
|
||||||
}
|
|
||||||
else if (position > length) {
|
|
||||||
position = length;
|
|
||||||
}
|
|
||||||
target = `${target}`;
|
|
||||||
return str.slice(position, position + target.length) == target;
|
|
||||||
}
|
|
||||||
/** class Mscript */
|
|
||||||
class Mscript {
|
class Mscript {
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* Create new Mscript interpreter
|
* Create new Mscript interpreter
|
||||||
**/
|
**/
|
||||||
constructor() {
|
constructor() {
|
||||||
this.output = {};
|
this.output = {
|
||||||
|
success: false,
|
||||||
|
arr: [],
|
||||||
|
meta: [],
|
||||||
|
cam: 0,
|
||||||
|
proj: 0
|
||||||
|
};
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Clear the state of the script
|
* Clear the state of the script
|
||||||
|
@ -56,17 +87,27 @@ class Mscript {
|
||||||
clear() {
|
clear() {
|
||||||
this.lines = [];
|
this.lines = [];
|
||||||
this.cam = 0;
|
this.cam = 0;
|
||||||
|
this.cam2 = 0;
|
||||||
this.proj = 0;
|
this.proj = 0;
|
||||||
|
this.proj2 = 0;
|
||||||
this.color = '';
|
this.color = '';
|
||||||
this.loops = [];
|
this.loops = [];
|
||||||
this.rec = -1;
|
this.rec = -1;
|
||||||
this.two = '';
|
this.two = '';
|
||||||
|
this.three = '';
|
||||||
|
this.four = '';
|
||||||
this.arr = [];
|
this.arr = [];
|
||||||
this.meta = [];
|
this.meta = [];
|
||||||
this.target = 0; //move to target using CAM # or PROJ #
|
this.target = 0; //move to target using CAM # or PROJ #
|
||||||
this.dist = 0;
|
this.dist = 0;
|
||||||
this.variables = {};
|
this.variables = {};
|
||||||
this.output = {};
|
this.output = {
|
||||||
|
success: false,
|
||||||
|
arr: [],
|
||||||
|
meta: [],
|
||||||
|
cam: 0,
|
||||||
|
proj: 0
|
||||||
|
};
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Main function, accepts multi-line string, parses into lines
|
* Main function, accepts multi-line string, parses into lines
|
||||||
|
@ -78,76 +119,88 @@ class Mscript {
|
||||||
*
|
*
|
||||||
* @returns {object} if callback is not provided
|
* @returns {object} if callback is not provided
|
||||||
*/
|
*/
|
||||||
interpret(text, callback) {
|
interpret(text) {
|
||||||
this.clear();
|
this.clear();
|
||||||
if (typeof text === 'undefined') {
|
if (typeof text === 'undefined') {
|
||||||
return this.fail('No input');
|
return this.fail('No input');
|
||||||
}
|
}
|
||||||
//split string into lines, each containing a command
|
//split string into lines, each containing a command
|
||||||
this.lines = text.split('\n');
|
this.lines = text.split('\n');
|
||||||
this.lines = this.lines.map(line => {
|
this.lines = this.lines.map((line) => {
|
||||||
line = line.replace(/\t+/g, ''); //strip tabs
|
line = line.replace(/\t+/g, ' '); //strip tabs
|
||||||
line = line.trim(); //remove excess whitespace before and after command
|
line = line.trim(); //remove excess whitespace before and after command
|
||||||
line = line.toUpperCase();
|
line = line.toUpperCase();
|
||||||
return line;
|
return line;
|
||||||
});
|
});
|
||||||
for (let line of this.lines) {
|
for (let line of this.lines) {
|
||||||
this.two = line.substring(0, 2);
|
this.two = line.substring(0, 2);
|
||||||
if (CMD.indexOf(this.two) !== -1) {
|
this.three = line.substring(0, 3);
|
||||||
this.basic_cmd(line);
|
this.four = line.substring(0, 4);
|
||||||
|
if (CMD.indexOf(this.four) !== -1) {
|
||||||
|
this.basic_cmd(line, this.four);
|
||||||
}
|
}
|
||||||
else if (startsWith(line, PAUSE)) {
|
else if (CMD.indexOf(this.three) !== -1) {
|
||||||
|
this.basic_cmd(line, this.three);
|
||||||
|
}
|
||||||
|
else if (CMD.indexOf(this.two) !== -1) {
|
||||||
|
this.basic_cmd(line, this.two);
|
||||||
|
}
|
||||||
|
else if (line.startsWith(DELAY)) {
|
||||||
|
this.delay(line);
|
||||||
|
}
|
||||||
|
else if (line.startsWith(PAUSE)) {
|
||||||
this.pause(line);
|
this.pause(line);
|
||||||
}
|
}
|
||||||
else if (startsWith(line, ALERT)) {
|
else if (line.startsWith(ALERT)) {
|
||||||
this.alert(line);
|
this.alert(line);
|
||||||
}
|
}
|
||||||
else if (startsWith(line, '@') || line.indexOf('@') !== -1) {
|
else if (line.startsWith('@') || line.indexOf('@') !== -1) {
|
||||||
this.variable(line);
|
this.variable(line);
|
||||||
}
|
}
|
||||||
else if (startsWith(line, 'LOOP')) {
|
else if (line.startsWith('LOOP')) {
|
||||||
this.new_loop(line);
|
this.new_loop(line);
|
||||||
}
|
}
|
||||||
else if (startsWith(line, 'L ')) {
|
else if (line.startsWith('L ')) {
|
||||||
this.light_state(line);
|
this.light_state(line);
|
||||||
}
|
}
|
||||||
else if (startsWith(line, 'F ')) {
|
else if (line.startsWith('F ')) {
|
||||||
this.new_loop(line, true);
|
this.new_loop(line, true);
|
||||||
}
|
}
|
||||||
else if (startsWith(line, 'END')) {
|
else if (line.startsWith('END')) {
|
||||||
this.end_loop(line);
|
this.end_loop(line);
|
||||||
}
|
}
|
||||||
else if (startsWith(line, 'CAM')) { //directly go to that frame (black?)
|
else if (line.startsWith('CAM2')) { //directly go to that frame
|
||||||
|
this.move_cam2(line);
|
||||||
|
}
|
||||||
|
else if (line.startsWith('CAM')) { //directly go to that frame
|
||||||
this.move_cam(line);
|
this.move_cam(line);
|
||||||
}
|
}
|
||||||
else if (startsWith(line, 'PROJ')) { //directly go to that frame
|
else if (line.startsWith('PROJ2')) { //directly go to that frame
|
||||||
|
this.move_proj2(line);
|
||||||
|
}
|
||||||
|
else if (line.startsWith('PROJ')) { //directly go to that frame
|
||||||
this.move_proj(line);
|
this.move_proj(line);
|
||||||
}
|
}
|
||||||
else if (startsWith(line, 'SET')) { //set that state
|
else if (line.startsWith('SET')) { //set that state
|
||||||
this.set_state(line);
|
this.set_state(line);
|
||||||
}
|
}
|
||||||
else if (startsWith(line, '#') || startsWith(line, '//')) {
|
else if (line.startsWith('#') || line.startsWith('//')) {
|
||||||
//comments
|
//comments
|
||||||
//ignore while parsing
|
//ignore while parsing
|
||||||
}
|
}
|
||||||
else if (startsWith(line, 'ALERT')) {
|
|
||||||
}
|
|
||||||
else if (startsWith(line, 'PAUSE')) {
|
|
||||||
this.pause(line);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.output.success = true;
|
this.output.success = true;
|
||||||
this.output.arr = this.arr; //all instructions
|
this.output.arr = this.arr; //all instructions
|
||||||
this.output.meta = this.meta; //all metadata for instructions
|
this.output.meta = this.meta; //all metadata for instructions
|
||||||
this.output.cam = this.cam;
|
this.output.cam = this.cam;
|
||||||
this.output.proj = this.proj;
|
this.output.proj = this.proj;
|
||||||
if (typeof callback !== 'undefined') {
|
if (this.contains(this.arr, CAMERA_SECONDARY)) {
|
||||||
//should only be invoked by running mscript.tests()
|
this.output.cam2 = this.cam2;
|
||||||
callback(this.output);
|
|
||||||
}
|
}
|
||||||
else {
|
if (this.contains(this.arr, PROJECTOR_SECONDARY)) {
|
||||||
return this.output;
|
this.output.proj2 = this.proj2;
|
||||||
}
|
}
|
||||||
|
return this.output;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Interprets variables for complex sequence behavior.
|
* Interprets variables for complex sequence behavior.
|
||||||
|
@ -161,6 +214,7 @@ class Mscript {
|
||||||
let key = parts[0];
|
let key = parts[0];
|
||||||
let value = parts[1];
|
let value = parts[1];
|
||||||
let update = false;
|
let update = false;
|
||||||
|
let num;
|
||||||
if (value && value.indexOf('#') !== -1) {
|
if (value && value.indexOf('#') !== -1) {
|
||||||
value = value.split('#')[0];
|
value = value.split('#')[0];
|
||||||
}
|
}
|
||||||
|
@ -176,7 +230,7 @@ class Mscript {
|
||||||
}
|
}
|
||||||
if (line.indexOf(',') === -1) { //if not color string
|
if (line.indexOf(',') === -1) { //if not color string
|
||||||
try {
|
try {
|
||||||
value = parseInt(value);
|
num = parseInt(value);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
//supress parsing error
|
//supress parsing error
|
||||||
|
@ -184,7 +238,7 @@ class Mscript {
|
||||||
}
|
}
|
||||||
//console.dir(parts)
|
//console.dir(parts)
|
||||||
if (!this.variables[key] || update) {
|
if (!this.variables[key] || update) {
|
||||||
this.variables[key] = value;
|
this.variables[key] = num;
|
||||||
}
|
}
|
||||||
//console.dir(this.variables)
|
//console.dir(this.variables)
|
||||||
}
|
}
|
||||||
|
@ -203,25 +257,26 @@ class Mscript {
|
||||||
* Interpret a basic two character command
|
* Interpret a basic two character command
|
||||||
*
|
*
|
||||||
* @param {string} line Line of script to interpret
|
* @param {string} line Line of script to interpret
|
||||||
|
* @param {string} short The short command to use
|
||||||
*/
|
*/
|
||||||
basic_cmd(line) {
|
basic_cmd(line, short) {
|
||||||
if (this.rec !== -1) {
|
if (this.rec !== -1) {
|
||||||
//hold generated arr in state loop array
|
//hold generated arr in state loop array
|
||||||
this.loops[this.rec].arr
|
this.loops[this.rec].arr
|
||||||
.push.apply(this.loops[this.rec].arr, this.str_to_arr(line, this.two));
|
.push.apply(this.loops[this.rec].arr, this.str_to_arr(line, short));
|
||||||
this.loops[this.rec].meta
|
this.loops[this.rec].meta
|
||||||
.push.apply(this.loops[this.rec].meta, this.light_to_arr(line, this.two));
|
.push.apply(this.loops[this.rec].meta, this.light_to_arr(line, short));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.arr.push.apply(this.arr, this.str_to_arr(line, this.two));
|
this.arr.push.apply(this.arr, this.str_to_arr(line, short));
|
||||||
this.meta.push.apply(this.meta, this.light_to_arr(line, this.two));
|
this.meta.push.apply(this.meta, this.light_to_arr(line, short));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Start a new loop
|
* Start a new loop
|
||||||
*
|
*
|
||||||
* @param {string} line Line to evaluate as either loop or fade
|
* @param {string} line Line to evaluate as either loop or fade
|
||||||
* @param {boolean} fade Flag as boolean if true
|
* @param {boolean} fade Flag as true if fade
|
||||||
*/
|
*/
|
||||||
new_loop(line, fade) {
|
new_loop(line, fade) {
|
||||||
this.rec++;
|
this.rec++;
|
||||||
|
@ -230,6 +285,8 @@ class Mscript {
|
||||||
meta: [],
|
meta: [],
|
||||||
cam: 0,
|
cam: 0,
|
||||||
proj: 0,
|
proj: 0,
|
||||||
|
cam2: 0,
|
||||||
|
proj2: 0,
|
||||||
cmd: line + ''
|
cmd: line + ''
|
||||||
};
|
};
|
||||||
if (fade) {
|
if (fade) {
|
||||||
|
@ -252,7 +309,7 @@ class Mscript {
|
||||||
start = this.loops[this.rec].start;
|
start = this.loops[this.rec].start;
|
||||||
end = this.loops[this.rec].end;
|
end = this.loops[this.rec].end;
|
||||||
len = this.loops[this.rec].fade_len;
|
len = this.loops[this.rec].fade_len;
|
||||||
meta_arr = meta_arr.map(l => {
|
meta_arr = meta_arr.map((l) => {
|
||||||
return this.fade_rgb(start, end, len, x);
|
return this.fade_rgb(start, end, len, x);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -315,6 +372,50 @@ class Mscript {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Move secondary camera to explicitly-defined frame
|
||||||
|
*
|
||||||
|
* @param {string} line Line to interpret with camera move statement
|
||||||
|
*/
|
||||||
|
move_cam2(line) {
|
||||||
|
this.target = parseInt(line.split('CAM2 ')[1]);
|
||||||
|
if (this.rec !== -1) {
|
||||||
|
if (this.target > this.cam2) {
|
||||||
|
this.dist = this.target - this.cam2;
|
||||||
|
for (let x = 0; x < this.dist; x++) {
|
||||||
|
this.loops[this.rec].arr.push('C2F');
|
||||||
|
this.loops[this.rec].meta.push(BLACK);
|
||||||
|
this.update('C2F');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.dist = this.cam2 - this.target;
|
||||||
|
for (let x = 0; x < this.dist; x++) {
|
||||||
|
this.loops[this.rec].arr.push('C2B');
|
||||||
|
this.loops[this.rec].meta.push(BLACK);
|
||||||
|
this.update('C2B');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (this.target > this.cam2) {
|
||||||
|
this.dist = this.target - this.cam2;
|
||||||
|
for (let x = 0; x < this.dist; x++) {
|
||||||
|
this.arr.push('C2F');
|
||||||
|
this.meta.push(BLACK);
|
||||||
|
this.update('C2F');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.dist = this.cam2 - this.target;
|
||||||
|
for (let x = 0; x < this.dist; x++) {
|
||||||
|
this.arr.push('C2B');
|
||||||
|
this.meta.push(BLACK);
|
||||||
|
this.update('C2B');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Move projector to explicitly-defined frame
|
* Move projector to explicitly-defined frame
|
||||||
*
|
*
|
||||||
|
@ -359,16 +460,66 @@ class Mscript {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Move projector to explicitly-defined frame
|
||||||
|
*
|
||||||
|
* @param {string} line Line containing `move` statement to interpret
|
||||||
|
*/
|
||||||
|
move_proj2(line) {
|
||||||
|
this.target = parseInt(line.split('PROJ2 ')[1]);
|
||||||
|
if (this.rec !== -1) {
|
||||||
|
if (this.target > this.proj2) {
|
||||||
|
this.dist = this.target - this.proj2;
|
||||||
|
for (let x = 0; x < this.dist; x++) {
|
||||||
|
this.loops[this.rec].arr.push('P2F');
|
||||||
|
this.loops[this.rec].meta.push('');
|
||||||
|
this.update('P2F');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.dist = this.proj2 - this.target;
|
||||||
|
for (let x = 0; x < this.dist; x++) {
|
||||||
|
this.loops[this.rec].arr.push('P2B');
|
||||||
|
this.loops[this.rec].meta.push('');
|
||||||
|
this.update('P2B');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (this.target > this.proj2) {
|
||||||
|
this.dist = this.target - this.proj2;
|
||||||
|
for (let x = 0; x < this.dist; x++) {
|
||||||
|
this.arr.push('P2F');
|
||||||
|
this.meta.push('');
|
||||||
|
this.update('P2F');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.dist = this.proj2 - this.target;
|
||||||
|
for (let x = 0; x < this.dist; x++) {
|
||||||
|
this.arr.push('P2B');
|
||||||
|
this.meta.push('');
|
||||||
|
this.update('P2B');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Set the state of either the cam or projector
|
* Set the state of either the cam or projector
|
||||||
*
|
*
|
||||||
* @param line {string} String containing set statement
|
* @param line {string} String containing set statement
|
||||||
*/
|
*/
|
||||||
set_state(line) {
|
set_state(line) {
|
||||||
if (startsWith(line, 'SET CAM')) {
|
if (line.startsWith('SET CAM2')) {
|
||||||
|
parseInt(line.split('SET CAM2')[1]);
|
||||||
|
}
|
||||||
|
else if (line.startsWith('SET PROJ2')) {
|
||||||
|
this.cam2 = parseInt(line.split('SET PROJ2')[1]);
|
||||||
|
}
|
||||||
|
else if (line.startsWith('SET CAM')) {
|
||||||
this.cam = parseInt(line.split('SET CAM')[1]);
|
this.cam = parseInt(line.split('SET CAM')[1]);
|
||||||
}
|
}
|
||||||
else if (startsWith(line, 'SET PROJ')) {
|
else if (line.startsWith('SET PROJ')) {
|
||||||
this.proj = parseInt(line.split('SET PROJ')[1]);
|
this.proj = parseInt(line.split('SET PROJ')[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -402,9 +553,9 @@ class Mscript {
|
||||||
* @param {string} line Line containing a fade initiator
|
* @param {string} line Line containing a fade initiator
|
||||||
*/
|
*/
|
||||||
fade(line) {
|
fade(line) {
|
||||||
let len = this.fade_count(line);
|
const len = this.fade_count(line);
|
||||||
let start = this.fade_start(line);
|
const start = this.fade_start(line);
|
||||||
let end = this.fade_end(line);
|
const end = this.fade_end(line);
|
||||||
this.loops[this.rec].start = start;
|
this.loops[this.rec].start = start;
|
||||||
this.loops[this.rec].end = end;
|
this.loops[this.rec].end = end;
|
||||||
this.loops[this.rec].fade = true;
|
this.loops[this.rec].fade = true;
|
||||||
|
@ -438,7 +589,7 @@ class Mscript {
|
||||||
* @returns {array} Array containing RGB color values
|
* @returns {array} Array containing RGB color values
|
||||||
*/
|
*/
|
||||||
fade_end(str) {
|
fade_end(str) {
|
||||||
let color = str.split(' ')[3];
|
const color = str.split(' ')[3];
|
||||||
return this.rgb(color.trim());
|
return this.rgb(color.trim());
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -475,7 +626,7 @@ class Mscript {
|
||||||
* @param {string} str String containing only color values as `#,#,#`
|
* @param {string} str String containing only color values as `#,#,#`
|
||||||
**/
|
**/
|
||||||
rgb(str) {
|
rgb(str) {
|
||||||
let rgb = str.split(',');
|
const rgb = str.split(',');
|
||||||
return rgb.map((char) => {
|
return rgb.map((char) => {
|
||||||
return parseInt(char);
|
return parseInt(char);
|
||||||
});
|
});
|
||||||
|
@ -503,10 +654,14 @@ class Mscript {
|
||||||
if (this.rec === 0) {
|
if (this.rec === 0) {
|
||||||
this.cam += this.loops[this.rec].cam;
|
this.cam += this.loops[this.rec].cam;
|
||||||
this.proj += this.loops[this.rec].proj;
|
this.proj += this.loops[this.rec].proj;
|
||||||
|
this.cam2 += this.loops[this.rec].cam2;
|
||||||
|
this.proj2 += this.loops[this.rec].proj2;
|
||||||
}
|
}
|
||||||
else if (this.rec >= 1) {
|
else if (this.rec >= 1) {
|
||||||
this.loops[this.rec - 1].cam += this.loops[this.rec].cam;
|
this.loops[this.rec - 1].cam += this.loops[this.rec].cam;
|
||||||
this.loops[this.rec - 1].proj += this.loops[this.rec].proj;
|
this.loops[this.rec - 1].proj += this.loops[this.rec].proj;
|
||||||
|
this.loops[this.rec - 1].cam2 += this.loops[this.rec].cam2;
|
||||||
|
this.loops[this.rec - 1].proj2 += this.loops[this.rec].proj2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -523,7 +678,7 @@ class Mscript {
|
||||||
this.cam -= val;
|
this.cam -= val;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.loops[this.rec].cam--;
|
this.loops[this.rec].cam -= val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (cmd === 'PF') {
|
else if (cmd === 'PF') {
|
||||||
|
@ -539,7 +694,7 @@ class Mscript {
|
||||||
this.proj -= val;
|
this.proj -= val;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.loops[this.rec].proj--;
|
this.loops[this.rec].proj -= val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (cmd === 'BF') {
|
else if (cmd === 'BF') {
|
||||||
|
@ -558,6 +713,118 @@ class Mscript {
|
||||||
this.loops[this.rec].cam -= val;
|
this.loops[this.rec].cam -= val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (cmd === 'C2F') {
|
||||||
|
if (this.rec === -1) {
|
||||||
|
this.cam2 += val;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.loops[this.rec].cam2 += val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (cmd === 'C2B') {
|
||||||
|
if (this.rec === -1) {
|
||||||
|
this.cam2 -= val;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.loops[this.rec].cam2 -= val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (cmd === 'CCF') {
|
||||||
|
if (this.rec === -1) {
|
||||||
|
this.cam += val;
|
||||||
|
this.cam2 += val;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.loops[this.rec].cam2 += val;
|
||||||
|
this.loops[this.rec].cam2 += val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (cmd === 'CCB') {
|
||||||
|
if (this.rec === -1) {
|
||||||
|
this.cam -= val;
|
||||||
|
this.cam2 -= val;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.loops[this.rec].cam2 -= val;
|
||||||
|
this.loops[this.rec].cam2 -= val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (cmd === 'P2F') {
|
||||||
|
if (this.rec === -1) {
|
||||||
|
this.proj2 += val;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.loops[this.rec].proj2 += val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (cmd === 'P2B') {
|
||||||
|
if (this.rec === -1) {
|
||||||
|
this.proj2 -= val;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.loops[this.rec].proj2 -= val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (cmd === 'PPF') {
|
||||||
|
if (this.rec === -1) {
|
||||||
|
this.proj += val;
|
||||||
|
this.proj2 += val;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.loops[this.rec].proj += val;
|
||||||
|
this.loops[this.rec].proj2 += val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (cmd === 'PPB') {
|
||||||
|
if (this.rec === -1) {
|
||||||
|
this.proj -= val;
|
||||||
|
this.proj2 -= val;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.loops[this.rec].proj -= val;
|
||||||
|
this.loops[this.rec].proj2 -= val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (cmd === 'CFCB') {
|
||||||
|
if (this.rec === -1) {
|
||||||
|
this.cam += val;
|
||||||
|
this.cam2 -= val;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.loops[this.rec].cam += val;
|
||||||
|
this.loops[this.rec].cam2 -= val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (cmd === 'CBCF') {
|
||||||
|
if (this.rec === -1) {
|
||||||
|
this.cam -= val;
|
||||||
|
this.cam2 += val;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.loops[this.rec].cam -= val;
|
||||||
|
this.loops[this.rec].cam2 += val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (cmd === 'PFPB') {
|
||||||
|
if (this.rec === -1) {
|
||||||
|
this.proj += val;
|
||||||
|
this.proj2 -= val;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.loops[this.rec].proj += val;
|
||||||
|
this.loops[this.rec].proj2 -= val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (cmd === 'PBPF') {
|
||||||
|
if (this.rec === -1) {
|
||||||
|
this.proj -= val;
|
||||||
|
this.proj2 += val;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.loops[this.rec].proj -= val;
|
||||||
|
this.loops[this.rec].proj2 += val;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (cmd === 'L ') {
|
else if (cmd === 'L ') {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -628,11 +895,11 @@ class Mscript {
|
||||||
this.color = color;
|
this.color = color;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Interpret a pause command
|
* Interpret a delay command
|
||||||
*
|
*
|
||||||
* @param {string} line String containing pause command
|
* @param {string} line String containing delay command
|
||||||
**/
|
**/
|
||||||
pause(line) {
|
delay(line) {
|
||||||
let lenStr = line.split(' ')[1] || '';
|
let lenStr = line.split(' ')[1] || '';
|
||||||
let len;
|
let len;
|
||||||
lenStr = lenStr.trim();
|
lenStr = lenStr.trim();
|
||||||
|
@ -649,23 +916,42 @@ class Mscript {
|
||||||
if (this.rec !== -1) {
|
if (this.rec !== -1) {
|
||||||
//hold generated arr in state loop array
|
//hold generated arr in state loop array
|
||||||
this.loops[this.rec].arr
|
this.loops[this.rec].arr
|
||||||
.push('PA');
|
.push('DE');
|
||||||
this.loops[this.rec].meta
|
this.loops[this.rec].meta
|
||||||
.push(lenStr);
|
.push(lenStr);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.arr.push('AL');
|
this.arr.push('DE');
|
||||||
this.meta.push(lenStr);
|
this.meta.push(lenStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Interpret an alert command
|
* Interpret an alert command
|
||||||
*
|
*
|
||||||
* @param {string} line String containing pause command
|
* @param {string} line String containing alert message
|
||||||
**/
|
**/
|
||||||
alert(line) {
|
alert(line) {
|
||||||
let msg = line.split(' ')[1] || '';
|
let msg = line.split(' ')[1] || '';
|
||||||
msg = msg.trim();
|
msg = msg.trim();
|
||||||
|
if (this.rec !== -1) {
|
||||||
|
//hold generated arr in state loop array
|
||||||
|
this.loops[this.rec].arr
|
||||||
|
.push('AL');
|
||||||
|
this.loops[this.rec].meta
|
||||||
|
.push(line);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.arr.push('AL');
|
||||||
|
this.meta.push(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Interpret an pause command
|
||||||
|
*
|
||||||
|
* @param {string} line String containing alert message
|
||||||
|
**/
|
||||||
|
pause(line) {
|
||||||
|
const msg = "Paused script. Click OK to continue.";
|
||||||
if (this.rec !== -1) {
|
if (this.rec !== -1) {
|
||||||
//hold generated arr in state loop array
|
//hold generated arr in state loop array
|
||||||
this.loops[this.rec].arr
|
this.loops[this.rec].arr
|
||||||
|
@ -686,6 +972,19 @@ class Mscript {
|
||||||
fail(msg) {
|
fail(msg) {
|
||||||
throw new Error(msg);
|
throw new Error(msg);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Determine if array contains matching elements of
|
||||||
|
* another array
|
||||||
|
*
|
||||||
|
* @param {Array} arr Original array to compare
|
||||||
|
* @param {Array} arr2 Array to compare elements from
|
||||||
|
*
|
||||||
|
* @returns {boolean} Whether arr contains elements in arr2
|
||||||
|
**/
|
||||||
|
contains(arr, arr2) {
|
||||||
|
return arr.some((r) => arr2.includes(r));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
exports.default = Mscript;
|
||||||
module.exports = Mscript;
|
module.exports = Mscript;
|
||||||
//# sourceMappingURL=index.js.map
|
//# sourceMappingURL=index.js.map
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,9 @@
|
||||||
|
<a name="module_lib/processing"></a>
|
||||||
|
|
||||||
|
## lib/processing
|
||||||
|
<a name="module_lib/processing..Processing"></a>
|
||||||
|
|
||||||
|
### lib/processing~Processing
|
||||||
|
Class representing all Processing camera features.
|
||||||
|
|
||||||
|
**Kind**: inner class of [<code>lib/processing</code>](#module_lib/processing)
|
|
@ -0,0 +1,10 @@
|
||||||
|
/** @module lib/processing */
|
||||||
|
/**
|
||||||
|
* Class representing all Processing camera features.
|
||||||
|
*/
|
||||||
|
export declare class Processing {
|
||||||
|
private _baseUrl;
|
||||||
|
constructor(url: string);
|
||||||
|
move(): Promise<number>;
|
||||||
|
setDir(dir: boolean): Promise<number>;
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
'use strict';
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.Processing = void 0;
|
||||||
|
const exec_1 = require("exec");
|
||||||
|
/** @module lib/processing */
|
||||||
|
/**
|
||||||
|
* Class representing all Processing camera features.
|
||||||
|
*/
|
||||||
|
class Processing {
|
||||||
|
constructor(url) {
|
||||||
|
this._baseUrl = (url.indexOf('http') === -1 && url.indexOf('://') === -1) ? `http://${url}` : url;
|
||||||
|
}
|
||||||
|
async move() {
|
||||||
|
return new Promise(async (resolve, reject) => {
|
||||||
|
const timeStart = +new Date();
|
||||||
|
const url = `${this._baseUrl}`;
|
||||||
|
const cmd = `curl --http0.9 ${url}`;
|
||||||
|
let res;
|
||||||
|
let ms;
|
||||||
|
//console.log(url)
|
||||||
|
try {
|
||||||
|
res = await (0, exec_1.exec)(cmd);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
return reject(err);
|
||||||
|
}
|
||||||
|
ms = (+new Date()) - timeStart;
|
||||||
|
return resolve(ms);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
async setDir(dir) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
return resolve(0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.Processing = Processing;
|
||||||
|
module.exports = { Processing };
|
||||||
|
//# sourceMappingURL=index.js.map
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/processing/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;;;AAEZ,+BAA4B;AAG5B,6BAA6B;AAE7B;;GAEG;AACH,MAAa,UAAU;IAEtB,YAAa,GAAY;QACxB,IAAI,CAAC,QAAQ,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAA;IAClG,CAAC;IAEM,KAAK,CAAC,IAAI;QAChB,OAAO,IAAI,OAAO,CAAE,KAAK,EAAE,OAAkB,EAAE,MAAiB,EAAE,EAAE;YACnE,MAAM,SAAS,GAAY,CAAC,IAAI,IAAI,EAAE,CAAA;YACtC,MAAM,GAAG,GAAY,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAA;YACvC,MAAM,GAAG,GAAY,kBAAkB,GAAG,EAAE,CAAA;YAC5C,IAAI,GAAgB,CAAA;YACpB,IAAI,EAAW,CAAA;YACf,kBAAkB;YAClB,IAAI;gBACH,GAAG,GAAG,MAAM,IAAA,WAAI,EAAC,GAAG,CAAC,CAAA;aACrB;YAAC,OAAO,GAAG,EAAE;gBACb,OAAO,MAAM,CAAC,GAAG,CAAC,CAAA;aAClB;YACD,EAAE,GAAG,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,GAAG,SAAS,CAAA;YAC9B,OAAO,OAAO,CAAC,EAAE,CAAC,CAAA;QACnB,CAAC,CAAC,CAAA;IACH,CAAC;IACM,KAAK,CAAC,MAAM,CAAE,GAAa;QACjC,OAAO,IAAI,OAAO,CAAE,CAAC,OAAkB,EAAE,MAAiB,EAAE,EAAE;YAC7D,OAAO,OAAO,CAAC,CAAC,CAAC,CAAA;QAClB,CAAC,CAAC,CAAA;IACH,CAAC;CACD;AA5BD,gCA4BC;AAED,MAAM,CAAC,OAAO,GAAG,EAAE,UAAU,EAAE,CAAA"}
|
|
@ -1,37 +1,52 @@
|
||||||
<a name="Projector"></a>
|
<a name="module_lib/proj"></a>
|
||||||
|
|
||||||
## Projector
|
## lib/proj
|
||||||
**Kind**: global class
|
|
||||||
|
|
||||||
* [Projector](#Projector)
|
* [lib/proj](#module_lib/proj)
|
||||||
* [.init()](#Projector+init)
|
* [~Projector](#module_lib/proj..Projector)
|
||||||
* [.listen()](#Projector+listen)
|
* [.init()](#module_lib/proj..Projector+init)
|
||||||
* [.set()](#Projector+set)
|
* [.listen()](#module_lib/proj..Projector+listen)
|
||||||
* [.move()](#Projector+move)
|
* [.set()](#module_lib/proj..Projector+set)
|
||||||
* [.listener()](#Projector+listener)
|
* [.move()](#module_lib/proj..Projector+move)
|
||||||
* [.end()](#Projector+end)
|
* [.listener()](#module_lib/proj..Projector+listener)
|
||||||
|
* [.end()](#module_lib/proj..Projector+end)
|
||||||
|
|
||||||
<a name="Projector+init"></a>
|
<a name="module_lib/proj..Projector"></a>
|
||||||
|
|
||||||
### projector.init()
|
### lib/proj~Projector
|
||||||
**Kind**: instance method of [<code>Projector</code>](#Projector)
|
Class representing all projector features.
|
||||||
<a name="Projector+listen"></a>
|
|
||||||
|
|
||||||
### projector.listen()
|
**Kind**: inner class of [<code>lib/proj</code>](#module_lib/proj)
|
||||||
**Kind**: instance method of [<code>Projector</code>](#Projector)
|
|
||||||
<a name="Projector+set"></a>
|
|
||||||
|
|
||||||
### projector.set()
|
* [~Projector](#module_lib/proj..Projector)
|
||||||
**Kind**: instance method of [<code>Projector</code>](#Projector)
|
* [.init()](#module_lib/proj..Projector+init)
|
||||||
<a name="Projector+move"></a>
|
* [.listen()](#module_lib/proj..Projector+listen)
|
||||||
|
* [.set()](#module_lib/proj..Projector+set)
|
||||||
|
* [.move()](#module_lib/proj..Projector+move)
|
||||||
|
* [.listener()](#module_lib/proj..Projector+listener)
|
||||||
|
* [.end()](#module_lib/proj..Projector+end)
|
||||||
|
|
||||||
### projector.move()
|
<a name="module_lib/proj..Projector+init"></a>
|
||||||
**Kind**: instance method of [<code>Projector</code>](#Projector)
|
|
||||||
<a name="Projector+listener"></a>
|
|
||||||
|
|
||||||
### projector.listener()
|
#### projector.init()
|
||||||
**Kind**: instance method of [<code>Projector</code>](#Projector)
|
**Kind**: instance method of [<code>Projector</code>](#module_lib/proj..Projector)
|
||||||
<a name="Projector+end"></a>
|
<a name="module_lib/proj..Projector+listen"></a>
|
||||||
|
|
||||||
### projector.end()
|
#### projector.listen()
|
||||||
**Kind**: instance method of [<code>Projector</code>](#Projector)
|
**Kind**: instance method of [<code>Projector</code>](#module_lib/proj..Projector)
|
||||||
|
<a name="module_lib/proj..Projector+set"></a>
|
||||||
|
|
||||||
|
#### projector.set()
|
||||||
|
**Kind**: instance method of [<code>Projector</code>](#module_lib/proj..Projector)
|
||||||
|
<a name="module_lib/proj..Projector+move"></a>
|
||||||
|
|
||||||
|
#### projector.move()
|
||||||
|
**Kind**: instance method of [<code>Projector</code>](#module_lib/proj..Projector)
|
||||||
|
<a name="module_lib/proj..Projector+listener"></a>
|
||||||
|
|
||||||
|
#### projector.listener()
|
||||||
|
**Kind**: instance method of [<code>Projector</code>](#module_lib/proj..Projector)
|
||||||
|
<a name="module_lib/proj..Projector+end"></a>
|
||||||
|
|
||||||
|
#### projector.end()
|
||||||
|
**Kind**: instance method of [<code>Projector</code>](#module_lib/proj..Projector)
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
/** class representing the Projector features **/
|
||||||
|
import type { Arduino } from 'arduino';
|
||||||
|
import type { FilmOut } from 'filmout';
|
||||||
|
import type { Config } from 'cfg';
|
||||||
|
import type { WebContents } from 'electron';
|
||||||
|
interface ProjectorState {
|
||||||
|
pos: number;
|
||||||
|
dir: boolean;
|
||||||
|
}
|
||||||
|
/** @module lib/proj */
|
||||||
|
/**
|
||||||
|
* Class representing all projector features.
|
||||||
|
*/
|
||||||
|
export declare class Projector {
|
||||||
|
state: ProjectorState;
|
||||||
|
arduino: Arduino;
|
||||||
|
private log;
|
||||||
|
private cfg;
|
||||||
|
private ui;
|
||||||
|
private ipc;
|
||||||
|
filmout: FilmOut;
|
||||||
|
private id;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
constructor(arduino: Arduino, cfg: Config, ui: WebContents, filmout: FilmOut, second?: boolean);
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private init;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private listen;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
set(dir: boolean, id: string): Promise<number>;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
move(id: string): Promise<number>;
|
||||||
|
both(id: string): Promise<number>;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private listener;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
end(cmd: string, id: string, ms: number): Promise<number>;
|
||||||
|
}
|
||||||
|
export type { ProjectorState };
|
|
@ -1,7 +1,13 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
/** class representing the Projector features **/
|
/** class representing the Projector features **/
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const Log = require("log");
|
exports.Projector = void 0;
|
||||||
|
const electron_1 = require("electron");
|
||||||
|
const log_1 = require("log");
|
||||||
|
/** @module lib/proj */
|
||||||
|
/**
|
||||||
|
* Class representing all projector features.
|
||||||
|
*/
|
||||||
class Projector {
|
class Projector {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -12,6 +18,7 @@ class Projector {
|
||||||
dir: true
|
dir: true
|
||||||
};
|
};
|
||||||
this.arduino = null;
|
this.arduino = null;
|
||||||
|
this.ipc = electron_1.ipcMain;
|
||||||
this.id = 'projector';
|
this.id = 'projector';
|
||||||
this.arduino = arduino;
|
this.arduino = arduino;
|
||||||
this.cfg = cfg;
|
this.cfg = cfg;
|
||||||
|
@ -25,8 +32,7 @@ class Projector {
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
async init() {
|
async init() {
|
||||||
this.log = await Log({ label: this.id });
|
this.log = await (0, log_1.Log)({ label: this.id });
|
||||||
this.ipc = require('electron').ipcMain;
|
|
||||||
this.listen();
|
this.listen();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -56,7 +62,7 @@ class Projector {
|
||||||
ms = await this.arduino.send(this.id, cmd);
|
ms = await this.arduino.send(this.id, cmd);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error(`Error setting ${this.id} direction`, err);
|
this.log.error(`Error setting ${this.id} direction: ${id}`, err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return await this.end(cmd, id, ms);
|
return await this.end(cmd, id, ms);
|
||||||
|
@ -64,7 +70,7 @@ class Projector {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
async move(frame, id) {
|
async move(id) {
|
||||||
const cmd = this.cfg.arduino.cmd[this.id];
|
const cmd = this.cfg.arduino.cmd[this.id];
|
||||||
let ms;
|
let ms;
|
||||||
if (this.filmout.state.enabled) {
|
if (this.filmout.state.enabled) {
|
||||||
|
@ -80,20 +86,20 @@ class Projector {
|
||||||
ms = await this.arduino.send(this.id, cmd);
|
ms = await this.arduino.send(this.id, cmd);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error(`Error moving ${this.id}`, err);
|
this.log.error(`Error moving ${this.id}: ${id}`, err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//this.log.info('Projector move time', { ms });
|
//this.log.info('Projector move time', { ms });
|
||||||
return await this.end(cmd, id, ms);
|
return await this.end(cmd, id, ms);
|
||||||
}
|
}
|
||||||
async both(frame, id) {
|
async both(id) {
|
||||||
const cmd = this.cfg.arduino.cmd[this.id + 's'];
|
const cmd = this.cfg.arduino.cmd[this.id + 's'];
|
||||||
let ms;
|
let ms;
|
||||||
try {
|
try {
|
||||||
ms = await this.arduino.send(this.id, cmd);
|
ms = await this.arduino.send(this.id, cmd);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error(`Error moving ${this.id}`, err);
|
this.log.error(`Error moving ${this.id}: ${id}`, err);
|
||||||
}
|
}
|
||||||
//this.log.info('Projectors move time', { ms });
|
//this.log.info('Projectors move time', { ms });
|
||||||
return await this.end(cmd, id, ms);
|
return await this.end(cmd, id, ms);
|
||||||
|
@ -110,12 +116,12 @@ class Projector {
|
||||||
this.log.error(err);
|
this.log.error(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (typeof arg.frame !== 'undefined') {
|
else if (typeof arg.move !== 'undefined') {
|
||||||
try {
|
try {
|
||||||
await this.move(arg.frame, arg.id);
|
await this.move(arg.id);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.log.error(err);
|
this.log.error(`Error moving ${this.id}: ${arg.id}`, err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (typeof arg.val !== 'undefined') {
|
else if (typeof arg.val !== 'undefined') {
|
||||||
|
@ -166,10 +172,10 @@ class Projector {
|
||||||
}
|
}
|
||||||
message += ` ${ms}ms`;
|
message += ` ${ms}ms`;
|
||||||
this.log.info(message, 'PROJECTOR');
|
this.log.info(message, 'PROJECTOR');
|
||||||
return await this.ui.send(this.id, { cmd: cmd, id: id, ms: ms });
|
await this.ui.send(this.id, { cmd, id, ms });
|
||||||
|
return ms;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.exports = function (arduino, cfg, ui, filmout, second) {
|
exports.Projector = Projector;
|
||||||
return new Projector(arduino, cfg, ui, filmout, second);
|
module.exports = { Projector };
|
||||||
};
|
|
||||||
//# sourceMappingURL=index.js.map
|
//# sourceMappingURL=index.js.map
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,176 @@
|
||||||
|
<a name="module_lib/sequencer"></a>
|
||||||
|
|
||||||
|
## lib/sequencer
|
||||||
|
|
||||||
|
* [lib/sequencer](#module_lib/sequencer)
|
||||||
|
* [~Create a new sequencer and assign command and UI as private sub-classes](#module_lib/sequencer..Create a new sequencer and assign command and UI as private sub-classes)
|
||||||
|
* [new Create a new sequencer and assign command and UI as private sub-classes(cfg, cmd, ui)](#new_module_lib/sequencer..Create a new sequencer and assign command and UI as private sub-classes_new)
|
||||||
|
* [~Sequencer](#module_lib/sequencer..Sequencer)
|
||||||
|
* [.cmds(obj)](#module_lib/sequencer..Sequencer+cmds)
|
||||||
|
* [.init()](#module_lib/sequencer..Sequencer+init)
|
||||||
|
* [.listen()](#module_lib/sequencer..Sequencer+listen)
|
||||||
|
* [.listener(event, arg)](#module_lib/sequencer..Sequencer+listener)
|
||||||
|
* [.setLoops(count)](#module_lib/sequencer..Sequencer+setLoops)
|
||||||
|
* [.setSteps(steps)](#module_lib/sequencer..Sequencer+setSteps)
|
||||||
|
* [.unsetSteps(steps)](#module_lib/sequencer..Sequencer+unsetSteps)
|
||||||
|
* [.start(arg)](#module_lib/sequencer..Sequencer+start)
|
||||||
|
* [.pause()](#module_lib/sequencer..Sequencer+pause)
|
||||||
|
* [.stop()](#module_lib/sequencer..Sequencer+stop)
|
||||||
|
* [.step(x)](#module_lib/sequencer..Sequencer+step)
|
||||||
|
* [.cmdExec(x)](#module_lib/sequencer..Sequencer+cmdExec)
|
||||||
|
|
||||||
|
<a name="module_lib/sequencer..Create a new sequencer and assign command and UI as private sub-classes"></a>
|
||||||
|
|
||||||
|
### lib/sequencer~Create a new sequencer and assign command and UI as private sub-classes
|
||||||
|
**Kind**: inner class of [<code>lib/sequencer</code>](#module_lib/sequencer)
|
||||||
|
<a name="new_module_lib/sequencer..Create a new sequencer and assign command and UI as private sub-classes_new"></a>
|
||||||
|
|
||||||
|
#### new Create a new sequencer and assign command and UI as private sub-classes(cfg, cmd, ui)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| cfg | <code>object</code> | Configuration object |
|
||||||
|
| cmd | <code>object</code> | Shared command class |
|
||||||
|
| ui | <code>object</code> | Electron UI, browser window |
|
||||||
|
|
||||||
|
<a name="module_lib/sequencer..Sequencer"></a>
|
||||||
|
|
||||||
|
### lib/sequencer~Sequencer
|
||||||
|
Class representing all sequencer features.
|
||||||
|
|
||||||
|
**Kind**: inner class of [<code>lib/sequencer</code>](#module_lib/sequencer)
|
||||||
|
|
||||||
|
* [~Sequencer](#module_lib/sequencer..Sequencer)
|
||||||
|
* [.cmds(obj)](#module_lib/sequencer..Sequencer+cmds)
|
||||||
|
* [.init()](#module_lib/sequencer..Sequencer+init)
|
||||||
|
* [.listen()](#module_lib/sequencer..Sequencer+listen)
|
||||||
|
* [.listener(event, arg)](#module_lib/sequencer..Sequencer+listener)
|
||||||
|
* [.setLoops(count)](#module_lib/sequencer..Sequencer+setLoops)
|
||||||
|
* [.setSteps(steps)](#module_lib/sequencer..Sequencer+setSteps)
|
||||||
|
* [.unsetSteps(steps)](#module_lib/sequencer..Sequencer+unsetSteps)
|
||||||
|
* [.start(arg)](#module_lib/sequencer..Sequencer+start)
|
||||||
|
* [.pause()](#module_lib/sequencer..Sequencer+pause)
|
||||||
|
* [.stop()](#module_lib/sequencer..Sequencer+stop)
|
||||||
|
* [.step(x)](#module_lib/sequencer..Sequencer+step)
|
||||||
|
* [.cmdExec(x)](#module_lib/sequencer..Sequencer+cmdExec)
|
||||||
|
|
||||||
|
<a name="module_lib/sequencer..Sequencer+cmds"></a>
|
||||||
|
|
||||||
|
#### sequencer.cmds(obj)
|
||||||
|
Take configuration object and assign all commands as keys
|
||||||
|
in the internal CMDS object.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Sequencer</code>](#module_lib/sequencer..Sequencer)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| obj | <code>object</code> | Configuration object |
|
||||||
|
|
||||||
|
<a name="module_lib/sequencer..Sequencer+init"></a>
|
||||||
|
|
||||||
|
#### sequencer.init()
|
||||||
|
Initialize the class by requiring ipcMain from electron
|
||||||
|
and creating logger.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Sequencer</code>](#module_lib/sequencer..Sequencer)
|
||||||
|
<a name="module_lib/sequencer..Sequencer+listen"></a>
|
||||||
|
|
||||||
|
#### sequencer.listen()
|
||||||
|
Bind ipc listener to channel 'sequencer' or current id of
|
||||||
|
class.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Sequencer</code>](#module_lib/sequencer..Sequencer)
|
||||||
|
<a name="module_lib/sequencer..Sequencer+listener"></a>
|
||||||
|
|
||||||
|
#### sequencer.listener(event, arg)
|
||||||
|
Listener callback function. Called whenever ipc
|
||||||
|
message is sent to channel 'sequencer'.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Sequencer</code>](#module_lib/sequencer..Sequencer)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| event | <code>object</code> | IPC message event |
|
||||||
|
| arg | <code>object</code> | Arguments provided in message |
|
||||||
|
|
||||||
|
<a name="module_lib/sequencer..Sequencer+setLoops"></a>
|
||||||
|
|
||||||
|
#### sequencer.setLoops(count)
|
||||||
|
Sets the value of the loops in the grid sequence
|
||||||
|
to value sent by UI in ipc message.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Sequencer</code>](#module_lib/sequencer..Sequencer)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| count | <code>integer</code> | Number of loops to set grid sequence to |
|
||||||
|
|
||||||
|
<a name="module_lib/sequencer..Sequencer+setSteps"></a>
|
||||||
|
|
||||||
|
#### sequencer.setSteps(steps)
|
||||||
|
Sets multiple steps at once
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Sequencer</code>](#module_lib/sequencer..Sequencer)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| steps | <code>array</code> | Array of steps to set or update |
|
||||||
|
|
||||||
|
<a name="module_lib/sequencer..Sequencer+unsetSteps"></a>
|
||||||
|
|
||||||
|
#### sequencer.unsetSteps(steps)
|
||||||
|
Resets multiple steps to default 'undefined' state
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Sequencer</code>](#module_lib/sequencer..Sequencer)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| steps | <code>array</code> | Array containing the x location of steps to unset |
|
||||||
|
|
||||||
|
<a name="module_lib/sequencer..Sequencer+start"></a>
|
||||||
|
|
||||||
|
#### sequencer.start(arg)
|
||||||
|
Starts a sequence with the existing grid sequence,
|
||||||
|
or if one is provided in the arg object, starts
|
||||||
|
that sequence.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Sequencer</code>](#module_lib/sequencer..Sequencer)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| arg | <code>object</code> | Arguments from ipc message |
|
||||||
|
|
||||||
|
<a name="module_lib/sequencer..Sequencer+pause"></a>
|
||||||
|
|
||||||
|
#### sequencer.pause()
|
||||||
|
Pauses sequence from UI.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Sequencer</code>](#module_lib/sequencer..Sequencer)
|
||||||
|
<a name="module_lib/sequencer..Sequencer+stop"></a>
|
||||||
|
|
||||||
|
#### sequencer.stop()
|
||||||
|
Stops the sequence
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Sequencer</code>](#module_lib/sequencer..Sequencer)
|
||||||
|
<a name="module_lib/sequencer..Sequencer+step"></a>
|
||||||
|
|
||||||
|
#### sequencer.step(x)
|
||||||
|
Execute command @ step x. Wrapper with try catch.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Sequencer</code>](#module_lib/sequencer..Sequencer)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| x | <code>integer</code> | Step to execute command at |
|
||||||
|
|
||||||
|
<a name="module_lib/sequencer..Sequencer+cmdExec"></a>
|
||||||
|
|
||||||
|
#### sequencer.cmdExec(x)
|
||||||
|
Locate step @ position x and execute the command.
|
||||||
|
|
||||||
|
**Kind**: instance method of [<code>Sequencer</code>](#module_lib/sequencer..Sequencer)
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| x | <code>integer</code> | Step to execute command at |
|
||||||
|
|
|
@ -0,0 +1,107 @@
|
||||||
|
import { Commands } from 'cmd';
|
||||||
|
import type { Config } from 'cfg';
|
||||||
|
import type { WebContents } from 'electron';
|
||||||
|
/** @module lib/sequencer */
|
||||||
|
/**
|
||||||
|
* Class representing all sequencer features.
|
||||||
|
*/
|
||||||
|
export declare class Sequencer {
|
||||||
|
private running;
|
||||||
|
private paused;
|
||||||
|
private grid;
|
||||||
|
private gridLoops;
|
||||||
|
private arr;
|
||||||
|
private loops;
|
||||||
|
private cfg;
|
||||||
|
private cmd;
|
||||||
|
private CMDS;
|
||||||
|
private ipc;
|
||||||
|
private ui;
|
||||||
|
private log;
|
||||||
|
private id;
|
||||||
|
private alerted;
|
||||||
|
private psbId;
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* Create a new sequencer and assign command and UI as private sub-classes
|
||||||
|
*
|
||||||
|
* @param {object} cfg Configuration object
|
||||||
|
* @param {object} cmd Shared command class
|
||||||
|
* @param {object} ui Electron UI, browser window
|
||||||
|
**/
|
||||||
|
constructor(cfg: Config, cmd: Commands, ui: WebContents);
|
||||||
|
/**
|
||||||
|
* Take configuration object and assign all commands as keys
|
||||||
|
* in the internal CMDS object.
|
||||||
|
*
|
||||||
|
* @param {object} obj Configuration object
|
||||||
|
**/
|
||||||
|
private cmds;
|
||||||
|
/**
|
||||||
|
* Initialize the class by requiring ipcMain from electron
|
||||||
|
* and creating logger.
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
private init;
|
||||||
|
/**
|
||||||
|
* Bind ipc listener to channel 'sequencer' or current id of
|
||||||
|
* class.
|
||||||
|
**/
|
||||||
|
private listen;
|
||||||
|
/**
|
||||||
|
* Listener callback function. Called whenever ipc
|
||||||
|
* message is sent to channel 'sequencer'.
|
||||||
|
*
|
||||||
|
* @param {object} event IPC message event
|
||||||
|
* @param {object} arg Arguments provided in message
|
||||||
|
**/
|
||||||
|
private listener;
|
||||||
|
/**
|
||||||
|
* Sets the value of the loops in the grid sequence
|
||||||
|
* to value sent by UI in ipc message.
|
||||||
|
*
|
||||||
|
* @param {integer} count Number of loops to set grid sequence to
|
||||||
|
**/
|
||||||
|
setLoops(count: number): void;
|
||||||
|
/**
|
||||||
|
* Sets multiple steps at once
|
||||||
|
*
|
||||||
|
* @param {array} steps Array of steps to set or update
|
||||||
|
**/
|
||||||
|
setSteps(steps: any[]): void;
|
||||||
|
/**
|
||||||
|
* Resets multiple steps to default 'undefined' state
|
||||||
|
*
|
||||||
|
* @param {array} steps Array containing the x location of steps to unset
|
||||||
|
**/
|
||||||
|
unsetSteps(steps: number[]): void;
|
||||||
|
/**
|
||||||
|
* Starts a sequence with the existing grid sequence,
|
||||||
|
* or if one is provided in the arg object, starts
|
||||||
|
* that sequence.
|
||||||
|
*
|
||||||
|
* @param {object} arg Arguments from ipc message
|
||||||
|
**/
|
||||||
|
start(arg: any): Promise<void>;
|
||||||
|
/**
|
||||||
|
* Pauses sequence from UI.
|
||||||
|
**/
|
||||||
|
pause(): void;
|
||||||
|
/**
|
||||||
|
* Stops the sequence
|
||||||
|
**/
|
||||||
|
stop(): void;
|
||||||
|
/**
|
||||||
|
* Execute command @ step x. Wrapper with try catch.
|
||||||
|
*
|
||||||
|
* @param {integer} x Step to execute command at
|
||||||
|
**/
|
||||||
|
private step;
|
||||||
|
/**
|
||||||
|
* Locate step @ position x and execute the command.
|
||||||
|
*
|
||||||
|
* @param {integer} x Step to execute command at
|
||||||
|
**/
|
||||||
|
private cmdExec;
|
||||||
|
isRunning(): boolean;
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue