First skeleton
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { types } from "@aas-core-works/aas-core3.0rc02-typescript";
|
||||
|
||||
export class AASStore {
|
||||
private static instance: AASStore;
|
||||
private shells: Array<types.AssetAdministrationShell> = [];
|
||||
|
||||
private constructor() { }
|
||||
|
||||
public static getInstance(): AASStore {
|
||||
if (!AASStore.instance) {
|
||||
AASStore.instance = new AASStore();
|
||||
}
|
||||
|
||||
return AASStore.instance;
|
||||
}
|
||||
|
||||
public addAAS(aas: types.AssetAdministrationShell | types.Environment): void {
|
||||
if (aas instanceof types.Environment) {
|
||||
if (aas.assetAdministrationShells) this.shells = this.shells.concat(aas.assetAdministrationShells);
|
||||
} else {
|
||||
this.shells.push(aas);
|
||||
}
|
||||
}
|
||||
|
||||
public getAAS(id: string): types.AssetAdministrationShell | undefined {
|
||||
return this.shells.find((aas) => aas.id === id);
|
||||
}
|
||||
|
||||
public removeAAS(id: string): void {
|
||||
this.shells = this.shells.filter((aas) => aas.id !== id);
|
||||
}
|
||||
|
||||
public getAll(): Array<types.AssetAdministrationShell> {
|
||||
return this.shells;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import type { types } from "@aas-core-works/aas-core3.0rc02-typescript";
|
||||
|
||||
type ConnectionType = "ON_DEMAND" | "PERMANENT";
|
||||
|
||||
export abstract class InterfaceConnectionObject {
|
||||
public abstract readonly name: string;
|
||||
public abstract readonly connectionType: ConnectionType;
|
||||
public abstract readonly supportsSubscriptions: boolean;
|
||||
|
||||
public abstract connect(): boolean;
|
||||
|
||||
public abstract disconnect(): void;
|
||||
|
||||
public abstract readProperty(prop: types.Property): void;
|
||||
|
||||
public abstract writeProperty(prop: types.Property, value: any): void;
|
||||
|
||||
public abstract observeProperty(prop: types.Property, callback: (value: any) => void): boolean;
|
||||
|
||||
public abstract callActionSync(action: types.Operation, args: types.OperationVariable[]): any;
|
||||
|
||||
public abstract callActionAsync(action: types.Operation, args: types.OperationVariable[]): Promise<boolean>;
|
||||
|
||||
public abstract readAsyncActionResponse(action: types.Operation): Promise<any>;
|
||||
|
||||
public abstract subscribeEvent(callback: (event: types.BasicEventElement) => void): boolean;
|
||||
|
||||
public abstract unsubscribeEvent(): void;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import type { types } from "@aas-core-works/aas-core3.0rc02-typescript";
|
||||
|
||||
type AASParsingType = types.Environment | types.AssetAdministrationShell | types.Submodel;
|
||||
|
||||
export interface Parser<T extends AASParsingType> {
|
||||
parse(): T | T[];
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { readdir, readFile } from "fs/promises";
|
||||
|
||||
export async function getAllAASFiles(aasPath: string): Promise<string[]> {
|
||||
const files = await readdir(aasPath);
|
||||
return files.filter(file => file.endsWith(".json")).map(file => `${aasPath}/${file}`);
|
||||
}
|
||||
|
||||
export async function getAASFileContent(aasPath: string): Promise<string> {
|
||||
const content = await readFile(aasPath, { encoding: "utf-8" });
|
||||
return content;
|
||||
}
|
||||
|
||||
export async function getAllAASFileContents(aasPath: string): Promise<string[]> {
|
||||
const files = await getAllAASFiles(aasPath)
|
||||
const content = [];
|
||||
for (const file of files) {
|
||||
content.push(await getAASFileContent(file));
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import type { types } from "@aas-core-works/aas-core3.0rc02-typescript";
|
||||
|
||||
type AASRequestType = types.Environment | types.Submodel;
|
||||
type AASResponseType = types.BasicEventElement | types.ValueList;
|
||||
|
||||
interface RequestTransformer<T extends AASRequestType, U> {
|
||||
transform(request: T): U;
|
||||
}
|
||||
|
||||
interface NorthboundResponseTransformer<T, U extends AASResponseType> {
|
||||
transform(response: T): U;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
type ServerConfig = {
|
||||
bindName: string;
|
||||
bindPort: number;
|
||||
}
|
||||
|
||||
export abstract class AASInterfaceServer {
|
||||
public abstract readonly name: string;
|
||||
public abstract config: ServerConfig;
|
||||
|
||||
public abstract prepare(): void;
|
||||
public abstract run(): void;
|
||||
}
|
||||
Reference in New Issue
Block a user