mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-09 00:00:01 +01:00
only open websockets of ICs with configured input or output signals #278
This commit is contained in:
parent
726f6767d7
commit
715ca76bae
1 changed files with 14 additions and 3 deletions
|
@ -177,11 +177,22 @@ class Dashboard extends Component {
|
|||
componentDidUpdate(prevProps: Readonly<P>, prevState: Readonly<S>, snapshot: SS) {
|
||||
// open web sockets if ICs are already known and sockets are not opened yet
|
||||
if (this.state.ics !== undefined && !Dashboard.webSocketsOpened) {
|
||||
if (this.state.ics.length > 0) {
|
||||
console.log("Starting to open IC websockets:", this.state.ics);
|
||||
// only open sockets of ICs with configured input or output signals
|
||||
let relevantICs = this.state.ics.filter(ic => {
|
||||
let result = false;
|
||||
this.state.configs.forEach(config => {
|
||||
if(ic.id === config.icID && (config.inputLength !== 0 || config.outputLength !== 0)){
|
||||
result = true;
|
||||
}
|
||||
})
|
||||
return result;
|
||||
})
|
||||
|
||||
if (relevantICs.length > 0) {
|
||||
console.log("Starting to open IC websockets:", relevantICs);
|
||||
AppDispatcher.dispatch({
|
||||
type: 'ics/open-sockets',
|
||||
data: this.state.ics
|
||||
data: relevantICs
|
||||
});
|
||||
|
||||
Dashboard.webSocketsOpened = true;
|
||||
|
|
Loading…
Add table
Reference in a new issue