From 3cbaedf9050451fa8ad79a8dcdc59b01fb5e6f79 Mon Sep 17 00:00:00 2001 From: sanjayk03-dev Date: Mon, 8 Jul 2024 15:32:05 +0530 Subject: [PATCH] saving config in vue --- src/js/control-view.js | 17 ++++++++++++++--- src/py/bbctrl/Mach.py | 12 ++++++------ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/js/control-view.js b/src/js/control-view.js index c3e3afd..a87e9b2 100644 --- a/src/js/control-view.js +++ b/src/js/control-view.js @@ -725,7 +725,9 @@ module.exports = { return; } const macrosList = this.state.macros_list.map(item => item.file_name); - var files_to_delete = selected_folder.files.map(item => item.file_name).filter(item => !macrosList.includes(item)); + var files_to_delete = selected_folder.files + .map(item => item.file_name) + .filter(item => !macrosList.includes(item)); if (selected_folder.name != "default") { this.config.gcode_list = this.config.gcode_list.filter(item => item.name != this.state.folder); } else { @@ -773,8 +775,17 @@ module.exports = { SvelteComponents.showDialog("Message", { title: this[axis].toolmsg }); }, - set_position: function (axis, position) { - api.put(`position/${axis}`, { position: parseFloat(position) }); + set_position: async function (axis, position) { + this.update_config(); + if (!this.config.axes) { + this.config.axes = {}; + } + this.config.axes[axis] = { + abs: position + this.state["offset_" + axis], + off: this.state["offset_" + axis], + }; + console.log(this.config); + await api.put(`position/${axis}`, { position: parseFloat(position) }); }, zero_all: function () { diff --git a/src/py/bbctrl/Mach.py b/src/py/bbctrl/Mach.py index 65cee3a..dd838af 100644 --- a/src/py/bbctrl/Mach.py +++ b/src/py/bbctrl/Mach.py @@ -358,7 +358,7 @@ class Mach(Comm): def set_position(self, axis, position): axis = axis.lower() state = self.ctrl.state - config = self.ctrl.config + # config = self.ctrl.config if state.is_axis_homed(axis): # If homed, change the offset rather than the absolute position @@ -371,11 +371,11 @@ class Mach(Comm): # Set the absolute position both locally and via the AVR target = position + state.get('offset_' + axis) - json_data = config.values - axes = json_data.setdefault('axes', {}) - axes[axis] = { 'abs' : target, 'off' : state.get('offset_' + axis)} - self.mlog.info('json_data: ' + repr(json_data)) - # config.save(json_data) + # json_data = config.values + # axes = json_data.setdefault('axes', {}) + # axes[axis] = { 'abs' : target, 'off' : state.get('offset_' + axis)} + self.mlog.info('target ' + target) + self.mlog.info('state.get ' + state.get('offset_' + axis)) state.set(axis + 'p', target) super().queue_command(Cmd.set_axis(axis, target))