Hello,
I create a topic like this:
struct FlightInfo {
double lon;
//@ID 0
double lat;
//@ID 1
double alt;
//@ID 2
double heading;
//@ID 3
double pitch;
//@ID 4
double roll;
//@ID 5
double ail_l;
//@ID 6
double ail_r;
//@ID 7
double flap_l;
//@ID 8
double flap_r;
//@ID 9
double slat_l;
//@ID 10
double slat_r;
//@ID 11
double rud_up;
//@ID 12
double rud_down;
//@ID 13
double ele_l;
//@ID 14
double ele_r;
//@ID 15
double gear_n;
//@ID 16
double gear_ml;
//@ID 17
double gear_mr;
//@ID 18
double fuel_mass_l;
//@ID 19
double fuel_mass_r;
//@ID 20
};
I need to send this structure at 100Hz,and I also has other large data needs to be send at high frequency。so I want to figure out that could I send changed fields instead of the whole structure if only fuel_mass_l and fuel_mass_r changed?
if it is possiable, what should i do and which function should i use?
i use the following codes to create IDL:
struct DDS_TypeCodeFactory *factory = DDS_TypeCodeFactory_get_instance();
DDS_TypeCode_add_member(Tc, "lon", 1, DDS_TypeCodeFactory_get_primitive_tc(factory, DDS_TK_DOUBLE), DDS_TYPECODE_NONKEY_REQUIRED_MEMBER, &ex);
DDS_TypeCode_add_member(Tc, "lat", 2, DDS_TypeCodeFactory_get_primitive_tc(factory, DDS_TK_DOUBLE), DDS_TYPECODE_NONKEY_REQUIRED_MEMBER, &ex);
DDS_TypeCode_add_member(Tc, "alt", 3, DDS_TypeCodeFactory_get_primitive_tc(factory, DDS_TK_DOUBLE), DDS_TYPECODE_NONKEY_REQUIRED_MEMBER, &ex);
DDS_TypeCode_add_member(Tc, "heading", 4, DDS_TypeCodeFactory_get_primitive_tc(factory, DDS_TK_DOUBLE), DDS_TYPECODE_NONKEY_REQUIRED_MEMBER, &ex);
DDS_TypeCode_add_member(Tc, "pitch", 5, DDS_TypeCodeFactory_get_primitive_tc(factory, DDS_TK_DOUBLE), DDS_TYPECODE_NONKEY_REQUIRED_MEMBER, &ex);
DDS_TypeCode_add_member(Tc, "roll", 6, DDS_TypeCodeFactory_get_primitive_tc(factory, DDS_TK_DOUBLE), DDS_TYPECODE_NONKEY_REQUIRED_MEMBER, &ex);
DDS_TypeCode_add_member(Tc, "ail_l", 7, DDS_TypeCodeFactory_get_primitive_tc(factory, DDS_TK_DOUBLE), DDS_TYPECODE_NONKEY_REQUIRED_MEMBER, &ex);
DDS_TypeCode_add_member(Tc, "ail_r", 8, DDS_TypeCodeFactory_get_primitive_tc(factory, DDS_TK_DOUBLE), DDS_TYPECODE_NONKEY_REQUIRED_MEMBER, &ex);
DDS_TypeCode_add_member(Tc, "flap_l", 9, DDS_TypeCodeFactory_get_primitive_tc(factory, DDS_TK_DOUBLE), DDS_TYPECODE_NONKEY_REQUIRED_MEMBER, &ex);
DDS_TypeCode_add_member(Tc, "flap_r", 10, DDS_TypeCodeFactory_get_primitive_tc(factory, DDS_TK_DOUBLE), DDS_TYPECODE_NONKEY_REQUIRED_MEMBER, &ex);
DDS_TypeCode_add_member(Tc, "slat_l", 11, DDS_TypeCodeFactory_get_primitive_tc(factory, DDS_TK_DOUBLE), DDS_TYPECODE_NONKEY_REQUIRED_MEMBER, &ex);
DDS_TypeCode_add_member(Tc, "slat_r", 12, DDS_TypeCodeFactory_get_primitive_tc(factory, DDS_TK_DOUBLE), DDS_TYPECODE_NONKEY_REQUIRED_MEMBER, &ex);
DDS_TypeCode_add_member(Tc, "rud_up", 13, DDS_TypeCodeFactory_get_primitive_tc(factory, DDS_TK_DOUBLE), DDS_TYPECODE_NONKEY_REQUIRED_MEMBER, &ex);
DDS_TypeCode_add_member(Tc, "rud_down", 14, DDS_TypeCodeFactory_get_primitive_tc(factory, DDS_TK_DOUBLE), DDS_TYPECODE_NONKEY_REQUIRED_MEMBER, &ex);
DDS_TypeCode_add_member(Tc, "ele_l", 15, DDS_TypeCodeFactory_get_primitive_tc(factory, DDS_TK_DOUBLE), DDS_TYPECODE_NONKEY_REQUIRED_MEMBER, &ex);
DDS_TypeCode_add_member(Tc, "ele_r", 16, DDS_TypeCodeFactory_get_primitive_tc(factory, DDS_TK_DOUBLE), DDS_TYPECODE_NONKEY_REQUIRED_MEMBER, &ex);
DDS_TypeCode_add_member(Tc, "gear_n", 17, DDS_TypeCodeFactory_get_primitive_tc(factory, DDS_TK_DOUBLE), DDS_TYPECODE_NONKEY_REQUIRED_MEMBER, &ex);
DDS_TypeCode_add_member(Tc, "gear_ml", 18, DDS_TypeCodeFactory_get_primitive_tc(factory, DDS_TK_DOUBLE), DDS_TYPECODE_NONKEY_REQUIRED_MEMBER, &ex);
DDS_TypeCode_add_member(Tc, "gear_mr", 19, DDS_TypeCodeFactory_get_primitive_tc(factory, DDS_TK_DOUBLE), DDS_TYPECODE_NONKEY_REQUIRED_MEMBER, &ex);
DDS_TypeCode_add_member(Tc, "fuel_mass_l", 20, DDS_TypeCodeFactory_get_primitive_tc(factory, DDS_TK_DOUBLE), DDS_TYPECODE_NONKEY_REQUIRED_MEMBER, &ex);
DDS_TypeCode_add_member(Tc, "fuel_mass_r", 21, DDS_TypeCodeFactory_get_primitive_tc(factory, DDS_TK_DOUBLE), DDS_TYPECODE_NONKEY_REQUIRED_MEMBER, &ex);
i use the following codes to set data:
DDS_DynamicData_set_double(fligthinfo, NULL, 1, lon);
DDS_DynamicData_set_double(fligthinfo, NULL, 2, lat);
DDS_DynamicData_set_double(fligthinfo, NULL, 3, alt);
DDS_DynamicData_set_double(fligthinfo, NULL, 4, heading);
DDS_DynamicData_set_double(fligthinfo, NULL, 5, pitch);
DDS_DynamicData_set_double(fligthinfo, NULL, 6, roll);
DDS_DynamicData_set_double(fligthinfo, NULL, 7, ail_l);
DDS_DynamicData_set_double(fligthinfo, NULL, 8, ail_r);
DDS_DynamicData_set_double(fligthinfo, NULL, 9, flap_l);
DDS_DynamicData_set_double(fligthinfo, NULL, 10, flap_r);
DDS_DynamicData_set_double(fligthinfo, NULL, 11, slat_l);
DDS_DynamicData_set_double(fligthinfo, NULL, 12, slat_r);
DDS_DynamicData_set_double(fligthinfo, NULL, 13, rud_up);
DDS_DynamicData_set_double(fligthinfo, NULL, 14, rud_down);
DDS_DynamicData_set_double(fligthinfo, NULL, 15, ele_l);
DDS_DynamicData_set_double(fligthinfo, NULL, 16, ele_r);
DDS_DynamicData_set_double(fligthinfo, NULL, 17, gear_n);
DDS_DynamicData_set_double(fligthinfo, NULL, 18, gear_ml);
DDS_DynamicData_set_double(fligthinfo, NULL, 19, gear_mr);
DDS_DynamicData_set_double(fligthinfo, NULL, 20, fuel_mass_l);
DDS_DynamicData_set_double(fligthinfo, NULL, 21, fuel_mass_r);
thanks for any reply
If only one field is sent at a time, use a union instead of a struct. If you can send multiple fields at a time, consider using optional members.
Is there any example of "optional members" ?
see https://community.rti.com/static/documentation/connext-dds/7.1.0/doc/manuals/connext_dds_professional/extensible_types_guide/extensible_types/Optional_Members.htm#3.2_Optional_Members