Skip to content

Commit

Permalink
Rotate the engraving cutter when both working state and active state …
Browse files Browse the repository at this point in the history
…are 'Run'
  • Loading branch information
cheton committed Dec 16, 2015
1 parent 7bfb433 commit bef8d3e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
25 changes: 18 additions & 7 deletions web/components/widgets/visualizer/Visualizer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ import colorNames from '../../../lib/color-names';
import Joystick from './Joystick';
import Toolbar from './Toolbar';
import {
COORDINATE_AXIS_LENGTH,
ACTIVE_STATE_IDLE,
ACTIVE_STATE_RUN,
WORKFLOW_STATE_RUNNING,
WORKFLOW_STATE_PAUSED,
WORKFLOW_STATE_IDLE,
COORDINATE_AXIS_LENGTH,
CAMERA_FOV,
CAMERA_NEAR,
CAMERA_FAR,
Expand All @@ -33,6 +35,9 @@ class Visualizer extends React.Component {

componentWillMount() {
this.workflowState = WORKFLOW_STATE_IDLE;
this.activeState = ACTIVE_STATE_IDLE;
this.modalState = {};

this.renderer = null;
this.scene = null;
this.camera = null;
Expand All @@ -42,7 +47,6 @@ class Visualizer extends React.Component {
this.engravingCutter = null;
this.object = null;
this.objectRenderer = null;
this.modalState = {};
}
componentDidMount() {
this.subscribe();
Expand Down Expand Up @@ -123,7 +127,9 @@ class Visualizer extends React.Component {
});
}
socketOnGrblCurrentStatus(data) {
let { workingPos } = data;
let { activeState, workingPos } = data;

this.activeState = activeState;
this.setEngravingCutterPosition(workingPos.x, workingPos.y, workingPos.z);
}
socketOnGCodeQueueStatus(data) {
Expand Down Expand Up @@ -210,10 +216,15 @@ class Visualizer extends React.Component {
// Call the render() function up to 60 times per second (i.e. 60fps)
requestAnimationFrame(render);

if (this.workflowState === WORKFLOW_STATE_RUNNING) {
this.rotateEngravingCutter(120); // 120 rounds per minute (rpm)
} else {
this.rotateEngravingCutter(0); // Stop rotation
{ // Rotate engraving cutter
let rotate = (this.workflowState === WORKFLOW_STATE_RUNNING) &&
(this.activeState === ACTIVE_STATE_RUN);

if (rotate) {
this.rotateEngravingCutter(120); // 120 rounds per minute (rpm)
} else {
this.rotateEngravingCutter(0); // Stop rotation
}
}

this.trackballControls.update();
Expand Down
9 changes: 9 additions & 0 deletions web/components/widgets/visualizer/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,12 @@ export const COORDINATE_AXIS_LENGTH = 99999;
export const WORKFLOW_STATE_RUNNING = 'running';
export const WORKFLOW_STATE_PAUSED = 'paused';
export const WORKFLOW_STATE_IDLE = 'idle';

// Grbl Active State
export const ACTIVE_STATE_IDLE = 'Idle';
export const ACTIVE_STATE_RUN = 'Run';
export const ACTIVE_STATE_HOLD = 'Hold';
export const ACTIVE_STATE_DOOR = 'Door';
export const ACTIVE_STATE_HOME = 'Home';
export const ACTIVE_STATE_ALARM = 'Alarm';
export const ACTIVE_STATE_CHECK = 'Check';

0 comments on commit bef8d3e

Please sign in to comment.