Hi, I am trying to use C++ struct to exchange structured data through ports. Is it really supported ? What I am doing wrong so that the PCWE Data List editors refuse the ports match ? Case sensitivity issue ? In my C++ program: enum TCommSpeed: int16 {csRobust =1, csAverage, csFast}; typedef struct
{
TCommSpeed CommSpeed;
// etc…
}TSystConfig; //… etc… TSystConfig xiSystConfig = {csAverage}; // Init first and only struct member // In my program creator: AddPortInfo(“xiSystConfig”, this->xiSystConfig); In my Metadata file (I removed the XML tags to not screw the editor): Port kind=“Input” name=“xiSystConfig” type=“TSystConfig” multiplicity=“1”
My PCWE data type declaration: TYPE COMM_SPEEDS:
(
CS_ROBUST := 1,
CS_AVERAGE,
CS_FAST
)OF INT := CS_AVERAGE; // Default value
END_TYPE
TYPE
TSystConfig: STRUCT
CommSpeed: COMM_SPEEDS;
// etc…
END_STRUCT; END_TYPE Removing the “enum” stuff on both side does not improve the result.
Hey, I think you might be missing the Library.Typemeta file. You can auto generated it if you once add AddPortInfo(“In.Id”, this->messageIn); and trigger “generate Progmeta file”. When that is done name it as follows and it should workout fine. Example: hpp:
struct Message
> {
> uint8 Id = 0;
> uint8 Length = 0;
> uint8 Data[80];
> };
cpp:
// Inports
> AddPortInfo("In.Id", this->messageIn.Id);
> AddPortInfo("In.Length", this->messageIn.Length);
> AddPortInfo("In.Data", this->messageIn.Data);
// Outports
> AddPortInfo("Out.Id", this->messageOut.Id);
> AddPortInfo("Out.Length", this->messageOut.Length);
> AddPortInfo("Out.Data", this->messageOut.Data);
> }
librarie.Typemeta:
Struct name="Message"
> Fields
> Field name="Id" type="uint8" multiplicity="1"/
> Field name="Length" type="uint8" multiplicity="1"/
> Field name="Data" type="uint8" multiplicity="80"/
> /Fields>
> /Struct>
program.Progmeta:
Program name="MessageProgram"
> Ports
> Port kind="Input" name="In" type="Message" multiplicity="1"
> Port kind="Output" name="Out" type="Message" multiplicity="1"
> /Ports
> /Program>
Library.Libmeta: // note that the Typemeta was linked here.
TypeIncludes
> Include path="ExampleLibrary.typemeta"/
> /TypeIncludes
Thanks Oliver. It is exactly what I needed. I will again give a try to the “generate Progmeta file”, hopping the problem I had before is now solved in PCWE v7.2.2 (did not work on mutiple Program classes project). I am curious where I could found that information. Where this kind of detailed information can be found ?
Hi fblanchard, please find now also a tutorial here Use ports with user defined datatypes. Have a nice weekend! Frank