...
Code Block |
---|
language | cpp |
---|
title | idlHelloComp/idl/HelloComponent.idl |
---|
linenumbers | true |
---|
collapse | true |
---|
|
#ifndef _HELLOCOMPONENT_IDL_
#define _HELLOCOMPONENT_IDL_
#pragma prefix "acsws"
#include <acscomponent.idl>
module workshop {
interface HelloComponent : ACS::ACSComponent {
voidstring printHello();
};
};
#endif |
...
Code Block |
---|
language | py |
---|
title | pyHelloComponent/src/workshop/HelloComponentImpl.py |
---|
linenumbers | true |
---|
collapse | true |
---|
|
#Client stubs and definitions, such as structs, enums, etc.
import workshop
#Skeleton infrastructure for server implementation
import workshop__POA
#Base component implementation
from Acspy.Servants.ACSComponent import ACSComponent
#Services provided by the container to the component
from Acspy.Servants.ContainerServices import ContainerServices
#Basic component lifecycle (initialize, execute, cleanUp and aboutToAbort methods)
from Acspy.Servants.ComponentLifecycle import ComponentLifecycle
class HelloComponentImpl(workshop__POA.HelloComponent, ACSComponent, ContainerServices, ComponentLifecycle):
def __init__(self):
ACSComponent.__init__(self)
ContainerServices.__init__(self)
self._logger = self.getLogger()
def printHello(self):
print("Just printing 'Hello World!'")
return "Hello World!" |
Java
Code Block |
---|
> getTemplateForDirectory MODROOT_WS jHelloComp
> cd jHelloComp/src
> mkdir -p acsws/workshop/HelloComponentImpl
> touch acsws/workshop/HelloComponentImpl/HelloComponentImpl.java
> cp ../../idlHelloComp/src/acsws/workshop/HelloComponentImpl/HelloComponentComponentHelper.java.tpl acsws/workshop/HelloComponentImpl/HelloComponentComponentHelper.java |
...
Code Block |
---|
language | java |
---|
title | jHelloComponent/src/acsws/workshop/HelloComponentImpl/HelloComponentImpl.java |
---|
linenumbers | true |
---|
collapse | true |
---|
|
//Suggested: import alma.<Module>.<Interface>Impl; //But anything, really
package acsws.workshop.HelloComponentImpl;
//Base component implementation, including container services and component lifecycle infrastructure
import alma.acs.component.ComponentImplBase;
//Skeleton interface for server implementation
import acsws.workshop.HelloComponentOperations;
//ClassName usually is <Interface>Impl, but can be anything
public class HelloComponentImpl extends ComponentImplBase implements HelloComponentOperations {
public HelloComponentImpl() {
}
public voidString printHello() {
System.out.println("Just printing 'Hello World!'");
return new String("Hello World!")
}
} |
C++
We create the needed directories:
...
Code Block |
---|
language | cpp |
---|
title | cppHelloComponent/include/HelloComponentImpl.h |
---|
linenumbers | true |
---|
collapse | true |
---|
|
#ifndef _HELLO_COMPONENT_IMPL_H
#define _HELLO_COMPONENT_IMPL_H
#ifndef __cplusplus
#error This is a C++ include file and cannot be used from plain C
#endif
//Base component implementation, including container services and component lifecycle infrastructure
#include <acscomponentImpl.h>
//Skeleton interface for server implementation
#include <HelloComponentS.h>
//Error definitions for catching and raising exceptions
class HelloComponentImpl : public virtual acscomponent::ACSComponentImpl, public virtual POA_workshop::HelloComponent {
public:
HelloComponentImpl(const ACE_CString& name, maci::ContainerServices * containerServices);
virtual ~HelloComponentImpl();
voidchar* printHello();
};
#endif |
Code Block |
---|
language | cpp |
---|
title | cppHelloComponent/src/HelloComponentImpl.cpp |
---|
linenumbers | true |
---|
collapse | true |
---|
|
#include <HelloComponentImpl.h>
HelloComponentImpl::HelloComponentImpl(const ACE_CString& name, maci::ContainerServices * containerServices) : ACSComponentImpl(name, containerServices) {
}
HelloComponentImpl::~HelloComponentImpl() {
}
voidchar* HelloComponentImpl::printHello() {
std::cout << "Just printing 'Hello World!'" << std::endl;
return "Hello World!";
}
/* --------------- [ MACI DLL support functions ] -----------------*/
#include <maciACSComponentDefines.h>
MACI_DLL_SUPPORT_FUNCTIONS(HelloComponentImpl)
/* ----------------------------------------------------------------*/ |
...
Code Block |
---|
language | py |
---|
linenumbers | true |
---|
collapse | true |
---|
|
from Acspy.Clients.SimpleClient import PySimpleClient
client = PySimpleClient()
hc_py = cclient.getComponent("PY_HELLO_COMP")
hc_java = cclient.getComponent("JAVA_HELLO_COMP")
hc_cpp = cclient.getComponent("CPP_HELLO_COMP")
print(hc_py.printHello())
print(hc_java.printHello())
print(hc_cpp.printHello()) |
Output
The output is seen on each container:
...
Code Block |
---|
...
2020-07-28T21:19:53.080 [Container-ActivationMethod - maci::ActivationMethod::call] Calling maci::CBComponentInfo::done with descOut.id_tag = 4.
2020-07-28T21:19:53.082 [Container-ActivationMethod - maci::ActivationMethod::call] Call to maci::CBComponentInfo::done with descOut.id_tag = 4 completed.
Just saying 'Hello World!'
... |
PySimpleClient
Code Block |
---|
...
Hello World!
Hello World!
Hello World!
... |