feature: customizeable tempchart length (moonraker: temperature_store_size)

bugfix: autoscale chart (ignore hidden series)

Signed-off-by: Stefan Dej <meteyou@gmail.com>
This commit is contained in:
Stefan Dej committed 2021-02-21 22:44:27 +01:00
1 parent d1d84953a1
commit 7e48b08f81
8 files changed
+85 -16

No files matched your search

+18 -8
View File
@@ -14,7 +14,6 @@ export default {
data: function() {
return {
chart : null,
tempchartDisplayMinutes: 10,
timerChart: '',
timerDataset: '',
chartOptions: {
@@ -100,7 +99,8 @@ export default {
type: 'time',
min: new Date() - 60*10,
max: new Date(),
minInterval: 60 * 2 * 1000 + 1,
splitNumber: 5,
//minInterval: 60 * 2 * 1000 + 1,
splitLine: {
show: true,
lineStyle: {
@@ -181,7 +181,7 @@ export default {
},
option: {
xAxis: {
minInterval: 60 * 1000 + 1,
splitNumber: 10,
}
}
}, {
@@ -218,6 +218,11 @@ export default {
intervalChartUpdate: state => state.gui.tempchart.intervalChartUpdate,
intervalDatasetUpdate: state => state.gui.tempchart.intervalDatasetUpdate,
}),
maxHistory: {
get() {
return this.$store.getters["server/getConfig"]('server', 'temperature_store_size') || 1200
}
},
series: {
get () {
return this.$store.state.printer.tempHistory.series
@@ -237,6 +242,11 @@ export default {
get() {
return this.$store.getters["printer/getMaxTemp"]
}
},
currentMaxTemp: {
get() {
return this.$store.getters["printer/tempHistory/getCurrentMaxTemp"]
}
}
},
methods: {
@@ -256,13 +266,13 @@ export default {
this.chart.setOption({
series: this.series,
xAxis: {
min: new Date() - 60* this.tempchartDisplayMinutes * 1000,
max: new Date()
min: new Date() - this.maxHistory * 1000,
max: new Date(),
},
yAxis: [{
max: this.autoscale ? null : this.maxTemp,
scale: this.autoscale
}]
max: this.autoscale ? this.currentMaxTemp : this.maxTemp,
//scale: this.autoscale
}],
})
}
}, this.intervalChartUpdate)
+13 -5
View File
@@ -7,6 +7,8 @@ export default {
getHistory({ commit, state, rootGetters }, payload) {
const now = new Date()
const maxHistory = rootGetters['server/getConfig']('server', 'temperature_store_size') || 1200
if (payload !== undefined) {
Object.entries(payload).sort().forEach(([name, datasets]) => {
let keySplit = name.split(" ")
@@ -54,7 +56,8 @@ export default {
name: name,
value: datasets.temperatures,
type: type,
time: now
time: now,
maxHistory: maxHistory
})
if ('targets' in datasets && (type.startsWith("extruder") || ["heater_bed", "temperature_fan"].includes(type))) {
@@ -82,7 +85,8 @@ export default {
name: name+"_target",
value: datasets.targets,
type: type,
time: now
time: now,
maxHistory: maxHistory
})
}
@@ -111,7 +115,8 @@ export default {
name: name+"_"+additionalType,
value: datasets[additionalType+"s"],
type: type,
time: now
time: now,
maxHistory: maxHistory
})
}
})
@@ -120,13 +125,15 @@ export default {
}
},
updateDatasets({ commit, rootState }) {
updateDatasets({ commit, rootState, rootGetters }) {
if (
'heaters' in rootState.printer &&
'available_sensors' in rootState.printer.heaters &&
rootState.printer.heaters.available_sensors.length
) {
const now = new Date()
const maxHistory = rootGetters['server/getConfig']('server', 'temperature_store_size') || 1200
rootState.printer.heaters.available_sensors.forEach((objectName) => {
if (objectName in rootState.printer) {
const objectNameSplits = objectName.split(" ")
@@ -139,7 +146,8 @@ export default {
name: datasetType === "temperature" ? name : name+"_"+datasetType,
value: rootState.printer[objectName][datasetType],
type: objectNameSplits[0],
time: now
time: now,
maxHistory: maxHistory
})
}
})
+30
View File
@@ -9,4 +9,34 @@ export default {
getSeries: state => (name) => {
return state.series.find(element => element.name === name)
},
getCurrentMaxTemp: state => {
let maxTemp = 0
state.series.forEach(serie => {
if (
serie.name.lastIndexOf("_") === -1 ||
!['power', 'speed'].includes(serie.name.substr(serie.name.lastIndexOf("_")+1))
) {
if (
serie.data.length && (
(
'lineStyle' in serie &&
'opacity' in serie.lineStyle &&
serie.lineStyle.opacity
) || (
'areaStyle' in serie &&
'opacity' in serie.areaStyle &&
serie.areaStyle.opacity
)
)
) {
const max = Math.max(...serie.data.map(data => data[1]))
if (maxTemp < max) maxTemp = max
}
}
})
return maxTemp + 10
}
}
+1 -1
View File
@@ -33,7 +33,7 @@ export default {
])
let i
const timeOld = new Date().getTime() - (1000 * 60 * 10)
const timeOld = new Date().getTime() - (1000 * payload.maxHistory)
while ((i = dataset.data.findIndex(item => timeOld > item[0])) > -1) {
dataset.data.splice(i, 1)
}
+7 -2
View File
@@ -9,6 +9,7 @@ export default {
init() {
Vue.prototype.$socket.sendObj('server.info', {}, 'server/getInfo')
Vue.prototype.$socket.sendObj('server.config', {}, 'server/getConfig')
Vue.prototype.$socket.sendObj('server.files.list', { root: 'config' }, 'server/checkMainsailJson')
},
@@ -32,8 +33,6 @@ export default {
},
getInfo({ commit, state, rootState }, payload) {
Vue.prototype.$socket.sendObj('server.gcode_store', {}, 'server/getGcodeStore')
if (state.plugins.length === 0) {
if (payload.plugins.includes("power") !== false)
Vue.prototype.$socket.sendObj('machine.device_power.devices', {}, 'server/power/getDevices')
@@ -60,6 +59,12 @@ export default {
}
},
getConfig({ commit }, payload) {
commit('setConfig', payload)
Vue.prototype.$socket.sendObj('server.gcode_store', {}, 'server/getGcodeStore')
},
getData({ commit }, payload){
commit('setData', payload)
},
+9
View File
@@ -20,4 +20,13 @@ export default {
return events
},
getConfig: (state) => (section, attribute) => {
if (
section in state.config &&
attribute in state.config[section]
) return state.config[section][attribute]
return null
}
}
+1
View File
@@ -16,6 +16,7 @@ export function getDefaultState() {
failed_plugins: [],
registered_directories: [],
events: [],
config: {},
}
}
+6
View File
@@ -33,6 +33,12 @@ export default {
});
},
setConfig(state, payload) {
Object.entries(payload.config).forEach(([key, value]) => {
Vue.set(state.config, key, value)
})
},
clearGcodeStore(state) {
Vue.set(state, 'events', [])
},