Search in sources :

Example 26 with CompletionHolder

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

the class CommonMonitorImpl method retrieveValueAndDispatch.

/**
	 * Retrieve property value via cached <code>mnemonicValue</code>
	 * and add response to <code>BACIDispatchAction<code>. 
	 */
protected void retrieveValueAndDispatch(long keyTime, boolean done) {
    // create new holder (done expeditiously)
    CompletionHolder completionHolder = CompletionUtil.createCompletionHolder();
    // retrieve value
    Object value = property.mnemonicValue(keyTime, completionHolder);
    // TODO make a copy of completion
    Completion completion = CompletionUtil.cloneCompletion(completionHolder.value);
    // fix time...
    completion.timeStamp = UTCUtility.utcJavaToOmg(keyTime);
    // ... and dispatch
    if (!done)
        dispatchAction.dispatchWorkingRequest(completion, value);
    else
        dispatchAction.dispatchDoneRequest(completion, value);
// TODO remove
//System.out.println("Dispatched monitor (" + done + "): " + new java.util.Date(keyTime));
}
Also used : Completion(alma.ACSErr.Completion) CompletionHolder(alma.ACSErr.CompletionHolder)

Example 27 with CompletionHolder

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

the class BuildingTest 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 = "BUILDING1";
            org.omg.CORBA.Object obj;
            try {
                obj = manager.get_component(clientInfo.h, COMPONENT_NAME, true);
                Building building = BuildingHelper.narrow(obj);
                ROstring version = building.version();
                // syncvalue retrival
                System.out.println("Version: " + version.get_sync(new CompletionHolder()));
                // create a monitor
                Monitor monitor = version.create_monitor(new CBstringImpl()._this(orb), new CBDescIn());
                // 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 (Exception ex) {
                ex.printStackTrace();
                System.out.println("Failed to release component.");
            }
            logout(manager, clientInfo);
        }
    }
    finalizeCORBA();
}
Also used : POAManager(org.omg.PortableServer.POAManager) Manager(si.ijs.maci.Manager) ROstring(alma.ACS.ROstring) CBDescIn(alma.ACS.CBDescIn) Monitor(alma.ACS.Monitor) CompletionHolder(alma.ACSErr.CompletionHolder) ClientInfo(si.ijs.maci.ClientInfo)

Example 28 with CompletionHolder

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

the class PropertySeqTest method testSetAsyncLongRW.

public void testSetAsyncLongRW() {
    CBvoidImpl cb = new CBvoidImpl();
    CBDescIn descIn = new CBDescIn(50000, 50000, 1208);
    synchronized (cb) {
        RWpropertyLongSeq.set_async(new int[] { 500, 600 }, 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();
    int[] value = RWpropertyLongSeq.get_sync(completionHolder);
    assertEquals(500, value[0], 0);
    assertEquals(600, value[1], 0);
}
Also used : CompletionHolder(alma.ACSErr.CompletionHolder) CBDescIn(alma.ACS.CBDescIn)

Example 29 with CompletionHolder

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

the class PropertySeqTest method testSetAsyncDoubleRW.

public void testSetAsyncDoubleRW() {
    CBvoidImpl cb = new CBvoidImpl();
    CBDescIn descIn = new CBDescIn(50000, 50000, 1208);
    synchronized (cb) {
        RWpropertyDoubleSeq.set_async(new double[] { 500.0, 600.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 = RWpropertyDoubleSeq.get_sync(completionHolder);
    assertEquals(500.0, value[0], 0);
    assertEquals(600.0, value[1], 0);
}
Also used : CompletionHolder(alma.ACSErr.CompletionHolder) CBDescIn(alma.ACS.CBDescIn)

Example 30 with CompletionHolder

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

the class TimeoutHandlerClient method doSomeStuff.

public void doSomeStuff() throws Exception {
    //Schedule the timeout for now + three seconds.
    alma.ACS.ROuLongLong now = m_clock.now();
    CompletionHolder completionHolder = new CompletionHolder();
    alma.acstime.Epoch start = new alma.acstime.Epoch(now.get_sync(completionHolder));
    start.value = start.value + 3000000;
    //Timeout only occurs once
    alma.acstime.Duration period = new alma.acstime.Duration(0);
    //Create timeout handler and schedule its timeout
    TimeoutHandlerImpl myHandler = new TimeoutHandlerImpl();
    //The TimeoutHandler IDL interface is derived from ACS::OffShoot so 
    //the container services can be used to activate it as a CORBA object
    alma.acstime.TimeoutHandler handlerCORBARef = alma.acstime.TimeoutHandlerHelper.narrow(getContainerServices().activateOffShoot(myHandler));
    //Schedule the timeout with the Timer device. Although we save
    //the timeout ID in a variable, there is really no point since
    //this is a one-shot timeout that should not be cancelled.
    int id1 = m_timer.schedule(handlerCORBARef, start, period);
}
Also used : CompletionHolder(alma.ACSErr.CompletionHolder)

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