use of alma.ACSErr.CompletionHolder in project ACS by ACS-Community.
the class CommonMonitorImpl method retrieveValueAndDispatch.
/**
* Retrieve property value via cached <code>mnemonicValue</code>
* and add response to <code>BACIDispatchAction<code>.
*/
protected void retrieveValueAndDispatch(long keyTime, boolean done) {
// create new holder (done expeditiously)
CompletionHolder completionHolder = CompletionUtil.createCompletionHolder();
// retrieve value
Object value = property.mnemonicValue(keyTime, completionHolder);
// TODO make a copy of completion
Completion completion = CompletionUtil.cloneCompletion(completionHolder.value);
// fix time...
completion.timeStamp = UTCUtility.utcJavaToOmg(keyTime);
// ... and dispatch
if (!done)
dispatchAction.dispatchWorkingRequest(completion, value);
else
dispatchAction.dispatchDoneRequest(completion, value);
// TODO remove
//System.out.println("Dispatched monitor (" + done + "): " + new java.util.Date(keyTime));
}
use of alma.ACSErr.CompletionHolder in project ACS by ACS-Community.
the class BuildingTest method test.
/**
* Main test routine.
*/
public void test() {
initializeCORBA();
Manager manager = resolveManager();
if (manager != null) {
ClientInfo clientInfo = login(manager);
if (clientInfo != null) {
System.out.println("All initialization done.");
//
// get component
//
final String COMPONENT_NAME = "BUILDING1";
org.omg.CORBA.Object obj;
try {
obj = manager.get_component(clientInfo.h, COMPONENT_NAME, true);
Building building = BuildingHelper.narrow(obj);
ROstring version = building.version();
// syncvalue retrival
System.out.println("Version: " + version.get_sync(new CompletionHolder()));
// create a monitor
Monitor monitor = version.create_monitor(new CBstringImpl()._this(orb), new CBDescIn());
// sleep for a while
try {
Thread.sleep(10000);
} catch (InterruptedException ie) {
}
;
monitor.destroy();
} catch (Exception e) {
// CannotGetComponentEx, ComponentConfigurationNotFoundEx
System.err.println("Failed to obtain component: " + COMPONENT_NAME);
}
// release now
try {
manager.release_component(clientInfo.h, COMPONENT_NAME);
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("Failed to release component.");
}
logout(manager, clientInfo);
}
}
finalizeCORBA();
}
use of alma.ACSErr.CompletionHolder in project ACS by ACS-Community.
the class PropertySeqTest method testSetAsyncLongRW.
public void testSetAsyncLongRW() {
CBvoidImpl cb = new CBvoidImpl();
CBDescIn descIn = new CBDescIn(50000, 50000, 1208);
synchronized (cb) {
RWpropertyLongSeq.set_async(new int[] { 500, 600 }, cb._this(orb), descIn);
try {
// wait for 5s
cb.wait(5000);
} catch (InterruptedException ie) {
}
}
// only 1 response is expected
//assertEquals(1, cb.getResponseQueue().size());
//CBResponse response = (CBResponse)cb.getResponseQueue().firstElement();
// check reponse type
//assertEquals(CBResponse.DONE_TYPE, response.type);
// check value
// TODO check value
CompletionHolder completionHolder = new CompletionHolder();
int[] value = RWpropertyLongSeq.get_sync(completionHolder);
assertEquals(500, value[0], 0);
assertEquals(600, value[1], 0);
}
use of alma.ACSErr.CompletionHolder in project ACS by ACS-Community.
the class PropertySeqTest method testSetAsyncDoubleRW.
public void testSetAsyncDoubleRW() {
CBvoidImpl cb = new CBvoidImpl();
CBDescIn descIn = new CBDescIn(50000, 50000, 1208);
synchronized (cb) {
RWpropertyDoubleSeq.set_async(new double[] { 500.0, 600.0 }, cb._this(orb), descIn);
try {
// wait for 5s
cb.wait(5000);
} catch (InterruptedException ie) {
}
}
// only 1 response is expected
//assertEquals(1, cb.getResponseQueue().size());
//CBResponse response = (CBResponse)cb.getResponseQueue().firstElement();
// check reponse type
//assertEquals(CBResponse.DONE_TYPE, response.type);
// check value
// TODO check value
CompletionHolder completionHolder = new CompletionHolder();
double[] value = RWpropertyDoubleSeq.get_sync(completionHolder);
assertEquals(500.0, value[0], 0);
assertEquals(600.0, value[1], 0);
}
use of alma.ACSErr.CompletionHolder in project ACS by ACS-Community.
the class TimeoutHandlerClient method doSomeStuff.
public void doSomeStuff() throws Exception {
//Schedule the timeout for now + three seconds.
alma.ACS.ROuLongLong now = m_clock.now();
CompletionHolder completionHolder = new CompletionHolder();
alma.acstime.Epoch start = new alma.acstime.Epoch(now.get_sync(completionHolder));
start.value = start.value + 3000000;
//Timeout only occurs once
alma.acstime.Duration period = new alma.acstime.Duration(0);
//Create timeout handler and schedule its timeout
TimeoutHandlerImpl myHandler = new TimeoutHandlerImpl();
//The TimeoutHandler IDL interface is derived from ACS::OffShoot so
//the container services can be used to activate it as a CORBA object
alma.acstime.TimeoutHandler handlerCORBARef = alma.acstime.TimeoutHandlerHelper.narrow(getContainerServices().activateOffShoot(myHandler));
//Schedule the timeout with the Timer device. Although we save
//the timeout ID in a variable, there is really no point since
//this is a one-shot timeout that should not be cancelled.
int id1 = m_timer.schedule(handlerCORBARef, start, period);
}
Aggregations