Information
We are currently investigating an issue with the editor of some pages. Please save your work and avoid to create new pages until this banner is gone.
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
#ifndef _ASYNC_IDL_ #define _ASYNC_IDL_ #pragma prefix "alma" #include <acscommon.idl> #include <acscomponent.idl> module workshop { interface Async : ACS::ACSComponent { oneway void delayResult(in ACS::uLong delay, in ACS::CBuLong cb, in ACS::CBDescIn desc); }; }; #endif |
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
#ifndef _ASYNC_IMPL_H #define _ASYNC_IMPL_H #include <acscomponentImpl.h> #include <AsyncS.h> class AsyncImpl : public virtual acscomponent::ACSComponentImpl, public virtual POA_workshop::Async { public: AsyncImpl(const ACE_CString& name, maci::ContainerServices* containerServices); virtual ~AsyncImpl(); void delayResult(ACS::uLong delay, ACS::CBuLong_ptr cb, const ACS::CBDescIn& desc); }; #endif |
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
#include <AsyncImpl.h> #include <ACSErrTypeOK.h> ACSAsyncImpl::Time timestamp; completion = ACSErrTypeOK::ACSErrOKCompletion(); completion = ACSErrTypeCommon::CouldntPerformActionCompletion(error_p, __FILE__, __LINE__, "::Door::closeAction"); | ||||||||
Code Block | ||||||||
| ||||||||
#include <AsyncImpl.h> AsyncImpl::AsyncImpl(const ACE_CString& name, maci::ContainerServices* containerServices) : acscomponent::ACSComponentImpl(name, containerServices) { } AsyncImpl::~AsyncImpl() { } void AsyncImpl::delayResult(ACS::uLong delay, ACS::CBuLong cb, ACS::CBDescInAsyncImpl(const ACE_CString& name, maci::ContainerServices* containerServices) : acscomponent::ACSComponentImpl(name, containerServices) { } AsyncImpl::~AsyncImpl() { } void AsyncImpl::delayResult(ACS::uLong delay, ACS::CBuLong_ptr cb, const ACS::CBDescIn& desc) { ACSErr::Completion completion; ACS::CBDescOut descOut; completion = ACSErrTypeOK::ACSErrOKCompletion(); cb->working(0, completion, descOut); sleep(delay); cb->done(delay, completion, descOut); } /* --------------- [ MACI DLL support functions ] -----------------*/ #include <maciACSComponentDefines.h> MACI_DLL_SUPPORT_FUNCTIONS(AsyncImpl) /* ----------------------------------------------------------------*/ |
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<e Name="ASYNC" Code="asyncImplAsyncImpl" Type="IDL:alma/workshop/Async:1.0" Container="bilboContainer" ImplLang="cpp" KeepAliveTime="0" /> |
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
import ACS import time from Acspy.Common.Callbacks import CBuLongCBuLongLong from Acspy.Clients.SimpleClient import PySimpleClient client = PySimpleClient() comp = client.getComponent('ASYNC') cb = CBuLongCBuLongLong() cbObj = client.activateOffShoot(cb) desc = ACS.CBDescIn(0, 0, 0) print(cb.status) comp.delayResult(8, cbObj, desc) print(cb.status) time.sleep(5) print(cb.status) time.sleep(5) print(cb.status) print(cb.values) client.releaseComponent(comp.name) client.disconnect() |
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
package workshop...async; import java.util.logging.Logger; import alma.acs.component.client.ComponentClient; import alma.ACS.CBDescIn; import alma.ACS.CBDescOut; import alma.ACSErr.Completion; import alma.workshop.Async; import alma.workshop.AsyncHelper; import alma.ACS.CBuLong; import alma.ACS.CBuLongPOA; public class AsyncClient extends ComponentClient { class CBuLongImpl extends CBuLongPOA { ; import alma.ACS.CBuLong; import alma.ACS.CBuLongPOA; public class AsyncClient extends ComponentClient { class CBuLongImpl extends CBuLongPOA { public int value; public String status; public CBuLongImpl(Logger logger) { status = "INIT"; this.value = 0; } public void working(int value, Completion completion, CBDescOut desc) { status = "WORKING"; this.value = value; } public void done(int value, Completion completion, CBDescOut desc) { publicstatus unsigned long value= "DONE"; public String status; this.value = value; public MyTestCBvoid(Logger logger) {} public boolean negotiate(long timeToTransit, statusCBDescOut = "INIT";desc) { this.value = 0return true; } } publicprivate void working(unsigned long value, Completion completion, CBDescOut desc) Logger m_logger; public AsyncClient() throws Exception { status = "WORKING"super(null, System.getProperty("ACS.manager"), "AsyncClient"); m_logger this.value = value= getContainerServices().getLogger(); } public void doStuff() public{ void done(unsigned long value, Completion completion, CBDescOut desc)try { statusorg.omg.CORBA.Object obj = "DONE"; getContainerServices().getComponent("ASYNC"); Async this.valuecomp = valueAsyncHelper.narrow(obj); } CBuLongImpl cb = new public boolean negotiate(long timeToTransit, CBDescOut desc) { CBuLongImpl(m_logger); return true; CBuLong cbObj }= alma.ACS.CBuLongHelper.narrow(getContainerServices().activateOffShoot(cb)); } private Logger m_logger; CBDescIn desc = publicnew AsyncClientCBDescIn(); { String managerLoc = System.getProperty("ACS.manager" m_logger.info(String.valueOf(cb.status)); super(null comp.delayResult(8, managerLoccbObj, clientNamedesc); m_logger = getContainerServices().getLogger().info(String.valueOf(cb.status)); } public doStuffThread.sleep(5000) {; org.omg.CORBA.Object obj = getContainerServices().getComponent("ASYNC"m_logger.info(String.valueOf(cb.status)); Async comp = AsyncHelperThread.narrowsleep(obj5000); CBuLongImpl cb = new CBuLongImpl(m_loggerlogger.info(String.valueOf(cb.status)); CBuLong cbObj = alma.ACS.CBuLongHelper.narrow(getContainerServices().activateOffShoot(cbm_logger.info(String.valueOf(cb.value)); CBDescIn desc = new CBDescIn(getContainerServices().releaseComponent("ASYNC"); } m_logger.info(cb.status); catch(Exception e) { compe.delayResult(8, cbObj, descprintStackTrace(); m_logger.info(cb.status);} Thread.sleep(5000);} public static void m_logger.info(cb.status); main(String[] args) { Thread.sleep(5000); try { m_logger.info(cb.status); AsyncClient client = new m_logger.info(cb.valueAsyncClient(); getContainerServices()client.releaseComponentdoStuff("ASYNC"); } public static void} maincatch(String[]Exception argse) { AsyncClient client = new AsyncCliente.printStackTrace(); client.doStuff();} } } |
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
#include <maciSimpleClient.h> #include <AsyncC.h> #include <ACSErrTypeCommon.h> #include <acsutilTimeStamp.h> using namespace maci; class CBuLongImpl : public virtual POA_ACS::CBuLong { public: CBuLongImpl() {value = 0; status=std::string("INIT");} virtual ~MyCBdouble~CBuLongImpl() {} void working (CORBAACS::uLong value, const ACSErr::Completion &c, const ACS::CBDescOut &desc) { status = std::string("WORKING"); this.value->value = value; } void done (CORBAACS::uLong value, const ACSErr::Completion &c, const ACS::CBDescOut &desc){ status = std::string("DONE"); this.value->value = value; } CORBA::Boolean negotiate (ACS::TimeInterval time_to_transmit, const ACS::CBDescOut &desc) { return true; } public: CORBA ACS::uLong value; public std::string status; }; int main(int argc, char *argv[]) { SimpleClient client; workshop::Async_var comp; if (client.init(argc,argv) == 0) { return -1; } else { client.login(); } try { comp = client.getComponent<workshop::Async>("ASYNC", 0, true); } catch(maciErrType::CannotGetComponentExImpl& _ex) { _ex.log(); return -1; } CBuLongImpl cb(){}; ACS::CBuLong_var cbObj = cb._this(); ACS::CBDescIn desc; desc.id_tag = 2; desc.id_tag = 2; ACS_SHORT_LOG((LM_INFO, "%s", cb.status)); comp->delayResult(8, cbObj.in(), desc); ACS_SHORT_LOG((LM_INFO, "%s", cb.status)); comp.delayResult(8, cbObj.in(), desc); sleep(5); ACS_SHORT_LOG((LM_INFO, "%s", cb.status)); Thread.sleep(5000 sleep(5); ACS_SHORT_LOG((LM_INFO, "%s", cb.status)); ACS_SHORT_LOG((LM_INFO, "%s%ul", cb.statusvalue)); try { Thread.sleep(5000 client.releaseComponent("ASYNC"); ACS_SHORT_LOG((LM_INFO, "%s", cb.status)); ACS_SHORT_LOG((LM_INFO, "%ul", cb.value)); try { client.releaseComponent("ASYNC"); } catch(maciErrType::CannotReleaseComponentExImpl &_ex) { _ex.log(); return -1; } client.logout(); ACE_OS::sleep(3); return 0; }} catch(maciErrType::CannotReleaseComponentExImpl &_ex) { _ex.log(); return -1; } client.logout(); ACE_OS::sleep(3); return 0; } |
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
#Component IDL
IDL_FILES_L = Async
AsyncStubs_LIBS = acscomponentStubs acscommonStubs
#C++ Component
LIBRARIES_L = AsyncImpl
AsyncImpl_OBJECTS = AsyncImpl
AsyncImpl_LIBS = AsyncStubs acscomponent
#C++ Client
EXECUTABLES_L = AsyncExample
AsyncExample_OBJECTS = AsyncClient
AsyncExample_LIBS = maciClient AsyncStubs
#Java Client
JARFILES_L = AsyncJar
AsyncJar_DIRS = workshop
#Python Client
PY_SCRIPTS_L = AsyncClient |