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

Lamp and plot widgets consider signal scaling #130

This commit is contained in:
Sonja Happ 2020-06-26 15:57:47 +02:00
parent fd5e6e476f
commit e8893f165e
3 changed files with 28 additions and 5 deletions

View file

@ -27,7 +27,7 @@ class PlotLegend extends React.Component {
<ul>
{this.props.signals.map(signal =>
<li key={signal.id} className="signal-legend" style={{ color: colorScale(signal.id) }}>
<span className="signal-legend-name">{signal.name}</span>
<span className="signal-legend-name">{signal.name + "(x" + signal.scalingFactor + ")"}</span>
<span style={{ marginLeft: '0.3em' }} className="signal-unit">{signal.unit}</span>
</li>
)}

View file

@ -49,8 +49,8 @@ class WidgetLamp extends Component {
// check if value has changed
const data = props.data[icID].output.values[signal[0].index-1];
if (data != null && Number(state.value) !== data[data.length - 1].y) {
return { value: data[data.length - 1].y };
if (data != null && Number(state.value) !== signal[0].scalingFactor * data[data.length - 1].y) {
return { value: signal[0].scalingFactor * data[data.length - 1].y };
}
return null;

View file

@ -49,13 +49,31 @@ class WidgetPlot extends React.Component {
if (sig.direction === "out") {
if (props.data[icID] != null && props.data[icID].output != null && props.data[icID].output.values != null) {
if (props.data[icID].output.values[sig.index-1] !== undefined) {
data.push(props.data[icID].output.values[sig.index-1]);
let values = props.data[icID].output.values[sig.index-1];
if(sig.scalingFactor !== 1) {
let scaledValues = JSON.parse(JSON.stringify(values));
for (let i=0; i< scaledValues.length; i++){
scaledValues[i].y = scaledValues[i].y * sig.scalingFactor;
}
data.push(scaledValues);
} else {
data.push(values);
}
}
}
} else if (sig.direction === "in") {
if (props.data[icID] != null && props.data[icID].input != null && props.data[icID].input.values != null) {
if (props.data[icID].input.values[sig.index-1] !== undefined) {
data.push(props.data[icID].input.values[sig.index-1]);
let values = props.data[icID].output.values[sig.index-1];
if(sig.scalingFactor !== 1) {
let scaledValues = JSON.parse(JSON.stringify(values));
for (let i=0; i< scaledValues.length; i++){
scaledValues[i].y = scaledValues[i].y * sig.scalingFactor;
}
data.push(scaledValues);
} else {
data.push(values);
}
}
}
}
@ -67,6 +85,11 @@ class WidgetPlot extends React.Component {
}
scaleData(data, scaleFactor){
// data is an array of value pairs x,y
}
render() {
return <div className="plot-widget" ref="wrapper">
<div className="widget-plot">