feature: new estimate time calculation

move getters to printer/getters

Signed-off-by: meteyou <meteyou@gmail.com>
This commit is contained in:
meteyou committed 2020-11-19 00:29:59 +01:00
1 parent f068a2ef21
commit e9179e5bcd
11 files changed
+214 -272

No files matched your search

+3 -3
View File
@@ -50,9 +50,9 @@
</v-btn-toggle>
</v-col>
</v-row>
<v-row class="" v-if="getMacros.length > 0">
<v-row class="" v-if="this['printer/getMacros'].length > 0">
<v-col class="col-12 px-4 py-2 text-center">
<div v-for="(macro, index) in getMacros" v-bind:key="index+99" class="d-inline-block mx-1 my-1">
<div v-for="(macro, index) in this['printer/getMacros']" v-bind:key="index+99" class="d-inline-block mx-1 my-1">
<v-btn color="primary" class="mx-1 my-1" @click="doSend(macro.name)">{{ macro.name.replace(/_/g, " ") }}</v-btn>
</div>
</v-col>
@@ -86,7 +86,7 @@
printer_state: state => state.printer.print_stats.state
}),
...mapGetters([
'getMacros',
'printer/getMacros',
])
},
methods: {
@@ -51,9 +51,8 @@
<div class="text-center">empty</div>
</template>
<template v-slot:body.prepend>
<tr
v-if="(currentPath !== '')"
<template v-slot:top v-if="(currentPath !== '')">
<tr
class="file-list-cursor"
@click="clickRowGoBack">
<td class=" "><v-icon>mdi-folder-upload</v-icon></td>
@@ -1,6 +1,6 @@
<template>
<div>
<div v-for="(runout, index) of getFilamentSwitchSensors" v-bind:key="index">
<div v-for="(runout, index) of this['printer/getFilamentSwitchSensors']" v-bind:key="index">
<v-card class="mt-6">
<v-list-item>
<v-list-item-avatar color="grey"><v-icon dark>mdi-printer-3d-nozzle-alert</v-icon></v-list-item-avatar>
@@ -10,7 +10,7 @@
</v-list-item>
<v-divider class="my-2"></v-divider>
<v-card-text class="px-0 pt-0 pb-2 content">
<settings-runout-switch :name="runout.name "></settings-runout-switch>
<settings-runout-switch :name="runout.name" :enabled="runout.enabled" :filament_detected="runout.filament_detected"></settings-runout-switch>
</v-card-text>
</v-card>
</div>
@@ -32,7 +32,7 @@
},
computed: {
...mapGetters([
'getFilamentSwitchSensors'
'printer/getFilamentSwitchSensors'
])
},
methods: {
+27 -30
View File
@@ -15,7 +15,7 @@
:rotate="-90"
:size="50"
:width="7"
:value="printProgress * 100"
:value="printPercent * 100"
color="red"
class="mr-5 mt-2"
v-if="['printing', 'paused', 'error'].includes(printer_state)"
@@ -23,8 +23,8 @@
</v-progress-circular>
<v-list-item-avatar color="grey" v-if="!['printing', 'paused', 'error'].includes(printer_state)"><v-icon dark>mdi-information-variant</v-icon></v-list-item-avatar>
<v-list-item-content>
<v-list-item-title class="headline">{{ ['printing', 'paused', 'error'].includes(printer_state) ? Math.round(printProgress * 100)+"% - " : "" }}{{ display_message ? display_message : (printer_state !== "" ? printer_state.charAt(0).toUpperCase() + printer_state.slice(1) : "Unknown") }}</v-list-item-title>
<v-list-item-subtitle class="mr-3" v-if="['printing', 'paused', 'complete', 'error'].includes(printer_state)">{{ "File: "+current_file }}</v-list-item-subtitle>
<v-list-item-title class="headline">{{ ['printing', 'paused', 'error'].includes(printer_state) ? Math.round(printPercent * 100)+"% - " : "" }}{{ display_message ? display_message : (printer_state !== "" ? printer_state.charAt(0).toUpperCase() + printer_state.slice(1) : "Unknown") }}</v-list-item-title>
<v-list-item-subtitle class="mr-3" v-if="['printing', 'paused', 'complete', 'error'].includes(printer_state)">{{ "File: "+current_filename }}</v-list-item-subtitle>
</v-list-item-content>
<v-btn-toggle
color="primary"
@@ -45,23 +45,23 @@
class="col-12 col-sm-4 pl-sm-5 pr-sm-2"
v-if="
['printing', 'paused', 'complete'].includes(printer_state) &&
current_file_metadata &&
current_file_metadata.thumbnails &&
current_file_metadata.thumbnails.length &&
current_file_metadata.thumbnails.find(element => element.width === 400)
current_file &&
current_file.thumbnails &&
current_file.thumbnails.length &&
current_file.thumbnails.find(element => element.width === 400)
">
<img
class="statusPanel-image-preview"
:src="'data:image/gif;base64,'+(current_file_metadata.thumbnails ? current_file_metadata.thumbnails.find(element => element.width === 400).data : '')"
:src="'data:image/gif;base64,'+(current_file.thumbnails ? current_file.thumbnails.find(element => element.width === 400).data : '')"
/>
</v-col>
<v-col
:class="
(['printing', 'paused', 'complete'].includes(printer_state) &&
current_file_metadata &&
current_file_metadata.thumbnails &&
current_file_metadata.thumbnails.length &&
current_file_metadata.thumbnails.find(element => element.width === 400)) ? 'col-12 py-0 col-sm-8 pl-sm-0' : 'col-12 py-0'
current_file &&
current_file.thumbnails &&
current_file.thumbnails.length &&
current_file.thumbnails.find(element => element.width === 400 || element.width === 300)) ? 'col-12 py-0 col-sm-8 pl-sm-0' : 'col-12 py-0'
">
<v-layout wrap class=" text-center">
<v-flex col tag="strong" class="category-header col-auto">
@@ -93,19 +93,19 @@
</v-flex>
<v-flex grow class="equal-width">
<v-layout column>
<v-flex tag="strong">Filament used</v-flex>
<v-flex tag="strong">Filament</v-flex>
<v-flex tag="span">{{ filament_used > 1000 ? (filament_used / 1000).toFixed(2)+"m" : filament_used.toFixed(2)+"mm" }}</v-flex>
</v-layout>
</v-flex>
<v-flex grow class="equal-width">
<v-layout column>
<v-flex tag="strong">Print Time</v-flex>
<v-flex tag="strong">Print</v-flex>
<v-flex tag="span">{{ formatTime(print_time) }}</v-flex>
</v-layout>
</v-flex>
<v-flex grow class="equal-width">
<v-layout column>
<v-flex tag="strong">Total Time</v-flex>
<v-flex tag="strong">Total</v-flex>
<v-flex tag="span">{{ formatTime(print_time_total) }}</v-flex>
</v-layout>
</v-flex>
@@ -118,19 +118,19 @@
<v-flex grow class="equal-width">
<v-layout column>
<v-flex tag="strong">File</v-flex>
<v-flex tag="span">{{ print_time > 0 && printProgress > 0 ? formatTime(print_time / printProgress - print_time) : '--' }}</v-flex>
<v-flex tag="span">{{ print_time > 0 && printPercent > 0 ? formatTime(print_time / printPercent - print_time) : '--' }}</v-flex>
</v-layout>
</v-flex>
<v-flex grow class="equal-width">
<v-layout column>
<v-flex tag="strong">Filament</v-flex>
<v-flex tag="span">{{ (filament_used > 0 && current_file_filament_total > filament_used) ? formatTime(print_time / (filament_used / current_file_filament_total) - print_time) : '--' }}</v-flex>
<v-flex tag="span">{{ (filament_used > 0 && 'filament_total' in current_file && current_file.filament_total > filament_used) ? formatTime(print_time / (filament_used / current_file.filament_total) - print_time) : '--' }}</v-flex>
</v-layout>
</v-flex>
<v-flex grow class="equal-width">
<v-layout column>
<v-flex tag="strong">Slicer</v-flex>
<v-flex tag="span">{{ current_file_estimated_time > print_time ? formatTime(current_file_estimated_time - print_time) : '--'}}</v-flex>
<v-flex tag="span">{{ 'estimated_time' in current_file && current_file.estimated_time > print_time ? formatTime(current_file.estimated_time - print_time) : '--'}}</v-flex>
</v-layout>
</v-flex>
</v-layout>
@@ -141,7 +141,7 @@
</template>
<script>
import { mapState, mapGetters } from 'vuex';
import { mapState } from 'vuex';
export default {
data: function() {
@@ -158,26 +158,23 @@
toolhead: state => state.printer.toolhead,
position: state => state.printer.toolhead.position,
estimated_print_time: state => state.printer.toolhead.estimated_print_time,
printProgress: state => state.printer.virtual_sdcard.progress,
file_position: state => state.printer.virtual_sdcard.file_position,
current_file: state => state.printer.current_file,
print_time: state => state.printer.print_stats.print_duration,
print_time_total: state => state.printer.print_stats.total_duration,
filament_used: state => state.printer.print_stats.filament_used,
current_file: state => state.printer.print_stats.filename,
current_filename: state => state.printer.print_stats.filename,
printer_state: state => state.printer.print_stats.state,
display_message: state => state.printer.display_status.message,
}),
...mapGetters([
'current_file_size',
'current_file_metadata',
'current_file_estimated_time',
'current_file_filament_total',
]),
printPercent: {
get() {
return this.$store.getters["printer/getPrintPercent"];
}
}
},
methods: {
btnPauseJob() {
@@ -203,7 +200,7 @@
btnReprintJob() {
// TODO loading button
//this.$store.commit('setLoading', {name: 'statusPrintReprint'});
this.$socket.sendObj('printer.print.start', { filename: this.current_file }, 'respondPrintReprint');
this.$socket.sendObj('printer.print.start', { filename: this.current_filename }, 'respondPrintReprint');
},
formatTime(seconds) {
let h = Math.floor(seconds / 3600);
+12 -13
View File
@@ -15,11 +15,11 @@
<v-list-item-content>
<v-list-item-title class="headline">Temperatures</v-list-item-title>
<v-list-item-subtitle>
{{ heatersCount }} heaters
<span v-if="temperature_fans.length === 1">, {{ temperature_fans.length }} fan</span>
<span v-if="temperature_fans.length > 1">, {{ temperature_fans.length }} fans</span>
<span v-if="temperature_sensors.length === 1">, {{ temperature_sensors.length }} sensor</span>
<span v-if="temperature_sensors.length > 1">, {{ temperature_sensors.length }} sensors</span>
{{ this['printer/getHeaters'].length }} heaters
<span v-if="this['printer/getTemperatureFans'].length === 1">, {{ this['printer/getTemperatureFans'].length }} fan</span>
<span v-if="this['printer/getTemperatureFans'].length > 1">, {{ this['printer/getTemperatureFans'].length }} fans</span>
<span v-if="this['printer/getTemperatureSensors'].length === 1">, {{ this['printer/getTemperatureSensors'].length }} sensor</span>
<span v-if="this['printer/getTemperatureSensors'].length > 1">, {{ this['printer/getTemperatureSensors'].length }} sensors</span>
</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
@@ -30,7 +30,7 @@
<v-col class="text-center py-0"><b>Current</b></v-col>
<v-col class="text-center py-0"><b>Target</b></v-col>
</v-row>
<div v-for="(heater, index) in heaters" v-bind:key="index" >
<div v-for="(heater, index) in this['printer/getHeaters']" v-bind:key="index" >
<v-divider class="my-2"></v-divider>
<v-row class="pl-3 pr-3 heater-row">
<v-col class="text-center py-0">
@@ -43,7 +43,7 @@
</v-col>
</v-row>
</div>
<div v-for="(fan, index) in temperature_fans" v-bind:key="index+99" >
<div v-for="(fan, index) in this['printer/getTemperatureFans']" v-bind:key="index+99" >
<v-divider class="my-2"></v-divider>
<v-row class="pl-3 pr-3 heater-row">
<v-col class="text-center py-0">
@@ -56,13 +56,13 @@
</v-col>
</v-row>
</div>
<div v-if="temperature_sensors.length" >
<div v-if="this['printer/getTemperatureSensors'].length" >
<v-divider class="my-2"></v-divider>
<v-row class="pl-3 pr-3 heater-row">
<v-col class="text-center py-0">
<b>Temperature<br />Sensors</b>
</v-col>
<v-col class="text-center py-0 vertical_align_center" v-for="(sensor,index) in temperature_sensors" v-bind:key="index+999" >
<v-col class="text-center py-0 vertical_align_center" v-for="(sensor,index) in this['printer/getTemperatureSensors']" v-bind:key="index+999" >
<span style="cursor: default;" :title="'min: '+(sensor.measured_min_temp ? sensor.measured_min_temp.toFixed(1) : 0)+'° / max: '+(sensor.measured_max_temp ? sensor.measured_max_temp.toFixed(1) : 0)+'°'">{{ sensor.temperature ? sensor.temperature.toFixed(1) : 0 }}°C</span><br />
<small style="cursor: default;" :title="'min: '+( sensor.measured_min_temp ? sensor.measured_min_temp.toFixed(1) : 0)+'° / max: '+(sensor.measured_max_temp ? sensor.measured_max_temp.toFixed(1) : 0)+'°'">{{ sensor.name }}</small>
</v-col>
@@ -103,10 +103,9 @@
boolTempchart: state => state.gui.dashboard.boolTempchart,
}),
...mapGetters([
'heaters',
'heatersCount',
'temperature_fans',
'temperature_sensors',
'printer/getHeaters',
'printer/getTemperatureFans',
'printer/getTemperatureSensors',
]),
datasets: {
get () {