diff --git a/package.json b/package.json index 8dd1078bc..56a5522d4 100644 --- a/package.json +++ b/package.json @@ -125,16 +125,16 @@ ], "dependencies": { "@trendmicro/react-anchor": "~0.5.5", - "@trendmicro/react-breadcrumbs": "~0.5.3", + "@trendmicro/react-breadcrumbs": "~0.5.4", "@trendmicro/react-buttons": "~1.1.0", - "@trendmicro/react-dropdown": "~0.6.13", + "@trendmicro/react-dropdown": "~0.6.14", "@trendmicro/react-interpolate": "~0.5.3", - "@trendmicro/react-modal": "~0.7.1", - "@trendmicro/react-navs": "~0.9.0", - "@trendmicro/react-paginations": "~0.5.10", - "@trendmicro/react-table": "~0.5.4", - "@trendmicro/react-toggle-switch": "~0.5.4", - "async": "~2.4.1", + "@trendmicro/react-modal": "~0.7.4", + "@trendmicro/react-navs": "~0.9.2", + "@trendmicro/react-paginations": "~0.6.0", + "@trendmicro/react-table": "~0.5.6", + "@trendmicro/react-toggle-switch": "~0.5.5", + "async": "~2.5.0", "babel-runtime": "~6.23.0", "bcrypt-nodejs": "0.0.3", "body-parser": "~1.17.2", @@ -143,7 +143,7 @@ "classnames": "~2.2.5", "clusterize.js": "~0.17.6", "colornames": "~1.1.1", - "commander": "~2.9.0", + "commander": "~2.10.0", "compression": "~1.6.2", "connect-multiparty": "~2.0.0", "connect-restreamer": "~1.0.3", @@ -207,7 +207,7 @@ "react-sortablejs": "~1.3.4", "react-toggle": "~4.0.1", "react-validation": "~2.10.9", - "redux": "~3.7.0", + "redux": "~3.7.1", "registry-auth-token": "~3.3.1", "registry-url": "~3.1.0", "rimraf": "~2.6.1", @@ -239,7 +239,7 @@ "babel-cli": "~6.24.1", "babel-core": "~6.25.0", "babel-eslint": "~7.2.3", - "babel-loader": "~7.1.0", + "babel-loader": "~7.1.1", "babel-plugin-transform-decorators-legacy": "~1.3.4", "babel-plugin-transform-proto-to-assign": "~6.23.0", "babel-plugin-transform-runtime": "~6.23.0", @@ -257,7 +257,7 @@ "electron-rebuild": "~1.5.11", "eslint": "~3.19.0", "eslint-config-trendmicro": "~0.5.1", - "eslint-import-resolver-webpack": "~0.8.1", + "eslint-import-resolver-webpack": "~0.8.3", "eslint-loader": "~1.7.1", "eslint-plugin-import": "~2.3.0", "eslint-plugin-jsx-a11y": "~2.2.3", @@ -273,7 +273,7 @@ "gulp-sort": "~2.0.0", "gulp-util": "~3.0.8", "html-webpack-inline-chunk-plugin": "~1.1.1", - "html-webpack-plugin": "~2.28.0", + "html-webpack-plugin": "~2.29.0", "html-webpack-plugin-addons": "~0.1.1", "i18next-scanner": "~1.8.0", "imports-loader": "~0.7.1", @@ -293,11 +293,11 @@ "stylint-loader": "~1.0.0", "stylus": "~0.54.5", "stylus-loader": "~3.0.1", - "tap": "~10.5.1", + "tap": "~10.7.0", "text-table": "~0.2.0", "transform-loader": "~0.2.4", "url-loader": "~0.5.9", - "webpack": "~3.0.0", + "webpack": "~2.6.1", "webpack-dev-middleware": "~1.11.0", "webpack-dev-server": "~2.5.0", "webpack-hot-middleware": "~2.18.0", diff --git a/src/app/controllers/TinyG/TinyGController.js b/src/app/controllers/TinyG/TinyGController.js index 9372b585d..5197f3e6f 100644 --- a/src/app/controllers/TinyG/TinyGController.js +++ b/src/app/controllers/TinyG/TinyGController.js @@ -74,10 +74,15 @@ class TinyGController { ready = false; state = {}; settings = {}; - queryTimer = null; + timer = { + query: null, + energizeMotors: null + }; + energizeMotorsTimer = null; blocked = false; sendResponseState = SEND_RESPONSE_STATE_NONE; actionTime = { + energizeMotors: 0, senderFinishTime: 0 }; @@ -93,10 +98,6 @@ class TinyGController { // Workflow workflow = null; - // Power Management - motorEnergizeTimer = null; - motorEnergizeTimeout = null; - dataFilter = (line, context) => { // Machine position const { @@ -412,8 +413,8 @@ class TinyGController { } }); - // Timer - this.queryTimer = setInterval(() => { + // Query Timer + this.timer.query = setInterval(() => { if (this.isClose()) { // Serial port is closed return; @@ -574,6 +575,7 @@ class TinyGController { sendInitCommands(); } clearActionValues() { + this.actionTime.energizeMotors = 0; this.actionTime.senderFinishTime = 0; } destroy() { @@ -599,9 +601,14 @@ class TinyGController { this.workflow = null; } - if (this.queryTimer) { - clearInterval(this.queryTimer); - this.queryTimer = null; + if (this.timer.query) { + clearInterval(this.timer.query); + this.timer.query = null; + } + + if (this.timer.energizeMotors) { + clearInterval(this.timer.energizeMotors); + this.timer.energizeMotors = null; } if (this.controller) { @@ -945,48 +952,40 @@ class TinyGController { this.command(socket, 'gcode', '{mto:0.25}'); } }, - 'motor:energize': () => { + 'energizeMotors:on': () => { const { mt = 0 } = this.state; - if (this.motorEnergizeTimer || !mt) { + if (this.timer.energizeMotors || !mt) { return; } this.command(socket, 'gcode', '{me:0}'); this.command(socket, 'gcode', '{pwr:n}'); - // Setup a timer to keep motors energized indefinitely - this.motorEnergizeTimer = setInterval(() => { - this.command(socket, 'gcode', '{me:0}'); - this.command(socket, 'gcode', '{pwr:n}'); - }, mt * 1000 - 500); - - // Set a timeout value so the motors will not run longer than 30 minutes - if (this.motorEnergizeTimeout) { - clearTimeout(this.motorEnergizeTimeout); - this.motorEnergizeTimeout = null; - } - this.motorEnergizeTimeout = setTimeout(() => { - this.motorEnergizeTimeout = null; + // Setup a timer to energize motors up to 30 minutes + this.timer.energizeMotors = setInterval(() => { + const now = new Date().getTime(); + if (this.actionTime.energizeMotors <= 0) { + this.actionTime.energizeMotors = now; + } - if (this.motorEnergizeTimer) { - clearInterval(this.motorEnergizeTimer); - this.motorEnergizeTimer = null; + const timespan = Math.abs(now - this.actionTime.energizeMotors); + const toleranceTime = 30 * 60 * 1000; // 30 minutes + if (timespan > toleranceTime) { + this.command(socket, 'energizeMotors:off'); + return; } - this.command(socket, 'gcode', '{md:0}'); + this.command(socket, 'gcode', '{me:0}'); this.command(socket, 'gcode', '{pwr:n}'); - }, 30 * 60 * 1000); + }, mt * 1000 - 500); }, - 'motor:deenergize': () => { - if (this.motorEnergizeTimer) { - clearInterval(this.motorEnergizeTimer); - this.motorEnergizeTimer = null; - } - if (this.motorEnergizeTimeout) { - clearTimeout(this.motorEnergizeTimeout); - this.motorEnergizeTimeout = null; + 'energizeMotors:off': () => { + if (this.timer.energizeMotors) { + clearInterval(this.timer.energizeMotors); + this.timer.energizeMotors = null; } + this.actionTime.energizeMotors = 0; this.command(socket, 'gcode', '{md:0}'); this.command(socket, 'gcode', '{pwr:n}'); diff --git a/src/package.json b/src/package.json index 1a1a99307..693862066 100644 --- a/src/package.json +++ b/src/package.json @@ -15,7 +15,7 @@ "bcrypt-nodejs": "0.0.3", "body-parser": "~1.17.2", "chalk": "~1.1.3", - "commander": "~2.9.0", + "commander": "~2.10.0", "compression": "~1.6.2", "connect-multiparty": "~2.0.0", "connect-restreamer": "~1.0.3", diff --git a/src/web/i18n/cs/resource.json b/src/web/i18n/cs/resource.json index 764dfb798..46d01ffbe 100644 --- a/src/web/i18n/cs/resource.json +++ b/src/web/i18n/cs/resource.json @@ -349,7 +349,6 @@ "Show All Settings": "", "List Self Tests": "", "Power Management": "", - "Motor Timeout: {{mt}} sec": "", "Enable Motors": "", "Disable Motors": "", "Motor {{n}}": "", diff --git a/src/web/i18n/de/resource.json b/src/web/i18n/de/resource.json index 237a12788..c4449324c 100644 --- a/src/web/i18n/de/resource.json +++ b/src/web/i18n/de/resource.json @@ -349,7 +349,6 @@ "Show All Settings": "", "List Self Tests": "", "Power Management": "", - "Motor Timeout: {{mt}} sec": "", "Enable Motors": "", "Disable Motors": "", "Motor {{n}}": "", diff --git a/src/web/i18n/en/resource.json b/src/web/i18n/en/resource.json index 5000e237e..f8c2dfc08 100644 --- a/src/web/i18n/en/resource.json +++ b/src/web/i18n/en/resource.json @@ -349,7 +349,6 @@ "Show All Settings": "Show All Settings", "List Self Tests": "List Self Tests", "Power Management": "Power Management", - "Motor Timeout: {{mt}} sec": "Motor Timeout: {{mt}} sec", "Enable Motors": "Enable Motors", "Disable Motors": "Disable Motors", "Motor {{n}}": "Motor {{n}}", diff --git a/src/web/i18n/es/resource.json b/src/web/i18n/es/resource.json index a85bc9be4..eb375084a 100644 --- a/src/web/i18n/es/resource.json +++ b/src/web/i18n/es/resource.json @@ -349,7 +349,6 @@ "Show All Settings": "", "List Self Tests": "", "Power Management": "", - "Motor Timeout: {{mt}} sec": "", "Enable Motors": "", "Disable Motors": "", "Motor {{n}}": "", diff --git a/src/web/i18n/fr/resource.json b/src/web/i18n/fr/resource.json index fe8e75800..81ce1108d 100644 --- a/src/web/i18n/fr/resource.json +++ b/src/web/i18n/fr/resource.json @@ -349,7 +349,6 @@ "Show All Settings": "", "List Self Tests": "", "Power Management": "", - "Motor Timeout: {{mt}} sec": "", "Enable Motors": "", "Disable Motors": "", "Motor {{n}}": "", diff --git a/src/web/i18n/hu/resource.json b/src/web/i18n/hu/resource.json index 4d8458722..65659b9dc 100644 --- a/src/web/i18n/hu/resource.json +++ b/src/web/i18n/hu/resource.json @@ -349,7 +349,6 @@ "Show All Settings": "Minden beállítás megjelenítése", "List Self Tests": "Ellenörző teszt lista", "Power Management": "Energiagazdálkodás", - "Motor Timeout: {{mt}} sec": "", "Enable Motors": "Motorok engedélyezve", "Disable Motors": "Motorok tiltva", "Motor {{n}}": "Motor {{n}}", diff --git a/src/web/i18n/it/resource.json b/src/web/i18n/it/resource.json index 09976861e..4149da5cc 100644 --- a/src/web/i18n/it/resource.json +++ b/src/web/i18n/it/resource.json @@ -349,7 +349,6 @@ "Show All Settings": "Visualizza tutti i settaggi", "List Self Tests": "", "Power Management": "", - "Motor Timeout: {{mt}} sec": "", "Enable Motors": "", "Disable Motors": "", "Motor {{n}}": "", diff --git a/src/web/i18n/ja/resource.json b/src/web/i18n/ja/resource.json index 385ec6497..72e5b0b92 100644 --- a/src/web/i18n/ja/resource.json +++ b/src/web/i18n/ja/resource.json @@ -349,7 +349,6 @@ "Show All Settings": "すべての設定を表示", "List Self Tests": "セルフテストの一覧", "Power Management": "", - "Motor Timeout: {{mt}} sec": "", "Enable Motors": "", "Disable Motors": "", "Motor {{n}}": "", diff --git a/src/web/i18n/pt-br/resource.json b/src/web/i18n/pt-br/resource.json index 0a2fefa97..b1b38c3d9 100644 --- a/src/web/i18n/pt-br/resource.json +++ b/src/web/i18n/pt-br/resource.json @@ -349,7 +349,6 @@ "Show All Settings": "Mostrar todas as configurações", "List Self Tests": "Lista autotestes", "Power Management": "", - "Motor Timeout: {{mt}} sec": "", "Enable Motors": "", "Disable Motors": "", "Motor {{n}}": "", diff --git a/src/web/i18n/ru/resource.json b/src/web/i18n/ru/resource.json index 9c0c5b400..eca6ff44f 100644 --- a/src/web/i18n/ru/resource.json +++ b/src/web/i18n/ru/resource.json @@ -349,7 +349,6 @@ "Show All Settings": "", "List Self Tests": "", "Power Management": "", - "Motor Timeout: {{mt}} sec": "", "Enable Motors": "", "Disable Motors": "", "Motor {{n}}": "", diff --git a/src/web/i18n/zh-cn/resource.json b/src/web/i18n/zh-cn/resource.json index 325e1965e..b837304b5 100644 --- a/src/web/i18n/zh-cn/resource.json +++ b/src/web/i18n/zh-cn/resource.json @@ -349,7 +349,6 @@ "Show All Settings": "显示全部设置", "List Self Tests": "列出自检测试", "Power Management": "", - "Motor Timeout: {{mt}} sec": "", "Enable Motors": "", "Disable Motors": "", "Motor {{n}}": "", diff --git a/src/web/i18n/zh-tw/resource.json b/src/web/i18n/zh-tw/resource.json index cd9e746ff..c1ad3fcba 100644 --- a/src/web/i18n/zh-tw/resource.json +++ b/src/web/i18n/zh-tw/resource.json @@ -349,7 +349,6 @@ "Show All Settings": "顯示全部設定", "List Self Tests": "列出自檢測試", "Power Management": "", - "Motor Timeout: {{mt}} sec": "", "Enable Motors": "", "Disable Motors": "", "Motor {{n}}": "", diff --git a/src/web/lib/controller.js b/src/web/lib/controller.js index 2321c676a..9752de8cb 100644 --- a/src/web/lib/controller.js +++ b/src/web/lib/controller.js @@ -247,6 +247,9 @@ class CNCController { // controller.command('spindleOverride') // - Rapid Override // controller.command('rapidOverride') + // - Energize Motors + // controller.command('energizeMotors:on') + // controller.command('energizeMotors:off') // - G-code // controller.command('gcode', 'G0X0Y0', context /* optional */) // - Load a macro diff --git a/src/web/widgets/Console/Terminal.jsx b/src/web/widgets/Console/Terminal.jsx index cd480b115..1694233c0 100644 --- a/src/web/widgets/Console/Terminal.jsx +++ b/src/web/widgets/Console/Terminal.jsx @@ -149,6 +149,22 @@ class Terminal extends PureComponent { const focus = false; this.term.open(el, focus); + // Fix an issue that caused the vertical scrollbar unclickable + // @see https://github.com/sourcelair/xterm.js/issues/512 + const viewport = el.querySelector('.terminal .xterm-viewport'); + if (viewport) { + viewport.style.overflowY = 'scroll'; + } + const rows = el.querySelector('.terminal .xterm-rows'); + if (rows) { + const scrollbarWidth = this.getScrollbarWidth() || 0; + rows.style.position = 'absolute'; + rows.style.top = '0px'; + rows.style.right = `${scrollbarWidth}px`; + rows.style.left = '5px'; + rows.style.overflow = 'hidden'; + } + setTimeout(() => { this.resize(); }, 0); @@ -175,6 +191,30 @@ class Terminal extends PureComponent { this.resize(); }, 0); } + // http://www.alexandre-gomes.com/?p=115 + getScrollbarWidth() { + const inner = document.createElement('p'); + inner.style.width = '100%'; + inner.style.height = '200px'; + + const outer = document.createElement('div'); + outer.style.position = 'absolute'; + outer.style.top = '0px'; + outer.style.left = '0px'; + outer.style.visibility = 'hidden'; + outer.style.width = '200px'; + outer.style.height = '150px'; + outer.style.overflow = 'hidden'; + outer.appendChild(inner); + + document.body.appendChild(outer); + const w1 = inner.offsetWidth; + outer.style.overflow = 'scroll'; + const w2 = (w1 === inner.offsetWidth) ? outer.clientWidth : inner.offsetWidth; + document.body.removeChild(outer); + + return (w1 - w2); + } resize() { if (!(this.term && this.term.element)) { return; diff --git a/src/web/widgets/Console/index.styl b/src/web/widgets/Console/index.styl index 02df6e445..6e00a294c 100644 --- a/src/web/widgets/Console/index.styl +++ b/src/web/widgets/Console/index.styl @@ -20,6 +20,5 @@ .terminal-container { background: #000; - padding: 0 5px; height: 240px; } diff --git a/src/web/widgets/TinyG/TinyG.jsx b/src/web/widgets/TinyG/TinyG.jsx index 31aaac7d7..1175fd37c 100644 --- a/src/web/widgets/TinyG/TinyG.jsx +++ b/src/web/widgets/TinyG/TinyG.jsx @@ -58,7 +58,6 @@ class TinyG extends PureComponent { const ovF = (fv >= 0.99) ? Math.round(mfo * 100) || 0 : 0; const ovS = (fv >= 0.98) ? Math.round(sso * 100) || 0 : 0; const ovT = (fv >= 0.99) ? Math.round(mto * 100) || 0 : 0; - const mt = get(controllerState, 'mt'); const pwr = get(controllerState, 'pwr'); const machineState = get(controllerState, 'sr.machineState'); const machineStateText = { @@ -108,17 +107,12 @@ class TinyG extends PureComponent { {panel.powerManagement.expanded && pwr && -
-
- {i18n._('Motor Timeout: {{mt}} sec', { mt: mt })} -
-