diff --git a/packages/td-tools/src/util/asset-interface-description.ts b/packages/td-tools/src/util/asset-interface-description.ts index d0927638c..cd0962375 100644 --- a/packages/td-tools/src/util/asset-interface-description.ts +++ b/packages/td-tools/src/util/asset-interface-description.ts @@ -893,6 +893,15 @@ export class AssetInterfaceDescriptionUtil { modelType: "Property", }); } + // description + if (propertyValue.description != null) { + propertyValues.push({ + idShort: "description", + valueType: "xs:string", + value: propertyValue.description, + modelType: "Property", + }); + } // observable (if it deviates from the default == false only) if (propertyValue.observable != null && propertyValue.observable === true) { propertyValues.push({ @@ -902,6 +911,44 @@ export class AssetInterfaceDescriptionUtil { modelType: "Property", }); } + // contentMediaType + if (propertyValue.contentMediaType != null) { + propertyValues.push({ + idShort: "contentMediaType", + valueType: "xs:string", + value: propertyValue.contentMediaType, + modelType: "Property", + }); + } + // TODO enum + // const + if (propertyValue.const != null) { + propertyValues.push({ + idShort: "const", + valueType: "xs:string", + value: propertyValue.const, + modelType: "Property", + }); + } + // default + if (propertyValue.default != null) { + propertyValues.push({ + idShort: "default", + valueType: "xs:string", + value: propertyValue.default, + modelType: "Property", + }); + } + // unit + if (propertyValue.unit != null) { + propertyValues.push({ + idShort: "unit", + valueType: "xs:string", + value: propertyValue.unit, + modelType: "Property", + }); + } + // readOnly and writeOnly marked as EXTERNAL in AID spec // range and others? Simply add them as is? diff --git a/packages/td-tools/test/AssetInterfaceDescriptionTest.ts b/packages/td-tools/test/AssetInterfaceDescriptionTest.ts index 2a3ad399c..700fd0f0b 100644 --- a/packages/td-tools/test/AssetInterfaceDescriptionTest.ts +++ b/packages/td-tools/test/AssetInterfaceDescriptionTest.ts @@ -497,6 +497,18 @@ class AssetInterfaceDescriptionUtilTest { }, ], }, + temperature: { + description: "Temperature value of the weather station", + type: "number", + minimum: -32.5, + maximum: 55.2, + unit: "degreeCelsius", + forms: [ + { + href: "temp", + }, + ], + }, }, }; @@ -586,7 +598,7 @@ class AssetInterfaceDescriptionUtilTest { .to.be.an("array") .to.have.lengthOf.greaterThan(0); let hasPropertyStatus = false; - let hasPropertyStatusDescription = false; + let hasPropertyTemperature = false; for (const propertyValue of interactionValues.value) { if (propertyValue.idShort === "status") { hasPropertyStatus = true; @@ -598,6 +610,7 @@ class AssetInterfaceDescriptionUtilTest { let hasTitle = false; let hasObservable = false; let hasForms = false; + let hasPropertyStatusDescription = false; for (const propProperty of propertyValue.value) { if (propProperty.idShort === "type") { hasType = true; @@ -636,29 +649,58 @@ class AssetInterfaceDescriptionUtilTest { expect(hasHtvMethodName).to.equal(true); } } + if (propertyValue.description != null) { + hasPropertyStatusDescription = true; + expect(propertyValue) + .to.have.property("description") + .to.eql([ + { + language: "en", + text: "Statistic", + }, + { + language: "de", + text: "Statistik", + }, + ]); + } expect(hasType).to.equal(true); expect(hasTitle).to.equal(false); expect(hasObservable).to.equal(true); expect(hasForms).to.equal(true); - } - if (propertyValue.description != null) { - hasPropertyStatusDescription = true; + expect(hasPropertyStatusDescription).to.equal(true); + } else if (propertyValue.idShort === "temperature") { + hasPropertyTemperature = true; expect(propertyValue) - .to.have.property("description") - .to.eql([ - { - language: "en", - text: "Statistic", - }, - { - language: "de", - text: "Statistik", - }, - ]); + .to.have.property("value") + .to.be.an("array") + .to.have.lengthOf.greaterThan(0); + let hasType = false; + let hasDescription = false; + let hasUnit = false; + let hasForms = false; + for (const propProperty of propertyValue.value) { + if (propProperty.idShort === "type") { + hasType = true; + expect(propProperty.value).to.equal("number"); + } else if (propProperty.idShort === "description") { + hasDescription = true; + expect(propProperty.value).to.equal("Temperature value of the weather station"); + } else if (propProperty.idShort === "unit") { + hasUnit = true; + expect(propProperty.value).to.equal("degreeCelsius"); + } else if (propProperty.idShort === "forms") { + hasForms = true; + } + } + expect(hasType).to.equal(true); + expect(hasDescription).to.equal(true); + expect(hasUnit).to.equal(true); + expect(hasForms).to.equal(true); } } expect(hasPropertyStatus).to.equal(true); - expect(hasPropertyStatusDescription).to.equal(true); + expect(hasPropertyTemperature).to.equal(true); } } expect(hasProperties).to.equal(true);