Search in sources :

Example 6 with CompletionHolder

use of alma.ACSErr.CompletionHolder in project ACS by ACS-Community.

the class StateChangeListener method getCurrentState.

/**
	 * Reads the current state hierarchy.
	 * @return State hierarchy with outmost state first
	 * @throws AcsJIllegalStateEventEx if the state can't be read ; @TODO: use better fitting ex (don't want to create one now right before the release)
	 */
public String[] getCurrentState() throws AcsJIllegalStateEventEx {
    CompletionHolder ch = new CompletionHolder();
    String[] statesHierarchy = statesProperty.get_sync(ch);
    AcsJCompletion statesSyncCompletion = AcsJCompletion.fromCorbaCompletion(ch.value);
    if (statesSyncCompletion.isError() || statesSyncCompletion.getType() != ACSErrTypeOK.value || statesSyncCompletion.getCode() != ACSErrOK.value || statesHierarchy == null) {
        throw new AcsJIllegalStateEventEx("Failed to retrieve current subsystem state.");
    }
    return statesHierarchy;
}
Also used : AcsJCompletion(alma.acs.exceptions.AcsJCompletion) AcsJIllegalStateEventEx(alma.ACSErrTypeCommon.wrappers.AcsJIllegalStateEventEx) CompletionHolder(alma.ACSErr.CompletionHolder)

Example 7 with CompletionHolder

use of alma.ACSErr.CompletionHolder in project ACS by ACS-Community.

the class MasterComponentImplBase method updateStateHierarchy.

/**
	 * Sets the property value of <code>currentStateHierarchy</code>
	 * to match the current (sub-)states from the state machine.
	 * <p>
	 * This method should not be overloaded by subclasses! We just don't make it final to meet special testing needs. 
	 */
public void updateStateHierarchy() throws AcsJException {
    AcsState[] stateHierarchy = m_stateMachine.getCurrentTopLevelState().getStateHierarchy();
    String newState = AcsStateUtil.stateHierarchyToString(stateHierarchy);
    // convert to String[]
    String[] stateNameHierarchy = new String[stateHierarchy.length];
    for (int i = 0; i < stateHierarchy.length; i++) {
        stateNameHierarchy[i] = stateHierarchy[i].stateName();
    }
    // set Baci property and announce the notification to the checker object beforehand if checking is enabled
    if (StateChangeNotificationChecker.monitorStateChangeNotification) {
        stateChangeNotificationChecker.announceStateChangeNotification(stateNameHierarchy);
    }
    CompletionHolder ch = new CompletionHolder();
    m_currentStateHierarchyDataAccess.set(stateNameHierarchy, ch);
    // optimization usually leaves out the completion if ok
    if (ch.value != null) {
        AcsJCompletion compl = AcsJCompletion.fromCorbaCompletion(ch.value);
        if (compl.isError()) {
            m_logger.log(Level.WARNING, "failed to update state property!", compl.getAcsJException());
            throw compl.getAcsJException();
        } else {
            m_logger.finest("Changed state property to '" + newState + "'.");
        }
    } else {
        m_logger.finest("Changed state property to '" + newState + "'.");
    }
}
Also used : AcsJCompletion(alma.acs.exceptions.AcsJCompletion) AcsState(alma.acs.genfw.runtime.sm.AcsState) CompletionHolder(alma.ACSErr.CompletionHolder)

Example 8 with CompletionHolder

use of alma.ACSErr.CompletionHolder in project ACS by ACS-Community.

the class SpecialTestMasterComponentTest method testOtherProperty.

public void testOtherProperty() {
    RWdouble doubleProperty = m_masterComp.someOtherProperty();
    assertNotNull(doubleProperty);
    CompletionHolder ch = new CompletionHolder();
    doubleProperty.set_sync(3.14);
    double actualValue = doubleProperty.get_sync(ch);
    assertTrue("value of property 'someOtherProperty' must equal 3.14", actualValue < 3.15 && actualValue > 3.13);
//		PropertySet allCharacteristics = doubleProperty.get_all_characteristics();
//		assertNotNull(allCharacteristics);
}
Also used : RWdouble(alma.ACS.RWdouble) RWdouble(alma.ACS.RWdouble) CompletionHolder(alma.ACSErr.CompletionHolder)

Example 9 with CompletionHolder

use of alma.ACSErr.CompletionHolder in project ACS by ACS-Community.

the class CommonPropertyImpl 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 {
        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)

Example 10 with CompletionHolder

use of alma.ACSErr.CompletionHolder in project ACS by ACS-Community.

the class PropertyPrimTest method testSetAsyncFloatRW.

public void testSetAsyncFloatRW() {
    CBvoidImpl cb = new CBvoidImpl();
    CBDescIn descIn = new CBDescIn(50000, 50000, 1208);
    synchronized (cb) {
        RWpropertyFloat.set_async((float) 500.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 = RWpropertyFloat.get_sync(completionHolder);
    assertEquals(500.0, value, 0.001);
}
Also used : RWdouble(alma.ACS.RWdouble) ROdouble(alma.ACS.ROdouble) Monitordouble(alma.ACS.Monitordouble) CompletionHolder(alma.ACSErr.CompletionHolder) CBDescIn(alma.ACS.CBDescIn)

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