コード例 #1
0
        private Boolean PP_string_handler(int nof_cycles)
        {
            DDS.SampleInfo[] infoList = null;
            int     amount;
            Boolean result = false;

            DDS.ReturnCode dds_result;

            /* System.out.println "PING: PING_string arrived"); */

            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            dds_result = PP_string_reader.Take(ref PP_string_dataList, ref infoList,
                                               DDS.Length.Unlimited, DDS.SampleStateKind.Any,
                                               DDS.ViewStateKind.Any, DDS.InstanceStateKind.Any);
            //assert (dds_result == RETCODE_OK.value);
            stopWatch.Stop();
            takeTicks = stopWatch.ElapsedTicks;

            amount = PP_string_dataList.Length;
            if (amount != 0)
            {
                if (amount > 1)
                {
                    System.Console.WriteLine("PING: Ignore excess messages : " + amount
                                             + " msg received");
                }
                PP_string_dataList[0].count++;
                if (PP_string_dataList[0].count < nof_cycles)
                {
                    stopWatch  = Stopwatch.StartNew();
                    dds_result = PP_string_writer.Write(
                        PP_string_dataList[0], DDS.InstanceHandle.Nil);
                    //assert (dds_result == RETCODE_OK.value);
                    stopWatch.Stop();
                    writeTicks = stopWatch.ElapsedTicks;
                    write_access.add_stats(writeTicks);
                }
                else
                {
                    result = true;
                }
                read_access.add_stats(takeTicks);
                roundtrip.add_stats(roundTripTicks + takeTicks);
                roundTripTicks = writeTicks;
                dds_result     = PP_string_reader.ReturnLoan(ref PP_string_dataList,
                                                             ref infoList);
                //assert (dds_result == RETCODE_OK.value);
            }
            else
            {
                System.Console.WriteLine("PING: PING_string triggered, but no data available");
            }
            return(result);
        }
コード例 #2
0
ファイル: pinger.cs プロジェクト: satej1210/CasinoRoyale
        private Boolean PP_string_handler(int nof_cycles)
        {
            DDS.SampleInfo[] infoList = null;
            int     amount;
            Boolean result = false;

            DDS.ReturnCode dds_result;

            /* System.out.println "PING: PING_string arrived"); */

            preTakeTime.timeGet();
            dds_result = PP_string_reader.Take(ref PP_string_dataList, ref infoList,
                                               DDS.Length.Unlimited, DDS.SampleStateKind.Any,
                                               DDS.ViewStateKind.Any, DDS.InstanceStateKind.Any);
            //assert (dds_result == RETCODE_OK.value);
            postTakeTime.timeGet();

            amount = PP_string_dataList.Length;
            if (amount != 0)
            {
                if (amount > 1)
                {
                    System.Console.WriteLine("PING: Ignore excess messages : " + amount
                                             + " msg received");
                }
                PP_string_dataList[0].count++;
                if (PP_string_dataList[0].count < nof_cycles)
                {
                    preWriteTime.timeGet();
                    dds_result = PP_string_writer.Write(
                        PP_string_dataList[0], DDS.InstanceHandle.Nil);
                    //assert (dds_result == RETCODE_OK.value);
                    postWriteTime.timeGet();
                    write_access.add_stats(postWriteTime.sub(preWriteTime));
                }
                else
                {
                    result = true;
                }
                read_access.add_stats(postTakeTime.sub(preTakeTime));
                roundtrip.add_stats(postTakeTime.sub(roundTripTime));
                roundTripTime.set(preWriteTime.get());
                dds_result = PP_string_reader.ReturnLoan(ref PP_string_dataList,
                                                         ref infoList);
                //assert (dds_result == RETCODE_OK.value);
            }
            else
            {
                System.Console.WriteLine("PING: PING_string triggered, but no data available");
            }
            return(result);
        }