From 1274d42682870ec16f2cd840d513fbfcd60dad43 Mon Sep 17 00:00:00 2001 From: mcorino Date: Fri, 17 Dec 2010 15:09:42 +0000 Subject: Fri Dec 17 15:01:53 UTC 2010 Martin Corino * */*.*: Merged RemedyWork branch. --- .../Shapes/Receiver/I2C_Shapes_Receiver.cpp | 98 ++++++++++++++++++++++ .../Shapes/Receiver/I2C_Shapes_Receiver.mpc | 21 +++++ 2 files changed, 119 insertions(+) create mode 100755 CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Receiver/I2C_Shapes_Receiver.cpp create mode 100755 CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Receiver/I2C_Shapes_Receiver.mpc (limited to 'CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Receiver') diff --git a/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Receiver/I2C_Shapes_Receiver.cpp b/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Receiver/I2C_Shapes_Receiver.cpp new file mode 100755 index 00000000000..fb39c89d298 --- /dev/null +++ b/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Receiver/I2C_Shapes_Receiver.cpp @@ -0,0 +1,98 @@ +// $Id$ + +#include "Common/I2C_Shapes_Common.h" +#include "connectors/dds4ccm/impl/ndds/DataReader_T.h" + +#include "ace/OS_NS_unistd.h" + +typedef ::CIAO::NDDS::DataReader_T + ShapesDataReader; + +void +read (ShapesDataReader* shapes_dr) +{ + int samples_received = 0; + if (shapes_dr) + { + while (samples_received < 1000) + { + //start to read + ShapeTypeSeq data; + ::DDS::SampleInfoSeq info; + ::DDS::ReturnCode_t retcode = shapes_dr->read ( + data, + info, + ::DDS::LENGTH_UNLIMITED, + ::DDS::NOT_READ_SAMPLE_STATE, + ::DDS::ANY_VIEW_STATE, + ::DDS::ALIVE_INSTANCE_STATE); + samples_received += data.length (); + if (retcode == ::DDS::RETCODE_OK) + { + for (::CORBA::ULong i = 0; i < data.length (); ++i) + { + ACE_DEBUG ((LM_DEBUG, "read - " + "Received sample: x <%u> - y <%u>\n", + data[i].x, + data[i].y)); + } + } + else if (retcode != ::DDS::RETCODE_NO_DATA) + { + ACE_ERROR ((LM_ERROR, "Receiver_exec_i::start_read_using_idl_proxy - " + "ERROR: Error during read\n")); + } + ACE_Time_Value tv (0, 50); + ACE_OS::sleep (tv); + } + ACE_DEBUG ((LM_DEBUG, "read - Ready\n")); + } + else + { + ACE_ERROR ((LM_ERROR, "read- ERROR: DataReader seems to be nil\n")); + } +} + +int ACE_TMAIN (int , ACE_TCHAR *[]) +{ + int main_result = 0; + + I2C_Shapes_Common common; + + try + { + ::DDS::Subscriber_var subscriber; + subscriber = common.create_subscriber (); + if (::CORBA::is_nil (subscriber.in ())) + { + ACE_ERROR ((LM_ERROR, "ACE_TMAIN - Subscriber seems to be nil\n")); + throw ::CORBA::INTERNAL (); + } + + ::DDS::Topic_var topic = common.get_topic (); + ::DDS::DataReader_var dr; + ::DDS::DataReaderQos dqos; + dr = subscriber->create_datareader (topic.in (), + dqos, + ::DDS::DataReaderListener::_nil (), + 0); + + ShapesDataReader * shapes_dr = dynamic_cast (dr.in ()); + read (shapes_dr); + } + catch (::CORBA::Exception &e) + { + e._tao_print_exception ("ACE_TMAIN RECEIVER"); + } + catch (...) + { + ACE_ERROR ((LM_ERROR, "ACE_TMAIN RECEIVER - " + "Error: unexpected exception caught\n")); + } + + return main_result; +} diff --git a/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Receiver/I2C_Shapes_Receiver.mpc b/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Receiver/I2C_Shapes_Receiver.mpc new file mode 100755 index 00000000000..8e4b2a14897 --- /dev/null +++ b/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Receiver/I2C_Shapes_Receiver.mpc @@ -0,0 +1,21 @@ +// $Id$ + +project(*i2c_shapes_receiver) : ndds_impl, dds4ccm_stub, dds4ccm_ts_default { + exename = I2C_Shapes_Receiver + after += I2C_Shapes_Base_Stub I2C_Shapes_Connector_stub I2C_Shapes_Common + + includes += .. $(CIAO_ROOT) $(CIAO_ROOT)/connectors + + libs += I2C_Shapes_Base_stub I2C_Shapes_Connector_stub I2C_Shapes_Common + libpaths += ../lib + + exeout += ../lib + + Source_Files { + I2C_Shapes_Receiver.cpp + } + + Header_Files { + } +} + -- cgit v1.2.1