use of alma.ACS.CBDescIn in project ACS by ACS-Community.
the class EnumPropertyTest method testGetAsync.
public void testGetAsync() {
CBStatesImpl cb = new CBStatesImpl();
CBDescIn descIn = new CBDescIn(50000, 50000, 1208);
synchronized (cb) {
ROproperty.get_async(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
assertEquals(ROproperty.default_value(), response.value);
// check descriptor
assertEquals(descIn.id_tag, response.desc.id_tag);
// check completion
assertEquals(0, response.completion.code);
assertEquals(0, response.completion.type);
assertEquals(0, response.completion.previousError.length);
// less than 5s
assertTrue((UTCUtility.utcJavaToOmg(System.currentTimeMillis()) - response.completion.timeStamp) < 50000000);
}
use of alma.ACS.CBDescIn in project ACS by ACS-Community.
the class LampAccessImpl method setLampBrightness.
/////////////////////////////////////////////////////////////
// Implementation of LampAccessOperations
/////////////////////////////////////////////////////////////
/**
* Passes a value to the brightness property of the lamp component.
* @param brightness
* @see alma.demo.LampAccessOperations#setLampBrightness(double)
* @throws LampUnavailable
*/
public void setLampBrightness(double brightness) throws LampUnavailable {
m_logger.finer("LampAccess:setLampBrightness(" + brightness + ") called...");
if (m_brightness == null) {
m_brightness = getLampBrightnessProperty();
m_logger.info("m_brightness initialized...");
}
if (m_cb == null) {
try {
m_cb = new CBvoidLampAccess(m_logger);
m_logger.info("CBvoidLampAccess instantiated...");
m_cbvoid = alma.ACS.CBvoidHelper.narrow(m_containerServices.activateOffShoot(m_cb));
// m_logger.warning("doof test: second activation...");
// CBvoidLampAccess cb2 = new CBvoidLampAccess(m_logger);
// m_containerServices.activateOffShoot(cb2);
} catch (Exception e) {
m_logger.log(Level.SEVERE, "failed to obtain the callback offshoot object.", e);
throw new LampUnavailable(e.getMessage());
}
}
if (m_desc == null) {
m_desc = new CBDescIn();
m_logger.info("m_desc instantiated...");
}
try {
m_logger.info("before callback done...");
getLampBrightnessProperty().set_async(brightness, m_cbvoid, m_desc);
m_logger.finer("now callback done...");
} catch (Exception ex) {
m_logger.log(Level.SEVERE, "ex in setLampBrightness impl", ex);
throw new LampUnavailable(ex.getMessage());
}
}
use of alma.ACS.CBDescIn in project ACS by ACS-Community.
the class LampCallbackImpl method monitorLampBrightness.
/////////////////////////////////////////////////////////////
// Implementation of LampCallbackOperations
/////////////////////////////////////////////////////////////
/**
* Attaches a monitor to the brightness object of the lamp component.
* The component uses a callback when the interval set to the timer expires.
* @return double
* @see LampCallbackOperations#monitorLampBrightness()
* @throws alma.demo.LampUnavailable
*/
public double monitorLampBrightness() throws LampUnavailable {
if (m_cb == null) {
m_cb = new CBdoubleLampCallback(m_logger);
m_logger.finer("CBdoubleLampCallback instantiated...");
}
CBdouble cbdouble;
try {
//test
// CBdoubleHelper.narrow(m_containerServices.activateOffShoot(m_cb));
// m_containerServices.deactivateOffShoot(m_cb);
// note that m_cb may go through a cycle of activation/deactivation, see stopMonitor()
cbdouble = CBdoubleHelper.narrow(m_containerServices.activateOffShoot(m_cb, CBdoubleOperations.class));
} catch (Exception e) {
m_logger.log(Level.SEVERE, "failed to obtain the callback offshoot object.", e);
throw new LampUnavailable(e.getMessage());
}
if (m_desc == null) {
m_desc = new CBDescIn();
m_logger.info("m_desc instantiated...");
}
double brightness = 0;
try {
getLampBrightnessObject();
CompletionHolder completionHolder = new CompletionHolder();
brightness = m_brightness.get_sync(completionHolder);
m_monitor = m_brightness.create_monitor(cbdouble, m_desc);
m_logger.info("monitor instantiated...");
// call every 10th second
m_logger.info("prepares to trigger brightness every 10th second...");
m_monitor.set_timer_trigger(100000000);
m_logger.info("ready to trigger brightness...");
} catch (Exception ex) {
m_logger.log(Level.SEVERE, "ex in monitorLampBrightness impl", ex);
throw new LampUnavailable(ex.getMessage());
}
return brightness;
}
use of alma.ACS.CBDescIn in project ACS by ACS-Community.
the class SimpleMasterComponentTest 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 = "SIMPLEMASTERCOMPONENT1";
org.omg.CORBA.Object obj;
try {
obj = manager.get_component(clientInfo.h, COMPONENT_NAME, true);
SimpleMasterComponent simpleMasterComponent = SimpleMasterComponentHelper.narrow(obj);
ROstringSeq currentStateHierarchy = simpleMasterComponent.currentStateHierarchy();
// syncvalue retrival
System.out.println("Current state hierarchy: " + getStringArray(currentStateHierarchy.get_sync(new CompletionHolder())));
System.out.println("Monitoring - 1s interval...");
// create a monitor
MonitorstringSeq monitor = currentStateHierarchy.create_monitor(new CBstringSeqImpl()._this(orb), new CBDescIn());
// sleep for a while
try {
Thread.sleep(10000);
} catch (InterruptedException ie) {
}
;
monitor.set_timer_trigger(0);
monitor.set_value_trigger(new String[0], true);
System.out.println("On-change monitoring...");
// 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 (NoPermissionEx ex) {
ex.printStackTrace();
}
logout(manager, clientInfo);
}
}
finalizeCORBA();
}
use of alma.ACS.CBDescIn in project ACS by ACS-Community.
the class PropertySeqTest method testCreatePostponedMonitor.
public void testCreatePostponedMonitor() {
// TODO tmp
if (true)
return;
try {
CBDescIn descIn = new CBDescIn(50000, 50000, 1208);
ROpropertyLongSeq.create_postponed_monitor(0, null, descIn);
fail("NO_IMPLEMENT exception expected");
} catch (NO_IMPLEMENT ex) {
// OK
}
}
Aggregations