Made it far less likely for the UI to lock up
This commit is contained in:
@@ -493,18 +493,19 @@ module.exports = {
|
|||||||
const toolpath = await api.get(`path/${file}`);
|
const toolpath = await api.get(`path/${file}`);
|
||||||
this.toolpath_progress = toolpath.progress;
|
this.toolpath_progress = toolpath.progress;
|
||||||
|
|
||||||
if (typeof toolpath.progress == 'undefined') {
|
if (toolpath.progress === 1 || typeof toolpath.progress == 'undefined') {
|
||||||
this.showGcodeMessage = false
|
this.showGcodeMessage = false
|
||||||
|
|
||||||
|
if (toolpath.bounds) {
|
||||||
toolpath.filename = file;
|
toolpath.filename = file;
|
||||||
this.toolpath_progress = 1;
|
this.toolpath_progress = 1;
|
||||||
this.toolpath = toolpath;
|
this.toolpath = toolpath;
|
||||||
|
|
||||||
const state = this.$root.state;
|
const state = this.$root.state;
|
||||||
const bounds = toolpath.bounds;
|
|
||||||
for (let axis of 'xyzabc') {
|
for (let axis of 'xyzabc') {
|
||||||
Vue.set(state, 'path_min_' + axis, bounds.min[axis]);
|
Vue.set(state, 'path_min_' + axis, toolpath.bounds.min[axis]);
|
||||||
Vue.set(state, 'path_max_' + axis, bounds.max[axis]);
|
Vue.set(state, 'path_max_' + axis, toolpath.bounds.max[axis]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -540,29 +541,47 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
upload: function (e) {
|
upload: async function (e) {
|
||||||
var files = e.target.files || e.dataTransfer.files;
|
const files = e.target.files || e.dataTransfer.files;
|
||||||
if (!files.length) return;
|
if (!files.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var file = files[0];
|
const file = files[0];
|
||||||
var fd = new FormData();
|
|
||||||
|
const extension = file.name.split(".").pop();
|
||||||
|
switch (extension.toLowerCase()) {
|
||||||
|
case "nc":
|
||||||
|
case "ngc":
|
||||||
|
case "gcode":
|
||||||
|
case "gc":
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
alert(`Unsupported file type: ${extension}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const fd = new FormData();
|
||||||
|
|
||||||
fd.append('gcode', file);
|
fd.append('gcode', file);
|
||||||
|
|
||||||
api.upload('file', fd)
|
try {
|
||||||
.done(function () {
|
await api.upload('file', fd);
|
||||||
|
|
||||||
this.last_file_time = undefined; // Force reload
|
this.last_file_time = undefined; // Force reload
|
||||||
this.$broadcast('gcode-reload', file.name);
|
this.$broadcast('gcode-reload', file.name);
|
||||||
|
} catch (err) {
|
||||||
}.bind(this)).fail(function (error) {
|
api.alert('Upload failed', err)
|
||||||
api.alert('Upload failed', error)
|
}
|
||||||
}.bind(this));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
delete_current: function () {
|
delete_current: function () {
|
||||||
if (this.state.selected)
|
if (this.state.selected) {
|
||||||
api.delete('file/' + this.state.selected);
|
api.delete('file/' + this.state.selected);
|
||||||
|
}
|
||||||
|
|
||||||
this.deleteGCode = false;
|
this.deleteGCode = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -36,14 +36,8 @@ script#console-template(type="text/x-template")
|
|||||||
table
|
table
|
||||||
tr
|
tr
|
||||||
th Level
|
th Level
|
||||||
th Source
|
|
||||||
th Location
|
|
||||||
th Repeat
|
|
||||||
th Message
|
th Message
|
||||||
|
|
||||||
tr(v-for="msg in messages", class="log-{{msg.level || 'info'}}")
|
tr(v-for="msg in messages", class="log-{{msg.level || 'info'}}")
|
||||||
td {{msg.level || 'info'}}
|
td {{msg.level || 'info'}}
|
||||||
td {{msg.source || ''}}
|
|
||||||
td {{msg.where || ''}}
|
|
||||||
td {{msg.repeat}}
|
|
||||||
td.message {{msg.msg}}
|
td.message {{msg.msg}}
|
||||||
|
|||||||
@@ -413,7 +413,7 @@ script#control-view-template(type="text/x-template")
|
|||||||
|
|
||||||
form.gcode-file-input.file-upload
|
form.gcode-file-input.file-upload
|
||||||
input(type="file", @change="upload", :disabled="!is_ready",
|
input(type="file", @change="upload", :disabled="!is_ready",
|
||||||
accept="text/*,.nc,.gcode,.gc,.ngc,.txt,.tap,.cnc")
|
accept=".nc,.ngc,.gcode,.gc")
|
||||||
|
|
||||||
a(:disabled="!state.selected", download,
|
a(:disabled="!state.selected", download,
|
||||||
:href="'/api/file/' + state.selected",
|
:href="'/api/file/' + state.selected",
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ class AVREmu(object):
|
|||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
self.close()
|
self.close()
|
||||||
self.log.exception('Failed to start bbemu')
|
self.log.exception('Internal error: Failed to start bbemu')
|
||||||
|
|
||||||
|
|
||||||
def set_handlers(self, read_cb, write_cb):
|
def set_handlers(self, read_cb, write_cb):
|
||||||
|
|||||||
@@ -429,7 +429,7 @@ class Camera(object):
|
|||||||
self._close_dev()
|
self._close_dev()
|
||||||
self.log.info('Closed camera')
|
self.log.info('Closed camera')
|
||||||
|
|
||||||
except: self.log.exception('Exception while closing camera')
|
except: self.log.exception('Internal error: Exception while closing camera')
|
||||||
finally: self.dev = None
|
finally: self.dev = None
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class CommandQueue():
|
|||||||
try:
|
try:
|
||||||
if cb is not None: cb(*args, **kwargs)
|
if cb is not None: cb(*args, **kwargs)
|
||||||
except Exception:
|
except Exception:
|
||||||
self.log.exception('During command queue callback')
|
self.log.exception('Internal error: Command queue callback error')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class Config(object):
|
|||||||
encoding = 'utf-8') as f:
|
encoding = 'utf-8') as f:
|
||||||
self.template = json.load(f)
|
self.template = json.load(f)
|
||||||
|
|
||||||
except Exception: self.log.exception()
|
except Exception: self.log.exception('Internal error: Failed to load config template')
|
||||||
|
|
||||||
|
|
||||||
def get(self, name, default = None):
|
def get(self, name, default = None):
|
||||||
@@ -73,7 +73,7 @@ class Config(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self.upgrade(config)
|
self.upgrade(config)
|
||||||
except Exception: self.log.exception()
|
except Exception: self.log.exception('Internal error: Failed to upgrade config')
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.log.warning('%s', e)
|
self.log.warning('%s', e)
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class Ctrl(object):
|
|||||||
|
|
||||||
os.environ['GCODE_SCRIPT_PATH'] = self.get_upload()
|
os.environ['GCODE_SCRIPT_PATH'] = self.get_upload()
|
||||||
|
|
||||||
except Exception: self.log.get('Ctrl').exception()
|
except Exception: self.log.get('Ctrl').exception('Internal error: Control initialization failed')
|
||||||
|
|
||||||
|
|
||||||
def __del__(self): print('Ctrl deleted')
|
def __del__(self): print('Ctrl deleted')
|
||||||
|
|||||||
@@ -79,7 +79,11 @@ class FileHandler(bbctrl.APIHandler):
|
|||||||
if not filename: raise HTTPError(400, 'Missing filename')
|
if not filename: raise HTTPError(400, 'Missing filename')
|
||||||
filename = os.path.basename(filename)
|
filename = os.path.basename(filename)
|
||||||
|
|
||||||
|
try:
|
||||||
with open(self.get_upload(filename).encode('utf8'), 'r') as f:
|
with open(self.get_upload(filename).encode('utf8'), 'r') as f:
|
||||||
self.write(f.read())
|
self.write(f.read())
|
||||||
|
except Exception:
|
||||||
|
self.get_ctrl().state.select_file('')
|
||||||
|
raise HTTPError(400, "Unable to read file - doesn't appear to be GCode.")
|
||||||
|
|
||||||
self.get_ctrl().state.select_file(filename)
|
self.get_ctrl().state.select_file(filename)
|
||||||
|
|||||||
@@ -101,8 +101,8 @@ class Logger(object):
|
|||||||
def exception(self, *args, **kwargs):
|
def exception(self, *args, **kwargs):
|
||||||
msg = traceback.format_exc()
|
msg = traceback.format_exc()
|
||||||
if len(args): msg = args[0] % args[1:] + '\n' + msg
|
if len(args): msg = args[0] % args[1:] + '\n' + msg
|
||||||
self._log(ERROR, msg, **kwargs)
|
self._log(INFO, msg, **kwargs)
|
||||||
|
self._log(ERROR, *args, **kwargs)
|
||||||
|
|
||||||
class Log(object):
|
class Log(object):
|
||||||
def __init__(self, args, ioloop, path):
|
def __init__(self, args, ioloop, path):
|
||||||
|
|||||||
@@ -99,6 +99,6 @@ class MonitorTemp(object):
|
|||||||
self.update_camera(temp)
|
self.update_camera(temp)
|
||||||
self.log_warnings(temp)
|
self.log_warnings(temp)
|
||||||
|
|
||||||
except: self.log.exception()
|
except: self.log.exception('Internal error: Temperature status')
|
||||||
|
|
||||||
self.ioloop.call_later(5, self.callback)
|
self.ioloop.call_later(5, self.callback)
|
||||||
|
|||||||
@@ -357,7 +357,7 @@ class Planner():
|
|||||||
self.cmdq.clear()
|
self.cmdq.clear()
|
||||||
|
|
||||||
except:
|
except:
|
||||||
self.log.exception()
|
self.log.exception('Internal error: Planner stop')
|
||||||
self.reset()
|
self.reset()
|
||||||
|
|
||||||
|
|
||||||
@@ -374,7 +374,7 @@ class Planner():
|
|||||||
self.planner.restart(id, position)
|
self.planner.restart(id, position)
|
||||||
|
|
||||||
except:
|
except:
|
||||||
self.log.exception()
|
self.log.exception('Internal error: Planner restart')
|
||||||
self.stop()
|
self.stop()
|
||||||
|
|
||||||
|
|
||||||
@@ -391,5 +391,5 @@ class Planner():
|
|||||||
self.stop()
|
self.stop()
|
||||||
|
|
||||||
except:
|
except:
|
||||||
self.log.exception()
|
self.log.exception('Internal error: Planner next')
|
||||||
self.stop()
|
self.stop()
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ class Plan(object):
|
|||||||
return meta, positions, speeds
|
return meta, positions, speeds
|
||||||
|
|
||||||
except:
|
except:
|
||||||
self.preplanner.log.exception()
|
self.preplanner.log.exception('Internal error: Preplanner read')
|
||||||
|
|
||||||
# Clean
|
# Clean
|
||||||
for path in self.files:
|
for path in self.files:
|
||||||
@@ -203,8 +203,7 @@ class Plan(object):
|
|||||||
self.future.set_result(self._read())
|
self.future.set_result(self._read())
|
||||||
|
|
||||||
except:
|
except:
|
||||||
self.preplanner.log.exception()
|
self.preplanner.log.exception("Failed to load file - doesn't appear to be GCode.")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Preplanner(object):
|
class Preplanner(object):
|
||||||
|
|||||||
Reference in New Issue
Block a user