Multiple Topics for Code Generator

5 posts / 0 new
Last post
Offline
Last seen: 1 year 8 months ago
Joined: 08/09/2022
Posts: 3
Multiple Topics for Code Generator

안녕! DDS를 공부하고 있습니다.

내가 idl 파일은 다음과 같다.
""

모듈 IEC61970  {

    모듈 {

        모듈 {

            구조 ACDC 터미널 {

                부울 연결;

                수 있습니다. // 가치를 높게 평가합니다.

            };

        };

        모듈 측정기  {

            struct Discrete : 측정  {

                 최대값;

                 최소값;

             };

        };

    };

};

""" (모듈로 연결되어 잇는)

이 코드 생성기용으로 하면 '갑'에 갇히게 될 것입니다.

생성에 의해 코드의 일부는 다음과 같습니다.
""

printf(" IEC61970_Base_Meas_Discrete 독립형 , 전형 %d\n", 특성);

-> Core.ACDCTerminal.number = num++; // Core::ACDCterminal -> 동일한 오류 

"""( 오류는 ->  'class IEC61970_Base_Meas_Discrete'에 'Core'  instance->Core.ACDCTerminal.number = num++;

그 상태가 되어 있을 것
입니다.
짹짹짹짹짹 당신이 좋아하는 것?
(아니면 구성해야 하나요?)

고맙습니다

Howard's picture
Offline
Last seen: 6 days 15 hours ago
Joined: 11/29/2012
Posts: 567

Sorry did you post this in Korean?  If so, can you please repost in English?  Your IDL file is also suspect since it's using Korean characters instead of ASCII.

But fundamentally, if your IDL has

module IEC61970 {

   module Base {

      module Meas {

        module Core {

             struct ADCTerminal {

        }

     }

  }

}

 

The name of the structure is "ACDCTerminal" in the namespace "IEC61970::Base::Meas::Core".  So the fully qualified name of the structure would be "IEC61970::Base::Meas::Core::ACDCTerminal".

What is the datatype of "instance"?  In any case, "Core.ACDCTerminal.number" should not be a recognized symbol.

If "instance" is of type "IEC61970::Base::Meas::Core::ACDCTerminal", then you should access the "number" member using "instance->number".

 

Finally, when using "rtiddsgen" to generate example code, the generator only generates an example for the LAST structure defined by the IDL.  You will have to modify the generated code if you want to publish/subscribe to other structures defined in the IDL.

So, in the IDL above, the generated code will only generate example code for the "Discrete" structure

Offline
Last seen: 1 year 8 months ago
Joined: 08/09/2022
Posts: 3

First of all, sorry.
I posted it in English, but I don't know why it was uploaded in Korean.

Below are some of the previous posts. It's in Korean, so I don't know what I was trying to say.

I have the following idl file.
""

module IEC61970 {

 

    module {

 

        module {

 

            Struct ACDCTerminal {

 

                boolean connected;

 

                float number; // 

 

            };

 

        };

 

        module meter {

 

            Struct measure {

 

                float maximum;

 

                float minimum;

 

            };

 

        };

 

    };

 

};

""" (devided into module)

 

And, in the idl structure, the module is divided into two. Core and Meas.
IEC61970::Base::Meas, IEC61970::Base::Core
ADCDTerminal is in Core,
The instance is IEC61970::Base::Meas::Discrete.

So, in the code generated via "rtiddsgen", do I just add code about another structure to publish/subscribe?

Offline
Last seen: 1 year 8 months ago
Joined: 08/09/2022
Posts: 3

I'm sorry, but I want to ask you one more question.

In the case of the above idl file, can't the module itself be designated as the topic, not the sturct?

Do I really need to add publish/subscribe code to each struct by making it a topic?

Howard's picture
Offline
Last seen: 6 days 15 hours ago
Joined: 11/29/2012
Posts: 567

The example code, xxx_publisher.cxx and xxx_subscriber.cxx, is example code.  It's there for people to learn how to use Connext DDS and serves as a convenient way to have applications that publish and subscribe to a DDS Topic  for the last data structure defined in the IDL file.

You are free to modify the xxx_publisher.cxx and xxx_subscriber.cxx to add code that registers other data types, creates additional topics as well as datawriters and datareaders to send/receive those topics.  You can use the existing code in those files as an example of how to add support for new data types/topics.

In the case of the above idl file, can't the module itself be designated as the topic, not the sturct?

I'm not sure what you mean?  An IDL file defines data structures that must be implemented by what is provided by a programming language as a class or struct.
 
In IDL, the "module" keyword is translated to be a namespace in C++. 
 

If you want to have structures that have embedded structures then you have to define them and use them in the IDL, for example

struct AAADataType {
       long foo;
       double bar;
};


struct BBBDataType {
      long b_foo;
      double b_bar;
      AAADataType aaa;
};

Do I really need to add publish/subscribe code to each struct by making it a topic?

A Topic in DDS is a datastream in which all of the data uses/follows the same data type, i.e., struct. A Topic cannot be sent in different pieces. All data defined for a Topic is sent in the same packet. If you have data that do not need to be sent together, then they should be in different Topics.