Skip to content

Commit

Permalink
Update resource.json
Browse files Browse the repository at this point in the history
  • Loading branch information
cheton committed Jun 28, 2017
2 parents 2d12a9b + 25c3977 commit 466fc31
Show file tree
Hide file tree
Showing 18 changed files with 144 additions and 32 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Expand Up @@ -13,6 +13,8 @@ os:
- linux
- osx

osx_image: xcode8.3

node_js:
- '4'
- '6'
Expand Down
34 changes: 17 additions & 17 deletions package.json
Expand Up @@ -162,10 +162,10 @@
"gcode-interpreter": "~1.1.1",
"gcode-parser": "~1.1.1",
"gcode-toolpath": "~1.1.1",
"history": "~4.6.2",
"history": "~4.6.3",
"hogan.js": "~3.0.2",
"i18next": "~8.4.2",
"i18next-browser-languagedetector": "~1.0.1",
"i18next-browser-languagedetector": "~2.0.0",
"i18next-express-middleware": "~1.0.5",
"i18next-node-fs-backend": "~1.0.0",
"i18next-xhr-backend": "~1.4.2",
Expand All @@ -190,12 +190,12 @@
"push.js": "~0.0.13",
"range_check": "~1.4.0",
"rc-slider": "~8.1.3",
"react": "~15.5.4",
"react-addons-shallow-compare": "~15.5.2",
"react-addons-update": "~15.5.2",
"react": "~15.6.1",
"react-addons-shallow-compare": "~15.6.0",
"react-addons-update": "~15.6.0",
"react-bootstrap": "~0.31.0",
"react-dom": "~15.5.4",
"react-dropzone": "~3.13.2",
"react-dom": "~15.6.1",
"react-dropzone": "~3.13.3",
"react-facebook-loading": "~0.6.1",
"react-infinite": "~0.11.0",
"react-infinite-tree": "~0.7.0",
Expand All @@ -207,7 +207,7 @@
"react-sortablejs": "~1.3.4",
"react-toggle": "~4.0.1",
"react-validation": "~2.10.9",
"redux": "~3.6.0",
"redux": "~3.7.0",
"registry-auth-token": "~3.3.1",
"registry-url": "~3.1.0",
"rimraf": "~2.6.1",
Expand All @@ -226,20 +226,20 @@
"static-eval": "~1.1.1",
"superagent": "~3.5.2",
"superagent-use": "~0.1.0",
"three": "~0.85.2",
"three": "~0.86.0",
"universal-logger": "~1.0.1",
"universal-logger-browser": "~1.0.1",
"uuid": "~3.0.1",
"uuid": "~3.1.0",
"watch": "~1.0.2",
"webappengine": "~1.1.3",
"webappengine": "~1.2.0",
"winston": "~2.3.1",
"xterm": "~2.7.0"
},
"devDependencies": {
"babel-cli": "~6.24.1",
"babel-core": "~6.25.0",
"babel-eslint": "~7.2.3",
"babel-loader": "~7.0.0",
"babel-loader": "~7.1.0",
"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 @@ -261,7 +261,7 @@
"eslint-loader": "~1.7.1",
"eslint-plugin-import": "~2.3.0",
"eslint-plugin-jsx-a11y": "~2.2.3",
"eslint-plugin-react": "~7.0.1",
"eslint-plugin-react": "~7.1.0",
"eventsource-polyfill": "~0.9.6",
"extract-text-webpack-plugin": "~2.1.2",
"file-loader": "~0.11.2",
Expand Down Expand Up @@ -293,13 +293,13 @@
"stylint-loader": "~1.0.0",
"stylus": "~0.54.5",
"stylus-loader": "~3.0.1",
"tap": "~10.3.4",
"tap": "~10.5.1",
"text-table": "~0.2.0",
"transform-loader": "~0.2.4",
"url-loader": "~0.5.9",
"webpack": "~2.6.1",
"webpack-dev-middleware": "~1.10.2",
"webpack-dev-server": "~2.4.5",
"webpack": "~3.0.0",
"webpack-dev-middleware": "~1.11.0",
"webpack-dev-server": "~2.5.0",
"webpack-hot-middleware": "~2.18.0",
"webpack-manifest-plugin": "~1.1.0",
"webpack-md5-hash": "0.0.5",
Expand Down
44 changes: 40 additions & 4 deletions src/app/controllers/TinyG/TinyG.js
Expand Up @@ -51,6 +51,7 @@ import {
class TinyGParser {
parse(data) {
const parsers = [
TinyGParserResultMotorTimeout,
TinyGParserResultPowerManagement,
TinyGParserResultQueueReports,
TinyGParserResultStatusReports,
Expand Down Expand Up @@ -78,10 +79,31 @@ class TinyGParser {
}
}

class TinyGParserResultMotorTimeout {
static parse(data) {
const mt = _.get(data, 'r.mt');
if (typeof mt === 'undefined') {
return null;
}

const footer = _.get(data, 'f') || [];
const statusCode = footer[1];
const payload = {};
if (mt && statusCode === 0) {
payload.mt = mt;
}

return {
type: TinyGParserResultMotorTimeout,
payload: payload
};
}
}

// https://github.com/synthetos/TinyG/wiki/Power-Management
class TinyGParserResultPowerManagement {
static parse(data) {
const pwr = _.get(data, 'r.pwr') || _.get(data, 'pwr');
const pwr = _.get(data, 'r.pwr');
if (typeof pwr === 'undefined') {
return null;
}
Expand Down Expand Up @@ -210,9 +232,12 @@ class TinyGParserResultReceiveReports {

class TinyG extends events.EventEmitter {
state = {
// Motor Timeout
mt: 0,
// Power Management
// {"pwr":{"1":0,"2":0,"3":0,"4":0}}
pwr: {},
pwr: {
// {"1":0,"2":0,"3":0,"4":0}
},
// Queue Reports
qr: 0,
// Status Reports
Expand Down Expand Up @@ -280,7 +305,18 @@ class TinyG extends events.EventEmitter {
const result = this.parser.parse(data) || {};
const { type, payload } = result;

if (type === TinyGParserResultPowerManagement) {
if (type === TinyGParserResultMotorTimeout) {
const { mt = this.state.mt } = payload;

if (this.state.mt !== mt) {
this.state = { // enforce change
...this.state,
mt: mt
};
}

this.emit('mt', payload.mt);
} else if (type === TinyGParserResultPowerManagement) {
const { pwr = this.state.pwr } = payload;

if (!_.isEqual(this.state.pwr, pwr)) {
Expand Down
53 changes: 53 additions & 0 deletions src/app/controllers/TinyG/TinyGController.js
Expand Up @@ -93,6 +93,10 @@ class TinyGController {
// Workflow
workflow = null;

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

dataFilter = (line, context) => {
// Machine position
const {
Expand Down Expand Up @@ -525,6 +529,9 @@ class TinyGController {
// System settings
{ cmd: '{sys:n}' },

// Request motor timeout
{ cmd: '{mt:n}' },

// Request motor states
{ cmd: '{pwr:n}' },

Expand Down Expand Up @@ -983,6 +990,52 @@ class TinyGController {
this.command(socket, 'gcode', '{mto:0.25}');
}
},
'motor:energize': () => {
const { mt = 0 } = this.state;

if (this.motorEnergizeTimer || !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;

if (this.motorEnergizeTimer) {
clearInterval(this.motorEnergizeTimer);
this.motorEnergizeTimer = null;
}

this.command(socket, 'gcode', '{md:0}');
this.command(socket, 'gcode', '{pwr:n}');
}, 30 * 60 * 1000);
},
'motor:deenergize': () => {
if (this.motorEnergizeTimer) {
clearInterval(this.motorEnergizeTimer);
this.motorEnergizeTimer = null;
}
if (this.motorEnergizeTimeout) {
clearTimeout(this.motorEnergizeTimeout);
this.motorEnergizeTimeout = null;
}

this.command(socket, 'gcode', '{md:0}');
this.command(socket, 'gcode', '{pwr:n}');
},
'lasertest:on': () => {
const [power = 0, duration = 0, maxS = 1000] = args;
const commands = [
Expand Down
4 changes: 2 additions & 2 deletions src/package.json
Expand Up @@ -52,9 +52,9 @@
"spawn-default-shell": "~2.0.0",
"static-eval": "~1.1.1",
"superagent": "~3.5.2",
"uuid": "~3.0.1",
"uuid": "~3.1.0",
"watch": "~1.0.2",
"webappengine": "~1.1.3",
"webappengine": "~1.2.0",
"winston": "~2.3.1"
}
}
1 change: 1 addition & 0 deletions src/web/i18n/cs/resource.json
Expand Up @@ -349,6 +349,7 @@
"Show All Settings": "",
"List Self Tests": "",
"Power Management": "",
"Motor Timeout: {{mt}} sec": "",
"Enable Motors": "",
"Disable Motors": "",
"Motor {{n}}": "",
Expand Down
1 change: 1 addition & 0 deletions src/web/i18n/de/resource.json
Expand Up @@ -349,6 +349,7 @@
"Show All Settings": "",
"List Self Tests": "",
"Power Management": "",
"Motor Timeout: {{mt}} sec": "",
"Enable Motors": "",
"Disable Motors": "",
"Motor {{n}}": "",
Expand Down
1 change: 1 addition & 0 deletions src/web/i18n/en/resource.json
Expand Up @@ -349,6 +349,7 @@
"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: 1 addition & 0 deletions src/web/i18n/es/resource.json
Expand Up @@ -349,6 +349,7 @@
"Show All Settings": "",
"List Self Tests": "",
"Power Management": "",
"Motor Timeout: {{mt}} sec": "",
"Enable Motors": "",
"Disable Motors": "",
"Motor {{n}}": "",
Expand Down
1 change: 1 addition & 0 deletions src/web/i18n/fr/resource.json
Expand Up @@ -349,6 +349,7 @@
"Show All Settings": "",
"List Self Tests": "",
"Power Management": "",
"Motor Timeout: {{mt}} sec": "",
"Enable Motors": "",
"Disable Motors": "",
"Motor {{n}}": "",
Expand Down
3 changes: 2 additions & 1 deletion src/web/i18n/hu/resource.json
Expand Up @@ -349,9 +349,10 @@
"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",
"Motor {{n}}": "Motor {{n}}",
"Velocity": "Velocity",
"Line": "Vonal",
"Path": "Pálya",
Expand Down
1 change: 1 addition & 0 deletions src/web/i18n/it/resource.json
Expand Up @@ -349,6 +349,7 @@
"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: 1 addition & 0 deletions src/web/i18n/ja/resource.json
Expand Up @@ -349,6 +349,7 @@
"Show All Settings": "すべての設定を表示",
"List Self Tests": "セルフテストの一覧",
"Power Management": "",
"Motor Timeout: {{mt}} sec": "",
"Enable Motors": "",
"Disable Motors": "",
"Motor {{n}}": "",
Expand Down
1 change: 1 addition & 0 deletions src/web/i18n/pt-br/resource.json
Expand Up @@ -349,6 +349,7 @@
"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: 1 addition & 0 deletions src/web/i18n/ru/resource.json
Expand Up @@ -349,6 +349,7 @@
"Show All Settings": "",
"List Self Tests": "",
"Power Management": "",
"Motor Timeout: {{mt}} sec": "",
"Enable Motors": "",
"Disable Motors": "",
"Motor {{n}}": "",
Expand Down
1 change: 1 addition & 0 deletions src/web/i18n/zh-cn/resource.json
Expand Up @@ -349,6 +349,7 @@
"Show All Settings": "显示全部设置",
"List Self Tests": "列出自检测试",
"Power Management": "",
"Motor Timeout: {{mt}} sec": "",
"Enable Motors": "",
"Disable Motors": "",
"Motor {{n}}": "",
Expand Down
1 change: 1 addition & 0 deletions src/web/i18n/zh-tw/resource.json
Expand Up @@ -349,6 +349,7 @@
"Show All Settings": "顯示全部設定",
"List Self Tests": "列出自檢測試",
"Power Management": "",
"Motor Timeout: {{mt}} sec": "",
"Enable Motors": "",
"Disable Motors": "",
"Motor {{n}}": "",
Expand Down

0 comments on commit 466fc31

Please sign in to comment.