diff options
author | mcorino <mcorino@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2010-12-17 15:09:42 +0000 |
---|---|---|
committer | mcorino <mcorino@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2010-12-17 15:09:42 +0000 |
commit | 1274d42682870ec16f2cd840d513fbfcd60dad43 (patch) | |
tree | d0c0dc6058b781b6025a8670187a48717c1f860a /CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes | |
parent | 338d7c0a7f427fe586c3637b0b3b06a72e4e2de9 (diff) | |
download | ATCD-1274d42682870ec16f2cd840d513fbfcd60dad43.tar.gz |
Fri Dec 17 15:01:53 UTC 2010 Martin Corino <mcorino@remedy.nl>
* */*.*:
Merged RemedyWork branch.
Diffstat (limited to 'CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes')
14 files changed, 696 insertions, 0 deletions
diff --git a/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Base/I2C_Shapes_Base.idl b/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Base/I2C_Shapes_Base.idl new file mode 100755 index 00000000000..667074f80c5 --- /dev/null +++ b/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Base/I2C_Shapes_Base.idl @@ -0,0 +1,25 @@ +// $Id$ + +/** + * @file I2C_Shapes_Base.idl + * @author Marcel Smit <msmit@remedy.nl> + */ + +#ifndef I2C_SHAPES_BASE_IDL +#define I2C_SHAPES_BASE_IDL + +struct ShapeType { + string color; //@key + long x; + long y; + long shapesize; +}; + +struct Attributes { + string shape; //@key + string color; //@key + float speed; +}; +typedef sequence<ShapeType> ShapeTypeSeq; + +#endif /* I2C_SHAPES_BASE_IDL */ diff --git a/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Base/I2C_Shapes_Base.mpc b/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Base/I2C_Shapes_Base.mpc new file mode 100755 index 00000000000..708ea1bdd0f --- /dev/null +++ b/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Base/I2C_Shapes_Base.mpc @@ -0,0 +1,24 @@ +// $Id$ + +project(I2C_Shapes_Base_stub) : taoidldefaults, dds4ccm_ts_default { + sharedname = I2C_Shapes_Base_stub + dynamicflags += SHAPES_BASE_STUB_BUILD_DLL + libout = ../lib + + idlflags += -SS -Sci \ + -Wb,stub_export_macro=SHAPES_BASE_STUB_Export \ + -Wb,stub_export_include=Shapes_Base_stub_export.h + + IDL_Files { + idlflags += -Gxhst + I2C_Shapes_Base.idl + } + + DDSGenerator_Files { + I2C_Shapes_Base.idl + } + + Source_Files { + } +} + diff --git a/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Common/I2C_Shapes_Common.cpp b/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Common/I2C_Shapes_Common.cpp new file mode 100755 index 00000000000..27f03b8e9cb --- /dev/null +++ b/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Common/I2C_Shapes_Common.cpp @@ -0,0 +1,131 @@ +// $Id$ + +#include "I2C_Shapes_Common.h" + +#include "ace/Env_Value_T.h" + +#include "connectors/dds4ccm/impl/ndds/DomainParticipant.h" +#include "connectors/dds4ccm/impl/logger/Log_Macros.h" + +#define TOPIC_NAME "Square" + + +I2C_Shapes_Common::I2C_Shapes_Common (void) + : factory_ (0) +{ + ACE_Env_Value<int> trace (ACE_TEXT("DDS4CCM_TRACE_ENABLE"), 0); + if (trace) + { + DDS4CCM_ENABLE_TRACE (); + } + else + { + DDS4CCM_DISABLE_TRACE (); + } + +} + +I2C_Shapes_Common::~I2C_Shapes_Common (void) +{ + if (this->factory_) + { + delete this->factory_; + } +} + +int +I2C_Shapes_Common::get_domain_id (void) +{ + int domain_id = 0; + ACE_Env_Value<int> id (ACE_TEXT("DDS4CCM_DEFAULT_DOMAIN_ID"), domain_id); + return id; +} + +void +I2C_Shapes_Common::initialize (void) +{ + ::DDS::DomainParticipantQos dp_qos; + this->participant_ = this->participant_factory_.create_participant ( + this->get_domain_id (), + dp_qos, + ::DDS::DomainParticipantListener::_nil (), + 0); + + ::CIAO::NDDS::DDS_DomainParticipant_i *part = + dynamic_cast< CIAO::NDDS::DDS_DomainParticipant_i * > (this->participant_.in ()); + if (!part) + { + DDS4CCM_ERROR (DDS4CCM_LOG_LEVEL_ERROR, (LM_ERROR, DDS4CCM_INFO + "I2C_Shapes_Common::initialize - Unable to cast the " + "DomainParticipant proxy to its internal representation.\n")); + throw ::CORBA::INTERNAL (); + } + + ACE_NEW_THROW_EX (this->factory_, + dds_type_factory (), + ::CORBA::NO_MEMORY ()); + + const char* typesupport_name = ShapeType_DDS_Traits::type_support::get_type_name (); + + ::CIAO::NDDS::DDS_TypeSupport_i::register_type (typesupport_name, + this->factory_, + this->participant_); + + ::DDS::ReturnCode_t retcode = ShapeType_DDS_Traits::type_support::register_type ( + part->get_rti_entity (), + typesupport_name); + if (retcode != ::DDS::RETCODE_OK) + { + DDS4CCM_ERROR (DDS4CCM_LOG_LEVEL_ERROR, (LM_ERROR, DDS4CCM_INFO + "I2C_Shapes_Common::initialize - Unable to register type\n")); + throw ::CORBA::INTERNAL (); + } + ::DDS::TopicQos tqos; + this->topic_ = this->participant_->create_topic (TOPIC_NAME, + typesupport_name, + tqos, + ::DDS::TopicListener::_nil (), + 0); + if (::CORBA::is_nil (this->topic_.in ())) + { + ACE_ERROR ((LM_ERROR, "I2C_Shapes_Common::initialize - " + "Topic seems to be nil\n")); + throw ::CORBA::INTERNAL (); + } +} + +::DDS::Topic_ptr +I2C_Shapes_Common::get_topic (void) +{ + return ::DDS::Topic::_duplicate (this->topic_.in ()); +} + +::DDS::Publisher_ptr +I2C_Shapes_Common::create_publisher (void) +{ + if (::CORBA::is_nil (participant_.in ())) + { + initialize(); + } + ::DDS::Publisher_var publisher; + ::DDS::PublisherQos pqos; + publisher = participant_->create_publisher (pqos, + ::DDS::PublisherListener::_nil (), + 0); + return publisher._retn (); +} + +::DDS::Subscriber_ptr +I2C_Shapes_Common::create_subscriber (void) +{ + if (::CORBA::is_nil (participant_.in ())) + { + initialize(); + } + ::DDS::Subscriber_var subscriber; + ::DDS::SubscriberQos sqos; + subscriber = participant_->create_subscriber (sqos, + ::DDS::SubscriberListener::_nil (), + 0); + return subscriber._retn (); +} diff --git a/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Common/I2C_Shapes_Common.h b/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Common/I2C_Shapes_Common.h new file mode 100755 index 00000000000..29efe23f274 --- /dev/null +++ b/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Common/I2C_Shapes_Common.h @@ -0,0 +1,52 @@ +// $Id$ + +#ifndef I2C_SHAPES_COMMON_H_ +#define I2C_SHAPES_COMMON_H_ + +#include "I2C_Shapes_Common_export.h" +#include "Connector/I2C_Shapes_Traits.h" +#include "connectors/dds4ccm/impl/ndds/DomainParticipant.h" +#include "connectors/dds4ccm/impl/ndds/DomainParticipantFactory.h" +#include "connectors/dds4ccm/impl/ndds/TypeSupport.h" + +/** + * Pulse generator + */ + +class I2C_SHAPES_Export I2C_Shapes_Common +{ +public: + I2C_Shapes_Common (); + ~I2C_Shapes_Common (); + + //@{ + /** Public methods. */ + ::DDS::Publisher_ptr create_publisher (void); + ::DDS::Subscriber_ptr create_subscriber (void); + //@} + + //@{ + /** Getters. */ + ::DDS::Topic_ptr get_topic (void); + //@} + +private: + typedef ::CIAO::NDDS::DDS_TypeFactory_T <ShapeType_DDS_Traits, + ShapeTypeSeq> dds_type_factory; + + //@{ + /** Members. */ + ::CIAO::NDDS::DDS_DomainParticipantFactory_i participant_factory_; + ::DDS::DomainParticipant_var participant_; + ::CIAO::NDDS::DDS_TypeFactory_i * factory_; + ::DDS::Topic_var topic_; + //@} + + //@{ + /** Private methods. */ + int get_domain_id (void); + void initialize (void); + //@} +}; + +#endif /* I2C_SHAPES_COMMON_H_ */ diff --git a/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Common/I2C_Shapes_Common.mpc b/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Common/I2C_Shapes_Common.mpc new file mode 100755 index 00000000000..d326296f72e --- /dev/null +++ b/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Common/I2C_Shapes_Common.mpc @@ -0,0 +1,23 @@ +// $Id$ + +project(I2C_Shapes_Common) : ndds_impl, dds4ccm_stub, dds4ccm_logger, dds4ccm_ts_default { + sharedname = I2C_Shapes_Common + dynamicflags += I2C_SHAPES_COMMON_BUILD_DLL + + after += I2C_Shapes_Base_stub I2C_Shapes_Connector_stub + libs += I2C_Shapes_Base_stub I2C_Shapes_Connector_stub + + libout = ../lib + libpaths += ../lib + + includes += .. $(CIAO_ROOT) $(CIAO_ROOT)/connectors + + Header_Files { + I2C_Shapes_Common.h + I2C_Shapes_Common_export.h + } + + Source_Files { + I2C_Shapes_Common.cpp + } +} diff --git a/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Common/I2C_Shapes_Common_export.h b/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Common/I2C_Shapes_Common_export.h new file mode 100755 index 00000000000..09ef5391f22 --- /dev/null +++ b/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Common/I2C_Shapes_Common_export.h @@ -0,0 +1,36 @@ +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// ------------------------------ +#ifndef I2C_SHAPES_COMMON_EXPORT_H +#define I2C_SHAPES_COMMON_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (I2C_SHAPES_HAS_DLL) +# define I2C_SHAPES_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && I2C_SHAPES_HAS_DLL */ + +#if !defined (I2C_SHAPES_HAS_DLL) +# define I2C_SHAPES_HAS_DLL 1 +#endif /* ! I2C_SHAPES_HAS_DLL */ + +#if defined (I2C_SHAPES_HAS_DLL) && (I2C_SHAPES_HAS_DLL == 1) +# if defined (I2C_SHAPES_COMMON_BUILD_DLL) +# define I2C_SHAPES_Export ACE_Proper_Export_Flag +# define I2C_SHAPES_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define I2C_SHAPES_COMMON_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* I2C_SHAPES_COMMON_BUILD_DLL */ +# define I2C_SHAPES_Export ACE_Proper_Import_Flag +# define I2C_SHAPES_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define I2C_SHAPES_COMMON_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* I2C_SHAPES_COMMON_BUILD_DLL */ +#else /* I2C_SHAPES_HAS_DLL == 1 */ +# define I2C_SHAPES_Export +# define I2C_SHAPES_SINGLETON_DECLARATION(T) +# define I2C_SHAPES_COMMON_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* I2C_SHAPES_HAS_DLL == 1 */ + +#endif /* I2C_SHAPES_COMMON_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Connector/I2C_Shapes_Connector.idl b/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Connector/I2C_Shapes_Connector.idl new file mode 100755 index 00000000000..799284b51fd --- /dev/null +++ b/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Connector/I2C_Shapes_Connector.idl @@ -0,0 +1,27 @@ +// $Id$ + +/** + * @file I2C_Shapes_Connector.idl + * @author + */ + +#ifndef I2C_SHAPES_CONNECTOR_IDL_ +#define I2C_SHAPES_CONNECTOR_IDL_ + +#include "connectors/dds4ccm/idl/dds4ccm_Entity.idl" + +#include "Base/I2C_Shapes_Base.idl" + +#pragma ciao lem "Connector/I2C_Shapes_ConnectorE.idl" + +module I2C_Typed <typename T, sequence<T> TSeq> { + alias DDS_Entity<T, TSeq> DDS_Typed_Entity; + typedef DDS_Typed_Entity::DataReader DataReader; + typedef DDS_Typed_Entity::DataWriter DataWriter; +}; + +module ::I2C_Typed < ::ShapeType, ::ShapeTypeSeq> I2C_Shapes; + +#endif /* I2C_SHAPES_CONNECTOR_IDL_ */ + + diff --git a/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Connector/I2C_Shapes_Connector.mpc b/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Connector/I2C_Shapes_Connector.mpc new file mode 100755 index 00000000000..cc80d6a0e61 --- /dev/null +++ b/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Connector/I2C_Shapes_Connector.mpc @@ -0,0 +1,80 @@ +// $Id$ + +// project(I2C_Shapes_Connector_idl_gen) : connectoridldefaults, dds4ccm { +project(I2C_Shapes_Connector_idl_gen) : connectoridldefaults, dds4ccm { + after += DDS4CCM_idl_gen + custom_only = 1 + idlflags += -Wb,stub_export_macro=I2C_SHAPES_CONNECTOR_STUB_Export \ + -Wb,stub_export_include=I2C_Shapes_Connector_stub_export.h \ + -I.. + idlflags -= -Gcn -Gxhcn + IDL_Files { + I2C_Shapes_Connector.idl + } +} + +project(I2C_Shapes_Connector_lem_gen) : ciaoidldefaults, dds4ccm { + custom_only = 1 + after += I2C_Shapes_Connector_idl_gen + idlflags += -Wb,stub_export_macro=I2C_SHAPES_CONNECTOR_LEM_STUB_Export \ + -Wb,stub_export_include=I2C_Shapes_Connector_lem_stub_export.h \ + -SS -Gxhst \ + -I .. + + IDL_Files { + I2C_Shapes_ConnectorE.idl + } +} + +project(I2C_Shapes_Connector_lem_stub) : ccm_svnt, dds4ccm_lem_stub { + after += I2C_Shapes_Connector_lem_gen I2C_Shapes_Connector_stub I2C_Shapes_Base_stub + libs += I2C_Shapes_Base_stub I2C_Shapes_Connector_stub + libpaths += ../lib + libout = ../lib + includes += .. + sharedname = I2C_Shapes_Connector_lem_stub + dynamicflags += I2C_SHAPES_CONNECTOR_LEM_STUB_BUILD_DLL + + IDL_Files { + } + + Source_Files { + I2C_Shapes_ConnectorEC.cpp + } + + Header_Files { + I2C_Shapes_ConnectorEC.h + I2C_Shapes_Connector_lem_stub_export.h + } + + Inline_Files { + I2C_Shapes_ConnectorEC.inl + } +} + +project(I2C_Shapes_Connector_stub) : ccm_stub, dds4ccm_base { + after += I2C_Shapes_Connector_idl_gen I2C_Shapes_Base_stub + libs += I2C_Shapes_Base_stub + libpaths += ../lib + libout = ../lib + includes += .. + sharedname = I2C_Shapes_Connector_stub + dynamicflags += I2C_SHAPES_CONNECTOR_STUB_BUILD_DLL + + IDL_Files { + } + + Source_Files { + I2C_Shapes_ConnectorC.cpp + } + + Header_Files { + I2C_Shapes_ConnectorC.h + I2C_Shapes_Connector_stub_export.h + I2C_Shapes_Traits.h + } + + Inline_Files { + I2C_Shapes_ConnectorC.inl + } +} diff --git a/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Connector/I2C_Shapes_Traits.h b/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Connector/I2C_Shapes_Traits.h new file mode 100755 index 00000000000..369f1401842 --- /dev/null +++ b/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Connector/I2C_Shapes_Traits.h @@ -0,0 +1,23 @@ +// -*- C++ -*- +// $Id$ + +#ifndef I2C_SHAPES_TRAITS_H_ +#define I2C_SHAPES_TRAITS_H_ + +#include "Base/I2C_Shapes_BaseSupport.h" +#include "Connector/I2C_Shapes_ConnectorC.h" + +struct ShapeType_DDS_Traits +{ + typedef ::ShapeType value_type; + typedef ::ShapeTypeRTISeq dds_seq_type; + typedef ::ShapeTypeTypeSupport type_support; + typedef ::DDS_SampleInfoSeq sampleinfo_seq_type; + typedef ::DDS_SampleInfo sampleinfo_type; + typedef ::ShapeTypeDataWriter datawriter_type; + typedef ::ShapeTypeDataReader datareader_type; + typedef ::I2C_Shapes::DataWriter typed_writer_type; + typedef ::I2C_Shapes::DataReader typed_reader_type; +}; + +#endif /* I2C_SHAPES_TRAITS_H_ */ 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<ShapeType_DDS_Traits::datareader_type, + ShapeType_DDS_Traits::typed_reader_type, + ShapeType_DDS_Traits::value_type, + ShapeTypeSeq, + ShapeType_DDS_Traits::dds_seq_type> + 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 <ShapesDataReader *>(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 { + } +} + diff --git a/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Sender/I2C_Shapes_Sender.cpp b/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Sender/I2C_Shapes_Sender.cpp new file mode 100755 index 00000000000..ececa972aa3 --- /dev/null +++ b/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Sender/I2C_Shapes_Sender.cpp @@ -0,0 +1,104 @@ +// $Id$ + +#include "Common/I2C_Shapes_Common.h" +#include "connectors/dds4ccm/impl/ndds/DataWriter_T.h" + +#include "ace/OS_NS_unistd.h" + +#define MAX_X_Y 250 + +typedef ::CIAO::NDDS::DataWriter_T<ShapeType_DDS_Traits::datawriter_type, + ShapeType_DDS_Traits::typed_writer_type, + ShapeType_DDS_Traits::value_type> + ShapesDataWriter; + +void +write (ShapesDataWriter * shapes_dw) +{ + if (shapes_dw) + { + ShapeType square; + square.color = "GREEN"; + square.x = ACE_OS::rand () % MAX_X_Y; + square.y = ACE_OS::rand () % MAX_X_Y; + square.shapesize = 25; + bool x_increasing = true; + bool y_increasing = true; + for (::CORBA::ULong i = 0; i < 1000; ++i) + { + if (x_increasing) + { + ++square.x; + x_increasing = square.x + 1 <= MAX_X_Y; + } + else + { + --square.x; + x_increasing = square.x - 1 < 0; + } + if (y_increasing) + { + ++square.y; + y_increasing = square.y + 1 <= MAX_X_Y; + } + else + { + --square.y; + y_increasing = square.y - 1 < 0; + } + ::DDS::ReturnCode_t retcode = shapes_dw->write (square, ::DDS::HANDLE_NIL); + if (retcode == ::DDS::RETCODE_OK) + { + ACE_DEBUG ((LM_DEBUG, "Updated square - " + "x: <%u> - y: <%u>\n", + square.x, square.y)); + } + ACE_Time_Value tv (0, 500000); + ACE_OS::sleep (tv); + } + ACE_DEBUG ((LM_DEBUG, "write - Ready. Written 1000 samples.\n")); + } + else + { + ACE_ERROR ((LM_ERROR, "write - ERROR: DataWriter seems to be nil\n")); + } +} + +int ACE_TMAIN (int , ACE_TCHAR *[]) +{ + int main_result = 0; + I2C_Shapes_Common common; + try + { + ::DDS::Publisher_var publisher; + publisher = common.create_publisher (); + if (::CORBA::is_nil (publisher.in ())) + { + ACE_ERROR ((LM_ERROR, "ACE_TMAIN - Publisher seems to be nil\n")); + throw ::CORBA::INTERNAL (); + } + + ::DDS::Topic_var topic = common.get_topic (); + ::DDS::DataWriter_var dw; + ::DDS::DataWriterQos wqos; + dw = publisher->create_datawriter (topic.in (), + wqos, + ::DDS::DataWriterListener::_nil (), + 0); + + ShapesDataWriter * shapes_dw = dynamic_cast <ShapesDataWriter *>(dw.in ()); + write (shapes_dw); + } + catch (::CORBA::Exception &e) + { + e._tao_print_exception ("ACE_TMAIN SENDER"); + } + catch (...) + { + ACE_ERROR ((LM_ERROR, "ACE_TMAIN SENDER - " + "Error: unexpected exception caught\n")); + } + + return main_result; +} + diff --git a/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Sender/I2C_Shapes_Sender.mpc b/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Sender/I2C_Shapes_Sender.mpc new file mode 100755 index 00000000000..74935878905 --- /dev/null +++ b/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/Sender/I2C_Shapes_Sender.mpc @@ -0,0 +1,19 @@ +// $Id$ + +project(*i2c_shapes_sender) : ndds_impl, dds4ccm_stub, dds4ccm_ts_default { + exename = I2C_Shapes_Sender + after += I2C_Shapes_Base_Stub I2C_Shapes_Connector_stub I2C_Shapes_Common + + includes += .. $(CIAO_ROOT) $(CIAO_ROOT)/connectors + + exeout += ../lib + libs += I2C_Shapes_Base_stub I2C_Shapes_Connector_stub I2C_Shapes_Common + libpaths += ../lib + + Source_Files { + I2C_Shapes_Sender.cpp + } + + Header_Files { + } +} diff --git a/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/descriptors/run_test.pl b/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/descriptors/run_test.pl new file mode 100755 index 00000000000..ebe95f6a85c --- /dev/null +++ b/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/descriptors/run_test.pl @@ -0,0 +1,33 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib "$ENV{'ACE_ROOT'}/bin"; +use PerlACE::TestTarget; + +$tg_sender = PerlACE::TestTarget::create_target (1) || die "Create target for EM failed\n"; +$tg_receiver = PerlACE::TestTarget::create_target (1) || die "Create target for EM failed\n"; +$tg_sender->AddLibPath ('../lib'); +$tg_receiver->AddLibPath ('../lib'); + + +print "Start receiver\n"; +$R = $tg_receiver->CreateProcess ("../lib/I2C_Shapes_Receiver", ""); +$R->Spawn(); + +sleep (1); + +print "Start sender\n"; +$S = $tg_sender->CreateProcess ("../lib/I2C_Shapes_Sender", ""); +$S->Spawn (); + + +sleep (80); + +$R->Kill (); +$S->Kill (); + +exit 0; |