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 | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
package ...; 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 { public unsigned long value; public String status; public MyTestCBvoid(Logger logger) { status = "INIT"; this.value = 0; } public void working(unsigned long value, Completion completion, CBDescOut desc) { status = "WORKING"; this.value = value; } public void done(unsigned long value, Completion completion, CBDescOut desc) { status = "DONE"; this.value = value; } public boolean negotiate(long timeToTransit, CBDescOut desc) { return true; } } private Logger m_logger; public AsyncClient() { String managerLoc = System.getProperty("ACS.manager"); super(null, managerLoc, clientName); m_logger = getContainerServices().getLogger() } public doStuff() { org.omg.CORBA.Object obj = getContainerServices().getComponent("ASYNC"); Async comp = AsyncHelper.narrow(obj); CBuLongImpl cb = new CBuLongImpl(m_logger); CBuLong cbObj = alma.ACS.CBuLongHelper.narrow(getContainerServices().activateOffShoot(cb)); CBDescIn desc = new CBDescIn(); m_logger.info(cb.status); comp.delayResult(8, cbObj, desc); m_logger.info(cb.status); Thread.sleep(5000); m_logger.info(cb.status); Thread.sleep(5000); m_logger.info(cb.status); m_logger.info(cb.value); getContainerServices().releaseComponent("ASYNC"); } public static void main(String[] args) { AsyncClient client = new AsyncClient(); 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() {}
void working (CORBA::uLong value, const ACSErr::Completion &c, const ACS::CBDescOut &desc) {
status = std::string("WORKING");
this.value = value;
}
void done (CORBA::uLong value, const ACSErr::Completion &c, const ACS::CBDescOut &desc){
status = std::string("DONE");
this.value = value;
}
CORBA::Boolean negotiate (ACS::TimeInterval time_to_transmit, const ACS::CBDescOut &desc) {
return true;
}
CORBA::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;
ACS_SHORT_LOG((LM_INFO, "%s", cb.status));
comp.delayResult(8, cbObj.in(), desc);
ACS_SHORT_LOG((LM_INFO, "%s", cb.status));
Thread.sleep(5000);
ACS_SHORT_LOG((LM_INFO, "%s", cb.status));
Thread.sleep(5000);
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;
} |