Open62541 nodeset compiler [RuntimeError: Infinite loop detected or type not found while processing type]

94 Views Asked by At

I need help with the following. I am working on an application for OPC-UA that makes use of Safety Nodeset. But I run into an error while compiling the nodesets using the open62541 nodeset compiler. Can anyone help me with this. The details are as follows.

  1. I generate Nodeset2 and related files using UA-Model Compiler.

For Safety Nodeset:

Opc.Ua.ModelCompiler.exe compile-nodesets -input .\OPC_Foundation_Safety-files -o2 .\generated_safety -uri http://opcfoundation.org/UA/Safety

copy .\generated_safety .\generated

For App.xml

del .\AppModel.csv

Opc.Ua.ModelCompiler.exe compile -d2 .\AppModel.xml -d2 .\OPC_Foundation_Safety-files\Opc.Ua.Safety.NodeSet2.xml,Safety,Safety -cg .\AppModel.csv -version v105 -o2 .\generated
  1. The AppModel.xml is as follows
<?xml version="1.0" encoding="utf-8"?>

<ModelDesign
  xmlns:uax="http://opcfoundation.org/UA/2008/02/Types.xsd"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:ua="http://opcfoundation.org/UA/"
  xmlns:Safety="http://opcfoundation.org/UA/Safety"
  xmlns:app="urn:open62541.server.application"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  TargetNamespace="urn:open62541.server.application"
  TargetVersion="0.1.0"
  TargetPublicationDate="2022-05-02T00:00:00Z"
  xmlns="http://opcfoundation.org/UA/ModelDesign.xsd">

  <Namespaces>
    <Namespace Name="app" Prefix="app">urn:open62541.server.application</Namespace>
    <Namespace Name="Safety" Prefix="Safety" PublicationDate="2022-06-28T00:00:00Z" Version="1.05.02">http://opcfoundation.org/UA/Safety</Namespace>
    <Namespace Name="ua" Prefix="ua" Version="1.05.02" PublicationDate="2022-11-01T00:00:00Z">http://opcfoundation.org/UA/</Namespace>
  </Namespaces>

  <DataType SymbolicName="app:MyResponseSPDUDataType" BaseType="Safety:ResponseSPDUDataType" IsAbstract="false">
    <Fields>      
      <Field Name="MyOutSafetyData"  DataType="app:MySafetyData1Type"></Field>
      <Field Name="MyOutNonSafetyData" DataType="app:MyNonSafetyData1Type"></Field>
    </Fields>
  </DataType>

  <DataType SymbolicName="app:MySafetyData1Type" BaseType="ua:Structure" >   
    <Fields>
      <Field Name="Field_1" DataType="ua:UInt32"></Field>
      <Field Name="Field_2" DataType="ua:UInt32"></Field>
      <Field Name="Field_4" DataType="ua:Boolean"></Field>     
    </Fields>
  </DataType>

  <DataType SymbolicName="app:MyNonSafetyData1Type" BaseType="ua:Structure">
    <Fields>
      <Field Name="Item1" DataType="ua:UInt32"></Field>
    </Fields>
  </DataType>


  <!-- ### Object ###-->

  <Object SymbolicName="app:MySafetyProvider" TypeDefinition="Safety:SafetyProviderType">
    <Children>
      <Method SymbolicName="app:MyReadSafetyData">
        <InputArguments>
          <Argument Name="InSafetyConsumerID" DataType="ua:UInt32" ValueRank="Scalar"></Argument>
          <Argument Name="InMonitoringNumber" DataType="ua:UInt32" ValueRank="Scalar"></Argument>
          <Argument Name="InFlags" DataType="Safety:InFlagsType" ValueRank="Scalar"></Argument>
        </InputArguments>
        <OutputArguments>
          <Argument Name="OutSafetyData" DataType="app:MySafetyData1Type" ></Argument>
          <Argument Name="OutFlags" DataType="Safety:OutFlagsType" ValueRank="Scalar"></Argument>
          <Argument Name="OutSPDU_ID_1" DataType="ua:UInt32" ValueRank="Scalar"></Argument>
          <Argument Name="OutSPDU_ID_2" DataType="ua:UInt32" ValueRank="Scalar"></Argument>
          <Argument Name="OutSPDU_ID_3" DataType="ua:UInt32" ValueRank="Scalar"></Argument>
          <Argument Name="OutSafetyConsumerID" DataType="ua:UInt32" ValueRank="Scalar"></Argument>
          <Argument Name="OutMonitoringNumber" DataType="ua:UInt32" ValueRank="Scalar"></Argument>
          <Argument Name="OutCRC" DataType="ua:UInt32" ValueRank="Scalar"></Argument>
          <Argument Name="OutNonSafetyData" DataType="app:MyNonSafetyData1Type" ></Argument>
        </OutputArguments>
      </Method>           
      <Object SymbolicName="app:MySafetyPDUs" TypeDefinition="Safety:SafetyPDUsType">
        <Children>
          <Variable SymbolicName="app:MyRequestSPDU" DataType="Safety:RequestSPDUDataType" TypeDefinition="ua:BaseDataVariableType"></Variable>
          <Variable SymbolicName="app:MyResponseSPDU" DataType="app:MyResponseSPDUDataType" TypeDefinition="ua:BaseDataVariableType"></Variable>
        </Children>
      </Object>
    </Children>

    <References>
      <Reference IsInverse="true">
        <ReferenceType>ua:Organizes</ReferenceType>
        <TargetId>Safety:SafetyACSet</TargetId>
      </Reference>
    </References>
  </Object>   
  
</ModelDesign>

  1. The app.Types.bsd file is as follows as generated by UA-Modeler
<opc:TypeDictionary
  xmlns:Safety="http://opcfoundation.org/UA/Safety"
  xmlns:SafetyTest="http://opcfoundation.org/UA/SafetyTest"
  xmlns:opc="http://opcfoundation.org/BinarySchema/"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:ua="http://opcfoundation.org/UA/"
  xmlns:tns="urn:open62541.server.application"
  DefaultByteOrder="LittleEndian"
  TargetNamespace="urn:open62541.server.application"
>
  <opc:Import Namespace="http://opcfoundation.org/UA/" Location="ua.BinarySchema.bsd"/>
  <opc:Import Namespace="http://opcfoundation.org/UA/Safety" Location="Safety.BinarySchema.bsd"/>

  <opc:StructuredType Name="SafetyProvider1ResponseSPDUDataType" BaseType="Safety:ResponseSPDUDataType">
    <opc:Field Name="OutFlags" TypeName="Safety:OutFlagsType" SourceType="Safety:ResponseSPDUDataType" />
    <opc:Field Name="OutSPDU_ID_1" TypeName="opc:UInt32" SourceType="Safety:ResponseSPDUDataType" />
    <opc:Field Name="OutSPDU_ID_2" TypeName="opc:UInt32" SourceType="Safety:ResponseSPDUDataType" />
    <opc:Field Name="OutSPDU_ID_3" TypeName="opc:UInt32" SourceType="Safety:ResponseSPDUDataType" />
    <opc:Field Name="OutSafetyConsumerID" TypeName="opc:UInt32" SourceType="Safety:ResponseSPDUDataType" />
    <opc:Field Name="OutMonitoringNumber" TypeName="opc:UInt32" SourceType="Safety:ResponseSPDUDataType" />
    <opc:Field Name="OutCRC" TypeName="opc:UInt32" SourceType="Safety:ResponseSPDUDataType" />
    <opc:Field Name="OutSafetyData" TypeName="tns:SafetyData1Type" />
    <opc:Field Name="OutNonSafetyData" TypeName="tns:NonSafetyData1Type" />
  </opc:StructuredType>

  <opc:StructuredType Name="SafetyData1Type" BaseType="ua:ExtensionObject">
    <opc:Field Name="Field_1" TypeName="opc:UInt32" />
    <opc:Field Name="Field_2" TypeName="opc:UInt32" />
    <opc:Field Name="Field_3" TypeName="opc:UInt32" />
    <opc:Field Name="Field_4" TypeName="opc:Boolean" />
  </opc:StructuredType>

  <opc:StructuredType Name="NonSafetyData1Type" BaseType="ua:ExtensionObject">
    <opc:Field Name="Item1" TypeName="opc:UInt32" />
  </opc:StructuredType>

</opc:TypeDictionary>
  1. The UAModel.Safety.Types.bsd is as follows as generated by UA-Modeler
<opc:TypeDictionary
  xmlns:opc="http://opcfoundation.org/BinarySchema/"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:ua="http://opcfoundation.org/UA/"
  xmlns:tns="http://opcfoundation.org/UA/Safety"
  DefaultByteOrder="LittleEndian"
  TargetNamespace="http://opcfoundation.org/UA/Safety"
>
  <opc:Import Namespace="http://opcfoundation.org/UA/" Location="Opc.Ua.BinarySchema.bsd"/>

  <opc:EnumeratedType Name="InFlagsType" LengthInBits="8" IsOptionSet="true">
    <opc:Documentation>Byte with Non safety Flags from SafetyConsumer</opc:Documentation>
    <opc:EnumeratedValue Name="None" Value="0" />
    <opc:EnumeratedValue Name="CommunicationError" Value="1" />
    <opc:EnumeratedValue Name="OperatorAckRequested" Value="2" />
    <opc:EnumeratedValue Name="FSV_Activated" Value="4" />
  </opc:EnumeratedType>

  <opc:EnumeratedType Name="OutFlagsType" LengthInBits="8" IsOptionSet="true">
    <opc:Documentation>Byte with Safety Flags from SafetyProvider</opc:Documentation>
    <opc:EnumeratedValue Name="None" Value="0" />
    <opc:EnumeratedValue Name="OperatorAckProvider" Value="1" />
    <opc:EnumeratedValue Name="ActivateFSV" Value="2" />
    <opc:EnumeratedValue Name="TestModeActivated" Value="4" />
  </opc:EnumeratedType>

  <opc:StructuredType Name="NonSafetyDataPlaceholderDataType" BaseType="ua:ExtensionObject">
    <opc:Documentation>Dummy structure to be used when no non-safety data are used</opc:Documentation>
    <opc:Field Name="Dummy" TypeName="opc:Boolean" />
  </opc:StructuredType>

  <opc:StructuredType Name="RequestSPDUDataType" BaseType="ua:ExtensionObject">
    <opc:Field Name="InSafetyConsumerID" TypeName="opc:UInt32" />
    <opc:Field Name="InMonitoringNumber" TypeName="opc:UInt32" />
    <opc:Field Name="InFlags" TypeName="tns:InFlagsType" />
  </opc:StructuredType>

  <opc:StructuredType Name="ResponseSPDUDataType" BaseType="ua:ExtensionObject">
    <opc:Field Name="OutFlags" TypeName="tns:OutFlagsType" />
    <opc:Field Name="OutSPDU_ID_1" TypeName="opc:UInt32" />
    <opc:Field Name="OutSPDU_ID_2" TypeName="opc:UInt32" />
    <opc:Field Name="OutSPDU_ID_3" TypeName="opc:UInt32" />
    <opc:Field Name="OutSafetyConsumerID" TypeName="opc:UInt32" />
    <opc:Field Name="OutMonitoringNumber" TypeName="opc:UInt32" />
    <opc:Field Name="OutCRC" TypeName="opc:UInt32" />
  </opc:StructuredType>

</opc:TypeDictionary>

Then I used the CMake GUI to generate Visual Studio Project. The generator is set to Visual Studio 17 2022

cmake_minimum_required(VERSION 3.2)
project(app VERSION 0.1.0)

find_package(open62541 REQUIRED COMPONENTS Events FullNamespace)

ua_generate_nodeset_and_datatypes(
    NAME "safety"
    FILE_NS "${PROJECT_SOURCE_DIR}/generated/UAModel.Safety.NodeSet2.xml"
    FILE_CSV "${PROJECT_SOURCE_DIR}/generated/UAModel.Safety.NodeIds.csv"
    FILE_BSD "${PROJECT_SOURCE_DIR}/generated/UAModel.Safety.Types.bsd"
    NAMESPACE_MAP "2:http://opcfoundation.org/UA/Safety"
    INTERNAL
)

ua_generate_nodeset_and_datatypes(
    NAME "app"
    FILE_NS "${PROJECT_SOURCE_DIR}/generated/app.NodeSet2.xml"
    FILE_CSV "${PROJECT_SOURCE_DIR}/generated/app.NodeIds.csv"
    FILE_BSD "${PROJECT_SOURCE_DIR}/generated/app.Types.bsd" "${PROJECT_SOURCE_DIR}/generated/UAModel.Safety.Types.bsd"
    NAMESPACE_MAP "1:urn:open62541.server.application"
    DEPENDS "safety"
    INTERNAL
    )
    
add_executable(${PROJECT_NAME} main.c)
target_link_libraries(${PROJECT_NAME} open62541::open62541)

Used CMake options:

-DCMAKE_CONFIGURATION_TYPES:STRING="Debug;Release;MinSizeRel;RelWithDebInfo" -Dopen62541_DIR:PATH="./../../../SDK_Open62541/open62541/build" -DUA_NAMESPACE_ZERO:STRING="FULL" -DCMAKE_INSTALL_PREFIX:PATH="C:/Program Files (x86)/app" -Dopen62541_TOOLS_DIR:PATH="./../../../SDK_Open62541/open62541/tools" -DUA_NODESET_DIR:PATH="./../../../SDK_Open62541/open62541/deps/ua-nodeset"

When I compile on Visual Studio 2022 I get the following error:

5>Traceback (most recent call last):
5>  File ".\..\..\..\SDK_Open62541\open62541\tools\generate_datatypes.py", line 95, in <module>
5>    parser.create_types()
5>  File ".\..\..\..\SDK_Open62541\open62541\tools\nodeset_compiler\type_parser.py", line 377, in create_types
5>    self.parse_types()
5>  File ".\..\..\..\SDK_Open62541\open62541\tools\nodeset_compiler\type_parser.py", line 419, in parse_types
5>    self.parseTypeDefinitions(self.outname, f)
5>  File ".\..\..\..\SDK_Open62541\open62541\tools\nodeset_compiler\type_parser.py", line 321, in parseTypeDefinitions
5>    raise RuntimeError("Infinite loop detected or type not found while processing types " +
5>RuntimeError: Infinite loop detected or type not found while processing types MyResponseSPDUDataType: unknonwn subtype ['Opc.Ua.Safety:OutFlagsType']. If the unknown subtype is 'Bit', then maybe a struct with optional fields is defined wrong in the .bsd-file. If not, maybe you need to import additional types with the --import flag. E.g. '--import=UA_TYPES#/path/to/deps/ua-nodeset/Schema/Opc.Ua.Types.bsd'

Can anyone help on how to resolve the error with ['Safety:OutFlagsType'] Thanks.

0

There are 0 best solutions below