It lives!
This commit is contained in:
+11
-11
@@ -1,12 +1,12 @@
|
||||
import * as aasCore from "@aas-core-works/aas-core3.0-typescript";
|
||||
import type { AssetInterfaceDescription, EndpointMetadata, InterfaceDescription, InterfaceMetadata, InterfaceAction, InterfaceEvent, InterfaceProperty, InterfacePropertyForm } from "types/aidConf";
|
||||
import { AvailableEndpoint, endpointAvailable } from "types/common";
|
||||
import AASStore from "aasStore";
|
||||
import { AvailableEndpoint, endpointAvailable } from "../types/common";
|
||||
import AASHelper from "../aasHelper";
|
||||
|
||||
export default class AIDParser {
|
||||
|
||||
public static parse(env: aasCore.types.Environment): AssetInterfaceDescription | null {
|
||||
const sm = AASStore.findSMByIdShort(env, "AssetInterfaceDescription");
|
||||
const sm = AASHelper.findSMByIdShort(env, "AssetInterfaceDescription");
|
||||
if (sm === null || sm.submodelElements === null) return null;
|
||||
|
||||
const parsed = {} as AssetInterfaceDescription;
|
||||
@@ -28,11 +28,11 @@ export default class AIDParser {
|
||||
}
|
||||
|
||||
private static parseAIDEntry(entry: aasCore.types.SubmodelElementCollection, endpointProtocol?: AvailableEndpoint): InterfaceDescription | null {
|
||||
const title = AASStore.findElement(entry, element => (element as any).idShort.toLocaleLowerCase() === "title");
|
||||
const title = AASHelper.findElement(entry, element => (element as any).idShort.toLocaleLowerCase() === "title");
|
||||
const titleString = title !== null && aasCore.types.isProperty(title) && title.value ? title.value : "";
|
||||
|
||||
const ep = AASStore.findElement(entry, element => (element as any).idShort.toLocaleLowerCase() === "endpointmetadata");
|
||||
const im = AASStore.findElement(entry, element => (element as any).idShort.toLocaleLowerCase() === "interfacemetadata");
|
||||
const ep = AASHelper.findElement(entry, element => (element as any).idShort.toLocaleLowerCase() === "endpointmetadata");
|
||||
const im = AASHelper.findElement(entry, element => (element as any).idShort.toLocaleLowerCase() === "interfacemetadata");
|
||||
if (ep === null || !aasCore.types.isSubmodelElementCollection(ep) || !ep.value || im === null || !aasCore.types.isSubmodelElementCollection(im) || !im.value) return null;
|
||||
|
||||
const parsedEp = AIDParser.parseEndpointMetaData(ep, endpointProtocol);
|
||||
@@ -53,7 +53,7 @@ export default class AIDParser {
|
||||
const parsed = {} as EndpointMetadata;
|
||||
|
||||
for (const key of ["base", "contentType"]) {
|
||||
const prop = AASStore.findElement(endpoint, element => (element as any).idShort.toLocaleLowerCase() === key.toLocaleLowerCase());
|
||||
const prop = AASHelper.findElement(endpoint, element => (element as any).idShort.toLocaleLowerCase() === key.toLocaleLowerCase());
|
||||
if (prop === null || !aasCore.types.isProperty(prop) || !prop.value) return null; // Mandatory
|
||||
else parsed[key] = prop.value;
|
||||
}
|
||||
@@ -73,7 +73,7 @@ export default class AIDParser {
|
||||
events: []
|
||||
} as InterfaceMetadata;
|
||||
|
||||
const prop = AASStore.findElement(interfaceMeta, element => (element as any).idShort.toLocaleLowerCase() === "properties");
|
||||
const prop = AASHelper.findElement(interfaceMeta, element => (element as any).idShort.toLocaleLowerCase() === "properties");
|
||||
if (prop === null || !aasCore.types.isSubmodelElementList(prop) || !prop.value) return null; // Mandatory
|
||||
for (const element of prop.value) {
|
||||
if (!aasCore.types.isSubmodelElementCollection(element)) continue;
|
||||
@@ -82,7 +82,7 @@ export default class AIDParser {
|
||||
parsed.properties.push(parsedProp);
|
||||
}
|
||||
|
||||
const actions = AASStore.findElement(interfaceMeta, element => (element as any).idShort.toLocaleLowerCase() === "actions");
|
||||
const actions = AASHelper.findElement(interfaceMeta, element => (element as any).idShort.toLocaleLowerCase() === "actions");
|
||||
if (actions === null || !aasCore.types.isSubmodelElementList(actions) || !actions.value) return null; // Mandatory
|
||||
for (const element of actions.value) {
|
||||
if (!aasCore.types.isSubmodelElementCollection(element)) continue;
|
||||
@@ -106,7 +106,7 @@ export default class AIDParser {
|
||||
else parsed[key] = prop.value;
|
||||
} */
|
||||
|
||||
const forms = AASStore.findElement(prop, element => (element as any).idShort.toLocaleLowerCase() === "forms");
|
||||
const forms = AASHelper.findElement(prop, element => (element as any).idShort.toLocaleLowerCase() === "forms");
|
||||
if (forms === null || !aasCore.types.isSubmodelElementList(forms) || !forms.value) return null; // Mandatory
|
||||
for (const element of forms.value) {
|
||||
if (!aasCore.types.isSubmodelElementCollection(element)) continue;
|
||||
@@ -127,7 +127,7 @@ export default class AIDParser {
|
||||
const parsed = {} as any;
|
||||
|
||||
for (const key of ["href", "contentType"]) {
|
||||
const prop = AASStore.findElement(form, element => (element as any).idShort.toLocaleLowerCase() === key.toLocaleLowerCase());
|
||||
const prop = AASHelper.findElement(form, element => (element as any).idShort.toLocaleLowerCase() === key.toLocaleLowerCase());
|
||||
if (prop === null || !aasCore.types.isProperty(prop) || !prop.value) return null; // Mandatory
|
||||
else parsed[key] = prop.value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user