Commit e7904d2b authored by Markus Grigull's avatar Markus Grigull

Add reverse channel for simulation data

parent 8c7f27d6
......@@ -16,4 +16,4 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
.vscode/
*.code-workspace
......@@ -26,10 +26,10 @@ class WebsocketAPI {
socket.binaryType = 'arraybuffer';
// register callbacks
if (callbacks.onOpen) socket.addEventListener('open', event => callbacks.onOpen(event));
if (callbacks.onClose) socket.addEventListener('close', event => callbacks.onClose(event));
if (callbacks.onMessage) socket.addEventListener('message', event => callbacks.onMessage(event));
if (callbacks.onError) socket.addEventListener('error', event => callbacks.onError(event));
if (callbacks.onOpen) socket.onopen = callbacks.onOpen;
if (callbacks.onClose) socket.onclose = callbacks.onClose;
if (callbacks.onMessage) socket.onmessage = callbacks.onMessage;
if (callbacks.onError) socket.onerror = callbacks.onError;
return socket;
}
......
......@@ -20,7 +20,7 @@
******************************************************************************/
import React from 'react';
import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap';
import { FormGroup, FormControl, ControlLabel, HelpBlock } from 'react-bootstrap';
import Table from '../table';
import TableColumn from '../table-column';
......@@ -35,8 +35,10 @@ class EditSimulationModelDialog extends React.Component {
this.state = {
name: '',
simulator: { node: '', simulator: '' },
length: 1,
mapping: [{ name: 'Signal', type: 'Type' }]
outputLength: 1,
inputLength: 1,
outputMapping: [{ name: 'Signal', type: 'Type' }],
inputMapping: [{ name: 'Signal', type: 'Type' }]
}
}
......@@ -51,16 +53,24 @@ class EditSimulationModelDialog extends React.Component {
}
handleChange(e) {
if (e.target.id === 'length') {
let mapping = null;
if (e.target.id === 'outputLength') {
mapping = this.state.outputMapping;
} else if (e.target.id === 'inputLength') {
mapping = this.state.inputMapping;
}
if (mapping != null) {
// change mapping size
if (e.target.value > this.state.mapping.length) {
if (e.target.value > mapping.length) {
// add missing signals
while (this.state.mapping.length < e.target.value) {
this.state.mapping.push({ name: 'Signal', type: 'Type' });
while (mapping.length < e.target.value) {
mapping.push({ name: 'Signal', type: 'Type' });
}
} else {
// remove signals
this.state.mapping.splice(e.target.value, this.state.mapping.length - e.target.value);
mapping.splice(e.target.value, mapping.length - e.target.value);
}
}
......@@ -72,8 +82,8 @@ class EditSimulationModelDialog extends React.Component {
}
}
handleMappingChange(event, row, column) {
var mapping = this.state.mapping;
handleMappingChange(key, event, row, column) {
const mapping = this.state[key];
if (column === 1) {
mapping[row].name = event.target.value;
......@@ -81,37 +91,45 @@ class EditSimulationModelDialog extends React.Component {
mapping[row].type = event.target.value;
}
this.setState({ mapping: mapping });
this.setState({ [key]: mapping });
}
resetState() {
this.setState({
name: this.props.data.name,
simulator: this.props.data.simulator,
length: this.props.data.length,
mapping: this.props.data.mapping
outputLength: this.props.data.outputLength,
inputLength: this.props.data.inputLength,
outputMapping: this.props.data.outputMapping,
inputMapping: this.props.data.inputMapping
});
}
validateForm(target) {
// check all controls
var name = true;
var length = true;
let inputLength = true;
let outputLength = true;
if (this.state.name === '') {
name = false;
}
// test if simulatorid is a number (in a string, not type of number)
if (!/^\d+$/.test(this.state.length)) {
length = false;
if (!/^\d+$/.test(this.state.outputLength)) {
outputLength = false;
}
if (!/^\d+$/.test(this.state.inputLength)) {
inputLength = false;
}
this.valid = name && length;
this.valid = name && inputLength && outputLength;
// return state to control
if (target === 'name') return name ? "success" : "error";
else if (target === 'length') return length ? "success" : "error";
else if (target === 'outputLength') return outputLength ? "success" : "error";
else if (target === 'inputLength') return inputLength ? "success" : "error";
}
render() {
......@@ -133,17 +151,32 @@ class EditSimulationModelDialog extends React.Component {
))}
</FormControl>
</FormGroup>
<FormGroup controlId="length" validationState={this.validateForm('length')}>
<ControlLabel>Length</ControlLabel>
<FormControl type="number" placeholder="Enter length" min="1" value={this.state.length} onChange={(e) => this.handleChange(e)} />
<FormGroup controlId="outputLength" validationState={this.validateForm('outputLength')}>
<ControlLabel>Output Length</ControlLabel>
<FormControl type="number" placeholder="Enter length" min="1" value={this.state.outputLength} onChange={(e) => this.handleChange(e)} />
<FormControl.Feedback />
</FormGroup>
<FormGroup controlId="outputMapping">
<ControlLabel>Output Mapping</ControlLabel>
<HelpBlock>Click Name or Type cell to edit</HelpBlock>
<Table data={this.state.outputMapping}>
<TableColumn title='ID' width='60' dataIndex />
<TableColumn title='Name' dataKey='name' inlineEditable onInlineChange={(event, row, column) => this.handleMappingChange('outputMapping', event, row, column)} />
<TableColumn title='Type' dataKey='type' inlineEditable onInlineChange={(event, row, column) => this.handleMappingChange('outputMapping', event, row, column)} />
</Table>
</FormGroup>
<FormGroup controlId="inputLength" validationState={this.validateForm('inputLength')}>
<ControlLabel>Input Length</ControlLabel>
<FormControl type="number" placeholder="Enter length" min="1" value={this.state.inputLength} onChange={(e) => this.handleChange(e)} />
<FormControl.Feedback />
</FormGroup>
<FormGroup controlId="mapping">
<ControlLabel>Mapping</ControlLabel>
<Table data={this.state.mapping}>
<FormGroup controlId="inputMapping">
<ControlLabel>Input Mapping</ControlLabel>
<HelpBlock>Click Name or Type cell to edit</HelpBlock>
<Table data={this.state.inputMapping}>
<TableColumn title='ID' width='60' dataIndex />
<TableColumn title='Name' dataKey='name' inlineEditable onInlineChange={(event, row, column) => this.handleMappingChange(event, row, column)} />
<TableColumn title='Type' dataKey='type' inlineEditable onInlineChange={(event, row, column) => this.handleMappingChange(event, row, column)} />
<TableColumn title='Name' dataKey='name' inlineEditable onInlineChange={(event, row, column) => this.handleMappingChange('inputMapping', event, row, column)} />
<TableColumn title='Type' dataKey='type' inlineEditable onInlineChange={(event, row, column) => this.handleMappingChange('inputMapping', event, row, column)} />
</Table>
</FormGroup>
</form>
......
......@@ -117,13 +117,17 @@ export default function createControls(widgetType = null, widget = null, session
break;
case 'Slider':
dialogControls.push(
<EditWidgetOrientation key={0} widget={widget} validate={(id) => validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} />
<EditWidgetOrientation key={0} widget={widget} validate={(id) => validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} />,
<EditWidgetSimulatorControl key={1} widget={widget} validate={(id) => validateForm(id)} simulation={simulation} handleChange={(e) => valueBoundOnChange(e)} />,
<EditWidgetSignalControl key={2} widget={widget} input validate={(id) => validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} />
);
break;
case 'Button':
dialogControls.push(
<EditWidgetColorControl key={0} widget={widget} controlId={'background_color'} label={'Background'} validate={(id) => validateForm(id)} handleChange={(e) => handleChange(e)} />,
<EditWidgetColorControl key={1} widget={widget} controlId={'font_color'} label={'Font color'} validate={(id) => validateForm(id)} handleChange={(e) => handleChange(e)} />
<EditWidgetColorControl key={1} widget={widget} controlId={'font_color'} label={'Font color'} validate={(id) => validateForm(id)} handleChange={(e) => handleChange(e)} />,
<EditWidgetSimulatorControl key={2} widget={widget} validate={(id) => validateForm(id)} simulation={simulation} handleChange={(e) => valueBoundOnChange(e)} />,
<EditWidgetSignalControl key={3} widget={widget} input validate={(id) => validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} />
);
break;
case 'Box':
......@@ -151,6 +155,14 @@ export default function createControls(widgetType = null, widget = null, session
);
break;
case 'NumberInput':
dialogControls.push(
<EditWidgetTextControl key={0} widget={widget} controlId={'name'} label={'Text'} placeholder={'Enter text'} validate={id => validateForm(id)} handleChange={e => handleChange(e)} />,
<EditWidgetSimulatorControl key={1} widget={widget} validate={(id) => validateForm(id)} simulation={simulation} handleChange={(e) => valueBoundOnChange(e)} />,
<EditWidgetSignalControl key={2} widget={widget} input validate={(id) => validateForm(id)} simulation={simulation} handleChange={(e) => handleChange(e)} />
);
break;
default:
console.log('Non-valid widget type: ' + widgetType);
}
......
......@@ -46,7 +46,12 @@ class EditWidgetSignalControl extends Component {
const simulationModel = this.props.simulation.models.find( model => model.simulator.node === this.state.widget.simulator.node && model.simulator.simulator === this.state.widget.simulator.simulator );
// If simulation model update the signals to render
signalsToRender = simulationModel ? simulationModel.mapping : [];
if (this.props.input) {
signalsToRender = simulationModel ? simulationModel.inputMapping : [];
} else {
signalsToRender = simulationModel ? simulationModel.outputMapping : [];
}
}
return (
......
......@@ -61,7 +61,7 @@ class EditWidgetSignalsControl extends Component {
const simulationModel = this.props.simulation.models.find( model => model.simulator.node === this.state.widget.simulator.node && model.simulator.simulator === this.state.widget.simulator.simulator );
// If simulation model update the signals to render
signalsToRender = simulationModel? simulationModel.mapping : [];
signalsToRender = simulationModel? simulationModel.outputMapping : [];
}
return (
......
......@@ -20,7 +20,7 @@
******************************************************************************/
import React from 'react';
import { FormGroup, FormControl, ControlLabel } from 'react-bootstrap';
import { FormGroup, FormControl, ControlLabel, HelpBlock } from 'react-bootstrap';
import Table from '../table';
import TableColumn from '../table-column';
......@@ -36,8 +36,10 @@ class ImportSimulationModelDialog extends React.Component {
this.state = {
name: '',
simulator: { node: '', simulator: '' },
length: '1',
mapping: [ { name: 'Signal', type: 'Type' } ]
outputLength: '1',
inputLength: '1',
outputMapping: [ { name: 'Signal', type: 'Type' } ],
inputMapping: [{ name: 'Signal', type: 'Type' }]
};
}
......@@ -53,24 +55,34 @@ class ImportSimulationModelDialog extends React.Component {
this.setState({
name: '',
simulator: { node: this.props.nodes[0] ? this.props.nodes[0]._id : '', simulator: this.props.nodes[0].simulators[0] ? 0 : '' },
length: '1',
mapping: [ { name: 'Signal', type: 'Type' } ]
outputLength: '1',
inputLength: '1',
outputMapping: [{ name: 'Signal', type: 'Type' }],
inputMapping: [{ name: 'Signal', type: 'Type' }]
});
this.imported = false;
}
handleChange(e) {
if (e.target.id === 'length') {
let mapping = null;
if (e.target.id === 'outputLength') {
mapping = this.state.outputMapping;
} else if (e.target.id === 'inputLength') {
mapping = this.state.inputMapping;
}
if (mapping != null) {
// change mapping size
if (e.target.value > this.state.mapping.length) {
if (e.target.value > mapping.length) {
// add missing signals
while (this.state.mapping.length < e.target.value) {
this.state.mapping.push({ name: 'Signal', type: 'Type' });
while (mapping.length < e.target.value) {
mapping.push({ name: 'Signal', type: 'Type' });
}
} else {
// remove signals
this.state.mapping.splice(e.target.value, this.state.mapping.length - e.target.value);
mapping.splice(e.target.value, mapping.length - e.target.value);
}
}
......@@ -81,8 +93,8 @@ class ImportSimulationModelDialog extends React.Component {
}
}
handleMappingChange(event, row, column) {
var mapping = this.state.mapping;
handleMappingChange(key, event, row, column) {
const mapping = this.state[key];
if (column === 1) {
mapping[row].name = event.target.value;
......@@ -90,7 +102,7 @@ class ImportSimulationModelDialog extends React.Component {
mapping[row].type = event.target.value;
}
this.setState({ mapping: mapping });
this.setState({ [key]: mapping });
}
loadFile(fileList) {
......@@ -119,7 +131,8 @@ class ImportSimulationModelDialog extends React.Component {
validateForm(target) {
// check all controls
var name = true;
var length = true;
let inputLength = true;
let outputLength = true;
var simulator = true;
if (this.state.name === '') {
......@@ -131,15 +144,20 @@ class ImportSimulationModelDialog extends React.Component {
}
// test if simulatorid is a number (in a string, not type of number)
if (!/^\d+$/.test(this.state.length)) {
length = false;
if (!/^\d+$/.test(this.state.outputLength)) {
outputLength = false;
}
if (!/^\d+$/.test(this.state.inputLength)) {
inputLength = false;
}
this.valid = name && length && simulator;
this.valid = name && inputLength && outputLength && simulator;
// return state to control
if (target === 'name') return name ? "success" : "error";
else if (target === 'length') return length ? "success" : "error";
else if (target === 'outputLength') return outputLength ? "success" : "error";
else if (target === 'inputLength') return inputLength ? "success" : "error";
else if (target === 'simulator') return simulator ? "success" : "error";
}
......@@ -167,17 +185,32 @@ class ImportSimulationModelDialog extends React.Component {
))}
</FormControl>
</FormGroup>
<FormGroup controlId="length" validationState={this.validateForm('length')}>
<ControlLabel>Length</ControlLabel>
<FormControl readOnly={!this.imported} type="number" placeholder="Enter length" min="1" value={this.state.length} onChange={(e) => this.handleChange(e)} />
<FormGroup controlId="outputLength" validationState={this.validateForm('outputLength')}>
<ControlLabel>Output Length</ControlLabel>
<FormControl type="number" placeholder="Enter length" min="1" value={this.state.outputLength} onChange={(e) => this.handleChange(e)} />
<FormControl.Feedback />
</FormGroup>
<FormGroup controlId="outputMapping">
<ControlLabel>Output Mapping</ControlLabel>
<HelpBlock>Click Name or Type cell to edit</HelpBlock>
<Table data={this.state.outputMapping}>
<TableColumn title='ID' width='60' dataIndex />
<TableColumn title='Name' dataKey='name' inlineEditable onInlineChange={(event, row, column) => this.handleMappingChange('outputMapping', event, row, column)} />
<TableColumn title='Type' dataKey='type' inlineEditable onInlineChange={(event, row, column) => this.handleMappingChange('outputMapping', event, row, column)} />
</Table>
</FormGroup>
<FormGroup controlId="inputLength" validationState={this.validateForm('inputLength')}>
<ControlLabel>Input Length</ControlLabel>
<FormControl type="number" placeholder="Enter length" min="1" value={this.state.inputLength} onChange={(e) => this.handleChange(e)} />
<FormControl.Feedback />
</FormGroup>
<FormGroup controlId="mapping">
<ControlLabel>Mapping</ControlLabel>
<Table data={this.state.mapping}>
<FormGroup controlId="inputMapping">
<ControlLabel>Input Mapping</ControlLabel>
<HelpBlock>Click Name or Type cell to edit</HelpBlock>
<Table data={this.state.inputMapping}>
<TableColumn title='ID' width='60' dataIndex />
<TableColumn title='Name' dataKey='name' inlineEditable onInlineChange={(event, row, column) => this.handleMappingChange(event, row, column)} />
<TableColumn title='Type' dataKey='type' inlineEditable onInlineChange={(event, row, column) => this.handleMappingChange(event, row, column)} />
<TableColumn title='Name' dataKey='name' inlineEditable onInlineChange={(event, row, column) => this.handleMappingChange('inputMapping', event, row, column)} />
<TableColumn title='Type' dataKey='type' inlineEditable onInlineChange={(event, row, column) => this.handleMappingChange('inputMapping', event, row, column)} />
</Table>
</FormGroup>
</form>
......
......@@ -35,8 +35,10 @@ class NewSimulationModelDialog extends React.Component {
this.state = {
name: '',
simulator: { node: '', simulator: '' },
length: '1',
mapping: [ { name: 'Signal', type: 'Type' } ]
outputLength: '1',
inputLength: '1',
outputMapping: [ { name: 'Signal', type: 'Type' } ],
inputMapping: [ { name: 'Signal', type: 'Type' } ]
};
}
......@@ -51,16 +53,24 @@ class NewSimulationModelDialog extends React.Component {
}
handleChange(e) {
if (e.target.id === 'length') {
let mapping = null;
if (e.target.id === 'outputLength') {
mapping = this.state.outputMapping;
} else if (e.target.id === 'inputLength') {
mapping = this.state.inputMapping;
}
if (mapping != null) {
// change mapping size
if (e.target.value > this.state.mapping.length) {
if (e.target.value > mapping.length) {
// add missing signals
while (this.state.mapping.length < e.target.value) {
this.state.mapping.push({ name: 'Signal', type: 'Type' });
while (mapping.length < e.target.value) {
mapping.push({ name: 'Signal', type: 'Type' });
}
} else {
// remove signals
this.state.mapping.splice(e.target.value, this.state.mapping.length - e.target.value);
mapping.splice(e.target.value, mapping.length - e.target.value);
}
}
......@@ -71,8 +81,8 @@ class NewSimulationModelDialog extends React.Component {
}
}
handleMappingChange(event, row, column) {
var mapping = this.state.mapping;
handleMappingChange(key, event, row, column) {
const mapping = this.state[key];
if (column === 1) {
mapping[row].name = event.target.value;
......@@ -80,23 +90,26 @@ class NewSimulationModelDialog extends React.Component {
mapping[row].type = event.target.value;
}
this.setState({ mapping: mapping });
this.setState({ [key]: mapping });
}
resetState() {
this.setState({
name: '',
simulator: { node: this.props.nodes[0] ? this.props.nodes[0]._id : '', simulator: this.props.nodes[0].simulators[0] ? 0 : '' },
length: '1',
mapping: [ { name: 'Signal', type: 'Type' } ]
outputLength: '1',
inputLength: '1',
outputMapping: [{ name: 'Signal', type: 'Type' }],
inputMapping: [{ name: 'Signal', type: 'Type' }]
});
}
validateForm(target) {
// check all controls
var name = true;
var length = true;
var simulator = true;
let name = true;
let inputLength = true;
let outputLength = true;
let simulator = true;
if (this.state.name === '') {
name = false;
......@@ -107,15 +120,20 @@ class NewSimulationModelDialog extends React.Component {
}
// test if simulatorid is a number (in a string, not type of number)
if (!/^\d+$/.test(this.state.length)) {
length = false;
if (!/^\d+$/.test(this.state.outputLength)) {
outputLength = false;
}
this.valid = name && length && simulator;
if (!/^\d+$/.test(this.state.inputLength)) {
inputLength = false;
}
this.valid = name && inputLength && outputLength && simulator;
// return state to control
if (target === 'name') return name ? "success" : "error";
else if (target === 'length') return length ? "success" : "error";
else if (target === 'outputLength') return outputLength ? "success" : "error";
else if (target === 'inputLength') return inputLength ? "success" : "error";
else if (target === 'simulator') return simulator ? "success" : "error";
}
......@@ -138,18 +156,32 @@ class NewSimulationModelDialog extends React.Component {
))}
</FormControl>
</FormGroup>
<FormGroup controlId="length" validationState={this.validateForm('length')}>
<ControlLabel>Length</ControlLabel>
<FormControl type="number" placeholder="Enter length" min="1" value={this.state.length} onChange={(e) => this.handleChange(e)} />
<FormGroup controlId="outputLength" validationState={this.validateForm('outputLength')}>
<ControlLabel>Output Length</ControlLabel>
<FormControl type="number" placeholder="Enter length" min="1" value={this.state.outputLength} onChange={(e) => this.handleChange(e)} />
<FormControl.Feedback />
</FormGroup>
<FormGroup controlId="outputMapping">
<ControlLabel>Output Mapping</ControlLabel>
<HelpBlock>Click Name or Type cell to edit</HelpBlock>
<Table data={this.state.outputMapping}>
<TableColumn title='ID' width='60' dataIndex />
<TableColumn title='Name' dataKey='name' inlineEditable onInlineChange={(event, row, column) => this.handleMappingChange('outputMapping', event, row, column)} />
<TableColumn title='Type' dataKey='type' inlineEditable onInlineChange={(event, row, column) => this.handleMappingChange('outputMapping', event, row, column)} />
</Table>
</FormGroup>
<FormGroup controlId="inputLength" validationState={this.validateForm('inputLength')}>
<ControlLabel>Input Length</ControlLabel>
<FormControl type="number" placeholder="Enter length" min="1" value={this.state.inputLength} onChange={(e) => this.handleChange(e)} />
<FormControl.Feedback />
</FormGroup>
<FormGroup controlId="mapping">
<ControlLabel>Mapping</ControlLabel>
<FormGroup controlId="inputMapping">
<ControlLabel>Input Mapping</ControlLabel>
<HelpBlock>Click Name or Type cell to edit</HelpBlock>
<Table data={this.state.mapping}>
<Table data={this.state.inputMapping}>
<TableColumn title='ID' width='60' dataIndex />
<TableColumn title='Name' dataKey='name' inlineEditable onInlineChange={(event, row, column) => this.handleMappingChange(event, row, column)} />
<TableColumn title='Type' dataKey='type' inlineEditable onInlineChange={(event, row, column) => this.handleMappingChange(event, row, column)} />
<TableColumn title='Name' dataKey='name' inlineEditable onInlineChange={(event, row, column) => this.handleMappingChange('inputMapping', event, row, column)} />
<TableColumn title='Type' dataKey='type' inlineEditable onInlineChange={(event, row, column) => this.handleMappingChange('inputMapping', event, row, column)} />
</Table>
</FormGroup>
</form>
......
......@@ -105,12 +105,16 @@ class WidgetFactory {
widget.height = 100;
widget.background_color = 1;
widget.font_color = 0;
widget.simulator = defaultSimulator;
widget.signal = 0;
break;
case 'NumberInput':
widget.minWidth = 200;
widget.minHeight = 50;
widget.width = 200;
widget.height = 50;
widget.simulator = defaultSimulator;
widget.signal = 0;
break;
case 'Slider':
widget.minWidth = 380;
......@@ -118,6 +122,8 @@ class WidgetFactory {
widget.width = 400;
widget.height = 50;
widget.orientation = WidgetSlider.OrientationTypes.HORIZONTAL.value; // Assign default orientation
widget.simulator = defaultSimulator;
widget.signal = 0;
break;
case 'Gauge':
widget.simulator = defaultSimulator;
......
......@@ -40,15 +40,14 @@ class WidgetGauge extends Component {
if (nextProps.data == null || nextProps.data[simulator.node] == null
|| nextProps.data[simulator.node][simulator.simulator] == null
|| nextProps.data[simulator.node][simulator.simulator].length === 0
|| nextProps.data[simulator.node][simulator.simulator].values.length === 0
|| nextProps.data[simulator.node][simulator.simulator].values[0].length === 0) {
|| nextProps.data[simulator.node][simulator.simulator].output.values.length === 0
|| nextProps.data[simulator.node][simulator.simulator].output.values[0].length === 0) {
this.setState({ value: 0 });
return;
}
// check if value has changed
const signal = nextProps.data[simulator.node][simulator.simulator].values[nextProps.widget.signal];
const signal = nextProps.data[simulator.node][simulator.simulator].output.values[nextProps.widget.signal];
// Take just 3 decimal positions
// Note: Favor this method over Number.toFixed(n) in order to avoid a type conversion, since it returns a String
if (signal != null) {
......@@ -180,7 +179,7 @@ class WidgetGauge extends Component {
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.mapping[this.props.widget.signal].type : '';
signalType = (simulationModel != null && simulationModel.length > 0 && this.props.widget.signal < simulationModel.length) ? simulationModel.outputMapping[this.props.widget.signal].type : '';
}
return (
......
......@@ -38,13 +38,13 @@ class WidgetLamp extends Component {
const simulator = nextProps.widget.simulator.simulator;
const node = nextProps.widget.simulator.node;
if (nextProps.data == null || nextProps.data[node] == null || nextProps.data[node][simulator] == null || nextProps.data[node][simulator].values == null) {
if (nextProps.data == null || nextProps.data[node] == null || nextProps.data[node][simulator] == null || nextProps.data[node][simulator].output.values == null) {
this.setState({ value: '' });
return;
}
// check if value has changed
const signal = nextProps.data[node][simulator].values[nextProps.widget.signal];
const signal = nextProps.data[node][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 });
}
......
......@@ -71,7 +71,7 @@ class WidgetPlotTable extends Component {
// Proceed if a simulation model is available
if (simulationModel) {
// Create checkboxes using the signal indices from simulation model
preselectedSignals = simulationModel.mapping.reduce(
preselectedSignals = simulationModel.outputMapping.reduce(
// Loop through simulation model signals
(accum, model_signal, signal_index) => {
// Append them if they belong to the current selected type
......@@ -107,7 +107,7 @@ class WidgetPlotTable extends Component {
let simulatorData = [];
if (this.props.data[simulator.node] != null && this.props.data[simulator.node][simulator.simulator] != null) {
simulatorData = this.props.data[simulator.node][simulator.simulator].values.filter((values, index) => (
simulatorData = this.props.data[simulator.node][simulator.simulator].output.values.filter((values, index) => (
this.props.widget.signals.findIndex(value => value === index) !== -1
));
}
......
......@@ -43,12 +43,12 @@ class WidgetPlot extends React.Component {
const model = simulation.models.find(model => model.simulator.node === simulator.node && model.simulator.simulator === simulator.simulator);
const chosenSignals = nextProps.widget.signals;
const data = nextProps.data[simulator.node][simulator.simulator].values.filter((values, index) => (