// -*- C++ -*- // // $Id: DataReaderListener.cpp 889 2007-06-29 21:55:06Z johnc $ #include "DataReaderListener.h" #include "PortTypeSupportC.h" #include "PortTypeSupportImpl.h" #include #include using namespace IOTest; // Implementation skeleton constructor DataReaderListenerImpl::DataReaderListenerImpl() { } // Implementation skeleton destructor DataReaderListenerImpl::~DataReaderListenerImpl () { } void DataReaderListenerImpl::on_data_available(DDS::DataReader_ptr reader) throw (CORBA::SystemException) { try { // fprintf(stderr, "1\n"); fflush(stderr); ::IOTest::PortDataReader_var port_dr = ::IOTest::PortDataReader::_narrow(reader); if (CORBA::is_nil (port_dr.in ())) { cerr << "read: _narrow failed." << endl; exit(1); } // fprintf(stderr, "2\n"); fflush(stderr); IOTest::Port port_obj; DDS::SampleInfo si ; DDS::ReturnCode_t status = port_dr->take_next_sample(port_obj, si) ; // fprintf(stderr, "3\n"); fflush(stderr); if (status == DDS::RETCODE_OK) { // cout << "Port: no: = " << port_obj.no << endl // << " value: = " << port_obj.value << endl; // cout << " sample_rank = " << si.sample_rank << endl; if(port_obj.no == 1) io.set(port_obj.value); } else if (status == DDS::RETCODE_NO_DATA) { cerr << "ERROR: reader received DDS::RETCODE_NO_DATA!" << endl; } else { cerr << "ERROR: read Message: Error: " << status << endl; } } catch (CORBA::Exception& e) { cerr << "Exception caught in read:" << endl << e << endl; exit(1); } } void DataReaderListenerImpl::on_requested_deadline_missed ( DDS::DataReader_ptr, const DDS::RequestedDeadlineMissedStatus &) throw (CORBA::SystemException) { cerr << "DataReaderListenerImpl::on_requested_deadline_missed" << endl; } void DataReaderListenerImpl::on_requested_incompatible_qos ( DDS::DataReader_ptr, const DDS::RequestedIncompatibleQosStatus &) throw (CORBA::SystemException) { cerr << "DataReaderListenerImpl::on_requested_incompatible_qos" << endl; } void DataReaderListenerImpl::on_liveliness_changed ( DDS::DataReader_ptr, const DDS::LivelinessChangedStatus &) throw (CORBA::SystemException) { cerr << "DataReaderListenerImpl::on_liveliness_changed" << endl; } void DataReaderListenerImpl::on_subscription_match ( DDS::DataReader_ptr, const DDS::SubscriptionMatchStatus &) throw (CORBA::SystemException) { cerr << "DataReaderListenerImpl::on_subscription_match" << endl; } void DataReaderListenerImpl::on_sample_rejected( DDS::DataReader_ptr, const DDS::SampleRejectedStatus&) throw (CORBA::SystemException) { cerr << "DataReaderListenerImpl::on_sample_rejected" << endl; } void DataReaderListenerImpl::on_sample_lost( DDS::DataReader_ptr, const DDS::SampleLostStatus&) throw (CORBA::SystemException) { cerr << "DataReaderListenerImpl::on_sample_lost" << endl; }