First skeleton
This commit is contained in:
Generated
+63
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"name": "prototyp",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "prototyp",
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@aas-core-works/aas-core3.0rc02-typescript": "^1.0.0-rc.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.8.2",
|
||||
"typescript": "^5.2.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@aas-core-works/aas-core3.0rc02-typescript": {
|
||||
"version": "1.0.0-rc.6",
|
||||
"resolved": "https://registry.npmjs.org/@aas-core-works/aas-core3.0rc02-typescript/-/aas-core3.0rc02-typescript-1.0.0-rc.6.tgz",
|
||||
"integrity": "sha512-dNdGOmetHzk5CqRUYNHcjufOe7qFnsvAch5ETgM/49lXf7PSbeYST/Z0MHpUHOkcLagtTUYN5dgj88mQTPUftw=="
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "20.8.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.2.tgz",
|
||||
"integrity": "sha512-Vvycsc9FQdwhxE3y3DzeIxuEJbWGDsnrxvMADzTDF/lcdR9/K+AQIeAghTQsHtotg/q0j3WEOYS/jQgSdWue3w==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.2.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz",
|
||||
"integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.17"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@aas-core-works/aas-core3.0rc02-typescript": {
|
||||
"version": "1.0.0-rc.6",
|
||||
"resolved": "https://registry.npmjs.org/@aas-core-works/aas-core3.0rc02-typescript/-/aas-core3.0rc02-typescript-1.0.0-rc.6.tgz",
|
||||
"integrity": "sha512-dNdGOmetHzk5CqRUYNHcjufOe7qFnsvAch5ETgM/49lXf7PSbeYST/Z0MHpUHOkcLagtTUYN5dgj88mQTPUftw=="
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "20.8.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.2.tgz",
|
||||
"integrity": "sha512-Vvycsc9FQdwhxE3y3DzeIxuEJbWGDsnrxvMADzTDF/lcdR9/K+AQIeAghTQsHtotg/q0j3WEOYS/jQgSdWue3w==",
|
||||
"dev": true
|
||||
},
|
||||
"typescript": {
|
||||
"version": "5.2.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz",
|
||||
"integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,10 @@
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.8.2",
|
||||
"typescript": "^5.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@aas-core-works/aas-core3.0rc02-typescript": "^1.0.0-rc.6"
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -27,9 +27,11 @@
|
||||
/* Modules */
|
||||
"module": "es2022", /* Specify what module code is generated. */
|
||||
"rootDir": "./src", /* Specify the root folder within your source files. */
|
||||
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
|
||||
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
||||
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
||||
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
|
||||
"baseUrl": "src", /* Specify the base directory to resolve non-relative module names. */
|
||||
"paths": {
|
||||
"types/*": ["types/*"]
|
||||
}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
||||
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
||||
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
||||
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
||||
Generated
-37
@@ -1,37 +0,0 @@
|
||||
{
|
||||
"name": "prototyp",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "prototyp",
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"typescript": "^5.2.2"
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.2.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz",
|
||||
"integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.17"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"typescript": {
|
||||
"version": "5.2.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz",
|
||||
"integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user