Skip to content

Commit

Permalink
Merge from dev
Browse files Browse the repository at this point in the history
  • Loading branch information
cheton committed Jul 3, 2017
2 parents a3abb30 + e6a0345 commit faa50e3
Show file tree
Hide file tree
Showing 19 changed files with 98 additions and 75 deletions.
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
75 changes: 37 additions & 38 deletions src/app/controllers/TinyG/TinyGController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand All @@ -93,10 +98,6 @@ class TinyGController {
// Workflow
workflow = null;

// Power Management
motorEnergizeTimer = null;
motorEnergizeTimeout = null;

dataFilter = (line, context) => {
// Machine position
const {
Expand Down Expand Up @@ -412,8 +413,8 @@ class TinyGController {
}
});

// Timer
this.queryTimer = setInterval(() => {
// Query Timer
this.timer.query = setInterval(() => {
if (this.isClose()) {
// Serial port is closed
return;
Expand Down Expand Up @@ -574,6 +575,7 @@ class TinyGController {
sendInitCommands();
}
clearActionValues() {
this.actionTime.energizeMotors = 0;
this.actionTime.senderFinishTime = 0;
}
destroy() {
Expand All @@ -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) {
Expand Down Expand Up @@ -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}');
Expand Down
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion src/web/i18n/cs/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@
"Show All Settings": "",
"List Self Tests": "",
"Power Management": "",
"Motor Timeout: {{mt}} sec": "",
"Enable Motors": "",
"Disable Motors": "",
"Motor {{n}}": "",
Expand Down
1 change: 0 additions & 1 deletion src/web/i18n/de/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@
"Show All Settings": "",
"List Self Tests": "",
"Power Management": "",
"Motor Timeout: {{mt}} sec": "",
"Enable Motors": "",
"Disable Motors": "",
"Motor {{n}}": "",
Expand Down
1 change: 0 additions & 1 deletion src/web/i18n/en/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}}",
Expand Down
1 change: 0 additions & 1 deletion src/web/i18n/es/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@
"Show All Settings": "",
"List Self Tests": "",
"Power Management": "",
"Motor Timeout: {{mt}} sec": "",
"Enable Motors": "",
"Disable Motors": "",
"Motor {{n}}": "",
Expand Down
1 change: 0 additions & 1 deletion src/web/i18n/fr/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@
"Show All Settings": "",
"List Self Tests": "",
"Power Management": "",
"Motor Timeout: {{mt}} sec": "",
"Enable Motors": "",
"Disable Motors": "",
"Motor {{n}}": "",
Expand Down
1 change: 0 additions & 1 deletion src/web/i18n/hu/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}}",
Expand Down
1 change: 0 additions & 1 deletion src/web/i18n/it/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}}": "",
Expand Down
1 change: 0 additions & 1 deletion src/web/i18n/ja/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@
"Show All Settings": "すべての設定を表示",
"List Self Tests": "セルフテストの一覧",
"Power Management": "",
"Motor Timeout: {{mt}} sec": "",
"Enable Motors": "",
"Disable Motors": "",
"Motor {{n}}": "",
Expand Down
1 change: 0 additions & 1 deletion src/web/i18n/pt-br/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}}": "",
Expand Down
1 change: 0 additions & 1 deletion src/web/i18n/ru/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@
"Show All Settings": "",
"List Self Tests": "",
"Power Management": "",
"Motor Timeout: {{mt}} sec": "",
"Enable Motors": "",
"Disable Motors": "",
"Motor {{n}}": "",
Expand Down
1 change: 0 additions & 1 deletion src/web/i18n/zh-cn/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@
"Show All Settings": "显示全部设置",
"List Self Tests": "列出自检测试",
"Power Management": "",
"Motor Timeout: {{mt}} sec": "",
"Enable Motors": "",
"Disable Motors": "",
"Motor {{n}}": "",
Expand Down
1 change: 0 additions & 1 deletion src/web/i18n/zh-tw/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@
"Show All Settings": "顯示全部設定",
"List Self Tests": "列出自檢測試",
"Power Management": "",
"Motor Timeout: {{mt}} sec": "",
"Enable Motors": "",
"Disable Motors": "",
"Motor {{n}}": "",
Expand Down
3 changes: 3 additions & 0 deletions src/web/lib/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 40 additions & 0 deletions src/web/widgets/Console/Terminal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/web/widgets/Console/index.styl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@

.terminal-container {
background: #000;
padding: 0 5px;
height: 240px;
}

0 comments on commit faa50e3

Please sign in to comment.