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


C# DDS.set_complex_member方法代码示例

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


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

示例1: write_data

    private static void write_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 " +
                "writing_data");
            return;
        }

        DDS.TypeCode sequence_element_tc = sequence_element_get_typecode(tcf);
        if (sequence_element_tc == null) {
            Console.WriteLine("Error to create sequence_element_get_typecode " +
                "in writing_data");
            return;
        }

        try {
            /* Creating DynamicData */
            DDS.DynamicData seq_member = new DDS.DynamicData(sequence_tc,
                DDS.DynamicData.DYNAMIC_DATA_PROPERTY_DEFAULT);
            DDS.DynamicData seq_element =
                new DDS.DynamicData(sequence_element_tc,
                DDS.DynamicData.DYNAMIC_DATA_PROPERTY_DEFAULT);

            for (int i = 0; i < MAX_SEQ_LEN; ++i) {
                /* To access the elements of a sequence it is necessary
                 * to use their id. This parameter allows accessing to every
                 * element of the sequence using a 1-based index.
                 * There are two ways of doing this: bind API and get API.
                 * See the NestedStructExample for further details about the
                 * differences between these two APIs. */

        #if (USE_BIND_API)
                seq_member.bind_complex_member(seq_element, null, i + 1);
                seq_element.set_int("a_member",
                    DDS.DynamicData.MEMBER_ID_UNSPECIFIED, i);
                Console.WriteLine("Writing sequence elemente #{0} : ", i + 1);
                seq_element.print(1);
                seq_member.unbind_complex_member(seq_element);
        #else
                seq_element.set_int("a_member",
                    DDS.DynamicData.MEMBER_ID_UNSPECIFIED, i);
                Console.WriteLine("Writing sequence element #{0}", i + 1);
                seq_element.print(1);
                seq_member.set_complex_member(null, i + 1, seq_element);
        #endif
            }

            sample.set_complex_member(sequence_member_name,
                DDS.DynamicData.MEMBER_ID_UNSPECIFIED, seq_member);

            /* Delete the created TC */
            if (sequence_element_tc != null) {
                tcf.delete_tc(sequence_element_tc);
            }

            if (sequence_tc != null) {
                tcf.delete_tc(sequence_tc);
            }

            return;
        } catch (DDS.Exception e) {
            Console.WriteLine("register_type error {0}", e);
            return;
        }
    }
开发者ID:hakiri,项目名称:rticonnextdds-examples,代码行数:68,代码来源:dynamic_data_sequences.cs


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