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

value widget displays output signal value #218

This commit is contained in:
Sonja Happ 2020-06-02 15:04:05 +02:00
parent e3e0962484
commit 39790b530e

View file

@ -33,31 +33,28 @@ class WidgetValue extends Component {
return null;
}
// TODO does the following line make sense?
const ICid = props.icIDs[0];
// get the signal with the selected signal ID
let signalID = props.widget.signalIDs[0];
let signal = props.signals.find(sig => sig.id === signalID);
let signal = props.signals.filter(s => s.id === signalID)
// determine ID of infrastructure component related to signal[0] (there is only one signal for a value widget)
let icID = props.icIDs[signal[0].id];
// update value
let value = '';
if (props.data == null
|| props.data[ICid] == null
|| props.data[ICid].output == null
|| props.data[ICid].output.values == null) {
// check if data available
let value = ''
if (props.data == null || props.data[icID] == null || props.data[icID].output == null || props.data[icID].output.values == null) {
value = '';
} else {
// check if value has changed
const signalData = props.data[ICid].output.values[signal.index];
if (signalData != null && state.value !== signalData[signalData.length - 1].y) {
value = signalData[signalData.length - 1].y
const data = props.data[icID].output.values[signal[0].index - 1];
if (data != null && Number(state.value) !== data[data.length - 1].y) {
value = data[data.length - 1].y;
}
}
// Update unit (assuming there is exactly one signal for this widget)
let unit = '';
if(signal !== undefined){
unit = signal.unit;
unit = signal[0].unit;
}
return {
@ -77,7 +74,7 @@ class WidgetValue extends Component {
<span style={{ fontSize: this.props.widget.customProperties.textSize + 'px', flex: 'none', width: value_width }}>{Number.isNaN(value_to_render) ? NaN : format('.3s')(value_to_render)}</span>
{this.props.widget.customProperties.showUnit &&
<span style={{ fontSize: this.props.widget.customProperties.textSize + 'px', flex: 'none', width: unit_width}}>[{this.state.unit}]</span>
}
}
</div>
);
}