Merge branch '1.0.7-devel' into refactored-probing

This commit is contained in:
OneFinityCNC
2021-03-03 00:37:34 -05:00
committed by GitHub
12 changed files with 165 additions and 135 deletions

View File

@@ -73,14 +73,12 @@ module.exports = {
restore: function (e) {
debugger;
var files = e.target.files || e.dataTransfer.files;
if (!files.length) return;
var fr = new FileReader();
fr.onload = function (e) {
var config;
debugger;
try {
config = JSON.parse(e.target.result);
} catch (ex) {
@@ -111,18 +109,15 @@ module.exports = {
cache: false
}).done(function (data) {
debugger;
//console.debug('>', data);
//this.default_config = data;
var config;
try {
config = JSON.parse(data);
} catch(ex) {
api.alert("Invalid default config file");
return;
}
api.put('config/save', config).done(function (data) {
var config;
try {
config = JSON.parse(data);
} catch(ex) {
api.alert("Invalid default config file");
return;
}
api.put('config/save', config).done(function (data) {
this.confirmReset = false;
this.$dispatch('update');
@@ -149,18 +144,15 @@ module.exports = {
cache: false
}).done(function (data) {
debugger;
//console.debug('>', data);
//this.default_config = data;
var config;
try {
config = JSON.parse(data);
} catch(ex) {
api.alert("Invalid default config file");
return;
}
api.put('config/save', config).done(function (data) {
var config;
try {
config = JSON.parse(data);
} catch(ex) {
api.alert("Invalid default config file");
return;
}
api.put('config/save', config).done(function (data) {
this.confirmReset = false;
this.$dispatch('update');

View File

@@ -359,13 +359,13 @@ module.exports = new Vue({
// },
get_ip_address : function() {
console.debug('get_ip>', this.ipAddress);
return this.ipAddress;
console.debug('get_ip>', this.ipAddress);
return this.ipAddress;
},
get_ssid : function() {
console.debug('get_ssid>', this.wifiSSID);
return this.wifiSSID;
console.debug('get_ssid>', this.wifiSSID);
return this.wifiSSID;
},
// get_disk_space : function() {
@@ -408,6 +408,11 @@ module.exports = new Vue({
}
update_object(this.state, e.data, false);
if (this.state.pw === 0) {
Vue.set(this.state, "probe_connected", true);
}
this.$broadcast('update');
}.bind(this)

View File

@@ -67,6 +67,7 @@ module.exports = {
deleteGCode: false,
tab: 'auto',
jog_incr: 1.0,
probe_test: false,
tool_msg: false,
tool_diameter: 6.35,
toolpath_msg: {x: false, y: false, z: false, a: false, b: false, c: false},
@@ -259,8 +260,27 @@ module.exports = {
},
set_tool_diameter : function (new_diameter) {
start_probe_test: function(on_finish) {
this.probe_test = true;
Vue.set(this.state, "probe_connected", false);
Vue.set(this.state, "on_probe_finish", on_finish);
},
finish_probe_test: function() {
this.probe_test = false;
Vue.set(this.state, "probe_connected", false);
const on_finish = this.state.on_probe_finish;
Vue.set(this.state, "on_probe_finish", undefined);
on_finish();
},
show_tool_diameter_prompt: function() {
this.tool_msg = true;
},
set_tool_diameter : function (new_diameter) {
if(isNaN(new_diameter))
return;
@@ -269,7 +289,6 @@ module.exports = {
this.tool_diameter = parseFloat(new_diameter);
this.probe_xyz();
},
set_jog_incr: function(newValue) {
@@ -435,9 +454,6 @@ module.exports = {
var zcmd = "Z" + z_jog * this.jog_incr;
var acmd = "A" + a_jog * this.jog_incr;
console.log("Jog command: " + this.jog_incr);
//debugger;
this.send('G91\nG0' + xcmd + ycmd + zcmd + acmd + '\n');
},
@@ -458,15 +474,20 @@ module.exports = {
},
load_toolpath: function (file, file_time) {
load_toolpath: async function (file, file_time) {
this.toolpath = {};
if (!file) return;
api.get('path/' + file).done(function (toolpath) {
if (this.last_file_time != file_time) return;
this.showGcodeMessage = true;
let done = false;
while (!done) {
const toolpath = await api.get(`path/${file}`);
if (typeof toolpath.progress == 'undefined') {
done = true;
toolpath.filename = file;
this.toolpath_progress = 1;
this.showGcodeMessage = false;
@@ -478,13 +499,10 @@ module.exports = {
Vue.set(state, 'path_min_' + axis, bounds.min[axis]);
Vue.set(state, 'path_max_' + axis, bounds.max[axis]);
}
} else {
this.showGcodeMessage = true;
this.toolpath_progress = toolpath.progress;
this.load_toolpath(file, file_time); // Try again
}
}.bind(this));
}
},

View File

@@ -80,33 +80,29 @@ module.exports = {
methods: {
load: function (file) {
load: async function(file) {
if (file == this.file) return;
this.clear();
this.file = file;
if (!file) return;
var xhr = new XMLHttpRequest();
xhr.open('GET', '/api/file/' + file + '?' + Math.random(), true);
xhr.responseType = 'text';
const response = await fetch(`/api/file/${file}?${Math.random()}`);
const text = await response.text();
xhr.onload = function (e) {
if (this.file != file) return;
var lines = escapeHTML(xhr.response.trimRight()).split(/\r?\n/);
for (var i = 0; i < lines.length; i++) {
lines[i] = '<li class="ln' + (i + 1) + '">' +
'<b>' + (i + 1) + '</b>' + lines[i] + '</li>';
}
if (text.length > 20e6) {
this.clusterize.update(['File is large - gcode view disabled']);
} else {
const lines = escapeHTML(text.trimRight())
.split(/[\r\n]/)
.map((line, i) => `<li class="ln${i + 1}"><b>${i + 1}</b>${line}</li>`);
this.clusterize.update(lines);
this.empty = false;
}
Vue.nextTick(this.update_line);
}.bind(this)
this.empty = false;
xhr.send();
Vue.nextTick(this.update_line);
},