当前位置: 首页>>代码示例>>C#>>正文


C# DDS.get_complex_member方法代码示例

本文整理汇总了C#中DDS.get_complex_member方法的典型用法代码示例。如果您正苦于以下问题:C# DDS.get_complex_member方法的具体用法?C# DDS.get_complex_member怎么用?C# DDS.get_complex_member使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DDS的用法示例。


在下文中一共展示了DDS.get_complex_member方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: read_data

    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;
    }
开发者ID:hakiri,项目名称:rticonnextdds-examples,代码行数:77,代码来源:dynamic_data_sequences.cs


注:本文中的DDS.get_complex_member方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。