public override Test.Framework.TestResult Run() { DDS.GuardCondition condition; DDS.WaitSet waitset; Test.Framework.TestResult result; Condition1.GuardConditionWaitset threadedWaitset; DDS.ReturnCode rc; string expResult = "StatusCondition test succeeded."; result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict .Pass, Test.Framework.TestVerdict.Fail); condition = new DDS.GuardCondition(); waitset = new DDS.WaitSet(); waitset.AttachCondition(condition); DDS.ICondition[] activeConditions = new DDS.ICondition[0]; rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed."; return(result); } if (activeConditions.Length > 0) { result.Result = "WaitSet.Wait returned condition where it shouldn't."; return(result); } threadedWaitset = new test.sacs.Condition1.GuardConditionWaitset(this, waitset); threadedWaitset.Start(); condition.SetTriggerValue(true); try { threadedWaitset.Join(); } catch (System.Exception e) { System.Console.WriteLine(e); } if (!threadedWaitset.Succeeded()) { result.Result = "GuardCondition trigger does not work properly."; return(result); } result.Result = expResult; result.Verdict = Test.Framework.TestVerdict.Pass; return(result); }
public override Test.Framework.TestResult Run() { DDS.GuardCondition condition; DDS.WaitSet waitset; Test.Framework.TestResult result; Condition1.GuardConditionWaitset threadedWaitset; DDS.ReturnCode rc; string expResult = "StatusCondition test succeeded."; result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict .Pass, Test.Framework.TestVerdict.Fail); condition = new DDS.GuardCondition(); waitset = new DDS.WaitSet(); waitset.AttachCondition(condition); DDS.ICondition[] activeConditions = new DDS.ICondition[0]; rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed."; return result; } if (activeConditions.Length > 0) { result.Result = "WaitSet.Wait returned condition where it shouldn't."; return result; } threadedWaitset = new test.sacs.Condition1.GuardConditionWaitset(this, waitset); threadedWaitset.Start(); condition.SetTriggerValue(true); try { threadedWaitset.Join(); } catch (System.Exception e) { System.Console.WriteLine(e); } if (!threadedWaitset.Succeeded()) { result.Result = "GuardCondition trigger does not work properly."; return result; } result.Result = expResult; result.Verdict = Test.Framework.TestVerdict.Pass; return result; }
public override Test.Framework.TestResult Run() { DDS.ITopic topic; DDS.IStatusCondition condition; DDS.WaitSet waitset; DDS.ICondition[] conditionHolder; Test.Framework.TestResult result; DDS.ReturnCode rc; string expResult = "StatusCondition test succeeded."; result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict .Pass, Test.Framework.TestVerdict.Fail); topic = (DDS.ITopic) this.ResolveObject("topic"); condition = topic.StatusCondition; if (condition == null) { result.Result = "Could not resolve participant condition."; return(result); } waitset = new DDS.WaitSet(); rc = waitset.AttachCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "Could not attach condition."; return(result); } conditionHolder = new DDS.ICondition[0]; rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed."; return(result); } if (conditionHolder.Length > 0) { result.Result = "WaitSet.Wait returned conditions where it shouldn't."; return(result); } result.Result = expResult; result.Verdict = Test.Framework.TestVerdict.Pass; return(result); }
public override Test.Framework.TestResult Run() { DDS.ITopic topic; DDS.IStatusCondition condition; DDS.WaitSet waitset; DDS.ICondition[] conditionHolder; Test.Framework.TestResult result; DDS.ReturnCode rc; string expResult = "StatusCondition test succeeded."; result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict .Pass, Test.Framework.TestVerdict.Fail); topic = (DDS.ITopic)this.ResolveObject("topic"); condition = topic.StatusCondition; if (condition == null) { result.Result = "Could not resolve participant condition."; return result; } waitset = new DDS.WaitSet(); rc = waitset.AttachCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "Could not attach condition."; return result; } conditionHolder = new DDS.ICondition[0]; rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed."; return result; } if (conditionHolder.Length > 0) { result.Result = "WaitSet.Wait returned conditions where it shouldn't."; return result; } result.Result = expResult; result.Verdict = Test.Framework.TestVerdict.Pass; return result; }
public void run(String[] args) { int myDomain = DDS.DomainId.Default; DDS.DomainParticipantFactory dpf; DDS.IDomainParticipant dp; DDS.IPublisher p; DDS.ISubscriber s; pingpong.PP_min_msgDataWriter PP_min_writer; pingpong.PP_seq_msgDataWriter PP_seq_writer; pingpong.PP_string_msgDataWriter PP_string_writer; pingpong.PP_fixed_msgDataWriter PP_fixed_writer; pingpong.PP_array_msgDataWriter PP_array_writer; pingpong.PP_min_msgDataReader PP_min_reader; pingpong.PP_seq_msgDataReader PP_seq_reader; pingpong.PP_string_msgDataReader PP_string_reader; pingpong.PP_fixed_msgDataReader PP_fixed_reader; pingpong.PP_array_msgDataReader PP_array_reader; pingpong.PP_quit_msgDataReader PP_quit_reader; pingpong.PP_min_msgTypeSupport PP_min_dt; pingpong.PP_seq_msgTypeSupport PP_seq_dt; pingpong.PP_string_msgTypeSupport PP_string_dt; pingpong.PP_fixed_msgTypeSupport PP_fixed_dt; pingpong.PP_array_msgTypeSupport PP_array_dt; pingpong.PP_quit_msgTypeSupport PP_quit_dt; pingpong.PP_min_msg[] PP_min_dataList = null; pingpong.PP_seq_msg[] PP_seq_dataList = null; pingpong.PP_string_msg[] PP_string_dataList = null; pingpong.PP_fixed_msg[] PP_fixed_dataList = null; pingpong.PP_array_msg[] PP_array_dataList = null; pingpong.PP_quit_msg[] PP_quit_dataList = null; DDS.IStatusCondition PP_min_sc; DDS.IStatusCondition PP_seq_sc; DDS.IStatusCondition PP_string_sc; DDS.IStatusCondition PP_fixed_sc; DDS.IStatusCondition PP_array_sc; DDS.IStatusCondition PP_quit_sc; DDS.ITopic PP_min_topic; DDS.ITopic PP_seq_topic; DDS.ITopic PP_string_topic; DDS.ITopic PP_fixed_topic; DDS.ITopic PP_array_topic; DDS.ITopic PP_quit_topic; DDS.ICondition[] conditionList = null; DDS.SampleInfo[] infoList = null; DDS.IWaitSet w; DDS.DomainParticipantQos dpQos; DDS.TopicQos tQos; DDS.PublisherQos pQos; DDS.DataWriterQos dwQos; DDS.SubscriberQos sQos; DDS.DataReaderQos drQos; Boolean terminate = false; DDS.ReturnCode result; int i; int imax; int j; int jmax; /* * Evaluate cmdline arguments */ if (args.Length != 0) { if (args.Length != 2) { System.Console.WriteLine("Invalid....."); System.Console.WriteLine("Usage: pong [READ_PARTITION WRITE_PARTITION]"); Environment.Exit(1); } read_partition = args[0]; write_partition = args[1]; } /* * Create WaitSet */ w = new DDS.WaitSet(); /* * Initialize Qos variables */ dpQos = new DDS.DomainParticipantQos(); tQos = new DDS.TopicQos(); pQos = new DDS.PublisherQos(); dwQos = new DDS.DataWriterQos(); sQos = new DDS.SubscriberQos(); drQos = new DDS.DataReaderQos(); /* * Create participant */ dpf = DDS.DomainParticipantFactory.Instance; dpf.GetDefaultParticipantQos(ref dpQos); dp = dpf.CreateParticipant(myDomain, dpQos, null, DDS.StatusKind.Any); if (dp == null) { System.Console.WriteLine("PING: ERROR - Splice Daemon not running"); return; } /* * Create PONG publisher */ dp.GetDefaultPublisherQos(ref pQos); pQos.Partition.Name = new String[1]; pQos.Partition.Name[0] = write_partition; p = dp.CreatePublisher(pQos); /* * Create PING subscriber */ dp.GetDefaultSubscriberQos(ref sQos); sQos.Partition.Name = new String[1]; sQos.Partition.Name[0] = read_partition; s = dp.CreateSubscriber(sQos); /* * Get default DataReader and DataWriter QoS settings */ p.GetDefaultDataWriterQos(ref dwQos); s.GetDefaultDataReaderQos(ref drQos); /* * Get default Topic Qos settings */ dp.GetDefaultTopicQos(ref tQos); /* match data reader/writer qos with topic qos */ p.CopyFromTopicQos(ref dwQos, tQos); s.CopyFromTopicQos(ref drQos, tQos); /* * PP_min_msg */ /* Create Topic */ PP_min_dt = new pingpong.PP_min_msgTypeSupport(); PP_min_dt.RegisterType(dp, "pingpong::PP_min_msg"); PP_min_topic = dp.CreateTopic("PP_min_topic", "pingpong::PP_min_msg", tQos); /* Create datawriter */ PP_min_writer = p.CreateDataWriter(PP_min_topic, dwQos) as pingpong.PP_min_msgDataWriter; /* Create datareader */ PP_min_reader = s.CreateDataReader(PP_min_topic, drQos) as pingpong.PP_min_msgDataReader; /* Add datareader statuscondition to waitset */ PP_min_sc = PP_min_reader.StatusCondition; PP_min_sc.SetEnabledStatuses(DDS.StatusKind.DataAvailable); result = w.AttachCondition(PP_min_sc); // assert(result == RETCODE_OK.value); /* * PP_seq_msg */ /* Create Topic */ PP_seq_dt = new pingpong.PP_seq_msgTypeSupport(); PP_seq_dt.RegisterType(dp, "pingpong::PP_seq_msg"); PP_seq_topic = dp.CreateTopic("PP_seq_topic", "pingpong::PP_seq_msg", tQos); /* Create datawriter */ PP_seq_writer = p.CreateDataWriter(PP_seq_topic, dwQos) as pingpong.PP_seq_msgDataWriter; /* Create datareader */ PP_seq_reader = s.CreateDataReader(PP_seq_topic, drQos) as pingpong.PP_seq_msgDataReader; /* Add datareader statuscondition to waitset */ PP_seq_sc = PP_seq_reader.StatusCondition; PP_seq_sc.SetEnabledStatuses(DDS.StatusKind.DataAvailable); result = w.AttachCondition(PP_seq_sc); //assert(result == RETCODE_OK.value); /* * PP_string_msg */ /* Create Topic */ PP_string_dt = new pingpong.PP_string_msgTypeSupport(); PP_string_dt.RegisterType(dp, "pingpong::PP_string_msg"); PP_string_topic = dp.CreateTopic("PP_string_topic", "pingpong::PP_string_msg", tQos); /* Create datawriter */ PP_string_writer = p.CreateDataWriter(PP_string_topic, dwQos) as pingpong.PP_string_msgDataWriter; /* Create datareader */ PP_string_reader = s.CreateDataReader(PP_string_topic, drQos) as pingpong.PP_string_msgDataReader; /* Add datareader statuscondition to waitset */ PP_string_sc = PP_string_reader.StatusCondition; PP_string_sc.SetEnabledStatuses(DDS.StatusKind.DataAvailable); result = w.AttachCondition(PP_string_sc); //assert(result == RETCODE_OK.value); /* * PP_fixed_msg */ /* Create Topic */ PP_fixed_dt = new pingpong.PP_fixed_msgTypeSupport(); PP_fixed_dt.RegisterType(dp, "pingpong::PP_fixed_msg"); PP_fixed_topic = dp.CreateTopic("PP_fixed_topic", "pingpong::PP_fixed_msg", tQos); /* Create datawriter */ PP_fixed_writer = p.CreateDataWriter(PP_fixed_topic, dwQos) as pingpong.PP_fixed_msgDataWriter; /* Create datareader */ PP_fixed_reader = s.CreateDataReader(PP_fixed_topic, drQos) as pingpong.PP_fixed_msgDataReader; /* Add datareader statuscondition to waitset */ PP_fixed_sc = PP_fixed_reader.StatusCondition; PP_fixed_sc.SetEnabledStatuses(DDS.StatusKind.DataAvailable); result = w.AttachCondition(PP_fixed_sc); //assert(result == RETCODE_OK.value); /* * PP_array_msg */ /* Create Topic */ PP_array_dt = new pingpong.PP_array_msgTypeSupport(); PP_array_dt.RegisterType(dp, "pingpong::PP_array_msg"); PP_array_topic = dp.CreateTopic("PP_array_topic", "pingpong::PP_array_msg", tQos); /* Create datawriter */ PP_array_writer = p.CreateDataWriter(PP_array_topic, dwQos) as pingpong.PP_array_msgDataWriter; /* Create datareader */ PP_array_reader = s.CreateDataReader(PP_array_topic, drQos) as pingpong.PP_array_msgDataReader; /* Add datareader statuscondition to waitset */ PP_array_sc = PP_array_reader.StatusCondition; PP_array_sc.SetEnabledStatuses(DDS.StatusKind.DataAvailable); result = w.AttachCondition(PP_array_sc); //assert(result == RETCODE_OK.value); /* * PP_quit_msg */ /* Create Topic */ PP_quit_dt = new pingpong.PP_quit_msgTypeSupport(); PP_quit_dt.RegisterType(dp, "pingpong::PP_quit_msg"); PP_quit_topic = dp.CreateTopic("PP_quit_topic", "pingpong::PP_quit_msg", tQos); /* Create datareader */ PP_quit_reader = s.CreateDataReader(PP_quit_topic, drQos) as pingpong.PP_quit_msgDataReader; /* Add datareader statuscondition to waitset */ PP_quit_sc = PP_quit_reader.StatusCondition; PP_quit_sc.SetEnabledStatuses(DDS.StatusKind.DataAvailable); result = w.AttachCondition(PP_quit_sc); //assert(result == RETCODE_OK.value); while (!terminate) { DDS.Duration wait_timeout = new DDS.Duration(DDS.Duration.InfiniteSec, DDS.Duration.InfiniteSec); result = w.Wait(ref conditionList, wait_timeout); ErrorHandler.checkStatus(result, "wait did not succeeed"); if (result == DDS.ReturnCode.AlreadyDeleted) { terminate = true; continue; } if (conditionList != null) { imax = conditionList.Length; for (i = 0; i < imax; i++) { if (conditionList[i] == PP_min_sc) { result = PP_min_reader.Take(ref PP_min_dataList, ref infoList, DDS.SampleStateKind.Any, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Any); jmax = PP_min_dataList.Length; if (jmax != 0) { for (j = 0; j < jmax; j++) { if (infoList[j].ValidData) { result = PP_min_writer.Write(PP_min_dataList[j], DDS.InstanceHandle.Nil); } } result = PP_min_reader.ReturnLoan(ref PP_min_dataList, ref infoList); } else { System.Console.WriteLine("PONG: PING_min triggered, but no data available"); } } else if (conditionList[i] == PP_seq_sc) { /* System.Console.WriteLine ("PONG: PING_seq arrived"); */ result = PP_seq_reader.Take(ref PP_seq_dataList, ref infoList, DDS.SampleStateKind.Any, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Any); jmax = PP_seq_dataList.Length; if (jmax != 0) { for (j = 0; j < jmax; j++) { if (infoList[j].ValidData) { result = PP_seq_writer.Write(PP_seq_dataList[j], DDS.InstanceHandle.Nil); } } result = PP_seq_reader.ReturnLoan(ref PP_seq_dataList, ref infoList); } else { System.Console.WriteLine("PONG: PING_seq triggered, but no data available"); } } else if (conditionList[i] == PP_string_sc) { /* System.Console.WriteLine ("PONG: PING_string arrived"); */ result = PP_string_reader.Take(ref PP_string_dataList, ref infoList, DDS.SampleStateKind.Any, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Any); jmax = PP_string_dataList.Length; if (jmax != 0) { for (j = 0; j < jmax; j++) { if (infoList[j].ValidData) { result = PP_string_writer.Write(PP_string_dataList[j], DDS.InstanceHandle.Nil); } } result = PP_string_reader.ReturnLoan(ref PP_string_dataList, ref infoList); } else { System.Console.WriteLine("PONG: PING_string triggered, but no data available"); } } else if (conditionList[i] == PP_fixed_sc) { /* System.Console.WriteLine ("PONG: PING_fixed arrived"); */ result = PP_fixed_reader.Take(ref PP_fixed_dataList, ref infoList, DDS.SampleStateKind.Any, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Any); jmax = PP_fixed_dataList.Length; if (jmax != 0) { for (j = 0; j < jmax; j++) { if (infoList[j].ValidData) { result = PP_fixed_writer.Write(PP_fixed_dataList[j], DDS.InstanceHandle.Nil); } } result = PP_fixed_reader.ReturnLoan(ref PP_fixed_dataList, ref infoList); } else { System.Console.WriteLine("PONG: PING_fixed triggered, but no data available"); } } else if (conditionList[i] == PP_array_sc) { /* System.Console.WriteLine ("PONG: PING_array arrived"); */ result = PP_array_reader.Take(ref PP_array_dataList, ref infoList, DDS.SampleStateKind.Any, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Any); jmax = PP_array_dataList.Length; if (jmax != 0) { for (j = 0; j < jmax; j++) { if (infoList[j].ValidData) { result = PP_array_writer.Write(PP_array_dataList[j], DDS.InstanceHandle.Nil); } } result = PP_array_reader.ReturnLoan(ref PP_array_dataList, ref infoList); } else { System.Console.WriteLine("PONG: PING_array triggered, but no data available"); } } else if (conditionList[i] == PP_quit_sc) { /* System.Console.WriteLine ("PONG: PING_quit arrived"); */ result = PP_quit_reader.Take(ref PP_quit_dataList, ref infoList, DDS.SampleStateKind.Any, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Any); jmax = PP_quit_dataList.Length; if (jmax != 0) { result = PP_quit_reader.ReturnLoan(ref PP_quit_dataList, ref infoList); } else { System.Console.WriteLine("PONG: PING_quit triggered, but no data available"); } terminate = true; } else { System.Console.WriteLine("PONG: unknown condition triggered: " + conditionList[i]); } } } else { System.Console.WriteLine("PONG: unknown condition triggered"); } } result = s.DeleteDataReader(PP_min_reader); result = p.DeleteDataWriter(PP_min_writer); result = s.DeleteDataReader(PP_seq_reader); result = p.DeleteDataWriter(PP_seq_writer); result = s.DeleteDataReader(PP_string_reader); result = p.DeleteDataWriter(PP_string_writer); result = s.DeleteDataReader(PP_fixed_reader); result = p.DeleteDataWriter(PP_fixed_writer); result = s.DeleteDataReader(PP_array_reader); result = p.DeleteDataWriter(PP_array_writer); result = s.DeleteDataReader(PP_quit_reader); result = dp.DeleteSubscriber(s); result = dp.DeletePublisher(p); result = dp.DeleteTopic(PP_min_topic); result = dp.DeleteTopic(PP_seq_topic); result = dp.DeleteTopic(PP_string_topic); result = dp.DeleteTopic(PP_fixed_topic); result = dp.DeleteTopic(PP_array_topic); result = dp.DeleteTopic(PP_quit_topic); result = dpf.DeleteParticipant(dp); return; }
public override Test.Framework.TestResult Run() { mod.tstDataWriter writer; mod.tstDataReader reader; mod.tstDataReader reader2; DDS.IStatusCondition condition; DDS.WaitSet waitset; DDS.ISubscriber subscriber; DDS.ICondition[] conditionHolder; Test.Framework.TestResult result; DDS.DataReaderQos drQos; DDS.ITopic topic; DDS.ReturnCode rc; string expResult = "StatusCondition test succeeded."; conditionHolder = new DDS.ICondition[0]; result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict .Pass, Test.Framework.TestVerdict.Fail); writer = (mod.tstDataWriter) this.ResolveObject("datawriter"); reader = (mod.tstDataReader) this.ResolveObject("datareader"); subscriber = (DDS.ISubscriber) this.ResolveObject("subscriber"); topic = (DDS.ITopic) this.ResolveObject("topic"); drQos = (DDS.DataReaderQos) this.ResolveObject("datareaderQos"); condition = writer.StatusCondition; if (condition == null) { result.Result = "Could not resolve reader condition."; return(result); } condition.SetEnabledStatuses(DDS.StatusKind.PublicationMatched); waitset = new DDS.WaitSet(); rc = waitset.AttachCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "Could not attach condition."; return(result); } /* A delay is required to make sure that 'reader' is created * and does not interfere with rest of the tests. Using the * waitset without checking all results as this garuantees * the fastest test execution. */ rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Ok) { result.Result = "WaitSet.Wait failed. (0)"; return(result); } /* Get publication matched status to make sure waitset is not woken * by 'reader' matched event. */ DDS.PublicationMatchedStatus holder = null; rc = writer.GetPublicationMatchedStatus(ref holder); if (rc != DDS.ReturnCode.Ok) { result.Result = "Unable to clear PublicationMatchedStatus."; return(result); } reader2 = (mod.tstDataReader)subscriber.CreateDataReader(topic, drQos);//, null, 0); if (reader2 == null) { result.Result = "Could not create datareader."; return(result); } rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Ok) { result.Result = "WaitSet.Wait failed. (1)"; return(result); } if (conditionHolder.Length != 1) { result.Result = "WaitSet.Wait returned no or multiple conditions where it should return one."; return(result); } if (conditionHolder[0] != condition) { result.Result = "WaitSet.Wait returned wrong condition (1)."; return(result); } if (writer.StatusChanges != DDS.StatusKind.PublicationMatched) { result.Result = "Expected status change (PublicationMatched) did not occur."; return(result); } if (!test.sacs.StatusValidator.PublicationMatchValid(writer, 2, 1, 2, 1)) { result.Result = "publication_matched not valid."; return(result); } if (!test.sacs.StatusValidator.PublicationMatchValid(writer, 2, 0, 2, 0)) { result.Result = "publication_matched not valid (2)."; return(result); } if (writer.StatusChanges != 0) { result.Result = "Expected all statuses are reset: this does not seem to be the case."; return(result); } rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed (2)."; return(result); } if (conditionHolder.Length != 0) { this.PrintStatusses(writer); result.Result = "WaitSet.Wait returned conditions where it shouldn't (1)."; return(result); } rc = subscriber.DeleteDataReader(reader); if (rc != DDS.ReturnCode.Ok) { result.Result = "delete_datareader failed."; return(result); } rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Ok) { result.Result = "WaitSet.Wait failed. (3)"; return(result); } if (conditionHolder.Length != 1) { result.Result = "WaitSet.Wait returned no or multiple conditions where it should return one (3)."; return(result); } if (conditionHolder[0] != condition) { result.Result = "WaitSet.Wait returned wrong condition (2)."; return(result); } if (writer.StatusChanges != DDS.StatusKind.PublicationMatched) { result.Result = "Expected status change (PublicationMatched) did not occur."; return(result); } if (!test.sacs.StatusValidator.PublicationMatchValid(writer, 2, 0, 1, 1)) { result.Result = "publication_matched not valid (3)."; return(result); } if (!test.sacs.StatusValidator.PublicationMatchValid(writer, 2, 0, 1, 0)) { result.Result = "publication_matched not valid (4)."; return(result); } if (writer.StatusChanges != 0) { result.Result = "Expected all statuses are reset: this does not seem to be the case (3)."; return(result); } rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed(4)."; return(result); } if (conditionHolder.Length > 0) { PrintStatusses(writer); result.Result = "WaitSet.Wait returned conditions where it shouldn't.(2)"; return(result); } result.Result = expResult; result.Verdict = Test.Framework.TestVerdict.Pass; return(result); }
public override Test.Framework.TestResult Run() { mod.tstDataWriter writer; mod.tstDataReader reader; DDS.IStatusCondition condition; DDS.IPublisher publisher; DDS.WaitSet waitset; mod.tst[] tstHolder; DDS.ICondition[] conditionHolder; DDS.SampleInfo[] sampleInfoHolder; Test.Framework.TestResult result; DDS.ReturnCode rc; string expResult = "StatusCondition test succeeded."; result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict .Pass, Test.Framework.TestVerdict.Fail); writer = (mod.tstDataWriter) this.ResolveObject("datawriter"); reader = (mod.tstDataReader) this.ResolveObject("datareader"); publisher = (DDS.IPublisher) this.ResolveObject("publisher"); condition = reader.StatusCondition; if (condition == null) { result.Result = "Could not resolve reader condition."; return(result); } waitset = new DDS.WaitSet(); rc = waitset.AttachCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "Could not attach condition."; return(result); } conditionHolder = new DDS.ICondition[0]; rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Ok) { result.Result = "WaitSet.Wait failed. (1)"; return(result); } if (conditionHolder.Length != 1) { result.Result = "WaitSet.Wait returned no or multiple conditions where it should return one."; return(result); } if (conditionHolder[0] != condition) { result.Result = "WaitSet.Wait returned wrong condition."; return(result); } if (!test.sacs.StatusValidator.LivelinessChangedValid(reader, 1, 1, 0, 0)) { result.Result = "liveliness_changed not valid."; return(result); } if (!test.sacs.StatusValidator.LivelinessChangedValid(reader, 1, 0, 0, 0)) { result.Result = "liveliness_changed not valid (2)."; return(result); } rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed. (2)"; return(result); } if (conditionHolder.Length != 0) { result.Result = "WaitSet.Wait returned conditions where it shouldn't (2)."; return(result); } mod.tst data = new mod.tst(); data.long_1 = 1; data.long_2 = 2; data.long_3 = 3; rc = writer.Write(data, 0); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataWriter.write failed."; return(result); } rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Ok) { result.Result = "WaitSet.Wait failed. (3)"; return(result); } if (conditionHolder.Length != 1) { result.Result = "WaitSet.Wait returned no conditions where it should (1)."; return(result); } if (conditionHolder[0] != condition) { result.Result = "WaitSet.Wait returned wrong condition (1)."; return(result); } tstHolder = new mod.tst[0]; sampleInfoHolder = new DDS.SampleInfo[0]; rc = reader.Take(ref tstHolder, ref sampleInfoHolder, 1, DDS.SampleStateKind.Any, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Any); reader.ReturnLoan(ref tstHolder, ref sampleInfoHolder); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataReader.take failed."; return(result); } rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed(4)."; return(result); } if (conditionHolder.Length > 0) { result.Result = "WaitSet.Wait returned conditions where it shouldn't.(2)"; return(result); } rc = publisher.DeleteDataWriter(writer); if (rc != DDS.ReturnCode.Ok) { result.Result = "delete_datawriter failed."; return(result); } try { System.Threading.Thread.Sleep(2000); } catch (System.Exception) { System.Console.Error.WriteLine("Sleep failed..."); } rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Ok) { result.Result = "WaitSet.Wait failed. (5)"; return(result); } if (conditionHolder.Length != 1) { result.Result = "WaitSet.Wait returned no or multiple conditions where it should return one."; return(result); } if (conditionHolder[0] != condition) { result.Result = "WaitSet.Wait returned wrong condition."; return(result); } if (!test.sacs.StatusValidator.LivelinessChangedValid(reader, 0, 1, 0, 0)) { result.Result = "liveliness_changed not valid (3)."; return(result); } if (!test.sacs.StatusValidator.LivelinessChangedValid(reader, 0, 0, 0, 0)) { result.Result = "liveliness_changed not valid (4)."; return(result); } rc = reader.Take(ref tstHolder, ref sampleInfoHolder, 1, DDS.SampleStateKind.Any, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Any); reader.ReturnLoan(ref tstHolder, ref sampleInfoHolder); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataReader.take failed."; return(result); } rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed(6)."; return(result); } if (conditionHolder.Length > 0) { result.Result = "WaitSet.Wait returned conditions where it shouldn't.(3)"; return(result); } result.Result = expResult; result.Verdict = Test.Framework.TestVerdict.Pass; return(result); }
public override Test.Framework.TestResult Run() { mod.tstDataReader reader; DDS.IStatusCondition condition; DDS.WaitSet waitset; Test.Framework.TestResult result; DDS.ReturnCode rc; bool value; DDS.StatusKind statusMask; DDS.ICondition[] holder; DDS.SubscriptionMatchedStatus smStatus = new DDS.SubscriptionMatchedStatus(); DDS.LivelinessChangedStatus lcStatus = new DDS.LivelinessChangedStatus(); string expResult = "ReadCondition test succeeded."; result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict.Pass, Test.Framework.TestVerdict.Fail); reader = (mod.tstDataReader) this.ResolveObject("datareader"); condition = reader.StatusCondition; if (condition == null) { result.Result = "Could not resolve status condition."; return(result); } waitset = new DDS.WaitSet(); rc = waitset.AttachCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "attach_condition failed."; return(result); } try { System.Threading.Thread.Sleep(3000); } catch (System.Exception) { System.Console.Error.WriteLine("Sleep failed..."); } holder = new DDS.Condition[0]; rc = waitset.Wait(ref holder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Ok) { result.Result = "wait failed (1). Retcode == " + rc; return(result); } if (holder.Length != 1) { System.Console.Out.WriteLine("Holder length : " + holder.Length); System.Console.Out.WriteLine("Status changes: " + reader.StatusChanges); reader.GetSubscriptionMatchedStatus(ref smStatus); System.Console.Out.WriteLine("Total count : " + smStatus.TotalCount); reader.GetLivelinessChangedStatus(ref lcStatus); System.Console.Out.WriteLine("Alive count : " + lcStatus.AliveCount); result.Result = "wait should return 1 condition but didn't (1)."; return(result); } rc = reader.GetLivelinessChangedStatus(ref lcStatus); DDS.LivelinessChangedStatus status = lcStatus; if (rc != DDS.ReturnCode.Ok) { result.Result = "GetLivelinessChangedStatus call failed."; return(result); } if (status.AliveCount != 1) { result.Result = "LivelinessChanged.AliveCount != 1. (" + status.AliveCount + ")."; return(result); } if (status.AliveCountChange != 1) { result.Result = "LivelinessChanged.AliveCountChange != 1." + status.AliveCountChange + ")."; return(result); } rc = reader.GetSubscriptionMatchedStatus(ref smStatus); if (rc != DDS.ReturnCode.Ok) { result.Result = "GetSubscriptionMatchedStatus call failed."; return(result); } if (smStatus.TotalCount != 1) { result.Result = "SubscriptionMatched.TotalCount != 1. (" + smStatus.TotalCount + ")."; return(result); } if (smStatus.TotalCountChange != 1) { result.Result = "SubscriptionMatched.TotalCountChange != 1." + smStatus.TotalCountChange + ")."; return(result); } value = condition.GetTriggerValue(); if (value) { result.Result = "GetTriggerValue returned true. " + reader.StatusChanges; return(result); } statusMask = condition.GetEnabledStatuses(); rc = condition.SetEnabledStatuses(statusMask); if (rc != DDS.ReturnCode.Ok) { result.Result = "SetEnabledStatuses failed (1)."; return(result); } if (condition.GetEnabledStatuses() != statusMask) { result.Result = "GetEnabledStatuses does not match the applied one."; return(result); } if (condition.GetEntity() != reader) { result.Result = "GetEntity does not return the correct entity."; return(result); } result.Result = expResult; result.Verdict = Test.Framework.TestVerdict.Pass; return(result); }
public override Test.Framework.TestResult Run() { DDS.ISubscriber subscriber; mod.tstDataWriter writer; mod.tstDataReader reader; DDS.IStatusCondition subscriberCondition; DDS.WaitSet waitset; mod.tst[] tstHolder; DDS.ICondition[] conditionHolder; DDS.SampleInfo[] sampleInfoHolder; Test.Framework.TestResult result; DDS.ReturnCode rc; string expResult = "StatusCondition test succeeded."; result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict .Pass, Test.Framework.TestVerdict.Fail); subscriber = (DDS.ISubscriber) this.ResolveObject("subscriber"); writer = (mod.tstDataWriter) this.ResolveObject("datawriter"); reader = (mod.tstDataReader) this.ResolveObject("datareader"); subscriberCondition = subscriber.StatusCondition; if (subscriberCondition == null) { result.Result = "Could not resolve subscriber condition."; return(result); } waitset = new DDS.WaitSet(); rc = waitset.AttachCondition(subscriberCondition); if (rc != DDS.ReturnCode.Ok) { result.Result = "Could not attach subscriber condition."; return(result); } conditionHolder = new DDS.ICondition[0]; rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed."; return(result); } if (conditionHolder.Length > 0) { result.Result = "WaitSet.Wait returned conditions where it shouldn't."; return(result); } mod.tst data = new mod.tst(); data.long_1 = 1; data.long_2 = 2; data.long_3 = 3; rc = writer.Write(data, 0); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataWriter.write failed."; return(result); } rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Ok) { result.Result = "WaitSet.Wait failed."; return(result); } if (conditionHolder.Length < 1) { result.Result = "WaitSet.Wait returned no conditions where it should (1)."; return(result); } if (conditionHolder[0] != subscriberCondition) { result.Result = "WaitSet.Wait returned wrong condition."; return(result); } tstHolder = new mod.tst[0]; sampleInfoHolder = new DDS.SampleInfo[0]; rc = reader.Take(ref tstHolder, ref sampleInfoHolder, 1, DDS.SampleStateKind.Any, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Any); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataReader.take failed."; return(result); } rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed(2)."; return(result); } if (conditionHolder.Length > 0) { result.Result = "WaitSet.Wait returned conditions where it shouldn't (2)."; return(result); } result.Result = expResult; result.Verdict = Test.Framework.TestVerdict.Pass; return(result); }
public override Test.Framework.TestResult Run() { mod.tstDataWriter writer; mod.tstDataReader reader; mod.tstDataReader reader2; DDS.IReadCondition condition; DDS.WaitSet waitset; DDS.ISubscriber subscriber; DDS.ICondition[] conditionHolder; Test.Framework.TestResult result; DDS.DataReaderQos drQos; mod.tst[] tstHolder; DDS.SampleInfo[] sampleInfoHolder; DDS.ITopic topic; DDS.ReturnCode rc; string expResult = "ReadCondition test succeeded."; result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict .Pass, Test.Framework.TestVerdict.Fail); writer = (mod.tstDataWriter)this.ResolveObject("datawriter"); reader = (mod.tstDataReader)this.ResolveObject("datareader"); subscriber = (DDS.ISubscriber)this.ResolveObject("subscriber"); topic = (DDS.ITopic)this.ResolveObject("topic"); drQos = (DDS.DataReaderQos)this.ResolveObject("datareaderQos"); condition = reader.CreateReadCondition(DDS.SampleStateKind.Any, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Any); if (condition == null) { result.Result = "Could not resolve reader condition."; return result; } waitset = new DDS.WaitSet(); rc = waitset.AttachCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "Could not attach condition."; return result; } reader2 = (mod.tstDataReader)subscriber.CreateDataReader(topic, drQos);//, null, 0); if (reader2 == null) { result.Result = "Could not create datareader."; return result; } conditionHolder = new DDS.ICondition[0]; rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed(3)."; return result; } if (conditionHolder.Length != 0) { result.Result = "WaitSet.Wait returned conditions where it shouldn't (3)."; return result; } mod.tst data = new mod.tst(); data.long_1 = 1; data.long_2 = 2; data.long_3 = 3; rc = writer.Write(data, 0); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataWriter.write failed."; return result; } rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Ok) { result.Result = "WaitSet.Wait failed."; return result; } if (conditionHolder.Length != 1) { result.Result = "WaitSet.Wait returned no or multiple conditions where it should return one."; return result; } if (conditionHolder[0] != condition) { result.Result = "WaitSet.Wait returned wrong condition."; return result; } rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Ok) { result.Result = "WaitSet.Wait failed(2)."; return result; } if (conditionHolder.Length != 1) { result.Result = "WaitSet.Wait returned no or multiple conditions where it should return one(2)."; return result; } if (conditionHolder[0] != condition) { result.Result = "WaitSet.Wait returned wrong condition(2)."; return result; } tstHolder = new mod.tst[0]; sampleInfoHolder = new DDS.SampleInfo[0]; rc = reader.TakeWithCondition(ref tstHolder, ref sampleInfoHolder, 1, condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataReader.take failed."; return result; } rc = reader.ReturnLoan(ref tstHolder, ref sampleInfoHolder); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataReader.return_loan failed."; return result; } rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed."; return result; } if (conditionHolder.Length != 0) { result.Result = "WaitSet.Wait returned conditions where it shouldn't (2)."; return result; } rc = subscriber.DeleteDataReader(reader); if (rc == DDS.ReturnCode.Ok) { result.Result = "delete_datareader succeeded, but should not."; return result; } rc = waitset.GetConditions(ref conditionHolder); if (rc != DDS.ReturnCode.Ok) { result.Result = "get_conditions failed."; return result; } if (conditionHolder.Length != 1) { result.Result = "Returned conditions not valid."; return result; } if (conditionHolder[0] != condition) { result.Result = "Returned condition does not equal set condition."; return result; } rc = reader.DeleteReadCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "delete_readcondition failed."; return result; } rc = waitset.GetConditions(ref conditionHolder); if (rc != DDS.ReturnCode.Ok) { result.Result = "get_conditions failed(2)."; return result; } if (conditionHolder.Length != 0) { result.Result = "Returned conditions not valid(2)."; return result; } rc = subscriber.DeleteDataReader(reader); if (rc != DDS.ReturnCode.Ok) { result.Result = "delete_datareader failed."; return result; } result.Result = expResult; result.Verdict = Test.Framework.TestVerdict.Pass; return result; }
public override Test.Framework.TestResult Run() { mod.tstDataReader reader; DDS.IStatusCondition condition; DDS.WaitSet waitset; Test.Framework.TestResult result; DDS.ReturnCode rc; bool value; DDS.StatusKind statusMask; DDS.ICondition[] holder; DDS.SubscriptionMatchedStatus smStatus = new DDS.SubscriptionMatchedStatus(); DDS.LivelinessChangedStatus lcStatus = new DDS.LivelinessChangedStatus(); string expResult = "ReadCondition test succeeded."; result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict.Pass, Test.Framework.TestVerdict.Fail); reader = (mod.tstDataReader)this.ResolveObject("datareader"); condition = reader.StatusCondition; if (condition == null) { result.Result = "Could not resolve status condition."; return result; } waitset = new DDS.WaitSet(); rc = waitset.AttachCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "attach_condition failed."; return result; } try { System.Threading.Thread.Sleep(3000); } catch (System.Exception) { System.Console.Error.WriteLine("Sleep failed..."); } holder = new DDS.Condition[0]; rc = waitset.Wait(ref holder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Ok) { result.Result = "wait failed (1). Retcode == " + rc; return result; } if (holder.Length != 1) { System.Console.Out.WriteLine("Holder length : " + holder.Length); System.Console.Out.WriteLine("Status changes: " + reader.StatusChanges); reader.GetSubscriptionMatchedStatus(ref smStatus); System.Console.Out.WriteLine("Total count : " + smStatus.TotalCount); reader.GetLivelinessChangedStatus(ref lcStatus); System.Console.Out.WriteLine("Alive count : " + lcStatus.AliveCount); result.Result = "wait should return 1 condition but didn't (1)."; return result; } rc = reader.GetLivelinessChangedStatus(ref lcStatus); DDS.LivelinessChangedStatus status = lcStatus; if (rc != DDS.ReturnCode.Ok) { result.Result = "GetLivelinessChangedStatus call failed."; return result; } if (status.AliveCount != 1) { result.Result = "LivelinessChanged.AliveCount != 1. (" + status.AliveCount + ")."; return result; } if (status.AliveCountChange != 1) { result.Result = "LivelinessChanged.AliveCountChange != 1." + status.AliveCountChange + ")."; return result; } value = condition.GetTriggerValue(); if (value) { result.Result = "GetTriggerValue returned true. " + reader.StatusChanges; return result; } statusMask = condition.GetEnabledStatuses(); rc = condition.SetEnabledStatuses(statusMask); if (rc != DDS.ReturnCode.Ok) { result.Result = "SetEnabledStatuses failed (1)."; return result; } if (condition.GetEnabledStatuses() != statusMask) { result.Result = "GetEnabledStatuses does not match the applied one."; return result; } if (condition.GetEntity() != reader) { result.Result = "GetEntity does not return the correct entity."; return result; } result.Result = expResult; result.Verdict = Test.Framework.TestVerdict.Pass; return result; }
public override Test.Framework.TestResult Run() { mod.tstDataWriter writer; mod.tstDataReader reader; mod.tstDataReader reader2; DDS.IQueryCondition condition; DDS.WaitSet waitset; DDS.ISubscriber subscriber; DDS.ICondition[] activeConditions = new DDS.Condition[0]; Test.Framework.TestResult result; DDS.DataReaderQos drQos = null; mod.tst[] tstHolder; DDS.SampleInfo[] sampleInfoHolder; string[] queryParams; DDS.ITopic topic; DDS.ReturnCode rc; string expression; string[] ssHolder; string expResult = "QueryCondition test succeeded."; result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict .Pass, Test.Framework.TestVerdict.Fail); writer = (mod.tstDataWriter) this.ResolveObject("datawriter"); reader = (mod.tstDataReader) this.ResolveObject("datareader"); subscriber = (DDS.ISubscriber) this.ResolveObject("subscriber"); topic = (DDS.ITopic) this.ResolveObject("topic"); drQos = (DDS.DataReaderQos) this.ResolveObject("datareaderQos"); expression = "long_1=%0"; queryParams = new string[1]; queryParams[0] = "1"; condition = reader.CreateQueryCondition(DDS.SampleStateKind.Any, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Any, expression, queryParams); if (condition == null) { result.Result = "Could not create query condition."; return(result); } waitset = new DDS.WaitSet(); rc = waitset.AttachCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "Could not attach condition."; return(result); } reader2 = (mod.tstDataReader)subscriber.CreateDataReader(topic, drQos); //, null, 0); if (reader2 == null) { result.Result = "Could not create datareader."; return(result); } rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed(3)."; return(result); } if (activeConditions.Length != 0) { result.Result = "WaitSet.Wait returned conditions where it shouldn't (3)."; return(result); } mod.tst data = new mod.tst(); data.long_1 = 2; data.long_2 = 2; data.long_3 = 3; rc = writer.Write(data, 0); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataWriter.write failed."; return(result); } rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed(3)."; return(result); } if (activeConditions.Length != 0) { result.Result = "WaitSet.Wait returned conditions where it shouldn't (4)."; return(result); } data = new mod.tst(); data.long_1 = 1; data.long_2 = 2; data.long_3 = 3; rc = writer.Write(data, 0); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataWriter.write failed."; return(result); } rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Ok) { result.Result = "WaitSet.Wait failed. "; return(result); } if (activeConditions.Length != 1) { result.Result = "WaitSet.Wait returned no or multiple conditions where it should return one."; return(result); } if (activeConditions[0] != condition) { result.Result = "WaitSet.Wait returned wrong condition."; return(result); } rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Ok) { result.Result = "WaitSet.Wait failed(2)."; return(result); } if (activeConditions.Length != 1) { result.Result = "WaitSet.Wait returned no or multiple conditions where it should return one(2)."; return(result); } if (activeConditions[0] != condition) { result.Result = "WaitSet.Wait returned wrong condition(2)."; return(result); } tstHolder = new mod.tst[0]; sampleInfoHolder = new DDS.SampleInfo[0]; rc = reader.TakeWithCondition(ref tstHolder, ref sampleInfoHolder, 1, condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataReader.take failed."; return(result); } rc = reader.ReturnLoan(ref tstHolder, ref sampleInfoHolder); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataReader.return_loan failed."; return(result); } rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed."; return(result); } if (activeConditions.Length != 0) { result.Result = "WaitSet.Wait returned conditions where it shouldn't (2)."; return(result); } rc = subscriber.DeleteDataReader(reader); if (rc == DDS.ReturnCode.Ok) { result.Result = "delete_datareader succeeded, but should not."; return(result); } rc = waitset.GetConditions(ref activeConditions); if (rc != DDS.ReturnCode.Ok) { result.Result = "get_conditions failed."; return(result); } if (activeConditions.Length != 1) { result.Result = "Returned conditions not valid."; return(result); } if (activeConditions[0] != condition) { result.Result = "Returned condition does not equal set condition."; return(result); } DDS.IDataReader reader3 = condition.GetDataReader(); if (reader != reader3) { result.Result = "ReadCondition.get_datareader failed."; return(result); } if (condition.GetInstanceStateMask() != DDS.InstanceStateKind.Any) { result.Result = "ReadCondition.get_instance_state_mask failed."; return(result); } if (condition.GetViewStateMask() != DDS.ViewStateKind.Any) { result.Result = "ReadCondition.get_view_state_mask failed."; return(result); } if (condition.GetSampleStateMask() != DDS.SampleStateKind.Any) { result.Result = "ReadCondition.get_sample_state_mask failed."; return(result); } rc = reader.DeleteReadCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "delete_readcondition failed."; return(result); } rc = waitset.GetConditions(ref activeConditions); if (rc != DDS.ReturnCode.Ok) { result.Result = "get_conditions failed(2)."; return(result); } if (activeConditions.Length != 0) { result.Result = "Returned conditions not valid(2)."; return(result); } queryParams = new string[1]; queryParams[0] = "1"; condition = reader.CreateQueryCondition(DDS.SampleStateKind.Any, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Any, "long_1=%0", queryParams); if (condition == null) { result.Result = "Could not create query condition."; return(result); } rc = waitset.AttachCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "Could not attach condition."; return(result); } rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed(q1)."; return(result); } if (activeConditions.Length != 0) { result.Result = "WaitSet.Wait returned conditions where it shouldn't (q1)."; return(result); } data = new mod.tst(); data.long_1 = 1; data.long_2 = 2; data.long_3 = 3; rc = writer.Write(data, 0); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataWriter.write failed(2)."; return(result); } rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Ok) { result.Result = "WaitSet.Wait failed (q2). "; return(result); } if (activeConditions.Length != 1) { result.Result = "WaitSet.Wait returned no or multiple conditions where it should return one(q2)."; return(result); } if (activeConditions[0] != condition) { result.Result = "WaitSet.Wait returned wrong condition(q2)."; return(result); } rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Ok) { result.Result = "WaitSet.Wait failed(2)."; return(result); } if (activeConditions.Length != 1) { result.Result = "WaitSet.Wait returned no or multiple conditions where it should return one(q3)."; return(result); } if (activeConditions[0] != condition) { result.Result = "WaitSet.Wait returned wrong condition(q3)."; return(result); } tstHolder = new mod.tst[0]; sampleInfoHolder = new DDS.SampleInfo[0]; rc = reader.TakeWithCondition(ref tstHolder, ref sampleInfoHolder, 1, condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataReader.take failed(q1)."; return(result); } rc = reader.ReturnLoan(ref tstHolder, ref sampleInfoHolder); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataReader.return_loan failed."; return(result); } rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed(q5)."; return(result); } if (activeConditions.Length != 0) { result.Result = "WaitSet.Wait returned conditions where it shouldn't (q6)."; return(result); } string expression2 = condition.GetQueryExpression(); if (!expression.Equals(expression2)) { result.Result = "QueryCondition.get_query_expression does not work properly."; return(result); } ssHolder = new string[0]; rc = condition.GetQueryParameters(ref ssHolder); if (rc != DDS.ReturnCode.Ok) { result.Result = "QueryCondition.get_query_parameters call failed."; return(result); } string[] queryParams2 = ssHolder; if (queryParams2 == null) { result.Result = "QueryCondition.get_query_parameters does not work properly (1)."; return(result); } if (queryParams2.Length != queryParams.Length) { result.Result = "QueryCondition.get_query_parameters does not work properly (2)."; return(result); } if (!queryParams2[0].Equals(queryParams[0])) { result.Result = "QueryCondition.get_query_parameters does not work properly (3)."; return(result); } queryParams[0] = "5"; rc = condition.SetQueryParameters(queryParams); if (rc != DDS.ReturnCode.Ok) { result.Result = "QueryCondition.set_query_parameters does not work properly."; return(result); } rc = condition.GetQueryParameters(ref ssHolder); if (rc != DDS.ReturnCode.Ok) { result.Result = "QueryCondition.get_query_parameters call failed (1)."; return(result); } queryParams2 = ssHolder; if (queryParams2 == null) { result.Result = "QueryCondition.get_query_parameters does not work properly (1)."; return(result); } if (queryParams2.Length != queryParams.Length) { result.Result = "QueryCondition.get_query_parameters does not work properly (2)."; return(result); } if (!queryParams2[0].Equals(queryParams[0])) { result.Result = "QueryCondition.get_query_parameters does not work properly (3)."; return(result); } rc = condition.SetQueryParameters(null); if (rc == DDS.ReturnCode.Ok) { result.Result = "QueryCondition.set_query_parameters does not work properly (2)."; this.testFramework.TestMessage(Test.Framework.TestMessage.Note, "See OSPL-2628: Query parameter checking should be added."); result.ExpectedVerdict = Test.Framework.TestVerdict.Fail; return(result); } rc = reader.DeleteReadCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "delete_readcondition failed(q7)."; return(result); } rc = waitset.GetConditions(ref activeConditions); if (rc != DDS.ReturnCode.Ok) { result.Result = "get_conditions failed(q7)."; return(result); } if (activeConditions.Length != 0) { result.Result = "Returned conditions not valid(q7)."; return(result); } rc = subscriber.DeleteDataReader(reader); if (rc != DDS.ReturnCode.Ok) { result.Result = "delete_datareader failed."; return(result); } result.Result = expResult; result.Verdict = Test.Framework.TestVerdict.Pass; return(result); }
public override Test.Framework.TestResult Run() { mod.tstDataWriter writer; mod.tstDataReader reader; DDS.IStatusCondition condition; DDS.IPublisher publisher; DDS.WaitSet waitset; mod.tst[] tstHolder; DDS.ICondition[] conditionHolder; DDS.SampleInfo[] sampleInfoHolder; Test.Framework.TestResult result; DDS.ReturnCode rc; string expResult = "StatusCondition test succeeded."; result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict .Pass, Test.Framework.TestVerdict.Fail); writer = (mod.tstDataWriter)this.ResolveObject("datawriter"); reader = (mod.tstDataReader)this.ResolveObject("datareader"); publisher = (DDS.IPublisher)this.ResolveObject("publisher"); condition = reader.StatusCondition; if (condition == null) { result.Result = "Could not resolve reader condition."; return result; } waitset = new DDS.WaitSet(); rc = waitset.AttachCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "Could not attach condition."; return result; } conditionHolder = new DDS.ICondition[0]; rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Ok) { result.Result = "WaitSet.Wait failed. (1)"; return result; } if (conditionHolder.Length != 1) { result.Result = "WaitSet.Wait returned no or multiple conditions where it should return one."; return result; } if (conditionHolder[0] != condition) { result.Result = "WaitSet.Wait returned wrong condition."; return result; } if (!test.sacs.StatusValidator.LivelinessChangedValid(reader, 1, 1, 0, 0)) { result.Result = "liveliness_changed not valid."; return result; } if (!test.sacs.StatusValidator.LivelinessChangedValid(reader, 1, 0, 0, 0)) { result.Result = "liveliness_changed not valid (2)."; return result; } rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed. (2)"; return result; } if (conditionHolder.Length != 0) { result.Result = "WaitSet.Wait returned conditions where it shouldn't (2)."; return result; } mod.tst data = new mod.tst(); data.long_1 = 1; data.long_2 = 2; data.long_3 = 3; rc = writer.Write(data, 0); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataWriter.write failed."; return result; } rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Ok) { result.Result = "WaitSet.Wait failed. (3)"; return result; } if (conditionHolder.Length != 1) { result.Result = "WaitSet.Wait returned no conditions where it should (1)."; return result; } if (conditionHolder[0] != condition) { result.Result = "WaitSet.Wait returned wrong condition (1)."; return result; } tstHolder = new mod.tst[0]; sampleInfoHolder = new DDS.SampleInfo[0]; rc = reader.Take(ref tstHolder, ref sampleInfoHolder, 1, DDS.SampleStateKind.Any, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Any); reader.ReturnLoan(ref tstHolder, ref sampleInfoHolder); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataReader.take failed."; return result; } rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed(4)."; return result; } if (conditionHolder.Length > 0) { result.Result = "WaitSet.Wait returned conditions where it shouldn't.(2)"; return result; } rc = publisher.DeleteDataWriter(writer); if (rc != DDS.ReturnCode.Ok) { result.Result = "delete_datawriter failed."; return result; } try { System.Threading.Thread.Sleep(2000); } catch (System.Exception) { System.Console.Error.WriteLine("Sleep failed..."); } rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Ok) { result.Result = "WaitSet.Wait failed. (5)"; return result; } if (conditionHolder.Length != 1) { result.Result = "WaitSet.Wait returned no or multiple conditions where it should return one."; return result; } if (conditionHolder[0] != condition) { result.Result = "WaitSet.Wait returned wrong condition."; return result; } if (!test.sacs.StatusValidator.LivelinessChangedValid(reader, 0, 1, 0, 0)) { result.Result = "liveliness_changed not valid (3)."; return result; } if (!test.sacs.StatusValidator.LivelinessChangedValid(reader, 0, 0, 0, 0)) { result.Result = "liveliness_changed not valid (4)."; return result; } rc = reader.Take(ref tstHolder, ref sampleInfoHolder, 1, DDS.SampleStateKind.Any, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Any); reader.ReturnLoan(ref tstHolder, ref sampleInfoHolder); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataReader.take failed."; return result; } rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed(6)."; return result; } if (conditionHolder.Length > 0) { result.Result = "WaitSet.Wait returned conditions where it shouldn't.(3)"; return result; } result.Result = expResult; result.Verdict = Test.Framework.TestVerdict.Pass; return result; }
public override Test.Framework.TestResult Run() { Test.Framework.TestResult result; Test.Framework.TestVerdict expVerdict = Test.Framework.TestVerdict.Pass; string expResult = "Resolving GuardCondition succeeded."; DDS.ICondition[] holder = null; DDS.ReturnCode[] resultCode = new DDS.ReturnCode[] { DDS.ReturnCode.Error, DDS.ReturnCode.Error, DDS.ReturnCode.Error }; DDS.ReturnCode ddsReturnCode; bool continueTesting = true; DDS.GuardCondition condition1 = (DDS.GuardCondition)ResolveObject("condition1"); DDS.GuardCondition condition2 = (DDS.GuardCondition)ResolveObject("condition2"); DDS.GuardCondition condition3 = (DDS.GuardCondition)ResolveObject("condition3"); DDS.WaitSet waitset = new DDS.WaitSet(); resultCode[0] = waitset.AttachCondition(condition1); resultCode[1] = waitset.AttachCondition(condition2); resultCode[2] = waitset.AttachCondition(condition3); if (resultCode[0] != 0 || resultCode[1] != 0 || resultCode[2] != 0) { result = new Test.Framework.TestResult("attached guardconditions to a waitset", "attach_condition returned RETCODE: " + resultCode[0] + " " + resultCode[1] + " " + resultCode[2], expVerdict, Test.Framework.TestVerdict.Fail); continueTesting = false; } else { result = new Test.Framework.TestResult(expResult, "get_conditions returned RETCODE_OK" , expVerdict, Test.Framework.TestVerdict.Pass); } if (continueTesting) { ddsReturnCode = waitset.GetConditions(ref holder); if (ddsReturnCode != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "get_conditions returned RETCODE: " + ddsReturnCode, expVerdict, Test.Framework.TestVerdict.Fail); } else { result = new Test.Framework.TestResult(expResult, "get_conditions returned RETCODE_OK" , expVerdict, Test.Framework.TestVerdict.Pass); } if (holder.Length != 3) { result = new Test.Framework.TestResult(expResult, "Did not resolve 3 GuardCondition objects" , expVerdict, Test.Framework.TestVerdict.Fail); } else { if ((holder[0] != condition1) && (holder[1] != condition1) && (holder[2] != condition1)) { result = new Test.Framework.TestResult(expResult, "Resolved GuardCondition objects not OK (1)" , expVerdict, Test.Framework.TestVerdict.Fail); return result; } if ((holder[0] != condition2) && (holder[1] != condition2) && (holder[2] != condition2)) { result = new Test.Framework.TestResult(expResult, "Resolved GuardCondition objects not OK (2)" , expVerdict, Test.Framework.TestVerdict.Fail); return result; } if ((holder[0] != condition3) && (holder[1] != condition3) && (holder[2] != condition3)) { result = new Test.Framework.TestResult(expResult, "Resolved GuardCondition objects not OK (3)" , expVerdict, Test.Framework.TestVerdict.Fail); return result; } result = new Test.Framework.TestResult(expResult, "Resolved 3 GuardCondition objects" , expVerdict, Test.Framework.TestVerdict.Pass); } } return result; }
public override Test.Framework.TestResult Run() { Test.Framework.TestResult result; Test.Framework.TestVerdict expVerdict = Test.Framework.TestVerdict.Pass; string expResult = "Waitset StatusCondition succeeded."; DDS.ICondition[] holder; DDS.ReturnCode rc; DDS.DomainParticipantFactory factory; DDS.IDomainParticipant participant; DDS.DomainParticipantQos qosHolder = null; DDS.IStatusCondition condition; DDS.IStatusCondition condition2; DDS.IPublisher publisher; DDS.PublisherQos pubQosHolder = null; result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict .Pass, Test.Framework.TestVerdict.Fail); holder = new DDS.ICondition[0]; DDS.WaitSet waitset = new DDS.WaitSet(); factory = DDS.DomainParticipantFactory.Instance; if (factory == null) { result.Result = "Factory get_instance failed."; return(result); } if (factory.GetDefaultParticipantQos(ref qosHolder) != DDS.ReturnCode.Ok) { result.Result = "get_default_participant_qos failed."; return(result); } participant = factory.CreateParticipant(DDS.DomainId.Default, qosHolder);//, null, 0); if (participant == null) { result.Result = "create_participant failed."; return(result); } if (participant.GetDefaultPublisherQos(ref pubQosHolder) != DDS.ReturnCode.Ok) { result.Result = "get_default_publisher_qos failed."; return(result); } publisher = participant.CreatePublisher(pubQosHolder);//, null, DDS.StatusKind.Any); if (publisher == null) { result.Result = "create_publisher failed."; return(result); } condition = participant.StatusCondition; if (condition == null) { result.Result = "get_status_condition failed."; return(result); } condition2 = publisher.StatusCondition; if (condition2 == null) { result.Result = "get_status_condition failed.(2)"; return(result); } rc = waitset.AttachCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "attach_condition returned RETCODE: " + rc; return(result); } rc = waitset.GetConditions(ref holder); if (rc != DDS.ReturnCode.Ok) { result.Result = "get_conditions returned RETCODE: " + rc; return(result); } if (holder.Length != 1) { result.Result = "get_conditions returned " + holder.Length + " conditions."; return(result); } if (holder[0] != condition) { result.Result = "get_conditions returned wrong condition."; return(result); } rc = waitset.DetachCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "detach_condition returned RETCODE: " + rc + " (1)"; return(result); } rc = waitset.GetConditions(ref holder); if (rc != DDS.ReturnCode.Ok) { result.Result = "get_conditions returned RETCODE: " + rc + " (1)"; return(result); } if (holder.Length != 0) { result.Result = "get_conditions returned " + holder.Length + " conditions (1)."; return(result); } rc = waitset.AttachCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "attach_condition returned RETCODE: " + rc; return(result); } rc = waitset.AttachCondition(condition2); if (rc != DDS.ReturnCode.Ok) { result.Result = "attach_condition returned RETCODE: " + rc; return(result); } rc = waitset.GetConditions(ref holder); if (rc != DDS.ReturnCode.Ok) { result.Result = "get_conditions returned RETCODE: " + rc; return(result); } if (holder.Length != 2) { result.Result = "get_conditions returned " + holder.Length + " conditions."; return(result); } if ((holder[0] != condition) && (holder[1] != condition)) { result.Result = "get_conditions returned wrong conditions(1)."; return(result); } if ((holder[0] != condition2) && (holder[1] != condition2)) { result.Result = "get_conditions returned wrong conditions(2)."; return(result); } rc = waitset.DetachCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "detach_condition returned RETCODE: " + rc + " (2)"; return(result); } rc = waitset.DetachCondition(condition2); if (rc != DDS.ReturnCode.Ok) { result.Result = "detach_condition returned RETCODE: " + rc + " (3)"; return(result); } rc = participant.DeleteContainedEntities(); if (rc != DDS.ReturnCode.Ok) { result.Result = "delete_contained_entities returned RETCODE: " + rc; return(result); } rc = factory.DeleteParticipant(participant); if (rc != DDS.ReturnCode.Ok) { result.Result = "delete_participant returned RETCODE: " + rc; return(result); } result.Result = expResult; result.Verdict = expVerdict; return(result); }
public void run(String[] args) { String myDomain = null; DDS.DomainParticipantFactory dpf; DDS.IDomainParticipant dp; DDS.IPublisher p; DDS.ISubscriber s; pingpong.PP_min_msgDataWriter PP_min_writer; pingpong.PP_seq_msgDataWriter PP_seq_writer; pingpong.PP_string_msgDataWriter PP_string_writer; pingpong.PP_fixed_msgDataWriter PP_fixed_writer; pingpong.PP_array_msgDataWriter PP_array_writer; pingpong.PP_min_msgDataReader PP_min_reader; pingpong.PP_seq_msgDataReader PP_seq_reader; pingpong.PP_string_msgDataReader PP_string_reader; pingpong.PP_fixed_msgDataReader PP_fixed_reader; pingpong.PP_array_msgDataReader PP_array_reader; pingpong.PP_quit_msgDataReader PP_quit_reader; pingpong.PP_min_msgTypeSupport PP_min_dt; pingpong.PP_seq_msgTypeSupport PP_seq_dt; pingpong.PP_string_msgTypeSupport PP_string_dt; pingpong.PP_fixed_msgTypeSupport PP_fixed_dt; pingpong.PP_array_msgTypeSupport PP_array_dt; pingpong.PP_quit_msgTypeSupport PP_quit_dt; pingpong.PP_min_msg[] PP_min_dataList = null; pingpong.PP_seq_msg[] PP_seq_dataList = null; pingpong.PP_string_msg[] PP_string_dataList = null; pingpong.PP_fixed_msg[] PP_fixed_dataList = null; pingpong.PP_array_msg[] PP_array_dataList = null; pingpong.PP_quit_msg[] PP_quit_dataList = null; DDS.IStatusCondition PP_min_sc; DDS.IStatusCondition PP_seq_sc; DDS.IStatusCondition PP_string_sc; DDS.IStatusCondition PP_fixed_sc; DDS.IStatusCondition PP_array_sc; DDS.IStatusCondition PP_quit_sc; DDS.ITopic PP_min_topic; DDS.ITopic PP_seq_topic; DDS.ITopic PP_string_topic; DDS.ITopic PP_fixed_topic; DDS.ITopic PP_array_topic; DDS.ITopic PP_quit_topic; DDS.ICondition[] conditionList = null; DDS.SampleInfo[] infoList = null; DDS.IWaitSet w; DDS.DomainParticipantQos dpQos; DDS.TopicQos tQos; DDS.PublisherQos pQos; DDS.DataWriterQos dwQos; DDS.SubscriberQos sQos; DDS.DataReaderQos drQos; Boolean terminate = false; DDS.ReturnCode result; int i; int imax; int j; int jmax; /* * Evaluate cmdline arguments */ if (args.Length != 0) { if (args.Length != 2) { System.Console.WriteLine("Invalid....."); System.Console.WriteLine("Usage: pong [READ_PARTITION WRITE_PARTITION]"); Environment.Exit(1); } read_partition = args[0]; write_partition = args[1]; } /* * Create WaitSet */ w = new DDS.WaitSet(); /* * Initialize Qos variables */ dpQos = new DDS.DomainParticipantQos(); tQos = new DDS.TopicQos(); pQos = new DDS.PublisherQos(); dwQos = new DDS.DataWriterQos(); sQos = new DDS.SubscriberQos(); drQos = new DDS.DataReaderQos(); /* * Create participant */ dpf = DDS.DomainParticipantFactory.Instance; dpf.GetDefaultParticipantQos(ref dpQos); dp = dpf.CreateParticipant(myDomain, dpQos, null, DDS.StatusKind.Any); if (dp == null) { System.Console.WriteLine("PING: ERROR - Splice Daemon not running"); return; } /* * Create PONG publisher */ dp.GetDefaultPublisherQos(ref pQos); pQos.Partition.Name = new String[1]; pQos.Partition.Name[0] = write_partition; p = dp.CreatePublisher(pQos); /* * Create PING subscriber */ dp.GetDefaultSubscriberQos(ref sQos); sQos.Partition.Name = new String[1]; sQos.Partition.Name[0] = read_partition; s = dp.CreateSubscriber(sQos); /* * Get default DataReader and DataWriter QoS settings */ p.GetDefaultDataWriterQos(ref dwQos); s.GetDefaultDataReaderQos(ref drQos); /* * Get default Topic Qos settings */ dp.GetDefaultTopicQos(ref tQos); /* match data reader/writer qos with topic qos */ p.CopyFromTopicQos(ref dwQos, tQos); s.CopyFromTopicQos(ref drQos, tQos); /* * PP_min_msg */ /* Create Topic */ PP_min_dt = new pingpong.PP_min_msgTypeSupport(); PP_min_dt.RegisterType(dp, "pingpong::PP_min_msg"); PP_min_topic = dp.CreateTopic("PP_min_topic", "pingpong::PP_min_msg", tQos); /* Create datawriter */ PP_min_writer = p.CreateDataWriter(PP_min_topic, dwQos) as pingpong.PP_min_msgDataWriter; /* Create datareader */ PP_min_reader = s.CreateDataReader(PP_min_topic, drQos) as pingpong.PP_min_msgDataReader; /* Add datareader statuscondition to waitset */ PP_min_sc = PP_min_reader.StatusCondition; PP_min_sc.SetEnabledStatuses(DDS.StatusKind.DataAvailable); result = w.AttachCondition(PP_min_sc); // assert(result == RETCODE_OK.value); /* * PP_seq_msg */ /* Create Topic */ PP_seq_dt = new pingpong.PP_seq_msgTypeSupport(); PP_seq_dt.RegisterType(dp, "pingpong::PP_seq_msg"); PP_seq_topic = dp.CreateTopic("PP_seq_topic", "pingpong::PP_seq_msg", tQos); /* Create datawriter */ PP_seq_writer = p.CreateDataWriter(PP_seq_topic, dwQos) as pingpong.PP_seq_msgDataWriter; /* Create datareader */ PP_seq_reader = s.CreateDataReader(PP_seq_topic, drQos) as pingpong.PP_seq_msgDataReader; /* Add datareader statuscondition to waitset */ PP_seq_sc = PP_seq_reader.StatusCondition; PP_seq_sc.SetEnabledStatuses(DDS.StatusKind.DataAvailable); result = w.AttachCondition(PP_seq_sc); //assert(result == RETCODE_OK.value); /* * PP_string_msg */ /* Create Topic */ PP_string_dt = new pingpong.PP_string_msgTypeSupport(); PP_string_dt.RegisterType(dp, "pingpong::PP_string_msg"); PP_string_topic = dp.CreateTopic("PP_string_topic", "pingpong::PP_string_msg", tQos); /* Create datawriter */ PP_string_writer = p.CreateDataWriter(PP_string_topic, dwQos) as pingpong.PP_string_msgDataWriter; /* Create datareader */ PP_string_reader = s.CreateDataReader(PP_string_topic,drQos) as pingpong.PP_string_msgDataReader; /* Add datareader statuscondition to waitset */ PP_string_sc = PP_string_reader.StatusCondition; PP_string_sc.SetEnabledStatuses(DDS.StatusKind.DataAvailable); result = w.AttachCondition(PP_string_sc); //assert(result == RETCODE_OK.value); /* * PP_fixed_msg */ /* Create Topic */ PP_fixed_dt = new pingpong.PP_fixed_msgTypeSupport(); PP_fixed_dt.RegisterType(dp, "pingpong::PP_fixed_msg"); PP_fixed_topic = dp.CreateTopic("PP_fixed_topic", "pingpong::PP_fixed_msg", tQos); /* Create datawriter */ PP_fixed_writer = p.CreateDataWriter(PP_fixed_topic, dwQos) as pingpong.PP_fixed_msgDataWriter; /* Create datareader */ PP_fixed_reader = s.CreateDataReader(PP_fixed_topic, drQos) as pingpong.PP_fixed_msgDataReader; /* Add datareader statuscondition to waitset */ PP_fixed_sc = PP_fixed_reader.StatusCondition; PP_fixed_sc.SetEnabledStatuses(DDS.StatusKind.DataAvailable); result = w.AttachCondition(PP_fixed_sc); //assert(result == RETCODE_OK.value); /* * PP_array_msg */ /* Create Topic */ PP_array_dt = new pingpong.PP_array_msgTypeSupport(); PP_array_dt.RegisterType(dp, "pingpong::PP_array_msg"); PP_array_topic = dp.CreateTopic("PP_array_topic", "pingpong::PP_array_msg", tQos); /* Create datawriter */ PP_array_writer = p.CreateDataWriter(PP_array_topic, dwQos) as pingpong.PP_array_msgDataWriter; /* Create datareader */ PP_array_reader = s.CreateDataReader(PP_array_topic, drQos) as pingpong.PP_array_msgDataReader; /* Add datareader statuscondition to waitset */ PP_array_sc = PP_array_reader.StatusCondition; PP_array_sc.SetEnabledStatuses(DDS.StatusKind.DataAvailable); result = w.AttachCondition(PP_array_sc); //assert(result == RETCODE_OK.value); /* * PP_quit_msg */ /* Create Topic */ PP_quit_dt = new pingpong.PP_quit_msgTypeSupport(); PP_quit_dt.RegisterType(dp, "pingpong::PP_quit_msg"); PP_quit_topic = dp.CreateTopic("PP_quit_topic", "pingpong::PP_quit_msg", tQos); /* Create datareader */ PP_quit_reader = s.CreateDataReader(PP_quit_topic, drQos) as pingpong.PP_quit_msgDataReader; /* Add datareader statuscondition to waitset */ PP_quit_sc = PP_quit_reader.StatusCondition; PP_quit_sc.SetEnabledStatuses(DDS.StatusKind.DataAvailable); result = w.AttachCondition(PP_quit_sc); //assert(result == RETCODE_OK.value); while (!terminate) { DDS.Duration wait_timeout = new DDS.Duration(DDS.Duration.InfiniteSec, DDS.Duration.InfiniteSec); result = w.Wait(ref conditionList, wait_timeout); ErrorHandler.checkStatus(result, "wait did not succeeed"); if (result == DDS.ReturnCode.AlreadyDeleted) { terminate = true; continue; } if (conditionList != null) { imax = conditionList.Length; for (i = 0; i < imax; i++) { if (conditionList[i] == PP_min_sc) { result = PP_min_reader.Take(ref PP_min_dataList, ref infoList, DDS.SampleStateKind.Any, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Any); jmax = PP_min_dataList.Length; if (jmax != 0) { for (j = 0; j < jmax; j++) { if (infoList[j].ValidData) { result = PP_min_writer.Write(PP_min_dataList[j], DDS.InstanceHandle.Nil); } } result = PP_min_reader.ReturnLoan(ref PP_min_dataList, ref infoList); } else { System.Console.WriteLine("PONG: PING_min triggered, but no data available"); } } else if (conditionList[i] == PP_seq_sc) { /* System.Console.WriteLine ("PONG: PING_seq arrived"); */ result = PP_seq_reader.Take(ref PP_seq_dataList, ref infoList, DDS.SampleStateKind.Any, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Any); jmax = PP_seq_dataList.Length; if (jmax != 0) { for (j = 0; j < jmax; j++) { if (infoList[j].ValidData) { result = PP_seq_writer.Write(PP_seq_dataList[j], DDS.InstanceHandle.Nil); } } result = PP_seq_reader.ReturnLoan(ref PP_seq_dataList, ref infoList); } else { System.Console.WriteLine("PONG: PING_seq triggered, but no data available"); } } else if (conditionList[i] == PP_string_sc) { /* System.Console.WriteLine ("PONG: PING_string arrived"); */ result = PP_string_reader.Take(ref PP_string_dataList, ref infoList, DDS.SampleStateKind.Any, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Any); jmax = PP_string_dataList.Length; if (jmax != 0) { for (j = 0; j < jmax; j++) { if (infoList[j].ValidData) { result = PP_string_writer.Write(PP_string_dataList[j], DDS.InstanceHandle.Nil); } } result = PP_string_reader.ReturnLoan(ref PP_string_dataList, ref infoList); } else { System.Console.WriteLine("PONG: PING_string triggered, but no data available"); } } else if (conditionList[i] == PP_fixed_sc) { /* System.Console.WriteLine ("PONG: PING_fixed arrived"); */ result = PP_fixed_reader.Take(ref PP_fixed_dataList, ref infoList, DDS.SampleStateKind.Any, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Any); jmax = PP_fixed_dataList.Length; if (jmax != 0) { for (j = 0; j < jmax; j++) { if (infoList[j].ValidData) { result = PP_fixed_writer.Write(PP_fixed_dataList[j], DDS.InstanceHandle.Nil); } } result = PP_fixed_reader.ReturnLoan(ref PP_fixed_dataList, ref infoList); } else { System.Console.WriteLine("PONG: PING_fixed triggered, but no data available"); } } else if (conditionList[i] == PP_array_sc) { /* System.Console.WriteLine ("PONG: PING_array arrived"); */ result = PP_array_reader.Take(ref PP_array_dataList, ref infoList, DDS.SampleStateKind.Any, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Any); jmax = PP_array_dataList.Length; if (jmax != 0) { for (j = 0; j < jmax; j++) { if (infoList[j].ValidData) { result = PP_array_writer.Write(PP_array_dataList[j], DDS.InstanceHandle.Nil); } } result = PP_array_reader.ReturnLoan(ref PP_array_dataList, ref infoList); } else { System.Console.WriteLine("PONG: PING_array triggered, but no data available"); } } else if (conditionList[i] == PP_quit_sc) { /* System.Console.WriteLine ("PONG: PING_quit arrived"); */ result = PP_quit_reader.Take(ref PP_quit_dataList, ref infoList, DDS.SampleStateKind.Any, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Any); jmax = PP_quit_dataList.Length; if (jmax != 0) { result = PP_quit_reader.ReturnLoan(ref PP_quit_dataList, ref infoList); } else { System.Console.WriteLine("PONG: PING_quit triggered, but no data available"); } terminate = true; } else { System.Console.WriteLine("PONG: unknown condition triggered: " + conditionList[i]); } } } else { System.Console.WriteLine("PONG: unknown condition triggered"); } } result = s.DeleteDataReader(PP_min_reader); result = p.DeleteDataWriter(PP_min_writer); result = s.DeleteDataReader(PP_seq_reader); result = p.DeleteDataWriter(PP_seq_writer); result = s.DeleteDataReader(PP_string_reader); result = p.DeleteDataWriter(PP_string_writer); result = s.DeleteDataReader(PP_fixed_reader); result = p.DeleteDataWriter(PP_fixed_writer); result = s.DeleteDataReader(PP_array_reader); result = p.DeleteDataWriter(PP_array_writer); result = s.DeleteDataReader(PP_quit_reader); result = dp.DeleteSubscriber(s); result = dp.DeletePublisher(p); result = dp.DeleteTopic(PP_min_topic); result = dp.DeleteTopic(PP_seq_topic); result = dp.DeleteTopic(PP_string_topic); result = dp.DeleteTopic(PP_fixed_topic); result = dp.DeleteTopic(PP_array_topic); result = dp.DeleteTopic(PP_quit_topic); result = dpf.DeleteParticipant(dp); return; }
public override Test.Framework.TestResult Run() { mod.tstDataWriter writer; mod.tstDataReader reader; DDS.IStatusCondition condition; DDS.IPublisher publisher; DDS.WaitSet waitset; mod.tst[] tstHolder; DDS.ICondition[] conditionHolder; DDS.SampleInfo[] sampleInfoHolder; Test.Framework.TestResult result; DDS.ReturnCode rc; string expResult = "StatusCondition test succeeded."; result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict .Pass, Test.Framework.TestVerdict.Fail); writer = (mod.tstDataWriter) this.ResolveObject("datawriter"); reader = (mod.tstDataReader) this.ResolveObject("datareader"); publisher = (DDS.IPublisher) this.ResolveObject("publisher"); condition = reader.StatusCondition; if (condition == null) { result.Result = "Could not resolve reader condition."; return(result); } waitset = new DDS.WaitSet(); rc = waitset.AttachCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "Could not attach condition."; return(result); } conditionHolder = new DDS.ICondition[0]; /* The LivelinessChanged and SubscriptionMatched are not necessarily synced. * So, it can happen that one triggers the waitset while the other hasn't been * updated yet. */ DDS.StatusKind statuses = 0; do { bool livelinessChanged = false; bool subscriptionMatched = false; rc = waitset.Wait(ref conditionHolder, new DDS.Duration(10, 0)); if (rc != DDS.ReturnCode.Ok) { result.Result = "WaitSet.Wait failed. (1): " + rc; return(result); } if (conditionHolder.Length != 1) { result.Result = "WaitSet.Wait returned no or multiple conditions where it should return one."; return(result); } if (conditionHolder[0] != condition) { result.Result = "WaitSet.Wait returned wrong condition."; return(result); } livelinessChanged = ((reader.StatusChanges & DDS.StatusKind.LivelinessChanged) == DDS.StatusKind.LivelinessChanged); subscriptionMatched = ((reader.StatusChanges & DDS.StatusKind.SubscriptionMatched) == DDS.StatusKind.SubscriptionMatched); statuses |= reader.StatusChanges; if (livelinessChanged) { if (!test.sacs.StatusValidator.LivelinessChangedValid(reader, 1, 1, 0, 0)) { result.Result = "liveliness_changed not valid."; return(result); } if (!test.sacs.StatusValidator.LivelinessChangedValid(reader, 1, 0, 0, 0)) { result.Result = "liveliness_changed not valid (2)."; return(result); } } /* This is only a useful test when both events were triggered at the same time, * because then getting liveliness status might have reset the subscription matched. */ if ((livelinessChanged && subscriptionMatched) && (reader.StatusChanges != DDS.StatusKind.SubscriptionMatched)) { result.Result = "Expected status change (SubscriptionMatched) should not have de-activated yet."; return(result); } if (subscriptionMatched) { if (!test.sacs.StatusValidator.SubscriptionMatchValid(reader, 1, 1, 1, 1)) { result.Result = "subscription_matched not valid."; return(result); } if (!test.sacs.StatusValidator.SubscriptionMatchValid(reader, 1, 0, 1, 0)) { result.Result = "subscription_matched not valid (2)."; return(result); } } } while (statuses != (DDS.StatusKind.LivelinessChanged | DDS.StatusKind.SubscriptionMatched)); if (reader.StatusChanges != 0) { result.Result = "Expected all statuses are reset: this does not seem to be the case."; return(result); } rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed. (2)"; return(result); } if (conditionHolder.Length != 0) { result.Result = "WaitSet.Wait returned conditions where it shouldn't."; return(result); } mod.tst data = new mod.tst(); data.long_1 = 1; data.long_2 = 2; data.long_3 = 3; rc = writer.Write(data, 0); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataWriter.write failed."; return(result); } rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Ok) { result.Result = "WaitSet.Wait failed. (3)"; return(result); } if (conditionHolder.Length != 1) { result.Result = "WaitSet.Wait returned no or multiple conditions where it should return one (2)."; return(result); } if (conditionHolder[0] != condition) { result.Result = "WaitSet.Wait returned wrong condition (2)."; return(result); } if (reader.StatusChanges != DDS.StatusKind.DataAvailable) { result.Result = "Expected status change DataAvailable, which is not currently set."; return(result); } tstHolder = new mod.tst[0]; sampleInfoHolder = new DDS.SampleInfo[0]; rc = reader.Take(ref tstHolder, ref sampleInfoHolder, 1, DDS.SampleStateKind.Any, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Any); reader.ReturnLoan(ref tstHolder, ref sampleInfoHolder); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataReader.take failed."; return(result); } if (reader.StatusChanges != 0) { result.Result = "Expected all statuses are reset: this does not seem to be the case (2)."; return(result); } rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed(4)."; return(result); } if (conditionHolder.Length > 0) { result.Result = "WaitSet.Wait returned conditions where it shouldn't.(2)"; return(result); } rc = publisher.DeleteDataWriter(writer); if (rc != DDS.ReturnCode.Ok) { result.Result = "delete_datawriter failed."; return(result); } try { System.Threading.Thread.Sleep(2000); } catch (System.Exception) { System.Console.Error.WriteLine("Sleep failed..."); } rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Ok) { result.Result = "WaitSet.Wait failed. (5)"; return(result); } if (conditionHolder.Length != 1) { result.Result = "WaitSet.Wait returned no or multiple conditions where it should return one (3)."; return(result); } if (conditionHolder[0] != condition) { result.Result = "WaitSet.Wait returned wrong condition (3)."; return(result); } if (reader.StatusChanges != (DDS.StatusKind.LivelinessChanged | DDS.StatusKind.SubscriptionMatched | DDS.StatusKind.DataAvailable)) { result.Result = "Expected status changes (LivelinessChanged AND SubscriptionMatched AND DataAvailable) did not occur."; return(result); } if (!test.sacs.StatusValidator.LivelinessChangedValid(reader, 0, 1, 0, 0)) { result.Result = "liveliness_changed not valid (3)."; return(result); } if (!test.sacs.StatusValidator.LivelinessChangedValid(reader, 0, 0, 0, 0)) { result.Result = "liveliness_changed not valid (4)."; return(result); } if (reader.StatusChanges != (DDS.StatusKind.SubscriptionMatched | DDS.StatusKind.DataAvailable)) { result.Result = "Expected status changes (SubscriptionMatched | DataAvailable) should not have de-activated yet."; return(result); } if (!test.sacs.StatusValidator.SubscriptionMatchValid(reader, 1, 0, 0, 1)) { result.Result = "subscription_matched not valid (3)."; return(result); } if (!test.sacs.StatusValidator.SubscriptionMatchValid(reader, 1, 0, 0, 0)) { result.Result = "subscription_matched not valid (4)."; return(result); } if (reader.StatusChanges != DDS.StatusKind.DataAvailable) { result.Result = "Expected status change (DataAvailable) should not have de-activated yet."; return(result); } rc = reader.Take(ref tstHolder, ref sampleInfoHolder, 1, DDS.SampleStateKind.Any, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Any); reader.ReturnLoan(ref tstHolder, ref sampleInfoHolder); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataReader.take failed."; return(result); } if (reader.StatusChanges != 0) { result.Result = "Expected all statuses are reset: this does not seem to be the case (3)."; return(result); } rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed(6)."; return(result); } if (conditionHolder.Length > 0) { result.Result = "WaitSet.Wait returned conditions where it shouldn't.(3)"; return(result); } result.Result = expResult; result.Verdict = Test.Framework.TestVerdict.Pass; return(result); }
public override Test.Framework.TestResult Run() { Test.Framework.TestResult result; Test.Framework.TestVerdict expVerdict = Test.Framework.TestVerdict.Pass; string expResult = "Waitset StatusCondition succeeded."; DDS.ICondition[] holder; DDS.ReturnCode rc; DDS.DomainParticipantFactory factory; DDS.IDomainParticipant participant; DDS.DomainParticipantQos qosHolder = null; DDS.IStatusCondition condition; DDS.IStatusCondition condition2; DDS.IPublisher publisher; DDS.PublisherQos pubQosHolder = null; result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict .Pass, Test.Framework.TestVerdict.Fail); holder = new DDS.ICondition[0]; DDS.WaitSet waitset = new DDS.WaitSet(); factory = DDS.DomainParticipantFactory.Instance; if (factory == null) { result.Result = "Factory get_instance failed."; return result; } if (factory.GetDefaultParticipantQos(ref qosHolder) != DDS.ReturnCode.Ok) { result.Result = "get_default_participant_qos failed."; return result; } participant = factory.CreateParticipant(string.Empty, qosHolder);//, null, 0); if (participant == null) { result.Result = "create_participant failed."; return result; } if (participant.GetDefaultPublisherQos(ref pubQosHolder) != DDS.ReturnCode.Ok) { result.Result = "get_default_publisher_qos failed."; return result; } publisher = participant.CreatePublisher(pubQosHolder);//, null, DDS.StatusKind.Any); if (publisher == null) { result.Result = "create_publisher failed."; return result; } condition = participant.StatusCondition; if (condition == null) { result.Result = "get_status_condition failed."; return result; } condition2 = publisher.StatusCondition; if (condition2 == null) { result.Result = "get_status_condition failed.(2)"; return result; } rc = waitset.AttachCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "attach_condition returned RETCODE: " + rc; return result; } rc = waitset.GetConditions(ref holder); if (rc != DDS.ReturnCode.Ok) { result.Result = "get_conditions returned RETCODE: " + rc; return result; } if (holder.Length != 1) { result.Result = "get_conditions returned " + holder.Length + " conditions."; return result; } if (holder[0] != condition) { result.Result = "get_conditions returned wrong condition."; return result; } rc = waitset.DetachCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "detach_condition returned RETCODE: " + rc + " (1)"; return result; } rc = waitset.GetConditions(ref holder); if (rc != DDS.ReturnCode.Ok) { result.Result = "get_conditions returned RETCODE: " + rc + " (1)"; return result; } if (holder.Length != 0) { result.Result = "get_conditions returned " + holder.Length + " conditions (1)."; return result; } rc = waitset.AttachCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "attach_condition returned RETCODE: " + rc; return result; } rc = waitset.AttachCondition(condition2); if (rc != DDS.ReturnCode.Ok) { result.Result = "attach_condition returned RETCODE: " + rc; return result; } rc = waitset.GetConditions(ref holder); if (rc != DDS.ReturnCode.Ok) { result.Result = "get_conditions returned RETCODE: " + rc; return result; } if (holder.Length != 2) { result.Result = "get_conditions returned " + holder.Length + " conditions."; return result; } if ((holder[0] != condition) && (holder[1] != condition)) { result.Result = "get_conditions returned wrong conditions(1)."; return result; } if ((holder[0] != condition2) && (holder[1] != condition2)) { result.Result = "get_conditions returned wrong conditions(2)."; return result; } rc = waitset.DetachCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "detach_condition returned RETCODE: " + rc + " (2)"; return result; } rc = waitset.DetachCondition(condition2); if (rc != DDS.ReturnCode.Ok) { result.Result = "detach_condition returned RETCODE: " + rc + " (3)"; return result; } rc = participant.DeleteContainedEntities(); if (rc != DDS.ReturnCode.Ok) { result.Result = "delete_contained_entities returned RETCODE: " + rc; return result; } rc = factory.DeleteParticipant(participant); if (rc != DDS.ReturnCode.Ok) { result.Result = "delete_participant returned RETCODE: " + rc; return result; } result.Result = expResult; result.Verdict = expVerdict; return result; }
/* * P I N G */ public void run(String[] args) { System.Console.WriteLine("starting PING"); DDS.ICondition[] conditionList = null; DDS.IWaitSet w; DDS.DomainParticipantQos dpQos; DDS.TopicQos tQos; DDS.PublisherQos pQos; DDS.DataWriterQos dwQos; DDS.SubscriberQos sQos; DDS.DataReaderQos drQos; DDS.Duration wait_timeout = new DDS.Duration(3, 0); DDS.ReturnCode result; Boolean finish_flag = false; Boolean timeout_flag = false; Boolean terminate = false; int imax = 1; int i; uint block; int nof_cycles = 100; int nof_blocks = 20; /** * Command Line argument processing */ if (args.Length != 0) { if (args.Length != 5) { System.Console.WriteLine("Invalid....."); System.Console.WriteLine("Usage: ping blocks blocksize topic_id WRITE_PARTITION READ_PARTITION "); Environment.Exit(1); } nof_blocks = int.Parse(args[0]); nof_cycles = int.Parse(args[1]); topic_id = args[2][0]; write_partition = args[3]; read_partition = args[4]; } /* * Create WaitSet */ w = new DDS.WaitSet(); /* * Initialize Qos variables */ dpQos = new DDS.DomainParticipantQos(); tQos = new DDS.TopicQos(); pQos = new DDS.PublisherQos(); dwQos = new DDS.DataWriterQos(); sQos = new DDS.SubscriberQos(); drQos = new DDS.DataReaderQos(); /* * Create participant */ dpf = DDS.DomainParticipantFactory.Instance; dpf.GetDefaultParticipantQos(ref dpQos); ErrorHandler.checkHandle(dpf, "DDS.DomainParticipantFactory.Instance"); dp = dpf.CreateParticipant(myDomain, dpQos); if (dp == null) { System.Console.WriteLine("PING: ERROR - Splice Daemon not running"); return; } /* * Create PING publisher */ dp.GetDefaultPublisherQos(ref pQos); pQos.Partition.Name = new String[1]; pQos.Partition.Name[0] = write_partition; p = dp.CreatePublisher(pQos); /* * Create PONG subscriber */ dp.GetDefaultSubscriberQos(ref sQos); sQos.Partition.Name = new String[1]; sQos.Partition.Name[0] = read_partition; s = dp.CreateSubscriber(sQos); /* * Get default DataReader and DataWriter QoS settings */ p.GetDefaultDataWriterQos(ref dwQos); s.GetDefaultDataReaderQos(ref drQos); /* * Get default Topic Qos settings */ dp.GetDefaultTopicQos(ref tQos); /*match data reader/writer qos with topic qos*/ p.CopyFromTopicQos(ref dwQos, tQos); s.CopyFromTopicQos(ref drQos, tQos); /* * PP_min_msg */ /* Create Topic */ PP_min_dt = new pingpong.PP_min_msgTypeSupport(); PP_min_dt.RegisterType(dp, "pingpong::PP_min_msg"); PP_min_topic = dp.CreateTopic("PP_min_topic", "pingpong::PP_min_msg", tQos); /* Create datawriter */ PP_min_writer = p.CreateDataWriter(PP_min_topic, dwQos) as pingpong.PP_min_msgDataWriter; /* Create datareader */ PP_min_reader = s.CreateDataReader(PP_min_topic, drQos) as pingpong.PP_min_msgDataReader; /* Add datareader statuscondition to waitset */ PP_min_sc = PP_min_reader.StatusCondition; PP_min_sc.SetEnabledStatuses(DDS.StatusKind.DataAvailable); result = w.AttachCondition(PP_min_sc); ErrorHandler.checkStatus(result, "attach condition pp_min_reader"); //assert (result == RETCODE_OK.value); /* * PP_seq_msg */ /* Create Topic */ PP_seq_dt = new pingpong.PP_seq_msgTypeSupport(); PP_seq_dt.RegisterType(dp, "pingpong::PP_seq_msg"); PP_seq_topic = dp.CreateTopic("PP_seq_topic", "pingpong::PP_seq_msg", tQos); /* Create datawriter */ PP_seq_writer = p.CreateDataWriter(PP_seq_topic, dwQos) as pingpong.PP_seq_msgDataWriter; /* Create datareader */ PP_seq_reader = s.CreateDataReader(PP_seq_topic, drQos) as pingpong.PP_seq_msgDataReader; /* Add datareader statuscondition to waitset */ PP_seq_sc = PP_seq_reader.StatusCondition; PP_seq_sc.SetEnabledStatuses(DDS.StatusKind.DataAvailable); result = w.AttachCondition(PP_seq_sc); ErrorHandler.checkStatus(result, "attach condition pp_seq_reader"); //assert (result == RETCODE_OK.value); /* * PP_string_msg */ /* Create Topic */ PP_string_dt = new pingpong.PP_string_msgTypeSupport(); PP_string_dt.RegisterType(dp, "pingpong::PP_string_msg"); PP_string_topic = dp.CreateTopic("PP_string_topic", "pingpong::PP_string_msg", tQos); /* Create datawriter */ PP_string_writer = p.CreateDataWriter(PP_string_topic, dwQos) as pingpong.PP_string_msgDataWriter; /* Create datareader */ PP_string_reader = s.CreateDataReader(PP_string_topic, drQos) as pingpong.PP_string_msgDataReader; /* Add datareader statuscondition to waitset */ PP_string_sc = PP_string_reader.StatusCondition; PP_string_sc.SetEnabledStatuses(DDS.StatusKind.DataAvailable); result = w.AttachCondition(PP_string_sc); ErrorHandler.checkStatus(result, "attach condition pp_string_reader"); //assert (result == RETCODE_OK.value); /* * PP_fixed_msg */ /* Create Topic */ PP_fixed_dt = new pingpong.PP_fixed_msgTypeSupport(); PP_fixed_dt.RegisterType(dp, "pingpong::PP_fixed_msg"); PP_fixed_topic = dp.CreateTopic("PP_fixed_topic", "pingpong::PP_fixed_msg", tQos); /* Create datawriter */ PP_fixed_writer = p.CreateDataWriter(PP_fixed_topic, dwQos) as pingpong.PP_fixed_msgDataWriter; /* Create datareader */ PP_fixed_reader = s.CreateDataReader(PP_fixed_topic, drQos) as pingpong.PP_fixed_msgDataReader; /* Add datareader statuscondition to waitset */ PP_fixed_sc = PP_fixed_reader.StatusCondition; PP_fixed_sc.SetEnabledStatuses(DDS.StatusKind.DataAvailable); result = w.AttachCondition(PP_fixed_sc); ErrorHandler.checkStatus(result, "attach condition pp_fixed_reader"); //assert (result == RETCODE_OK.value); /* * PP_array_msg */ /* Create Topic */ PP_array_dt = new pingpong.PP_array_msgTypeSupport(); PP_array_dt.RegisterType(dp, "pingpong::PP_array_msg"); PP_array_topic = dp.CreateTopic("PP_array_topic", "pingpong::PP_array_msg", tQos); /* Create datawriter */ PP_array_writer = p.CreateDataWriter(PP_array_topic, dwQos) as pingpong.PP_array_msgDataWriter; /* Create datareader */ PP_array_reader = s.CreateDataReader(PP_array_topic, drQos) as pingpong.PP_array_msgDataReader; /* Add datareader statuscondition to waitset */ PP_array_sc = PP_array_reader.StatusCondition; PP_array_sc.SetEnabledStatuses(DDS.StatusKind.DataAvailable); result = w.AttachCondition(PP_array_sc); ErrorHandler.checkStatus(result, "attach condition pp_array_reader"); //assert (result == RETCODE_OK.value); /* * PP_quit_msg */ /* Create Topic */ PP_quit_dt = new pingpong.PP_quit_msgTypeSupport(); PP_quit_dt.RegisterType(dp, "pingpong::PP_quit_msg"); PP_quit_topic = dp.CreateTopic("PP_quit_topic", "pingpong::PP_quit_msg", tQos); /* Create datawriter */ PP_quit_writer = p.CreateDataWriter(PP_quit_topic, dwQos) as pingpong.PP_quit_msgDataWriter; for (block = 0; block < nof_blocks; block++) { while (!finish_flag) { /* * Send Initial message */ timeout_flag = false; switch (topic_id) { case 'm': { /* System.Console.WriteLine ("PING: sending initial ping_min"); */ pingpong.PP_min_msg PPdata = new pingpong.PP_min_msg(); PPdata.count = 0; PPdata.block = block; preWriteTime.timeGet(); result = PP_min_writer.Write(PPdata); postWriteTime.timeGet(); } break; case 'q': { /* System.Console.WriteLine ("PING: sending initial ping_seq"); */ pingpong.PP_seq_msg PPdata = new pingpong.PP_seq_msg(); PPdata.count = 0; PPdata.block = block; preWriteTime.timeGet(); result = PP_seq_writer.Write(PPdata); postWriteTime.timeGet(); } break; case 's': { //System.Console.WriteLine ("PING: sending initial ping_string"); pingpong.PP_string_msg PPdata = new pingpong.PP_string_msg(); PPdata.count = 0; PPdata.block = block; PPdata.a_string = "a_string " + block.ToString(); preWriteTime.timeGet(); result = PP_string_writer.Write(PPdata); ErrorHandler.checkStatus(result, "writing PPData in case S"); postWriteTime.timeGet(); } break; case 'f': { /* System.Console.WriteLine ("PING: sending initial ping_fixed"); */ pingpong.PP_fixed_msg PPdata = new pingpong.PP_fixed_msg(); PPdata.count = 0; PPdata.block = block; preWriteTime.timeGet(); result = PP_fixed_writer .Write(PPdata); postWriteTime.timeGet(); } break; case 'a': { /* System.Console.WriteLine ("PING: sending initial ping_array"); */ pingpong.PP_array_msg PPdata = new pingpong.PP_array_msg(); PPdata.count = 0; PPdata.block = block; PPdata.str_arr_char = new char[10]; PPdata.str_arr_octet = new byte[10]; PPdata.str_arr_short = new short[10]; PPdata.str_arr_ushort = new ushort[10]; PPdata.str_arr_long = new int[10]; PPdata.str_arr_ulong = new uint[10]; PPdata.str_arr_longlong = new long[10]; PPdata.str_arr_ulonglong = new ulong[10]; PPdata.str_arr_float = new float[10]; PPdata.str_arr_double = new double[10]; PPdata.str_arr_boolean = new Boolean[11]; preWriteTime.timeGet(); result = PP_array_writer .Write(PPdata); postWriteTime.timeGet(); } break; case 't': { /* System.Console.WriteLine ("PING: sending initial ping_quit"); */ pingpong.PP_quit_msg PPdata = new pingpong.PP_quit_msg(); PPdata.quit = true; terminate = true; finish_flag = true; preWriteTime.timeGet(); result = PP_quit_writer.Write(PPdata); postWriteTime.timeGet(); } break; default: System.Console.WriteLine("Invalid topic-id"); return; } if (!terminate) { roundTripTime.set(preWriteTime.get()); write_access.add_stats(postWriteTime.sub(preWriteTime)); /* * Wait for response, calculate timing, and send another * data if not ready */ while (!(timeout_flag || finish_flag)) { result = w.Wait(ref conditionList, wait_timeout); //ErrorHandler.checkStatus(result, "wait did not work condition list is probably null!"); if (conditionList != null) { imax = conditionList.Length; if (imax != 0) { for (i = 0; i < imax; i++) { if (conditionList[i] == PP_min_sc) { finish_flag = PP_min_handler(nof_cycles); } else if (conditionList[i] == PP_seq_sc) { finish_flag = PP_seq_handler(nof_cycles); } else if (conditionList[i] == PP_string_sc) { finish_flag = PP_string_handler(nof_cycles); } else if (conditionList[i] == PP_fixed_sc) { finish_flag = PP_fixed_handler(nof_cycles); } else if (conditionList[i] == PP_array_sc) { finish_flag = PP_array_handler(nof_cycles); } else { System.Console.WriteLine("PING: unexpected condition triggered: " + conditionList[i]); } } } else { System.Console.WriteLine("PING: TIMEOUT - message lost (1)"); timeout_flag = true; } } else { System.Console.WriteLine("PING: TIMEOUT - message lost (2)"); timeout_flag = true; } } } } if (!terminate) { finish_flag = false; if (block == 0) { System.Console.WriteLine("# PING PONG measurements (in us)"); System.Console.WriteLine("# Executed at: "); System.Console.WriteLine("# Roundtrip time [us] Write-access time [us] Read-access time [us]"); System.Console.WriteLine("# Block Count mean min max Count mean min max Count mean min max"); } System.Console.WriteLine(String.Format("{0,-6} {1, 10} {2, 6} {3, 6} {4, 6} {5, 10} {6, 6} {7, 6} {8, 6} {9, 10} {10, 6} {11, 6} {12, 6}", block,roundtrip.count,roundtrip.average,roundtrip.min, roundtrip.max,write_access.count, write_access.average,write_access.min, write_access.max, read_access.count, read_access.average, read_access.min, read_access.max)); Console.Out.Flush(); write_access.init_stats(); read_access.init_stats(); roundtrip.init_stats(); } } result = s.DeleteDataReader(PP_min_reader); result = p.DeleteDataWriter(PP_min_writer); result = s.DeleteDataReader(PP_seq_reader); result = p.DeleteDataWriter(PP_seq_writer); result = s.DeleteDataReader(PP_string_reader); result = p.DeleteDataWriter(PP_string_writer); result = s.DeleteDataReader(PP_fixed_reader); result = p.DeleteDataWriter(PP_fixed_writer); result = s.DeleteDataReader(PP_array_reader); result = p.DeleteDataWriter(PP_array_writer); result = p.DeleteDataWriter(PP_quit_writer); result = dp.DeleteSubscriber(s); result = dp.DeletePublisher(p); result = dp.DeleteTopic(PP_min_topic); result = dp.DeleteTopic(PP_seq_topic); result = dp.DeleteTopic(PP_string_topic); result = dp.DeleteTopic(PP_fixed_topic); result = dp.DeleteTopic(PP_array_topic); result = dp.DeleteTopic(PP_quit_topic); result = dpf.DeleteParticipant(dp); return; }
public override Test.Framework.TestResult Run() { mod.tstDataWriter writer; mod.tstDataReader reader; mod.tstDataReader reader2; DDS.IStatusCondition condition; DDS.WaitSet waitset; DDS.ISubscriber subscriber; DDS.ICondition[] conditionHolder; Test.Framework.TestResult result; DDS.DataReaderQos drQos; DDS.ITopic topic; DDS.ReturnCode rc; string expResult = "StatusCondition test succeeded."; result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict .Pass, Test.Framework.TestVerdict.Fail); writer = (mod.tstDataWriter) this.ResolveObject("datawriter"); reader = (mod.tstDataReader) this.ResolveObject("datareader"); subscriber = (DDS.ISubscriber) this.ResolveObject("subscriber"); topic = (DDS.ITopic) this.ResolveObject("topic"); drQos = (DDS.DataReaderQos) this.ResolveObject("datareaderQos"); condition = writer.StatusCondition; if (condition == null) { result.Result = "Could not resolve reader condition."; return(result); } waitset = new DDS.WaitSet(); rc = waitset.AttachCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "Could not attach condition."; return(result); } reader2 = (mod.tstDataReader)subscriber.CreateDataReader(topic, drQos);//, null, 0); if (reader2 == null) { result.Result = "Could not create datareader."; return(result); } conditionHolder = new DDS.ICondition[0]; rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed."; return(result); } if (conditionHolder.Length != 0) { this.PrintStatusses(writer); result.Result = "WaitSet.Wait returned conditions where it shouldn't (2)."; return(result); } rc = subscriber.DeleteDataReader(reader); if (rc != DDS.ReturnCode.Ok) { result.Result = "delete_datareader failed."; return(result); } rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed(3)."; return(result); } if (conditionHolder.Length > 0) { PrintStatusses(writer); result.Result = "WaitSet.Wait returned conditions where it shouldn't.(3)"; return(result); } result.Result = expResult; result.Verdict = Test.Framework.TestVerdict.Pass; return(result); }
public override Test.Framework.TestResult Run() { mod.tstDataWriter writer; mod.tstDataReader reader; mod.tstDataReader reader2; DDS.IQueryCondition condition; DDS.WaitSet waitset; DDS.ISubscriber subscriber; DDS.ICondition[] activeConditions = new DDS.Condition[0]; Test.Framework.TestResult result; DDS.DataReaderQos drQos = null; mod.tst[] tstHolder; DDS.SampleInfo[] sampleInfoHolder; string[] queryParams; DDS.ITopic topic; DDS.ReturnCode rc; string expression; string[] ssHolder; string expResult = "QueryCondition test succeeded."; result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict .Pass, Test.Framework.TestVerdict.Fail); writer = (mod.tstDataWriter)this.ResolveObject("datawriter"); reader = (mod.tstDataReader)this.ResolveObject("datareader"); subscriber = (DDS.ISubscriber)this.ResolveObject("subscriber"); topic = (DDS.ITopic)this.ResolveObject("topic"); drQos = (DDS.DataReaderQos)this.ResolveObject("datareaderQos"); expression = "long_1=%0"; queryParams = new string[1]; queryParams[0] = "1"; condition = reader.CreateQueryCondition(DDS.SampleStateKind.Any, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Any, expression, queryParams); if (condition == null) { result.Result = "Could not create query condition."; return result; } waitset = new DDS.WaitSet(); rc = waitset.AttachCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "Could not attach condition."; return result; } reader2 = (mod.tstDataReader)subscriber.CreateDataReader(topic, drQos); //, null, 0); if (reader2 == null) { result.Result = "Could not create datareader."; return result; } rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed(3)."; return result; } if (activeConditions.Length != 0) { result.Result = "WaitSet.Wait returned conditions where it shouldn't (3)."; return result; } mod.tst data = new mod.tst(); data.long_1 = 2; data.long_2 = 2; data.long_3 = 3; rc = writer.Write(data, 0); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataWriter.write failed."; return result; } rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed(3)."; return result; } if (activeConditions.Length != 0) { result.Result = "WaitSet.Wait returned conditions where it shouldn't (4)."; return result; } data = new mod.tst(); data.long_1 = 1; data.long_2 = 2; data.long_3 = 3; rc = writer.Write(data, 0); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataWriter.write failed."; return result; } rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Ok) { result.Result = "WaitSet.Wait failed. "; return result; } if (activeConditions.Length != 1) { result.Result = "WaitSet.Wait returned no or multiple conditions where it should return one."; return result; } if (activeConditions[0] != condition) { result.Result = "WaitSet.Wait returned wrong condition."; return result; } rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Ok) { result.Result = "WaitSet.Wait failed(2)."; return result; } if (activeConditions.Length != 1) { result.Result = "WaitSet.Wait returned no or multiple conditions where it should return one(2)."; return result; } if (activeConditions[0] != condition) { result.Result = "WaitSet.Wait returned wrong condition(2)."; return result; } tstHolder = new mod.tst[0]; sampleInfoHolder = new DDS.SampleInfo[0]; rc = reader.TakeWithCondition(ref tstHolder, ref sampleInfoHolder, 1, condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataReader.take failed."; return result; } rc = reader.ReturnLoan(ref tstHolder, ref sampleInfoHolder); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataReader.return_loan failed."; return result; } rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed."; return result; } if (activeConditions.Length != 0) { result.Result = "WaitSet.Wait returned conditions where it shouldn't (2)."; return result; } rc = subscriber.DeleteDataReader(reader); if (rc == DDS.ReturnCode.Ok) { result.Result = "delete_datareader succeeded, but should not."; return result; } rc = waitset.GetConditions(ref activeConditions); if (rc != DDS.ReturnCode.Ok) { result.Result = "get_conditions failed."; return result; } if (activeConditions.Length != 1) { result.Result = "Returned conditions not valid."; return result; } if (activeConditions[0] != condition) { result.Result = "Returned condition does not equal set condition."; return result; } DDS.IDataReader reader3 = condition.GetDataReader(); if (reader != reader3) { result.Result = "ReadCondition.get_datareader failed."; return result; } if (condition.GetInstanceStateMask() != DDS.InstanceStateKind.Any) { result.Result = "ReadCondition.get_instance_state_mask failed."; return result; } if (condition.GetViewStateMask() != DDS.ViewStateKind.Any) { result.Result = "ReadCondition.get_view_state_mask failed."; return result; } if (condition.GetSampleStateMask() != DDS.SampleStateKind.Any) { result.Result = "ReadCondition.get_sample_state_mask failed."; return result; } rc = reader.DeleteReadCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "delete_readcondition failed."; return result; } rc = waitset.GetConditions(ref activeConditions); if (rc != DDS.ReturnCode.Ok) { result.Result = "get_conditions failed(2)."; return result; } if (activeConditions.Length != 0) { result.Result = "Returned conditions not valid(2)."; return result; } queryParams = new string[1]; queryParams[0] = "1"; condition = reader.CreateQueryCondition(DDS.SampleStateKind.Any, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Any, "long_1=%0", queryParams); if (condition == null) { result.Result = "Could not create query condition."; return result; } rc = waitset.AttachCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "Could not attach condition."; return result; } rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed(q1)."; return result; } if (activeConditions.Length != 0) { result.Result = "WaitSet.Wait returned conditions where it shouldn't (q1)."; return result; } data = new mod.tst(); data.long_1 = 1; data.long_2 = 2; data.long_3 = 3; rc = writer.Write(data, 0); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataWriter.write failed(2)."; return result; } rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Ok) { result.Result = "WaitSet.Wait failed (q2). "; return result; } if (activeConditions.Length != 1) { result.Result = "WaitSet.Wait returned no or multiple conditions where it should return one(q2)."; return result; } if (activeConditions[0] != condition) { result.Result = "WaitSet.Wait returned wrong condition(q2)."; return result; } rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Ok) { result.Result = "WaitSet.Wait failed(2)."; return result; } if (activeConditions.Length != 1) { result.Result = "WaitSet.Wait returned no or multiple conditions where it should return one(q3)."; return result; } if (activeConditions[0] != condition) { result.Result = "WaitSet.Wait returned wrong condition(q3)."; return result; } tstHolder = new mod.tst[0]; rc = reader.TakeWithCondition(ref tstHolder, ref sampleInfoHolder, 1, condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataReader.take failed(q1)."; return result; } rc = reader.ReturnLoan(ref tstHolder, ref sampleInfoHolder); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataReader.return_loan failed."; return result; } rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed(q5)."; return result; } if (activeConditions.Length != 0) { result.Result = "WaitSet.Wait returned conditions where it shouldn't (q6)."; return result; } string expression2 = condition.GetQueryExpression(); if (!expression.Equals(expression2)) { result.Result = "QueryCondition.get_query_expression does not work properly."; return result; } ssHolder = new string[0]; rc = condition.GetQueryParameters(ref ssHolder); if (rc != DDS.ReturnCode.Ok) { result.Result = "QueryCondition.get_query_parameters call failed."; return result; } string[] queryParams2 = ssHolder; if (queryParams2 == null) { result.Result = "QueryCondition.get_query_parameters does not work properly (1)."; return result; } if (queryParams2.Length != queryParams.Length) { result.Result = "QueryCondition.get_query_parameters does not work properly (2)."; return result; } if (!queryParams2[0].Equals(queryParams[0])) { result.Result = "QueryCondition.get_query_parameters does not work properly (3)."; return result; } queryParams[0] = "5"; rc = condition.SetQueryParameters(queryParams); if (rc != DDS.ReturnCode.Ok) { result.Result = "QueryCondition.set_query_parameters does not work properly."; return result; } rc = condition.GetQueryParameters(ref ssHolder); if (rc != DDS.ReturnCode.Ok) { result.Result = "QueryCondition.get_query_parameters call failed (1)."; return result; } queryParams2 = ssHolder; if (queryParams2 == null) { result.Result = "QueryCondition.get_query_parameters does not work properly (1)."; return result; } if (queryParams2.Length != queryParams.Length) { result.Result = "QueryCondition.get_query_parameters does not work properly (2)."; return result; } if (!queryParams2[0].Equals(queryParams[0])) { result.Result = "QueryCondition.get_query_parameters does not work properly (3)."; return result; } rc = condition.SetQueryParameters(null); if (rc == DDS.ReturnCode.Ok) { result.Result = "QueryCondition.set_query_parameters does not work properly (2)."; return result; } rc = reader.DeleteReadCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "delete_readcondition failed(q7)."; return result; } rc = waitset.GetConditions(ref activeConditions); if (rc != DDS.ReturnCode.Ok) { result.Result = "get_conditions failed(q7)."; return result; } if (activeConditions.Length != 0) { result.Result = "Returned conditions not valid(q7)."; return result; } rc = subscriber.DeleteDataReader(reader); if (rc != DDS.ReturnCode.Ok) { result.Result = "delete_datareader failed."; return result; } result.Result = expResult; result.Verdict = Test.Framework.TestVerdict.Pass; return result; }
public override Test.Framework.TestResult Run() { DDS.ISubscriber subscriber; mod.tstDataWriter writer; mod.tstDataReader reader; DDS.IStatusCondition subscriberCondition; DDS.WaitSet waitset; mod.tst[] tstHolder; DDS.ICondition[] conditionHolder; DDS.SampleInfo[] sampleInfoHolder; Test.Framework.TestResult result; DDS.ReturnCode rc; string expResult = "StatusCondition test succeeded."; result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict .Pass, Test.Framework.TestVerdict.Fail); subscriber = (DDS.ISubscriber)this.ResolveObject("subscriber"); writer = (mod.tstDataWriter)this.ResolveObject("datawriter"); reader = (mod.tstDataReader)this.ResolveObject("datareader"); subscriberCondition = subscriber.StatusCondition; if (subscriberCondition == null) { result.Result = "Could not resolve subscriber condition."; return result; } waitset = new DDS.WaitSet(); rc = waitset.AttachCondition(subscriberCondition); if (rc != DDS.ReturnCode.Ok) { result.Result = "Could not attach subscriber condition."; return result; } conditionHolder = new DDS.ICondition[0]; rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed."; return result; } if (conditionHolder.Length > 0) { result.Result = "WaitSet.Wait returned conditions where it shouldn't."; return result; } mod.tst data = new mod.tst(); data.long_1 = 1; data.long_2 = 2; data.long_3 = 3; rc = writer.Write(data, 0); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataWriter.write failed."; return result; } rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Ok) { result.Result = "WaitSet.Wait failed."; return result; } if (conditionHolder.Length < 1) { result.Result = "WaitSet.Wait returned no conditions where it should (1)."; return result; } if (conditionHolder[0] != subscriberCondition) { result.Result = "WaitSet.Wait returned wrong condition."; return result; } tstHolder = new mod.tst[0]; sampleInfoHolder = new DDS.SampleInfo[0]; rc = reader.Take(ref tstHolder, ref sampleInfoHolder, 1, DDS.SampleStateKind.Any, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Any); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataReader.take failed."; return result; } rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed(2)."; return result; } if (conditionHolder.Length > 0) { result.Result = "WaitSet.Wait returned conditions where it shouldn't (2)."; return result; } result.Result = expResult; result.Verdict = Test.Framework.TestVerdict.Pass; return result; }
public override Test.Framework.TestResult Run() { mod.tstDataWriter writer; mod.tstDataReader reader; mod.tstDataReader reader2; DDS.IReadCondition condition; DDS.WaitSet waitset; DDS.ISubscriber subscriber; DDS.ICondition[] activeConditions = null; Test.Framework.TestResult result; DDS.DataReaderQos drQos; mod.tst[] tstHolder; DDS.SampleInfo[] sampleInfoHolder; DDS.ITopic topic; DDS.ReturnCode rc; string expResult = "ReadCondition test succeeded."; result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict .Pass, Test.Framework.TestVerdict.Fail); writer = (mod.tstDataWriter) this.ResolveObject("datawriter"); reader = (mod.tstDataReader) this.ResolveObject("datareader"); subscriber = (DDS.ISubscriber) this.ResolveObject("subscriber"); topic = (DDS.ITopic) this.ResolveObject("topic"); drQos = (DDS.DataReaderQos) this.ResolveObject("datareaderQos"); condition = reader.CreateReadCondition(DDS.SampleStateKind.Any, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Any); if (condition == null) { result.Result = "Could not resolve reader condition."; return(result); } waitset = new DDS.WaitSet(); rc = waitset.AttachCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "Could not attach condition."; return(result); } reader2 = (mod.tstDataReader)subscriber.CreateDataReader(topic, drQos); //, null, 0); if (reader2 == null) { result.Result = "Could not create datareader."; return(result); } activeConditions = new DDS.Condition[0]; rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed(3)."; return(result); } if (activeConditions.Length != 0) { result.Result = "WaitSet.Wait returned conditions where it shouldn't (3)."; return(result); } mod.tst data = new mod.tst(); data.long_1 = 1; data.long_2 = 2; data.long_3 = 3; rc = writer.Write(data, 0); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataWriter.write failed."; return(result); } rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Ok) { result.Result = "WaitSet.Wait failed."; return(result); } if (activeConditions.Length != 1) { result.Result = "WaitSet.Wait returned no or multiple conditions where it should return one."; return(result); } if (activeConditions[0] != condition) { result.Result = "WaitSet.Wait returned wrong condition."; return(result); } rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Ok) { result.Result = "WaitSet.Wait failed(2)."; return(result); } if (activeConditions.Length != 1) { result.Result = "WaitSet.Wait returned no or multiple conditions where it should return one(2)."; return(result); } if (activeConditions[0] != condition) { result.Result = "WaitSet.Wait returned wrong condition(2)."; return(result); } tstHolder = new mod.tst[0]; sampleInfoHolder = new DDS.SampleInfo[0]; rc = reader.TakeWithCondition(ref tstHolder, ref sampleInfoHolder, 1, condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataReader.take failed."; return(result); } rc = reader.ReturnLoan(ref tstHolder, ref sampleInfoHolder); if (rc != DDS.ReturnCode.Ok) { result.Result = "tstDataReader.return_loan failed."; return(result); } rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed."; return(result); } if (activeConditions.Length != 0) { result.Result = "WaitSet.Wait returned conditions where it shouldn't (2)."; return(result); } rc = subscriber.DeleteDataReader(reader); if (rc == DDS.ReturnCode.Ok) { result.Result = "delete_datareader succeeded, but should not."; return(result); } rc = waitset.GetConditions(ref activeConditions); if (rc != DDS.ReturnCode.Ok) { result.Result = "get_conditions failed."; return(result); } if (activeConditions.Length != 1) { result.Result = "Returned conditions not valid."; return(result); } if (activeConditions[0] != condition) { result.Result = "Returned condition does not equal set condition."; return(result); } DDS.IDataReader reader3 = condition.GetDataReader(); if (reader != reader3) { result.Result = "ReadCondition.get_datareader failed."; return(result); } if (condition.GetInstanceStateMask() != DDS.InstanceStateKind.Any) { result.Result = "ReadCondition.get_instance_state_mask failed."; return(result); } if (condition.GetViewStateMask() != DDS.ViewStateKind.Any) { result.Result = "ReadCondition.get_view_state_mask failed."; return(result); } if (condition.GetSampleStateMask() != DDS.SampleStateKind.Any) { result.Result = "ReadCondition.get_sample_state_mask failed."; return(result); } rc = reader.DeleteReadCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "delete_readcondition failed."; return(result); } rc = waitset.GetConditions(ref activeConditions); if (rc != DDS.ReturnCode.Ok) { result.Result = "get_conditions failed(2)."; return(result); } if (activeConditions.Length != 0) { result.Result = "Returned conditions not valid(2)."; return(result); } rc = subscriber.DeleteDataReader(reader); if (rc != DDS.ReturnCode.Ok) { result.Result = "delete_datareader failed."; return(result); } result.Result = expResult; result.Verdict = Test.Framework.TestVerdict.Pass; return(result); }
public override Test.Framework.TestResult Run() { Test.Framework.TestResult result; Test.Framework.TestVerdict expVerdict = Test.Framework.TestVerdict.Pass; string expResult = "Resolving GuardCondition succeeded."; DDS.ICondition[] holder = null; DDS.ReturnCode[] resultCode = new DDS.ReturnCode[] { DDS.ReturnCode.Error, DDS.ReturnCode.Error, DDS.ReturnCode.Error }; DDS.ReturnCode ddsReturnCode; bool continueTesting = true; DDS.GuardCondition condition1 = (DDS.GuardCondition)ResolveObject("condition1"); DDS.GuardCondition condition2 = (DDS.GuardCondition)ResolveObject("condition2"); DDS.GuardCondition condition3 = (DDS.GuardCondition)ResolveObject("condition3"); DDS.WaitSet waitset = new DDS.WaitSet(); resultCode[0] = waitset.AttachCondition(condition1); resultCode[1] = waitset.AttachCondition(condition2); resultCode[2] = waitset.AttachCondition(condition3); if (resultCode[0] != 0 || resultCode[1] != 0 || resultCode[2] != 0) { result = new Test.Framework.TestResult("attached guardconditions to a waitset", "attach_condition returned RETCODE: " + resultCode[0] + " " + resultCode[1] + " " + resultCode[2], expVerdict, Test.Framework.TestVerdict.Fail); continueTesting = false; } else { result = new Test.Framework.TestResult(expResult, "get_conditions returned RETCODE_OK" , expVerdict, Test.Framework.TestVerdict.Pass); } if (continueTesting) { ddsReturnCode = waitset.GetConditions(ref holder); if (ddsReturnCode != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "get_conditions returned RETCODE: " + ddsReturnCode, expVerdict, Test.Framework.TestVerdict.Fail); } else { result = new Test.Framework.TestResult(expResult, "get_conditions returned RETCODE_OK" , expVerdict, Test.Framework.TestVerdict.Pass); } if (holder.Length != 3) { result = new Test.Framework.TestResult(expResult, "Did not resolve 3 GuardCondition objects" , expVerdict, Test.Framework.TestVerdict.Fail); } else { if ((holder[0] != condition1) && (holder[1] != condition1) && (holder[2] != condition1)) { result = new Test.Framework.TestResult(expResult, "Resolved GuardCondition objects not OK (1)" , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } if ((holder[0] != condition2) && (holder[1] != condition2) && (holder[2] != condition2)) { result = new Test.Framework.TestResult(expResult, "Resolved GuardCondition objects not OK (2)" , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } if ((holder[0] != condition3) && (holder[1] != condition3) && (holder[2] != condition3)) { result = new Test.Framework.TestResult(expResult, "Resolved GuardCondition objects not OK (3)" , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } result = new Test.Framework.TestResult(expResult, "Resolved 3 GuardCondition objects" , expVerdict, Test.Framework.TestVerdict.Pass); } } return(result); }
/* * P I N G */ public void run(String[] args) { System.Console.WriteLine("starting PING"); DDS.ICondition[] conditionList = null; DDS.IWaitSet w; DDS.DomainParticipantQos dpQos; DDS.TopicQos tQos; DDS.PublisherQos pQos; DDS.DataWriterQos dwQos; DDS.SubscriberQos sQos; DDS.DataReaderQos drQos; DDS.Duration wait_timeout = new DDS.Duration(3, 0); DDS.ReturnCode result; Boolean finish_flag = false; Boolean timeout_flag = false; Boolean terminate = false; int imax = 1; int i; uint block; int nof_cycles = 100; int nof_blocks = 20; /** * Command Line argument processing */ if (args.Length != 0) { if (args.Length != 5) { System.Console.WriteLine("Invalid....."); System.Console.WriteLine("Usage: ping blocks blocksize topic_id WRITE_PARTITION READ_PARTITION "); Environment.Exit(1); } nof_blocks = int.Parse(args[0]); nof_cycles = int.Parse(args[1]); topic_id = args[2][0]; write_partition = args[3]; read_partition = args[4]; } /* * Create WaitSet */ w = new DDS.WaitSet(); /* * Initialize Qos variables */ dpQos = new DDS.DomainParticipantQos(); tQos = new DDS.TopicQos(); pQos = new DDS.PublisherQos(); dwQos = new DDS.DataWriterQos(); sQos = new DDS.SubscriberQos(); drQos = new DDS.DataReaderQos(); /* * Create participant */ dpf = DDS.DomainParticipantFactory.Instance; dpf.GetDefaultParticipantQos(ref dpQos); ErrorHandler.checkHandle(dpf, "DDS.DomainParticipantFactory.Instance"); dp = dpf.CreateParticipant(myDomain, dpQos); if (dp == null) { System.Console.WriteLine("PING: ERROR - Splice Daemon not running"); return; } /* * Create PING publisher */ dp.GetDefaultPublisherQos(ref pQos); pQos.Partition.Name = new String[1]; pQos.Partition.Name[0] = write_partition; p = dp.CreatePublisher(pQos); /* * Create PONG subscriber */ dp.GetDefaultSubscriberQos(ref sQos); sQos.Partition.Name = new String[1]; sQos.Partition.Name[0] = read_partition; s = dp.CreateSubscriber(sQos); /* * Get default DataReader and DataWriter QoS settings */ p.GetDefaultDataWriterQos(ref dwQos); s.GetDefaultDataReaderQos(ref drQos); /* * Get default Topic Qos settings */ dp.GetDefaultTopicQos(ref tQos); /*match data reader/writer qos with topic qos*/ p.CopyFromTopicQos(ref dwQos, tQos); s.CopyFromTopicQos(ref drQos, tQos); /* * PP_min_msg */ /* Create Topic */ PP_min_dt = new pingpong.PP_min_msgTypeSupport(); PP_min_dt.RegisterType(dp, "pingpong::PP_min_msg"); PP_min_topic = dp.CreateTopic("PP_min_topic", "pingpong::PP_min_msg", tQos); /* Create datawriter */ PP_min_writer = p.CreateDataWriter(PP_min_topic, dwQos) as pingpong.PP_min_msgDataWriter; /* Create datareader */ PP_min_reader = s.CreateDataReader(PP_min_topic, drQos) as pingpong.PP_min_msgDataReader; /* Add datareader statuscondition to waitset */ PP_min_sc = PP_min_reader.StatusCondition; PP_min_sc.SetEnabledStatuses(DDS.StatusKind.DataAvailable); result = w.AttachCondition(PP_min_sc); ErrorHandler.checkStatus(result, "attach condition pp_min_reader"); //assert (result == RETCODE_OK.value); /* * PP_seq_msg */ /* Create Topic */ PP_seq_dt = new pingpong.PP_seq_msgTypeSupport(); PP_seq_dt.RegisterType(dp, "pingpong::PP_seq_msg"); PP_seq_topic = dp.CreateTopic("PP_seq_topic", "pingpong::PP_seq_msg", tQos); /* Create datawriter */ PP_seq_writer = p.CreateDataWriter(PP_seq_topic, dwQos) as pingpong.PP_seq_msgDataWriter; /* Create datareader */ PP_seq_reader = s.CreateDataReader(PP_seq_topic, drQos) as pingpong.PP_seq_msgDataReader; /* Add datareader statuscondition to waitset */ PP_seq_sc = PP_seq_reader.StatusCondition; PP_seq_sc.SetEnabledStatuses(DDS.StatusKind.DataAvailable); result = w.AttachCondition(PP_seq_sc); ErrorHandler.checkStatus(result, "attach condition pp_seq_reader"); //assert (result == RETCODE_OK.value); /* * PP_string_msg */ /* Create Topic */ PP_string_dt = new pingpong.PP_string_msgTypeSupport(); PP_string_dt.RegisterType(dp, "pingpong::PP_string_msg"); PP_string_topic = dp.CreateTopic("PP_string_topic", "pingpong::PP_string_msg", tQos); /* Create datawriter */ PP_string_writer = p.CreateDataWriter(PP_string_topic, dwQos) as pingpong.PP_string_msgDataWriter; /* Create datareader */ PP_string_reader = s.CreateDataReader(PP_string_topic, drQos) as pingpong.PP_string_msgDataReader; /* Add datareader statuscondition to waitset */ PP_string_sc = PP_string_reader.StatusCondition; PP_string_sc.SetEnabledStatuses(DDS.StatusKind.DataAvailable); result = w.AttachCondition(PP_string_sc); ErrorHandler.checkStatus(result, "attach condition pp_string_reader"); //assert (result == RETCODE_OK.value); /* * PP_fixed_msg */ /* Create Topic */ PP_fixed_dt = new pingpong.PP_fixed_msgTypeSupport(); PP_fixed_dt.RegisterType(dp, "pingpong::PP_fixed_msg"); PP_fixed_topic = dp.CreateTopic("PP_fixed_topic", "pingpong::PP_fixed_msg", tQos); /* Create datawriter */ PP_fixed_writer = p.CreateDataWriter(PP_fixed_topic, dwQos) as pingpong.PP_fixed_msgDataWriter; /* Create datareader */ PP_fixed_reader = s.CreateDataReader(PP_fixed_topic, drQos) as pingpong.PP_fixed_msgDataReader; /* Add datareader statuscondition to waitset */ PP_fixed_sc = PP_fixed_reader.StatusCondition; PP_fixed_sc.SetEnabledStatuses(DDS.StatusKind.DataAvailable); result = w.AttachCondition(PP_fixed_sc); ErrorHandler.checkStatus(result, "attach condition pp_fixed_reader"); //assert (result == RETCODE_OK.value); /* * PP_array_msg */ /* Create Topic */ PP_array_dt = new pingpong.PP_array_msgTypeSupport(); PP_array_dt.RegisterType(dp, "pingpong::PP_array_msg"); PP_array_topic = dp.CreateTopic("PP_array_topic", "pingpong::PP_array_msg", tQos); /* Create datawriter */ PP_array_writer = p.CreateDataWriter(PP_array_topic, dwQos) as pingpong.PP_array_msgDataWriter; /* Create datareader */ PP_array_reader = s.CreateDataReader(PP_array_topic, drQos) as pingpong.PP_array_msgDataReader; /* Add datareader statuscondition to waitset */ PP_array_sc = PP_array_reader.StatusCondition; PP_array_sc.SetEnabledStatuses(DDS.StatusKind.DataAvailable); result = w.AttachCondition(PP_array_sc); ErrorHandler.checkStatus(result, "attach condition pp_array_reader"); //assert (result == RETCODE_OK.value); /* * PP_quit_msg */ /* Create Topic */ PP_quit_dt = new pingpong.PP_quit_msgTypeSupport(); PP_quit_dt.RegisterType(dp, "pingpong::PP_quit_msg"); PP_quit_topic = dp.CreateTopic("PP_quit_topic", "pingpong::PP_quit_msg", tQos); /* Create datawriter */ PP_quit_writer = p.CreateDataWriter(PP_quit_topic, dwQos) as pingpong.PP_quit_msgDataWriter; for (block = 0; block < nof_blocks && !terminate; block++) { while (!finish_flag) { /* * Send Initial message */ timeout_flag = false; switch (topic_id) { case 'm': { /* System.Console.WriteLine ("PING: sending initial ping_min"); */ pingpong.PP_min_msg PPdata = new pingpong.PP_min_msg(); PPdata.count = 0; PPdata.block = block; preWriteTime.timeGet(); result = PP_min_writer.Write(PPdata); postWriteTime.timeGet(); } break; case 'q': { /* System.Console.WriteLine ("PING: sending initial ping_seq"); */ pingpong.PP_seq_msg PPdata = new pingpong.PP_seq_msg(); PPdata.count = 0; PPdata.block = block; preWriteTime.timeGet(); result = PP_seq_writer.Write(PPdata); postWriteTime.timeGet(); } break; case 's': { //System.Console.WriteLine ("PING: sending initial ping_string"); pingpong.PP_string_msg PPdata = new pingpong.PP_string_msg(); PPdata.count = 0; PPdata.block = block; PPdata.a_string = "a_string " + block.ToString(); preWriteTime.timeGet(); result = PP_string_writer.Write(PPdata); ErrorHandler.checkStatus(result, "writing PPData in case S"); postWriteTime.timeGet(); } break; case 'f': { /* System.Console.WriteLine ("PING: sending initial ping_fixed"); */ pingpong.PP_fixed_msg PPdata = new pingpong.PP_fixed_msg(); PPdata.count = 0; PPdata.block = block; preWriteTime.timeGet(); result = PP_fixed_writer .Write(PPdata); postWriteTime.timeGet(); } break; case 'a': { /* System.Console.WriteLine ("PING: sending initial ping_array"); */ pingpong.PP_array_msg PPdata = new pingpong.PP_array_msg(); PPdata.count = 0; PPdata.block = block; PPdata.str_arr_char = new char[10]; PPdata.str_arr_octet = new byte[10]; PPdata.str_arr_short = new short[10]; PPdata.str_arr_ushort = new ushort[10]; PPdata.str_arr_long = new int[10]; PPdata.str_arr_ulong = new uint[10]; PPdata.str_arr_longlong = new long[10]; PPdata.str_arr_ulonglong = new ulong[10]; PPdata.str_arr_float = new float[10]; PPdata.str_arr_double = new double[10]; PPdata.str_arr_boolean = new Boolean[11]; preWriteTime.timeGet(); result = PP_array_writer .Write(PPdata); postWriteTime.timeGet(); } break; case 't': { /* System.Console.WriteLine ("PING: sending initial ping_quit"); */ pingpong.PP_quit_msg PPdata = new pingpong.PP_quit_msg(); PPdata.quit = true; terminate = true; finish_flag = true; System.Threading.Thread.Sleep(1000); preWriteTime.timeGet(); result = PP_quit_writer.Write(PPdata); postWriteTime.timeGet(); System.Threading.Thread.Sleep(1000); } break; default: System.Console.WriteLine("Invalid topic-id"); return; } if (!terminate) { roundTripTime.set(preWriteTime.get()); write_access.add_stats(postWriteTime.sub(preWriteTime)); /* * Wait for response, calculate timing, and send another * data if not ready */ while (!(timeout_flag || finish_flag)) { result = w.Wait(ref conditionList, wait_timeout); if (result == DDS.ReturnCode.Ok || result == DDS.ReturnCode.NoData || result == DDS.ReturnCode.Timeout) { //ErrorHandler.checkStatus(result, "wait did not work condition list is probably null!"); if (conditionList != null) { imax = conditionList.Length; if (imax != 0) { for (i = 0; i < imax; i++) { if (conditionList[i] == PP_min_sc) { finish_flag = PP_min_handler(nof_cycles); } else if (conditionList[i] == PP_seq_sc) { finish_flag = PP_seq_handler(nof_cycles); } else if (conditionList[i] == PP_string_sc) { finish_flag = PP_string_handler(nof_cycles); } else if (conditionList[i] == PP_fixed_sc) { finish_flag = PP_fixed_handler(nof_cycles); } else if (conditionList[i] == PP_array_sc) { finish_flag = PP_array_handler(nof_cycles); } else { System.Console.WriteLine("PING: unexpected condition triggered: " + conditionList[i]); } } } else { System.Console.WriteLine("PING: TIMEOUT - message lost (1)"); timeout_flag = true; } } else { System.Console.WriteLine("PING: TIMEOUT - message lost (2)"); timeout_flag = true; } } else { System.Console.WriteLine("PING: Waitset wait failed (code " + result + "), terminating"); finish_flag = true; terminate = true; } } } } if (!terminate) { finish_flag = false; if (block == 0) { System.Console.WriteLine("# PING PONG measurements (in us)"); System.Console.WriteLine("# Executed at: "); System.Console.WriteLine("# Roundtrip time [us] Write-access time [us] Read-access time [us]"); System.Console.WriteLine("# Block Count mean min max Count mean min max Count mean min max"); } System.Console.WriteLine(String.Format("{0,-6} {1, 10} {2, 6} {3, 6} {4, 6} {5, 10} {6, 6} {7, 6} {8, 6} {9, 10} {10, 6} {11, 6} {12, 6}", block, roundtrip.count, roundtrip.average, roundtrip.min, roundtrip.max, write_access.count, write_access.average, write_access.min, write_access.max, read_access.count, read_access.average, read_access.min, read_access.max)); Console.Out.Flush(); write_access.init_stats(); read_access.init_stats(); roundtrip.init_stats(); } } result = s.DeleteDataReader(PP_min_reader); result = p.DeleteDataWriter(PP_min_writer); result = s.DeleteDataReader(PP_seq_reader); result = p.DeleteDataWriter(PP_seq_writer); result = s.DeleteDataReader(PP_string_reader); result = p.DeleteDataWriter(PP_string_writer); result = s.DeleteDataReader(PP_fixed_reader); result = p.DeleteDataWriter(PP_fixed_writer); result = s.DeleteDataReader(PP_array_reader); result = p.DeleteDataWriter(PP_array_writer); result = p.DeleteDataWriter(PP_quit_writer); result = dp.DeleteSubscriber(s); result = dp.DeletePublisher(p); result = dp.DeleteTopic(PP_min_topic); result = dp.DeleteTopic(PP_seq_topic); result = dp.DeleteTopic(PP_string_topic); result = dp.DeleteTopic(PP_fixed_topic); result = dp.DeleteTopic(PP_array_topic); result = dp.DeleteTopic(PP_quit_topic); result = dpf.DeleteParticipant(dp); return; }
public override Test.Framework.TestResult Run() { mod.tstDataWriter writer; mod.tstDataReader reader; mod.tstDataReader reader2; DDS.IStatusCondition condition; DDS.WaitSet waitset; DDS.ISubscriber subscriber; DDS.ICondition[] conditionHolder; Test.Framework.TestResult result; DDS.DataReaderQos drQos; DDS.ITopic topic; DDS.ReturnCode rc; string expResult = "StatusCondition test succeeded."; result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict .Pass, Test.Framework.TestVerdict.Fail); writer = (mod.tstDataWriter)this.ResolveObject("datawriter"); reader = (mod.tstDataReader)this.ResolveObject("datareader"); subscriber = (DDS.ISubscriber)this.ResolveObject("subscriber"); topic = (DDS.ITopic)this.ResolveObject("topic"); drQos = (DDS.DataReaderQos)this.ResolveObject("datareaderQos"); condition = writer.StatusCondition; if (condition == null) { result.Result = "Could not resolve reader condition."; return result; } waitset = new DDS.WaitSet(); rc = waitset.AttachCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "Could not attach condition."; return result; } reader2 = (mod.tstDataReader)subscriber.CreateDataReader(topic, drQos);//, null, 0); if (reader2 == null) { result.Result = "Could not create datareader."; return result; } conditionHolder = new DDS.ICondition[0]; rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed."; return result; } if (conditionHolder.Length != 0) { this.PrintStatusses(writer); result.Result = "WaitSet.Wait returned conditions where it shouldn't (2)."; return result; } rc = subscriber.DeleteDataReader(reader); if (rc != DDS.ReturnCode.Ok) { result.Result = "delete_datareader failed."; return result; } rc = waitset.Wait(ref conditionHolder, new DDS.Duration(3, 0)); if (rc != DDS.ReturnCode.Timeout) { result.Result = "WaitSet.Wait failed(3)."; return result; } if (conditionHolder.Length > 0) { PrintStatusses(writer); result.Result = "WaitSet.Wait returned conditions where it shouldn't.(3)"; return result; } result.Result = expResult; result.Verdict = Test.Framework.TestVerdict.Pass; return result; }