| 12 | |
| 13 | template<class Tseq, class R, class R_var, class R_ptr> |
| 14 | ::DDS::ReturnCode_t read (TestStats* stats, |
| 15 | ::DDS::Subscriber_ptr subscriber, |
| 16 | ::DDS::DataReader_ptr reader) |
| 17 | { |
| 18 | R_var pt_dr |
| 19 | = R::_narrow(reader); |
| 20 | if (CORBA::is_nil (pt_dr.in ())) |
| 21 | { |
| 22 | ACE_ERROR ((LM_ERROR, |
| 23 | ACE_TEXT("(%P|%t) _narrow failed.\n"))); |
| 24 | throw TestException() ; |
| 25 | } |
| 26 | |
| 27 | const ::CORBA::Long max_read_samples = 100; |
| 28 | Tseq samples(max_read_samples); |
| 29 | ::DDS::SampleInfoSeq infos(max_read_samples); |
| 30 | |
| 31 | // wait for data to become available |
| 32 | // so we know to start reading |
| 33 | if (!Reader::wait_for_data(subscriber, 10)) |
| 34 | ACE_ERROR_RETURN((LM_ERROR, |
| 35 | "ERROR: waited too long for the first sample\n"), |
| 36 | -2); |
| 37 | |
| 38 | int num_reads = 0; |
| 39 | int zero_reads = 0; |
| 40 | int samples_recvd = 0; |
| 41 | DDS::ReturnCode_t status; |
| 42 | // initialize to zero. |
| 43 | ::DDS::SampleRejectedStatus rejected; |
| 44 | ::DDS::SampleLostStatus lost; |
| 45 | if ((pt_dr->get_sample_rejected_status (rejected) != ::DDS::RETCODE_OK) |
| 46 | || (pt_dr->get_sample_lost_status (lost) != ::DDS::RETCODE_OK)) |
| 47 | { |
| 48 | ACE_ERROR((LM_ERROR,"ERROR: Failed to get sample reject or lost status.\n")); |
| 49 | ACE_OS::exit (7); |
| 50 | } |
| 51 | |
| 52 | while ( !stats->all_packets_received () ) |
| 53 | { |
| 54 | |
| 55 | status = pt_dr->read ( |
| 56 | samples, |
| 57 | infos, |
| 58 | max_read_samples, |
| 59 | ::DDS::NOT_READ_SAMPLE_STATE, |
| 60 | ::DDS::ANY_VIEW_STATE, |
| 61 | ::DDS::ANY_INSTANCE_STATE); |
| 62 | //TBD do the right thing here. |
| 63 | |
| 64 | |
| 65 | if (status == ::DDS::RETCODE_OK) |
| 66 | { |
| 67 | num_reads++; |
| 68 | //if (samples.length () < 5) |
| 69 | // ACE_DEBUG((LM_DEBUG,"got just %d samples\n", samples.length ())); |
| 70 | stats->samples_received(samples.length ()); |
| 71 | samples_recvd += samples.length (); |
nothing calls this directly
no test coverage detected