Skip to content

Instantly share code, notes, and snippets.

@rjdestigter
Last active February 20, 2020 15:03
Show Gist options
  • Save rjdestigter/9d1cad1b963831913e7ffabcebdd8f67 to your computer and use it in GitHub Desktop.
Save rjdestigter/9d1cad1b963831913e7ffabcebdd8f67 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const valueInput = id => ({
initial: "empty",
states: {
empty: {
on: {
[`${id}.LOCK`]: {
target: "locked",
actions: send('STEP')
}
}
},
valid: {},
locked: {
on: {
// '': { actions: 'STEP' }
}
}
}
})
const fsCalcMachine = Machine({
id: "fsCalc",
initial: "calculating",
context: {
solvingFor: "unknown"
},
states: {
fullyDefined: {},
calculating: {
on: {
DONE: {
target:'fullyDefined',
cond: (_, e) => e.value === true
}
},
type: 'parallel',
states: {
result: {
initial: 'zero',
states: {
zero: {
on: { STEP: 'one' },
},
one: {
on: { STEP: 'two' },
},
two: {
type: 'final',
on: { STEP: {
actions: send({ type: 'DONE', value: true })
} },
}
}
},
feedrateInput: valueInput('feedrateInput'),
chiploadInput: valueInput('chiploadInput'),
numFlutesInput: valueInput('numFlutesInput'),
spindleSpeedInput: valueInput('spindleSpeedInput'),
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment