More work on lib

This commit is contained in:
Daniel Kluge
2023-10-20 10:14:53 +02:00
parent 99fd86ff95
commit 9836905de4
5 changed files with 80 additions and 34 deletions
+25 -6
View File
@@ -1,16 +1,16 @@
import { types } from "@aas-core-works/aas-core3.0rc02-typescript";
export type PossibleRequests = "TODO";
export type OnRequestCallback = (request: PossibleRequests) => void
import type { Request, OnRequestCallback } from "types/requests";
export default abstract class AASInterfaceServer<ConfigInterface> {
protected abstract readonly name: string;
protected config: ConfigInterface;
private onRequestCallback: OnRequestCallback;
protected abstract readonly supportsSubscriptions: boolean;
protected readonly aas: types.Environment;
private onRequestCallback: OnRequestCallback
constructor(config: ConfigInterface, aas: types.Environment, onRequestCallback: OnRequestCallback) {
this.config = config;
this.aas = aas;
this.onRequestCallback = onRequestCallback;
}
@@ -19,5 +19,24 @@ export default abstract class AASInterfaceServer<ConfigInterface> {
public abstract stop(): void;
public abstract notify(event: any): void;
protected abstract findElementByRequest(request: PossibleRequests): any | null;
protected abstract findElementByRequest(request: Request): any | null;
protected findElementBySemanticId(id: string): types.Class | null {
for (const element of this.aas.descend()) {
if ((element as any).semanticId === id) {
return element;
}
}
return null;
}
protected findElementByShortId(id: string): types.Class | null {
for (const element of this.aas.descend()) {
if ((element as any).idShort === id) {
return element;
}
}
return null;
}
}