From cdd14b9ed568e28f9d89b1a44d969e33db30eb7e Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 21 Jun 2016 11:05:44 -0400 Subject: [PATCH] Restructure main script --- app/main.js | 78 ++++++++++++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 37 deletions(-) diff --git a/app/main.js b/app/main.js index 13bbef2..b9de53a 100644 --- a/app/main.js +++ b/app/main.js @@ -4,17 +4,20 @@ var electron = require('electron'), MenuItem = require('menu-item'), ipcMain = require('electron').ipcMain, app = electron.app, - BrowserWindow = electron.BrowserWindow, - uuid = require('node-uuid'), winston = require('winston'), moment = require('moment'), + BrowserWindow = electron.BrowserWindow, + uuid = require('node-uuid'), Q = require('q'), + events = require('events'), mcopy = {}, mainWindow, mscript, arduino, projector, - camera; + camera, + capture = require('./lib/capture-report.js'), + log = {}; mcopy.cfg = {}; mcopy.cfgFile = './data/cfg.json'; @@ -32,24 +35,6 @@ mcopy.cfgStore = function () { fs.writeFileSync(mcopy.cfgFile, data, 'utf8'); }; -var init = function () { - 'use strict'; - mcopy.cfgInit(); - createWindow(); - //createMenu(); - log.init(); - light.init(); - proj.init(); - cam.init(); - - arduino = require('./lib/mcopy-arduino.js')(mcopy.cfg); - mscript = require('./lib/mscript.js'); - - setTimeout(function () { - arduino.enumerate(enumerateDevices); - }, 1000); -}; - var enumerateDevices = function (err, devices) { 'use strict'; if (err) { @@ -292,20 +277,6 @@ var createWindow = function () { }); } -app.on('ready', init); - -app.on('window-all-closed', function () { - //if (process.platform !== 'darwin') { - app.quit(); - //} -}); - -app.on('activate', function () { - if (mainWindow === null) { - createWindow(); - } -}); - var light = {}; light.init = function () { 'use strict'; @@ -448,7 +419,6 @@ cam.end = function (cmd, id, ms) { mainWindow.webContents.send('cam', {cmd: cmd, id : id, ms: ms}); }; -var log = {}; log.time = 'MM/DD/YY-HH:mm:ss'; log.transport = new (winston.Logger)({ transports: [ @@ -483,4 +453,38 @@ log.info = function (action, service, status, display) { if (display) { log.display(obj); } -}; \ No newline at end of file +}; + +var init = function () { + 'use strict'; + mcopy.cfgInit(); + createWindow(); + //createMenu(); + log.init(); + light.init(); + proj.init(); + cam.init(); + + capture.init(); + + arduino = require('./lib/mcopy-arduino.js')(mcopy.cfg); + mscript = require('./lib/mscript.js'); + + setTimeout(function () { + arduino.enumerate(enumerateDevices); + }, 1000); +}; + +app.on('ready', init); + +app.on('window-all-closed', function () { + //if (process.platform !== 'darwin') { + app.quit(); + //} +}); + +app.on('activate', function () { + if (mainWindow === null) { + createWindow(); + } +});