Reputation:
I began to work with C# and I'm trying to test the code that follows for an dds app. I took it from: http://www.laas.fr/files/SLides-A_Corsaro.pdf
using System;
/**********************************************************
* Definition for the TempSensorType
**********************************************************/
enum TemperatureScale{
CELSIUS,
KELVIN,
FAHRENHEIT
};
struct TempSensorType{
short id;
float temp;
float hum;
TemperatureScale scale;
};
#pragma keylist TempSensor id
/**********************************************************
* Main
**********************************************************/
static public void Main(string[] args){
dds::Topic<TempSensorType> tsTopic(TempSensorTopic);
dds::DataWriter<TempSensorType> dw(tsTopic);
dds::DataReader<TempSensorType> dr(tsTopic);
dds::SampleInfoSeq info;
TempSensorSeq data;
TempSensorType ts;
ts = new TempSensorType { 1, 25.0F, 65.0F, CELSIUS };
dw.write(ts);
ts = new TempSensorType { 2, 26.0F, 70.0F, CELSIUS };
dw.write(ts);
ts = new TempSensorType { 3, 27.0F, 75.0F, CELSIUS };
dw.write(ts);
sleep(10);
while (true){
dr.read(data, info);
for (int i = 0; i < data.length(); ++i)
std::cout << data[i] << std::endl;
sleep(1);
}
Console.WriteLine("Bonjour");
}
I start to understand the purpose of each piece of code. But I'm having doubts about the 4 first lines in the main, thoses that start with "dds::" and I think they are wrong - I'm getting "Identifier expected". If you could help it would be gratefull.
Upvotes: 0
Views: 2418
Reputation: 12415
In my opinion it's not valid DDS code. It seems that you're missing the IDL definition (that should explain the #pragma
) and the code.
You must at first create topics in a .idl file, then build id in order to create classes that you use in your program, and then use program libraries, and everything is missing.
Start to download a DDS implementation, like OpenDDS or Fast-RTPS. In addition to this you can check the OpenDDS section in this site from a working OpenDDS example from scratch.
Upvotes: 1