Skip to content

Commit 0628956

Browse files
committed
set ModbusTask for modbusSpecification
1 parent 4e924aa commit 0628956

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

src/app/select-slave/select-slave.component.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export class SelectSlaveComponent extends SessionStorage implements OnInit {
162162
//slavesFormArray: FormArray<FormGroup>
163163
slaveNewForm: FormGroup = this._formBuilder.group({
164164
slaveId: [null],
165-
detectSpec: [true],
165+
detectSpec: [false],
166166
});
167167
paramsSubscription: Subscription;
168168
errorStateMatcher = new M2mErrorStateMatcher();
@@ -347,19 +347,23 @@ export class SelectSlaveComponent extends SessionStorage implements OnInit {
347347
}
348348
getSpecsForConfiguredSlave(uiSlave:IuiSlave):Observable<IidentificationSpecification[]>{
349349
let rc= new Subject<IidentificationSpecification[]>()
350-
this.entityApiService.getModbusSpecification(this.bus.busId,uiSlave.slave.slaveid,uiSlave.slave.specificationid).subscribe(v=>{
350+
let fct = ( specModbus:ImodbusSpecification| undefined )=>{
351351
let rci:IidentificationSpecification[]=[]
352352
this.preparedSpecs.forEach(spec=>{
353-
console.log( "v" + v.filename + " spec" + spec.filename)
354-
let name = getSpecificationI18nName(spec,this.config.mqttdiscoverylanguage)
353+
let name = getSpecificationI18nName(spec,this.config.mqttdiscoverylanguage)
355354
rci.push({
356355
name: name,
357-
identified: spec.filename== v.filename?v.identified:IdentifiedStates.unknown,
356+
identified: specModbus && spec.filename== specModbus.filename?specModbus.identified:IdentifiedStates.unknown,
358357
filename: spec.filename,
359358
} as IidentificationSpecification);
360359
rc.next(rci)
361360
})
362-
})
361+
}
362+
if( uiSlave.slave.specificationid )
363+
this.entityApiService.getModbusSpecification(this.bus.busId,uiSlave.slave.slaveid,uiSlave.slave.specificationid, true).subscribe(fct)
364+
else
365+
fct(undefined )
366+
363367
return rc;
364368
}
365369
getUiSlave(slave: Islave, detectSpec: boolean | undefined): IuiSlave {
@@ -369,7 +373,8 @@ export class SelectSlaveComponent extends SessionStorage implements OnInit {
369373
label: this.getSlaveName(slave),
370374
slaveForm: fg,
371375
} as any;
372-
rc.specsObservable = (slave.specificationid == undefined? this.getDetectedSpecs( rc,detectSpec):this.getSpecsForConfiguredSlave(rc) )
376+
377+
rc.specsObservable = this.getSpecsForConfiguredSlave(rc) // getDetectedSpecs is disabled, because of performance issues
373378
this.addSpecificationToUiSlave(rc);
374379
(rc.selectedEntitites = this.getSelectedEntites(slave)),
375380
this.fillCommandTopics(rc);

src/app/services/api-service.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class ApiService {
7070

7171
errorHandler: (err: HttpErrorResponse) => any;
7272
getSpecification(
73-
specification: string | undefined = undefined,
73+
specification: string | undefined = undefined
7474
): Observable<Ispecification> {
7575
if (!specification) throw new Error("spec is a required parameter");
7676

@@ -83,11 +83,16 @@ export class ApiService {
8383
busid: number,
8484
slaveid: number,
8585
specification: string | undefined = undefined,
86+
deviceDetection:boolean| undefined = undefined
8687
): Observable<ImodbusSpecification> {
88+
let deviceDetectionStr :string = ''
89+
if(deviceDetection)
90+
deviceDetectionStr = '&deviceDetection=1'
91+
8792
let f: string =
8893
this.getFullUri(apiUri.modbusSpecification) +
8994
`?busid=${busid}&slaveid=${slaveid}`;
90-
if (specification) f = f + `&spec=${specification}`;
95+
if (specification) f = f + `&spec=${specification}${deviceDetectionStr}`;
9196
return this.httpClient.get<ImodbusSpecification>(f).pipe(
9297
catchError((err) => {
9398
this.errorHandler(err);

0 commit comments

Comments
 (0)