Got UI working again.
This commit is contained in:
parent
339303c0c2
commit
26e3428fa8
|
@ -3037,15 +3037,16 @@ PB - Projector backwards
|
||||||
BB - Black backwards
|
BB - Black backwards
|
||||||
|
|
||||||
*/
|
*/
|
||||||
var remote = require('remote'),
|
|
||||||
|
var mcopy = {};
|
||||||
|
|
||||||
|
var { remote, ipcRenderer } = require('electron'),
|
||||||
dialog = require('electron').remote.dialog,
|
dialog = require('electron').remote.dialog,
|
||||||
notifier = require('node-notifier'),
|
notifier = require('node-notifier'),
|
||||||
fs = require('fs'),
|
fs = require('fs'),
|
||||||
uuid = require('uuid'),
|
uuid = require('uuid'),
|
||||||
moment = require('moment'),
|
moment = require('moment'),
|
||||||
humanizeDuration = require('humanize-duration')
|
humanizeDuration = require('humanize-duration')
|
||||||
ipcRenderer = require('electron').ipcRenderer,
|
|
||||||
mcopy = {},
|
|
||||||
light = require('./lib/light-ui.js'),
|
light = require('./lib/light-ui.js'),
|
||||||
proj = require('./lib/proj-ui.js'),
|
proj = require('./lib/proj-ui.js'),
|
||||||
cam = require('./lib/cam-ui.js'),
|
cam = require('./lib/cam-ui.js'),
|
||||||
|
@ -3056,7 +3057,7 @@ var remote = require('remote'),
|
||||||
log = require('./lib/log-ui.js'),
|
log = require('./lib/log-ui.js'),
|
||||||
devices = require('./lib/devices-ui.js'),
|
devices = require('./lib/devices-ui.js'),
|
||||||
mscript = require('./lib/mscript.js');
|
mscript = require('./lib/mscript.js');
|
||||||
//console.log(ipcRenderer.sendSync('light', { 'fuck' : true }) );
|
|
||||||
|
|
||||||
mcopy.cfg = JSON.parse(fs.readFileSync('./data/cfg.json'), 'utf8');
|
mcopy.cfg = JSON.parse(fs.readFileSync('./data/cfg.json'), 'utf8');
|
||||||
|
|
||||||
|
|
103
app/main.js
103
app/main.js
|
@ -1,32 +1,31 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
var electron = require('electron'),
|
const electron = require('electron')
|
||||||
Menu = electron.Menu,
|
const { Menu, MenuItem, ipcMain, BrowserWindow, app } = require('electron')
|
||||||
MenuItem = electron.MenuItem,
|
const fs = require('fs')
|
||||||
ipcMain = electron.ipcMain,
|
const winston = require('winston')
|
||||||
BrowserWindow = electron.BrowserWindow,
|
const moment = require('moment')
|
||||||
app = electron.app,
|
const uuid = require('uuid')
|
||||||
fs = require('fs'),
|
const Q = require('q')
|
||||||
winston = require('winston'),
|
const events = require('events')
|
||||||
moment = require('moment'),
|
const ee = new events.EventEmitter()
|
||||||
uuid = require('uuid'),
|
const capture = require('./lib/capture-report.js')(ee)
|
||||||
Q = require('q'),
|
|
||||||
events = require('events'),
|
const mcopy = {}
|
||||||
ee = new events.EventEmitter(),
|
|
||||||
mcopy = {},
|
|
||||||
mainWindow,
|
|
||||||
mscript,
|
|
||||||
arduino,
|
|
||||||
projector,
|
|
||||||
camera,
|
|
||||||
capture = require('./lib/capture-report.js')(ee),
|
|
||||||
log = {};
|
|
||||||
|
|
||||||
console.log(process.version);
|
let mainWindow
|
||||||
|
let mscript
|
||||||
|
let arduino
|
||||||
|
let projector
|
||||||
|
let camera
|
||||||
|
let log = {}
|
||||||
|
|
||||||
mcopy.cfg = {};
|
console.log(process.version)
|
||||||
mcopy.cfgFile = './data/cfg.json';
|
|
||||||
|
mcopy.cfg = {}
|
||||||
|
mcopy.cfgFile = './data/cfg.json'
|
||||||
mcopy.cfgInit = function () {
|
mcopy.cfgInit = function () {
|
||||||
'use strict';
|
|
||||||
if (!fs.existsSync(mcopy.cfgFile)) {
|
if (!fs.existsSync(mcopy.cfgFile)) {
|
||||||
console.log('Using default configuration...');
|
console.log('Using default configuration...');
|
||||||
fs.writeFileSync(mcopy.cfgFile, fs.readFileSync('./data/cfg.json.default'));
|
fs.writeFileSync(mcopy.cfgFile, fs.readFileSync('./data/cfg.json.default'));
|
||||||
|
@ -34,13 +33,13 @@ mcopy.cfgInit = function () {
|
||||||
mcopy.cfg = JSON.parse(fs.readFileSync(mcopy.cfgFile, 'utf8'));
|
mcopy.cfg = JSON.parse(fs.readFileSync(mcopy.cfgFile, 'utf8'));
|
||||||
};
|
};
|
||||||
mcopy.cfgStore = function () {
|
mcopy.cfgStore = function () {
|
||||||
'use strict';
|
|
||||||
var data = JSON.stringify(mcopy.cfg);
|
var data = JSON.stringify(mcopy.cfg);
|
||||||
fs.writeFileSync(mcopy.cfgFile, data, 'utf8');
|
fs.writeFileSync(mcopy.cfgFile, data, 'utf8');
|
||||||
};
|
};
|
||||||
|
|
||||||
var enumerateDevices = function (err, devices) {
|
var enumerateDevices = function (err, devices) {
|
||||||
'use strict';
|
|
||||||
if (err) {
|
if (err) {
|
||||||
log.info(err, 'SERIAL', false, true);
|
log.info(err, 'SERIAL', false, true);
|
||||||
arduino.fakeConnect('projector', function () {
|
arduino.fakeConnect('projector', function () {
|
||||||
|
@ -57,7 +56,7 @@ var enumerateDevices = function (err, devices) {
|
||||||
};
|
};
|
||||||
|
|
||||||
var distinguishDevice = function (device, callback) {
|
var distinguishDevice = function (device, callback) {
|
||||||
'use strict';
|
|
||||||
var connectCb = function (err, device) {
|
var connectCb = function (err, device) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return console.error(err);
|
return console.error(err);
|
||||||
|
@ -85,7 +84,7 @@ var distinguishDevice = function (device, callback) {
|
||||||
|
|
||||||
//Cases for 1 or 2 arduinos connected
|
//Cases for 1 or 2 arduinos connected
|
||||||
var distinguishDevices = function (devices) {
|
var distinguishDevices = function (devices) {
|
||||||
'use strict';
|
|
||||||
var distinguishOne = function (err, type) {
|
var distinguishOne = function (err, type) {
|
||||||
arduino.close(function () {
|
arduino.close(function () {
|
||||||
if (type === 'projector') {
|
if (type === 'projector') {
|
||||||
|
@ -133,7 +132,7 @@ var distinguishDevices = function (devices) {
|
||||||
};
|
};
|
||||||
|
|
||||||
var devicesReady = function (camera, projector) {
|
var devicesReady = function (camera, projector) {
|
||||||
'use strict';
|
|
||||||
mainWindow.webContents.send('ready', {camera: camera, projector: projector });
|
mainWindow.webContents.send('ready', {camera: camera, projector: projector });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -267,7 +266,7 @@ var createMenu = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
var createWindow = function () {
|
var createWindow = function () {
|
||||||
'use strict';
|
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
|
@ -283,18 +282,18 @@ var createWindow = function () {
|
||||||
|
|
||||||
var light = {};
|
var light = {};
|
||||||
light.init = function () {
|
light.init = function () {
|
||||||
'use strict';
|
|
||||||
light.listen();
|
light.listen();
|
||||||
};
|
};
|
||||||
light.listen = function () {
|
light.listen = function () {
|
||||||
'use strict';
|
|
||||||
ipcMain.on('light', function(event, arg) {
|
ipcMain.on('light', function(event, arg) {
|
||||||
light.set(arg.rgb, arg.id);
|
light.set(arg.rgb, arg.id);
|
||||||
event.returnValue = true;
|
event.returnValue = true;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
light.set = function (rgb, id) {
|
light.set = function (rgb, id) {
|
||||||
'use strict';
|
|
||||||
var str = rgb.join(',');
|
var str = rgb.join(',');
|
||||||
arduino.send('projector', mcopy.cfg.arduino.cmd.light, function (ms) {
|
arduino.send('projector', mcopy.cfg.arduino.cmd.light, function (ms) {
|
||||||
light.end(rgb, id, ms);
|
light.end(rgb, id, ms);
|
||||||
|
@ -302,7 +301,7 @@ light.set = function (rgb, id) {
|
||||||
arduino.string('projector', str);
|
arduino.string('projector', str);
|
||||||
};
|
};
|
||||||
light.end = function (rgb, id, ms) {
|
light.end = function (rgb, id, ms) {
|
||||||
'use strict';
|
|
||||||
log.info('Light set to ' + rgb.join(','), 'LIGHT', true, true);
|
log.info('Light set to ' + rgb.join(','), 'LIGHT', true, true);
|
||||||
mainWindow.webContents.send('light', {rgb: rgb, id : id, ms: ms});
|
mainWindow.webContents.send('light', {rgb: rgb, id : id, ms: ms});
|
||||||
};
|
};
|
||||||
|
@ -312,11 +311,11 @@ proj.state = {
|
||||||
dir : true //default dir
|
dir : true //default dir
|
||||||
};
|
};
|
||||||
proj.init = function () {
|
proj.init = function () {
|
||||||
'use strict';
|
|
||||||
proj.listen();
|
proj.listen();
|
||||||
};
|
};
|
||||||
proj.set = function (dir, id) {
|
proj.set = function (dir, id) {
|
||||||
'use strict';
|
|
||||||
var cmd;
|
var cmd;
|
||||||
if (dir) {
|
if (dir) {
|
||||||
cmd = mcopy.cfg.arduino.cmd.proj_forward;
|
cmd = mcopy.cfg.arduino.cmd.proj_forward;
|
||||||
|
@ -329,13 +328,13 @@ proj.set = function (dir, id) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
proj.move = function (frame, id) {
|
proj.move = function (frame, id) {
|
||||||
'use strict';
|
|
||||||
arduino.send('projector', mcopy.cfg.arduino.cmd.projector, function (ms) {
|
arduino.send('projector', mcopy.cfg.arduino.cmd.projector, function (ms) {
|
||||||
proj.end(mcopy.cfg.arduino.cmd.projector, id, ms);
|
proj.end(mcopy.cfg.arduino.cmd.projector, id, ms);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
proj.listen = function () {
|
proj.listen = function () {
|
||||||
'use strict';
|
|
||||||
ipcMain.on('proj', function (event, arg) {
|
ipcMain.on('proj', function (event, arg) {
|
||||||
if (typeof arg.dir !== 'undefined') {
|
if (typeof arg.dir !== 'undefined') {
|
||||||
proj.set(arg.dir, arg.id);
|
proj.set(arg.dir, arg.id);
|
||||||
|
@ -346,7 +345,7 @@ proj.listen = function () {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
proj.end = function (cmd, id, ms) {
|
proj.end = function (cmd, id, ms) {
|
||||||
'use strict';
|
|
||||||
var message = '';
|
var message = '';
|
||||||
if (cmd === mcopy.cfg.arduino.cmd.proj_forward) {
|
if (cmd === mcopy.cfg.arduino.cmd.proj_forward) {
|
||||||
message = 'Projector set to FORWARD';
|
message = 'Projector set to FORWARD';
|
||||||
|
@ -370,11 +369,11 @@ cam.state = {
|
||||||
dir : true //default dir
|
dir : true //default dir
|
||||||
};
|
};
|
||||||
cam.init = function () {
|
cam.init = function () {
|
||||||
'use strict';
|
|
||||||
cam.listen();
|
cam.listen();
|
||||||
};
|
};
|
||||||
cam.set = function (dir, id) {
|
cam.set = function (dir, id) {
|
||||||
'use strict';
|
|
||||||
var cmd;
|
var cmd;
|
||||||
if (dir) {
|
if (dir) {
|
||||||
cmd = mcopy.cfg.arduino.cmd.cam_forward;
|
cmd = mcopy.cfg.arduino.cmd.cam_forward;
|
||||||
|
@ -387,13 +386,13 @@ cam.set = function (dir, id) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
cam.move = function (frame, id) {
|
cam.move = function (frame, id) {
|
||||||
'use strict';
|
|
||||||
arduino.send('camera', mcopy.cfg.arduino.cmd.camera, function (ms) {
|
arduino.send('camera', mcopy.cfg.arduino.cmd.camera, function (ms) {
|
||||||
cam.end(mcopy.cfg.arduino.cmd.camera, id, ms);
|
cam.end(mcopy.cfg.arduino.cmd.camera, id, ms);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
cam.listen = function () {
|
cam.listen = function () {
|
||||||
'use strict';
|
|
||||||
ipcMain.on('cam', function (event, arg) {
|
ipcMain.on('cam', function (event, arg) {
|
||||||
if (typeof arg.dir !== 'undefined') {
|
if (typeof arg.dir !== 'undefined') {
|
||||||
cam.set(arg.dir, arg.id);
|
cam.set(arg.dir, arg.id);
|
||||||
|
@ -404,7 +403,7 @@ cam.listen = function () {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
cam.end = function (cmd, id, ms) {
|
cam.end = function (cmd, id, ms) {
|
||||||
'use strict';
|
|
||||||
var message = '';
|
var message = '';
|
||||||
if (cmd === mcopy.cfg.arduino.cmd.cam_forward) {
|
if (cmd === mcopy.cfg.arduino.cmd.cam_forward) {
|
||||||
message = 'Camera set to FORWARD';
|
message = 'Camera set to FORWARD';
|
||||||
|
@ -431,22 +430,22 @@ log.transport = new (winston.Logger)({
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
log.init = function () {
|
log.init = function () {
|
||||||
'use strict';
|
|
||||||
log.listen();
|
log.listen();
|
||||||
};
|
};
|
||||||
log.display = function (obj) {
|
log.display = function (obj) {
|
||||||
'use strict';
|
|
||||||
mainWindow.webContents.send('log', obj);
|
mainWindow.webContents.send('log', obj);
|
||||||
};
|
};
|
||||||
log.listen = function () {
|
log.listen = function () {
|
||||||
'use strict';
|
|
||||||
ipcMain.on('log', function (event, arg) {
|
ipcMain.on('log', function (event, arg) {
|
||||||
log.transport.info('renderer', arg);
|
log.transport.info('renderer', arg);
|
||||||
event.returnValue = true;
|
event.returnValue = true;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
log.info = function (action, service, status, display) {
|
log.info = function (action, service, status, display) {
|
||||||
'use strict';
|
|
||||||
var obj = {
|
var obj = {
|
||||||
time : moment().format(log.time),
|
time : moment().format(log.time),
|
||||||
action : action,
|
action : action,
|
||||||
|
@ -462,11 +461,11 @@ log.info = function (action, service, status, display) {
|
||||||
var transfer = {};
|
var transfer = {};
|
||||||
|
|
||||||
transfer.init = function () {
|
transfer.init = function () {
|
||||||
'use strict';
|
|
||||||
transfer.listen();
|
transfer.listen();
|
||||||
};
|
};
|
||||||
transfer.listen = function () {
|
transfer.listen = function () {
|
||||||
'use strict';
|
|
||||||
ipcMain.on('transfer', function (event, arg) {
|
ipcMain.on('transfer', function (event, arg) {
|
||||||
var res = '';
|
var res = '';
|
||||||
//also turn on and off
|
//also turn on and off
|
||||||
|
@ -486,7 +485,7 @@ transfer.listen = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
var init = function () {
|
var init = function () {
|
||||||
'use strict';
|
|
||||||
mcopy.cfgInit();
|
mcopy.cfgInit();
|
||||||
createWindow();
|
createWindow();
|
||||||
//createMenu();
|
//createMenu();
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
var remote = require('remote'),
|
|
||||||
|
var mcopy = {};
|
||||||
|
|
||||||
|
var { remote, ipcRenderer } = require('electron'),
|
||||||
dialog = require('electron').remote.dialog,
|
dialog = require('electron').remote.dialog,
|
||||||
notifier = require('node-notifier'),
|
notifier = require('node-notifier'),
|
||||||
fs = require('fs'),
|
fs = require('fs'),
|
||||||
uuid = require('uuid'),
|
uuid = require('uuid'),
|
||||||
moment = require('moment'),
|
moment = require('moment'),
|
||||||
humanizeDuration = require('humanize-duration')
|
humanizeDuration = require('humanize-duration')
|
||||||
ipcRenderer = require('electron').ipcRenderer,
|
|
||||||
mcopy = {},
|
|
||||||
light = require('./lib/light-ui.js'),
|
light = require('./lib/light-ui.js'),
|
||||||
proj = require('./lib/proj-ui.js'),
|
proj = require('./lib/proj-ui.js'),
|
||||||
cam = require('./lib/cam-ui.js'),
|
cam = require('./lib/cam-ui.js'),
|
||||||
|
@ -17,7 +18,7 @@ var remote = require('remote'),
|
||||||
log = require('./lib/log-ui.js'),
|
log = require('./lib/log-ui.js'),
|
||||||
devices = require('./lib/devices-ui.js'),
|
devices = require('./lib/devices-ui.js'),
|
||||||
mscript = require('./lib/mscript.js');
|
mscript = require('./lib/mscript.js');
|
||||||
//console.log(ipcRenderer.sendSync('light', { 'fuck' : true }) );
|
|
||||||
|
|
||||||
mcopy.cfg = JSON.parse(fs.readFileSync('./data/cfg.json'), 'utf8');
|
mcopy.cfg = JSON.parse(fs.readFileSync('./data/cfg.json'), 'utf8');
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue