use of alma.ACSErr.CompletionHolder in project ACS by ACS-Community.
the class EnumPropertyTest method testSetSync.
public void testSetSync() {
RWproperty.set_sync(States.ENABLED);
// check value
CompletionHolder completionHolder = new CompletionHolder();
States value = RWproperty.get_sync(completionHolder);
assertEquals(States.ENABLED, value);
}
use of alma.ACSErr.CompletionHolder in project ACS by ACS-Community.
the class EnumPropertyTest method testSetAsync.
public void testSetAsync() {
CBvoidImpl cb = new CBvoidImpl();
CBDescIn descIn = new CBDescIn(50000, 50000, 1208);
synchronized (cb) {
RWproperty.set_async(States.DIAGNOSE, 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
CompletionHolder completionHolder = new CompletionHolder();
States value = RWproperty.get_sync(completionHolder);
assertEquals(States.DIAGNOSE, value);
}
use of alma.ACSErr.CompletionHolder 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.ACSErr.CompletionHolder in project ACS by ACS-Community.
the class RWCommonComparablePropertyImpl method decrementImpl.
/**
* Decrement action implementation.
* @throws AcsJException thown on any failure.
*/
protected Completion decrementImpl() throws AcsJException {
CompletionHolder completionHolder = CompletionUtil.createCompletionHolder();
Object currentValue = getSync(completionHolder);
// TODO completion error (type != 0) check
// decrement
Object decrementedValue = sum(currentValue, minStep, true);
return setSync(decrementedValue);
}
use of alma.ACSErr.CompletionHolder in project ACS by ACS-Community.
the class RWCommonComparablePropertyImpl method setSync.
/*********************** [ RW<type> helpers ] ***********************/
/**
* @see alma.ACSErr.Completion alma.ACS.RW<type>Operations#set_sync(<type>)
*/
protected Completion setSync(Object value) throws AcsJException {
try {
// check limits
if (value instanceof Comparable) {
Comparable c = (Comparable) value;
if (c.compareTo(minValue) < 0 || c.compareTo(maxValue) > 0) {
OutOfBoundsAcsJCompletion compl = new OutOfBoundsAcsJCompletion();
compl.setMinValue(minValue.toString());
compl.setMaxValue(maxValue.toString());
compl.setRequestedValue(value.toString());
return compl.toCorbaCompletion();
}
}
CompletionHolder completionHolder = CompletionUtil.createCompletionHolder();
dataAccess.set(value, completionHolder);
// generate no-error completion, if not generated
if (completionHolder.value == null)
completionHolder.value = CompletionUtil.generateNoErrorCompletion();
return completionHolder.value;
} catch (AcsJException acsex) {
throw new AcsJCouldntPerformActionEx("Failed to set value.", acsex);
}
}
Aggregations