cncjs-conversational 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/web/index.html +12 -2
package/package.json
CHANGED
package/web/index.html
CHANGED
|
@@ -1080,7 +1080,15 @@ const embedding = window.parent === window || !token ? 'standalone' : sameOrigin
|
|
|
1080
1080
|
const cnc = { token, port: null, load: { state: 'idle', message: '', program: '' } };
|
|
1081
1081
|
const programName = () => `${st.op}${st.op === 'square' ? `-setup${st.sq.setup}` : st.op === 'side' ? `-${st.side.side}` : ''}.nc`;
|
|
1082
1082
|
const programText = () => current.length ? current.join('\n') + '\n' : '';
|
|
1083
|
-
const setLoad = (state, message = '', program = '') => {
|
|
1083
|
+
const setLoad = (state, message = '', program = '') => {
|
|
1084
|
+
// An outcome that arrives after the operator edited the program is still shown once,
|
|
1085
|
+
// marked as describing the earlier version; the next edit clears it.
|
|
1086
|
+
const edited = state !== 'loading' && program !== programText();
|
|
1087
|
+
cnc.load = edited
|
|
1088
|
+
? { state, message: `${message} (This was the program before your last edit.)`, program: programText() }
|
|
1089
|
+
: { state, message, program };
|
|
1090
|
+
updateLoad();
|
|
1091
|
+
};
|
|
1084
1092
|
|
|
1085
1093
|
function updateLoad() {
|
|
1086
1094
|
const load = document.getElementById('load'), note = document.getElementById('cnc-note');
|
|
@@ -1114,7 +1122,9 @@ async function loadIntoCncjs() {
|
|
|
1114
1122
|
try {
|
|
1115
1123
|
// gcode:load stops CNCjs's workflow, so only load when nothing is running or paused,
|
|
1116
1124
|
// the same rule CNCjs's own Upload button follows.
|
|
1117
|
-
const
|
|
1125
|
+
const controllers = await cncjsApi('/api/controllers');
|
|
1126
|
+
if (!Array.isArray(controllers)) return setLoad('failed', 'Not loaded: CNCjs did not report its controllers.', program);
|
|
1127
|
+
const workflow = controllers.find(c => c.port === port)?.workflow?.state;
|
|
1118
1128
|
if (!workflow) return setLoad('failed', `Not loaded: ${port} is not open in CNCjs.`, program);
|
|
1119
1129
|
if (workflow !== 'idle') return setLoad('refused', `Not loaded: a program is ${workflow} on ${port}. Stop it in CNCjs first.`, program);
|
|
1120
1130
|
await cncjsApi('/api/gcode', { method: 'POST', body: JSON.stringify({ port, name, gcode: program }) });
|