feature: new estimate time calculation
move getters to printer/getters Signed-off-by: meteyou <meteyou@gmail.com>
This commit is contained in:
parent
f068a2ef21
commit
e9179e5bcd
19
src/App.vue
19
src/App.vue
@ -157,6 +157,7 @@ export default {
|
||||
printername: state => state.gui.general.printername,
|
||||
virtual_sdcard: state => state.printer.virtual_sdcard,
|
||||
current_file: state => state.printer.print_stats.filename,
|
||||
current_file_position: state => state.printer.virtual_sdcard.file_position,
|
||||
boolNaviWebcam: state => state.gui.webcam.bool,
|
||||
config: state => state.printer.configfile.config,
|
||||
save_config_pending: state => state.printer.configfile.save_config_pending,
|
||||
@ -164,7 +165,12 @@ export default {
|
||||
...mapGetters([
|
||||
'getTitle',
|
||||
'getVersion'
|
||||
])
|
||||
]),
|
||||
print_percent: {
|
||||
get() {
|
||||
return this.$store.getters["printer/getPrintPercent"];
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
clickEmergencyStop: function() {
|
||||
@ -242,17 +248,12 @@ export default {
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
virtual_sdcard: {
|
||||
deep: true,
|
||||
handler: function(val) {
|
||||
let progress = (val && val.progress) ? val.progress : 0;
|
||||
|
||||
this.drawFavicon(progress);
|
||||
}
|
||||
current_file_position() {
|
||||
this.drawFavicon(this.print_percent);
|
||||
},
|
||||
current_file: {
|
||||
handler: function(newVal) {
|
||||
this.$socket.sendObj("server.files.metadata", { filename: newVal }, "getMetadataCurrentFile");
|
||||
this.$socket.sendObj("server.files.metadata", { filename: newVal }, "files/getMetadataCurrentFile");
|
||||
}
|
||||
},
|
||||
config() {
|
||||
|
@ -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: {
|
||||
|
@ -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);
|
||||
|
@ -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 () {
|
||||
|
@ -8,10 +8,10 @@
|
||||
<div>
|
||||
<v-row class="px-6" >
|
||||
<v-col sm-12>
|
||||
<v-switch v-model="enabled" :label="enabled ? 'enabled' : 'disabled'" @change="changeSensor()" class="settingsRunoutSwitchInput my-0"></v-switch>
|
||||
<v-switch v-model="value" :label="enabled ? 'enabled' : 'disabled'" @change="changeSensor()" class="settingsRunoutSwitchInput my-0"></v-switch>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row class="px-6" v-if="enabled" >
|
||||
<v-row class="px-6" v-if="value" >
|
||||
<v-col sm-12>
|
||||
<label class="mt-1 d-inline-block">Filament:</label>
|
||||
<v-chip class="float-right" :color="filament_detected ? 'green' : 'red' " text-color="white">{{ filament_detected ? 'detected' : 'empty' }}</v-chip>
|
||||
@ -22,47 +22,30 @@
|
||||
|
||||
|
||||
<script>
|
||||
import { mapGetters } from 'vuex';
|
||||
|
||||
export default {
|
||||
data: function() {
|
||||
return {
|
||||
value: false,
|
||||
enabled: false,
|
||||
filament_detected: false,
|
||||
}
|
||||
},
|
||||
props: {
|
||||
name: String,
|
||||
enabled: Boolean,
|
||||
filament_detected: Boolean,
|
||||
|
||||
},
|
||||
computed: {
|
||||
...mapGetters([
|
||||
'getFilamentSwitchSensors'
|
||||
])
|
||||
|
||||
},
|
||||
methods: {
|
||||
changeSensor() {
|
||||
let gcode = 'SET_FILAMENT_SENSOR SENSOR='+this.name+' ENABLE='+(this.enabled ? 1 : 0);
|
||||
this.$socket.sendObj('printer.gcode.script', { script: gcode });
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
getFilamentSwitchSensors: function() {
|
||||
let sensor = this.getFilamentSwitchSensors.find(sensor => sensor.name === this.name);
|
||||
|
||||
if (sensor) {
|
||||
this.enabled = sensor.enabled;
|
||||
this.filament_detected = sensor.filament_detected;
|
||||
}
|
||||
let gcode = 'SET_FILAMENT_SENSOR SENSOR='+this.name+' ENABLE='+(this.value ? 1 : 0)
|
||||
this.$store.commit('server/addEvent', gcode)
|
||||
this.$socket.sendObj('printer.gcode.script', { script: gcode })
|
||||
}
|
||||
},
|
||||
created() {
|
||||
let sensor = this.getFilamentSwitchSensors.find(sensor => sensor.name === this.name);
|
||||
|
||||
if (sensor) {
|
||||
this.enabled = sensor.enabled;
|
||||
this.filament_detected = sensor.filament_detected;
|
||||
}
|
||||
this.value = this.enabled
|
||||
}
|
||||
}
|
||||
</script>
|
@ -10,4 +10,14 @@ export function findDirectory (folder, dirArray) {
|
||||
} else return parent.childrens;
|
||||
} else return folder;
|
||||
}
|
||||
}
|
||||
|
||||
export function caseInsensitiveNameSort(a, b) {
|
||||
let nameA = a.name.toUpperCase();
|
||||
let nameB = b.name.toUpperCase();
|
||||
|
||||
if (nameA < nameB) return -1;
|
||||
if (nameA > nameB) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
@ -74,6 +74,7 @@ export default {
|
||||
|
||||
let index = path.findIndex(element => element.filename === filename);
|
||||
if (index >= 0 && path[index]) {
|
||||
|
||||
const safeDefault = (value, def = undefined) => value ? value : def;
|
||||
let newData = {
|
||||
estimated_time: safeDefault(payload.estimated_time),
|
||||
@ -81,6 +82,8 @@ export default {
|
||||
first_layer_height: safeDefault(payload.first_layer_height),
|
||||
first_layer_bed_temp: safeDefault(payload.first_layer_bed_temp),
|
||||
first_layer_extr_temp: safeDefault(payload.first_layer_extr_temp),
|
||||
gcode_start_byte: safeDefault(payload.gcode_start_byte),
|
||||
gcode_end_byte: safeDefault(payload.gcode_end_byte),
|
||||
layer_height: safeDefault(payload.layer_height),
|
||||
object_height: safeDefault(payload.object_height),
|
||||
slicer: safeDefault(payload.slicer),
|
||||
|
@ -1,167 +1,27 @@
|
||||
function caseInsensitiveNameSort(a, b) {
|
||||
let nameA = a.name.toUpperCase();
|
||||
let nameB = b.name.toUpperCase();
|
||||
|
||||
if (nameA < nameB) return -1;
|
||||
if (nameA > nameB) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
import { caseInsensitiveNameSort } from '@/plugins/helpers'
|
||||
|
||||
export default {
|
||||
getVersion: state => {
|
||||
return state.packageVersion
|
||||
},
|
||||
|
||||
heaters: state => {
|
||||
let heaters = [];
|
||||
getTitle: (state, getters) => {
|
||||
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 === "complete") return "Complete - "+state.printer.print_stats.filename
|
||||
|
||||
if (state.printer.heaters.available_heaters) {
|
||||
for (let [key, value] of Object.entries(state.printer)) {
|
||||
if (state.printer.heaters.available_heaters.includes(key)) {
|
||||
let name = key;
|
||||
let nameSplit = key.split(" ");
|
||||
|
||||
if (nameSplit.length > 1 && nameSplit[0] === "heater_generic") name = nameSplit[1];
|
||||
|
||||
heaters.push({
|
||||
name: name,
|
||||
target: value.target,
|
||||
temperature: value.temperature,
|
||||
min_temp: state.printer.configfile.config[key] !== undefined ? parseFloat(state.printer.configfile.config[key].min_temp) : undefined,
|
||||
max_temp: state.printer.configfile.config[key] !== undefined ? parseFloat(state.printer.configfile.config[key].max_temp) : undefined,
|
||||
});
|
||||
}
|
||||
}
|
||||
return state.gui.general.printername ? state.gui.general.printername : state.printer.hostname
|
||||
}
|
||||
|
||||
return heaters.sort(caseInsensitiveNameSort);
|
||||
},
|
||||
|
||||
heatersCount: (state, getters) => {
|
||||
return getters.heaters.length;
|
||||
},
|
||||
|
||||
temperature_fans: state => {
|
||||
let fans = [];
|
||||
|
||||
for (let [key, value] of Object.entries(state.printer)) {
|
||||
let nameSplit = key.split(" ");
|
||||
|
||||
if (nameSplit[0] === "temperature_fan") {
|
||||
fans.push({
|
||||
name: nameSplit[1],
|
||||
target: value.target,
|
||||
temperature: value.temperature,
|
||||
speed: value.speed,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return fans.sort(caseInsensitiveNameSort);
|
||||
},
|
||||
|
||||
temperature_sensors: state => {
|
||||
let sensors = [];
|
||||
|
||||
for (let [key, value] of Object.entries(state.printer)) {
|
||||
let nameSplit = key.split(" ");
|
||||
|
||||
if (nameSplit[0] === "temperature_sensor") {
|
||||
sensors.push({
|
||||
name: nameSplit[1],
|
||||
temperature: value.temperature,
|
||||
measured_min_temp: value.measured_min_temp,
|
||||
measured_max_temp: value.measured_max_temp,
|
||||
});
|
||||
}
|
||||
|
||||
if (nameSplit[0] === "temperature_probe") {
|
||||
sensors.push({
|
||||
name: "Probe",
|
||||
temperature: value.temperature,
|
||||
//TODO: update measured_temps
|
||||
measured_min_temp: 0,
|
||||
measured_max_temp: 0,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return sensors.sort(caseInsensitiveNameSort);
|
||||
},
|
||||
|
||||
current_file_size: state => {
|
||||
if (state.printer.print_stats.filename === state.printer.current_file.filename) {
|
||||
return state.printer.current_file.size;
|
||||
}
|
||||
|
||||
return 0;
|
||||
},
|
||||
|
||||
current_file_metadata: state => {
|
||||
return state.printer.current_file;
|
||||
},
|
||||
|
||||
current_file_estimated_time: state => {
|
||||
if (state.printer.print_stats.filename === state.printer.current_file.filename) {
|
||||
return state.printer.current_file.estimated_time;
|
||||
}
|
||||
|
||||
return 0;
|
||||
},
|
||||
|
||||
current_file_filament_total: state => {
|
||||
if (state.printer.print_stats.filename === state.printer.current_file.filename) {
|
||||
return state.printer.current_file.filament_total;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return "Mainsail"
|
||||
},
|
||||
|
||||
is_printing: state => {
|
||||
return (["printing", "paused"].includes(state.printer.print_stats.state));
|
||||
},
|
||||
|
||||
getMacros: state => {
|
||||
let array = [];
|
||||
let hiddenMacros = [];
|
||||
state.gui.dashboard.hiddenMacros.forEach(function(item,index) {
|
||||
hiddenMacros[index] = item.toLowerCase();
|
||||
});
|
||||
|
||||
for (let prop in state.printer.configfile.config) {
|
||||
if (prop.startsWith("gcode_macro") &&
|
||||
!Object.hasOwnProperty.call(state.printer.configfile.config[prop], "rename_existing") &&
|
||||
!(hiddenMacros.indexOf(prop.replace("gcode_macro ", "").toLowerCase()) > -1)
|
||||
) {
|
||||
array.push({
|
||||
"name": prop.replace("gcode_macro ", ""),
|
||||
"prop": state.printer.configfile.config[prop]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return array.sort(caseInsensitiveNameSort);
|
||||
},
|
||||
|
||||
getFilamentSwitchSensors: state => {
|
||||
let sensors = [];
|
||||
|
||||
for (let [key, value] of Object.entries(state.printer)) {
|
||||
let nameSplit = key.split(" ");
|
||||
|
||||
if (nameSplit[0] === "filament_switch_sensor") {
|
||||
sensors.push({
|
||||
name: nameSplit[1],
|
||||
enabled: value.enabled,
|
||||
filament_detected: value.filament_detected,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return sensors.sort(caseInsensitiveNameSort);
|
||||
},
|
||||
|
||||
getBedMeshProfiles: state => {
|
||||
let profiles = [];
|
||||
let currentProfile = "";
|
||||
@ -184,43 +44,10 @@ export default {
|
||||
return profiles.sort(caseInsensitiveNameSort);
|
||||
},
|
||||
|
||||
getTitle: state => {
|
||||
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 (state.printer.virtual_sdcard.progress * 100).toFixed(0)+"% Printing - "+state.printer.print_stats.filename;
|
||||
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;
|
||||
} else return "Mainsail";
|
||||
},
|
||||
|
||||
showDashboardWebcam: state => {
|
||||
return (state.gui.webcam.url !== "" && state.gui.dashboard.boolWebcam);
|
||||
},
|
||||
|
||||
getCurrentExtruder: state => {
|
||||
if (state.printer.configfile.config === null) return null;
|
||||
|
||||
let extruder = {
|
||||
name: "",
|
||||
status: null,
|
||||
config: null,
|
||||
};
|
||||
let extruderName = state.printer.toolhead.extruder;
|
||||
extruder.name = extruderName;
|
||||
|
||||
if (state.printer.configfile.config[extruderName]) {
|
||||
extruder.config = state.printer.configfile.config[extruderName];
|
||||
}
|
||||
|
||||
if (state.printer[extruderName]) {
|
||||
extruder.status = state.printer[extruderName];
|
||||
}
|
||||
|
||||
return extruder;
|
||||
},
|
||||
|
||||
existPrinterConfig: state => {
|
||||
if (
|
||||
typeof(state.printer.configfile.config) === "object" &&
|
||||
@ -230,8 +57,6 @@ export default {
|
||||
return false;
|
||||
},
|
||||
|
||||
|
||||
|
||||
checkConfigVirtualSdcard: state => {
|
||||
return 'virtual_sdcard' in state.printer.configfile.config;
|
||||
},
|
||||
|
@ -1,5 +1,112 @@
|
||||
import { caseInsensitiveNameSort } from '@/plugins/helpers'
|
||||
|
||||
export default {
|
||||
|
||||
getPrintPercent: state => {
|
||||
if (
|
||||
'filename' in state.current_file &&
|
||||
'gcode_start_byte' in state.current_file &&
|
||||
'gcode_end_byte' in state.current_file &&
|
||||
state.current_file.filename === state.print_stats.filename
|
||||
) {
|
||||
if (state.virtual_sdcard.file_position <= state.current_file.gcode_start_byte) return 0
|
||||
if (state.virtual_sdcard.file_position >= state.current_file.gcode_end_byte) return 1
|
||||
|
||||
let currentPosition = state.virtual_sdcard.file_position - state.current_file.gcode_start_byte;
|
||||
let maxPosition = state.current_file.gcode_end_byte - state.current_file.gcode_start_byte;
|
||||
|
||||
if (currentPosition > 0 && maxPosition > 0) return 1 / maxPosition * currentPosition;
|
||||
}
|
||||
|
||||
return state.virtual_sdcard.progress
|
||||
},
|
||||
|
||||
getMacros: (state, getters, rootState) => {
|
||||
let array = []
|
||||
let hiddenMacros = []
|
||||
rootState.gui.dashboard.hiddenMacros.forEach(function(item,index) {
|
||||
hiddenMacros[index] = item.toLowerCase()
|
||||
});
|
||||
|
||||
for (let prop in state.configfile.config) {
|
||||
if (
|
||||
prop.startsWith("gcode_macro") &&
|
||||
!("rename_existing" in state.configfile.config[prop]) &&
|
||||
!(hiddenMacros.indexOf(prop.replace("gcode_macro ", "").toLowerCase()) > -1)
|
||||
) {
|
||||
array.push({
|
||||
"name": prop.replace("gcode_macro ", ""),
|
||||
"prop": state.configfile.config[prop]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return array.sort(caseInsensitiveNameSort);
|
||||
},
|
||||
|
||||
getHeaters: state => {
|
||||
let heaters = []
|
||||
|
||||
if (state.heaters.available_heaters) {
|
||||
for (let [key, value] of Object.entries(state)) {
|
||||
if (state.heaters.available_heaters.includes(key)) {
|
||||
let name = key;
|
||||
let nameSplit = key.split(" ");
|
||||
|
||||
if (nameSplit.length > 1 && nameSplit[0] === "heater_generic") name = nameSplit[1];
|
||||
|
||||
heaters.push({
|
||||
name: name,
|
||||
target: value.target,
|
||||
temperature: value.temperature,
|
||||
min_temp: state.configfile.config[key] !== undefined ? parseFloat(state.configfile.config[key].min_temp) : undefined,
|
||||
max_temp: state.configfile.config[key] !== undefined ? parseFloat(state.configfile.config[key].max_temp) : undefined,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return heaters.sort(caseInsensitiveNameSort);
|
||||
},
|
||||
|
||||
getTemperatureFans: state => {
|
||||
let fans = []
|
||||
|
||||
for (let [key, value] of Object.entries(state)) {
|
||||
let nameSplit = key.split(" ")
|
||||
|
||||
if (nameSplit[0] === "temperature_fan") {
|
||||
fans.push({
|
||||
name: nameSplit[1],
|
||||
target: value.target,
|
||||
temperature: value.temperature,
|
||||
speed: value.speed,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return fans.sort(caseInsensitiveNameSort)
|
||||
},
|
||||
|
||||
getTemperatureSensors: state => {
|
||||
let sensors = []
|
||||
|
||||
for (let [key, value] of Object.entries(state)) {
|
||||
let nameSplit = key.split(" ")
|
||||
|
||||
if (nameSplit[0] === "temperature_sensor") {
|
||||
sensors.push({
|
||||
name: nameSplit[1],
|
||||
temperature: value.temperature,
|
||||
measured_min_temp: value.measured_min_temp,
|
||||
measured_max_temp: value.measured_max_temp,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return sensors.sort(caseInsensitiveNameSort)
|
||||
},
|
||||
|
||||
getPartFanSpeed: state => {
|
||||
return "fan" in state ? state.fan.speed : 0;
|
||||
},
|
||||
@ -73,6 +180,24 @@ export default {
|
||||
})
|
||||
},
|
||||
|
||||
getFilamentSwitchSensors: state => {
|
||||
let sensors = []
|
||||
|
||||
for (let [key, value] of Object.entries(state)) {
|
||||
let nameSplit = key.split(" ")
|
||||
|
||||
if (nameSplit[0] === "filament_switch_sensor") {
|
||||
sensors.push({
|
||||
name: nameSplit[1],
|
||||
enabled: value.enabled,
|
||||
filament_detected: value.filament_detected,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return sensors.sort(caseInsensitiveNameSort)
|
||||
},
|
||||
|
||||
getExtrudePossible: state => {
|
||||
if ("toolhead" in state) {
|
||||
let extruderName = state.toolhead.extruder;
|
||||
|
Loading…
x
Reference in New Issue
Block a user