equinor / iec63131

Other
8 stars 8 forks source link

Define a mechanism/attribute to hold the function defintion for a custom arithmetic function ('#'-notation EFB) #66

Open Erik0x42 opened 2 years ago

Erik0x42 commented 2 years ago

Proposal summary, three alternative solutions: a) Facilitate direct entry of arithmetic function in a new attribute in AML, with language/syntax conformity requirements b) By new attribute/field; Facilitate reference to externally defined type, by type name and/or ID, with only interface (terminals) defined in AML c) Combine/merge a) and b) into a single new attribute, and allow both use cases concurrently

The AML library name for the custom/arithmetic function is "ElementaryFunctionLibrary/NorsokElementaryFunctionClass/Arithmetic/Opt", with Description "Optional formula - Terminal names users choice". This corresponds with the '#' entry in IEC PAS 63131:2017 Table B.2 - EFB function notations.

One solution (a) to allow instances of this type to be machine readable, and conducive to auto-generation of PLC logic, is to declare the arithmetic formula - precisely and faithfully (according to a syntax/language that is also part of the declaration) - in a field/attribute in the custom arithmetic function instance.

Another solution (b), is to reference - in the instance - a named type to be used in the logic implementation for a custom function. The named type may - subject to project agreements - be taken from any supplementary AML library (vendor specific, or project specific).

All three alternatives could be covered with one single new attribute - leaving the choice between alternatives up to standard (normative or informative) and/or project guideline. The proposal is to add an attribute to the custom function AML type, named "FunctionDefinition" (the following example is compatible with alternatives a and c):

<SystemUnitClass Name="Opt" RefBaseClassPath="ElementaryFunctionLibrary/NorsokElementaryFunctionClass/Arithmetic">
  <Description>Optional formula - Terminal names users choice</Description>
  <!-- new (non-parameter) attribute follows: -->
  <Attribute Name="FunctionDefinition" AttributeDataType="xs:string" Language="StructuredText">
    <Value>Y := X1 - 42 * SQRT( X2 );</Value>
  </Attribute>
  <Attribute Name="Notation" AttributeDataType="xs:string">
    <Description>Character in symbol</Description>
    <DefaultValue />
    <Value>#</Value>
  </Attribute>
  <ExternalInterface Name="X1" RefBaseClassPath="InterfaceClassLibrary/NorsokSignalClass/In/Analogue/X/X1">
  </ExternalInterface>
  <ExternalInterface Name="X2" RefBaseClassPath="InterfaceClassLibrary/NorsokSignalClass/In/Analogue/X/X2">
  </ExternalInterface>
  <ExternalInterface Name="Y" RefBaseClassPath="InterfaceClassLibrary/NorsokSignalClass/Out/Analogue/Y">
  </ExternalInterface>
</SystemUnitClass>
Erik0x42 commented 1 year ago

Edited on 2022-11-21: Changed issue title. Edited issue text to cover two alternative proposed solutions for custom arithmetic functions.

cdenisey commented 1 year ago

Discussions have been taken in the workshop held on 21.06.2023, refer to item 5. https://github.com/equinor/iec63131/blob/2c8fa87426e072459c5afc61afd97b1ce53cd28c/MOM%20AML%20Library%200.0.11%20workshop.docx

It has been agreed to add the possibility to write the Formula as an attribute.

AlexTxen commented 1 year ago

'FunctionDefinition' attribute was added to 'Opt' elementary function and black box in 46fbaf6bf0b8aee3f369da10a985fd151185ac22

Item/issue remains open. Language (e.g. IEC61131 Structured Text) / allowed operators restrictions are to be assessed by IEC63131 committee acc. to workshop held on 21.06.2023, refer to item 5. https://github.com/equinor/iec63131/blob/2c8fa87426e072459c5afc61afd97b1ce53cd28c/MOM%20AML%20Library%200.0.11%20workshop.docx