Merge remote-tracking branch 'origin/master'

This commit is contained in:
Stefan Dej 2021-08-01 14:06:12 +02:00
commit fd1f70649f
3 changed files with 44 additions and 54 deletions

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>

View File

@ -317,6 +317,7 @@
"CancelPrint": "Cancel print",
"ClearPrintStats": "Clear print stats",
"ReprintJob": "Reprint job",
"Requested": "Requested",
"Speed": "Speed",
"Flow": "Flow",
"Max": "max",

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