HTTP Interface
This commit is contained in:
+27
-2
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user