private static void read_data(DDS.DynamicData sample, DDS.TypeCodeFactory tcf) { /* Creating typecodes */ DDS.TypeCode sequence_tc = sequence_get_typecode(tcf); if (sequence_tc == null) { Console.WriteLine("Error to create sequence_get_typecode in " + "reading_data"); return; } /* Creating DynamicData */ DDS.DynamicData seq_member = new DDS.DynamicData(sequence_tc, DDS.DynamicData.DYNAMIC_DATA_PROPERTY_DEFAULT); DDS.DynamicData seq_element = new DDS.DynamicData(null, DDS.DynamicData.DYNAMIC_DATA_PROPERTY_DEFAULT); DDS.DynamicDataInfo info = new DDS.DynamicDataInfo(); sample.get_complex_member(seq_member, sequence_member_name, DDS.DynamicData.MEMBER_ID_UNSPECIFIED); /* Now we get the total amount of elements contained in the array * by accessing the dynamic data info */ Console.WriteLine("* Getting sequence member info...."); seq_member.get_info(info); Console.WriteLine("* Sequence contains {0} elements", info.member_count); for (int i = 0; i < info.member_count; ++i) { /* * The same results can be obtained using * bind_complex_member method. The main difference, is that * in that case the members are not copied, just referenced */ #if (USE_BIND_API) try { seq_member.bind_complex_member(seq_element, null, i + 1); } catch (DDS.Exception e) { Console.WriteLine("register_type error {0}", e); return; } #else try { seq_member.get_complex_member(seq_element, null, i + 1); } catch (DDS.Exception e) { Console.WriteLine("register_type error {0}", e); return; } #endif long value = seq_element.get_long("a_member", DDS.DynamicData.MEMBER_ID_UNSPECIFIED); Console.WriteLine("Reading sequence element #{0} : ", i + 1); seq_element.print(1); #if (USE_BIND_API) try { seq_member.unbind_complex_member(seq_element); } catch (DDS.Exception e) { Console.WriteLine("register_type error {0}", e); return; } #endif } /* Delete the created TC */ if (sequence_tc != null) { tcf.delete_tc(sequence_tc); } return; }
private static void read_data(DDS.DynamicData sample, DDS.TypeCodeFactory tcf ) { /* Creating typecodes */ DDS.TypeCode sequence_tc = sequence_get_typecode(tcf); if (sequence_tc == null) { Console.WriteLine("Error to create sequence_get_typecode in " + "reading_data"); return; } /* Creating DynamicData */ DDS.DynamicData seq_member = new DDS.DynamicData(sequence_tc, DDS.DynamicData.DYNAMIC_DATA_PROPERTY_DEFAULT); DDS.DynamicData seq_element = new DDS.DynamicData(null, DDS.DynamicData.DYNAMIC_DATA_PROPERTY_DEFAULT); DDS.DynamicDataInfo info = new DDS.DynamicDataInfo(); sample.get_complex_member(seq_member, sequence_member_name, DDS.DynamicData.MEMBER_ID_UNSPECIFIED); /* Now we get the total amount of elements contained in the array * by accessing the dynamic data info */ Console.WriteLine("* Getting sequence member info...."); seq_member.get_info(info); Console.WriteLine("* Sequence contains {0} elements", info.member_count); for (int i = 0; i < info.member_count; ++i) { /* * The same results can be obtained using * bind_complex_member method. The main difference, is that * in that case the members are not copied, just referenced */ #if (USE_BIND_API) try { seq_member.bind_complex_member(seq_element, null, i + 1); } catch (DDS.Exception e) { Console.WriteLine("register_type error {0}", e); return; } #else try { seq_member.get_complex_member(seq_element, null, i + 1); } catch (DDS.Exception e) { Console.WriteLine("register_type error {0}", e); return; } #endif long value = seq_element.get_long("a_member", DDS.DynamicData.MEMBER_ID_UNSPECIFIED); Console.WriteLine("Reading sequence element #{0} : ", i + 1); seq_element.print(1); #if (USE_BIND_API) try { seq_member.unbind_complex_member(seq_element); } catch (DDS.Exception e) { Console.WriteLine("register_type error {0}", e); return; } #endif } /* Delete the created TC */ if (sequence_tc != null) { tcf.delete_tc(sequence_tc); } return; }