Small cleanup

This commit is contained in:
Daniel Kluge
2023-10-30 14:31:32 +01:00
parent 4c7417d647
commit 8b52ffd51b
6 changed files with 21 additions and 33 deletions
@@ -11,17 +11,13 @@ export type Config = {
} }
export default class HTTPInterfaceServer extends AASInterfaceServer<Config> { export default class HTTPInterfaceServer extends AASInterfaceServer<Config> {
protected name: string = "HTTPInterfaceServer"; public readonly name: string = "HTTPInterfaceServer";
protected supportsSubscriptions: boolean = false; // TODO, longpolling? public readonly supportsSubscriptions: boolean = false; // TODO, longpolling?
private app: Express = express(); private app: Express = express();
private server: any = null; private server: any = null;
private observers: any[] = []; private observers: any[] = [];
public constructor(config: Config, aas: types.Environment, onRequestCallback: OnRequestCallback) {
super(config, aas, onRequestCallback);
}
public prepare(): void { public prepare(): void {
this.app.use(express.json()); this.app.use(express.json());
this.createRoutes(); this.createRoutes();
+6 -7
View File
@@ -1,17 +1,16 @@
import * as mqtt from "mqtt"; import * as mqtt from "mqtt";
import type { Property, Operation, OperationVariable, BasicEventElement } from "@aas-core-works/aas-core3.0-typescript/dist/types/types";
import InterfaceConnectionObject from "interfaceConnectionObject"; import InterfaceConnectionObject from "interfaceConnectionObject";
import type { types } from "@aas-core-works/aas-core3.0-typescript"; import type { types } from "@aas-core-works/aas-core3.0-typescript";
export default class MQTTConnector extends InterfaceConnectionObject<mqtt.IClientOptions> { export default class MQTTConnector extends InterfaceConnectionObject<mqtt.IClientOptions> {
public name: string = "MQTT Connector"; public readonly name: string = "MQTT Connector";
public uriProtocol: string[] = ["mqtt", "mqtts"]; public readonly uriProtocol: string[] = ["mqtt", "mqtts"];
public connectionType: "ON_DEMAND" | "PERMANENT" = "PERMANENT"; public readonly connectionType: "ON_DEMAND" | "PERMANENT" = "PERMANENT";
public supportsSubscriptions: boolean = true; public readonly supportsSubscriptions: boolean = true;
private client: mqtt.MqttClient|null = null; private client: mqtt.MqttClient|null = null;
private messageStore: Record<string, any> = {}; private readonly messageStore: Record<string, any> = {};
public connect(): boolean { public connect(): boolean {
if (!this.client) this.client = mqtt.connect(this.endpointMetadata.base, this.connectionParameter); if (!this.client) this.client = mqtt.connect(this.endpointMetadata.base, this.connectionParameter);
@@ -93,7 +92,7 @@ export default class MQTTConnector extends InterfaceConnectionObject<mqtt.IClien
throw new Error("Method not implemented."); throw new Error("Method not implemented.");
} }
public subscribeEvent(event: types.BasicEventElement, callback: (event: BasicEventElement) => void): boolean { public subscribeEvent(event: types.BasicEventElement, callback: (event: types.BasicEventElement) => void): boolean {
// TODO // TODO
// Vorher mal ne ordentliche Mapping-Definition // Vorher mal ne ordentliche Mapping-Definition
+4 -5
View File
@@ -1,8 +1,7 @@
import type { types } from "@aas-core-works/aas-core3.0-typescript"; import type { types } from "@aas-core-works/aas-core3.0-typescript";
import { AIMCMapper } from "parser/AIMCMapper"; import AIMCMapper from "./parser/AIMCMapper";
import { v4 } from "uuid"; import { v4 } from "uuid";
import type { EndpointMetadata } from "types/aidConf"; import type { EndpointMetadata } from "types/aidConf";
import { Request } from "types/requests";
type ConnectionType = "ON_DEMAND" | "PERMANENT"; type ConnectionType = "ON_DEMAND" | "PERMANENT";
@@ -14,9 +13,9 @@ export default abstract class InterfaceConnectionObject<ConfigInterface> {
public abstract readonly connectionType: ConnectionType; public abstract readonly connectionType: ConnectionType;
public abstract readonly supportsSubscriptions: boolean; public abstract readonly supportsSubscriptions: boolean;
protected observerStore: Record<any, ((value: any) => void)[]> = {}; protected readonly observerStore: Record<any, ((value: any) => void)[]> = {};
protected eventSubStore: Record<any, ((value: any) => void)[]> = {}; protected readonly eventSubStore: Record<any, ((value: any) => void)[]> = {};
protected asyncActionStateStore: Record<any, {finished: boolean, result: any}> = {}; protected readonly asyncActionStateStore: Record<any, {finished: boolean, result: any}> = {};
public constructor( public constructor(
protected readonly connectionParameter: ConfigInterface, protected readonly connectionParameter: ConfigInterface,
+2 -4
View File
@@ -1,10 +1,8 @@
import { types } from "@aas-core-works/aas-core3.0-typescript"; import { types } from "@aas-core-works/aas-core3.0-typescript";
import type AASInterfaceServer from "server"; import type AASInterfaceServer from "./server";
import type { Request } from "types/requests"; import type { Request } from "types/requests";
import type InterfaceConnectionObject from "interfaceConnectionObject"; import type InterfaceConnectionObject from "interfaceConnectionObject";
import Traverser from "./helper/traverser"; import AIMCMapper from "./parser/AIMCMapper";
import { AIMCMapper } from "./parser/AIMCMapper";
import { AssetInterfacesDescription } from "types/aidConf";
import AIDParser from "./parser/AIDParser"; import AIDParser from "./parser/AIDParser";
type AASRegistration = { type AASRegistration = {
+1 -1
View File
@@ -5,7 +5,7 @@ import Traverser from "helper/traverser";
import AIDParser from "./AIDParser"; import AIDParser from "./AIDParser";
import { SubmodelElementCollection } from "@aas-core-works/aas-core3.0-typescript/dist/types/types"; import { SubmodelElementCollection } from "@aas-core-works/aas-core3.0-typescript/dist/types/types";
export class AIMCMapper { export default class AIMCMapper {
private map: AIMCMap = new Map(); private map: AIMCMap = new Map();
+6 -10
View File
@@ -2,17 +2,13 @@ import { types } from "@aas-core-works/aas-core3.0-typescript";
import type { Request, OnRequestCallback } from "types/requests"; import type { Request, OnRequestCallback } from "types/requests";
export default abstract class AASInterfaceServer<ConfigInterface> { export default abstract class AASInterfaceServer<ConfigInterface> {
protected abstract readonly name: string; public abstract readonly name: string;
protected config: ConfigInterface; public abstract readonly supportsSubscriptions: boolean;
protected abstract readonly supportsSubscriptions: boolean;
protected readonly aas: types.Environment;
protected onRequestCallback: OnRequestCallback
constructor(config: ConfigInterface, aas: types.Environment, onRequestCallback: OnRequestCallback) { constructor(
this.config = config; protected readonly config: ConfigInterface,
this.aas = aas; protected readonly aas: types.Environment,
this.onRequestCallback = onRequestCallback; protected readonly onRequestCallback: OnRequestCallback) {}
}
public abstract prepare(): void; public abstract prepare(): void;
public abstract run(): void; public abstract run(): void;