Follow AID spec more

This commit is contained in:
Daniel Kluge
2023-12-21 10:22:43 +01:00
parent 4d11d45340
commit a54a87eebe
10 changed files with 1788 additions and 1345 deletions
File diff suppressed because it is too large Load Diff
+253 -288
View File
@@ -4,337 +4,302 @@
"kind": "Instance", "kind": "Instance",
"submodelElements": [ "submodelElements": [
{ {
"idShort": "MQTT", "idShort": "Mapping01",
"typeValueListElement": "SubmodelElementCollection",
"value": [ "value": [
{ {
"idShort": "DEL-00", "idShort": "EndpointMetaDataReference",
"value": {
"type": "ModelReference",
"keys": [
{
"type": "Submodel",
"value": "www.example.com/ids/sm/7142_2140_7032_7989"
},
{
"type": "SubmodelElementCollection",
"value": "Interface01"
},
{
"type": "SubmodelElementCollection",
"value": "EndpointMetadata"
}
]
},
"modelType": "ReferenceElement"
},
{
"idShort": "MappingConfiguration",
"typeValueListElement": "SubmodelElementCollection",
"value": [ "value": [
{ {
"idShort": "EndpointMetaDataReference", "idShort": "DEL-00",
"value": {
"type": "ModelReference",
"keys": [
{
"type": "Submodel",
"value": "www.example.com/ids/sm/7142_2140_7032_7989"
},
{
"type": "SubmodelElementList",
"value": "MQTT"
},
{
"type": "SubmodelElementCollection",
"value": "DEL-00"
},
{
"type": "SubmodelElementCollection",
"value": "EndpointMetadata"
}
]
},
"modelType": "ReferenceElement"
},
{
"idShort": "MappingConfiguration",
"typeValueListElement": "SubmodelElement",
"value": [ "value": [
{ {
"idShort": "DEL-00", "idShort": "InterfaceMetaDataReference",
"value": {
"type": "ModelReference",
"keys": [
{
"type": "Submodel",
"value": "www.example.com/ids/sm/7142_2140_7032_7989"
},
{
"type": "SubmodelElementCollection",
"value": "Interface01"
},
{
"type": "SubmodelElementCollection",
"value": "InterfaceMetadata"
}
]
},
"modelType": "ReferenceElement"
},
{
"idShort": "SourceSinkMappings",
"typeValueListElement": "SubmodelElement",
"value": [ "value": [
{ {
"idShort": "InterfaceMetaDataReference", "idShort": "DEL-00",
"value": { "first": {
"type": "ModelReference", "type": "ModelReference",
"keys": [ "keys": [
{ {
"type": "Submodel", "type": "Submodel",
"value": "www.example.com/ids/sm/7142_2140_7032_7989" "value": "www.example.com/ids/sm/7142_2140_7032_7989"
}, },
{
"type": "SubmodelElementList",
"value": "MQTT"
},
{ {
"type": "SubmodelElementCollection", "type": "SubmodelElementCollection",
"value": "DEL-00" "value": "Interface01"
}, },
{ {
"type": "SubmodelElementCollection", "type": "SubmodelElementCollection",
"value": "InterfaceMetadata" "value": "InterfaceMetadata"
},
{
"type": "SubmodelElementCollection",
"value": "Properties"
},
{
"type": "SubmodelElementCollection",
"value": "Property01"
} }
] ]
}, },
"modelType": "ReferenceElement" "second": {
"type": "ModelReference",
"keys": [
{
"type": "Submodel",
"value": "https://example.com/ids/sm/8055_9060_7032_0793"
},
{
"type": "SubmodelElementCollection",
"value": "Params"
},
{
"type": "Property",
"value": "TestParam1"
}
]
},
"modelType": "RelationshipElement"
}, },
{ {
"idShort": "SourceSinkMappings", "idShort": "DEL-01",
"typeValueListElement": "SubmodelElement", "first": {
"value": [ "type": "ModelReference",
{ "keys": [
"idShort": "DEL-00", {
"first": { "type": "Submodel",
"type": "ModelReference", "value": "www.example.com/ids/sm/7142_2140_7032_7989"
"keys": [
{
"type": "Submodel",
"value": "www.example.com/ids/sm/7142_2140_7032_7989"
},
{
"type": "SubmodelElementList",
"value": "MQTT"
},
{
"type": "SubmodelElementCollection",
"value": "DEL-00"
},
{
"type": "SubmodelElementCollection",
"value": "InterfaceMetadata"
},
{
"type": "SubmodelElementList",
"value": "Properties"
},
{
"type": "SubmodelElementCollection",
"value": "DEL-00"
}
]
}, },
"second": { {
"type": "ModelReference", "type": "SubmodelElementCollection",
"keys": [ "value": "Interface01"
{
"type": "Submodel",
"value": "https://example.com/ids/sm/8055_9060_7032_0793"
},
{
"type": "SubmodelElementCollection",
"value": "Params"
},
{
"type": "Property",
"value": "TestParam1"
}
]
}, },
"modelType": "RelationshipElement" {
}, "type": "SubmodelElementCollection",
{ "value": "InterfaceMetadata"
"idShort": "DEL-01",
"first": {
"type": "ModelReference",
"keys": [
{
"type": "Submodel",
"value": "www.example.com/ids/sm/7142_2140_7032_7989"
},
{
"type": "SubmodelElementList",
"value": "MQTT"
},
{
"type": "SubmodelElementCollection",
"value": "DEL-00"
},
{
"type": "SubmodelElementCollection",
"value": "InterfaceMetadata"
},
{
"type": "SubmodelElementList",
"value": "Properties"
},
{
"type": "SubmodelElementCollection",
"value": "DEL-01"
}
]
}, },
"second": { {
"type": "ModelReference", "type": "SubmodelElementCollection",
"keys": [ "value": "Properties"
{
"type": "Submodel",
"value": "https://example.com/ids/sm/8055_9060_7032_0793"
},
{
"type": "SubmodelElementCollection",
"value": "Params"
},
{
"type": "Property",
"value": "TestParam2"
}
]
}, },
"modelType": "RelationshipElement" {
}, "type": "SubmodelElementCollection",
{ "value": "Property02"
"idShort": "DEL-02", }
"first": { ]
"type": "ModelReference", },
"keys": [ "second": {
{ "type": "ModelReference",
"type": "Submodel", "keys": [
"value": "www.example.com/ids/sm/7142_2140_7032_7989" {
}, "type": "Submodel",
{ "value": "https://example.com/ids/sm/8055_9060_7032_0793"
"type": "SubmodelElementList",
"value": "MQTT"
},
{
"type": "SubmodelElementCollection",
"value": "DEL-00"
},
{
"type": "SubmodelElementCollection",
"value": "InterfaceMetadata"
},
{
"type": "SubmodelElementList",
"value": "Actions"
},
{
"type": "SubmodelElementCollection",
"value": "DEL-00"
}
]
}, },
"second": { {
"type": "ModelReference", "type": "SubmodelElementCollection",
"keys": [ "value": "Params"
{
"type": "Submodel",
"value": "https://example.com/ids/sm/8055_9060_7032_0793"
},
{
"type": "SubmodelElementCollection",
"value": "Operations"
},
{
"type": "Operation",
"value": "TestOperation1"
}
]
}, },
"modelType": "RelationshipElement" {
}, "type": "Property",
{ "value": "TestParam2"
"idShort": "DEL-03", }
"first": { ]
"type": "ModelReference", },
"keys": [ "modelType": "RelationshipElement"
{ },
"type": "Submodel", {
"value": "www.example.com/ids/sm/7142_2140_7032_7989" "idShort": "DEL-02",
}, "first": {
{ "type": "ModelReference",
"type": "SubmodelElementList", "keys": [
"value": "MQTT" {
}, "type": "Submodel",
{ "value": "www.example.com/ids/sm/7142_2140_7032_7989"
"type": "SubmodelElementCollection",
"value": "DEL-00"
},
{
"type": "SubmodelElementCollection",
"value": "InterfaceMetadata"
},
{
"type": "SubmodelElementList",
"value": "Actions"
},
{
"type": "SubmodelElementCollection",
"value": "DEL-01"
}
]
}, },
"second": { {
"type": "ModelReference", "type": "SubmodelElementCollection",
"keys": [ "value": "Interface01"
{
"type": "Submodel",
"value": "https://example.com/ids/sm/8055_9060_7032_0793"
},
{
"type": "SubmodelElementCollection",
"value": "Operations"
},
{
"type": "Operation",
"value": "TestOperation2"
}
]
}, },
"modelType": "RelationshipElement" {
}, "type": "SubmodelElementCollection",
{ "value": "InterfaceMetadata"
"idShort": "DEL-04",
"first": {
"type": "ModelReference",
"keys": [
{
"type": "Submodel",
"value": "www.example.com/ids/sm/7142_2140_7032_7989"
},
{
"type": "SubmodelElementList",
"value": "MQTT"
},
{
"type": "SubmodelElementCollection",
"value": "DEL-00"
},
{
"type": "SubmodelElementCollection",
"value": "InterfaceMetadata"
},
{
"type": "SubmodelElementList",
"value": "Actions"
},
{
"type": "SubmodelElementCollection",
"value": "DEL-02"
}
]
}, },
"second": { {
"type": "ModelReference", "type": "SubmodelElementCollection",
"keys": [ "value": "Actions"
{
"type": "Submodel",
"value": "https://example.com/ids/sm/8055_9060_7032_0793"
},
{
"type": "SubmodelElementCollection",
"value": "Operations"
},
{
"type": "Operation",
"value": "TestOperation3"
}
]
}, },
"modelType": "RelationshipElement" {
} "type": "SubmodelElementCollection",
], "value": "Action01"
"modelType": "SubmodelElementList" }
]
},
"second": {
"type": "ModelReference",
"keys": [
{
"type": "Submodel",
"value": "https://example.com/ids/sm/8055_9060_7032_0793"
},
{
"type": "SubmodelElementCollection",
"value": "Operations"
},
{
"type": "Operation",
"value": "TestOperation1"
}
]
},
"modelType": "RelationshipElement"
},
{
"idShort": "DEL-03",
"first": {
"type": "ModelReference",
"keys": [
{
"type": "Submodel",
"value": "www.example.com/ids/sm/7142_2140_7032_7989"
},
{
"type": "SubmodelElementCollection",
"value": "Interface01"
},
{
"type": "SubmodelElementCollection",
"value": "InterfaceMetadata"
},
{
"type": "SubmodelElementCollection",
"value": "Actions"
},
{
"type": "SubmodelElementCollection",
"value": "Action02"
}
]
},
"second": {
"type": "ModelReference",
"keys": [
{
"type": "Submodel",
"value": "https://example.com/ids/sm/8055_9060_7032_0793"
},
{
"type": "SubmodelElementCollection",
"value": "Operations"
},
{
"type": "Operation",
"value": "TestOperation2"
}
]
},
"modelType": "RelationshipElement"
},
{
"idShort": "DEL-04",
"first": {
"type": "ModelReference",
"keys": [
{
"type": "Submodel",
"value": "www.example.com/ids/sm/7142_2140_7032_7989"
},
{
"type": "SubmodelElementCollection",
"value": "Interface01"
},
{
"type": "SubmodelElementCollection",
"value": "InterfaceMetadata"
},
{
"type": "SubmodelElementCollection",
"value": "Actions"
},
{
"type": "SubmodelElementCollection",
"value": "Action03"
}
]
},
"second": {
"type": "ModelReference",
"keys": [
{
"type": "Submodel",
"value": "https://example.com/ids/sm/8055_9060_7032_0793"
},
{
"type": "SubmodelElementCollection",
"value": "Operations"
},
{
"type": "Operation",
"value": "TestOperation3"
}
]
},
"modelType": "RelationshipElement"
} }
], ],
"modelType": "SubmodelElementCollection" "modelType": "SubmodelElementList"
} }
], ],
"modelType": "SubmodelElementList" "modelType": "SubmodelElementCollection"
} }
], ],
"modelType": "SubmodelElementCollection" "modelType": "SubmodelElementList"
} }
], ],
"modelType": "SubmodelElementList" "modelType": "SubmodelElementCollection"
} }
], ],
"modelType": "Submodel" "modelType": "Submodel"
+42 -44
View File
@@ -37,28 +37,46 @@ export default class AIMCMapper {
const aimc = AIMCParser.parse(this.env); const aimc = AIMCParser.parse(this.env);
if (aimc === null) return; if (aimc === null) return;
for (const endpointConf of Object.values(aimc)) { for (const entry of aimc) {
for (const entry of endpointConf) { const ep = AIDParser.parseEndpointMetaData(entry.EndpointMetaDataReference);
const ep = AIDParser.parseEndpointMetaData(entry.EndpointMetaDataReference); if (ep === null) continue;
if (ep === null) continue;
for (const mapping of entry.MappingConfiguration) { for (const mapping of entry.MappingConfiguration) {
//const ifm = AIDParser.parseInterfaceMetaData(mapping.InterfaceMetaDataReference); //const ifm = AIDParser.parseInterfaceMetaData(mapping.InterfaceMetaDataReference);
//if (ifm === null) continue; //if (ifm === null) continue;
// Why do we need this? We already have the interface metadata reference in every ssm // Why do we need this? We already have the interface metadata reference in every ssm
for (const ssm of mapping.SourceSinkMappings) { for (const ssm of mapping.SourceSinkMappings) {
const resolved = Traverser.resolveRelationship(this.env, ssm); const resolved = Traverser.resolveRelationship(this.env, ssm);
if (resolved === null) continue; if (resolved === null) continue;
// To know if we currently view a property, action or event, they reference keys can help us. // To know if we currently view a property, action or event, they reference keys can help us.
// We know the third to last must be the "InterfaceMetadata" and the second to last must be the "Properties", "Actions" or "Events". // We know the third to last must be the "InterfaceMetadata" and the second to last must be the "Properties", "Actions" or "Events".
// As we _maybe_ don't know if the first and second reference are switched we can check for the third to last. // As we _maybe_ don't know if the first and second reference are switched we can check for the third to last.
const elemType = (ssm as types.RelationshipElement).first.keys.at(-3)?.value.toLocaleLowerCase() === "interfacemetadata" ? (ssm as types.RelationshipElement).first.keys.at(-2)?.value : (ssm as types.RelationshipElement).second.keys.at(-2)?.value; const elemType = (ssm as types.RelationshipElement).first.keys.at(-3)?.value.toLocaleLowerCase() === "interfacemetadata" ? (ssm as types.RelationshipElement).first.keys.at(-2)?.value : (ssm as types.RelationshipElement).second.keys.at(-2)?.value;
let {first, second} = resolved; let {first, second} = resolved;
let parsedPropConf: InterfaceProperty | InterfaceAction | InterfaceEvent | null = null; let parsedPropConf: InterfaceProperty | InterfaceAction | InterfaceEvent | null = null;
switch (elemType?.toLocaleLowerCase()) {
case "properties":
parsedPropConf = AIDParser.parseInterfaceMetadataProperty(first as types.SubmodelElementCollection);
break;
case "actions":
parsedPropConf = AIDParser.parseInterfaceMetadataAction(first as types.SubmodelElementCollection);
break;
case "events":
parsedPropConf = AIDParser.parseInterfaceMetadataEvent(first as types.SubmodelElementCollection);
break;
default:
// Error. We have not found a valid type of element to parse.
continue;
}
if (parsedPropConf === null) {
// maybe the property is in the first element
[first, second] = [second, first];
switch (elemType?.toLocaleLowerCase()) { switch (elemType?.toLocaleLowerCase()) {
case "properties": case "properties":
@@ -70,35 +88,15 @@ export default class AIMCMapper {
case "events": case "events":
parsedPropConf = AIDParser.parseInterfaceMetadataEvent(first as types.SubmodelElementCollection); parsedPropConf = AIDParser.parseInterfaceMetadataEvent(first as types.SubmodelElementCollection);
break; break;
default:
// Error. We have not found a valid type of element to parse.
continue;
} }
if (parsedPropConf === null) {
// maybe the property is in the first element
[first, second] = [second, first];
switch (elemType?.toLocaleLowerCase()) {
case "properties":
parsedPropConf = AIDParser.parseInterfaceMetadataProperty(first as types.SubmodelElementCollection);
break;
case "actions":
parsedPropConf = AIDParser.parseInterfaceMetadataAction(first as types.SubmodelElementCollection);
break;
case "events":
parsedPropConf = AIDParser.parseInterfaceMetadataEvent(first as types.SubmodelElementCollection);
break;
}
}
if (parsedPropConf === null) continue;
this.map.set(second, ({
...ep,
...parsedPropConf
} as any as ConnectionConfiguration));
} }
if (parsedPropConf === null) continue;
this.map.set(second, ({
...ep,
...parsedPropConf
} as any as ConnectionConfiguration));
} }
} }
} }
+1 -1
View File
@@ -122,7 +122,7 @@ export default class MultiMessageBroker {
const interfaceDescription = AIDParser.parse(registration.aas); const interfaceDescription = AIDParser.parse(registration.aas);
if (!interfaceDescription) continue; if (!interfaceDescription) continue;
const endpoints = Object.values(interfaceDescription).flatMap(idEntries => idEntries.map(entry => entry.EndPointMetadata)); const endpoints = interfaceDescription.map(entry => entry.EndPointMetadata);
const uniqueProtocols: Record<string, EndpointMetadata[]> = {}; const uniqueProtocols: Record<string, EndpointMetadata[]> = {};
endpoints.forEach(endpoint => { endpoints.forEach(endpoint => {
+32 -32
View File
@@ -19,19 +19,13 @@ export default class AIDParser {
const sm = Traverser.findSMByIdShort(env, "AssetInterfacesDescription"); const sm = Traverser.findSMByIdShort(env, "AssetInterfacesDescription");
if (sm === null || sm.submodelElements === null) return null; if (sm === null || sm.submodelElements === null) return null;
const parsed = {} as AssetInterfacesDescription; const parsed = [] as AssetInterfacesDescription;
sm.submodelElements.forEach(e => { sm.submodelElements.forEach(e => {
if (!aasCore.types.isSubmodelElementList(e) || !e.idShort || !e.value) return; if (!aasCore.types.isSubmodelElementCollection(e) || !e.value) return;
const parsedInterface = AIDParser.parseAIDEntry(e);
const endpointProto = endpointAvailable(e.idShort); if (parsedInterface === null) return;
if (!endpointProto) return; parsed.push(parsedInterface);
parsed[endpointProto] = e.value.map(element => {
if (!aasCore.types.isSubmodelElementCollection(element)) return null;
return AIDParser.parseAIDEntry(element, endpointProto);
}).filter(e => e !== null) as InterfaceDescription[];
}); });
return parsed; return parsed;
@@ -43,7 +37,7 @@ export default class AIDParser {
* @param endpointProtocol Protocol used in the endpoint, so additional properties can be parsed * @param endpointProtocol Protocol used in the endpoint, so additional properties can be parsed
* @returns Description for one interface or null if not parsable * @returns Description for one interface or null if not parsable
*/ */
private static parseAIDEntry(entry: aasCore.types.SubmodelElementCollection, endpointProtocol?: AvailableEndpoint): InterfaceDescription | null { private static parseAIDEntry(entry: aasCore.types.SubmodelElementCollection): InterfaceDescription | null {
const title = Traverser.findElement(entry, element => (element as any).idShort?.toLocaleLowerCase() === "title"); const title = Traverser.findElement(entry, element => (element as any).idShort?.toLocaleLowerCase() === "title");
const titleString = title !== null && aasCore.types.isProperty(title) && title.value ? title.value : ""; const titleString = title !== null && aasCore.types.isProperty(title) && title.value ? title.value : "";
@@ -51,7 +45,9 @@ export default class AIDParser {
const im = Traverser.findElement(entry, element => (element as any).idShort?.toLocaleLowerCase() === "interfacemetadata"); const im = Traverser.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; 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); const parsedEp = AIDParser.parseEndpointMetaData(ep);
const endpointProtocol = endpointAvailable(parsedEp?.base ?? "");
const parsedIm = AIDParser.parseInterfaceMetaData(im, endpointProtocol); const parsedIm = AIDParser.parseInterfaceMetaData(im, endpointProtocol);
if (parsedEp === null || parsedIm === null) return null; if (parsedEp === null || parsedIm === null) return null;
@@ -69,7 +65,7 @@ export default class AIDParser {
* @param endpointProtocol Protocol used in the endpoint, so additional properties can be parsed * @param endpointProtocol Protocol used in the endpoint, so additional properties can be parsed
* @returns Parsed EndpointMetaData or null if not parsable * @returns Parsed EndpointMetaData or null if not parsable
*/ */
public static parseEndpointMetaData(endpoint: aasCore.types.SubmodelElementCollection, endpointProtocol?: AvailableEndpoint): EndpointMetadata | null { public static parseEndpointMetaData(endpoint: aasCore.types.SubmodelElementCollection): EndpointMetadata | null {
if (!endpoint.value || endpoint.idShort?.toLocaleLowerCase() !== "endpointmetadata") return null; if (!endpoint.value || endpoint.idShort?.toLocaleLowerCase() !== "endpointmetadata") return null;
const parsed = {} as EndpointMetadata; const parsed = {} as EndpointMetadata;
@@ -82,6 +78,7 @@ export default class AIDParser {
// TODO // TODO
// Other values based on endpoint protocol // Other values based on endpoint protocol
// Protocol is set in base string
return parsed; return parsed;
} }
@@ -106,30 +103,33 @@ export default class AIDParser {
} as InterfaceMetadata; } as InterfaceMetadata;
const prop = Traverser.findElement(interfaceMeta, element => (element as any).idShort?.toLocaleLowerCase() === "properties"); const prop = Traverser.findElement(interfaceMeta, element => (element as any).idShort?.toLocaleLowerCase() === "properties");
if (prop === null || !aasCore.types.isSubmodelElementList(prop) || !prop.value) return null; // Mandatory if (prop !== null && aasCore.types.isSubmodelElementCollection(prop)) {
for (const element of prop.overValueOrEmpty()) { for (const element of prop.overValueOrEmpty()) {
if (!aasCore.types.isSubmodelElementCollection(element)) continue; if (!aasCore.types.isSubmodelElementCollection(element)) continue;
const parsedProp = AIDParser.parseInterfaceMetadataProperty(element, endpointProtocol); const parsedProp = AIDParser.parseInterfaceMetadataProperty(element, endpointProtocol);
if (parsedProp === null) continue; if (parsedProp === null) continue;
parsed.properties.push(parsedProp); parsed.properties.push(parsedProp);
}
} }
const actions = Traverser.findElement(interfaceMeta, element => (element as any).idShort?.toLocaleLowerCase() === "actions"); const actions = Traverser.findElement(interfaceMeta, element => (element as any).idShort?.toLocaleLowerCase() === "actions");
if (actions === null || !aasCore.types.isSubmodelElementList(actions) || !actions.value) return null; // Mandatory if (actions !== null && aasCore.types.isSubmodelElementCollection(actions)) {
for (const element of actions.overValueOrEmpty()) { for (const element of actions.overValueOrEmpty()) {
if (!aasCore.types.isSubmodelElementCollection(element)) continue; if (!aasCore.types.isSubmodelElementCollection(element)) continue;
const parsedAction = AIDParser.parseInterfaceMetadataAction(element, endpointProtocol); const parsedAction = AIDParser.parseInterfaceMetadataAction(element, endpointProtocol);
if (parsedAction === null) continue; if (parsedAction === null) continue;
parsed.actions.push(parsedAction); parsed.actions.push(parsedAction);
}
} }
const events = Traverser.findElement(interfaceMeta, element => (element as any).idShort?.toLocaleLowerCase() === "events"); const events = Traverser.findElement(interfaceMeta, element => (element as any).idShort?.toLocaleLowerCase() === "events");
if (events === null || !aasCore.types.isSubmodelElementList(events) || !events.value) return null; // Mandatory if (events !== null && aasCore.types.isSubmodelElementCollection(events)) {
for (const element of events.overValueOrEmpty()) { for (const element of events.overValueOrEmpty()) {
if (!aasCore.types.isSubmodelElementCollection(element)) continue; if (!aasCore.types.isSubmodelElementCollection(element)) continue;
const parsedEvent = AIDParser.parseInterfaceMetadataEvent(element, endpointProtocol); const parsedEvent = AIDParser.parseInterfaceMetadataEvent(element, endpointProtocol);
if (parsedEvent === null) continue; if (parsedEvent === null) continue;
parsed.events.push(parsedEvent); parsed.events.push(parsedEvent);
}
} }
return parsed as InterfaceMetadata; return parsed as InterfaceMetadata;
+6 -12
View File
@@ -19,19 +19,13 @@ export default class AIMCParser {
const sm = Traverser.findSMByIdShort(env, "AssetInterfacesMappingConfiguration"); const sm = Traverser.findSMByIdShort(env, "AssetInterfacesMappingConfiguration");
if (sm === null || sm.submodelElements === null) return null; if (sm === null || sm.submodelElements === null) return null;
const parsed = {} as AssetInterfacesMappingConfiguration; const parsed = [] as AssetInterfacesMappingConfiguration;
sm.submodelElements.forEach(e => { sm.submodelElements.forEach(mapping => {
if (!aasCore.types.isSubmodelElementList(e) || !e.idShort || !e.value) return; if (!aasCore.types.isSubmodelElementCollection(mapping) || !mapping.value) return;
const parsedMapping = AIMCParser.parseAIMCEntry(mapping, env);
const endpointProto = endpointAvailable(e.idShort); if (parsedMapping === null) return;
if (!endpointProto) return; parsed.push(parsedMapping);
parsed[endpointProto] = e.value.map(element => {
if (!aasCore.types.isSubmodelElementCollection(element)) return null;
return AIMCParser.parseAIMCEntry(element, env);
}).filter(e => e !== null) as MappingConfEntry[];
}); });
return parsed; return parsed;
+1 -3
View File
@@ -1,8 +1,6 @@
import type { AvailableEndpoint } from "./common"; import type { AvailableEndpoint } from "./common";
export type AssetInterfacesDescription = { export type AssetInterfacesDescription = InterfaceDescription[];
[key in AvailableEndpoint]?: InterfaceDescription[];
};
export type InterfaceDescription = { export type InterfaceDescription = {
title: string; title: string;
+1 -2
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 type { AvailableEndpoint } from "./common";
import type { ConnectionConfiguration } from "./requests"; import type { ConnectionConfiguration } from "./requests";
export type AssetInterfacesMappingConfiguration = Record<AvailableEndpoint, MappingConfEntry[]>; export type AssetInterfacesMappingConfiguration = MappingConfEntry[];
export type MappingConfEntry = { export type MappingConfEntry = {
EndpointMetaDataReference:types.SubmodelElementCollection; EndpointMetaDataReference:types.SubmodelElementCollection;
+2 -2
View File
@@ -3,9 +3,9 @@ import type { types } from "@aas-core-works/aas-core3.0-typescript";
export const availableEndpoints = ["HTTP", "MQTT"] as const; export const availableEndpoints = ["HTTP", "MQTT"] as const;
export type AvailableEndpoint = typeof availableEndpoints[number]; export type AvailableEndpoint = typeof availableEndpoints[number];
export function endpointAvailable(endpoint: string): AvailableEndpoint | null { export function endpointAvailable(endpoint: string): AvailableEndpoint | undefined {
const idx = availableEndpoints.map(e => e.toLocaleLowerCase()).findIndex(e => e === endpoint.toLocaleLowerCase()); const idx = availableEndpoints.map(e => e.toLocaleLowerCase()).findIndex(e => e === endpoint.toLocaleLowerCase());
if (idx === -1) return null; if (idx === -1) return undefined;
return availableEndpoints[idx]; return availableEndpoints[idx];
} }
+851 -624
View File
File diff suppressed because it is too large Load Diff