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;
}
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 + "'.");
}
}
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);
}
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);
}
}
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);
}
Aggregations