static void Main(string[] args) { _dpf = DomainParticipantFactory.Instance; ErrorHandler.checkHandle(_dpf, "Domain Participant Factory"); _dp = _dpf.CreateParticipant(Domain); //Initialize QOS pQos = new PublisherQos(); dwQos = new DataWriterQos(); fdmDataType = new FDMTypeSupport(); string FDMDATATypeName = fdmDataType.TypeName; ReturnCode status = fdmDataType.RegisterType(_dp, FDMDATATypeName); ErrorHandler.checkStatus(status, "FDMDATA: Cannot Register Type"); //Create FDMDATA Topic fdmDataTopic = _dp.FindTopic("FDMDATA", Duration.FromMilliseconds(1000)); if (fdmDataTopic == null) { fdmDataTopic = _dp.CreateTopic("FDMDATA", FDMDATATypeName); } ErrorHandler.checkHandle(fdmDataTopic, "Cannot Create Topic FDMDATA"); //Get Publisher QOS and Set Partition Name _dp.GetDefaultPublisherQos(ref pQos); pQos.Partition.Name = new String[1]; pQos.Partition.Name[0] = PartitionName; //Create Subscriber for FDMDATA Topic Publisher = _dp.CreatePublisher(pQos); ErrorHandler.checkHandle(Publisher, "Cannot Create FDMDATA Publisher"); //Get Data Writer QOS and Set History Depth Publisher.GetDefaultDataWriterQos(ref dwQos); ErrorHandler.checkHandle(dwQos, "Cannot get Data Writer Qos"); dwQos.History.Depth = 5; dwQos.Reliability.Kind = ReliabilityQosPolicyKind.BestEffortReliabilityQos; //Create DataReader for FDMDATA Topic parentWriter = Publisher.CreateDataWriter(fdmDataTopic, dwQos); ErrorHandler.checkHandle(parentWriter, "Cannot Create FDMDATA Data Writer"); //Narrow abstract parentWriter into its typed representative fdmDataWriter = parentWriter as FDMDataWriter; ErrorHandler.checkHandle(fdmDataWriter, "Cannot Narrow FDMDATA Data Writer"); fdmData = new FDM(); while (true) { StartPublish(); Console.WriteLine("Publishing data! "); Thread.Sleep(10); } }
static void Main(string[] args) { _dpf = DomainParticipantFactory.Instance; ErrorHandler.checkHandle(_dpf, "Domain Participant Factory"); _dp = _dpf.CreateParticipant(Domain); //Initialize QOS sQos = new SubscriberQos(); drQos = new DataReaderQos(); fdmDataType = new FDMTypeSupport(); string FDMDATATypeName = fdmDataType.TypeName; ReturnCode status = fdmDataType.RegisterType(_dp, FDMDATATypeName); ErrorHandler.checkStatus(status, "FDMDATA: Cannot Register Type"); //Create FDMDATA Topic fdmDataTopic = _dp.FindTopic("FDMDATA", Duration.FromMilliseconds(1000)); if (fdmDataTopic == null) { fdmDataTopic = _dp.CreateTopic("FDMDATA", FDMDATATypeName); } ErrorHandler.checkHandle(fdmDataTopic, "Cannot Create Topic FDMDATA"); //Get Subscriber QOS and Set Partition Name _dp.GetDefaultSubscriberQos(ref sQos); sQos.Partition.Name = new String[1]; sQos.Partition.Name[0] = PartitionName; //Create Subscriber for FDMDATA Topic Subscriber = _dp.CreateSubscriber(sQos); ErrorHandler.checkHandle(Subscriber, "Cannot Create FDMDATA Subscriber"); //Get Data Reader QOS and Set History Depth Subscriber.GetDefaultDataReaderQos(ref drQos); ErrorHandler.checkHandle(drQos, "Cannot get Data Reader Qos"); drQos.History.Depth = 5; drQos.Reliability.Kind = ReliabilityQosPolicyKind.BestEffortReliabilityQos; //Create DataReader for FDMDATA Topic parentReader = Subscriber.CreateDataReader(fdmDataTopic, drQos); ErrorHandler.checkHandle(parentReader, "Cannot Create FDMDATA Data Reader"); //Narrow abstract parentReader into its typed representative fdmDataReader = parentReader as FDMDataReader; ErrorHandler.checkHandle(fdmDataReader, "Cannot Narrow FDMDATA Data Reader"); // drQos.Durability.Kind = DurabilityQosPolicyKind.TransientLocalDurabilityQos; fdmData = new FDM(); //Rececieve Loop while (true) { StartReceive(); Console.WriteLine("abc: " + fdmData.aa.ToString()); } }