feature: add ETA to page title
Signed-off-by: Stefan Dej <meteyou@gmail.com>
This commit is contained in:
parent
261794630d
commit
d643e63017
@ -300,54 +300,22 @@
|
||||
},
|
||||
estimated_time_file: {
|
||||
get() {
|
||||
if (this.print_time > 0 && this.printPercent > 0) {
|
||||
return (this.print_time / this.printPercent - this.print_time).toFixed(0)
|
||||
}
|
||||
|
||||
return 0
|
||||
return this.$store.getters.getEstimatedTimeFile
|
||||
}
|
||||
},
|
||||
estimated_time_filament: {
|
||||
get() {
|
||||
if (this.filament_used > 0 && 'filament_total' in this.current_file && this.current_file.filament_total > this.filament_used) {
|
||||
return (this.print_time / (this.filament_used / this.current_file.filament_total) - this.print_time).toFixed(0)
|
||||
}
|
||||
|
||||
return 0
|
||||
return this.$store.getters.getEstimatedTimeFilament
|
||||
}
|
||||
},
|
||||
estimated_time_slicer: {
|
||||
get() {
|
||||
if ('estimated_time' in this.current_file && this.current_file.estimated_time > this.print_time) {
|
||||
return (this.current_file.estimated_time - this.print_time).toFixed(0)
|
||||
}
|
||||
|
||||
return 0
|
||||
return this.$store.getters.getEstimatedTimeSlicer
|
||||
}
|
||||
},
|
||||
eta: {
|
||||
get() {
|
||||
let time = 0
|
||||
let timeCount = 0
|
||||
|
||||
if (this.estimated_time_file > 0) {
|
||||
time += parseInt(this.estimated_time_file)
|
||||
timeCount++
|
||||
}
|
||||
|
||||
if (this.estimated_time_filament > 0) {
|
||||
time += parseInt(this.estimated_time_filament)
|
||||
timeCount++
|
||||
}
|
||||
|
||||
if (this.estimated_time_slicer > 0) {
|
||||
time += parseInt(this.estimated_time_slicer)
|
||||
timeCount++
|
||||
}
|
||||
|
||||
if (time && timeCount) return Date.now() + (time / timeCount) * 1000
|
||||
|
||||
return 0
|
||||
return this.$store.getters.getEstimatedTimeETA
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -7,7 +7,18 @@ export default {
|
||||
if (state.socket.isConnected) {
|
||||
if (state.server.klippy_state !== "ready") return "ERROR"
|
||||
else if (state.printer.print_stats.state === "paused") return "Pause Print"
|
||||
else if (state.printer.print_stats.state === "printing") return (getters["printer/getPrintPercent"] * 100).toFixed(0)+"% Printing - "+state.printer.print_stats.filename
|
||||
else if (state.printer.print_stats.state === "printing") {
|
||||
const eta = getters["printer/getEstimatedTimeETA"]
|
||||
const date = new Date(eta)
|
||||
const h = date.getHours() >= 10 ? date.getHours() : "0"+date.getHours()
|
||||
const m = date.getMinutes() >= 10 ? date.getMinutes() : "0"+date.getMinutes()
|
||||
|
||||
let output = (getters["printer/getPrintPercent"] * 100).toFixed(0)+"% Printing"
|
||||
output += " - ETA: "+h+":"+m
|
||||
output += " - "+state.printer.print_stats.filename
|
||||
|
||||
return output
|
||||
}
|
||||
else if (state.printer.print_stats.state === "complete") return "Complete - "+state.printer.print_stats.filename
|
||||
|
||||
return state.gui.general.printername ? state.gui.general.printername : state.printer.hostname
|
||||
|
@ -531,4 +531,74 @@ export default {
|
||||
checkConfigMacroCancel: state => {
|
||||
return Object.keys(state.configfile.config).findIndex(key => key.toLowerCase() === 'gcode_macro cancel_print') !== -1;
|
||||
},
|
||||
|
||||
getEstimatedTimeFile: (state, getters) => {
|
||||
if (
|
||||
'print_stats' in state &&
|
||||
'print_duration' in state.print_stats &&
|
||||
state.print_stats.print_duration > 0 &&
|
||||
getters.getPrintPercent > 0
|
||||
) {
|
||||
return (state.print_stats.print_duration / getters.getPrintPercent - state.print_stats.print_duration).toFixed(0)
|
||||
}
|
||||
|
||||
return 0
|
||||
},
|
||||
|
||||
getEstimatedTimeFilament: (state) => {
|
||||
if (
|
||||
'print_stats' in state &&
|
||||
'print_duration' in state.print_stats &&
|
||||
'filament_used' in state.print_stats &&
|
||||
'current_file' in state &&
|
||||
'filament_total' in state.current_file &&
|
||||
state.print_stats.print_duration > 0 &&
|
||||
state.current_file.filament_total > 0 &&
|
||||
state.current_file.filament_total > state.print_stats.filament_used
|
||||
) {
|
||||
return (state.print_stats.print_duration / (state.print_stats.filament_used / state.current_file.filament_total) - state.print_stats.print_duration).toFixed(0)
|
||||
}
|
||||
|
||||
return 0
|
||||
},
|
||||
|
||||
getEstimatedTimeSlicer: (state) => {
|
||||
if (
|
||||
'print_stats' in state &&
|
||||
'print_duration' in state.print_stats &&
|
||||
'current_file' in state &&
|
||||
'estimated_time' in state.current_file &&
|
||||
state.print_stats.print_duration > 0 &&
|
||||
state.current_file.estimated_time > 0 &&
|
||||
state.current_file.estimated_time > state.print_stats.print_duration
|
||||
) {
|
||||
return (state.current_file.estimated_time - state.print_stats.print_duration).toFixed(0)
|
||||
}
|
||||
|
||||
return 0
|
||||
},
|
||||
|
||||
getEstimatedTimeETA: (getters) => {
|
||||
let time = 0
|
||||
let timeCount = 0
|
||||
|
||||
if (getters.getEstimatedTimeFile > 0) {
|
||||
time += parseInt(getters.getEstimatedTimeFile)
|
||||
timeCount++
|
||||
}
|
||||
|
||||
if (getters.getEstimatedTimeFilament > 0) {
|
||||
time += parseInt(getters.getEstimatedTimeFilament)
|
||||
timeCount++
|
||||
}
|
||||
|
||||
if (getters.getEstimatedTimeSlicer > 0) {
|
||||
time += parseInt(getters.getEstimatedTimeSlicer)
|
||||
timeCount++
|
||||
}
|
||||
|
||||
if (time && timeCount) return Date.now() + (time / timeCount) * 1000
|
||||
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user