From d56eba3997e0c6f381fb87fe812af3638298a4de Mon Sep 17 00:00:00 2001 From: mcmcgrath13 Date: Mon, 11 Nov 2019 17:30:56 -0500 Subject: [PATCH 1/2] feat: pull EVENT_MARKER_PRODUCT_ID from env if available --- public/config/trigger.js | 2 ++ public/electron.js | 6 +++++- src/config/trigger.js | 7 +------ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/public/config/trigger.js b/public/config/trigger.js index 480e024..7942816 100644 --- a/public/config/trigger.js +++ b/public/config/trigger.js @@ -7,6 +7,8 @@ const productId = '0487' // Make sure the 'open_resting_task' value doesn't conflict with any value sent // by any other task, since we use it to uniquely identify this task. It's ok // for other values to be re-used in other tasks. + +// NOTE - these must match the codes in src/config/trigger.js const eventCodes = { 'test_connect': 32, 'open_task': 12, diff --git a/public/electron.js b/public/electron.js index ae3d252..5730cf7 100644 --- a/public/electron.js +++ b/public/electron.js @@ -16,6 +16,10 @@ const { eventCodes, manufacturer, vendorId, productId } = require('./config/trig const { isPort, getPort, sendToPort } = require('event-marker') log.info(AT_HOME) +// Override product ID if environment variable set +const activeProductId = process.env.EVENT_MARKER_PRODUCT_ID || productId +log.info("Active product ID", activeProductId) + // Data Saving const { dataDir } = require('./config/saveData') @@ -80,7 +84,7 @@ let portAvailable let SKIP_SENDING_DEV = false const setUpPort = async () => { - p = await getPort(vendorId, productId) + p = await getPort(vendorId, activeProductId) if (p) { triggerPort = p portAvailable = true diff --git a/src/config/trigger.js b/src/config/trigger.js index 787e8f6..bf35dec 100644 --- a/src/config/trigger.js +++ b/src/config/trigger.js @@ -1,8 +1,6 @@ // Event trigger settings - used in both the react app (renderer) and the electron app (main) -const manufacturer = 'Teensyduino' -const vendorId = '16c0' -const productId = '0483' +// NOTE - these must match the codes in public/config/trigger.js const eventCodes = { 'test_connect': 32, 'open_task': 12, @@ -27,8 +25,5 @@ const eventCodes = { // this is module.exports isntead of just exports as it is also imported into the electron app module.exports = { - manufacturer, - vendorId, - productId, eventCodes } From 0be93243a8faf21705c570bad4c69ee1f1fd5b67 Mon Sep 17 00:00:00 2001 From: mcmcgrath13 Date: Mon, 11 Nov 2019 17:35:11 -0500 Subject: [PATCH 2/2] docs: update electron oriented docs --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 049bbeb..86f1026 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,16 @@ The `package-lock.json` contains metadata about the package installation. It sho The `public` directory contains files that are used as assets in the built app. The `favicon.ico` is the small icon you can see in the browser tab (on Chrome) - it is set to Brown's logo in the project. The `index.html` contains the shell of your website - the name displayed on the tab can be changed here, otherwise it shouldn't need to be edited. The scripts included in the file are for `psiturk` as are the files in the `lib/` directory. +#### `electron.js` + +This file contains all of the code relating to the electron app. This includes the event-marker, throwing errors via dialog windows, saving data, and reading files. + +#### `config/` + +The `config` directory contains the config files needed for the electron app. This includes the event-marker details and event codes. + +Note: the productId can be overwritten by the environment variable EVENT_MARKER_PRODUCT_ID + ### `src/` This folder contains the code for the app, the vast majority of changes and code should go here.