1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-09 00:00:01 +01:00

Merge branch '155-output-widgets-sometimes-crash' into 'develop'

Resolve "Output widgets sometimes crash"

Closes #155

See merge request acs/public/villas/VILLASweb!28
This commit is contained in:
Markus Grigull 2018-05-04 12:49:41 +02:00
commit 7c7c7cfb3f
6 changed files with 14 additions and 6 deletions

View file

@ -44,6 +44,8 @@ class WidgetGauge extends Component {
// update value
if (nextProps.data == null || nextProps.data[simulator] == null
|| nextProps.data[simulator].output == null
|| nextProps.data[simulator].output.values == null
|| nextProps.data[simulator].output.values.length === 0
|| nextProps.data[simulator].output.values[0].length === 0) {
this.setState({ value: 0 });

View file

@ -42,7 +42,7 @@ class WidgetLamp extends Component {
const simulator = nextProps.simulationModel.simulator;
// update value
if (nextProps.data == null || nextProps.data[simulator] == null || nextProps.data[simulator].output.values == null) {
if (nextProps.data == null || nextProps.data[simulator] == null || nextProps.data[simulator].output == null || nextProps.data[simulator].output.values == null) {
this.setState({ value: '' });
return;
}

View file

@ -103,7 +103,7 @@ class WidgetPlotTable extends Component {
const simulator = this.props.simulationModel.simulator;
let simulatorData = [];
if (this.props.data[simulator] != null) {
if (this.props.data[simulator] != null && this.props.data[simulator].output != null && this.props.data[simulator].output.values != null) {
simulatorData = this.props.data[simulator].output.values.filter((values, index) => (
this.props.widget.signals.findIndex(value => value === index) !== -1
));

View file

@ -43,7 +43,7 @@ class WidgetPlot extends React.Component {
const simulator = nextProps.simulationModel.simulator;
// Proceed if a simulation with models and a simulator are available
if (simulator && nextProps.data[simulator] != null && nextProps.data[simulator] != null) {
if (simulator && nextProps.data[simulator] != null && nextProps.data[simulator] != null && nextProps.data[simulator].output != null && nextProps.data[simulator].output.values != null) {
const chosenSignals = nextProps.widget.signals;
const data = nextProps.data[simulator].output.values.filter((values, index) => (

View file

@ -46,7 +46,6 @@ class WidgetTable extends Component {
if (nextProps.data == null
|| nextProps.data[simulator] == null
|| nextProps.data[simulator].output == null
|| nextProps.data[simulator].output.length === 0
|| nextProps.data[simulator].output.values.length === 0
|| nextProps.data[simulator].output.values[0].length === 0) {
// clear values

View file

@ -32,8 +32,15 @@ class WidgetValue extends Component {
}
componentWillReceiveProps(nextProps) {
if (nextProps.simulationModel == null) {
this.setState({ value: '' });
return;
}
const simulator = nextProps.simulationModel.simulator;
// update value
if (nextProps.data == null || nextProps.simulationModel == null || nextProps.data[nextProps.simulationModel.simulator] == null || nextProps.data[nextProps.simulationModel.simulator].output == null || nextProps.data[nextProps.simulationModel.simulator].output.values == null) {
if (nextProps.data == null || nextProps.data[simulator] == null || nextProps.data[simulator].output == null || nextProps.data[simulator].output.values == null) {
this.setState({ value: '' });
return;
}
@ -41,7 +48,7 @@ class WidgetValue extends Component {
const unit = nextProps.simulationModel.outputMapping[nextProps.widget.signal].type;
// check if value has changed
const signal = nextProps.data[nextProps.simulationModel.simulator].output.values[nextProps.widget.signal];
const signal = nextProps.data[simulator].output.values[nextProps.widget.signal];
if (signal != null && this.state.value !== signal[signal.length - 1].y) {
this.setState({ value: signal[signal.length - 1].y, unit });
}