mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-09 00:00:01 +01:00
Upgrade gauge widget to simulation model
This commit is contained in:
parent
ac91e65fe9
commit
00ce63c7a0
2 changed files with 14 additions and 7 deletions
|
@ -35,9 +35,13 @@ class WidgetGauge extends Component {
|
|||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
// update value
|
||||
const simulator = nextProps.widget.simulator;
|
||||
if (nextProps.simulationModel == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const simulator = nextProps.simulationModel.simulator;
|
||||
|
||||
// update value
|
||||
if (nextProps.data == null || nextProps.data[simulator] == null
|
||||
|| nextProps.data[simulator].output.values.length === 0
|
||||
|| nextProps.data[simulator].output.values[0].length === 0) {
|
||||
|
@ -176,9 +180,8 @@ class WidgetGauge extends Component {
|
|||
const componentClass = this.props.editing ? "gauge-widget editing" : "gauge-widget";
|
||||
let signalType = null;
|
||||
|
||||
if (this.props.simulation) {
|
||||
const simulationModel = this.props.simulation.models.filter((model) => model.simulator.node === this.props.widget.simulator.node && model.simulator.simulator === this.props.widget.simulator.simulator)[0];
|
||||
signalType = (simulationModel != null && simulationModel.length > 0 && this.props.widget.signal < simulationModel.length) ? simulationModel.outputMapping[this.props.widget.signal].type : '';
|
||||
if (this.props.simulationModel != null) {
|
||||
signalType = (this.props.simulationModel != null && this.props.simulationModel.outputLength > 0 && this.props.widget.signal < this.props.simulationModel.outputLength) ? this.props.simulationModel.outputMapping[this.props.widget.signal].type : '';
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
|
@ -35,10 +35,14 @@ class WidgetTable extends Component {
|
|||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
// check data
|
||||
if (nextProps.simulationModel == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const simulator = nextProps.simulationModel.simulator;
|
||||
|
||||
if (nextProps.data == null || nextProps.simulationModel == null
|
||||
// check data
|
||||
if (nextProps.data == null
|
||||
|| nextProps.data[simulator] == null
|
||||
|| nextProps.data[simulator].output.length === 0
|
||||
|| nextProps.data[simulator].output.values.length === 0
|
||||
|
|
Loading…
Add table
Reference in a new issue