#include <BuiltInTopicUtils.h>
Public Member Functions | |
DDS::ReturnCode_t | instance_handle_to_bit_data (DomainParticipantImpl *dp, const char *bit_name, const DDS::InstanceHandle_t &handle, BIT_DataSeq &data) |
Definition at line 62 of file BuiltInTopicUtils.h.
DDS::ReturnCode_t OpenDDS::DCPS::BIT_Helper_1< BIT_Reader, BIT_Reader_var, BIT_DataSeq >::instance_handle_to_bit_data | ( | DomainParticipantImpl * | dp, | |
const char * | bit_name, | |||
const DDS::InstanceHandle_t & | handle, | |||
BIT_DataSeq & | data | |||
) | [inline] |
Definition at line 64 of file BuiltInTopicUtils.h.
References DDS::ANY_INSTANCE_STATE, DDS::ANY_SAMPLE_STATE, DDS::ANY_VIEW_STATE, OpenDDS::DCPS::DCPS_debug_level, OpenDDS::DCPS::DomainParticipantImpl::get_builtin_subscriber(), DDS::LENGTH_UNLIMITED, DDS::RETCODE_ERROR, DDS::RETCODE_NO_DATA, DDS::RETCODE_OK, DDS::RETCODE_TIMEOUT, and TheServiceParticipant.
00069 { 00070 DDS::Subscriber_var bit_subscriber = dp->get_builtin_subscriber(); 00071 00072 DDS::DataReader_var reader = 00073 bit_subscriber->lookup_datareader(bit_name); 00074 00075 BIT_Reader_var bit_reader = BIT_Reader::_narrow(reader.in()); 00076 00077 ACE_Time_Value due = ACE_OS::gettimeofday() + 00078 ACE_Time_Value(TheServiceParticipant->bit_lookup_duration_msec() / 1000, 00079 (TheServiceParticipant->bit_lookup_duration_msec() % 1000)*1000); 00080 00081 DDS::ReturnCode_t ret = DDS::RETCODE_OK; 00082 00083 // Look for the data from builtin topic datareader until we get results or 00084 // timeout. 00085 // This is to resolve the problem of lookup return nothing. This could happen 00086 // when the add_association is called before the builtin topic datareader got 00087 // the published data. 00088 while (1) { 00089 DDS::SampleInfoSeq the_info; 00090 BIT_DataSeq the_data; 00091 ret = bit_reader->read_instance(the_data, 00092 the_info, 00093 DDS::LENGTH_UNLIMITED, // zero-copy 00094 handle, 00095 DDS::ANY_SAMPLE_STATE, 00096 DDS::ANY_VIEW_STATE, 00097 DDS::ANY_INSTANCE_STATE); 00098 00099 if (ret != DDS::RETCODE_OK && ret != DDS::RETCODE_NO_DATA) { 00100 ACE_ERROR_RETURN((LM_ERROR, 00101 ACE_TEXT("(%P|%t) ERROR: BIT_Helper::instance_handle_to_repo_id, ") 00102 ACE_TEXT(" read instance 0x%x returned error %d. \n"), 00103 handle, ret), 00104 ret); 00105 } 00106 00107 if (ret == DDS::RETCODE_OK) { 00108 data.length(1); 00109 data[0] = the_data[0]; 00110 return ret; 00111 } 00112 00113 ACE_Time_Value now = ACE_OS::gettimeofday(); 00114 00115 if (now < due) { 00116 if (DCPS_debug_level >= 10) 00117 ACE_DEBUG((LM_DEBUG, 00118 ACE_TEXT("(%P|%t) BIT_Helper::instance_handle_to_repo_id, ") 00119 ACE_TEXT(" BIT reader read_instance failed - trying again. \n"))); 00120 00121 ACE_Time_Value tv = due - now; 00122 00123 if (tv > ACE_Time_Value(0, 100000)) { 00124 tv = ACE_Time_Value(0, 100000); 00125 } 00126 00127 ACE_OS::sleep(tv); 00128 00129 } else { 00130 ACE_ERROR_RETURN((LM_ERROR, 00131 ACE_TEXT("(%P|%t) ERROR: BIT_Helper::instance_handle_to_repo_id, ") 00132 ACE_TEXT(" timeout. \n")), 00133 DDS::RETCODE_ERROR); 00134 return DDS::RETCODE_TIMEOUT; 00135 } 00136 } 00137 }