use of alma.ACS.CBDescIn in project ACS by ACS-Community.
the class PropertySeqTest method testCreateMonitorDouble.
public void testCreateMonitorDouble() {
// TODO do test with null callback ;)
// TODO implement...
CBdoubleSeqImpl cb = new CBdoubleSeqImpl();
CBDescIn descIn = new CBDescIn(50000, 50000, 1208);
Monitordouble monitor = ROpropertyDoubleSeq.create_monitor(cb._this(orb), descIn);
try {
// 10.5 sec
Thread.sleep(10500);
} catch (InterruptedException ie) {
}
synchronized (cb) {
try {
monitor.destroy();
// wait for 3s
cb.wait(3000);
} catch (InterruptedException ie) {
}
}
// TODO test if done was called
}
use of alma.ACS.CBDescIn in project ACS by ACS-Community.
the class StateChangeListener method createMonitor.
/**
* Creates a monitor for <code>statesProperty</code> from this instance.
*
* @param statesProperty
* @param contSrv
* @return usually not needed
* @throws Exception
*/
public MonitorstringSeq createMonitor(ROstringSeq statesProperty, ContainerServices contSrv) throws Exception {
this.contSrv = contSrv;
if (monitor != null) {
destroyMonitor();
}
this.statesProperty = statesProperty;
// register this callback object with CORBA
OffShoot offshoot = contSrv.activateOffShoot(this);
CBstringSeq cbStringSeq = CBstringSeqHelper.narrow(offshoot);
// register callback CORBA object with the statesProperty as a monitor
monitor = statesProperty.create_monitor(cbStringSeq, new CBDescIn());
// baci.idl: "On creation, the only trigger present will be the timer trigger.
// Calling the set_value_trigger method determines the behaviour of the value trigger.
// The enable parameter determines whether the value trigger is active or not ."
// Strings have no triggerable value, thus don't care
monitor.set_value_trigger(new String[0], true);
// baci.idl: "Timer trigger can be disabled by passing the value 0 for timer parameter."
monitor.set_timer_trigger(0);
return monitor;
}
use of alma.ACS.CBDescIn in project ACS by ACS-Community.
the class ManagerProxy method releaseComponentAsync.
public void releaseComponentAsync(int id, URI curl, LongCompletionCallback callback) throws AcsJNoPermissionEx, AcsJBadParameterEx {
try {
final LongCompletionCallback fcallback = callback;
CBlongPOA cbo = new CBlongPOA() {
public boolean negotiate(long time_to_transmit, CBDescOut desc) {
return false;
}
public void working(int value, Completion c, CBDescOut desc) {
// noop
}
public void done(int value, Completion c, CBDescOut desc) {
if (c.code == 0 && c.type == 0)
fcallback.done(value);
else
// TODO maybe convert to specific exceptions
fcallback.failed(value, AcsJCompletion.fromCorbaCompletion(c).getAcsJException());
}
};
CBDescIn desc = new CBDescIn(0, 0, 0);
manager.release_component_async(id, curl.toString(), cbo._this(), desc);
} catch (NoPermissionEx nop) {
throw new AcsJNoPermissionEx(nop);
}
}
use of alma.ACS.CBDescIn 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.ACS.CBDescIn in project ACS by ACS-Community.
the class PropertySeqTest method testOnChangeMonitorLong.
public void testOnChangeMonitorLong() {
// TODO implement...
CBlongSeqImpl cb = new CBlongSeqImpl();
CBDescIn descIn = new CBDescIn(50000, 50000, 1208);
Monitorlong monitor = ROpropertyLongSeq.create_monitor(cb._this(orb), descIn);
// disable on time trigger
monitor.set_timer_trigger(0);
try {
// sleep for 5 sec
Thread.sleep(3000);
} catch (InterruptedException ie) {
}
// TODO monitors should not come
// every change test
monitor.set_value_trigger(0, true);
// TODO change value here...
// ups RO monitor ;)
// !!! TMP - tested with backdoor via alarm_high_on()...
ROpropertyLongSeq.alarm_high_on();
try {
Thread.sleep(3000);
} catch (InterruptedException ie) {
}
// disable test
monitor.set_value_trigger(0, false);
ROpropertyLongSeq.alarm_high_on();
try {
Thread.sleep(3000);
} catch (InterruptedException ie) {
}
monitor.set_value_trigger(0, true);
ROpropertyLongSeq.alarm_high_on();
try {
Thread.sleep(3000);
} catch (InterruptedException ie) {
}
System.out.println("------");
// disable test
monitor.suspend();
ROpropertyLongSeq.alarm_high_on();
try {
Thread.sleep(3000);
} catch (InterruptedException ie) {
}
// / ... this should revive it
monitor.resume();
System.out.println("------");
ROpropertyLongSeq.alarm_high_on();
try {
Thread.sleep(3000);
} catch (InterruptedException ie) {
}
synchronized (cb) {
try {
monitor.destroy();
// wait for 3s
cb.wait(3000);
} catch (InterruptedException ie) {
}
}
// TODO test if done was called
}
Aggregations