mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-09 00:00:01 +01:00
Upgrade table widget to simulation model
This commit is contained in:
parent
cfdef87d01
commit
ac91e65fe9
2 changed files with 11 additions and 15 deletions
|
@ -36,9 +36,10 @@ class WidgetTable extends Component {
|
|||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
// check data
|
||||
const simulator = nextProps.widget.simulator;
|
||||
const simulator = nextProps.simulationModel.simulator;
|
||||
|
||||
if (nextProps.simulation == null || nextProps.data == null || nextProps.data[simulator] == null
|
||||
if (nextProps.data == null || nextProps.simulationModel == null
|
||||
|| nextProps.data[simulator] == null
|
||||
|| nextProps.data[simulator].output.length === 0
|
||||
|| nextProps.data[simulator].output.values.length === 0
|
||||
|| nextProps.data[simulator].output.values[0].length === 0) {
|
||||
|
@ -52,18 +53,13 @@ class WidgetTable extends Component {
|
|||
return;
|
||||
}*/
|
||||
|
||||
// get simulation model
|
||||
const simulationModel = nextProps.simulation.models.find((model) => {
|
||||
return (model.simulator.node === simulator.node && model.simulator.simulator === simulator.simulator);
|
||||
});
|
||||
|
||||
// get rows
|
||||
var rows = [];
|
||||
const rows = [];
|
||||
|
||||
nextProps.data[simulator].output.values.forEach((signal, index) => {
|
||||
if (index < simulationModel.outputMapping.length) {
|
||||
if (index < nextProps.simulationModel.outputMapping.length) {
|
||||
rows.push({
|
||||
name: simulationModel.outputMapping[index].name,
|
||||
name: nextProps.simulationModel.outputMapping[index].name,
|
||||
value: signal[signal.length - 1].y.toFixed(3)
|
||||
});
|
||||
}
|
||||
|
|
|
@ -193,17 +193,17 @@ class Widget extends React.Component {
|
|||
|
||||
// dummy is passed to widgets to keep updating them while in edit mode
|
||||
if (widget.type === 'Lamp') {
|
||||
element = <WidgetLamp widget={widget} data={this.state.simulatorData} dummy={this.state.sequence} simulation={this.props.simulation} />
|
||||
element = <WidgetLamp widget={widget} data={this.state.simulatorData} dummy={this.state.sequence} simulationModel={simulationModel} />
|
||||
} else if (widget.type === 'Value') {
|
||||
element = <WidgetValue widget={widget} data={this.state.simulatorData} dummy={this.state.sequence} simulationModel={simulationModel} />
|
||||
} else if (widget.type === 'Plot') {
|
||||
element = <WidgetPlot widget={widget} data={this.state.simulatorData} dummy={this.state.sequence} simulation={this.props.simulation} paused={this.props.paused} />
|
||||
element = <WidgetPlot widget={widget} data={this.state.simulatorData} dummy={this.state.sequence} simulationModel={simulationModel} paused={this.props.paused} />
|
||||
} else if (widget.type === 'Table') {
|
||||
element = <WidgetTable widget={widget} data={this.state.simulatorData} dummy={this.state.sequence} simulation={this.props.simulation} />
|
||||
element = <WidgetTable widget={widget} data={this.state.simulatorData} dummy={this.state.sequence} simulationModel={simulationModel} />
|
||||
} else if (widget.type === 'Label') {
|
||||
element = <WidgetLabel widget={widget} />
|
||||
} else if (widget.type === 'PlotTable') {
|
||||
element = <WidgetPlotTable widget={widget} data={this.state.simulatorData} dummy={this.state.sequence} simulation={this.props.simulation} editing={this.props.editing} onWidgetChange={(w) => this.props.onWidgetStatusChange(w, this.props.index)} paused={this.props.paused} />
|
||||
element = <WidgetPlotTable widget={widget} data={this.state.simulatorData} dummy={this.state.sequence} simulationModel={simulationModel} editing={this.props.editing} onWidgetChange={(w) => this.props.onWidgetStatusChange(w, this.props.index)} paused={this.props.paused} />
|
||||
} else if (widget.type === 'Image') {
|
||||
element = <WidgetImage widget={widget} files={this.state.files} token={this.state.sessionToken} />
|
||||
} else if (widget.type === 'Button') {
|
||||
|
@ -213,7 +213,7 @@ class Widget extends React.Component {
|
|||
} else if (widget.type === 'Slider') {
|
||||
element = <WidgetSlider widget={widget} editing={this.props.editing} onWidgetChange={(w) => this.props.onWidgetStatusChange(w, this.props.index) } onInputChanged={(value) => this.inputDataChanged(widget, value)} />
|
||||
} else if (widget.type === 'Gauge') {
|
||||
element = <WidgetGauge widget={widget} data={this.state.simulatorData} editing={this.props.editing} simulation={this.props.simulation} />
|
||||
element = <WidgetGauge widget={widget} data={this.state.simulatorData} editing={this.props.editing} simulationModel={simulationModel} />
|
||||
} else if (widget.type === 'Box') {
|
||||
element = <WidgetBox widget={widget} editing={this.props.editing} />
|
||||
} else if (widget.type === 'HTML') {
|
||||
|
|
Loading…
Add table
Reference in a new issue