|
|
|
@@ -1,4 +1,4 @@ |
|
|
|
import {ChangeDetectorRef, Component, OnChanges, OnDestroy, OnInit, SimpleChanges} from '@angular/core'; |
|
|
|
import { Component, OnDestroy, OnInit } from '@angular/core'; |
|
|
|
import {SocketService} from "../../../shared/services/socket.service"; |
|
|
|
import {Subscription} from "rxjs"; |
|
|
|
|
|
|
|
@@ -8,16 +8,9 @@ import {Subscription} from "rxjs"; |
|
|
|
styleUrls: ['./overall-ground.component.scss'] |
|
|
|
}) |
|
|
|
export class OverallGroundComponent implements OnInit, OnDestroy{ |
|
|
|
isClicked = false; |
|
|
|
isConnected = false; |
|
|
|
state1 = ''; |
|
|
|
state2 = ''; |
|
|
|
state3 = ''; |
|
|
|
state4 = ''; |
|
|
|
state5 = ''; |
|
|
|
state6 = ''; |
|
|
|
Sstate1 = false; |
|
|
|
Sstate2 = false; |
|
|
|
private statusSubscription?: Subscription; |
|
|
|
private messageSubscription?: Subscription; |
|
|
|
private intervalId: any; |
|
|
|
@@ -27,7 +20,7 @@ export class OverallGroundComponent implements OnInit, OnDestroy{ |
|
|
|
} |
|
|
|
|
|
|
|
ngOnInit() { |
|
|
|
this.socketService$.connect(); |
|
|
|
this.socketService$.connect(); |
|
|
|
this.statusSubscription = this.socketService$.status$.subscribe(isConnected => { |
|
|
|
this.isConnected = isConnected; |
|
|
|
if (this.isConnected) { |
|
|
|
@@ -39,10 +32,6 @@ export class OverallGroundComponent implements OnInit, OnDestroy{ |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
toggleColor(): void { |
|
|
|
this.isClicked = !this.isClicked; |
|
|
|
} |
|
|
|
|
|
|
|
ngOnDestroy(): void { |
|
|
|
if (this.statusSubscription) { |
|
|
|
this.statusSubscription.unsubscribe(); |
|
|
|
@@ -61,14 +50,14 @@ export class OverallGroundComponent implements OnInit, OnDestroy{ |
|
|
|
this.socketService$.sendMessage(str); |
|
|
|
} |
|
|
|
toggleState1() { |
|
|
|
this.Sstate1 = (this.state5 !== 'ON'); // toggle on when state 5 off. |
|
|
|
let str = { id: '0', type: 'cmd', state1: this.Sstate1.toString() }; |
|
|
|
const state = (this.state5 !== 'ON'); // toggle on when state 5 off. |
|
|
|
let str = { id: '0', type: 'cmd', state1: state.toString() }; |
|
|
|
this.socketService$.sendMessage(str); |
|
|
|
} |
|
|
|
|
|
|
|
toggleState2() { |
|
|
|
this.Sstate2 = (this.state6 !== 'ON'); // toggle on when state 6 off. |
|
|
|
let str = { id: '0', type: 'cmd', state2: this.Sstate2.toString() }; |
|
|
|
const state = (this.state6 !== 'ON'); // toggle on when state 6 off. |
|
|
|
let str = { id: '0', type: 'cmd', state2: state.toString() }; |
|
|
|
this.socketService$.sendMessage(str); |
|
|
|
} |
|
|
|
|