Exemplo n.º 1
0
 public ITopic FindTopic(string topic_name, Duration timeout)
 {
     return realParticipant.FindTopic(topic_name, timeout);
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("Insufficient number of arguments.");
                usage();
            }
            else
            {
                DDSEntityManager mgr           = new DDSEntityManager("Durability");
                String           partitionName = "Durability Example";
                DDS.Duration     timeout       = new DDS.Duration(40, 0);
                ReturnCode       status;

                String durabilityKind = args[0];

                // create Domain Participant
                mgr.createParticipant(partitionName);

                // set the durability kind
                mgr.setDurabilityKind(durabilityKind);

                // create Type
                MsgTypeSupport msgTS = new MsgTypeSupport();
                mgr.registerType(msgTS);

                // create Topic
                if (args[0].Equals("persistent"))
                {
                    mgr.createTopic("PersistentCSDurabilityData_Msg");
                }
                else
                {
                    mgr.createTopic("CSDurabilityData_Msg");
                }

                // create Subscriber
                mgr.createSubscriber();
                mgr.createReader(false);

                IDataReader   dreader = mgr.getReader();
                MsgDataReader DurabilityDataReader = dreader as MsgDataReader;

                status = DurabilityDataReader.WaitForHistoricalData(timeout);
                ErrorHandler.checkStatus(status, "DurabilityDataReader.WaitForHistoricalData");

                Msg[]            msgSeq    = null;
                DDS.SampleInfo[] infoSeq   = null;
                Boolean          terminate = false;
                Console.WriteLine("=== [Subscriber] Ready ...");
                while (!terminate)
                {
                    status = DurabilityDataReader.Take(ref msgSeq, ref infoSeq, Length.Unlimited, SampleStateKind.Any, ViewStateKind.Any, InstanceStateKind.Any);
                    ErrorHandler.checkStatus(status, "DataReader.Take");
                    for (int i = 0; i < msgSeq.Length; i++)
                    {
                        if (infoSeq[i].ValidData)
                        {
                            Console.WriteLine(msgSeq[i].content);
                            if (msgSeq[i].content.Equals("9"))
                            {
                                terminate = true;
                                break;
                            }
                        }
                    }
                    status = DurabilityDataReader.ReturnLoan(ref msgSeq, ref infoSeq);
                    ErrorHandler.checkStatus(status, "MsgDataReader.ReturnLoan");
                }

                // For single process mode wait some time to ensure persistent data is stored to disk
                Thread.Sleep(2000);

                // clean up
                mgr.getSubscriber().DeleteDataReader(DurabilityDataReader);
                mgr.deleteSubscriber();
                mgr.deleteTopic();
                mgr.deleteParticipant();
            }
        }