Compare commits

...

431 Commits
1.6.9 ... main

Author SHA1 Message Date
Matt McWilliams 2af8b4b209 Merge remote-tracking branch 'origin/main' 2024-04-28 21:38:32 -04:00
Matt McWilliams 66096fa2ea Add the designs and sketches for the ACME Trebes. 2024-04-19 18:09:44 -06:00
Matt McWilliams 18875a01c6 Correctly reference common.scad and add file for camera mount. 2024-04-15 14:05:38 -06:00
Matt McWilliams 7d2c2b9d09 Use common.scad, change all cylinder entries 2024-04-15 09:42:25 -06:00
Matt McWilliams 67a290a02a Add a bellows adapter for Canon RF cameras and an ACME bellows 2024-04-14 13:34:41 -06:00
Matt McWilliams 63f4278b2b Resolve startup order issues and explanation for all the delays that were meager attempts to solve a race condition. By moving more IPC connectionts to handles, which can be awaited, there are no more attempts to send message to light object that fails because it has not yet been instantiated. 2024-04-06 23:37:30 -04:00
Matt McWilliams 6778f871db Devices, serial and type terms were updated everywhere in code except in the settings object. 2024-04-06 20:29:56 -04:00
Matt McWilliams edc72a5486 Do not overwrite data with an empty object. Overwrite values if there are keys in the object. 2024-04-06 20:15:19 -04:00
Matt McWilliams 2779258111 List of devices looks strange on laptop. Attempt at fix here 2024-04-06 20:10:14 -04:00
Matt McWilliams da735779b4 Add more trycatches add more logs. Not sure where failure is. 2024-04-06 20:00:54 -04:00
Matt McWilliams b7e2e912f4 Figure out why devices.ready() is not reaching end of method on Mono laptop 2024-04-06 19:53:04 -04:00
Matt McWilliams d34172d8e9 Use device.profile() method, seemingly not implemented properly 2024-04-06 19:37:29 -04:00
Matt McWilliams f30ce78f9d Suppress warnings from Intval and execRaw during compilation. Add logging to ready to test on Mono laptop 2024-04-06 19:18:15 -04:00
Matt McWilliams ed767aedb5 Recompile with newer modules. 2024-04-06 19:09:50 -04:00
Matt McWilliams ab35895cb3 update rails 2024-04-06 19:02:39 -04:00
Matt McWilliams 1e2b65644d Update package lock files to work with node16 and electron19 2024-04-06 18:55:46 -04:00
Matt McWilliams 3f58bbc617 Merged changes from work script into JKMM100, works on device in both work script and deployment one 2024-04-06 15:48:02 -04:00
Matt McWilliams c1da7b53a2 Fix for the canonical URL caught by Tom Murphy
Thanks Tom!
2024-01-24 05:19:07 +00:00
Matt McWilliams 4181c22995 Cleanup whitespace/semicolons and add concept for passing an exposure length to the image in millis. 2024-01-19 06:49:03 -05:00
Matt McWilliams d31ac53bd1 Back is ready to print 2024-01-09 13:54:01 -05:00
Matt McWilliams 9b954852aa Add the first draft for the CPC plug back 2024-01-08 15:49:08 -05:00
Matt McWilliams 3758916fb5 Adjust plug insert 2024-01-06 17:56:55 -05:00
Matt McWilliams 25c1395655 make insert thicker for betther overall strength of the plug 2024-01-06 14:30:00 -05:00
Matt McWilliams 440edd7b18 Add 5mm marks to bolex plate 2023-12-27 23:56:10 -05:00
Matt McWilliams a2f045841f Fix bolt countersink in bolex mounting block. Add center line to top 2023-12-27 20:04:43 -05:00
Matt McWilliams c890107e1e Experimental refactor, move commonly-used pattern of cylinder() module with 4 names arguments to cy() with 3 positional arguments, D = diameter, H = height, and FN = $fn. Might improve readability and reduce repetative use of center = true. 2023-12-26 17:37:39 -05:00
Matt McWilliams a5df1650b9 Move nuts to bottom of camera sled and bolts can drop in from the top (easier assembly, bolts can be glued in place or held in more easily). Create camera sled bolex plate and modify the bolex standoff to accomodate it. WIP. 2023-12-23 23:08:59 -05:00
Matt McWilliams 173ce499bc CPC connector work 2023-12-15 19:40:18 -05:00
Matt McWilliams 33412b0588 Merge branch 'main' of ssh://git.sixteenmillimeter.com/16mm/mcopy 2023-12-10 22:51:38 -05:00
Matt McWilliams 3c5e31a961 Work on CPC Connector plug 2023-12-10 22:48:12 -05:00
Matt McWilliams 39676f9a06 fastcsg is non-deterministic 2023-12-02 09:40:54 -05:00
Matt McWilliams 0f893d94c4 Fix the dual projector script and add notes 2023-11-30 22:32:48 -05:00
Matt McWilliams b08f5094d5 Make a solid bearing roller 2023-11-30 22:32:33 -05:00
Matt McWilliams 70e046eeb7 Fix plug diameter 2023-11-30 22:32:18 -05:00
Matt McWilliams 58d0742187 Add takeup signal terminals to the mcopy projector board. 2023-11-28 23:09:09 -05:00
Matt McWilliams f84e8b741a Developed a seemingly working fix with the "correction loop" strategy. Might be putting the motor through hell but it is consistent. 2023-11-25 20:22:44 -05:00
Matt McWilliams fcf24b5539 Add the OFFSET command to the McopySerial library 2023-11-25 20:06:16 -05:00
Matt McWilliams 128a4d2ded Update mcopy_JKMM100_work to have McopySerial library 2023-11-25 20:05:52 -05:00
Matt McWilliams b14d24e650 Prototype for Arduino Mega shield for projector. 2023-11-25 18:08:10 -05:00
Matt McWilliams 7995665c6b Add camera sled 2023-11-24 10:58:20 -05:00
Matt McWilliams a22906d3c2 Add mcopy projector board. 2023-11-22 17:33:23 -05:00
Matt McWilliams 042533dc85 Add plugs for linear bearings in rail ends. 2023-11-19 16:08:37 -05:00
Matt McWilliams 5fbefeecbf Update to the orbital brace 2023-11-13 20:43:13 -05:00
Matt McWilliams a9772ff081 Changes to the brace to allow the projector to fit. Made Y of panel larger. 2023-11-13 20:41:26 -05:00
Matt McWilliams cdf983c7c6 Render STLs for mcopy_projector and mcopy_rails. Make tweaks to orbital mount to fit bolts. 2023-11-12 15:22:23 -05:00
Matt McWilliams 03f886580f Created orbital brace corner and rendered additional stls 2023-11-09 15:54:56 -05:00
Matt McWilliams a06e2869b9 Adjust bolt voids on corner_bracket 2023-11-08 18:15:31 -05:00
Matt McWilliams 6bafb263de Projector rails added and printed 2023-11-04 09:38:20 -04:00
Matt McWilliams 493ff5fbf6 Update raisl and render all files 2023-11-01 00:27:46 -04:00
Matt McWilliams c29e0880ac Work on rails and lens gantry. First prototype is made. Rendering all. 2023-10-30 22:02:30 -04:00
Matt McWilliams 986c7a915b Tweaks to lens sled gantry 2023-10-26 18:11:35 -04:00
Matt McWilliams 68b1b8b819 Double bearings in lens sled 2023-10-24 22:20:47 -04:00
Matt McWilliams 382ba56fa7 Create a prospective "inaccurate" analogReadAverage method. 2023-10-10 22:29:02 -04:00
Matt McWilliams 24d6685047 Use I to trigger projector.home() 2023-10-10 22:12:31 -04:00
Matt McWilliams 565d2ecceb Add second dataset for testing findPeak method 2023-10-10 21:20:51 -04:00
Matt McWilliams c4456e458f Add "home" as command character "I". 2023-10-10 21:16:49 -04:00
Matt McWilliams f707dedc91 New homing behavior. Ready to port back to original. 2023-10-09 22:59:05 -04:00
Matt McWilliams 702fc4680d Had accidentally switched motors, explaining odd homing behavior. New homing behavior whips ass. 2023-10-09 22:58:48 -04:00
Matt McWilliams 99b63150ac Add more smoothing during homing step. Is running consistently but is ending with motor in wrong position each time. Very strange. 2023-10-09 20:52:58 -04:00
Matt McWilliams 6e7c226c57 Make a sample script for analyzing the array during homing step. 2023-10-09 20:52:18 -04:00
Matt McWilliams c8e5f7b742 Caught one bug after separating out code 2023-10-09 19:15:30 -04:00
Matt McWilliams 0cf147d185 Piece off homing code into its own script. 2023-10-09 19:09:50 -04:00
Matt McWilliams cf1514f53e Print lens slded at full width (140mm for now) 2023-10-09 19:07:16 -04:00
Matt McWilliams af3843a8ef Add servo functionality for rack and pinion motion. Need to fix home feature. 2023-10-09 09:59:19 -04:00
Matt McWilliams 91ce2dd450 Add BOM log lines and move rail ends into its own module 2023-10-09 09:58:55 -04:00
Matt McWilliams 71c9efae42 Tweak to the rack and pinion mechanism to allow it to fit. 2023-10-09 09:58:35 -04:00
Matt McWilliams 08ce0d792b Fix for case where this.confirmExec is not a function 2023-10-08 18:15:31 -04:00
Matt McWilliams 754ef17b74 Update servo gear to fit reinforced servo connectors. 2023-10-08 11:41:35 -04:00
Matt McWilliams 5d4fec8c81 Start adding BOM log lines to build. 2023-10-07 15:26:10 -04:00
Matt McWilliams 1e0338a77f Update rack and pinion library to one that produces valid geometry. Make first pass at rack and pinion gear 2023-10-06 13:47:15 -04:00
Matt McWilliams e6b9628746 All projector work from today 2023-10-05 17:28:01 -04:00
Matt McWilliams 6f68081dc5 Restore the home method. Now it compiles. 2023-10-03 13:44:04 -04:00
Matt McWilliams 66b18dd351 Work on LED enclosure 2023-10-03 09:16:34 -04:00
Matt McWilliams b5f5b6461a Work on LED housings 2023-09-28 22:51:55 -04:00
Matt McWilliams 6dd29d9596 Disable home feature for now. Fixed impossibly stupid bug with reverse mode. Used uint16_t rather than int16_t causing an overflow. 2023-09-28 20:46:45 -04:00
Matt McWilliams 29ba125534 Work on LED housing. 2023-09-27 21:31:35 -04:00
Matt McWilliams 144af1414c Merge remote-tracking branch 'origin/main' 2023-09-27 19:10:24 -04:00
Matt McWilliams 06906eca42 Start progress on rack and pinion nub mover 2023-09-27 19:10:13 -04:00
Matt McWilliams 0d47748d6a Saved work in progress 2023-09-27 10:07:50 -04:00
Matt McWilliams b1c8192625 Projector firmware progress: currently the homing function will not compile due to errors with reference and so the sketch method needs to be broken into workable smaller methods 2023-09-25 21:54:31 -04:00
Matt McWilliams d2c7781d79 Servo notch puller progress 2023-09-25 21:53:10 -04:00
Matt McWilliams 37d4f50ef4 Add OpenSCAD/MCAD to the project to prevent double work. Including as a submodule appears to satisfy the requirement of the LGPL and allows mcopy to remain MIT licensed. 2023-09-25 12:25:56 -04:00
Matt McWilliams 082ac85c5c Add deeper notches for 90 degree points 2023-09-25 12:14:59 -04:00
Matt McWilliams cfca56ba48 Migrate stepper block into its own module 2023-09-24 22:58:14 -04:00
Matt McWilliams c7cb4ddbc5 Create the first design of the orbital mount and make slight adjustment to panel (screws were not attaching fully). 2023-09-24 22:46:38 -04:00
Matt McWilliams 7f98d6028b Commit all work in progress 2023-09-21 21:06:31 -04:00
Matt McWilliams 401822a7bb Merge branch 'main' of ssh://git.sixteenmillimeter.com/16mm/mcopy 2023-09-15 19:18:09 -04:00
Matt McWilliams 173ba06590 Work on projector (wrong) 2023-09-14 23:30:29 -04:00
Matt McWilliams 2677118bad fix 2023-09-12 22:36:18 -04:00
Matt McWilliams 8e90456d87 LED gate should be larger 2023-09-12 21:53:38 -04:00
Matt McWilliams 0b880a5e79 Add accurateRead functions and Readme 2023-09-06 15:41:36 -04:00
Matt McWilliams 082dbc0826 Add void for motor, threaded rod (optional) and linear rod. 2023-09-06 00:01:00 -04:00
Matt McWilliams 5eccbbf6df Remove part of the 2020 ends so that it can print without supports 2023-09-05 23:29:48 -04:00
Matt McWilliams 513deb7a0a Render part of the projector. 2023-09-05 23:15:53 -04:00
Matt McWilliams 2b24dc647c Update lens assembly to start using a 2020 frame 2023-09-05 23:15:32 -04:00
Matt McWilliams f8e5968f30 Rename JK lens assembly to reflect it is a new design 2023-09-05 21:31:31 -04:00
Matt McWilliams 18b8c84fff Add additional bearings to lens sled and voids for m5 bolts to hold in side bearings. 2023-09-04 13:10:23 -04:00
Matt McWilliams 1d6ccb7838 Enlarge void for m5 bolt. Add void for m5 nut. 2023-09-04 11:43:01 -04:00
Matt McWilliams a7a63a3be7 Render all projector and rails in current state 2023-09-04 10:49:20 -04:00
Matt McWilliams 153ef9eceb Use fast-csg and parallel with 8 jobs hardcoded 2023-09-04 10:48:54 -04:00
Matt McWilliams eec7765e73 Restore settings logic 2023-08-30 01:18:10 -04:00
Matt McWilliams 03f2b55762 Fucked up the merge 2023-08-29 23:33:42 -04:00
Matt McWilliams 6714374639 restore work from tonight 2023-08-29 23:11:24 -04:00
Matt McWilliams b6b1f5d5ba Parts work 2023-08-29 22:34:55 -04:00
Matt McWilliams d7a10f9737 Enable different modes of stepping by using the settings pins. Previously was causing odd behavior because they were being used for LEDs. 2023-08-29 19:48:49 -04:00
Matt McWilliams d778adc7d0 Add LED holder concept to projector panel design 2023-08-29 17:05:53 -04:00
Matt McWilliams dcbb57f732 Rewrite mcopy_projector_firmware with AccelStepper, replacing the custom Itead firmware (not working) 2023-08-29 15:33:51 -04:00
Matt McWilliams 24452794a9 Merge remote-tracking branch 'origin/main' 2023-08-25 16:44:35 -04:00
Matt McWilliams 24fe1e8773 Work on projector: Still having issues with IteadDualStepperShield (addresses wrong motor, wrong number of steps). 2023-08-25 16:44:28 -04:00
Matt McWilliams b30c637c10 Add structures to insert 2020 Tslot into to make rails fit more snug 2023-08-23 23:35:00 -04:00
Matt McWilliams f16795b11c Render the mcopy rails parts in current form 2023-08-23 22:27:06 -04:00
Matt McWilliams 141d27599f McopyProjector lib for mcopy_projector_firmware rewrite in progress. 2023-08-23 15:21:50 -04:00
Matt McWilliams 86c88c4ac2 Printing a prototype for the lens sled 2023-08-23 00:14:47 -04:00
Matt McWilliams fbab0c043a Give up on SCAD makefile 2023-08-21 22:47:29 -04:00
Matt McWilliams 1a01a4f05e Update sprocketed_roller 2023-08-21 22:47:05 -04:00
Matt McWilliams b0305ae6da Run on all but 1 core. Update JK rails to use actual measurement 2023-08-21 22:46:42 -04:00
Matt McWilliams dd4834de04 Render rails parts (still WIP) 2023-08-21 19:39:08 -04:00
Matt McWilliams 2d90c127a3 Render existing projector panel parts 2023-08-21 19:38:55 -04:00
Matt McWilliams 51d440fccc Render all working CPC connector parts 2023-08-21 19:38:16 -04:00
Matt McWilliams 2e3ed56bb3 Update part names of bellows.scad. Render missing magnetic board. 2023-08-21 19:34:21 -04:00
Matt McWilliams 4be57f3128 Update part names for CPC connectors 2023-08-21 19:31:20 -04:00
Matt McWilliams de6f0d0495 Compile all parts in project, optionally using GNU parallel if available. 2023-08-21 19:04:39 -04:00
Matt McWilliams 98e1e73163 Update to a dynamic bash file that can render all parts in a .scad file 2023-08-21 18:23:41 -04:00
Matt McWilliams 1ae524ff31 Start making a parts list in rails end file 2023-08-21 18:23:16 -04:00
Matt McWilliams 010927c5ca Rename rails_2020 to mcopy_rails 2023-08-20 23:55:27 -04:00
Matt McWilliams 3346bf01af Work on rails having a bearing 2023-08-20 23:54:21 -04:00
Matt McWilliams 788cac7d50 All work towards creating a sled rail for the lens carriage assembly 2023-08-20 18:35:48 -04:00
Matt McWilliams 4c0fa2ba41 rails end prototype 2023-08-20 13:57:00 -04:00
Matt McWilliams 83209f466f Update all submodules 2023-08-20 12:46:36 -04:00
Matt McWilliams 10c452c1b3 Work on rails 2023-08-20 12:37:50 -04:00
Matt McWilliams a8a33a823a Update to 1.8.0 to reflect new breaking changes in app 2023-08-06 15:22:38 -04:00
Matt McWilliams e7e7f86ab3 Manual merge from capper branch: all changes to devices library. 2023-08-06 15:04:33 -04:00
Matt McWilliams 386285d48c Definition file that prevents compiler warnings on some platforms. Still unexplained because tsc is installed local to the project. 2023-08-06 14:58:26 -04:00
Matt McWilliams c4119ab7cc Manual merge from capper branch: all changes to arduino library with some improvements. 2023-08-06 14:56:42 -04:00
Matt McWilliams 176643f148 Manual merge from capper branch: all changes to display library. 2023-08-06 14:36:31 -04:00
Matt McWilliams 8b235bb6b0 mitchell work 2023-08-05 14:42:03 -04:00
Matt McWilliams 8a170f65ca Merge pull request 'canon_ble' (#82) from canon_ble into main
Reviewed-on: #82
2023-08-01 03:38:51 +00:00
Matt McWilliams 2f56dd4b8a Update the timing after delaying for 5000ms (hack) 2023-07-30 23:03:06 -04:00
Matt McWilliams 699c2dbec8 UI cleanup 1: confirm setting the exposure 2023-07-30 22:26:05 -04:00
Matt McWilliams dac720863d Resolves #80 and #81. UI will need a little cleanup. There is some string concatenation happening where it shouldn't. 2023-07-30 22:13:50 -04:00
Matt McWilliams 3b03eb70fb Add placeholder for original stepper motor 2023-07-24 21:20:06 -04:00
Matt McWilliams a173cf0d7c WIP 2023-07-23 20:00:42 -04:00
Matt McWilliams 55b39e7db3 Tweak to USB protector 2023-07-18 23:13:20 -04:00
Matt McWilliams 505a2a71e7 Add magnetic bellows models 2023-07-14 21:40:03 -04:00
Matt McWilliams fb51716e3a All work 2023-07-14 21:13:04 -04:00
Matt McWilliams bdd74fa90a Save css changes 2023-07-14 21:12:48 -04:00
Matt McWilliams 8631250b9e Ignore all apple hidden files 2023-07-13 13:00:10 -04:00
Matt McWilliams c9f35ffe90 Merge branch 'canon_ble' of ssh://git.sixteenmillimeter.com/16mm/mcopy into canon_ble 2023-07-12 22:25:17 -04:00
Matt McWilliams 18d6e2c7cd WIP on state problem 2023-07-12 22:22:46 -04:00
Matt McWilliams f47ea2d382 Work on rails ends 2023-07-10 23:07:32 -04:00
Matt McWilliams 0cc167b3a6 Incredibly close to #80 and #81. Can get state confirmation at startup. Can send exposure string and get confirmation after. Cannot get state outside of initial confirmation. Something is either locked or failing to wait? 2023-07-10 22:33:16 -04:00
Matthew McWilliams 5133295f38 Save JKMM100 work 2023-07-08 19:44:57 -04:00
Matt McWilliams 621948fbac Work on mcopy_rails concepts 2023-07-05 15:17:56 -04:00
Matt McWilliams 4539c6d897 Methods in place for setting exposure 2023-07-05 15:17:45 -04:00
Matt McWilliams a7db072dc6 Accept exposure targets as string arguments to be parsed 2023-07-05 14:46:43 -04:00
Matt McWilliams 58ce079330 Both components are working properly. 2023-07-04 22:46:37 -04:00
Matt McWilliams dd03583a27 Proof of concept works. Nano can proxy requests to ESP32 via soft serial and then receives confirmation after event. Nano has a cleaner serial interface and will not throw junk into mcopy app serial listener. 2023-07-04 18:45:51 -04:00
Matt McWilliams 3feaea74bf Do not need to declare Serial2. 2023-07-04 18:18:51 -04:00
Matt McWilliams 1d6cbe5c53 Update the serial tests 2023-07-04 17:15:26 -04:00
Matt McWilliams 318f931dbf ESP32 HardSerial note 2023-07-03 22:44:43 -04:00
Matt McWilliams 5400518ea6 Merge remote-tracking branch 'origin/canon_ble' into canon_ble 2023-07-03 22:35:37 -04:00
Matt McWilliams f73a1e3931 nano softserial note 2023-07-03 22:35:29 -04:00
Matthew McWilliams 60d7ab4b5e Add missing lines to debug sketch 2023-07-03 20:34:47 -04:00
Matthew McWilliams 95cde2907a Run the debug script 2023-07-03 20:33:32 -04:00
Matthew McWilliams 35b67f1815 Use the correct identifier on projectors 2023-07-03 20:33:18 -04:00
Matt McWilliams f958789b20 Merge remote-tracking branch 'origin/canon_ble' into canon_ble 2023-07-02 13:56:11 -04:00
Matt McWilliams 4beef04a3f Projector debug idea. 2023-07-02 13:56:03 -04:00
Matthew McWilliams 6d379d284b on site work at MONO 2023-07-01 16:34:07 -04:00
Matt McWilliams 2c21110b97 fix reference to cmdChar 2023-06-28 20:01:53 -04:00
Matt McWilliams 777db577d7 Structure of both sketches is complete, need to test on hardware 2023-06-28 15:06:11 -04:00
Matt McWilliams bf320216cf REmove remaining components from ble 2023-06-28 12:43:24 -04:00
Matt McWilliams b48c498574 Remove unneeded components from both ble sketches 2023-06-28 12:41:54 -04:00
Matt McWilliams 0b71da8e7b Canon BLE two-Arduino rewrite WIP 2023-06-27 23:16:16 -04:00
Matt McWilliams c0d6cbccec Can now detect if state is available on a device 2023-06-17 17:57:30 -04:00
Matt McWilliams 95ede98623 State string should start and end with the character 2023-06-17 13:08:00 -04:00
Matt McWilliams 3881dd4891 Update McopySerial to have a sendStr method, which is distinct from print, which should be used for debug logging. 2023-06-17 11:40:56 -04:00
Matt McWilliams 71e4bea384 Preliminary state support in arduino library. Currently confirms the negative state. Might want to push it until after verify, out of enumerate. 2023-06-16 23:04:16 -04:00
Matt McWilliams 83aa3099c4 Update the settings page with time for projector and camera actions 2023-06-16 22:07:53 -04:00
Matt McWilliams 672db32917 Put in place changes needed to receive a string from an arduino 2023-06-12 22:45:25 -04:00
Matt McWilliams 80a9c23f4d Speed down the motors 2023-05-26 07:09:00 -04:00
Matt McWilliams 49ad3c28a8 Only print projector time to state 2023-05-25 10:45:44 -04:00
Matt McWilliams a29c85628c Add bones of the dual stepper motor, JK compatible projector firmware. 2023-05-25 10:43:45 -04:00
Matt McWilliams 3ec93ab3b1 work 2023-05-16 23:05:13 -04:00
Matt McWilliams 10c29d3af1 Add a set screw to the gate_key 2023-05-15 21:48:09 -04:00
Matt McWilliams 41840b90c8 Update gitsub 2023-05-15 12:36:03 -04:00
Matt McWilliams c89e865d3d Bearing needs slight gap to allow the inner bearing wheel to rotate freely 2023-05-14 21:17:20 -04:00
Matt McWilliams c6ec54bd06 Flip projector panel to print 2023-05-14 21:01:46 -04:00
Matt McWilliams af3b1b8cbb Create first draft of projector panel redesign 2023-05-14 21:00:52 -04:00
Matt McWilliams 86273a9f09 Merge remote-tracking branch 'origin/canon_ble' into canon_ble 2023-05-02 23:58:39 -04:00
Matt McWilliams ba0241a811 Update ESP32 case 2023-05-02 23:58:31 -04:00
Matt McWilliams 1bd73876b4 Add sprocketed roller module 2023-04-28 15:35:54 -04:00
Matt McWilliams cc806cbe52 Initialize and connect only after mcopyserial connects. 2023-04-20 22:50:48 -04:00
Matt McWilliams 8f7a40075a Add connected and identified member booleans to determine when fully connected to mcopy. 2023-04-20 22:37:37 -04:00
Matt McWilliams 64faaa9427 Slight change to outer diameter. 2023-04-19 13:32:06 -04:00
Matt McWilliams d44c67ce80 Update the lens board design 2023-04-19 13:31:47 -04:00
Matt McWilliams 144b408092 Print state in the arri-s firmware 2023-04-17 16:44:04 -04:00
Matt McWilliams d2390dca30 Add a bellows board -- to be attached to bellows and then to boards with magnets. Render all STLs 2023-04-16 23:33:11 -04:00
Matt McWilliams 503a8ec92f Add magnets to bellows board design 2023-04-16 22:53:16 -04:00
Matt McWilliams ca22a3ba4b Rewrite arri_s_firmware to use McopySerial 2023-04-16 16:42:00 -04:00
Matt McWilliams ef54e61494 Use McopySerial in mcopy_arri_s_firmware 2023-04-15 22:44:33 -04:00
Matt McWilliams b1745c786b Invert logic for use with solid state relays rather than standard 2023-04-14 19:48:20 -04:00
Matt McWilliams 83efbc18c7 Fix mcopy_cam_canon_ble 2023-04-13 20:39:24 -04:00
Matthew McWilliams f47396e48c Need confirmation after mcopy_cam_relay 2023-04-12 15:25:41 -04:00
Matt McWilliams 03c27a9226 Relay logic was reversed 2023-04-12 15:15:41 -04:00
Matt McWilliams 08655898d4 Merge remote-tracking branch 'origin/canon_ble' into canon_ble 2023-04-12 14:52:40 -04:00
Matt McWilliams 5d347d23e4 Correctly reference backward LED 2023-04-12 14:52:35 -04:00
Matthew McWilliams a25d93ec55 Correctly delay between frames. 2023-04-12 14:52:05 -04:00
Matthew McWilliams bbf0cbd1c6 Add the button to the relay sketch 2023-04-11 23:43:35 -04:00
Matthew McWilliams 4aceeac1c2 Remove libraries required by TickTwo. This sketch will not use blink in this fashion ATM. 2023-04-11 23:26:12 -04:00
Matt McWilliams 1f5bb85304 Correctly reference LEDs 2023-04-11 22:39:44 -04:00
Matthew McWilliams 087fd3f763 Complete the mcopy relay sketch without variable exposure. 2023-04-11 01:13:44 -04:00
Matthew McWilliams daece3b45a Add the new mcopy_cam_relay script. 2023-04-11 00:38:06 -04:00
Matthew McWilliams 9705505285 Refactor ino.sh to loop through array of scripts to copy McopySerial library to. 2023-04-11 00:37:14 -04:00
Matthew McWilliams 9016062f70 Rename mcopy_cam_canon to mcopy_cam_canon_ble to differentiate 2023-04-11 00:28:27 -04:00
Matthew McWilliams a6de66eb66 Blink LED on startup 2023-04-11 00:24:39 -04:00
Matt McWilliams 6ada6b08ed Add LED features to projector firmware. 2023-04-10 23:28:02 -04:00
Matt McWilliams 710e178ba2 Merge branch 'canon_ble' of ssh://git.sixteenmillimeter.com/16mm/mcopy into canon_ble 2023-04-10 21:12:08 -04:00
Matt McWilliams 9e7990851e Case design work 2023-04-10 21:04:01 -04:00
Matt McWilliams ae34558f18 Add project home and mirrors to Readme 2023-04-07 09:44:51 -04:00
Matt McWilliams c1a51f1ce8 Canon EF bellows adapter 2023-04-01 19:24:29 -04:00
Matt McWilliams 13702a3d5b Add a canon_EF_body_cap script 2023-03-30 20:15:43 -04:00
Matt McWilliams 6b66cfe03f Add bolt voids to canon mount 2023-03-29 22:47:49 -04:00
Matt McWilliams cbc876c57c Case ready for production 2023-03-29 21:58:03 -04:00
Matt McWilliams 7813a8c904 First draft of Rebel case 2023-03-28 19:41:35 -04:00
Matt McWilliams 5f941e91b5 Add conecpt for arduino nano case 2023-03-26 20:19:15 -04:00
Matt McWilliams d262ed418d Add base to socket connector. 2023-03-26 20:19:00 -04:00
Matt McWilliams 2e9db4d667 Connector size is working 2023-03-26 18:53:01 -04:00
Matt McWilliams bd9317dd8f Adjust angles. Make $fn configurable (crashing the GUI on my desktop). 2023-03-26 17:53:26 -04:00
Matt McWilliams 461add1cda Start adding LEDs 2023-03-26 16:06:08 -04:00
Matt McWilliams 1528dec668 Rename bellows adapter 2023-03-24 13:51:29 -04:00
Matt McWilliams fff9d5d410 Export mcopy serial to it's own repo 2023-03-24 13:50:38 -04:00
Matt McWilliams 231c354cb1 Update McopySerial usage in both scripts that use it. 2023-03-21 20:38:45 -04:00
Matt McWilliams 4e0149e752 Fixed issue with baud being stored as const overflowed. Silly mistake.
Also storing command chars as public const variables to shorten code and allow for mc.COMMAND rather than McopySerial::COMMAND. Cleans up example code a lot.
2023-03-21 20:35:00 -04:00
Matt McWilliams 5c6b9191e5 Work in progress: Serial does not work from external library 2023-03-20 19:45:32 -04:00
Matt McWilliams 77a0f7d8a0 Use the correct pins for the projector 2023-03-18 17:36:24 -04:00
Matt McWilliams 9faae6fc36 Create the first state sender. 2023-03-18 17:25:58 -04:00
Matt McWilliams 3689eb7528 Rewrite mcopy_light to use McopySerial 2023-03-18 17:13:41 -04:00
Matt McWilliams 210dc85558 Add getString and print methods 2023-03-18 17:04:06 -04:00
Matt McWilliams 174b900cd8 Update commands 2023-03-18 17:00:13 -04:00
Matt McWilliams fbe954280f Socket connector work 2023-03-18 17:00:02 -04:00
Matt McWilliams 142c990a0e Refactored GUI into TypeScript and class-based format 2023-03-18 16:59:26 -04:00
Matt McWilliams 790ea3d551 Add guides for collar flanges 2023-03-15 22:11:48 -04:00
Matt McWilliams c6b8592490 Enlarge case and add bolt 2023-03-15 21:35:35 -04:00
Matt McWilliams f67e011d5e Canon EOS M50 mount design 2023-03-15 21:35:23 -04:00
Matt McWilliams a4bc54482d Work on canon mount 2023-03-15 19:22:18 -04:00
Matt McWilliams be50eb6fcf Work on ESP32 case and CPC socket 2023-03-14 21:45:18 -04:00
Matt McWilliams a7d784583a Case for an ESP32 dev board (Inland, Microcenter) 2023-03-13 17:46:38 -04:00
Matt McWilliams 7af1f739e4 Canon EF M bellows mount 2023-03-13 17:46:21 -04:00
Matt McWilliams 3e247703a8 More CPC connector work 2023-03-13 17:45:50 -04:00
Matt McWilliams c7e338ebff projector electronics improvements, move arduino mount, increase size, adjust resistor mount 2023-03-12 21:28:29 -04:00
Matt McWilliams cc2af435d5 First pass at esp32 case 2023-03-12 17:55:09 -04:00
Matt McWilliams 87695b173d First pass at projector controller design and refactor of sequencer case. 2023-03-12 16:36:16 -04:00
Matt McWilliams 722ff9c05e Remove unneeded comments 2023-03-10 21:19:30 -05:00
Matt McWilliams 51114df576 First draft of the JKMM100 firmware using McopySerial. Boy does this make my life easier.
Need to find a better way than copying it into all of these different projects.
Oh well.
2023-03-09 21:54:54 -05:00
Matt McWilliams 9126bc82c0 Confirm the camera command (this should happen after it expects frame is taken). 2023-03-09 21:51:49 -05:00
Matt McWilliams e09fe7d42f McopySerial now has a confirm() method which marks the end of a command. This is a wrapper around Serial.println() 2023-03-09 21:51:29 -05:00
Matt McWilliams 234e69c7a2 Canon BLE firmware now uses the McopySerial script for it's USB communication. 2023-03-09 21:30:59 -05:00
Matt McWilliams d7017af245 Move connect and identify methods to internal ones. 2023-03-09 21:26:31 -05:00
Matt McWilliams f49c70ead6 Define all command chars as static constants. Provide an identity when initializing and allow for setting with another method. 2023-03-09 21:18:10 -05:00
Matt McWilliams 9a89dbe6a5 Automatically toggle debug state internally 2023-03-09 21:08:36 -05:00
Matt McWilliams 844bb286a5 Build the skeleton of McopySerial. Contains all command chars as flags. Is now re-built with latest command flags automatically when syncing to all projects. Compiles. Will implement more in canon firmware. 2023-03-09 21:01:20 -05:00
Matt McWilliams 4eceecf139 Add ino script 2023-03-08 22:37:40 -05:00
Matt McWilliams 95e2e997e5 Move mcopy serial script. Add work (isn't working). 2023-03-08 21:28:09 -05:00
Matt McWilliams 346c303edb First pass at connector plug 2023-03-08 16:01:02 -05:00
Matt McWilliams 908fe52ad8 Simplify projector_controller.scad 2023-03-05 17:14:01 -05:00
Matt McWilliams 3fd1e47b7b Rename sleeve to collar 2023-03-05 17:13:42 -05:00
Matt McWilliams d41f082839 Update light sketch, add Pixie lib 2023-03-05 17:13:29 -05:00
Matt McWilliams 2047ce4f76 cpc connector work 2023-03-05 00:28:39 -05:00
Matt McWilliams 3ef56cab21 Compile all Arri-S parts 2023-03-04 20:20:16 -05:00
Matt McWilliams 6b77b98aad Add more files to scad.sh 2023-03-04 20:00:01 -05:00
Matt McWilliams 211101cd6b Add common SCAD lib. Add a script that compiles all scad files to stl (make is getting excessive). Canonicalize STL files after they're compiled. 2023-03-04 19:44:20 -05:00
Matt McWilliams e27cae353f Work on McopySerial library. Still having trouble with compiling. 2023-03-04 19:25:50 -05:00
Matt McWilliams b12a08e47a Rename lib to match style of others 2023-03-04 19:04:55 -05:00
Matt McWilliams 9b298ac676 Sync actual files 2023-03-04 19:01:35 -05:00
Matt McWilliams 52acb97e08 Try without symlinks 2023-03-04 18:59:47 -05:00
Matt McWilliams 78450e9e6a Add mcopy_serial library 2023-03-04 18:52:51 -05:00
Matt McWilliams dc746fe6f4 canon work 2023-03-03 10:13:40 -05:00
Matt McWilliams 0e3bc563a7 Update blink functionality. Probably will not work during start? 2023-03-01 13:51:54 -05:00
Matt McWilliams d0ef5d410d Ignore all .svd files 2023-03-01 13:38:48 -05:00
Matt McWilliams d9aa7dc698 Ignore build artifacts 2023-03-01 13:38:27 -05:00
Matt McWilliams 70ab8cb527 Improve timing. Sequence takes into account serialDelay within each command and sequenceDelay has no bearing. Was adding 120ms of error to every step 2023-03-01 13:37:22 -05:00
Matt McWilliams 512f6c86ad Resolves #73. Delay is exported in .ts file so it is non-ambient 2023-03-01 13:35:45 -05:00
Matt McWilliams d23eb290d9 Merge branch 'main' into canon_ble 2023-02-28 15:59:11 -05:00
Matt McWilliams 648bca5b2e Merge pull request 'Merge the estimates branch' (#79) from estimates into main
Reviewed-on: #79
2023-02-28 15:58:26 -05:00
Matt McWilliams 5db5d477e4 Timing is now updated via rolling average on all projector and camera actions. This data is reset when profile is changed. This data is stored in the settings.json and loaded on start so estimates will improve the more it is used. 2023-02-28 15:55:02 -05:00
Matt McWilliams 7741134917 Create the Timing class 2023-02-28 14:30:17 -05:00
Matt McWilliams 3c19cd35cf Resolves #4 (4 years ago!). Adds delay (stops scripts for X seconds), alert (displays an alert that stops script execution) and pause (displays a pre-populated alert). 2023-02-28 12:49:11 -05:00
Matt McWilliams 85832d18f6 Placeholder for notes 2023-02-27 23:16:44 -05:00
Matt McWilliams 5f0da91659 Canon BLE work 2023-02-26 22:19:07 -05:00
Matt McWilliams e1bf69e622 Add work on mcopy_cam_canon. This includes teh CanonBLERemote library, ArduinoNvs (dependency of CanonBLERemote) and TickTwo, potentially to manage a blinking UI component. Not working. Finish the firmware feature in this branch. 2023-02-25 22:24:29 -05:00
Matt McWilliams d9290f7262 Add branch_name.sh to print out only the branch name 2023-02-25 22:22:42 -05:00
Matt McWilliams 81b6846261 Only update patch on main 2023-02-25 22:22:18 -05:00
Matt McWilliams a57519adce Merge pull request 'Merge all work on server with filmout features' (#77) from server into main
Reviewed-on: #77
2023-02-25 21:16:28 -05:00
Matt McWilliams 02639466ee By doing a check for active clients during the sequencer start and stop actions, the local display is no longer used. Resolves first part of #20. 2023-02-25 17:00:11 -05:00
Matt McWilliams 6e2795d380 Remove ACK messages for ping, rely on 2023-02-25 16:33:55 -05:00
Matt McWilliams 8e35596088 Fixed the iOS issue. Also allow for fullscreen on all browsers (with no sleep). Can preview properly but normal mode does not work 2023-02-25 16:32:08 -05:00
Matt McWilliams 0162d012c5 Server can now display images and will completely preempt local display when done 2023-02-25 13:22:20 -05:00
Matt McWilliams 47fb673b78 Combined script and html into single request (problems with iOS safari).
Can get script loaded but still cannot connect to websocket server without SSL.

ALSO: Now can pre-empt opening new display if an active client is connected to server.
Otherwise will open a local link.
2023-02-25 13:11:40 -05:00
Matt McWilliams f296488bc2 Further progress on #20. TODO: Image display logic on the server side. Need to add image to proxy list and give it a properly-extensioned name and cmdAll.
ALSO: Server is not working on iOS.
2023-02-25 12:40:35 -05:00
Matt McWilliams f5392aea9f Resolves #74 2023-02-25 12:33:18 -05:00
Matt McWilliams 24b1301f9f Adding contextIsolation: false to the display module fixes the initial issue in #74, cannot use "require" but the escape button does not work due to "Cannot read properties of undefined (reading 'getCurrentWindow')" 2023-02-25 12:16:47 -05:00
Matt McWilliams 1290a8f324 Major progress on #20. Promised-based websocket command structure is completed. All functionality needs to be placed into individual classes and any new functions get added to the server.
Will create entire thin client using this method.
2023-02-25 11:59:56 -05:00
Matt McWilliams e64277e438 More work on #20. Fix typos in display code. Should re-work script into transpiled ts file. 2023-02-25 02:08:56 -05:00
Matt McWilliams c9bcb74a9f Progress on #20. Can start up a server and serve client.js 2023-02-25 02:08:05 -05:00
Matt McWilliams 42db1f81b8 Server work 2023-02-25 00:24:07 -05:00
Matt McWilliams 7222952eba Update version nubmers 2023-02-19 19:43:12 -05:00
Matt McWilliams 744f10c948 Display version in app 2023-02-19 11:36:06 -05:00
Matt McWilliams b50704a6a8 Fix minor layout issue on sequence page (on mac at least). 2023-02-19 01:28:18 -05:00
Matt McWilliams c152806511 Now it works. 2023-02-19 01:27:19 -05:00
Matt McWilliams 4d9454daf2 Patch script now working 2023-02-19 01:22:44 -05:00
Matt McWilliams e754c65602 Increment patch without npm install 2023-02-19 01:20:51 -05:00
Matt McWilliams b672921c84 Increment patch number on commit 2023-02-19 01:18:03 -05:00
Matt McWilliams 6116ada2fd Getting a new error when compiling delay library. Attempt to stop autogenerating d.ts files.
src/delay/index.ts:11:10 - error TS2384: Overload signatures must all be ambient or non-ambient.
2023-02-19 00:55:17 -05:00
Matt McWilliams d7baa4d17b Merge branch 'capper'
:w
ls
2023-02-19 00:29:40 -05:00
Matt McWilliams ebc5504998 Add commands for takeup 2023-02-19 00:29:07 -05:00
Matt McWilliams c5e66a6f40 Merge pull request 'Merge in 9 months of work on capper branch' (#71) from capper into main
Reviewed-on: #71
2023-02-19 00:28:45 -05:00
Matt McWilliams cff558ef9a Add 15mm to mount void for camera bolt 2023-02-12 14:14:03 -05:00
Matt McWilliams 325837d93e Adjustment to allow space on the right side 2023-02-12 14:10:44 -05:00
Matt McWilliams 135540b261 Remove some material for the rails 2023-02-03 20:08:18 -05:00
Matt McWilliams 49464cd25a Finished the design of the lens assembly base z attachment 2023-02-02 19:48:30 -05:00
Matt McWilliams d0fe54b429 Add m5 nut to the common lib 2023-02-02 19:48:08 -05:00
Matt McWilliams 2dce6f4b08 Merge branch 'capper' of git.sixteenmillimeter.com:16mm/mcopy into capper 2023-01-31 11:52:13 -05:00
Matt McWilliams 99794d04c2 jk assembly and arri-s wip 2023-01-31 11:52:10 -05:00
Matt McWilliams cc06655cd6 Update debug 2023-01-23 00:28:26 -05:00
Matt McWilliams ab6f517d27 Rails work 2023-01-17 12:04:03 -05:00
Matt McWilliams 682167db48 Add new commands for takeup forward and takeup backward 2023-01-15 10:09:55 -05:00
Matt McWilliams f127dc1128 Merge remote-tracking branch 'origin/capper' into capper 2023-01-14 15:26:07 -05:00
Matt McWilliams 0b816ae8e1 Adjust the position of the Z axis, move the linear bearing up and down to prevent binding on motion 2023-01-14 15:25:53 -05:00
Matt McWilliams c600fea4e1 Start rails concept 2023-01-12 19:26:05 -05:00
Matt McWilliams 92067bdbef Add top part to assembly 2023-01-11 19:17:15 -05:00
Matt McWilliams c181e003a3 First draft of base 2023-01-07 18:43:59 -05:00
Matt McWilliams 597137670d Merge base work with knob changes 2023-01-06 10:31:25 -05:00
Matt McWilliams 3036aebbc4 Knob and collar work 2023-01-06 09:18:03 -05:00
Matt McWilliams cbe6477af2 Improvements to bearing and Tnut size 2023-01-05 17:35:25 -05:00
Matthew McWilliams c2546d2bc5 Add m3 nuts and bolts to threaded z movement 2023-01-05 14:40:25 -05:00
Matt McWilliams 46be1bfd3b Assembly work. Adjusted design to simplify placement of 2 linear bearings 2023-01-04 23:11:48 -05:00
Matt McWilliams 1029885047 Update threaded Z, still needs m3 bolts 2023-01-04 18:26:22 -05:00
Matt McWilliams 164bde8cce All arri s mount and jk lens assembly work. need to do some branch cleanup on this project and tackle capper issues for merge of this branch. 2023-01-03 21:16:19 -05:00
Matt McWilliams 41504caac9 Increase the bolt size on the bellows board 2023-01-02 17:11:44 -05:00
Matt McWilliams 9b34b4e026 Adjust the height of the mount (-14.5mm) and make bolt voids larger 2023-01-02 14:33:16 -05:00
Matt McWilliams 95612c1d18 Add m3 nuts 2023-01-02 14:30:54 -05:00
Matt McWilliams 0829ec9081 Use a variable 2023-01-02 13:53:41 -05:00
Matt McWilliams ef0d246901 Increase the inner diameter of the bellows board to allow the threads to pass through cleanly and be held in place by the screw 2023-01-02 13:53:30 -05:00
Matt McWilliams 622a8a7c42 Add first concept bellows board 2023-01-01 11:43:30 -05:00
Matt McWilliams 925659ba4b Create an Arri S mount for the JK rails 2023-01-01 11:43:21 -05:00
Matt McWilliams 20c9287ac2 Work on concept JK lens assembly 2022-12-24 17:36:25 -05:00
Matt McWilliams 8aaa2b8940 Add a concept JK lens assembly 2022-12-24 01:55:11 -05:00
Matt McWilliams 30bd35e21d Add an M4 nut to the common OpenSCAD lib 2022-12-24 01:54:57 -05:00
Matthew McWilliams 0c2e39f0b2 Arri bellows work 2022-12-23 23:01:37 -05:00
Matt McWilliams cbd7001228 Save work on the JK99 shield. 2022-11-13 17:35:18 -05:00
Matt McWilliams dec96ec9be Use variable in stepper declaration 2022-11-11 15:47:58 -05:00
Matt McWilliams 3942cd05be Declare stepsPerRevolution so change is explicit when that happens 2022-11-11 15:47:43 -05:00
Matt McWilliams ee1e9c9feb Stepper firmware is working. Needed extra tape around coupling connector to add friction to connection and now it keeps. 2022-11-04 19:37:11 -04:00
Matt McWilliams fcb77232ec Create the driveCoupling module for the stepper motor design 2022-10-30 12:14:25 -04:00
Matt McWilliams 1fcbec7466 Work on stepper motor design and software. Motor still moves more slowly than it should but will investigate multiple factors leading to this result 2022-10-28 19:46:02 -04:00
Matt McWilliams 98f2c7a24a Pausing work on arri_s_DC firmware because hardware is less than ideal. Too much play in the motor position to trust right now. Steppers better approach. 2022-10-28 11:28:30 -04:00
Matt McWilliams 787e6ed06e Add a concept arri_s camera controller firmware. Using class-based approach as an experiment in Arduino code structure. 2022-10-28 07:50:30 -04:00
Matt McWilliams bb5b7c7897 Add divot to the drive coupling 2022-10-28 07:44:19 -04:00
Matt McWilliams 42b3aa767d Allow for even more space for microswritch 2022-10-28 01:32:58 -04:00
Matt McWilliams b20a6084e6 Allow for more space for the microswitch 2022-10-27 18:10:13 -04:00
Matthew McWilliams d9a8576701 Adjust size of drive coupling for the DC connector 2022-10-21 16:05:56 -04:00
Matthew McWilliams 69273d2a1c Increase scale of motor shaft void by 5% 2022-10-21 15:26:17 -04:00
Matthew McWilliams 755ea757f7 Add set screw for bearing and counter sink bolt caps for other cap m3s 2022-10-21 15:24:21 -04:00
Matt McWilliams 81fc54af8d DC motor design has all components designed, need to print, test and adjust. 2022-10-19 06:38:56 -04:00
Matt McWilliams 4281ca4390 Work on Arri-S DC motor 2022-10-16 19:03:02 -04:00
Matt McWilliams 3419172535 Arri-S work 2022-10-15 00:13:05 -04:00
Matt McWilliams 206c266b08 Added Arri-S motor and cap measurements as taken 10/8/2022 2022-10-09 11:22:12 -04:00
Matthew McWilliams 5026cf869f Arri-S work 2022-10-07 19:47:56 -04:00
Matthew McWilliams d5ecd9e057 Improve capper documentation 2022-09-16 09:45:19 -04:00
Matthew McWilliams 72b5077356 Restructure includes and type definition files so that mscript runs 2022-08-07 22:18:58 -04:00
Matthew McWilliams 6601c030f7 Refactor mscript GUI code into Typescript 2022-08-07 22:10:53 -04:00
Matthew McWilliams 3ec1373f08 Caught a possible ancient bug in the loop logic for calculating state of camera and projector backwards movements. 2022-08-07 17:23:06 -04:00
Matt McWilliams b29478cb58 Increment build patch version 2022-08-04 10:57:36 -04:00
Matt McWilliams fe61e63e76 Add secondary projector and camera commands to the mscript module 2022-08-04 10:52:00 -04:00
Matt McWilliams ee0ab663d7 Complete the alert feature. Have not created pause, but this could be done using the same alert object to prevent code duplication. 2022-08-03 09:02:47 -04:00
Matt McWilliams 1964d6002d Add mono logo as png, but might use svg instead. Render crashed PC. 2022-07-22 21:56:43 -04:00
Matt McWilliams f55b72044c Mcopy firmware with optional capper feature 2022-07-17 11:05:20 -04:00
Matt McWilliams 3f759f5678 Add the ability to detect a single capper device 2022-07-17 09:57:52 -04:00
Matt McWilliams 6582154ec6 Fix debug script and component 2022-07-17 09:56:03 -04:00
Matt McWilliams 9d0545aa4f All capper features in app, can shoot blank frames, can turn on capper independently and can schedule blank frames in the sequencer. Some cleanup may be needed but there are no noticeable regressions in the app. TODO: Finish all arduino scripts. 2022-07-15 18:11:26 -04:00
Matt McWilliams ea055d6e56 Capper case candidate 2022-07-13 23:04:00 -04:00
Matthew McWilliams bc48765b35 Start work on base 2022-07-13 18:16:43 -04:00
Matthew McWilliams 70c2c695f0 All capper work. Need to wrap all actions in the 'b' command and push functionality to a lower level to prevent unneeded complexity. 2022-07-13 15:21:26 -04:00
Matthew McWilliams 8ec5816364 Adjust settings page to support Processing input 2022-07-13 10:15:47 -04:00
Matthew McWilliams c33c6e24f6 Work on motor rod 2022-07-13 09:01:25 -04:00
Matt McWilliams b0ca15bd8d Merge branch 'capper' of git.sixteenmillimeter.com:16mm/mcopy into capper 2022-07-13 08:28:58 -04:00
Matt McWilliams 76799bd66d Capper work 2022-07-13 08:28:18 -04:00
Matthew McWilliams 18dbb72a54 Minor updates to comments 2022-07-06 14:42:53 -04:00
Matthew McWilliams c0ec81c0f9 Add Servo debug script 2022-07-06 14:42:16 -04:00
Matt McWilliams c3661d6ff1 Remove opto endstop logic, ready for hardware testing. 2022-06-28 08:58:31 -04:00
Matt McWilliams c0f056cd8d Re-render all STLs for capper, removing the opto endstop component (for now) 2022-06-28 08:38:11 -04:00
Matt McWilliams 2924efe39f Reduce the size of the void for the screw in the cap. 2022-06-28 08:34:29 -04:00
Matt McWilliams e275539fb0 Remove endstop completely and start rounding surfaces. 2022-06-22 07:45:01 -04:00
Matt McWilliams 4c13c54815 Updates to endstop mount design. Had incorrectly positioned voids for SMD chips on the endstop 2022-06-20 13:00:40 -04:00
Matt McWilliams 62a66f5f6d More mount work and start of endstop logic. Rebuilding the B&H projector unity. 2022-06-17 23:39:19 -04:00
Matt McWilliams 3a435933e3 Work on the opto endstop mount. This needs to be re-oriented before next print. 2022-06-16 00:29:31 -04:00
Matt McWilliams 78f7ac0e68 Mount work 2022-06-13 22:46:23 -04:00
Matt McWilliams 28dc19fc32 Work on endstop functionality 2022-06-13 22:46:13 -04:00
Matt McWilliams 585c47d6c7 Allow capper identifier in list of acceptable responses. 2022-06-13 08:08:42 -04:00
Matt McWilliams 04a0330327 All work on first draft of capper hardware 2022-06-12 22:26:03 -04:00
Matt McWilliams dae4e65aee Merge branch 'capper' of git.sixteenmillimeter.com:16mm/mcopy into capper 2022-06-12 13:37:52 -04:00
Matt McWilliams 129647b863 App work 2022-06-12 13:37:00 -04:00
Matt McWilliams 2f9201716a All capper work. Debug firmware for testing. STL of cap as printed. 2022-06-12 13:14:43 -04:00
Matt McWilliams f9d716552b Merge branch 'capper' of git.sixteenmillimeter.com:16mm/mcopy into capper 2022-06-11 16:06:25 -04:00
Matt McWilliams 818c8453ee Capper OpenSCAD work 2022-06-11 16:03:08 -04:00
Matthew McWilliams f7a3c52260 Silly typo: did not invoke Servo_init() and so servo was not initalizing 2022-06-10 13:19:38 -04:00
Matt McWilliams 9d3bf24627 Hardware ideas for capper mount and flag. Need to model servo and add places for endstops 2022-06-07 07:55:47 -04:00
Matt McWilliams c77201ef4e Add new commands and identifiers for the capper, start moving into capital characters 2022-06-07 07:55:26 -04:00
Matt McWilliams f585aa2a5a Upgrade electron 11 -> 19 (huge jump). Install new remote module to preserve legacy communication protocol. 2022-06-04 11:11:23 -04:00
Matt McWilliams 96e0ce6050 Merge branch 'capper' of git.sixteenmillimeter.com:16mm/mcopy into capper 2022-05-31 17:44:56 -04:00
Matt McWilliams 17d4ff459f Notes about 4pin_connectors 2022-05-31 17:43:03 -04:00
Matt McWilliams c15c376a2f Start work on capper branch 2022-05-30 18:50:18 -04:00
Matt McWilliams 22bed4632b Update the notarization process for installing mcopy 2022-04-30 18:51:33 -04:00
Matt McWilliams 8b5faaa1a4 Update global package.lock 2022-04-30 16:03:33 -04:00
Matt McWilliams 81d94fd727 update package lock 2022-04-30 16:03:03 -04:00
Matt McWilliams bbfe6fc657 Add option to use Processing with a server as a capture method triggered by the camera.
Enter a url into the Settings panel in the Processing URL input box and select the radio button.
2022-04-30 15:58:17 -04:00
Matt McWilliams 467a5c06d6 Update the projector knob design 2022-04-30 15:52:04 -04:00
Matt McWilliams 9dce9fb1f2 Add an alternate script for notarizing builds 2021-05-01 12:20:19 -04:00
Matt McWilliams e1c8ba1320 Build_linux.sh already tags the installer with the correct version number 2021-04-13 18:39:22 -04:00
mmcwilliams 4ef318c55e Rename installer after build process. 2021-04-13 14:45:15 -04:00
mmcwilliams 7f7513809a Established an app signing process for macs using electron-packager. The process takes an enormous amount of time but has so far been running without throwing an exception and the signature is confirmed by codesign. 2021-04-13 14:17:12 -04:00
Matt McWilliams b3bb07454f Add a lamp housing knob 2021-04-05 10:40:50 -04:00
Matt McWilliams faad084b2b Hide "blank" buttons because they do not have a use case in the current app. 2021-04-01 22:21:27 -04:00
Matt McWilliams 3e528c23a5 Give the filmout position input element a fixed width value 2021-04-01 19:45:08 -04:00
Matt McWilliams 6fed941441 Filmout UI was breaking on linux (all of a sudden) 2021-04-01 19:40:29 -04:00
Matt McWilliams 6fee5a803c connector case box 2021-03-19 21:32:53 -04:00
Matt McWilliams 2861bc52fd intval2 connector firmware 2021-03-19 14:09:46 -04:00
Matt McWilliams 8c14a06b96 Removed naked console.log statements that were used to debug a serial issue. If needed they can be re-added to the actual log library. 2021-03-19 12:10:07 -04:00
Matt McWilliams 3e0ac3f0d0 Added return types to Filmout library and added return types to comments where needed. 2021-03-19 12:09:03 -04:00
Matt McWilliams 394fbe2323 Update cfg.json. Not sure why this lags?? 2021-03-18 11:55:18 -04:00
Matt McWilliams 11267796ba Update links to latest release 2021-03-18 11:35:55 -04:00
314 changed files with 3161371 additions and 12794 deletions

8
.gitignore vendored
View File

@ -3,4 +3,10 @@
*.Parent
node_modules
dist
dist
*.svd
*debug_custom.json
*debug.cfg
notes/mphd

9
.gitmodules vendored Normal file
View File

@ -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
View File

@ -1,87 +1,93 @@
# mcopy
An open platform for controlling small-gauge film optical printers (16mm, Super8, 8mm).
-------
1. <a href="#intro">Introduction</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>
3. <a href="#hardware">Hardware</a>
4. <a href="#why">Why?</a>
-------
## Introduction <a name="intro"></a>
The `mcopy` project is comprised of software and hardware for optical printers, built with re-purposed broken projectors.
#### Components
* Sequencer desktop app
* Scripting language, called `mscript`, for orchestrating complex sequences
* Arduino firmware for projectors, cameras, lights and existing printers
* 3D models of parts used for modifying projectors and printers
* Schematics for simple Arduino-based electronics
* Filmout feature for digitally transferring video and images to analog film
* Interoperability with the [intval3](https://github.com/sixteenmillimeter/intval3) intervalometer
## Downloads <a name="downloads"></a>
### Latest Installers
* [1.6.7](https://github.com/sixteenmillimeter/mcopy/releases/tag/1.6.7) for macOS and Linux (.deb)
### Older Versions
* [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
* [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
* [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)
* [1.0.3](https://github.com/sixteenmillimeter/mcopy/releases/tag/1.0.3) for macOS and Linux (.deb)
For Windows, you can [install from source](https://github.com/sixteenmillimeter/mcopy/tree/master/app#mcopy-desktop-app) for now.
## Usage <a name="usage"></a>
The software requires your hardware to be in place before the mcopy control app is useful.
![mcopy app](docs/mcopy.png?raw=true "mcopy app")
## Software <a name="software"></a>
The mcopy desktop app is an Electron-based project which can be built for Linux, Windows and macOS.
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).
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).
## Firmware <a name="firmware"></a>
This project contains Arduino formware for controlling:
* a projector
* a camera (see [intval2](https://github.com/sixteenmillimeter/intval2) for more info)
* a light
* a projector + a camera
* a projector + a light
* a camera + a light
* a camera + a projector + a light
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 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.
## Hardware <a name="hardware"></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.
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.
# mcopy
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)
* Github Mirror - [github.com/sixteenmillimeter/mcopy](https://github.com/sixteenmillimeter/mcopy)
* Gitlab Mirror - [gitlab.com/16mm/mcopy](https://gitlab.com/16mm/mcopy)
-------
1. <a href="#intro">Introduction</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>
3. <a href="#hardware">Hardware</a>
4. <a href="#why">Why?</a>
-------
## Introduction <a name="intro"></a>
The `mcopy` project is comprised of software and hardware for optical printers, built with re-purposed broken projectors.
#### Components
* Sequencer desktop app
* Scripting language, called `mscript`, for orchestrating complex sequences
* Arduino firmware for projectors, cameras, lights and existing printers
* 3D models of parts used for modifying projectors and printers
* Schematics for simple Arduino-based electronics
* Filmout feature for digitally transferring video and images to analog film
* Interoperability with the [intval3](https://github.com/sixteenmillimeter/intval3) intervalometer
## Downloads <a name="downloads"></a>
### Latest Installers
* [1.6.9](https://github.com/sixteenmillimeter/mcopy/releases/tag/1.6.9) for macOS, Linux (.deb) and Windows (.msi)
### Older Versions
* [1.6.7](https://github.com/sixteenmillimeter/mcopy/releases/tag/1.6.7) 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
* [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
* [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)
* [1.0.3](https://github.com/sixteenmillimeter/mcopy/releases/tag/1.0.3) for macOS and Linux (.deb)
For Windows, you can [install from source](https://github.com/sixteenmillimeter/mcopy/tree/master/app#mcopy-desktop-app) for now.
## Usage <a name="usage"></a>
The software requires your hardware to be in place before the mcopy control app is useful.
![mcopy app](docs/mcopy.png?raw=true "mcopy app")
## Software <a name="software"></a>
The mcopy desktop app is an Electron-based project which can be built for Linux, Windows and macOS.
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).
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).
## Firmware <a name="firmware"></a>
This project contains Arduino formware for controlling:
* a projector
* a camera (see [intval2](https://github.com/sixteenmillimeter/intval2) for more info)
* a light
* a projector + a camera
* a projector + a light
* a camera + a light
* a camera + a projector + a light
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 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.
## Hardware <a name="hardware"></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.
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.

5
app/.gitignore vendored
View File

@ -1,3 +1,6 @@
node_modules/*
logs/*
data/transfer*.json
data/transfer*.json
.appleId*
.applePwd*
.appleIdentity*

View File

@ -194,8 +194,8 @@ button:focus {
width: 66px;
height: 66px;
position: absolute;
top: 7px;
left: 7px;
top: 14px / 2;
left: 14px / 2;
}
.dial-wrapper input {
margin-top: 94px;
@ -210,10 +210,10 @@ button:focus {
top: 0;
bottom: 0;
overflow: hidden;
width: 40px;
width: 80px / 2;
}
.dial-container.dial-container1 {
left: 40px;
left: 80px / 2;
}
.dial-container.dial-container1 .dial-wedge {
transform: rotateZ(0deg);
@ -227,16 +227,16 @@ button:focus {
.dial-container.dial-container2 .dial-wedge {
transform: rotateZ(0deg);
border-radius: 80px 0 0 80px;
transform-origin: 40px 40px;
transform-origin: 80px/2 80px/2;
}
.dial-wedge {
height: 80px;
width: 40px;
width: 80px / 2;
}
.dial-marker {
border-radius: 50%;
height: 7px;
width: 7px;
height: 14px / 2;
width: 14px / 2;
position: absolute;
top: 0;
left: calc(50% - (14px * 2));
@ -367,6 +367,7 @@ button:focus {
float: right;
width: 90px;
margin-right: 60px;
height: 32px;
}
#seq_stats {
width: 40%;
@ -484,6 +485,9 @@ button:focus {
#sequence #projector_second_backward > div {
color: #bf2e39;
}
#sequence #black input[type=checkbox]:checked {
background: white;
}
#sequence input[type=checkbox] {
-webkit-appearance: none;
-moz-appearance: none;
@ -500,6 +504,10 @@ button:focus {
box-sizing: border-box;
cursor: pointer;
}
#sequence input[type=checkbox].disabled {
cursor: not-allowed;
border-color: #646464;
}
#sequence .L {
display: inline-block;
width: 35px;
@ -627,6 +635,11 @@ button:focus {
background: #AB1A25;
border-color: #AB1A25;
}
.cmd:active.capper,
.cmd.active.capper {
background: white;
color: #272b30;
}
.cmd:active i,
.cmd.active i {
color: #272b30;
@ -650,14 +663,44 @@ button:focus {
::-webkit-scrollbar-thumb:window-inactive {
background: rgba(0, 0, 0, 0.05);
}
#settings h4 {
margin-bottom: 1px;
}
#settings > div {
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 {
width: 360px;
}
#settings input[type=text],
#settings input[type=number],
#settings select {
display: block;
border-radius: 5px;
@ -672,33 +715,43 @@ button:focus {
padding: 6px 12px;
font-size: 21px;
min-width: 300px;
max-width: 300px;
}
#settings input[type=text] span,
#settings input[type=number] span,
#settings select span {
display: block;
font-size: 16px;
font-weight: 200;
}
#settings input[type=text]:active,
#settings input[type=number]:active,
#settings select:active,
#settings input[type=text] .active,
#settings input[type=number] .active,
#settings select .active {
background: #fff;
color: #272b30;
outline: none;
}
#settings input[type=text]:focus,
#settings input[type=number]:focus,
#settings select:focus {
outline: none;
}
#settings input[type=text].active,
#settings input[type=number].active,
#settings select.active {
border-color: #DAE035;
color: #DAE035;
}
#settings input[type=text] {
width: 200px;
}
#settings button {
margin-top: -1px;
margin-top: 0px;
float: right;
padding: 8px 16px 9px;
}
#settings input[type=radio] {
float: right;
@ -707,6 +760,17 @@ button:focus {
#settings .spacer {
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 {
background: #272b30 !important;
}
@ -839,20 +903,22 @@ button:focus {
#filmout_position_wrap input {
margin-right: 5px;
margin-left: 5px;
width: 308px !important;
box-sizing: border-box;
}
#filmout_position_wrap button,
#filmout_position_wrap input {
float: left;
}
#filmout_position_wrap > div {
width: 410px;
width: 425px;
margin: 0 auto;
}
#filmout_functions {
padding-top: 5px;
}
#filmout_functions > div {
width: 410px;
width: 425px;
margin: 0 auto;
}
#filmout_stats_video,
@ -874,6 +940,12 @@ button:focus {
#filmout_stats_monitor {
right: 5px;
}
.hide {
display: none;
}
.show {
display: block;
}
#screens {
overflow-x: hidden;
}
@ -1126,19 +1198,23 @@ button:focus {
float: right;
}
.cam2,
.proj2 {
.proj2,
.black {
display: none;
}
.cam2 > *,
.proj2 > * {
.proj2 > *,
.black > * {
visibility: hidden;
}
.cam2.on,
.proj2.on {
.proj2.on,
.black.on {
display: block;
}
.cam2.on > *,
.proj2.on > * {
.proj2.on > *,
.black.on > * {
visibility: visible;
}
#overlay {

View File

@ -1,5 +1,5 @@
{
"version": "1.6.8",
"version": "1.8.104",
"ext_port": 1111,
"profiles": {
"mcopy": {
@ -15,8 +15,8 @@
"momentary": 0
},
"black": {
"before": 0,
"after": 0
"before": 100,
"after": 100
},
"light": false
},
@ -178,7 +178,20 @@
"cameras": "4",
"camera_projectors_identifier": "5",
"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",
"takeup_forward": "D",
"takeup_backward": "F",
"error": "E",
"camera_exposure": "G",
"state": "H",
"home": "I",
"offset": "O"
}
}
}

View File

@ -13,6 +13,16 @@
body.meter {
background: rgb(117, 117, 117);
}
body.meter #img,
body.meter #can {
display: none;
}
body.image #can{
display: none;
}
body.image #img {
display: block;
}
#img {
position: absolute;
/*background-image: url(".../img/background.jpg");*/
@ -46,35 +56,48 @@
</canvas>
<script>
'use strict';
const { remote, ipcRenderer } = require('electron')
const { ipcRenderer } = require('electron')
const remote = require('@electron/remote')
let imgTmp;
function delay (ms) {
return new Promise((resolve) => {
return setTimeout(resolve, ms)
})
}
async function setImage (src) {
return new Promise(async (resolve, reject) => {
imgTmp = new Image()
let img = document.getElementById('img')
let body = document.querySelector('body')
if (body.classList.contains('meter')) {
body.classList.remove('meter')
}
body.className = ''
body.classList.add('image')
imgTmp.onload = function () {
img.style.backgroundImage = `url('${src}')`;
return resolve(src);
};
imgTmp.src = src;
});
img.style.backgroundImage = `url('${src}')`
return resolve(src)
}
imgTmp.src = src
})
}
function setBlank () {
let img = document.getElementById('img')
img.style.background = ''
img.style.backgroundUrl = ''
img.style.backgroundColor = 'black'
}
async function onMeter () {
console.log('meter')
const body = document.querySelector('body')
if (!body.classList.contains('meter')) {
body.classList.add('meter')
}
body.className = ''
body.classList.add('meter')
}
async function onFocus () {
console.log('focus')
const can = document.getElementById('can')
const dpr = window.devicePixelRatio || 1
const body = document.querySelector('body')
let ctx;
body.className = ''
if (!can.classList.contains('show')) {
can.classList.add('show')
}
@ -122,7 +145,9 @@
const can = document.getElementById('can')
const dpr = window.devicePixelRatio || 1
const screen = window.outerWidth / window.outerHeight
let ctx;
const body = document.querySelector('body')
let ctx
body.className = ''
if (!can.classList.contains('show')) {
can.classList.add('show')
}
@ -131,7 +156,7 @@
can.width = (window.innerHeight * arg.ratio) * dpr
can.height = window.innerHeight * dpr
} else {
can.width =window.innerWidth * dpr
can.width = window.innerWidth * dpr
can.height = (window.innerWidth / arg.ratio) * dpr
}
} else {
@ -145,7 +170,7 @@
can.style.width = `${window.innerHeight * arg.ratio}px`
can.style.height = `${window.innerHeight}px`
} else {
can.style.width = `${window.inneWidth}px`
can.style.width = `${window.innerWidth}px`
can.style.height = `${window.innerWidth / arg.ratio}px`
}
} else {
@ -208,18 +233,28 @@
}
async function onDigital (event, arg) {
if (arg.src) {
if (arg.exposure) {
setBlank()
await delay(10)
}
try {
await setImage(arg.src)
await setImage(arg.src)
} catch (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
}
async function onEscape (evt) {
let isEscape = false
let win
evt = evt || window.event
if ('key' in evt) {
@ -227,6 +262,7 @@
} else {
isEscape = (evt.keyCode == 27)
}
if (isEscape) {
win = remote.getCurrentWindow()
win.close()

12
app/entitlements.plist Normal file
View File

@ -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>

View File

@ -45,6 +45,8 @@
<div id="camera_second_backward" class="row cam2" y="2"></div>
<div id="projector_backward" class="row" y="1"></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="numbers" class="row"></div>
@ -60,6 +62,8 @@
<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="black"><span>BLANK </span><i class="fa fa-times"></i></div>
<div class="spacer"><span>LIGHT</span></div>
</div>
</div>
@ -144,20 +148,34 @@
<i class="fa fa-step-backward"></i>
</button>
</div>
<div>
<div class="hide">
<button id="cmd_black_forward" onclick="cmd.black_forward();" class="cmd fwd">
<i class="fa fa-times-circle"></i>
BLANK +1
<i class="fa fa-step-forward"></i>
</button>
</div>
<div>
<div class="hide">
<button id="cmd_black_backward" onclick="cmd.black_backward();" class="cmd bwd">
<i class="fa fa-times-circle"></i>
BLANK -1
<i class="fa fa-step-backward"></i>
</button>
</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>
@ -389,7 +407,7 @@
</div>
</div>
<div id="settings" class="screen">
<div>
<div class="left">
<div>
<h4>Devices</h4>
<select id="devices">
@ -419,6 +437,13 @@
<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();" />
</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>
<h4>Light</h4>
<select id="light_device">
@ -432,6 +457,19 @@
</select>
</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 id="overlay" onclick="gui.overlay(false);gui.spinner(false);"></div>

View File

@ -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});
const mcopy = {};
const { remote, ipcRenderer } = require('electron');
const dialog = require('electron').remote.dialog;
const remote = require('@electron/remote');
const { ipcRenderer } = require('electron');
const { dialog } = remote;
const notifier = require('node-notifier');
const fs = require('fs');
const uuid = require('uuid').v4;
@ -2495,8 +2496,11 @@ const cmd = require('./lib/ui/cmd.js');
const devices = require('./lib/ui/devices.js');
const filmout = require('./lib/ui/filmout.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 { delay } = require('./lib/delay');
const alertObj = require('./lib/ui/alert.js');
let log;
@ -2514,6 +2518,7 @@ async function init () {
log = await require('log')({})
nav.init();
gui.init();
grid.init();
mse.mscript.init();
mse.console.init();
@ -2524,4 +2529,7 @@ async function init () {
proj.init();
cam.init();
seq.init();
capper.init();
alertObj.init();
timing.init();
};

View File

@ -10,6 +10,13 @@
@import "./mscript.less";
@import "./filmout.less";
.hide {
display: none;
}
.show {
display: block;
}
#screens{
overflow-x: hidden;
}
@ -168,7 +175,8 @@
}
.cam2,
.proj2{
.proj2,
.black{
display : none;
> * {
visibility: hidden;

View File

@ -42,6 +42,10 @@
background: @BACKWARD;
border-color: @BACKWARD;
}
&.capper{
background: white;
color: @BG;
}
i{
color: @BG;
}

View File

@ -75,12 +75,14 @@
input{
margin-right: 5px;
margin-left: 5px;
width: 308px !important;
box-sizing: border-box;
}
button, input{
float: left;
}
> div{
width: 410px;
width: 425px;
margin: 0 auto;
}
}
@ -88,7 +90,7 @@
#filmout_functions{
padding-top: 5px;
> div{
width: 410px;
width: 425px;
margin: 0 auto;
}
}

View File

@ -28,6 +28,7 @@
float: right;
width: 90px;
margin-right: 60px;
height: 32px;
}
}
#seq_stats{
@ -126,6 +127,13 @@
color: @BACKWARD + @SECOND;
}
}
#black{
input[type=checkbox]{
&:checked{
background: white;
}
}
}
input[type=checkbox]{
-webkit-appearance: none;
-moz-appearance: none;
@ -141,6 +149,10 @@
display: inline-block;
box-sizing: border-box;
cursor: pointer;
&.disabled{
cursor: not-allowed;
border-color: rgb(100, 100, 100);
}
}
.L{
display: inline-block;

View File

@ -1,25 +1,61 @@
#settings{
h4{
margin-bottom: 1px;
}
> div{
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{
width: 360px;
}
input[type=text], select{
input[type=text],
input[type=number],
select{
.button();
display: inline-block;
padding: 6px 12px;
font-size: 21px;
min-width: 300px;
max-width: 300px;
&.active{
border-color: @SELECTED;
color: @SELECTED;
}
}
input[type=text]{
width: 200px;
}
button{
margin-top: -1px;
float: right;
margin-top: 0px;
float: right;
padding: 8px 16px 9px;
}
input[type=radio]{
float: right;
@ -28,4 +64,15 @@
.spacer{
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;
}
}

1
app/lib/alert/index.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export {};

58
app/lib/alert/index.js Normal file
View File

@ -0,0 +1,58 @@
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
/* class representing alert functionality */
class Alert {
constructor(ui) {
this.id = 'alert';
this.cb = null;
this.ui = ui;
this.init();
}
/**
*
**/
async init() {
const Log = require('log');
this.log = await Log({ label: this.id });
this.ipc = require('electron').ipcMain;
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));
}
}
module.exports = function (ui) {
return new Alert(ui);
};
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/alert/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAIb,4CAA4C;AAE5C,MAAM,KAAK;IAOV,YAAc,EAAQ;QAJd,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,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAA;QAC1B,IAAI,CAAC,GAAG,GAAG,MAAM,GAAG,CAAC,EAAE,KAAK,EAAG,IAAI,CAAC,EAAE,EAAE,CAAC,CAAA;QACzC,IAAI,C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AE,CAAC,CAAC;YACpB,CAAC,CAAA;QACF,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACf,CAAC;CACD;AAED,MAAM,CAAC,OAAO,GAAG,UAAU,EAAQ;IAClC,OAAO,IAAI,KAAK,CAAC,EAAE,CAAC,CAAC;AACtB,CAAC,CAAA"}

1
app/lib/arduino/index.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export {};

View File

@ -1,11 +1,23 @@
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
/**
* 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
*
**/
//import Log = require('log');
const delay_1 = require("delay");
const SerialPort = require('serialport');
const Readline = SerialPort.parsers.Readline;
const { SerialPort } = require('serialport');
const { ReadlineParser } = require('@serialport/parser-readline');
const exec = require('child_process').exec;
const parser = new Readline('');
const parser = new ReadlineParser({ delimiter: '\r\n' });
const newlineRe = new RegExp('\n', 'g');
const returnRe = new RegExp('\r', 'g');
let eventEmitter;
@ -29,22 +41,26 @@ class Arduino {
this.path = {};
this.known = KNOWN;
this.alias = {};
this.serial = { connect: {}, projector: {}, camera: {}, light: {} };
this.serial = {};
this.hasState = {};
this.baud = 57600;
this.queue = {};
this.timer = 0;
this.lock = false;
this.locks = {};
this.stateStr = {};
this.errorState = errorState;
this.init();
}
async init() {
const Log = require('log');
this.log = await Log({ label: 'arduino' });
this.keys = Object.keys(cfg.arduino.cmd);
this.values = this.keys.map(key => cfg.arduino.cmd[key]);
}
/**
* Enumerate all connected devices that might be Arduinos
*
* @async
* @returns {Promise} Resolves after enumerating
**/
async enumerate() {
@ -85,63 +101,146 @@ class Arduino {
/**
* 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
*
* @async
* @returns {Promise} Resolves after sending
**/
async sendAsync(device, cmd) {
return new Promise((resolve, reject) => {
this.log.info(`sendAsync ${cmd} -> ${device}`);
this.queue[cmd] = (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) {
//console.error(err)
//this.log.error(err)
return reject(err);
}
//
});
});
}
async send(serial, cmd) {
const device = this.alias[serial];
let results;
console.log(`${cmd} -> ${serial}`);
if (this.locks[serial]) {
return false;
/**
* 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.
**/
async send(device, cmd) {
const serial = this.alias[device];
let ms;
this.log.info(`send ${cmd} -> ${device}`);
if (this.isLocked(serial)) {
this.log.warn(`send Serial ${serial} is locked`);
return null;
}
this.timer = new Date().getTime();
this.locks[serial] = true;
await delay_1.delay(cfg.arduino.serialDelay);
this.lock(serial);
await (0, delay_1.delay)(cfg.arduino.serialDelay);
try {
results = await this.sendAsync(device, cmd);
ms = await this.sendAsync(device, cmd);
}
catch (e) {
return console.error(e);
return this.log.error(e);
}
this.locks[serial] = false;
this.unlock(serial);
await 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.
* 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.
**/
async sendString(device, str) {
let writeSuccess;
await delay_1.delay(cfg.arduino.serialDelay);
if (typeof this.serial[device].fake !== 'undefined'
&& this.serial[device].fake) {
return this.serial[device].string(str);
await (0, delay_1.delay)(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 {
this.log.info(`sendString ${str} -> ${device}`);
try {
writeSuccess = await this.writeAsync(device, str);
}
catch (e) {
return console.error(e);
return this.log.error(e);
}
this.unlock(this.alias[device]);
return writeSuccess;
}
}
/**
*
**/
async stateAsync(device, confirm = false) {
const cmd = 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)(cfg.arduino.serialDelay);
try {
results = await this.stateAsync(device, confirm);
}
catch (e) {
return this.log.error(e);
}
this.unlock(serial);
await eventEmitter.emit('arduino_state', cfg.arduino.cmd.state);
return results;
}
/**
* Send a string to an Arduino using async/await
*
@ -152,7 +251,7 @@ class Arduino {
**/
async writeAsync(device, str) {
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) {
return reject(err);
}
@ -160,59 +259,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) {
const end = new Date().getTime();
const ms = end - this.timer;
let complete;
console.log(`${serial} -> ${data}`);
//this.log.info(`end ${serial} -> ${data}`)
if (this.queue[data] !== undefined) {
this.locks[serial] = false;
this.unlock(serial);
complete = this.queue[data](ms); //execute callback
eventEmitter.emit('arduino_end', data);
delete this.queue[data];
}
else if (data === 'E') {
else if (data[0] === cfg.arduino.cmd.state) {
//this.log.info(`end serial -> ${serial}`)
this.unlock(serial);
complete = this.queue[cfg.arduino.cmd.state](data);
eventEmitter.emit('arduino_end', data);
delete this.queue[cfg.arduino.cmd.state];
return data;
}
else if (data[0] === cfg.arduino.cmd.error) {
this.log.error(`Received error from device ${serial}`);
this.unlock(serial);
this.error(serial, data);
//error state
//stop sequence
//throw error in ui
}
else {
//console.log('Received stray "' + data + '"'); //silent to user
this.log.info('Received stray "' + data + '"'); //silent to user
}
return ms;
}
aliasSerial(serial, device) {
//this.log.info(`Making "${serial}" an alias of ${device}`);
this.alias[serial] = device;
error(serial, data) {
this.log.error("ERROR", data);
}
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) => {
let connectSuccess;
this.path[serial] = device;
this.alias[serial] = device;
this.serial[device] = new SerialPort(this.path[serial], {
this.path[device] = serial;
this.aliasSerial(device, serial);
this.serial[serial] = new SerialPort({
path: serial,
autoOpen: false,
baudRate: cfg.arduino.baud,
parser: parser
parser
});
this.locks[device] = false;
this.unlock(serial);
try {
connectSuccess = await this.openArduino(device);
}
catch (e) {
console.error('failed to open: ' + e);
this.log.error(`Failed to open ${device} @ ${serial}: ` + 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) {
this.serial[device].on('data', async (data) => {
this.serial[this.alias[device]].on('data', async (data) => {
let d = data.toString('utf8');
d = d.replace(newlineRe, '').replace(returnRe, '');
return this.end(serial, d);
});
}
else {
this.serial[device].on('data', async (data) => {
this.serial[this.alias[device]].on('data', async (data) => {
let d = data.toString('utf8');
d = d.replace(newlineRe, '').replace(returnRe, '');
return await this.confirmEnd(d);
@ -221,34 +365,35 @@ class Arduino {
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) {
//console.dir(data)
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) {
if (this.values.indexOf(data) !== -1 && typeof this.confirmExec === 'function') {
this.confirmExec(null, data);
this.confirmExec = {};
this.unlock(this.alias['connect']);
}
else if (data[0] === cfg.arduino.cmd.state) {
this.queue[cfg.arduino.cmd.state](data);
delete this.queue[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() {
return new Promise(async (resolve, reject) => {
const device = this.alias['connect'];
const device = 'connect';
let writeSuccess;
this.confirmExec = function (err, data) {
if (data === cfg.arduino.cmd.connect) {
@ -258,7 +403,7 @@ class Arduino {
return reject('Wrong data returned');
}
};
await delay_1.delay(cfg.arduino.serialDelay);
await (0, delay_1.delay)(cfg.arduino.serialDelay);
try {
writeSuccess = await this.sendAsync(device, cfg.arduino.cmd.connect);
}
@ -268,9 +413,17 @@ class Arduino {
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() {
return new Promise(async (resolve, reject) => {
const device = this.alias['connect'];
const device = 'connect';
let writeSuccess;
let type;
this.confirmExec = function (err, data) {
@ -313,19 +466,39 @@ class Arduino {
else if (data === cfg.arduino.cmd.cameras_projectors_identifier) {
type = 'camera,camera_second,projector,projector_second';
}
else if (data === cfg.arduino.cmd.capper_identifier) {
type = 'capper';
}
else if (data === cfg.arduino.cmd.camera_capper_identifier) {
type = 'camera,capper';
}
else if (data === cfg.arduino.cmd.camera_capper_projector_identifier) {
type = 'camera,capper,projector';
}
else if (data === cfg.arduino.cmd.camera_capper_projectors_identifier) {
type = 'camera,capper,projector,projector_second';
}
return resolve(type);
};
await delay_1.delay(cfg.arduino.serialDelay);
await (0, delay_1.delay)(cfg.arduino.serialDelay);
try {
writeSuccess = await this.sendAsync(device, cfg.arduino.cmd.mcopy_identifier);
this.log.info(writeSuccess);
}
catch (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() {
const device = this.alias['connect'];
const device = 'connect';
let closeSuccess;
try {
closeSuccess = await this.closeArduino(device);
@ -335,21 +508,30 @@ class Arduino {
}
return closeSuccess;
}
;
async fakeConnect(serial) {
const device = '/dev/fake';
this.alias[serial] = device;
this.serial[device] = {
/**
* 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.
**/
async fakeConnect(device) {
const serial = '/dev/fake';
this.aliasSerial(device, serial);
this.serial[serial] = {
write: async function (cmd, cb) {
const t = {
c: cfg.arduino.cam.time + cfg.arduino.cam.delay,
p: cfg.arduino.proj.time + cfg.arduino.proj.delay
p: cfg.arduino.proj.time + cfg.arduino.proj.delay,
A: 180,
B: 180
};
let timeout = t[cmd];
if (typeof timeout === 'undefined')
timeout = 10;
arduino.timer = +new Date();
await delay_1.delay(timeout);
await (0, delay_1.delay)(timeout);
arduino.end(serial, cmd);
return cb();
},
@ -359,7 +541,7 @@ class Arduino {
},
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;
}
/**
@ -371,7 +553,7 @@ class Arduino {
**/
async openArduino(device) {
return new Promise((resolve, reject) => {
return this.serial[device].open((err) => {
return this.serial[this.alias[device]].open((err) => {
if (err) {
return reject(err);
}
@ -388,7 +570,7 @@ class Arduino {
**/
async closeArduino(device) {
return new Promise((resolve, reject) => {
return this.serial[device].close((err) => {
return this.serial[this.alias[device]].close((err) => {
if (err) {
return reject(err);
}
@ -396,6 +578,17 @@ 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) {
module.exports = function (c, ee, errorState) {

File diff suppressed because one or more lines are too long

1
app/lib/cam/index.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export {};

View File

@ -1,6 +1,8 @@
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
const intval_1 = require("intval");
const processing_1 = require("processing");
const delay_1 = require("delay");
/** class representing camera functions **/
class Camera {
/**
@ -9,10 +11,12 @@ class Camera {
constructor(arduino, cfg, ui, filmout, second = false) {
this.state = {
pos: 0,
dir: true
dir: true,
capepr: false
};
this.arduino = null;
this.intval = null;
this.processing = null;
this.id = 'camera';
this.arduino = arduino;
this.cfg = cfg;
@ -37,6 +41,7 @@ class Camera {
listen() {
this.ipc.on(this.id, this.listener.bind(this));
this.ipc.on('intval', this.connectIntval.bind(this));
this.ipc.on('processing', this.connectProcessing.bind(this));
}
/**
*
@ -51,7 +56,15 @@ class Camera {
cmd = this.cfg.arduino.cmd[`${this.id}_backward`];
}
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 {
ms = await this.intval.setDir(dir);
}
@ -69,6 +82,27 @@ class Camera {
}
return await this.end(cmd, id, ms);
}
/**
*
**/
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);
}
/**
*
**/
@ -78,7 +112,15 @@ class Camera {
if (this.filmout.state.enabled) {
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 {
ms = await this.intval.move();
}
@ -116,11 +158,55 @@ class Camera {
/**
*
**/
exposure(exposure, id) {
let cmd = 'E';
this.intval.setExposure(this.id, exposure, (ms) => {
this.end(cmd, id, ms);
});
async exposure(exposure, id) {
const cmd = this.cfg.arduino.cmd.camera_exposure;
const str = `${exposure}`;
const started = +new Date();
let ms;
let confirmState;
let parts;
let confirmExposure;
if (this.intval) {
return this.intval.setExposure(this.id, 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 +215,7 @@ class Camera {
return new Promise((resolve, reject) => {
if (arg.connect) {
this.intval = new intval_1.Intval(arg.url);
this.processing = null;
this.intval.connect((err, ms, state) => {
if (err) {
this.ui.send('intval', { connected: false });
@ -148,6 +235,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);
});
}
/**
*
**/
@ -171,6 +269,22 @@ class Camera {
else if (typeof arg.val !== 'undefined') {
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;
}
/**
@ -213,9 +327,13 @@ class Camera {
else if (cmd === this.cfg.arduino.cmd.camerass) {
message += 'Cameras both MOVED 1 frame each';
}
else if (cmd === this.cfg.arduino.camera_exposure) {
message += 'Camera set exposure';
}
message += ` ${ms}ms`;
this.log.info(message);
this.ui.send(this.id, { cmd: cmd, id: id, ms: ms });
return ms;
}
}
module.exports = function (arduino, cfg, ui, filmout, second) {

File diff suppressed because one or more lines are too long

1
app/lib/capper/index.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export {};

89
app/lib/capper/index.js Normal file
View File

@ -0,0 +1,89 @@
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
/** class representing capper functions **/
class Capper {
/**
*
**/
constructor(arduino, cfg, ui, filmout) {
this.state = {
capper: false
};
this.arduino = null;
this.id = 'capper';
this.arduino = arduino;
this.cfg = cfg;
this.ui = ui;
this.filmout = filmout;
this.init();
}
/**
*
**/
async init() {
const Log = require('log');
this.log = await Log({ label: this.id });
this.ipc = require('electron').ipcMain;
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);
this.ui.send(this.id, { cmd: cmd, id: id, ms: ms });
}
}
module.exports = function (arduino, cfg, ui, filmout) {
return new Capper(arduino, cfg, ui, filmout);
};
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/capper/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAMb,2CAA2C;AAE3C,MAAM,MAAM;IAWX;;QAEI;IACJ,YAAa,OAAiB,EAAE,GAAS,EAAE,EAAQ,EAAE,OAAa;QAb1D,UAAK,GAAS;YACrB,MAAM,EAAG,KAAK;SACd,CAAC;QACM,YAAO,GAAa,IAAI,CAAC;QAMzB,OAAE,GAAY,QAAQ,CAAC;QAK9B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,IAAI,EAAE,CAAC;IACb,CAAC;IAED;;QAEI;IACI,KAAK,CAAC,IAAI;QACjB,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;QAC3B,IAAI,CAAC,GAAG,GAAG,MAAM,GAAG,CAAC,EAAE,KAAK,EAAG,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;QAC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,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;IACI,KAAK,CAAC,GAAG,CAAE,GAAY,EAAE,EAAW,EAAE,EAAW;QACxD,IAAI,OAAO,GAAG,EAAE,CAAC;QAEjB,IAAI,GAAG,KAAK,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE;YAC3C,OAAO,GAAG,kBAAkB,CAAC;SAC7B;aAAM,IAAI,GAAG,KAAK,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE;YACnD,OAAO,GAAG,mBAAmB,CAAC;SAC9B;QAED,OAAO,IAAI,IAAI,EAAE,IAAI,CAAA;QAErB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,EAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAG,EAAE,EAAE,EAAE,EAAE,EAAE,EAAC,CAAC,CAAC;IACpD,CAAC;CACD;AAED,MAAM,CAAC,OAAO,GAAG,UAAU,OAAiB,EAAE,GAAS,EAAE,EAAQ,EAAE,OAAY;IAC9E,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC,CAAA"}

287
app/lib/client/index.js Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
app/lib/cmd/index.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export {};

View File

@ -11,18 +11,24 @@ class Commands {
* @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} 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.cfg = cfg;
this.proj = proj;
this.cam = cam;
this.light = light;
if (cam2)
this.alertObj = alert;
if (cam2 !== null)
this.cam2 = cam2;
if (proj2)
if (proj2 !== null)
this.proj2 = proj2;
if (capper !== null)
this.capper = capper;
this.ipc = require('electron').ipcMain;
}
/**
@ -34,10 +40,10 @@ class Commands {
let ms;
try {
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 delay_1.delay(this.cfg.arduino.serialDelay);
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
ms = await this.proj.move();
}
catch (err) {
@ -54,10 +60,10 @@ class Commands {
let ms;
try {
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 delay_1.delay(this.cfg.arduino.serialDelay);
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
ms = await this.proj.move();
}
catch (err) {
@ -68,24 +74,25 @@ class Commands {
/**
* 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
**/
async camera_forward(rgb = [255, 255, 255]) {
const id = uuid_1.v4();
async camera_forward() {
const id = (0, uuid_1.v4)();
const off = [0, 0, 0];
let rgb = [255, 255, 255];
let ms;
try {
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 delay_1.delay(this.cfg.arduino.serialDelay);
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
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();
await delay_1.delay(this.cfg.arduino.serialDelay);
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
await this.light.set(off, id);
}
catch (err) {
@ -99,20 +106,27 @@ class Commands {
* @returns {integer} Length of action in ms
**/
async black_forward() {
const id = uuid_1.v4();
const id = (0, uuid_1.v4)();
const off = [0, 0, 0];
let ms;
let ms = 0;
try {
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 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 delay_1.delay(this.cfg.arduino.serialDelay);
ms = await this.cam.move();
await delay_1.delay(this.cfg.arduino.serialDelay);
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
ms += await this.cam.move();
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
await this.light.set(off, id);
if (this.capper) {
ms += await this.capper.capper(false, id);
}
}
catch (err) {
throw err;
@ -122,24 +136,25 @@ class Commands {
/**
* 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
**/
async camera_backward(rgb = [255, 255, 255]) {
const id = uuid_1.v4();
async camera_backward() {
const id = (0, uuid_1.v4)();
const off = [0, 0, 0];
let rgb = [255, 255, 255];
let ms;
try {
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 delay_1.delay(this.cfg.arduino.serialDelay);
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
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();
await delay_1.delay(this.cfg.arduino.serialDelay);
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
await this.light.set(off, id);
}
catch (err) {
@ -153,20 +168,26 @@ class Commands {
* @returns {integer} Length of action in ms
**/
async black_backward() {
const id = uuid_1.v4();
const id = (0, uuid_1.v4)();
const off = [0, 0, 0];
let ms;
let ms = 0;
try {
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 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 delay_1.delay(this.cfg.arduino.serialDelay);
ms = await this.cam.move();
await delay_1.delay(this.cfg.arduino.serialDelay);
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
ms += await this.cam.move();
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
await this.light.set(off, id);
if (this.capper) {
ms += await this.capper.capper(false, id);
}
}
catch (err) {
throw err;
@ -176,24 +197,25 @@ class Commands {
/**
* 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
**/
async camera_second_forward(rgb = [255, 255, 255]) {
const id = uuid_1.v4();
async camera_second_forward() {
const id = (0, uuid_1.v4)();
const off = [0, 0, 0];
let rgb = [255, 255, 255];
let ms;
try {
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 delay_1.delay(this.cfg.arduino.serialDelay);
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
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();
await delay_1.delay(this.cfg.arduino.serialDelay);
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
await this.light.set(off, id);
}
catch (err) {
@ -204,24 +226,25 @@ class Commands {
/**
* 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
**/
async camera_second_backward(rgb = [255, 255, 255]) {
const id = uuid_1.v4();
async camera_second_backward() {
const id = (0, uuid_1.v4)();
const off = [0, 0, 0];
let rgb = [255, 255, 255];
let ms;
try {
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 delay_1.delay(this.cfg.arduino.serialDelay);
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
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();
await delay_1.delay(this.cfg.arduino.serialDelay);
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
await this.light.set(off, id);
}
catch (err) {
@ -232,27 +255,28 @@ class Commands {
/**
* 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
**/
async cameras_forward(rgb = [255, 255, 255]) {
const id = uuid_1.v4();
async cameras_forward() {
const id = (0, uuid_1.v4)();
const off = [0, 0, 0];
let rgb = [255, 255, 255];
let both;
let ms;
try {
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);
}
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 delay_1.delay(this.cfg.arduino.serialDelay);
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
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) {
ms = await this.cam.both();
}
@ -262,7 +286,7 @@ class Commands {
both = [await this.cam.move, await this.cam2.move];
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);
}
catch (err) {
@ -273,27 +297,28 @@ class Commands {
/**
* 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
**/
async cameras_backward(rgb = [255, 255, 255]) {
const id = uuid_1.v4();
async cameras_backward() {
const id = (0, uuid_1.v4)();
const off = [0, 0, 0];
let rgb = [255, 255, 255];
let both;
let ms;
try {
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);
}
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 delay_1.delay(this.cfg.arduino.serialDelay);
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
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) {
ms = await this.cam.both();
}
@ -303,7 +328,7 @@ class Commands {
both = [await this.cam.move, await this.cam2.move];
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);
}
catch (err) {
@ -314,27 +339,28 @@ class Commands {
/**
* 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
**/
async camera_forward_camera_second_backward(rgb = [255, 255, 255]) {
const id = uuid_1.v4();
async camera_forward_camera_second_backward() {
const id = (0, uuid_1.v4)();
const off = [0, 0, 0];
let rgb = [255, 255, 255];
let both;
let ms;
try {
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);
}
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 delay_1.delay(this.cfg.arduino.serialDelay);
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
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) {
ms = await this.cam.both();
}
@ -344,7 +370,7 @@ class Commands {
both = [await this.cam.move, await this.cam2.move];
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);
}
catch (err) {
@ -355,27 +381,28 @@ class Commands {
/**
* 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
**/
async camera_backward_camera_second_forward(rgb = [255, 255, 255]) {
const id = uuid_1.v4();
async camera_backward_camera_second_forward() {
const id = (0, uuid_1.v4)();
const off = [0, 0, 0];
let rgb = [255, 255, 255];
let both;
let ms;
try {
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);
}
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 delay_1.delay(this.cfg.arduino.serialDelay);
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
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) {
ms = await this.cam.both();
}
@ -385,7 +412,7 @@ class Commands {
both = [await this.cam.move, await this.proj2.move];
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);
}
catch (err) {
@ -402,10 +429,10 @@ class Commands {
let ms;
try {
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 delay_1.delay(this.cfg.arduino.serialDelay);
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
ms = await this.proj2.move();
}
catch (err) {
@ -422,10 +449,10 @@ class Commands {
let ms;
try {
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 delay_1.delay(this.cfg.arduino.serialDelay);
await (0, delay_1.delay)(this.cfg.arduino.serialDelay);
ms = await this.proj2.move();
}
catch (err) {
@ -443,14 +470,14 @@ class Commands {
let ms;
try {
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);
}
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 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) {
ms = await this.proj.both();
}
@ -476,14 +503,14 @@ class Commands {
let ms;
try {
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);
}
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 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) {
ms = await this.proj.both();
@ -511,14 +538,14 @@ class Commands {
let ms;
try {
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);
}
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 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) {
ms = await this.proj.both();
@ -546,14 +573,14 @@ class Commands {
let ms;
try {
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);
}
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 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) {
ms = await this.proj.both();
@ -570,8 +597,48 @@ class Commands {
}
return ms;
}
/**
* Throws an alert to pause a sequence
*
* @returns {integer} Length of action in ms
**/
async alert(cmd) {
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) {
let ms;
try {
ms = await (0, delay_1.delay)(cmd.light * 1000); //delay is in seconds
}
catch (err) {
throw err;
}
return ms;
}
async camera_exposure(cmd) {
let ms;
try {
ms = await this.cam.exposure(cmd.light);
}
catch (err) {
throw err;
}
return ms;
}
}
module.exports = function (cfg, proj, cam, light, cam2, proj2) {
return new Commands(cfg, proj, cam, light, cam2, proj2);
module.exports = function (cfg, proj, cam, light, alert, cam2, proj2, capper) {
return new Commands(cfg, proj, cam, light, alert, cam2, proj2, capper);
};
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

8
app/lib/delay/index.d.ts vendored Normal file
View File

@ -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<unknown>;

View File

@ -1,4 +1,6 @@
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
exports.delay = void 0;
/**
* Delay in an async/await function
*
@ -11,5 +13,6 @@ function delay(ms) {
return setTimeout(resolve, ms);
});
}
module.exports.delay = delay;
exports.delay = delay;
module.exports = { delay };
//# sourceMappingURL=index.js.map

View File

@ -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,OAAO,EAAE,EAAE,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AACJ,CAAC;AAJD,sBAIC;AAED,MAAM,CAAC,OAAO,GAAG,EAAE,KAAK,EAAE,CAAC"}

1
app/lib/devices/index.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export {};

View File

@ -34,49 +34,57 @@ class Devices {
* Listen to the "profile" channel for messages from the UI.
**/
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
* local settings object.
**/
listener(event, arg) {
this.log.info(`Saving profile ${arg.profile}`, 'SETTINGS', false, false);
this.settings.update('profile', arg.profile);
this.settings.save();
async listener(event, arg) {
if (typeof arg.profile !== 'undefined') {
this.log.info(`Saving profile ${arg.profile}`, 'SETTINGS', false, false);
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() {
let devices;
let serials;
try {
devices = await this.arduino.enumerate();
serials = await this.arduino.enumerate();
}
catch (err) {
this.log.warn(err, 'SERIAL', false, true);
await delay_1.delay(1000);
await (0, delay_1.delay)(1000);
return this.all([]);
}
this.log.info(`Found ${devices.length} USB devices`, 'SERIAL', true, true);
devices = this.favor(devices);
return await this.all(devices);
this.log.info(`Found ${serials.length} USB devices`, 'SERIAL', true, true);
serials = this.favor(serials);
return await this.all(serials);
}
/**
*
**/
favor(devices) {
favor(serials) {
const past = this.settings.state.devices.filter((device) => {
if (device.arduino) {
if (device.serial) {
return device;
}
}).map((device) => {
return device.arduino;
return device.serial;
});
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) {
return 1;
}
@ -85,23 +93,24 @@ class Devices {
}
return 0;
});
return devices;
return serials;
}
/**
*
**/
async distinguish(device) {
async distinguish(serial) {
let connectSuccess;
let verifySuccess;
let type;
let device;
//this.log.info(`distinguish() ${serial}`)
try {
connectSuccess = await this.arduino.connect('connect', device, true);
connectSuccess = await this.arduino.connect('connect', serial, true);
}
catch (err) {
this.log.error('Error connecting', err);
return null;
}
await delay_1.delay(2000);
await (0, delay_1.delay)(2000);
try {
verifySuccess = await this.arduino.verify();
}
@ -109,18 +118,25 @@ class Devices {
this.log.error('Error verifying device', err);
return null;
}
this.log.info(`Verified ${device} as mcopy device`, 'SERIAL', true, true);
await delay_1.delay(1000);
this.log.info(`Verified ${serial} as mcopy device`, 'SERIAL', true, true);
await (0, delay_1.delay)(1000);
try {
type = await this.arduino.distinguish();
device = await this.arduino.distinguish();
}
catch (err) {
this.log.error('Error distinguishing device', err);
return null;
}
this.remember('arduino', device, type);
this.log.info(`Determined ${device} to be ${type}`, 'SERIAL', true, true);
return type;
this.remember(device, serial, 'arduino');
this.log.info(`Determined ${device} to be ${device}`, 'SERIAL', true, true);
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');
}
catch (err) {
console.error(err);
this.log.error(`Error connecting to fake PRONECTOR device`, 'SERIAL', true, true);
this.log.error(`Error connecting to fake PROjECTOR device`, 'SERIAL', true, true);
this.log.error(err);
return false;
}
this.log.info('Connected to fake PROJECTOR device', 'SERIAL', true, true);
return true;
}
/**
*
**/
*
**/
async fakeCamera() {
this.connected.camera = '/dev/fake';
try {
await this.arduino.fakeConnect('camera');
}
catch (err) {
console.error(err);
this.log.error(`Error connecting to fake CAMERA device`, 'SERIAL', true, true);
this.log.error(err);
return false;
}
this.log.info('Connected to fake CAMERA device', 'SERIAL', true, true);
@ -163,17 +179,33 @@ class Devices {
await this.arduino.fakeConnect('light');
}
catch (err) {
console.error(err);
this.log.error(`Error connecting to fake LIGHT device`, 'SERIAL', true, true);
this.log.error(err);
return false;
}
this.log.info('Connected to fake LIGHT device', 'SERIAL', true, 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 connectSuccess;
try {
@ -183,10 +215,10 @@ class Devices {
this.log.error('Error closing arduino connection', err);
return false;
}
if (type === 'projector') {
this.connected.projector = device;
if (device === 'projector') {
this.connected.projector = serial;
try {
connectSuccess = await this.arduino.connect('projector', device, false);
connectSuccess = await this.arduino.connect('projector', serial, false);
}
catch (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);
}
else if (type === 'camera') {
this.connected.camera = device;
else if (device === 'camera') {
this.connected.camera = serial;
try {
connectSuccess = await this.arduino.connect('camera', device, false);
connectSuccess = await this.arduino.connect('camera', serial, false);
}
catch (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);
}
else if (type === 'light') {
this.connected.light = device;
else if (device === 'light') {
this.connected.light = serial;
try {
connectSuccess = await this.arduino.connect('light', device, false);
connectSuccess = await this.arduino.connect('light', serial, false);
}
catch (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);
}
else if (type === 'projector,light') {
this.connected.projector = device;
this.connected.light = device;
this.arduino.aliasSerial('light', device);
else if (device === 'projector,light') {
this.connected.projector = serial;
this.connected.light = serial;
this.arduino.aliasSerial('light', serial);
try {
connectSuccess = await this.arduino.connect('projector', device, false);
connectSuccess = await this.arduino.connect('projector', serial, false);
}
catch (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);
}
else if (type === 'projector,camera,light') {
this.connected.projector = device;
this.connected.camera = device;
this.connected.light = device;
this.arduino.aliasSerial('camera', device);
this.arduino.aliasSerial('light', device);
else if (device === 'projector,camera,light') {
this.connected.projector = serial;
this.connected.camera = serial;
this.connected.light = serial;
this.arduino.aliasSerial('camera', serial);
this.arduino.aliasSerial('light', serial);
try {
connectSuccess = await this.arduino.connect('projector', device, false);
connectSuccess = await this.arduino.connect('projector', serial, false);
}
catch (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);
}
else if (type === 'projector,camera') {
this.connected.projector = device;
this.connected.camera = device;
this.arduino.aliasSerial('camera', device);
else if (device === 'projector,camera') {
this.connected.projector = serial;
this.connected.camera = serial;
this.arduino.aliasSerial('camera', serial);
try {
connectSuccess = await this.arduino.connect('projector', device, false);
connectSuccess = await this.arduino.connect('projector', serial, false);
}
catch (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);
}
else if (type === 'projector_second') {
this.connected.projector_second = device;
else if (device === 'projector_second') {
this.connected.projector_second = serial;
try {
connectSuccess = await this.arduino.connect('projector_second', device, false);
connectSuccess = await this.arduino.connect('projector_second', serial, false);
}
catch (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);
}
else if (type === 'projector,projector_second') {
this.connected.projector = device;
this.connected.projector_second = device;
this.arduino.aliasSerial('projector_second', device);
else if (device === 'projector,projector_second') {
this.connected.projector = serial;
this.connected.projector_second = serial;
this.arduino.aliasSerial('projector_second', serial);
try {
connectSuccess = await this.arduino.connect('projector', device, false);
connectSuccess = await this.arduino.connect('projector', serial, false);
}
catch (err) {
this.log.error('Error connecting to projector and secondary projector', err);
return false;
}
}
else if (type === 'camera_second') {
this.connected.camera_second = device;
else if (device === 'camera_second') {
this.connected.camera_second = serial;
try {
connectSuccess = await this.arduino.connect('camera_second', device, false);
connectSuccess = await this.arduino.connect('camera_second', serial, false);
}
catch (err) {
console.error(err);
this.log.error(err);
return false;
}
}
else if (type === 'camera,camera_second') {
this.connected.camera = device;
this.connected.camera_second = device;
this.arduino.aliasSerial('camera_second', device);
else if (device === 'camera,camera_second') {
this.connected.camera = serial;
this.connected.camera_second = serial;
this.arduino.aliasSerial('camera_second', serial);
try {
connectSuccess = await this.arduino.connect('camera', device, false);
connectSuccess = await this.arduino.connect('camera', serial, false);
}
catch (err) {
this.log.error('Error connecting to camera, camera_secondary and projector', err);
return false;
}
}
else if ('camera,projector,projector_second') {
this.connected.camera = device;
this.connected.projector = device;
this.connected.projector_second = device;
this.arduino.aliasSerial('projector', device);
this.arduino.aliasSerial('projector_second', device);
else if (device === 'camera,projector,projector_second') {
this.connected.camera = serial;
this.connected.projector = serial;
this.connected.projector_second = serial;
this.arduino.aliasSerial('projector', serial);
this.arduino.aliasSerial('projector_second', serial);
try {
connectSuccess = await this.arduino.connect('camera', device, false);
connectSuccess = await this.arduino.connect('camera', serial, false);
}
catch (err) {
this.log.error('Error connecting to camera, projector and projector_second', err);
return false;
}
}
else if ('camera,camera_second,projector') {
this.connected.camera = device;
this.connected.camera_second = device;
this.connected.projector = device;
this.arduino.aliasSerial('camera_second', device);
this.arduino.aliasSerial('projector', device);
else if (device === 'camera,camera_second,projector') {
this.connected.camera = serial;
this.connected.camera_second = serial;
this.connected.projector = serial;
this.arduino.aliasSerial('camera_second', serial);
this.arduino.aliasSerial('projector', serial);
try {
connectSuccess = await this.arduino.connect('camera', device, false);
connectSuccess = await this.arduino.connect('camera', serial, false);
}
catch (err) {
this.log.error('Error connecting to camera, camera_second and projector', err);
return false;
}
}
else if ('camera,camera_second,projector,projector_second') {
this.connected.camera = device;
this.connected.camera_second = device;
this.connected.projector = device;
this.connected.projector_second = device;
this.arduino.aliasSerial('camera_second', device);
this.arduino.aliasSerial('projector', device);
this.arduino.aliasSerial('projector_second', device);
else if (device === 'camera,camera_second,projector,projector_second') {
this.connected.camera = serial;
this.connected.camera_second = serial;
this.connected.projector = serial;
this.connected.projector_second = serial;
this.arduino.aliasSerial('camera_second', serial);
this.arduino.aliasSerial('projector', serial);
this.arduino.aliasSerial('projector_second', serial);
try {
connectSuccess = await this.arduino.connect('camera', device, false);
connectSuccess = await this.arduino.connect('camera', serial, false);
}
catch (err) {
this.log.error('Error connecting to camera, camera_second, projector and projector_second', err);
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;
}
/**
*
**/
*
**/
//Cases for 1 or 2 arduinos connected
async all(devices) {
async all(serials) {
let c = {};
let p = {};
let l = {};
let type;
let device;
let d;
let cs = {};
let ps = {};
let capper = {};
let checklist = [];
let exposure;
let parts;
this.connected = {
projector: false,
camera: false,
light: false,
projector_second: false
projector_second: false,
capper: false
};
for (let device of devices) {
for (let serial of serials) {
try {
type = await this.distinguish(device);
device = await this.distinguish(serial);
}
catch (err) {
this.log.error('Error distinguishing device', err);
throw err;
}
try {
await this.connectDevice(device, type);
await this.connectDevice(device, serial);
}
catch (err) {
this.log.error('Error connecting to device', err);
@ -387,56 +475,82 @@ class Devices {
if (!this.connected.projector) {
await this.fakeProjector();
}
else if (this.arduino.hasState['projector']) {
p.state = true;
}
p.arduino = this.connected.projector;
if (!this.connected.camera) {
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;
if (!this.connected.light) {
await this.fakeLight();
}
l.arduino = this.connected.light;
if (this.connected.camera_second) {
cs = { arduino: this.connected.camera_second };
cs.arduino = this.connected.camera_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) {
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;
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;
}
});
if (match.length === 0) {
deviceEntry = {
type: type
device,
type,
serial
};
deviceEntry[which] = device;
this.settings.state.devices.push(deviceEntry);
this.settings.update('devices', this.settings.state.devices);
this.settings.save();
}
}
/**
*
**/
ready(projector, camera, light, camera_second, projector_second) {
*
**/
ready(projector, camera, light, camera_second, projector_second, capper) {
let args = {
camera,
projector,
light,
profile: this.settings.state.profile
};
if (this.settings.state.timing) {
args.timing = this.settings.state.timing;
}
if (projector_second && projector_second.arduino) {
args.projector_second = projector_second;
this.settings.update('projector_second', projector_second);
@ -452,6 +566,11 @@ class Devices {
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('projector', projector);
this.settings.update('light', light);

File diff suppressed because one or more lines are too long

1
app/lib/display/index.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export {};

View File

@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = require("path");
const url_1 = require("url");
const delay_1 = require("delay");
const Log = require("log");
const { BrowserWindow } = require('electron');
class WebView {
constructor(platform, display) {
@ -17,7 +18,8 @@ class WebView {
webPreferences: {
nodeIntegration: true,
allowRunningInsecureContent: false,
enableRemoteModule: true
enableRemoteModule: true,
contextIsolation: false
},
width: 800,
height: 600,
@ -25,16 +27,18 @@ class WebView {
minHeight: 600 //,
//icon: path.join(__dirname, '../../assets/icons/icon.png')
};
const pagePath = path_1.normalize(path_1.join(__dirname, '../../display.html'));
const pageUrl = url_1.format({
const pagePath = (0, path_1.normalize)((0, path_1.join)(__dirname, '../../display.html'));
const pageUrl = (0, url_1.format)({
pathname: pagePath,
protocol: 'file:'
});
this.init();
if (!display.primary) {
prefs.x = display.x + 50;
prefs.y = display.y + 50;
}
this.digitalWindow = new BrowserWindow(prefs);
require('@electron/remote/main').enable(this.digitalWindow.webContents);
this.digitalWindow.loadURL(pageUrl);
if (process.argv.indexOf('-d') !== -1 || process.argv.indexOf('--dev') !== -1) {
this.digitalWindow.webContents.openDevTools();
@ -49,27 +53,30 @@ class WebView {
this.ipc = require('electron').ipcMain;
this.ipc.on('display_load', this.onLoad.bind(this));
}
async init() {
this.log = await Log({ label: 'devices' });
}
async open() {
this.digitalWindow.show();
this.showing = true;
this.opened = true;
await this.digitalWindow.setFullScreen(true);
await delay_1.delay(300);
await (0, delay_1.delay)(300);
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) {
const normalSrc = path_1.normalize(path_1.join(src));
const normalSrc = (0, path_1.normalize)((0, path_1.join)(src));
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;
}
try {
this.digitalWindow.webContents.send('display', { src: normalSrc });
}
catch (err) {
console.error(err);
this.log.error(err);
}
this.showing = true;
return new Promise(function (resolve) {
@ -84,41 +91,41 @@ class WebView {
}
async focus() {
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;
}
await delay_1.delay(500);
await (0, delay_1.delay)(500);
try {
this.digitalWindow.webContents.send('focus', { focus: true });
}
catch (err) {
console.error(err);
this.log.error(err);
}
}
async field(ratio) {
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;
}
await delay_1.delay(500);
await (0, delay_1.delay)(500);
try {
this.digitalWindow.webContents.send('field', { field: true, ratio });
}
catch (err) {
console.error(err);
this.log.error(err);
}
}
async meter() {
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;
}
await delay_1.delay(500);
await (0, delay_1.delay)(500);
try {
this.digitalWindow.webContents.send('meter', { meter: true });
}
catch (err) {
console.error(err);
this.log.error(err);
}
}
hide() {
@ -143,7 +150,7 @@ class Display {
constructor(sys) {
this.platform = sys.platform;
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) => {
if (display.primary)
return true;

File diff suppressed because one or more lines are too long

1
app/lib/exec/index.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export declare const execRaw: any;

View File

@ -1,5 +1,7 @@
'use strict';
const execRaw = require('child_process').exec;
Object.defineProperty(exports, "__esModule", { value: true });
exports.execRaw = void 0;
exports.execRaw = require('child_process').exec;
/**
* Promisified child_process.exec
*
@ -28,7 +30,7 @@ async function exec(...args) {
opts = { maxBuffer: 1024 * 1024 };
}
return new Promise((resolve, reject) => {
const child = execRaw(cmd, opts, (err, stdout, stderr) => err ? reject(err) : resolve({
const child = (0, exports.execRaw)(cmd, opts, (err, stdout, stderr) => err ? reject(err) : resolve({
stdout,
stderr
}));

View File

@ -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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,OAAO,CAAC,IAAI,GAAG,IAAI,CAAA"}

8
app/lib/exit/index.d.ts vendored Normal file
View File

@ -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;

1
app/lib/ffmpeg/index.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export {};

View File

@ -7,7 +7,7 @@ const exec_1 = require("exec");
const child_process_1 = require("child_process");
async function spawnAsync(bin, args) {
return new Promise((resolve, reject) => {
const child = child_process_1.spawn(bin, args);
const child = (0, child_process_1.spawn)(bin, args);
let stdout = '';
let stderr = '';
child.on('exit', (code) => {
@ -41,7 +41,7 @@ class FFMPEG {
this.id = 'ffmpeg';
this.onProgress = () => { };
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();
}
/**
@ -124,9 +124,9 @@ class FFMPEG {
if (w && h) {
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 {
fileExists = await fs_extra_1.exists(tmpoutput);
fileExists = await (0, fs_extra_1.exists)(tmpoutput);
}
catch (err) {
//
@ -143,7 +143,7 @@ class FFMPEG {
//-vf "select=gte(n\,${frame})" -compression_algo raw -pix_fmt rgb24 "export-${padded}.png"
try {
this.log.info(cmd);
output = await exec_1.exec(cmd);
output = await (0, exec_1.exec)(cmd);
}
catch (err) {
this.log.error(err);
@ -179,7 +179,7 @@ class FFMPEG {
const h = state.info.height;
const tmppath = this.TMPDIR;
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 output;
let estimated = -1;
@ -201,7 +201,7 @@ class FFMPEG {
//console.dir(args)
//console.dir(state)
try {
await fs_extra_1.mkdir(tmppath);
await (0, fs_extra_1.mkdir)(tmppath);
}
catch (err) {
if (err.code && err.code === 'EEXIST') {
@ -216,7 +216,7 @@ class FFMPEG {
let stdout = '';
let stderr = '';
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) => {
//console.log('GOT TO EXIT');
if (code === 0) {
@ -273,9 +273,9 @@ class FFMPEG {
let ext = 'png';
let tmppath;
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 {
fileExists = await fs_extra_1.exists(tmppath);
fileExists = await (0, fs_extra_1.exists)(tmppath);
}
catch (err) {
this.log.error(err);
@ -283,7 +283,7 @@ class FFMPEG {
if (!fileExists)
return false;
try {
await fs_extra_1.unlink(tmppath);
await (0, fs_extra_1.unlink)(tmppath);
this.log.info(`Cleared frame ${tmppath}`);
}
catch (err) {
@ -299,7 +299,7 @@ class FFMPEG {
const tmppath = this.TMPDIR;
let files;
try {
files = await fs_extra_1.readdir(tmppath);
files = await (0, fs_extra_1.readdir)(tmppath);
}
catch (err) {
this.log.error(err);
@ -313,7 +313,7 @@ class FFMPEG {
if (files) {
files.forEach(async (file, index) => {
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) {
this.log.error(err);
@ -328,14 +328,14 @@ class FFMPEG {
async checkDir() {
let fileExists;
try {
fileExists = await fs_extra_1.exists(this.TMPDIR);
fileExists = await (0, fs_extra_1.exists)(this.TMPDIR);
}
catch (err) {
this.log.error('Error checking for tmp dir', err);
}
if (!fileExists) {
try {
await fs_extra_1.mkdir(this.TMPDIR);
await (0, fs_extra_1.mkdir)(this.TMPDIR);
this.log.info(`Created tmpdir ${this.TMPDIR}`);
}
catch (err) {

File diff suppressed because one or more lines are too long

1
app/lib/ffprobe/index.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export {};

View File

@ -39,7 +39,7 @@ class FFPROBE {
let json;
let vid; //whether video has stream with video data
try {
fileExists = await fs_extra_1.exists(video);
fileExists = await (0, fs_extra_1.exists)(video);
}
catch (err) {
return exit(err, 5);
@ -51,7 +51,7 @@ class FFPROBE {
}
try {
console.log(cmd);
raw = await exec_1.exec(cmd);
raw = await (0, exec_1.exec)(cmd);
}
catch (err) {
//return exit(err, 7);
@ -90,7 +90,7 @@ class FFPROBE {
* @returns {integer} Number of frames in 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 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`;
@ -98,7 +98,7 @@ class FFPROBE {
let raw;
let frames;
try {
fileExists = await fs_extra_1.exists(video);
fileExists = await (0, fs_extra_1.exists)(video);
}
catch (err) {
//return exit(err, 5);
@ -118,7 +118,7 @@ class FFPROBE {
}
try {
console.log(cmd);
raw = await exec_1.exec(cmd);
raw = await (0, exec_1.exec)(cmd);
}
catch (err) {
console.error(err);

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ffprobe/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,uBAAuB;AAEvB,uCAAkC;AAClC,+BAA+B;AAC/B,+BAA4B;AAC5B,iCAAiC;AACjC,+BAA+B;AAE/B,MAAM,OAAO;IAGZ,YAAa,GAAS;QACrB,I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@ -23,7 +23,7 @@ class FilmOut {
* @param {object} ui Electron ui object
* @param {object} light Light device object
**/
constructor(display, ffmpeg, ffprobe, ui, light) {
constructor(display, server, ffmpeg, ffprobe, ui, light) {
this.id = 'filmout';
this.videoExtensions = ['.mpg', '.mpeg', '.mov', '.mkv', '.avi', '.mp4'];
this.stillExtensions = ['.tif', '.tiff', '.png', '.jpg', '.jpeg', '.bmp'];
@ -42,6 +42,7 @@ class FilmOut {
files: []
};
this.display = display;
this.server = server;
this.ffmpeg = ffmpeg;
this.ffprobe = ffprobe;
this.ui = ui;
@ -80,7 +81,7 @@ class FilmOut {
* @param {string} data Data to produce hash of
*/
hash(data) {
return crypto_1.createHash('sha1').update(data).digest('hex');
return (0, crypto_1.createHash)('sha1').update(data).digest('hex');
}
/**
* Sets filmout direction.
@ -92,11 +93,13 @@ class FilmOut {
}
/**
* Moves filmout a frame at a time.
*
* @returns {number} Time since start
**/
async move() {
let start = +new Date();
if (this.state.still) {
return false;
return -1;
}
if (this.state.dir) {
this.state.frame++;
@ -121,14 +124,18 @@ class FilmOut {
this.log.error(err, 'FILMOUT', true, true);
throw err;
}
if (this.server.displayImage(path)) {
await (0, delay_1.delay)(20);
return;
}
await this.display.show(path);
await delay_1.delay(20);
await (0, delay_1.delay)(20);
}
/**
* Ends the filmout process and closes the display.
**/
async end() {
await delay_1.delay(20);
await (0, delay_1.delay)(20);
this.display.hide();
}
/**
@ -136,6 +143,8 @@ class FilmOut {
*
* @param {object} evt Original connect event
* @param {object} arg Arguments from ipc message
*
* @returns {boolean} Success state
**/
async onConnect(evt, arg) {
let frames = 0;
@ -145,13 +154,13 @@ class FilmOut {
let stats;
let frameList;
try {
stats = await fs_extra_1.lstat(arg.path);
stats = await (0, fs_extra_1.lstat)(arg.path);
}
catch (err) {
this.log.error(err, 'FILMOUT', true, true);
return false;
}
ext = path_1.extname(arg.fileName.toLowerCase());
ext = (0, path_1.extname)(arg.fileName.toLowerCase());
if (stats.isDirectory()) {
this.state.directory = true;
this.state.still = false;
@ -240,7 +249,6 @@ class FilmOut {
return false;
}
}
console.dir(info);
this.state.frame = 0;
this.state.path = arg.path;
this.state.fileName = arg.fileName;
@ -265,13 +273,16 @@ class FilmOut {
this.log.info(`Opened ${this.state.fileName}`, 'FILMOUT', true, true);
this.log.info(`Frames : ${frames}`, 'FILMOUT', true, 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.
*
* @param {object} evt IPC event
* @param {object} arg IPC args
*
* @returns {any} UI send call
*/
async onPreExport(evt, arg) {
if (!this.state.path) {
@ -295,13 +306,13 @@ class FilmOut {
async isGifAnimated(pathStr) {
let gifBuffer;
try {
gifBuffer = await fs_extra_1.readFile(pathStr);
gifBuffer = await (0, fs_extra_1.readFile)(pathStr);
}
catch (err) {
this.log.error(err, 'FILMOUT', true, true);
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
@ -349,13 +360,13 @@ class FilmOut {
async dirList(pathStr) {
let frameList = [];
try {
frameList = await fs_extra_1.readdir(pathStr);
frameList = await (0, fs_extra_1.readdir)(pathStr);
}
catch (err) {
this.log.error(err, 'FILMOUT', true, true);
}
frameList = frameList.filter((fileName) => {
let ext = path_1.extname(fileName);
let ext = (0, path_1.extname)(fileName);
if (this.sequenceExtensions.indexOf(ext) !== -1) {
return true;
}
@ -363,7 +374,7 @@ class FilmOut {
});
frameList.sort();
frameList = frameList.map((fileName) => {
return path_1.join(pathStr, fileName);
return (0, path_1.join)(pathStr, fileName);
});
return frameList;
}
@ -405,6 +416,9 @@ class FilmOut {
throw err;
}
try {
if (await this.server.displayImage(path)) {
return;
}
await this.display.open();
await this.display.show(path);
}
@ -418,6 +432,9 @@ class FilmOut {
async focus(evt, arg) {
this.log.info(`Showing focus screen`);
try {
if (await this.server.cmdAll('focus')) {
return;
}
await this.display.open();
await this.display.focus();
}
@ -432,6 +449,9 @@ class FilmOut {
const ratio = arg.ratio;
this.log.info(`Showing field guide screen`);
try {
if (await this.server.cmdAll('field', { ratio })) {
return;
}
await this.display.open();
await this.display.field(ratio);
}
@ -445,6 +465,9 @@ class FilmOut {
async meter(evt, arg) {
this.log.info(`Showing meter screen`);
try {
if (await this.server.cmdAll('meter')) {
return;
}
await this.display.open();
await this.display.meter();
}
@ -457,6 +480,9 @@ class FilmOut {
**/
async close(evt, arg) {
try {
if (await this.server.cmdAll('blank')) {
return;
}
await this.display.hide();
await this.display.close();
}
@ -472,7 +498,7 @@ class FilmOut {
this.log.info(`Changing the display to ${arg.display}`);
}
}
module.exports = (display, ffmpeg, ffprobe, ui, light) => {
return new FilmOut(display, ffmpeg, ffprobe, ui, light);
module.exports = (display, server, ffmpeg, ffprobe, ui, light) => {
return new FilmOut(display, server, ffmpeg, ffprobe, ui, light);
};
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

15
app/lib/frame/index.d.ts vendored Normal file
View File

@ -0,0 +1,15 @@
interface RGBA {
r: number;
g: number;
b: number;
a: number;
}
export default 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 {};

9
app/lib/intval/index.d.ts vendored Normal file
View File

@ -0,0 +1,9 @@
export declare class Intval {
private _baseUrl;
private req;
constructor(url: string);
move(): Promise<unknown>;
setDir(dir: boolean): Promise<unknown>;
setExposure(exposure: number, cb: Function): Promise<unknown>;
connect(cb: Function): void;
}

View File

@ -1,4 +1,6 @@
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
exports.Intval = void 0;
class Intval {
constructor(url) {
this._baseUrl = `http://${url}`;
@ -64,5 +66,6 @@ class Intval {
});
}
}
exports.Intval = Intval;
module.exports.Intval = Intval;
//# sourceMappingURL=index.js.map

View File

@ -1 +1 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AG,EAAG,GAAG;YACT,OAAO,EAAE,IAAI;SACb,CAAA;QAED,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,GAAW,EAAE,GAAS,EAAE,IAAa,EAAE,EAAE;YACxD,IAAI,EAAE,GAAY,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,GAAG,SAAS,CAAA;YAC3C,IAAI,GAAG,EAAE;gBACR,oBAAoB;gBACpB,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;aAClB;YACD,EAAE,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,CAAA;QACnB,CAAC,CAAC,CAAA;IACH,CAAC;CACD;AAnED,wBAmEC;AAED,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,MAAM,CAAA"}

1
app/lib/light/index.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export {};

View File

@ -27,7 +27,7 @@ class Light {
*
**/
listen() {
this.ipc.on(this.id, this.listener.bind(this));
this.ipc.handle(this.id, this.listener.bind(this));
}
/**
*
@ -47,7 +47,7 @@ class Light {
else if (typeof arg.disable !== 'undefined') {
this.enabled = false;
}
event.returnValue = true;
return true;
}
/**
*
@ -62,14 +62,14 @@ class Light {
catch (err) {
this.log.error('Error sending light command', err);
}
await delay_1.delay(1);
await (0, delay_1.delay)(1);
try {
this.arduino.string(this.id, str);
this.arduino.sendString(this.id, str);
}
catch (err) {
this.log.error('Error sending light string', err);
}
await delay_1.delay(1);
await (0, delay_1.delay)(1);
await ms;
return await this.end(rgb, id, ms);
}

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/light/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,iCAA8B;AAC9B,2BAA4B;AAE5B,MAAM,KAAK;IAYV;;QAEI;IACJ,YAAa,OAAiB,EAAE,GAAS,EAAE,EAAQ;QAd5C,UAAK,GAAS,EAAE,KAAK,EAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,C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EAAC,CAAC,CAAC,CAAC;QACf,IAAI;YACH,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;SACtC;QAAC,OAAO,GAAG,EAAE;YACb,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAC;SAClD;QACD,MAAM,IAAA,aAAK,EAAC,CAAC,CAAC,CAAC;QACf,MAAM,EAAE,CAAC;QACT,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IACpC,CAAC;IAED;;QAEI;IACI,KAAK,CAAC,GAAG,CAAE,GAAc,EAAE,EAAW,EAAE,EAAW;QAC1D,IAAI,GAAG,CAAC;QACR,iBAAiB;QACjB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACpE,IAAI;YACH,8BAA8B;YAC9B,GAAG,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;SACnD;QAAC,OAAO,GAAG,EAAE;YACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnB,MAAM,GAAG,CAAA;SACT;QACD,OAAO,GAAG,CAAC;IACZ,CAAC;CACD;AAED,MAAM,CAAC,OAAO,GAAG,UAAU,OAAiB,EAAE,GAAS,EAAE,EAAQ;IAChE,OAAO,IAAI,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;AACpC,CAAC,CAAA"}

1
app/lib/log/index.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export {};

View File

@ -13,34 +13,34 @@ let transport;
* @returns {string} Path to log file
**/
async function logFile() {
const homeDir = os_1.homedir();
const homeDir = (0, os_1.homedir)();
const linuxDir = `/.mcopy/`;
const macDir = `/Library/Logs/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;
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') {
logPath = path_1.normalize(path_1.join(homeDir, winDir));
logPath = (0, path_1.normalize)((0, path_1.join)(homeDir, winDir));
}
try {
dirExists = await fs_extra_1.exists(logPath);
dirExists = await (0, fs_extra_1.exists)(logPath);
}
catch (err) {
console.error(err);
}
if (!dirExists) {
try {
await fs_extra_1.mkdir(logPath);
await (0, fs_extra_1.mkdir)(logPath);
}
catch (err) {
console.error(`Error creating directory for mcopy log file, ${logPath}`);
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
@ -50,7 +50,7 @@ async function logFile() {
*
* @returns {object} Logger transport
**/
module.exports = async function (arg) {
module.exports = async function Log(arg) {
let consoleFormat = {
colorize: true
};
@ -70,7 +70,7 @@ module.exports = async function (arg) {
consoleFormat.label = arg.label;
fileFormat.label = arg.label;
}
transport = winston_1.createLogger({
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}` : " "))),

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/log/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,qCAA2D;AAC3D,+BAAuC;AACvC,uCAAyC;AACzC,2BAA6B;AAE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AC,CAC7I;YACH,UAAU,EAAE;gBACX,IAAI,CAAC,oBAAU,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC;gBACvC,IAAI,CAAC,oBAAU,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC;aACjC;SACD,CAAC,CAAA;KACF;IACD,OAAO,SAAS,CAAA;AACjB,CAAC,CAAA"}

249
app/lib/mscript/index.d.ts vendored Normal file
View File

@ -0,0 +1,249 @@
/** @module lib/mscript */
interface RGB extends Array<number> {
[index: number]: number;
}
/** class Mscript */
export default class Mscript {
output: any;
lines: string[];
cam: number;
cam2: number;
proj: number;
proj2: number;
color: string;
loops: any[];
rec: number;
two: string;
three: string;
four: string;
arr: any[];
meta: string[];
target: number;
dist: number;
variables: any;
/**
* @constructor
* Create new Mscript interpreter
**/
constructor();
/**
* Clear the state of the script
*/
clear(): void;
/**
* 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, callback?: Function): any;
/**
* Interprets variables for complex sequence behavior.
* TODO: Fully implement, add test coverage
*
* @param {string} line Line containing a variable assignment
*
**/
variable(line: string): void;
/**
* 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
**/
variable_replace(line: string): string;
/**
* Interpret a basic two character command
*
* @param {string} line Line of script to interpret
* @param {string} short The short command to use
*/
basic_cmd(line: string, short: string): void;
/**
* Start a new loop
*
* @param {string} line Line to evaluate as either loop or fade
* @param {boolean} fade Flag as true if fade
*/
new_loop(line: string, fade?: boolean): void;
/**
* Close the most recent loop
*
* @param {string} line Line to interpret
*/
end_loop(line: string): void;
/**
* Move camera to explicitly-defined frame
*
* @param {string} line Line to interpret with camera move statement
*/
move_cam(line: string): void;
/**
* Move secondary camera to explicitly-defined frame
*
* @param {string} line Line to interpret with camera move statement
*/
move_cam2(line: string): void;
/**
* Move projector to explicitly-defined frame
*
* @param {string} line Line containing `move` statement to interpret
*/
move_proj(line: string): void;
/**
* Move projector to explicitly-defined frame
*
* @param {string} line Line containing `move` statement to interpret
*/
move_proj2(line: string): void;
/**
* Set the state of either the cam or projector
*
* @param line {string} String containing set statement
*/
set_state(line: string): void;
/**
* Return the last loop
*
* @returns {object}
*/
last_loop(): any;
/**
* Return the second-last loop
*
* @returns {object} Loop array
*/
parent_loop(): any;
/**
* Extract the loop count integer from a LOOP cmd
*
* @returns {integer} Loop count in string parsed into integer
*/
loop_count(str: string): number;
/**
* Execute a fade of frame length, from color to another color
*
* @param {string} line Line containing a fade initiator
*/
fade(line: string): void;
/**
* Extract the fade length integer from a FADE cmd
*
* @param {string} str Line containing the length of fade in frames
*/
fade_count(str: string): number;
/**
* 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
*/
fade_start(str: string): RGB;
/**
* 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
*/
fade_end(str: string): RGB;
/**
* 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
*/
fade_rgb(start: RGB, end: RGB, len: number, x: number): string;
/**
* Parse string into array of RGB color values. 0-255 octet.
*
* @param {string} str String containing only color values as `#,#,#`
**/
rgb(str: string): RGB;
/**
* Cast RGB color values as string
*
* @param {array} arr Array to join into string
*
* @returns {string} String of RGB values
**/
rgb_str(arr: RGB): string;
/**
* 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
*/
update(cmd: string, val?: number): void;
/**
* 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
*/
str_to_arr(str: string, cmd: string): string[];
/**
* 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
*/
light_to_arr(str: string, cmd: string): RGB;
/**
* Split a string to extract an rgb color value
*
* @param {string} Color string assign to color property
*/
light_state(str: string): void;
/**
* Interpret a delay command
*
* @param {string} line String containing delay command
**/
delay(line: string): void;
/**
* Interpret an alert command
*
* @param {string} line String containing alert message
**/
alert(line: string): void;
/**
* Interpret an pause command
*
* @param {string} line String containing alert message
**/
pause(line: string): void;
/**
* Throw an error with specific message
*
* @param {string} msg Error message to print
*/
fail(msg: string): void;
/**
* 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: string[], arr2: string[]): boolean;
}
export {};

View File

@ -1,4 +1,5 @@
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
const BLACK = '0,0,0';
const WHITE = '255,255,255';
const CMD = [
@ -7,7 +8,35 @@ const CMD = [
'BF',
'CB',
'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 = {
'CF': ['CAMERA FORWARD', 'CAM FORWARD'],
@ -17,8 +46,21 @@ const ALTS = {
'PB': ['PROJECTOR FORWARD', 'PROJ FORWARD', 'PROJECTOR BACK', 'PROJ BACK'],
'BB': ['BLACK BACKWARD', 'BLACK BACK', 'BLANK BACK'],
'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 ALERT = 'ALERT';
/** helper functions */
@ -56,11 +98,15 @@ class Mscript {
clear() {
this.lines = [];
this.cam = 0;
this.cam2 = 0;
this.proj = 0;
this.proj2 = 0;
this.color = '';
this.loops = [];
this.rec = -1;
this.two = '';
this.three = '';
this.four = '';
this.arr = [];
this.meta = [];
this.target = 0; //move to target using CAM # or PROJ #
@ -78,7 +124,7 @@ class Mscript {
*
* @returns {object} if callback is not provided
*/
interpret(text, callback) {
interpret(text, callback = null) {
this.clear();
if (typeof text === 'undefined') {
return this.fail('No input');
@ -93,8 +139,19 @@ class Mscript {
});
for (let line of this.lines) {
this.two = line.substring(0, 2);
if (CMD.indexOf(this.two) !== -1) {
this.basic_cmd(line);
this.three = line.substring(0, 3);
this.four = line.substring(0, 4);
if (CMD.indexOf(this.four) !== -1) {
this.basic_cmd(line, this.four);
}
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 (startsWith(line, DELAY)) {
this.delay(line);
}
else if (startsWith(line, PAUSE)) {
this.pause(line);
@ -117,9 +174,15 @@ class Mscript {
else if (startsWith(line, 'END')) {
this.end_loop(line);
}
else if (startsWith(line, 'CAM')) { //directly go to that frame (black?)
else if (startsWith(line, 'CAM2')) { //directly go to that frame
this.move_cam2(line);
}
else if (startsWith(line, 'CAM')) { //directly go to that frame
this.move_cam(line);
}
else if (startsWith(line, 'PROJ2')) { //directly go to that frame
this.move_proj2(line);
}
else if (startsWith(line, 'PROJ')) { //directly go to that frame
this.move_proj(line);
}
@ -130,18 +193,19 @@ class Mscript {
//comments
//ignore while parsing
}
else if (startsWith(line, 'ALERT')) {
}
else if (startsWith(line, 'PAUSE')) {
this.pause(line);
}
}
this.output.success = true;
this.output.arr = this.arr; //all instructions
this.output.meta = this.meta; //all metadata for instructions
this.output.cam = this.cam;
this.output.proj = this.proj;
if (typeof callback !== 'undefined') {
if (this.contains(this.arr, CAMERA_SECONDARY)) {
this.output.cam2 = this.cam2;
}
if (this.contains(this.arr, PROJECTOR_SECONDARY)) {
this.output.proj2 = this.proj2;
}
if (typeof callback !== 'undefined' && callback != null) {
//should only be invoked by running mscript.tests()
callback(this.output);
}
@ -203,25 +267,26 @@ class Mscript {
* Interpret a basic two character command
*
* @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) {
//hold generated arr in state loop array
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
.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 {
this.arr.push.apply(this.arr, this.str_to_arr(line, this.two));
this.meta.push.apply(this.meta, this.light_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, short));
}
}
/**
* Start a new loop
*
* @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) {
this.rec++;
@ -230,6 +295,8 @@ class Mscript {
meta: [],
cam: 0,
proj: 0,
cam2: 0,
proj2: 0,
cmd: line + ''
};
if (fade) {
@ -315,6 +382,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
*
@ -359,13 +470,63 @@ 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
*
* @param line {string} String containing set statement
*/
set_state(line) {
if (startsWith(line, 'SET CAM')) {
if (startsWith(line, 'SET CAM2')) {
parseInt(line.split('SET CAM2')[1]);
}
else if (startsWith(line, 'SET PROJ2')) {
this.cam2 = parseInt(line.split('SET PROJ2')[1]);
}
else if (startsWith(line, 'SET CAM')) {
this.cam = parseInt(line.split('SET CAM')[1]);
}
else if (startsWith(line, 'SET PROJ')) {
@ -523,7 +684,7 @@ class Mscript {
this.cam -= val;
}
else {
this.loops[this.rec].cam--;
this.loops[this.rec].cam -= val;
}
}
else if (cmd === 'PF') {
@ -539,7 +700,7 @@ class Mscript {
this.proj -= val;
}
else {
this.loops[this.rec].proj--;
this.loops[this.rec].proj -= val;
}
}
else if (cmd === 'BF') {
@ -558,6 +719,118 @@ class Mscript {
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 ') {
}
}
@ -628,11 +901,11 @@ class Mscript {
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 len;
lenStr = lenStr.trim();
@ -649,23 +922,42 @@ class Mscript {
if (this.rec !== -1) {
//hold generated arr in state loop array
this.loops[this.rec].arr
.push('PA');
.push('DE');
this.loops[this.rec].meta
.push(lenStr);
}
else {
this.arr.push('AL');
this.arr.push('DE');
this.meta.push(lenStr);
}
}
/**
* Interpret an alert command
*
* @param {string} line String containing pause command
* @param {string} line String containing alert message
**/
alert(line) {
let msg = line.split(' ')[1] || '';
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) {
//hold generated arr in state loop array
this.loops[this.rec].arr
@ -686,6 +978,19 @@ class Mscript {
fail(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;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

1
app/lib/processing/index.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,33 @@
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
const exec_1 = require("exec");
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);
});
}
}
module.exports.Processing = Processing;
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/processing/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,+BAA4B;AAE5B,MAAM,UAAU;IAEf,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,OAAa,EAAE,MAAY,EAAE,EAAE;YACzD,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,GAAY,CAAA;YAChB,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,OAAa,EAAE,MAAY,EAAE,EAAE;YACnD,OAAO,OAAO,CAAC,CAAC,CAAC,CAAA;QAClB,CAAC,CAAC,CAAA;IACH,CAAC;CACD;AAED,MAAM,CAAC,OAAO,CAAC,UAAU,GAAG,UAAU,CAAA"}

2
app/lib/proj/index.d.ts vendored Normal file
View File

@ -0,0 +1,2 @@
/** class representing the Projector features **/
export {};

View File

@ -59,6 +59,7 @@ class Projector {
this.log.error(`Error setting ${this.id} direction`, err);
}
}
console.dir(ms);
return await this.end(cmd, id, ms);
}
/**
@ -166,7 +167,7 @@ class Projector {
}
message += ` ${ms}ms`;
this.log.info(message, 'PROJECTOR');
return await this.ui.send(this.id, { cmd: cmd, id: id, ms: ms });
return await this.ui.send(this.id, { cmd, id, ms });
}
}
module.exports = function (arduino, cfg, ui, filmout, second) {

File diff suppressed because one or more lines are too long

1
app/lib/sequencer/index.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export {};

View File

@ -1,7 +1,11 @@
'use strict';
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Log = require("log");
const electron_1 = require("electron");
const delay_1 = __importDefault(require("delay"));
/** @module lib/sequencer **/
let seq;
class Sequencer {
@ -146,7 +150,7 @@ class Sequencer {
//start sequence
this.log.info(`Starting sequence...`);
this.ui.send(this.id, { start: true });
if (this.cmd.proj.filmout.state.enabled === true) {
if (this.cmd.proj.filmout.state.enabled === true && !this.cmd.proj.filmout.server.useServer()) {
await this.cmd.proj.filmout.display.open();
}
for (let x = 0; x < this.loops; x++) {
@ -160,7 +164,7 @@ class Sequencer {
}
//UI initiates pause, not planned
while (this.paused) {
await delay(42);
await (0, delay_1.default)(42);
}
if (typeof this.arr[y] === 'undefined') {
continue;
@ -179,7 +183,7 @@ class Sequencer {
this.log.info(`Ended loop ${x + 1}`);
this.ui.send(this.id, { loop: x, stop: true });
}
if (this.cmd.proj.filmout.state.enabled === true) {
if (this.cmd.proj.filmout.state.enabled === true && !this.cmd.proj.filmout.server.useServer()) {
await this.cmd.proj.filmout.display.close();
}
electron_1.powerSaveBlocker.stop(psbId);
@ -230,8 +234,7 @@ class Sequencer {
const cmdOriginal = this.arr[x].cmd;
const cmd = this.CMDS[cmdOriginal];
this.log.info(`CMD: '${cmdOriginal}' -> ${cmd}`);
//I wrote this when I was very tired and delirious
return await this.cmd[cmd]();
return await this.cmd[cmd](this.arr[x]);
}
}
module.exports = function (cfg, cmd, ui) {

File diff suppressed because one or more lines are too long

1
app/lib/server/index.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export {};

View File

@ -1,90 +1,204 @@
'use script'
let os
let restify
let app
let cam
let proj
let light
const PACKAGE = require('../../package.json')
'use strict';
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const ws_1 = require("ws");
const express_1 = __importDefault(require("express"));
const promises_1 = require("fs/promises");
const path_1 = require("path");
const uuid_1 = require("uuid");
const Log = require("log");
class Server {
constructor (camera, projector, light) {
restify = require('restify')
os = require('os')
app = restify.createServer({
name: 'mcopy-server',
version: PACKAGE.version
})
this.ip = this.getIp()
/*app.get('/', function (req, res) {
mcopy.mobile.log('Device connected');
res.send(fs.readFileSync('tmpl/mcopy_index.html', 'utf8'));
})
app.get('/js/mcopy_mobile.js', function (req, res) {
res.send(fs.readFileSync('js/mcopy_mobile.js', 'utf8'));
});
app.get('/js/jquery.js', function (req, res) {
res.send(fs.readFileSync('js/jquery.js', 'utf8'));
});
app.get('/cmd/:cmd', function (req, res) {
var cmd,
success = function (res) {
var obj = {
success: true,
cmd : cmd,
cam: {
dir : cam.dir,
pos : cam.pos
},
proj: {
dir : proj.dir,
pos : proj.pos
}
}
res.json(obj);
};
if (typeof req.params.cmd !== 'undefined') {
mcopy.log('Receiving command from mobile: ' + req.params.cmd);
cmd = req.params.cmd;
if (cmd === 'CF'){
mcopy.cmd.camera_forward(success);
} else if (cmd === 'CB') {
mcopy.cmd.camera_backward(success);
} else if (cmd === 'PF') {
mcopy.cmd.projector_forward(success);
} else if (cmd === 'PB') {
mcopy.cmd.projector_backward(success);
} else {
mcopy.mobile.fail(res, 'Command ' + cmd + ' not found');
}
} else {
mcopy.mobile.fail(res, 'No command provided');
}
});
app.get('/state', function (req, res) {
res.json({
cam: {
dir : cam.dir,
pos : cam.pos
},
proj: {
dir : proj.dir,
pos : proj.pos
}
});
});*/
}
end () {
app.close()
app = null
}
constructor(uiInput) {
this.id = 'server';
this.isActive = false;
this.templates = [
{
name: 'index',
path: 'server.html'
},
{
name: 'script',
path: 'lib/client/index.js'
}
];
this.port = 9900;
this.wsPort = 9901;
this.proxy = {};
this.queue = {};
this.intervalPeriod = 10000; //10 sec
this.init();
this.ui = uiInput;
}
async init() {
this.log = await Log({ label: this.id });
await this.load();
await this.start();
}
async load() {
this.http = (0, express_1.default)();
for (let tmpl of this.templates) {
tmpl.data = await (0, promises_1.readFile)(tmpl.path, 'utf8');
}
this.http.get('/', this.index.bind(this));
this.http.get('/image/:key', this.image.bind(this));
this.log.info("Server assets loaded");
}
template(name, data) {
let html = this.templates.find(el => el.name === name).data;
for (let key of Object.keys(data)) {
html = html.replace(`{{${key}}}`, data[key]);
}
return html;
}
async startWss() {
try {
this.wss = new ws_1.WebSocketServer({ port: this.wsPort });
}
catch (err) {
this.log.error(err);
return;
}
this.wss.on('connection', async function (ws, req) {
const address = req.socket.remoteAddress;
ws.on('message', function (data) {
let obj = JSON.parse(data);
//this.log.info(data)
if (obj.id && this.queue[obj.id]) {
this.queue[obj.id](obj);
delete this.queue[obj.id];
if (obj.action !== 'ping') {
this.log.info(`${obj.action} ACK`);
}
}
}.bind(this));
ws.on('close', function () {
this.log.info('Client disconnected');
this.notify('Client disconnected', `No longer forwarding digital display to client ${address}`);
}.bind(this));
await this.cmd(ws, 'mcopy');
this.log.info('Client connected');
this.notify('Client connected', `Forwarding digital display to client: ${address}`);
}.bind(this));
this.log.info(`Websocket server started!`);
this.log.info(`WSS [ ws://localhost:${this.wsPort} ]`);
}
async startHttp() {
return new Promise(function (resolve, reject) {
this.httpd = this.http.listen(this.port, function () {
this.log.info(`HTTP server started!`);
this.log.info(`URL [ http://localhost:${this.port} ]`);
return resolve(true);
}.bind(this));
}.bind(this));
}
async start() {
await this.startHttp();
await this.startWss();
this.interval = setInterval(async function () {
await this.cmdAll('ping');
}.bind(this), this.intervalPeriod);
this.isActive = true;
}
async stopHttp() {
return new Promise(function (resolve, reject) {
return this.httpd.close(function () {
this.log.info(`HTTP server stopped :(`);
return resolve(false);
}.bind(this));
}.bind(this));
}
async stop() {
await this.stopHttp();
clearInterval(this.interval);
this.isActive = false;
}
index(req, res, next) {
const SCRIPT = this.template('script', { PORT: `${this.wsPort}` });
const html = this.template('index', { SCRIPT });
this.log.info('GET /');
return res.send(html);
}
async image(req, res, next) {
let filePath;
if (req.params && req.params.key) {
if (this.proxy[req.params.key]) {
filePath = this.proxy[req.params.key].path;
}
else {
return false;
}
}
else {
return false;
}
return new Promise(function (resolve, reject) {
return res.sendFile(filePath, function (err) {
if (err) {
res.status(err.status).end();
return reject(err);
}
return resolve(true);
});
}.bind(this));
}
addProxy(key, filePath) {
//wipe every time
this.proxy = {};
this.proxy[key] = {
path: filePath
};
this.log.info(`Added proxy image [${key}]`);
}
async cmdAll(action, options = {}) {
const cmds = [];
if (this.useServer()) {
this.wss.clients.forEach(function (ws) {
cmds.push(this.cmd(ws, action, options));
}.bind(this));
await Promise.all(cmds);
return true;
}
return false;
}
async displayImage(src) {
let key;
if (this.useServer()) {
key = (0, path_1.basename)(src);
this.addProxy(key, src);
await this.cmdAll('image', { image: `/image/${key}` });
return true;
}
return false;
}
useServer() {
return this.isActive && this.wss.clients.size > 0;
}
/**
* WSS
**/
async cmd(ws, action, options = {}) {
const id = (0, uuid_1.v4)();
let obj = {
id, action
};
let str;
obj = Object.assign(obj, options);
str = JSON.stringify(obj);
ws.send(str);
return new Promise(function (resolve, reject) {
this.queue[id] = function (obj) {
return resolve(obj);
};
//setTimeout() ?
}.bind(this));
}
notify(title, message) {
this.ui.send('gui', { notify: { title, message } });
}
}
module.exports = Server
module.exports = function (ui) {
return new Server(ui);
};
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

1
app/lib/settings/index.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export {};

View File

@ -18,7 +18,9 @@ class Settings {
profile: 'mcopy',
camera: {},
projector: {},
light: {}
light: {},
capper: {},
timing: {}
};
this.state = this.freshState();
}

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/settings/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,yBAA0B;AAC1B,6BAA8B;AAC9B,+BAAgC;AAEhC,MAAM,QAAQ;IAcb;;QAEI;IACJ;QAhBQ,SAAI,GAAW,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,uBAAuB,CAAC,CAAC;QAChE,iB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,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,MAAM,EAAE;YACX,IAAI;gBACH,MAAM,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aAC3B;YAAC,OAAO,GAAG,EAAE;gBACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;aACnB;SACD;QACD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAC/B,IAAI,CAAC,OAAO,EAAE,CAAC;IAChB,CAAC;IAAA,CAAC;CACF;AAED,MAAM,CAAC,OAAO,GAAG,IAAI,QAAQ,EAAE,CAAA"}

1
app/lib/system/index.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export {};

View File

@ -42,7 +42,7 @@ async function dependencies(platform) {
//if linux
if (platform === 'nix') {
try {
eogoutput = await exec_1.exec('which eog');
eogoutput = await (0, exec_1.exec)('which eog');
}
catch (err) {
console.error('eog is not installed', err);
@ -96,12 +96,12 @@ async function system(ui) {
const obj = {};
let platform;
try {
obj.tmp = os_1.tmpdir();
obj.tmp = (0, os_1.tmpdir)();
}
catch (err) {
obj.tmp = '/tmp';
}
platform = os_1.type();
platform = (0, os_1.type)();
if (platform === 'Darwin') {
obj.platform = 'osx';
}

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/system/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAOb,2BAAkC;AAClC,uCAAkC;AAClC,SAAS;AACT,+BAA4B;AAC5B;;;;;;;;IAQI;AAGJ,KAAK,UAAU,YAAY,CAAE,QAAiB;IAC7C,IAAI,GAAG,GAAS,EAAE,CAAC;IACnB,IAAI,MAAM,GAAS,OAAO,CAAC,eAAe,CAAC,CAAC;IAC5C,IAAI,OAAO,GAAS,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC9C,IAAI,QAAqB,CAAC;IAC1B,4BAA4B;IAC5B,IAAI,SAAsB,CAAC;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AQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC3B,OAAO,QAAQ,CAAC;AACjB,CAAC;AAED;;;;;;GAMG;AACH,KAAK,UAAU,MAAM,CAAE,EAAQ;IAC9B,MAAM,GAAG,GAAS,EAAE,CAAC;IACrB,IAAI,QAAiB,CAAC;IAEtB,IAAI;QACH,GAAG,CAAC,GAAG,GAAG,IAAA,WAAM,GAAE,CAAC;KACnB;IAAC,OAAO,GAAG,EAAE;QACb,GAAG,CAAC,GAAG,GAAG,MAAM,CAAA;KAChB;IAED,QAAQ,GAAG,IAAA,SAAI,GAAE,CAAC;IAElB,IAAI,QAAQ,KAAK,QAAQ,EAAE;QAC1B,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC;KACrB;SAAM,IAAI,QAAQ,KAAK,YAAY,EAAE;QACrC,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC;KACrB;SAAM;QACN,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC;KACrB;IAED,GAAG,CAAC,QAAQ,GAAG,MAAM,QAAQ,EAAE,CAAA;IAC/B,GAAG,CAAC,IAAI,GAAG,MAAM,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAE5C,UAAU,CAAC,GAAG,EAAE;QACf,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IACxB,CAAC,EAAE,IAAI,CAAC,CAAC;IAET,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC"}

27
app/lib/ui/alert.js Normal file
View File

@ -0,0 +1,27 @@
'use strict';
let alertObj;
class Alert {
constructor() {
this.id = 'alert';
}
init() {
this.listen();
}
start(msg) {
alert(msg);
this.end();
}
end() {
const obj = {};
ipcRenderer.sendSync(this.id, obj);
}
listen() {
ipcRenderer.on(this.id, (function (event, arg) {
this.start(arg.msg);
}).bind(this));
}
;
}
alertObj = new Alert();
module.exports = alertObj;
//# sourceMappingURL=alert.js.map

1
app/lib/ui/alert.js.map Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"alert.js","sourceRoot":"","sources":["../../src/lib/ui/alert.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAOb,IAAI,QAAgB,CAAC;AAErB,MAAM,KAAK;IAGV;QAFA,OAAE,GAAY,OAAO,CAAC;IAGtB,CAAC;IAEM,IAAI;QACV,IAAI,CAAC,MAAM,EAAE,CAAC;IACf,CAAC;IAEM,KAAK,CAAE,GAAY;QACzB,KAAK,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,GAAG,EAAE,CAAC;IACZ,CAAC;IAEO,GAAG;QACV,MAAM,GAAG,GAAS,EAAE,CAAC;QAErB,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IACpC,CAAC;IAEO,MAAM;QACb,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,UAAU,KAAa,EAAE,GAAS;YAC1D,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAChB,CAAC;IAAA,CAAC;CAEF;AAED,QAAQ,GAAG,IAAI,KAAK,EAAE,CAAC;AACvB,MAAM,CAAC,OAAO,GAAG,QAAQ,CAAC"}

View File

@ -80,7 +80,8 @@ cam.end = function (c, id, ms) {
}
gui.counterUpdate('cam2', cam.second.pos);
}
gui.counterUpdate('cam', cam.pos)
timing.update(c, ms);
gui.counterUpdate('cam', cam.pos);
if (typeof cam.queue[id] !== 'undefined') {
if (typeof cam.queue[id].callback !== 'undefined') {
cam.queue[id].callback(ms);
@ -89,6 +90,26 @@ cam.end = function (c, id, ms) {
cam.lock = false;
}
};
cam.exposure = async function (exposure) {
var obj = {
id : uuid(),
exposure
};
var change = false;
try {
change = await gui.confirm(`Are you sure you want to set camera exposure to ${exposure}ms?`);
} catch (err) {
log.error(err);
}
if (change) {
log.info(`Setting exposure: ${exposure}`);
ipcRenderer.sendSync(cam.id, obj);
} else {
timing.updateUI('#cam_time', timing.data['cam']);
}
}
cam.listen = function () {
'use strict';
ipcRenderer.on(cam.id, function (event, arg) {
@ -182,6 +203,7 @@ cam.second.end = function (c, id, ms) {
cam.second.pos -= 1;
}
}
timing.update(c, ms);
gui.counterUpdate('cam2', cam.second.pos)
if (typeof cam.second.queue[id] !== 'undefined') {
if (typeof cam.queue[id].callback !== 'undefined') {

72
app/lib/ui/capper.js Normal file
View File

@ -0,0 +1,72 @@
'use strict';
let capper;
class Capper {
constructor() {
this.enabled = false;
this.queue = {};
this.lock = false;
this.id = 'capper';
this.state = false;
}
init() {
this.listen();
}
enable() {
$('.black').addClass('on');
$('#cmd_black_forward').parent().removeClass('hide');
$('#cmd_black_backward').parent().removeClass('hide');
$('#cmd_capper_on').parent().removeClass('hide');
$('#cmd_capper_off').parent().removeClass('hide');
this.enabled = true;
}
capper(state, callback) {
let obj;
if (this.lock) {
return false;
}
obj = {
state,
id: uuid()
};
ipcRenderer.sendSync(this.id, obj);
if (typeof callback !== 'undefined') {
obj.callback = callback;
}
this.queue[obj.id] = obj;
this.lock = true;
this.state = state;
if (state) {
$('#cmd_capper_on').addClass('active');
$('#cmd_capper_off').removeClass('active');
}
else {
$('#cmd_capper_off').addClass('active');
$('#cmd_capper_on').removeClass('active');
}
}
end(c, id, ms) {
if (c === cfg.arduino.cmd.capper_on) {
this.state = true;
}
else if (c === cfg.arduino.cmd.capper_off) {
this.state = false;
}
if (typeof this.queue[id] !== 'undefined') {
if (typeof this.queue[id].callback !== 'undefined') {
this.queue[id].callback(ms);
}
delete this.queue[id];
this.lock = false;
}
}
listen() {
ipcRenderer.on(this.id, function (event, arg) {
capper.end(arg.cmd, arg.id, arg.ms);
return event.returnValue = true;
});
}
;
}
capper = new Capper();
module.exports = capper;
//# sourceMappingURL=capper.js.map

1
app/lib/ui/capper.js.map Normal file
View File

@ -0,0 +1 @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G,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;YACpC,OAAO,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;QACjC,CAAC,CAAC,CAAC;IACJ,CAAC;IAAA,CAAC;CAEF;AAED,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;AACtB,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC"}

View File

@ -155,24 +155,63 @@ cmd.black_forward = function (callback) {
if (callback) { callback(ms); }
};
$('#cmd_black_forward').addClass('active');
if (!cam.dir) {
cam.set(true, function () {
setTimeout( function () {
light.display(off);
light.set(off, function () {
setTimeout( function () {
cam.move(res);
}, cfg.arduino.serialDelay);
});
}, cfg.arduino.serialDelay);
});
if (capper.enabled) {
cam.set(true, function () {
setTimeout( function () {
capper.capper(true, function () {
setTimeout( function () {
light.display(off);
light.set(off, function () {
setTimeout( function () {
cam.move(function () {
setTimeout(function () {
capper.capper(false, res);
}, cfg.arduino.serialDelay);
});
}, cfg.arduino.serialDelay);
});
}, cfg.arduino.serialDelay)
})
}, cfg.arduino.serialDelay);
});
} else {
cam.set(true, function () {
setTimeout( function () {
light.display(off);
light.set(off, function () {
setTimeout( function () {
cam.move(res);
}, cfg.arduino.serialDelay);
});
}, cfg.arduino.serialDelay);
});
}
} else {
light.display(off);
light.set(off, function () {
setTimeout(function () {
cam.move(res);
}, cfg.arduino.serialDelay);
});
if (capper.enabled) {
capper.capper(true, function () {
setTimeout( function () {
light.display(off);
light.set(off, function () {
setTimeout( function () {
cam.move(function () {
setTimeout(function () {
capper.capper(false, res);
}, cfg.arduino.serialDelay);
});
}, cfg.arduino.serialDelay);
});
}, cfg.arduino.serialDelay);
});
} else {
light.display(off);
light.set(off, function () {
setTimeout(function () {
cam.move(res);
}, cfg.arduino.serialDelay);
});
}
}
};
/**
@ -226,21 +265,57 @@ cmd.black_backward = function (callback) {
};
$('#cmd_black_backward').addClass('active');
if (cam.dir) {
cam.set(false, function () {
if (capper.enabled) {
cam.set(false, function () {
setTimeout( function () {
capper.capper(true, function () {
setTimeout(function () {
light.display(off);
light.set(off, function () {
cam.move(function () {
setTimeout(function () {
capper.capper(false, res);
}, cfg.arduino.serialDelay);
});
});
}, cfg.arduino.serialDelay);
});
}, cfg.arduino.serialDelay);
});
} else {
cam.set(false, function () {
setTimeout(function () {
light.display(off);
light.set(off, function () {
cam.move(res);
});
}, cfg.arduino.serialDelay);
});
}
} else {
if (capper.enabled) {
capper.capper(true, function () {
setTimeout( function () {
light.display(off);
light.set(off, function () {
setTimeout( function () {
cam.move(function () {
setTimeout(function () {
capper.capper(false, res);
}, cfg.arduino.serialDelay);
});
}, cfg.arduino.serialDelay);
});
}, cfg.arduino.serialDelay);
});
} else {
setTimeout(function () {
light.display(off);
light.set(off, function () {
cam.move(res);
});
}, cfg.arduino.serialDelay);
});
} else {
setTimeout(function () {
light.display(off);
light.set(off, function () {
cam.move(res);
});
}, cfg.arduino.serialDelay);
}
}
};
@ -534,4 +609,32 @@ cmd.projector_second_to = function (t) {
}
}
/**
* Turn the capper on (block the camera)
*
* @param {function} callback Function to call after capper is on
**/
cmd.capper_on = function (callback) {
'use strict';
var res = function (ms) {
gui.updateState();
if (callback) { callback(ms); }
};
capper.capper(true, res);
};
/**
* Turn the capper off (not blocking the camera)
*
* @param {function} callback Function to call after capper is off
**/
cmd.capper_off = function (callback) {
'use strict';
var res = function (ms) {
gui.updateState();
if (callback) { callback(ms); }
};
capper.capper(false, res);
};
module.exports = cmd;

View File

@ -16,34 +16,30 @@ class Devices {
}
init() {
this.listen();
this.profiles();
this.layoutProfiles();
gui.overlay(true);
gui.spinner(true, 'Checking for connected devices...');
}
listen() {
ipcRenderer.on('ready', this.ready.bind(this));
ipcRenderer.on('intval', this.intvalCb.bind(this));
ipcRenderer.on('processing', this.processingCb.bind(this));
ipcRenderer.on('error_state', this.errorState.bind(this));
}
ready(event, arg) {
return __awaiter(this, void 0, void 0, function* () {
//console.dir(arg)
log.info("Devices ready");
let opt;
let devs = [];
let notify = 'Connected to ';
let p;
//@ts-ignore
yield delay(1000);
try {
gui.spinner(false);
gui.overlay(false);
}
catch (err) {
log.error(err);
if (typeof arg.camera !== 'undefined' && typeof arg.camera.exposure !== undefined) {
$('#submit_cam_time').removeClass('hide');
$('#cam_time').removeAttr('readonly');
}
for (let i in arg) {
devs.push(arg[i].arduino);
if (arg[i].arduino && arg[i].arduino !== '/dev/fake') {
if (typeof arg[i].arduino !== 'undefined' && arg[i].arduino !== '/dev/fake') {
devs.push(arg[i].arduino);
if (notify === 'Connected to ') {
notify += arg[i].arduino + ' ';
}
@ -72,35 +68,60 @@ class Devices {
$('#devices').append(opt);
}
}
if (arg && arg.profile) {
$('#profile').val(arg.profile);
log.info(`Using configuration profile "${arg.profile}"`, 'DEVICES', true, true);
p = cfg.profiles[arg.profile];
if (typeof p.light !== 'undefined' && p.light === false) {
light.disable();
}
else {
light.enable();
}
//devices.profile(arg.profile)
if (typeof arg !== 'undefined' && typeof arg.profile !== 'undefined') {
yield devices.profile(arg.profile);
}
if (typeof arg !== 'undefined' && typeof arg.timing !== 'undefined') {
timing.restore(arg.timing);
}
if (typeof arg !== 'undefined' && typeof arg.projector_second !== 'undefined') {
//add second row of projector pads to grid
proj.second.enable();
}
if (typeof arg !== 'undefined' && typeof arg.camera_second !== 'undefined') {
//add second row of camera pads to grid
cam.second.enable();
}
if (typeof arg !== 'undefined' && typeof arg.capper !== 'undefined') {
//add capper features to grid
capper.enable();
}
seq.set(0, cfg.cmd.camera_forward);
seq.set(1, cfg.cmd.projector_forward);
grid.state(0);
grid.state(1);
seq.stats();
if (arg.projector_second) {
//add second row of projector pads to grid
proj.second.enable();
try {
gui.spinner(false);
gui.overlay(false);
}
if (arg.camera_second) {
//add second row of camera pads to grid
cam.second.enable();
catch (err) {
log.error(err);
}
return event.returnValue = true;
});
}
profiles() {
profile(profile) {
return __awaiter(this, void 0, void 0, function* () {
log.info(`Changed configuration profile to "${profile}"`, 'DEVICES', true, true);
const p = cfg.profiles[profile];
const keys = Object.keys(p);
for (let key of keys) {
cfg[key] = keys[key];
}
$('#profile').val(profile);
timing.reset(p);
if (typeof p.light !== 'undefined' && p.light === false) {
yield light.disable();
}
else {
yield light.enable();
}
yield ipcRenderer.invoke('profile', { profile });
yield timing.store();
});
}
layoutProfiles() {
const keys = Object.keys(cfg.profiles);
const elem = $('#profile');
let opt;
@ -116,33 +137,18 @@ class Devices {
this.profile(val);
});
}
profile(profile) {
log.info(`Changed configuration profile to "${profile}"`, 'DEVICES', true, true);
const p = cfg.profiles[profile];
const keys = Object.keys(p);
for (let key of keys) {
cfg[key] = keys[key];
}
if (typeof p.light !== 'undefined' && p.light === false) {
light.disable();
}
else {
light.enable();
}
ipcRenderer.send('profile', { profile });
}
intval() {
const url = $('#intval').val();
let proceed = false;
let obj = {
connect: true,
url: url
url
};
if (url !== '' && typeof url !== 'undefined') {
proceed = confirm(`Are you sure you want to connect to INTVAL3 @ ${url}?`);
}
else {
alert('Cannot connect to INTVAL3 url as entered.');
alert('Cannot connect to INTVAL3 URL as entered.');
}
if (proceed) {
gui.overlay(true);
@ -174,6 +180,32 @@ class Devices {
$('#intval').removeClass('active');
}
}
processing() {
const url = $('#processing').val();
let proceed = false;
let obj = {
url
};
if (url !== '' && typeof url !== 'undefined') {
proceed = confirm(`Are you sure you want to connect to Processing @ ${url}?`);
}
else {
alert('Cannot connect to Processing URL as entered.');
}
if (proceed) {
gui.overlay(true);
gui.spinner(true, `Connecting to Processing @ ${url}`);
ipcRenderer.send('processing', obj);
}
else {
$('#camera_type_arduino').prop('checked', 'checked');
$('#processing').removeClass('active');
}
}
processingCb() {
gui.spinner(false);
gui.overlay(false);
}
errorState() {
gui.spinner(false);
gui.overlay(false);

File diff suppressed because one or more lines are too long

View File

@ -6,6 +6,9 @@ let grid;
class Grid {
constructor() {
this.swatchesElem = {};
this.projector_cmds = [
'PF', 'PB', 'P2F', 'P2B', 'PPF', 'PPB'
];
}
init() {
this.refresh();
@ -24,8 +27,8 @@ class Grid {
const step = seq.grid[x];
let className;
let className2;
elem.prop('checked', false);
if (typeof step !== 'undefined') {
elem.prop('checked', false);
if (step.cmd === cfg.cmd.cameras_forward) {
className = cfg.cmd.camera_forward;
className2 = cfg.cmd.camera_second_forward;
@ -58,6 +61,14 @@ class Grid {
className = cfg.cmd.projector_backward;
className2 = cfg.cmd.projector_second_forward;
}
else if (step.cmd === cfg.cmd.black_forward) {
className = cfg.cmd.camera_forward;
className2 = 'black';
}
else if (step.cmd === cfg.cmd.black_backward) {
className = cfg.cmd.camera_backward;
className2 = 'black';
}
else {
className = step.cmd;
}
@ -75,6 +86,12 @@ class Grid {
.removeClass('a')
.prop('title', '');
}
if (capper.enabled && this.projector_cmds.indexOf(step.cmd) !== -1) {
$(`.black[x=${x}]`).addClass('disabled');
}
else if (capper.enabled) {
$(`.black[x=${x}]`).removeClass('disabled');
}
}
else {
lightElem.css('background', 'transparent')
@ -113,6 +130,7 @@ class Grid {
'camera_second_backward',
'projector_backward',
'projector_second_backward',
'black',
'light_set',
'numbers'
];
@ -132,6 +150,10 @@ class Grid {
elem = `<div x="${x}" class="L"></div>`;
$(cmd).append($(elem));
}
else if (cmds[i] === 'black') {
elem = `<input type="checkbox" x="${x}" class="black" />`;
$(cmd).append($(elem));
}
else {
elem = `<input type="checkbox" x="${x}" />`;
$(cmd).append($(elem).addClass(cfg.cmd[cmds[i]]));
@ -159,7 +181,24 @@ class Grid {
current = seq.grid[x].cmd + ''; // cast to string, bad hack
}
if (checked) {
if (cam.second.enabled && current.indexOf('C') !== -1) {
if (c.indexOf('black') !== -1) {
if (other === '') {
c = cfg.cmd.black_forward;
}
else if (current.indexOf('C') !== -1) {
if (other == cfg.cmd.camera_forward) {
c = cfg.cmd.black_forward;
}
else if (other === cfg.cmd.camera_backward) {
c = cfg.cmd.black_backward;
}
}
else if (current.indexOf('P') !== -1) {
$(elem).prop('checked', false);
return;
}
}
else if (cam.second.enabled && current.indexOf('C') !== -1) {
if (c === cfg.cmd.camera_forward) {
if (other === cfg.cmd.camera_second_forward) {
c = cfg.cmd.cameras_forward;
@ -254,7 +293,27 @@ class Grid {
seq.set(x, c);
}
else {
if (cam.second.enabled && current.indexOf('C') !== -1) {
if (c.indexOf('black') !== -1) {
if (current === 'BF' || current === 'BB') {
if (other === cfg.cmd.camera_forward) {
c = cfg.cmd.camera_forward;
}
else if (other === cfg.cmd.camera_backward) {
c = cfg.cmd.camera_backward;
}
}
else if (current.indexOf('P') !== -1) {
$(elem).prop('checked', false);
return;
}
}
else if (other === 'black' && current === cfg.cmd.camera_forward) {
c = '';
}
else if (other === 'black' && current === cfg.cmd.camera_backward) {
c = '';
}
else if (cam.second.enabled && current.indexOf('C') !== -1) {
if (current === cfg.cmd.cameras_forward) {
if (other === cfg.cmd.camera_second_forward) {
c = cfg.cmd.camera_second_forward;

File diff suppressed because one or more lines are too long

View File

@ -1,259 +1,293 @@
/* jslint esversion: 6*/
const gui = {};
//GUI
gui.fmtZero = function (val, len) {
'use strict';
const raw = val;
let str = val + '';
let output = '';
if (raw < 0) {
output = '-' + Array(len - (str.length - 1)).join('0') + str.replace('-', '');
} else {
if (str.length < len) {
output = Array(len - str.length).join('0') + str;
} else if (str.length >= len) {
str = parseInt(str) + '';
output = Array(len - str.length).join('0') + str;
}
}
return output;
'use strict';
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
gui.counterFormat = function (t, normal, prevent) {
'use strict';
const raw = t.value;
t.value = gui.fmtZero(raw, 6);
if (typeof normal !== 'undefined' && parseInt(raw) !== normal) {
$(t).addClass('changed');
} else {
$(t).removeClass('changed');
}
};
gui.counterUpdate = function (which, raw) {
'use strict';
const formattedVal = gui.fmtZero(raw, 6);
$(`.${which} .count`).val(formattedVal);
};
gui.notifierWorking = true;
gui.notify = function (title, message) {
'use strict';
if (!gui.notifierWorking) {
return true;
}
return new Promise((resolve, reject) => {
try {
notifier.notify({
title: title,
message: message,
//icon: path.join(__dirname, 'coulson.jpg'), // Absolute path (doesn't work on balloons)
sound: true, // Only Notification Center or Windows Toasters
wait: true // Wait with callback, until user action is taken against notification
}, function (err, response) {
// Response is response from notification
if (err) {
gui.notifierWorking = false;
log.error(`Error with notification`, err);
return reject(err);
}
return resolve(true);
});
} catch (err) {
gui.notifierWorking = false;
//notify-send is not found
//determine an alternate for raspian
//this feels like a hack
}
});
};
gui.updateCam = async function (t) {
'use strict';
const val = t.value;
let change;
if (parseInt(val) === cam.pos) {
return false;
}
change = await gui.confirm(`Are you sure you want to set camera counter to ${val}?`);
if (change) {
cam.pos = parseInt(val);
gui.updateState();
} else {
t.value = cam.pos;
gui.counterFormat(t);
}
};
gui.updateCam2 = async function (t) {
'use strict';
const val = t.value;
let change;
if (parseInt(val) === cam.pos) {
return false;
}
change = await gui.confirm(`Are you sure you want to set second camera counter to ${val}?`);
if (change) {
cam.second.pos = parseInt(val);
gui.updateState();
} else {
t.value = cam.second.pos;
gui.counterFormat(t);
}
};
gui.updateProj = async function (t) {
'use strict';
const val = t.value;
let change;
if (parseInt(val) === proj.pos) {
return false;
}
change = await gui.confirm(`Are you sure you want to set projector counter to ${val}?`);
if (change) {
proj.pos = parseInt(val);
gui.updateState();
} else {
t.value = proj.pos;
gui.counterFormat(t);
}
proj.setValue(t.value);
};
gui.updateProj2 = async function (t) {
'use strict';
const val = t.value;
let change;
if (parseInt(val) === proj.second.pos) {
return false;
}
change = await gui.confirm(`Are you sure you want to set second projector counter to ${val}?`);
if (change) {
proj.second.pos = parseInt(val);
gui.updateState();
} else {
t.value = proj.second.pos;
gui.counterFormat(t);
}
proj.setValue(t.value);
};
gui.updateState = function () {
'use strict';
const cpos = cam.pos;
const ppos = proj.pos;
const p2pos = proj.second.pos;
const c2pos = cam.second.pos;
$('#seq_cam_count').val(cpos).change();
$('#seq_proj_count').val(ppos).change();
$('#seq_cam_count_2').val(cpos).change();
$('#seq_proj_count_2').val(ppos).change();
$('#seq_cam_2_count').val(c2pos).change();
$('#seq_proj_2_count').val(p2pos).change();
$('#seq_cam_2_count_2').val(c2pos).change();
$('#seq_proj_2_count_2').val(p2pos).change();
};
gui.spinnerCfg = {
lines: 11, // The number of lines to draw
length: 15, // The length of each line
width: 7, // The line thickness
radius: 20, // The radius of the inner circle
corners: 1, // Corner roundness (0..1)
rotate: 0, // The rotation offset
direction: 1, // 1: clockwise, -1: counterclockwise
color: '#F2F2F1', // #rgb or #rrggbb or array of colors
speed: 1, // Rounds per second
trail: 60, // Afterglow percentage
shadow: true, // Whether to render a shadow
hwaccel: true, // Whether to use hardware acceleration
className: 'spinner', // The CSS class to assign to the spinner
zIndex: 2e9, // The z-index (defaults to 2000000000)
top: '50%', // Top position relative to parent
left: '50%' // Left position relative to parent
};
gui.spinner = function (state, msg, progress, cancel) {
'use strict';
let target;
let spinner;
if (msg && msg !== '') {
gui.spinnerMsg(msg);
}
if (state && !$('#spinner').hasClass('created')) {
target = document.getElementById('spinner');
spinner = new Spinner(gui.spinnerCfg).spin(target);
$('#spinnerProgress').hide();
$('#spinner').addClass('created');
} else if (state) {
$('#spinner').show();
} else if (!state) {
$('#spinner').hide();
gui.spinnerMsg('');
}
if (progress) {
$('#spinnerProgress').show();
} else {
$('#spinnerProgress').hide();
}
if (cancel) {
$('#spinnerCancel').show();
} else {
$('#spinnerCancel').hide();
}
};
gui.spinnerMsg = function (msg) {
'use strict';
$('#spinnerMsg').text(msg);
};
gui.overlay = function (state) {
'use strict';
if (state) {
$('#overlay').show();
} else {
$('#overlay').hide();
}
};
gui.info = async function (title, message) {
'use strict';
const config = {
type : 'info',
buttons : ['Ok'],
title: title,
message : message
};
return dialog.showMessageBox(config);
};
gui.confirm = async function (message, cancel = 'Cancel') {
const config = {
buttons : ['Yes', cancel],
message
}
const res = await dialog.showMessageBox(config);
return res.response === 0;
};
gui.choice = async function (message, choices) {
const config = {
buttons : choices,
defaultId : 0,
message
}
const res = await dialog.showMessageBox(config);
return res.response;
};
gui.warn = async function (title, message) {
'use strict';
const config = {
type : 'warning',
buttons : ['Ok'],
title: title,
message : message
};
return dialog.showMessageBox(config);
};
gui.error = function () {};
module.exports = gui;
let gui;
class GUI {
constructor() {
this.id = 'gui';
this.notifierWorking = true;
this.spinnerCfg = {
lines: 11,
length: 15,
width: 7,
radius: 20,
corners: 1,
rotate: 0,
direction: 1,
color: '#F2F2F1',
speed: 1,
trail: 60,
shadow: true,
hwaccel: true,
className: 'spinner',
zIndex: 2e9,
top: '50%',
left: '50%' // Left position relative to parent
};
}
init() {
this.version();
this.listen();
}
listen() {
ipcRenderer.on(this.id, this.listener.bind(this));
}
listener(event, arg) {
if (arg.notify) {
this.notify(arg.notify.title, arg.notify.message);
}
}
fmtZero(val, len) {
const raw = val;
let str = val + '';
let output = '';
if (raw < 0) {
output = '-' + Array(len - (str.length - 1)).join('0') + str.replace('-', '');
}
else {
if (str.length < len) {
output = Array(len - str.length).join('0') + str;
}
else if (str.length >= len) {
str = parseInt(str) + '';
output = Array(len - str.length).join('0') + str;
}
}
return output;
}
counterFormat(t, normal = null) {
const raw = t.value;
t.value = gui.fmtZero(raw, 6);
if (typeof normal !== 'undefined' && parseInt(raw) !== normal) {
$(t).addClass('changed');
}
else {
$(t).removeClass('changed');
}
}
counterUpdate(which, raw) {
const formattedVal = this.fmtZero(raw, 6);
$(`.${which} .count`).val(formattedVal);
}
notify(title, message) {
const config = {
title,
message,
//icon: path.join(__dirname, 'coulson.jpg'), // Absolute path (doesn't work on balloons)
sound: true,
wait: true // Wait with callback, until user action is taken against notification
};
if (!this.notifierWorking) {
return new Promise((resolve, reject) => { return resolve(true); });
}
return new Promise((resolve, reject) => {
try {
notifier.notify(config, function (err, response) {
// Response is response from notification
if (err) {
this.notifierWorking = false;
log.error(`Error with notification`, err);
return reject(err);
}
return resolve(true);
}.bind(this));
}
catch (err) {
this.notifierWorking = false;
//notify-send is not found
//determine an alternate for raspian
//this feels like a hack
}
});
}
updateCam(t) {
return __awaiter(this, void 0, void 0, function* () {
const val = t.value;
let change;
if (parseInt(val) === cam.pos) {
return false;
}
change = yield this.confirm(`Are you sure you want to set camera counter to ${val}?`);
if (change) {
cam.pos = parseInt(val);
this.updateState();
}
else {
t.value = cam.pos;
this.counterFormat(t);
}
});
}
updateCam2(t) {
return __awaiter(this, void 0, void 0, function* () {
const val = t.value;
let change;
if (parseInt(val) === cam.pos) {
return false;
}
change = yield this.confirm(`Are you sure you want to set second camera counter to ${val}?`);
if (change) {
cam.second.pos = parseInt(val);
this.updateState();
}
else {
t.value = cam.second.pos;
this.counterFormat(t);
}
});
}
updateProj(t) {
return __awaiter(this, void 0, void 0, function* () {
const val = t.value;
let change;
if (parseInt(val) === proj.pos) {
return false;
}
change = yield this.confirm(`Are you sure you want to set projector counter to ${val}?`);
if (change) {
proj.pos = parseInt(val);
this.updateState();
}
else {
t.value = proj.pos;
this.counterFormat(t);
}
proj.setValue(t.value);
});
}
updateProj2(t) {
return __awaiter(this, void 0, void 0, function* () {
const val = t.value;
let change;
if (parseInt(val) === proj.second.pos) {
return false;
}
change = yield this.confirm(`Are you sure you want to set second projector counter to ${val}?`);
if (change) {
proj.second.pos = parseInt(val);
this.updateState();
}
else {
t.value = proj.second.pos;
this.counterFormat(t);
}
proj.setValue(t.value);
});
}
updateState() {
const cpos = cam.pos;
const ppos = proj.pos;
const p2pos = proj.second.pos;
const c2pos = cam.second.pos;
$('#seq_cam_count').val(cpos).change();
$('#seq_proj_count').val(ppos).change();
$('#seq_cam_count_2').val(cpos).change();
$('#seq_proj_count_2').val(ppos).change();
$('#seq_cam_2_count').val(c2pos).change();
$('#seq_proj_2_count').val(p2pos).change();
$('#seq_cam_2_count_2').val(c2pos).change();
$('#seq_proj_2_count_2').val(p2pos).change();
}
spinner(state, msg = null, progress = false, cancel = false) {
let target;
let spinner;
if (msg && msg !== '') {
this.spinnerMsg(msg);
}
if (state && !$('#spinner').hasClass('created')) {
target = document.getElementById('spinner');
spinner = new Spinner(this.spinnerCfg).spin(target);
$('#spinnerProgress').hide();
$('#spinner').addClass('created');
}
else if (state) {
$('#spinner').show();
}
else if (!state) {
$('#spinner').hide();
this.spinnerMsg('');
}
if (progress) {
$('#spinnerProgress').show();
}
else {
$('#spinnerProgress').hide();
}
if (cancel) {
$('#spinnerCancel').show();
}
else {
$('#spinnerCancel').hide();
}
}
spinnerMsg(msg) {
$('#spinnerMsg').text(msg);
}
overlay(state) {
if (state) {
$('#overlay').show();
}
else {
$('#overlay').hide();
}
}
info(title, message) {
return __awaiter(this, void 0, void 0, function* () {
const config = {
type: 'info',
buttons: ['Ok'],
title: title,
message: message
};
return dialog.showMessageBox(config);
});
}
confirm(message, cancel = 'Cancel') {
return __awaiter(this, void 0, void 0, function* () {
const config = {
buttons: ['Yes', cancel],
message
};
const res = yield dialog.showMessageBox(config);
return res.response === 0;
});
}
choice(message, choices) {
return __awaiter(this, void 0, void 0, function* () {
const config = {
buttons: choices,
defaultId: 0,
message
};
const res = yield dialog.showMessageBox(config);
return res.response;
});
}
warn(title, message) {
return __awaiter(this, void 0, void 0, function* () {
const config = {
type: 'warning',
buttons: ['Ok'],
title,
message
};
return dialog.showMessageBox(config);
});
}
version() {
$('#version').text(PACKAGE.version);
}
error() {
}
}
gui = new GUI();
module.exports = gui;
//# sourceMappingURL=index.js.map

1
app/lib/ui/index.js.map Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,13 @@
'use strict';
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
let light;
class Light {
constructor() {
@ -91,26 +100,30 @@ class Light {
}
}
disable() {
const obj = {
disable: true,
id: uuid()
};
this.disabled = true;
$('#tb_toolbar_item_light').hide();
$('#seq_labels .spacer').eq(1).hide();
$('#light_set').hide();
ipcRenderer.sendSync(this.id, obj);
return __awaiter(this, void 0, void 0, function* () {
const obj = {
disable: true,
id: uuid()
};
this.disabled = true;
$('#tb_toolbar_item_light').hide();
$('#seq_labels .spacer').eq(1).hide();
$('#light_set').hide();
return ipcRenderer.invoke(this.id, obj);
});
}
enable() {
const obj = {
enable: true,
id: uuid()
};
light.disabled = false;
$('#tb_toolbar_item_light').show();
$('#seq_labels .spacer').eq(1).show();
$('#light_set').show();
ipcRenderer.sendSync(light.id, obj);
return __awaiter(this, void 0, void 0, function* () {
const obj = {
enable: true,
id: uuid()
};
this.disabled = false;
$('#tb_toolbar_item_light').show();
$('#seq_labels .spacer').eq(1).show();
$('#light_set').show();
return ipcRenderer.invoke(this.id, obj);
});
}
colorPickers() {
//@ts-ignore

File diff suppressed because one or more lines are too long

View File

@ -1,231 +1,284 @@
const mse = {};
'use strict';
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
/// <reference path ="jquery.d.ts"/>
const mscript_1 = __importDefault(require("mscript"));
/******
Mscript GUI
Mscript GUI
*******/
mse.mscript = {};
mse.mscript.editor = {};
mse.mscript.data = {};
mse.mscript.raw = '';
mse.mscript.init = function () {
'use strict';
$('#editor').val('CF 1\nPF 1');
mse.mscript.editor = CodeMirror.fromTextArea(document.getElementById('editor'), {
lineNumbers: true,
mode: 'python',
matchBrackets: true,
theme: 'monokai'
});
mse.mscript.editor.setSize(null, $(window).height() - $('footer').eq(0).height() - 30);
mse.mscript.editor.on('change', function (e) {
//
});
$(document).on('resize', function (e) {
mse.mscript.editor.setSize(null, $(window).height() - $('footer').eq(0).height() - 30);
});
};
mse.mscript.open = function () {
'use strict';
mse.mscript.editor.setSize(null, $(window).height() - $('footer').eq(0).height() - 30);
mse.mscript.editor.refresh();
};
mse.mscript.fromSequence = function () {
//ehhhhh
'use strict';
let str;
let tmp = [];
let cont;
let cmd;
//str = seq.grid.map(step => { return step.cmd }).join('\n'); //quick hack
//console.dir(seq.grid);
for (let step of seq.grid) {
if (!step || !step.cmd) continue;
cmd = step.cmd;
if (tmp.length > 0 && tmp[tmp.length - 1].cmd === cmd) {
tmp[tmp.length - 1].num++;
continue;
}
tmp.push({ cmd : cmd, num : 1 });
}
tmp = tmp.map(line => {
return `${line.cmd} ${line.num}`
})
//console.dir(tmp)
if (seq.gridLoops > 1) {
tmp.map(line => {
return ` ${line}`;
})
tmp.reverse();
tmp.push(`LOOP ${seq.gridLoops}`);
tmp.reverse();
tmp.push('END');
}
str = tmp.join('\n');
nav.change('script');
cont = confirm(`Are you sure you want to over-write the current sequence?`);
if (cont) {
mse.mscript.editor.getDoc().setValue(str);
}
};
mse.mscript.toGUI = function () {
'use strict';
let c;
let step;
for (let x = 0; x < mse.mscript.data.arr.length; x++) {
c = mse.mscript.data.arr[x];
seq.set(x, c);
if (c === 'CF' || c === 'CB') {
if (typeof mse.mscript.data.meta[x] !== 'undefined' && mse.mscript.data.meta[x] !== '') {
seq.setLight(x, mse.mscript.data.meta[x]);
} else {
seq.setLight(x, light.color);
}
} else {
//unset light?
}
grid.state(x);
}
};
mse.mscript.toSequence = function () {
'use strict';
const data = mse.mscript.editor.getValue();
let cont;
if (data !== mse.mscript.raw) {
cont = confirm(`Current script has not been compiled. Compile first?`);
if (cont) {
mse.mscript.compile()
}
}
mse.console.print(`Sending compiled script to GUI sequencer...`);
seq.clear();
mse.mscript.toGUI();
grid.refresh();
seq.stats();
return nav.change('sequencer');
class MscriptGUI {
constructor() {
this.editor = {};
this.data = {};
this.raw = '';
}
/**
* Initializes the mscript GUI. Sets up CodeMirror instance,
* binds events and sets height of editor.
**/
init() {
const startingScript = `CF 1
PF 1`;
const editorHeight = $(window).height() - $('footer').eq(0).height() - 30;
const editorElem = document.getElementById('editor');
const editorConfig = {
lineNumbers: true,
mode: 'python',
matchBrackets: true,
theme: 'monokai'
};
$('#editor').val(startingScript);
this.editor = CodeMirror.fromTextArea(editorElem, editorConfig);
this.editor.setSize(null, editorHeight);
this.editor.on('change', (e) => { });
$(document).on('resize', function (e) {
this.editor.setSize(null, editorHeight);
}.bind(this));
}
/**
* Callback for when open event occurs.
**/
open() {
//recalcuate in case resize has occurred needed
const editorHeight = $(window).height() - $('footer').eq(0).height() - 30;
this.editor.setSize(null, editorHeight);
this.editor.refresh();
}
/**
* Create script from the sequencer's current state.
* Previous comment: ehhhh
* TODO: Make this smarter.
**/
fromSequence() {
let str;
let tmp = [];
let cont;
let cmd;
//str = seq.grid.map(step => { return step.cmd }).join('\n'); //quick hack
//console.dir(seq.grid);
for (let step of seq.grid) {
if (!step || !step.cmd) {
continue;
}
cmd = step.cmd;
if (tmp.length > 0 && tmp[tmp.length - 1].cmd === cmd) {
tmp[tmp.length - 1].num++;
continue;
}
tmp.push({ cmd, num: 1 });
}
tmp = tmp.map(line => {
return `${line.cmd} ${line.num}`;
});
if (seq.gridLoops > 1) {
tmp.map(line => {
return ` ${line}`;
});
tmp.reverse();
tmp.push(`LOOP ${seq.gridLoops}`);
tmp.reverse();
tmp.push('END');
}
str = tmp.join('\n');
nav.change('script');
cont = confirm(`Are you sure you want to over-write the current sequence?`);
if (cont) {
this.editor.getDoc().setValue(str);
}
}
/**
* Take current compiled mscript state and send it to the sequencer
* GUI. TODO: Add confirm step if sequence is longer than X steps.
* TODO: Make this smarter (detect outer non-fade loop and assign to loop counter)
**/
toGUI() {
let c;
let step;
for (let x = 0; x < this.data.arr.length; x++) {
c = this.data.arr[x];
seq.set(x, c);
if (c === 'CF' || c === 'CB') {
if (typeof this.data.meta[x] !== 'undefined' && this.data.meta[x] !== '') {
seq.setLight(x, this.data.meta[x]);
}
else {
seq.setLight(x, light.color);
}
}
else {
//unset light?
}
grid.state(x);
}
}
/**
* Handles compilation of mscript and switches to sequencer
* GUI after confirmation questions.
**/
toSequence() {
const data = this.editor.getValue();
let cont = false;
if (data !== this.raw) {
cont = confirm(`Current script has not been compiled. Compile first?`);
if (cont) {
this.compile();
}
}
mse.console.print(`Sending compiled script to GUI sequencer...`);
seq.clear();
this.toGUI();
grid.refresh();
seq.stats();
return nav.change('sequencer');
}
/**
* Compiles text in editor using the Mscript library.
*
**/
compile() {
const data = this.editor.getValue();
const mscript = new mscript_1.default();
const output = mscript.interpret(data);
const len = output.arr.length;
const cam2 = typeof output.cam2 !== 'undefined' ? `, CAM2 : ${output.cam2}` : '';
const proj2 = typeof output.proj2 !== 'undefined' ? `, PROJ2 : ${output.proj2}` : '';
const report = `Sequence contains ${len} step${(len === 1 ? '' : 's')}, CAM: ${output.cam}, PROJ: ${output.proj}${cam2}${proj2}`;
this.raw = data;
this.data = output;
//mse.console.print(JSON.stringify(output, null, '\t') + '\n')
mse.console.print(report);
}
/**
* This function re-writes the optional "meta" attribute
* of an mcopy command object to "light". TODO: change this.
* Do not re-write this object and improve the consumers
* of the compiled data.
**/
prepare() {
const arr = [];
let obj;
for (let i = 0; i < this.data.arr.length; i++) {
obj = {
cmd: this.data.arr[i]
};
if (typeof this.data.meta[i] !== 'undefined' && this.data.meta[i] !== '') {
obj.light = this.data.meta[i];
}
else {
obj.light = light.color.join(',');
}
arr.push(obj);
}
return arr;
}
/**
* Method which compiles script if needs and then runs as a sequence.
**/
run() {
const data = this.editor.getValue();
let arr;
let cont = false;
if (data !== this.raw) {
cont = confirm(`Current script has not been compiled. Compile first?`);
if (cont) {
this.compile();
}
}
arr = this.prepare();
mse.console.print(`Started running compiled sequence...`);
gui.overlay(true);
gui.spinner(true, `Running mscript sequence...`, true, true);
return seq.exec(arr, 1);
}
}
mse.mscript.compile = function () {
'use strict';
const data = mse.mscript.editor.getValue();
const mscript = new Mscript();
let output = mscript.interpret(data);
let len = output.arr.length;
mse.mscript.raw = data;
mse.mscript.data = output;
//mse.console.print(JSON.stringify(output, null, '\t') + '\n')
mse.console.print(`Sequence contains ${len} step${(len === 1 ? '' : 's')}, CAM: ${output.cam}, PROJ: ${output.proj}`);
};
mse.mscript.prepare = function () {
'use strict';
const arr = [];
let obj;
for (let i = 0; i < mse.mscript.data.arr.length; i++) {
obj = {
cmd : mse.mscript.data.arr[i]
};
if (typeof mse.mscript.data.meta[i] !== 'undefined' && mse.mscript.data.meta[i] !== '') {
obj.light = mse.mscript.data.meta[i];
} else {
obj.light = light.color.join(',');
}
arr.push(obj);
}
return arr;
};
mse.mscript.run = function () {
'use strict';
const data = mse.mscript.editor.getValue();
let arr;
let cont;
if (data !== mse.mscript.raw) {
cont = confirm(`Current script has not been compiled. Compile first?`);
if (cont) {
mse.mscript.compile();
}
}
arr = mse.mscript.prepare();
mse.console.print(`Started running compiled sequence...`);
gui.overlay(true);
gui.spinner(true, `Running mscript sequence...`, true, true);
return seq.exec(arr, 1);
};
/*******
* gui console
* Mscript GUI Console
*******/
mse.console = {};
mse.console.elem = {};
mse.console.init = function () {
'use script';
mse.console.elem = $('#console textarea');
mse.console.elem.on('keyup', function (e) {
var code = e.keyCode || e.which;
if (code === 13) {
mse.console.exec();
e.preventDefault();
return false;
}
});
class MscriptConsole {
/**
* Initializes the console by creating the element
* containing the output text and binding to
* keyup event.
**/
init() {
this.elem = $('#console textarea');
this.elem.on('keyup', function (e) {
var code = e.keyCode || e.which;
if (code === 13) {
this.exec();
e.preventDefault();
return false;
}
}.bind(this));
}
/**
* Parse the current state of the console and get the last
* line to add to the current state array.
**/
parse() {
const lines = (this.elem.val() + '').split('\n');
const line = lines[lines.length - 2].replace('>', '').trim();
this.lines.push(line);
}
/**
* Executes the command in the last line of the console.
* TODO: implement the remaining commands. Currently only camera
* forward and backward will be executed.
**/
exec() {
let command;
this.parse();
command = this.lines[this.lines.length - 1].replace('>', '').trim();
log.info(command);
this.newLine();
if (mscript.cmd.indexOf(command) !== -1) {
if (command === 'CF') {
cmd.camera_forward(light.color);
}
else if (cmd === 'CB') {
cmd.camera_backward(light.color);
}
}
if (command === 'compile') {
mse.mscript.compile();
}
else if (command === 'run') {
mse.mscript.run();
}
}
/**
* Adds a new line to the console after an event
* and re-establishes the height of the array. Animates
* the console to scroll down to last line.
**/
newLine() {
let current = (this.elem.val() + '');
let height;
current += '> ';
this.elem.val(current);
height = this.elem[0].scrollHeight;
this.elem.animate({
scrollTop: height
}, 'normal');
}
/**
* Print string to the console and add new line
**/
print(str) {
let current = (this.elem.val() + '');
let height;
current += str;
current += '\n';
mse.console.elem.val(current);
mse.console.elem.focus();
this.newLine();
}
}
const mse = {
mscript: new MscriptGUI(),
console: new MscriptConsole()
};
mse.console.lines = [];
mse.console.parse = function () {
'use strict';
const lines = mse.console.elem.val().split('\n');
const line = lines[lines.length - 2].replace('>', '').trim();
mse.console.lines.push(line);
};
mse.console.exec = function () {
'use strict';
let command;
mse.console.parse();
command = mse.console.lines[mse.console.lines.length - 1].replace('>', '').trim();
log.info(command);
mse.console.newLine();
if (mscript.cmd.indexOf(command) !== -1) {
if (command === 'CF') {
cmd.camera_forward(light.color);
} else if (cmd === 'CB') {
cmd.camera_backward(light.color);
}
}
if (command === 'compile') {
mse.mscript.compile();
} else if (command === 'run') {
mse.mscript.run();
}
};
mse.console.newLine = function () {
'use strict';
let current = mse.console.elem.val();
let height;
current += '> ';
mse.console.elem.val(current);
height = mse.console.elem[0].scrollHeight;
mse.console.elem.animate({
scrollTop : height
},'normal');
};
mse.console.print = function (str) {
'use strict'
let current = mse.console.elem.val();
let height;
current += str;
current += '\n> ';
mse.console.elem.val(current);
mse.console.elem.focus();
height = mse.console.elem[0].scrollHeight;
mse.console.elem.animate({
scrollTop : height
},'normal');
};
module.exports = mse;
module.exports = mse;
//# sourceMappingURL=mscript.js.map

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