More work on lib
This commit is contained in:
+25
-6
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user