UI: lwm2m observe strategy feature.
This commit is contained in:
parent
1131fda582
commit
3f2fd6f979
@ -20,6 +20,20 @@
|
|||||||
<mat-tab label="{{ 'device-profile.lwm2m.model-tab' | translate }}">
|
<mat-tab label="{{ 'device-profile.lwm2m.model-tab' | translate }}">
|
||||||
<ng-template matTabContent>
|
<ng-template matTabContent>
|
||||||
<section [formGroup]="lwm2mDeviceProfileFormGroup">
|
<section [formGroup]="lwm2mDeviceProfileFormGroup">
|
||||||
|
<mat-form-field class="mat-block">
|
||||||
|
<mat-label translate>device-profile.lwm2m.observe-strategy.observe-strategy</mat-label>
|
||||||
|
<mat-select formControlName="observeStrategy">
|
||||||
|
<mat-select-trigger>
|
||||||
|
{{ observeStrategyMap.get(lwm2mDeviceProfileFormGroup.get('observeStrategy').value)?.name | translate }}
|
||||||
|
</mat-select-trigger>
|
||||||
|
<mat-option *ngFor="let strategy of observeStrategyList" [value]="strategy">
|
||||||
|
{{ observeStrategyMap.get(strategy).name | translate }}
|
||||||
|
<small style="display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
|
||||||
|
{{ observeStrategyMap.get(strategy).description | translate }}
|
||||||
|
</small>
|
||||||
|
</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
<tb-profile-lwm2m-object-list
|
<tb-profile-lwm2m-object-list
|
||||||
(addList)="addObjectsList($event)"
|
(addList)="addObjectsList($event)"
|
||||||
(removeList)="removeObjectsList($event)"
|
(removeList)="removeObjectsList($event)"
|
||||||
|
|||||||
@ -43,7 +43,9 @@ import {
|
|||||||
RESOURCES,
|
RESOURCES,
|
||||||
ServerSecurityConfig,
|
ServerSecurityConfig,
|
||||||
TELEMETRY,
|
TELEMETRY,
|
||||||
ObjectIDVerTranslationMap
|
ObjectIDVerTranslationMap,
|
||||||
|
ObserveStrategy,
|
||||||
|
ObserveStrategyMap
|
||||||
} from './lwm2m-profile-config.models';
|
} from './lwm2m-profile-config.models';
|
||||||
import { DeviceProfileService } from '@core/http/device-profile.service';
|
import { DeviceProfileService } from '@core/http/device-profile.service';
|
||||||
import { deepClone, isDefinedAndNotNull, isEmpty } from '@core/utils';
|
import { deepClone, isDefinedAndNotNull, isEmpty } from '@core/utils';
|
||||||
@ -84,6 +86,9 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
|
|||||||
objectIDVers = Object.values(ObjectIDVer) as ObjectIDVer[];
|
objectIDVers = Object.values(ObjectIDVer) as ObjectIDVer[];
|
||||||
objectIDVerTranslationMap = ObjectIDVerTranslationMap;
|
objectIDVerTranslationMap = ObjectIDVerTranslationMap;
|
||||||
|
|
||||||
|
observeStrategyList = Object.values(ObserveStrategy) as ObserveStrategy[];
|
||||||
|
observeStrategyMap = ObserveStrategyMap;
|
||||||
|
|
||||||
sortFunction: (key: string, value: object) => object;
|
sortFunction: (key: string, value: object) => object;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
@ -102,6 +107,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
|
|||||||
observeAttrTelemetry: [null],
|
observeAttrTelemetry: [null],
|
||||||
bootstrapServerUpdateEnable: [false],
|
bootstrapServerUpdateEnable: [false],
|
||||||
bootstrap: [[]],
|
bootstrap: [[]],
|
||||||
|
observeStrategy: [null, []],
|
||||||
clientLwM2mSettings: this.fb.group({
|
clientLwM2mSettings: this.fb.group({
|
||||||
clientOnlyObserveAfterConnect: [1, []],
|
clientOnlyObserveAfterConnect: [1, []],
|
||||||
useObject19ForOtaInfo: [false],
|
useObject19ForOtaInfo: [false],
|
||||||
@ -173,6 +179,10 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.lwm2mDeviceProfileFormGroup.get('objectIds').valueChanges.pipe(
|
||||||
|
takeUntil(this.destroy$)
|
||||||
|
).subscribe(value => this.updateObserveStrategy(value));
|
||||||
|
|
||||||
this.lwm2mDeviceProfileFormGroup.valueChanges.pipe(
|
this.lwm2mDeviceProfileFormGroup.valueChanges.pipe(
|
||||||
takeUntil(this.destroy$)
|
takeUntil(this.destroy$)
|
||||||
).subscribe((value) => {
|
).subscribe((value) => {
|
||||||
@ -261,6 +271,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
|
|||||||
observeAttrTelemetry: this.getObserveAttrTelemetryObjects(value),
|
observeAttrTelemetry: this.getObserveAttrTelemetryObjects(value),
|
||||||
bootstrap: this.configurationValue.bootstrap,
|
bootstrap: this.configurationValue.bootstrap,
|
||||||
bootstrapServerUpdateEnable: this.configurationValue.bootstrapServerUpdateEnable || false,
|
bootstrapServerUpdateEnable: this.configurationValue.bootstrapServerUpdateEnable || false,
|
||||||
|
observeStrategy: this.configurationValue.observeAttr.observeStrategy || ObserveStrategy.SINGLE,
|
||||||
clientLwM2mSettings: {
|
clientLwM2mSettings: {
|
||||||
clientOnlyObserveAfterConnect: this.configurationValue.clientLwM2mSettings.clientOnlyObserveAfterConnect,
|
clientOnlyObserveAfterConnect: this.configurationValue.clientLwM2mSettings.clientOnlyObserveAfterConnect,
|
||||||
useObject19ForOtaInfo: this.configurationValue.clientLwM2mSettings.useObject19ForOtaInfo ?? false,
|
useObject19ForOtaInfo: this.configurationValue.clientLwM2mSettings.useObject19ForOtaInfo ?? false,
|
||||||
@ -283,6 +294,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
|
|||||||
this.lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings.fwUpdateStrategy').updateValueAndValidity({onlySelf: true});
|
this.lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings.fwUpdateStrategy').updateValueAndValidity({onlySelf: true});
|
||||||
this.lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings.swUpdateStrategy').updateValueAndValidity({onlySelf: true});
|
this.lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings.swUpdateStrategy').updateValueAndValidity({onlySelf: true});
|
||||||
}
|
}
|
||||||
|
this.updateObserveStrategy(value);
|
||||||
this.cd.markForCheck();
|
this.cd.markForCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -427,6 +439,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
|
|||||||
const telemetryArray: Array<string> = [];
|
const telemetryArray: Array<string> = [];
|
||||||
const attributes: any = {};
|
const attributes: any = {};
|
||||||
const keyNameNew = {};
|
const keyNameNew = {};
|
||||||
|
const observeStrategyValue = val.length ? this.lwm2mDeviceProfileFormGroup.get('observeStrategy')?.value : ObserveStrategy.SINGLE;
|
||||||
const observeJson: ObjectLwM2M[] = JSON.parse(JSON.stringify(val));
|
const observeJson: ObjectLwM2M[] = JSON.parse(JSON.stringify(val));
|
||||||
observeJson.forEach(obj => {
|
observeJson.forEach(obj => {
|
||||||
if (isDefinedAndNotNull(obj.attributes) && !isEmpty(obj.attributes)) {
|
if (isDefinedAndNotNull(obj.attributes) && !isEmpty(obj.attributes)) {
|
||||||
@ -467,7 +480,8 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
|
|||||||
attribute: attributeArray,
|
attribute: attributeArray,
|
||||||
telemetry: telemetryArray,
|
telemetry: telemetryArray,
|
||||||
keyName: this.sortObjectKeyPathJson(KEY_NAME, keyNameNew),
|
keyName: this.sortObjectKeyPathJson(KEY_NAME, keyNameNew),
|
||||||
attributeLwm2m: attributes
|
attributeLwm2m: attributes,
|
||||||
|
observeStrategy: observeStrategyValue
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -568,4 +582,12 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
|
|||||||
return this.lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings') as UntypedFormGroup;
|
return this.lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings') as UntypedFormGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private updateObserveStrategy(value: ObjectLwM2M[]) {
|
||||||
|
if (value.length && !this.disabled) {
|
||||||
|
this.lwm2mDeviceProfileFormGroup.get('observeStrategy').enable({onlySelf: true});
|
||||||
|
} else {
|
||||||
|
this.lwm2mDeviceProfileFormGroup.get('observeStrategy').disable({onlySelf: true});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -136,6 +136,41 @@ export const ObjectIDVerTranslationMap = new Map<ObjectIDVer, string>(
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export interface ObserveStrategyData {
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum ObserveStrategy {
|
||||||
|
SINGLE = 'SINGLE',
|
||||||
|
COMPOSITE_ALL = 'COMPOSITE_ALL',
|
||||||
|
COMPOSITE_BY_OBJECT = 'COMPOSITE_BY_OBJECT'
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ObserveStrategyMap = new Map<ObserveStrategy, ObserveStrategyData>([
|
||||||
|
[
|
||||||
|
ObserveStrategy.SINGLE,
|
||||||
|
{
|
||||||
|
name: 'device-profile.lwm2m.observe-strategy.single',
|
||||||
|
description: 'device-profile.lwm2m.observe-strategy.single-description'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
ObserveStrategy.COMPOSITE_ALL,
|
||||||
|
{
|
||||||
|
name: 'device-profile.lwm2m.observe-strategy.composite-all',
|
||||||
|
description: 'device-profile.lwm2m.observe-strategy.composite-all-description'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
ObserveStrategy.COMPOSITE_BY_OBJECT,
|
||||||
|
{
|
||||||
|
name: 'device-profile.lwm2m.observe-strategy.composite-by-object',
|
||||||
|
description: 'device-profile.lwm2m.observe-strategy.composite-by-object-description'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
export interface ServerSecurityConfig {
|
export interface ServerSecurityConfig {
|
||||||
host?: string;
|
host?: string;
|
||||||
port?: number;
|
port?: number;
|
||||||
@ -187,6 +222,7 @@ export interface ObservableAttributes {
|
|||||||
telemetry: string[];
|
telemetry: string[];
|
||||||
keyName: {};
|
keyName: {};
|
||||||
attributeLwm2m: AttributesNameValueMap;
|
attributeLwm2m: AttributesNameValueMap;
|
||||||
|
observeStrategy: ObserveStrategy;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDefaultProfileObserveAttrConfig(): ObservableAttributes {
|
export function getDefaultProfileObserveAttrConfig(): ObservableAttributes {
|
||||||
@ -195,7 +231,8 @@ export function getDefaultProfileObserveAttrConfig(): ObservableAttributes {
|
|||||||
attribute: [],
|
attribute: [],
|
||||||
telemetry: [],
|
telemetry: [],
|
||||||
keyName: {},
|
keyName: {},
|
||||||
attributeLwm2m: {}
|
attributeLwm2m: {},
|
||||||
|
observeStrategy: ObserveStrategy.SINGLE
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2209,6 +2209,15 @@
|
|||||||
"v1-0": "1.0",
|
"v1-0": "1.0",
|
||||||
"v1-1": "1.1",
|
"v1-1": "1.1",
|
||||||
"v1-2": "1.2"
|
"v1-2": "1.2"
|
||||||
|
},
|
||||||
|
"observe-strategy": {
|
||||||
|
"observe-strategy": "Observe strategy",
|
||||||
|
"single": "Single",
|
||||||
|
"single-description": "One resource equals one single observe request",
|
||||||
|
"composite-all": "Composite all",
|
||||||
|
"composite-all-description": "All resources in one composite observe request",
|
||||||
|
"composite-by-object": "Composite by objects",
|
||||||
|
"composite-by-object-description": "Grouped composite observe requests by object"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"snmp": {
|
"snmp": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user