Feature/motion report (#317)

* test new flow and velocity

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* test build for live speed & flow

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* bugfix: fix ToolSlider.vue for printsettings and machine limits

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* remove debug output

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* rework MachineLimits

Signed-off-by: Stefan Dej <meteyou@gmail.com>

* feature: live extruder, toolhead speed and position data in StatusPanel.vue

Signed-off-by: Stefan Dej <meteyou@gmail.com>
This commit is contained in:
Stefan Dej authored and GitHub committed 2021-08-01 14:05:44 +02:00
1 parent 79c490b1a6
commit aefd4caf5e
9 files changed
+242 -163

No files matched your search

@@ -0,0 +1,60 @@
<style scoped>
</style>
<template>
<form v-on:submit.prevent="sendCmd">
<v-text-field
:label="label"
:suffix="unit"
v-model="value"
type="number"
outlined
dense
:append-icon="this.value !== this.defaultValue ? 'mdi-refresh' : ''"
:error="this.value > this.defaultValue"
@click:append="resetLimit"
hide-details
></v-text-field>
</form>
</template>
<script lang="ts">
import Component from "vue-class-component";
import {Mixins, Prop, Watch} from "vue-property-decorator";
import BaseMixin from "@/components/mixins/base";
@Component
export default class MachineLimitsInput extends Mixins(BaseMixin) {
private value: any = 0
@Prop({ type: String, required: true }) readonly label!: string
@Prop({ type: Number, required: true, default: 0 }) readonly target!: number
@Prop({ type: Number, required: true, default: 0 }) readonly defaultValue!: number
@Prop({ type: Number, required: true, default: 100 }) readonly max!: number
@Prop({ type: String, required: true }) readonly attributeName!: string
@Prop({ type: String, required: true }) readonly unit!: string
@Watch('target')
targetChanged(newVal: number): void {
this.value = newVal
}
created(): void {
this.value = this.target
}
resetLimit() {
this.value = this.defaultValue
this.sendCmd()
}
sendCmd() {
const gcode = 'SET_VELOCITY_LIMIT ' + this.attributeName + '=' + Math.max(1, this.value).toFixed(0)
this.$store.dispatch('server/addEvent', {message: gcode, type: 'command'})
this.$socket.emit('printer.gcode.script', {script: gcode})
}
}
</script>
+15 -5
View File
@@ -15,7 +15,7 @@
class="ml-2"
x-small
icon
@click="processedMin = min; processedMax = max; value = defaultValue; sliding = true; sendCmd()"
@click="resetSlider"
>
<v-icon>mdi-restart</v-icon>
</v-btn>
@@ -49,8 +49,6 @@
<script lang="ts">
import {Component, Mixins, Prop, Watch} from "vue-property-decorator";
import BaseMixin from "@/components/mixins/base";
import {Debounce} from "vue-debounce-decorator";
@@ -80,8 +78,8 @@ export default class ToolSlider extends Mixins(BaseMixin) {
this.startValue = this.target * this.multi
this.dynamicStep = Math.floor((this.max - this.min) / 2)
if (this.value > this.max) {
this.processedMax = Math.ceil(this.value / this.defaultValue) * this.defaultValue
if (this.value >= this.processedMax) {
this.processedMax = (Math.ceil(this.value / this.dynamicStep) + 1) * this.dynamicStep
}
}
@@ -91,6 +89,8 @@ export default class ToolSlider extends Mixins(BaseMixin) {
@Debounce(250)
changeSlider() {
this.sendCmd()
if (!this.dynamicRange) return
if (this.value >= this.processedMax) {
this.processedMax = this.value + this.dynamicStep
@@ -112,6 +112,16 @@ export default class ToolSlider extends Mixins(BaseMixin) {
this.processedMax = newVal > this.value ? newVal : Math.ceil(this.value / this.dynamicStep) * this.dynamicStep
}
resetSlider() {
this.value = this.defaultValue
this.processedMax = this.max
if (this.value >= this.processedMax) {
this.processedMax = (Math.ceil(this.value / this.dynamicStep) + 1) * this.dynamicStep
}
this.sendCmd()
}
sendCmd() {
const gcode = this.command + ' ' + this.attributeName + (Math.max(1, this.value) * this.attributeScale).toFixed(0)
this.$store.dispatch('server/addEvent', {message: gcode, type: 'command'})
+48 -47
View File
@@ -5,52 +5,52 @@
<span class="subheading"><v-icon left>mdi-speedometer</v-icon>{{ $t('Machine.LimitsPanel.MachineLimits')}}</span>
</v-toolbar-title>
</v-toolbar>
<tool-slider
:label="$t('Machine.LimitsPanel.Velocity')"
unit="mm/s"
:target="current_velocity"
:max="max_velocity"
:default-value="max_velocity"
:step="50"
:dynamic-range="true"
command="SET_VELOCITY_LIMIT"
attribute-name="VELOCITY="
></tool-slider>
<v-divider></v-divider>
<tool-slider
:label="$t('Machine.LimitsPanel.Acceleration')"
unit="mm/s²"
:target="current_accel"
:max="max_accel"
:default-value="max_accel"
:step="100"
:dynamic-range="true"
command="SET_VELOCITY_LIMIT"
attribute-name="ACCEL="
></tool-slider>
<v-divider></v-divider>
<tool-slider
:label="$t('Machine.LimitsPanel.Deceleration')"
unit="mm/s²" :target="current_accel_to_decel"
:max="max_accel_to_decel"
:default-value="max_accel_to_decel"
:step="100"
:dynamic-range="true"
command="SET_VELOCITY_LIMIT"
attribute-name="ACCEL_TO_DECEL="
></tool-slider>
<v-divider></v-divider>
<tool-slider
:label="$t('Machine.LimitsPanel.SquareCornerVelocity')"
unit="mm/s"
:target="current_square_corner_velocity"
:max="max_square_corner_velocity"
:default-value="max_square_corner_velocity"
:step="1"
:dynamic-range="true"
command="SET_VELOCITY_LIMIT"
attribute-name="SQUARE_CORNER_VELOCITY="
></tool-slider>
<v-card-text>
<v-row>
<v-col class="col-6">
<machine-limits-input
:label="$t('Machine.LimitsPanel.Velocity')"
:target="current_velocity"
:max="max_velocity"
:default-value="max_velocity"
unit="mm/s"
attribute-name="VELOCITY"
></machine-limits-input>
</v-col>
<v-col class="col-6">
<machine-limits-input
:label="$t('Machine.LimitsPanel.SquareCornerVelocity')"
:target="current_square_corner_velocity"
:max="max_square_corner_velocity"
:default-value="max_square_corner_velocity"
unit="mm/s"
attribute-name="SQUARE_CORNER_VELOCITY"
></machine-limits-input>
</v-col>
</v-row>
<v-row>
<v-col class="col-6">
<machine-limits-input
:label="$t('Machine.LimitsPanel.Acceleration')"
:target="current_accel"
:max="max_accel"
:default-value="max_accel"
unit="mm/s²"
attribute-name="ACCEL"
></machine-limits-input>
</v-col>
<v-col class="col-6">
<machine-limits-input
:label="$t('Machine.LimitsPanel.Deceleration')"
:target="current_accel_to_decel"
:max="max_accel_to_decel"
:default-value="max_accel_to_decel"
unit="mm/s²"
attribute-name="ACCEL_TO_DECEL"
></machine-limits-input>
</v-col>
</v-row>
</v-card-text>
</v-card>
</template>
@@ -60,8 +60,9 @@
import { Component, Mixins } from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base.ts'
import ToolSlider from '@/components/inputs/ToolSlider'
import MachineLimitsInput from '@/components/inputs/MachineLimitsInput'
@Component({
components: {ToolSlider}
components: {MachineLimitsInput, ToolSlider}
})
export default class LimitsPanel extends Mixins(BaseMixin) {
+30 -57
View File
@@ -3,49 +3,35 @@
</style>
<template>
<div v-if="klipperReadyForGui">
<v-card class="mb-6" v-if="['printing', 'paused'].includes(printer_state)">
<v-toolbar flat dense >
<v-toolbar-title>
<span class="subheading"><v-icon class="mdi mdi-printer-3d" left></v-icon>{{ $t("Panels.MiscellaneousPanel.PrintSettings") }}</span>
</v-toolbar-title>
</v-toolbar>
<tool-slider :label="$t('Panels.MiscellaneousPanel.SpeedFactor')" :target="speed_factor" :max="200" :multi="100" :step="5" :dynamic-range="true" command="M220" attribute-name="S" ></tool-slider>
<template v-if="existsExtruder">
<v-divider></v-divider>
<tool-slider :label="$t('Panels.MiscellaneousPanel.ExtrusionFactor')" :target="extrude_factor" :max="200" :multi="100" :step="1" command="M221" attribute-name="S" ></tool-slider>
</template>
</v-card>
<v-card class="mb-6" v-if="miscellaneous.length || filamentSensors.length">
<v-toolbar flat dense >
<v-toolbar-title>
<span class="subheading"><v-icon left>mdi-dip-switch</v-icon>{{ $t("Panels.MiscellaneousPanel.Miscellaneous") }}</span>
</v-toolbar-title>
</v-toolbar>
<div v-for="(object, index) of miscellaneous" v-bind:key="index">
<v-divider v-if="index"></v-divider>
<miscellaneous-slider
:name="object.name"
:type="object.type"
:target="object.power"
:rpm="object.rpm"
:controllable="object.controllable"
:pwm="object.pwm"
:off_below="object.off_below"
:max="object.max_power"
:multi="parseInt(object.scale)"
></miscellaneous-slider>
</div>
<div v-for="(sensor, index) of filamentSensors" v-bind:key="'sensor_'+index">
<v-divider v-if="index || miscellaneous.length"></v-divider>
<filament-sensor
:name="sensor.name"
:enabled="sensor.enabled"
:filament_detected="sensor.filament_detected"
></filament-sensor>
</div>
</v-card>
</div>
<v-card class="mb-6" v-if="klipperReadyForGui && (miscellaneous.length || filamentSensors.length)">
<v-toolbar flat dense >
<v-toolbar-title>
<span class="subheading"><v-icon left>mdi-dip-switch</v-icon>{{ $t("Panels.MiscellaneousPanel.Miscellaneous") }}</span>
</v-toolbar-title>
</v-toolbar>
<div v-for="(object, index) of miscellaneous" v-bind:key="index">
<v-divider v-if="index"></v-divider>
<miscellaneous-slider
:name="object.name"
:type="object.type"
:target="object.power"
:rpm="object.rpm"
:controllable="object.controllable"
:pwm="object.pwm"
:off_below="object.off_below"
:max="object.max_power"
:multi="parseInt(object.scale)"
></miscellaneous-slider>
</div>
<div v-for="(sensor, index) of filamentSensors" v-bind:key="'sensor_'+index">
<v-divider v-if="index || miscellaneous.length"></v-divider>
<filament-sensor
:name="sensor.name"
:enabled="sensor.enabled"
:filament_detected="sensor.filament_detected"
></filament-sensor>
</div>
</v-card>
</template>
<script lang="ts">
@@ -56,18 +42,9 @@ import MiscellaneousSlider from "@/components/inputs/MiscellaneousSlider.vue";
import ToolSlider from "@/components/inputs/ToolSlider.vue";
import FilamentSensor from "@/components/inputs/FilamentSensor.vue";
@Component({
components: {FilamentSensor, ToolSlider, MiscellaneousSlider}
components: {FilamentSensor, MiscellaneousSlider}
})
export default class MiscellaneousPanel extends Mixins(BaseMixin) {
get extrude_factor() {
return this.$store.state.printer?.gcode_move?.extrude_factor ?? 1
}
get speed_factor() {
return this.$store.state.printer?.gcode_move?.speed_factor ?? 1
}
get miscellaneous() {
return this.$store.getters['printer/getMiscellaneous'] ?? []
}
@@ -75,9 +52,5 @@ export default class MiscellaneousPanel extends Mixins(BaseMixin) {
get filamentSensors() {
return this.$store.getters['printer/getFilamentSensors'] ?? []
}
get existsExtruder() {
return 'extruder' in this.$store.state.printer
}
}
</script>
@@ -0,0 +1,42 @@
<style scoped>
</style>
<template>
<v-card class="mb-6" v-if="klipperReadyForGui && ['printing', 'paused'].includes(printer_state)">
<v-toolbar flat dense >
<v-toolbar-title>
<span class="subheading"><v-icon class="mdi mdi-printer-3d" left></v-icon>{{ $t("Panels.MiscellaneousPanel.PrintSettings") }}</span>
</v-toolbar-title>
</v-toolbar>
<tool-slider :label="$t('Panels.MiscellaneousPanel.SpeedFactor')" :target="speed_factor" :max="200" :multi="100" :step="5" :dynamic-range="true" command="M220" attribute-name="S" ></tool-slider>
<template v-if="existsExtruder">
<v-divider></v-divider>
<tool-slider :label="$t('Panels.MiscellaneousPanel.ExtrusionFactor')" :target="extrude_factor" :max="200" :multi="100" :step="1" command="M221" attribute-name="S" ></tool-slider>
</template>
</v-card>
</template>
<script lang="ts">
import {Component, Mixins} from "vue-property-decorator";
import BaseMixin from "@/components/mixins/base";
import ToolSlider from "@/components/inputs/ToolSlider.vue";
@Component({
components: {ToolSlider}
})
export default class PrintsettingsPanel extends Mixins(BaseMixin) {
get extrude_factor() {
return this.$store.state.printer?.gcode_move?.extrude_factor ?? 1
}
get speed_factor() {
return this.$store.state.printer?.gcode_move?.speed_factor ?? 1
}
get existsExtruder() {
return 'extruder' in this.$store.state.printer
}
}
</script>
+42 -53
View File
@@ -148,18 +148,31 @@
<v-container class="py-0">
<v-row class="text-center py-5" align="center">
<v-col class="col-3 pa-0">
<strong>{{ $t("Panels.StatusPanel.Speed") }}</strong><br />
<span class="text-no-wrap">{{ requested_speed }} mm/s</span>
<template v-if="live_velocity !== null">
<v-tooltip top>
<template v-slot:activator="{ on, attrs }">
<div v-bind="attrs" v-on="on">
<strong>{{ $t("Panels.StatusPanel.Speed") }}</strong><br />
<span class="text-no-wrap">{{ live_velocity }} mm/s</span>
</div>
</template>
<span>{{ $t("Panels.StatusPanel.Requested") }}: {{ requested_speed+" mm/s" }}</span>
</v-tooltip>
</template>
<template v-else>
<strong>{{ $t("Panels.StatusPanel.Speed") }}</strong><br />
<span class="text-no-wrap">{{ requested_speed }} mm/s</span>
</template>
</v-col>
<v-col class="col-3 pa-0">
<v-tooltip top>
<template v-slot:activator="{ on, attrs }">
<div v-bind="attrs" v-on="on">
<strong>{{ $t("Panels.StatusPanel.Flow") }}</strong><br />
<span class="d-block text-center text-no-wrap">{{ maxFlow.lastValue ? maxFlow.lastValue.toFixed(1)+" mm&sup3;/s" : "--" }}</span>
<span class="d-block text-center text-no-wrap">{{ live_flow+" mm&sup3;/s" }}</span>
</div>
</template>
<span>{{ $t("Panels.StatusPanel.Max") }}: {{ maxFlow.maxValue ? maxFlow.maxValue.toFixed(1)+" mm&sup3;/s" : "--" }}</span>
<span>{{ $t("Panels.StatusPanel.Max") }}: {{ maxFlow ? maxFlow+" mm&sup3;/s" : "--" }}</span>
</v-tooltip>
</v-col>
<v-col class="col-3 pa-0">
@@ -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
}
}
</script>
+1
View File
@@ -317,6 +317,7 @@
"CancelPrint": "Cancel print",
"ClearPrintStats": "Clear print stats",
"ReprintJob": "Reprint job",
"Requested": "Requested",
"Speed": "Speed",
"Flow": "Flow",
"Max": "max",
+3
View File
@@ -8,6 +8,7 @@
<webcam-panel v-if="showDashboardWebcam"></webcam-panel>
<z-offset-panel></z-offset-panel>
<control-panel></control-panel>
<printsettings-panel></printsettings-panel>
<miscellaneous-panel></miscellaneous-panel>
</v-col>
<v-col class="col-sm-12 col-md-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,
+1 -1
View File
@@ -32,7 +32,7 @@ export const getters: GetterTree<PrinterState, RootState> = {
},
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