Search in sources :

Example 11 with CompletionHolder

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);
}
Also used : RWStates(jbaciEnumPropTest.RWStates) ROStates(jbaciEnumPropTest.ROStates) States(jbaciEnumPropTest.States) CompletionHolder(alma.ACSErr.CompletionHolder)

Example 12 with CompletionHolder

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);
}
Also used : RWStates(jbaciEnumPropTest.RWStates) ROStates(jbaciEnumPropTest.ROStates) States(jbaciEnumPropTest.States) CompletionHolder(alma.ACSErr.CompletionHolder) CBDescIn(alma.ACS.CBDescIn)

Example 13 with CompletionHolder

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;
}
Also used : CBdouble(alma.ACS.CBdouble) LampUnavailable(alma.demo.LampUnavailable) CBdouble(alma.ACS.CBdouble) RWdouble(alma.ACS.RWdouble) Monitordouble(alma.ACS.Monitordouble) CompletionHolder(alma.ACSErr.CompletionHolder) CBDescIn(alma.ACS.CBDescIn) ACSException(alma.ACSErr.ACSException) AcsJException(alma.acs.exceptions.AcsJException)

Example 14 with CompletionHolder

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);
}
Also used : CompletionHolder(alma.ACSErr.CompletionHolder)

Example 15 with CompletionHolder

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);
    }
}
Also used : AcsJCouldntPerformActionEx(alma.ACSErrTypeCommon.wrappers.AcsJCouldntPerformActionEx) AcsJException(alma.acs.exceptions.AcsJException) CompletionHolder(alma.ACSErr.CompletionHolder) OutOfBoundsAcsJCompletion(alma.ACSErrTypeCommon.wrappers.OutOfBoundsAcsJCompletion)

Aggregations

CompletionHolder (alma.ACSErr.CompletionHolder)30 CBDescIn (alma.ACS.CBDescIn)11 RWdouble (alma.ACS.RWdouble)5 Monitordouble (alma.ACS.Monitordouble)4 ROdouble (alma.ACS.ROdouble)3 AcsJCompletion (alma.acs.exceptions.AcsJCompletion)3 AcsJException (alma.acs.exceptions.AcsJException)3 ROStates (jbaciEnumPropTest.ROStates)3 RWStates (jbaciEnumPropTest.RWStates)3 States (jbaciEnumPropTest.States)3 AcsJCouldntPerformActionEx (alma.ACSErrTypeCommon.wrappers.AcsJCouldntPerformActionEx)2 LampUnavailable (alma.demo.LampUnavailable)2 POAManager (org.omg.PortableServer.POAManager)2 ClientInfo (si.ijs.maci.ClientInfo)2 Manager (si.ijs.maci.Manager)2 CBdouble (alma.ACS.CBdouble)1 Monitor (alma.ACS.Monitor)1 MonitorstringSeq (alma.ACS.MonitorstringSeq)1 ROstring (alma.ACS.ROstring)1 ROstringSeq (alma.ACS.ROstringSeq)1