feat: add SET_PRINT_STATS_INFO command support (#1034)
This commit is contained in:
parent
d5cafaaa06
commit
57bb268ea0
@ -189,34 +189,11 @@ export default class StatusPanelPrintstatusPrinting extends Mixins(BaseMixin) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get max_layers() {
|
get max_layers() {
|
||||||
if (
|
return this.$store.getters['printer/getPrintMaxLayers'] ?? 0
|
||||||
'first_layer_height' in this.current_file &&
|
|
||||||
'layer_height' in this.current_file &&
|
|
||||||
'object_height' in this.current_file
|
|
||||||
) {
|
|
||||||
const max = Math.ceil(
|
|
||||||
(this.current_file.object_height - this.current_file.first_layer_height) /
|
|
||||||
this.current_file.layer_height +
|
|
||||||
1
|
|
||||||
)
|
|
||||||
return max > 0 ? max : 0
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get current_layer() {
|
get current_layer() {
|
||||||
if (this.print_time > 0 && 'first_layer_height' in this.current_file && 'layer_height' in this.current_file) {
|
return this.$store.getters['printer/getPrintCurrentLayer'] ?? 0
|
||||||
const gcodePositionZ = this.$store.state.printer.gcode_move?.gcode_position[2] ?? 0
|
|
||||||
let current_layer = Math.ceil(
|
|
||||||
(gcodePositionZ - this.current_file.first_layer_height) / this.current_file.layer_height + 1
|
|
||||||
)
|
|
||||||
current_layer = current_layer <= this.max_layers ? current_layer : this.max_layers
|
|
||||||
|
|
||||||
return current_layer > 0 ? current_layer : 0
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get estimated_time_file() {
|
get estimated_time_file() {
|
||||||
|
@ -96,6 +96,48 @@ export const getters: GetterTree<PrinterState, RootState> = {
|
|||||||
return state.virtual_sdcard?.progress ?? 0
|
return state.virtual_sdcard?.progress ?? 0
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getPrintMaxLayers: (state) => {
|
||||||
|
if (state.print_stats?.info?.total_layer !== null) {
|
||||||
|
return state.print_stats.info.total_layer
|
||||||
|
} else if (state.current_file?.layer_count) {
|
||||||
|
return state.current_file.layer_count
|
||||||
|
} else if (
|
||||||
|
'current_file' in state &&
|
||||||
|
'first_layer_height' in state.current_file &&
|
||||||
|
'layer_height' in state.current_file &&
|
||||||
|
'object_height' in state.current_file
|
||||||
|
) {
|
||||||
|
const max = Math.ceil(
|
||||||
|
(state.current_file.object_height - state.current_file.first_layer_height) /
|
||||||
|
state.current_file.layer_height +
|
||||||
|
1
|
||||||
|
)
|
||||||
|
return max > 0 ? max : 0
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0
|
||||||
|
},
|
||||||
|
|
||||||
|
getPrintCurrentLayer: (state, getters) => {
|
||||||
|
if (state.print_stats?.info?.current_layer !== null) {
|
||||||
|
return state.print_stats.info.current_layer
|
||||||
|
} else if (
|
||||||
|
state.print_stats?.print_duration > 0 &&
|
||||||
|
'first_layer_height' in state.current_file &&
|
||||||
|
'layer_height' in state.current_file
|
||||||
|
) {
|
||||||
|
const gcodePositionZ = state.gcode_move?.gcode_position[2] ?? 0
|
||||||
|
const current_layer = Math.ceil(
|
||||||
|
(gcodePositionZ - state.current_file.first_layer_height) / state.current_file.layer_height + 1
|
||||||
|
)
|
||||||
|
|
||||||
|
if (current_layer > getters.getPrintMaxLayers) return getters.getPrintMaxLayers
|
||||||
|
if (current_layer > 0) return current_layer
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0
|
||||||
|
},
|
||||||
|
|
||||||
getMacros: (state) => {
|
getMacros: (state) => {
|
||||||
const array: PrinterStateMacro[] = []
|
const array: PrinterStateMacro[] = []
|
||||||
const config = state.configfile?.config ?? {}
|
const config = state.configfile?.config ?? {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user