HTTP Interface

This commit is contained in:
Daniel Kluge
2023-10-23 16:18:20 +02:00
parent 0fd7b81526
commit 778202e61a
3 changed files with 178 additions and 31 deletions
+27 -2
View File
@@ -70,11 +70,36 @@ export default class AASHelper {
return current;
}
public static findElement(environment: types.Class, checkFunction: (element: types.Class) => boolean): types.Class | null {
for (const element of environment.descend()) {
public static traverseByShortIds(start: types.Class, shortIds: string[]): types.Class | null {
let current: types.Class | null = start;
for (const shortId of shortIds) {
if (current === null) break;
current = AASHelper.findChildByIdShort(current, shortId);
}
return current;
}
public static getElementByIdPath(env: types.Environment, submodelOrIdShort: string | types.Submodel, idShorts: string[]): types.Class | null {
const sm = typeof submodelOrIdShort === "string" ? AASHelper.findSMByIdShort(env, submodelOrIdShort) : submodelOrIdShort;
if (sm === null) return null;
return AASHelper.traverseByShortIds(sm, idShorts);
}
public static findElement(start: types.Class, checkFunction: (element: types.Class) => boolean): types.Class | null {
for (const element of start.descend()) {
if (checkFunction(element)) return element;
}
return null;
}
public static findChildByIdShort(start: types.Class, idShort: string): types.Class | null {
for (const child of start.descendOnce()) {
if ((child as any).idShort === idShort) return child;
}
return null;
}
}