Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Create component

Code Block
languagebash
cd ~/workspace
getTemplateForDirectory MODROOT_WS cppHelloComp
cd cppHelloComp/src
touch HelloComponentImpl.cpp
touch ../include/HelloComponentImpl.h
vim Makefile

...

Code Block
languagecpp
titlecppHelloComp/src/HelloComponentImpl.cpp
#include <HelloComponentImpl.h>
 
HelloComponentImpl::HelloComponentImpl(const ACE_CString& name, maci::ContainerServices * containerServices) : ACSComponentImpl(name, containerServices) {
}
 
HelloComponentImpl::~HelloComponentImpl() {
}
 
char* HelloComponentImpl::printHello() {
    std::cout << "Just printing 'Hello World!'" << std::endl;
    return CORBA::string_dup("Hello World!");
}
 
/* --------------- [ MACI DLL support functions ] -----------------*/
#include <maciACSComponentDefines.h>
MACI_DLL_SUPPORT_FUNCTIONS(HelloComponentImpl)
/* ----------------------------------------------------------------*/

Compile component

Code Block
languagebash
export INTROOT=~/workspace/introot
export LD_LIBRARY_PATH=$INTROOT/lib:$LD_LIBRARY_PATH
make all install

Add component to CDB

Code Block
languagebash
vim $ACS_CDB/CDB/MACI/Components/Components.xml

...

Code Block
languagebash
titleComponents.xml
<e Name="HelloWorldCPP" Code="HelloComponentImpl"
                        Type="IDL:acsws/workshop/HelloComponent:1.0"
                        Container="bilboContainer" ImplLang="cpp" />

Testing

Create client python file:

...

Code Block
languagebash
# in one terminal
acsStop
acsStart
# in a different terminal
acsStartContainer -cpp bilboContainer
# in a different terminal
python client.py

Example output:

Code Block
...
Hello World!
...