From aefd4caf5e85478de47d07e709a9abc7a1cdc092 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sun, 1 Aug 2021 14:05:44 +0200 Subject: [PATCH] Feature/motion report (#317) * test new flow and velocity Signed-off-by: Stefan Dej * test build for live speed & flow Signed-off-by: Stefan Dej * bugfix: fix ToolSlider.vue for printsettings and machine limits Signed-off-by: Stefan Dej * remove debug output Signed-off-by: Stefan Dej * rework MachineLimits Signed-off-by: Stefan Dej * feature: live extruder, toolhead speed and position data in StatusPanel.vue Signed-off-by: Stefan Dej --- src/components/inputs/MachineLimitsInput.vue | 60 ++++++++++++ src/components/inputs/ToolSlider.vue | 20 +++- src/components/panels/Machine/LimitsPanel.vue | 95 ++++++++++--------- src/components/panels/MiscellaneousPanel.vue | 87 ++++++----------- src/components/panels/PrintsettingsPanel.vue | 42 ++++++++ src/components/panels/StatusPanel.vue | 95 ++++++++----------- src/locales/en.json | 1 + src/pages/Dashboard.vue | 3 + src/store/printer/getters.ts | 2 +- 9 files changed, 242 insertions(+), 163 deletions(-) create mode 100644 src/components/inputs/MachineLimitsInput.vue create mode 100644 src/components/panels/PrintsettingsPanel.vue diff --git a/src/components/inputs/MachineLimitsInput.vue b/src/components/inputs/MachineLimitsInput.vue new file mode 100644 index 00000000..1d8bc165 --- /dev/null +++ b/src/components/inputs/MachineLimitsInput.vue @@ -0,0 +1,60 @@ + + + + + \ No newline at end of file diff --git a/src/components/inputs/ToolSlider.vue b/src/components/inputs/ToolSlider.vue index 09e7b1b0..aaa1e011 100644 --- a/src/components/inputs/ToolSlider.vue +++ b/src/components/inputs/ToolSlider.vue @@ -15,7 +15,7 @@ class="ml-2" x-small icon - @click="processedMin = min; processedMax = max; value = defaultValue; sliding = true; sendCmd()" + @click="resetSlider" > mdi-restart @@ -49,8 +49,6 @@ diff --git a/src/components/panels/PrintsettingsPanel.vue b/src/components/panels/PrintsettingsPanel.vue new file mode 100644 index 00000000..42ca0817 --- /dev/null +++ b/src/components/panels/PrintsettingsPanel.vue @@ -0,0 +1,42 @@ + + + + + diff --git a/src/components/panels/StatusPanel.vue b/src/components/panels/StatusPanel.vue index cf150093..18320aa8 100644 --- a/src/components/panels/StatusPanel.vue +++ b/src/components/panels/StatusPanel.vue @@ -148,18 +148,31 @@ - {{ $t("Panels.StatusPanel.Speed") }}
- {{ requested_speed }} mm/s + +
- {{ $t("Panels.StatusPanel.Max") }}: {{ maxFlow.maxValue ? maxFlow.maxValue.toFixed(1)+" mm³/s" : "--" }} + {{ $t("Panels.StatusPanel.Max") }}: {{ maxFlow ? maxFlow+" mm³/s" : "--" }} @@ -265,13 +278,7 @@ import VueLoadImage from "vue-load-image" VueLoadImage }) export default class StatusPanel extends Mixins(BaseMixin) { - maxFlow = { - intervalTimer: null, - lastExtruderPos: 0, - lastTime: 0, - lastValue: 0, - maxValue: 0, - } + maxFlow = 0 get current_filename() { return this.$store.state.printer.print_stats?.filename ?? "" @@ -379,6 +386,26 @@ export default class StatusPanel extends Mixins(BaseMixin) { }) } + get live_velocity() { + return Math.abs(this.$store.state.printer.motion_report?.live_velocity?.toFixed(0)) ?? null + } + + get live_extruder_velocity() { + const live_extruder_velocity = this.$store.state.printer.motion_report?.live_extruder_velocity ?? null + if (live_extruder_velocity === null) return null + + return live_extruder_velocity > 0 ? live_extruder_velocity : 0 + } + + get live_flow() { + if (this.live_extruder_velocity === null) return null + + const filamentCrossSection = Math.pow(this.filament_diameter / 2, 2) * Math.PI + const currentFlow = filamentCrossSection * this.live_extruder_velocity + + return currentFlow?.toFixed(1) + } + get requested_speed() { const requested_speed = this.$store.state.printer.gcode_move?.speed ?? 0 const speed_factor = this.$store.state.printer.gcode_move?.speed_factor ?? 0 @@ -533,49 +560,11 @@ export default class StatusPanel extends Mixins(BaseMixin) { return h+":"+m+((diff > 60*60*24*1000) ? "+"+parseInt(diff / (60*60*24*1000)) : "") } - calcMaxFlow() { - const newExtruderPos = parseFloat(this.filament_used) + @Watch('live_flow') + live_flowChanged(newVal) { + newVal = parseFloat(newVal) - if ( - this.maxFlow.lastExtruderPos && - this.maxFlow.lastExtruderPos < newExtruderPos && - this.maxFlow.lastTime - ) { - const timeDiff = (new Date().getTime() - this.maxFlow.lastTime) / 1000 - const filamentDiff = newExtruderPos - this.maxFlow.lastExtruderPos - const filamentCrossSection = Math.pow(this.filament_diameter / 2, 2) * Math.PI - - if (timeDiff < 5000) { - this.maxFlow.lastValue = filamentCrossSection * filamentDiff / timeDiff - - if (this.maxFlow.maxValue < this.maxFlow.lastValue) this.maxFlow.maxValue = this.maxFlow.lastValue - } - } - - this.maxFlow.lastExtruderPos = newExtruderPos - this.maxFlow.lastTime = new Date().getTime() - } - - created() { - this.maxFlow.intervalTimer = setInterval(() => { - this.calcMaxFlow() - }, 3000) - } - - beforeDestroy() { - if (this.maxFlow.intervalTimer) { - clearInterval(this.maxFlow.intervalTimer) - this.maxFlow.intervalTimer = null - } - } - - @Watch('printerState') - printerStateChange(newVal) { - if (['complete', 'cancel', 'error', 'standby'].includes(newVal)) { - this.maxFlow.lastValue = 0 - this.maxFlow.maxValue = 0 - this.maxFlow.lastTime = 0 - } + if (newVal && this.maxFlow < newVal) this.maxFlow = newVal } } \ No newline at end of file diff --git a/src/locales/en.json b/src/locales/en.json index 0b00642c..0786fcd8 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -317,6 +317,7 @@ "CancelPrint": "Cancel print", "ClearPrintStats": "Clear print stats", "ReprintJob": "Reprint job", + "Requested": "Requested", "Speed": "Speed", "Flow": "Flow", "Max": "max", diff --git a/src/pages/Dashboard.vue b/src/pages/Dashboard.vue index a6cee548..19b01ce9 100644 --- a/src/pages/Dashboard.vue +++ b/src/pages/Dashboard.vue @@ -8,6 +8,7 @@ + @@ -32,9 +33,11 @@ import ZOffsetPanel from "@/components/panels/ZOffsetPanel.vue"; import ControlPanel from "@/components/panels/ControlPanel.vue"; import MiscellaneousPanel from "@/components/panels/MiscellaneousPanel.vue"; import MiniconsolePanel from "@/components/panels/MiniconsolePanel.vue"; +import PrintsettingsPanel from "@/components/panels/PrintsettingsPanel.vue"; @Component({ components: { + PrintsettingsPanel, MiniconsolePanel, MiscellaneousPanel, ControlPanel, diff --git a/src/store/printer/getters.ts b/src/store/printer/getters.ts index aa54c43a..9a8a4cb7 100644 --- a/src/store/printer/getters.ts +++ b/src/store/printer/getters.ts @@ -32,7 +32,7 @@ export const getters: GetterTree = { }, getPositions: (state) => { - const position = state.motion_report?.position ?? state.toolhead?.position ?? [0,0,0] + const position = state.motion_report?.live_position ?? state.toolhead?.position ?? [0,0,0] const gcode_position = state.gcode_move?.gcode_position ?? [0,0,0] const absolute = state.gcode_move?.absolute_coordinates ?? true