@@ -44,12 +44,12 @@ export class TagPropertyComponent implements OnInit, OnDestroy {
44
44
@Inject ( MAT_DIALOG_DATA ) public data : any ) {
45
45
46
46
this . tagType = TagType ;
47
- if ( this . data . device . type === DeviceType . OPCUA || this . data . device . type === DeviceType . BACnet || this . data . device . type === DeviceType . WebAPI ) {
47
+ if ( this . isOpcua ( ) || this . isBACnet ( ) || this . isWebApi ( ) ) {
48
48
this . dialogType = EditTagDialogType . Tree ;
49
49
this . config . height = '640px' ;
50
50
this . config . width = '1000px' ;
51
- this . config . type = ( this . data . device . type === DeviceType . WebAPI ) ? 'todefine' : '' ;
52
- } else if ( this . data . device . type === DeviceType . MQTTclient ) {
51
+ this . config . type = ( this . isWebApi ( ) ) ? 'todefine' : '' ;
52
+ } else if ( this . isMqtt ( ) ) {
53
53
this . dialogType = EditTagDialogType . List ;
54
54
} else {
55
55
if ( this . isModbus ( ) ) {
@@ -71,7 +71,7 @@ export class TagPropertyComponent implements OnInit, OnDestroy {
71
71
72
72
ngOnInit ( ) {
73
73
if ( this . dialogType === EditTagDialogType . Tree ) {
74
- if ( this . data . device . type === DeviceType . OPCUA || this . data . device . type === DeviceType . BACnet ) {
74
+ if ( this . isOpcua ( ) || this . isBACnet ( ) ) {
75
75
this . subscriptionBrowse = this . hmiService . onDeviceBrowse . subscribe ( values => {
76
76
if ( this . data . device . name === values . device ) {
77
77
if ( values . error ) {
@@ -93,7 +93,7 @@ export class TagPropertyComponent implements OnInit, OnDestroy {
93
93
}
94
94
}
95
95
} ) ;
96
- } else if ( this . data . device . type === DeviceType . WebAPI ) {
96
+ } else if ( this . isWebApi ( ) ) {
97
97
this . hmiService . onDeviceWebApiRequest . subscribe ( res => {
98
98
if ( res . result ) {
99
99
this . addTreeNodes ( res . result ) ;
@@ -103,7 +103,7 @@ export class TagPropertyComponent implements OnInit, OnDestroy {
103
103
this . hmiService . askWebApiProperty ( this . data . device . property ) ;
104
104
}
105
105
this . queryNext ( null ) ;
106
- } else if ( this . dialogType === EditTagDialogType . List && this . data . device . type === DeviceType . MQTTclient ) {
106
+ } else if ( this . dialogType === EditTagDialogType . List && this . isMqtt ( ) ) {
107
107
this . subscriptionBrowse = this . hmiService . onDeviceBrowse . subscribe ( value => {
108
108
if ( value . result === 'error' ) {
109
109
this . discoveryError = value . result ;
@@ -150,10 +150,10 @@ export class TagPropertyComponent implements OnInit, OnDestroy {
150
150
151
151
onOkClick ( ) : void {
152
152
this . data . nodes = [ ] ;
153
- if ( this . data . device . type === DeviceType . WebAPI ) {
153
+ if ( this . isWebApi ( ) ) {
154
154
let result = this . getSelectedTreeNodes ( Object . values ( this . treetable . nodes ) , null ) ;
155
155
this . data . nodes = result ;
156
- } else if ( this . data . device . type === DeviceType . MQTTclient ) {
156
+ } else if ( this . isMqtt ( ) ) {
157
157
let listcheck = { } ;
158
158
Object . values ( this . topicsList ) . forEach ( ( topic :any ) => {
159
159
if ( topic . checked && topic . enabled ) {
@@ -175,6 +175,7 @@ export class TagPropertyComponent implements OnInit, OnDestroy {
175
175
this . data . nodes . push ( t ) ;
176
176
}
177
177
} ) ;
178
+ } else if ( this . isModbus ( ) ) {
178
179
} else {
179
180
Object . keys ( this . treetable . nodes ) . forEach ( ( key ) => {
180
181
let n : Node = this . treetable . nodes [ key ] ;
@@ -232,7 +233,7 @@ export class TagPropertyComponent implements OnInit, OnDestroy {
232
233
let node = new Node ( n . id , n . name ) ;
233
234
node . class = n . class ;
234
235
node . property = this . getProperty ( n ) ;
235
- if ( this . data . device . type === DeviceType . BACnet ) {
236
+ if ( this . isBACnet ( ) ) {
236
237
node . class = Node . strToType ( n . class ) ;
237
238
node . type = n . type ;
238
239
var typetext = Object . values ( BACnetObjectType ) [ n . type ] ;
@@ -374,7 +375,7 @@ export class TagPropertyComponent implements OnInit, OnDestroy {
374
375
375
376
queryNext ( node : Node ) {
376
377
let n = ( node ) ? { id : node . id } : null ;
377
- if ( this . data . device . type === DeviceType . BACnet && node ) {
378
+ if ( this . isBACnet ( ) && node ) {
378
379
n [ 'parent' ] = ( node . parent ) ? node . parent . id : null ;
379
380
}
380
381
this . hmiService . askDeviceBrowse ( this . data . device . name , n ) ;
@@ -413,6 +414,10 @@ export class TagPropertyComponent implements OnInit, OnDestroy {
413
414
return ( this . data . device . type === DeviceType . MQTTclient ) ? true : false ;
414
415
}
415
416
417
+ isBACnet ( ) {
418
+ return ( this . data . device . type === DeviceType . BACnet ) ? true : false ;
419
+ }
420
+
416
421
checkMemAddress ( memaddress ) {
417
422
if ( memaddress === '000000' || memaddress === '100000' ) {
418
423
this . data . tag . type = ModbusTagType . Bool ;
0 commit comments