Search in sources :

Example 11 with CBDescIn

use of alma.ACS.CBDescIn in project ACS by ACS-Community.

the class EnumPropertyTest method testGetAsync.

public void testGetAsync() {
    CBStatesImpl cb = new CBStatesImpl();
    CBDescIn descIn = new CBDescIn(50000, 50000, 1208);
    synchronized (cb) {
        ROproperty.get_async(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
    assertEquals(ROproperty.default_value(), response.value);
    // check descriptor
    assertEquals(descIn.id_tag, response.desc.id_tag);
    // check completion
    assertEquals(0, response.completion.code);
    assertEquals(0, response.completion.type);
    assertEquals(0, response.completion.previousError.length);
    // less than 5s
    assertTrue((UTCUtility.utcJavaToOmg(System.currentTimeMillis()) - response.completion.timeStamp) < 50000000);
}
Also used : CBDescIn(alma.ACS.CBDescIn)

Example 12 with CBDescIn

use of alma.ACS.CBDescIn in project ACS by ACS-Community.

the class LampAccessImpl method setLampBrightness.

/////////////////////////////////////////////////////////////
// Implementation of LampAccessOperations
/////////////////////////////////////////////////////////////
/**
	 * Passes a value to the brightness property of the lamp component. 
	 * @param brightness
	 * @see alma.demo.LampAccessOperations#setLampBrightness(double)
	 * @throws LampUnavailable
	 */
public void setLampBrightness(double brightness) throws LampUnavailable {
    m_logger.finer("LampAccess:setLampBrightness(" + brightness + ") called...");
    if (m_brightness == null) {
        m_brightness = getLampBrightnessProperty();
        m_logger.info("m_brightness initialized...");
    }
    if (m_cb == null) {
        try {
            m_cb = new CBvoidLampAccess(m_logger);
            m_logger.info("CBvoidLampAccess instantiated...");
            m_cbvoid = alma.ACS.CBvoidHelper.narrow(m_containerServices.activateOffShoot(m_cb));
        //				m_logger.warning("doof test: second activation...");
        //				CBvoidLampAccess cb2 = new CBvoidLampAccess(m_logger);
        //				m_containerServices.activateOffShoot(cb2);
        } 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...");
    }
    try {
        m_logger.info("before callback done...");
        getLampBrightnessProperty().set_async(brightness, m_cbvoid, m_desc);
        m_logger.finer("now callback done...");
    } catch (Exception ex) {
        m_logger.log(Level.SEVERE, "ex in setLampBrightness impl", ex);
        throw new LampUnavailable(ex.getMessage());
    }
}
Also used : LampUnavailable(alma.demo.LampUnavailable) CBDescIn(alma.ACS.CBDescIn) ComponentLifecycleException(alma.acs.component.ComponentLifecycleException)

Example 13 with CBDescIn

use of alma.ACS.CBDescIn 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 CBDescIn

use of alma.ACS.CBDescIn in project ACS by ACS-Community.

the class SimpleMasterComponentTest 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 = "SIMPLEMASTERCOMPONENT1";
            org.omg.CORBA.Object obj;
            try {
                obj = manager.get_component(clientInfo.h, COMPONENT_NAME, true);
                SimpleMasterComponent simpleMasterComponent = SimpleMasterComponentHelper.narrow(obj);
                ROstringSeq currentStateHierarchy = simpleMasterComponent.currentStateHierarchy();
                // syncvalue retrival
                System.out.println("Current state hierarchy: " + getStringArray(currentStateHierarchy.get_sync(new CompletionHolder())));
                System.out.println("Monitoring - 1s interval...");
                // create a monitor
                MonitorstringSeq monitor = currentStateHierarchy.create_monitor(new CBstringSeqImpl()._this(orb), new CBDescIn());
                // sleep for a while
                try {
                    Thread.sleep(10000);
                } catch (InterruptedException ie) {
                }
                ;
                monitor.set_timer_trigger(0);
                monitor.set_value_trigger(new String[0], true);
                System.out.println("On-change monitoring...");
                // 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 (NoPermissionEx ex) {
                ex.printStackTrace();
            }
            logout(manager, clientInfo);
        }
    }
    finalizeCORBA();
}
Also used : SimpleMasterComponent(test.jbaci.SimpleMasterComponent) POAManager(org.omg.PortableServer.POAManager) Manager(si.ijs.maci.Manager) CBDescIn(alma.ACS.CBDescIn) ROstringSeq(alma.ACS.ROstringSeq) MonitorstringSeq(alma.ACS.MonitorstringSeq) NoPermissionEx(alma.maciErrType.NoPermissionEx) CompletionHolder(alma.ACSErr.CompletionHolder) ClientInfo(si.ijs.maci.ClientInfo)

Example 15 with CBDescIn

use of alma.ACS.CBDescIn in project ACS by ACS-Community.

the class PropertySeqTest method testCreatePostponedMonitor.

public void testCreatePostponedMonitor() {
    // TODO tmp
    if (true)
        return;
    try {
        CBDescIn descIn = new CBDescIn(50000, 50000, 1208);
        ROpropertyLongSeq.create_postponed_monitor(0, null, descIn);
        fail("NO_IMPLEMENT exception expected");
    } catch (NO_IMPLEMENT ex) {
    // OK
    }
}
Also used : NO_IMPLEMENT(org.omg.CORBA.NO_IMPLEMENT) CBDescIn(alma.ACS.CBDescIn)

Aggregations

CBDescIn (alma.ACS.CBDescIn)57 CompletionHolder (alma.ACSErr.CompletionHolder)11 Monitordouble (alma.ACS.Monitordouble)10 Completion (alma.ACSErr.Completion)7 Callback (alma.ACS.Callback)6 BACIDispatchAction (alma.ACS.jbaci.BACIDispatchAction)6 NO_IMPLEMENT (org.omg.CORBA.NO_IMPLEMENT)6 RWdouble (alma.ACS.RWdouble)5 Monitorfloat (alma.ACS.Monitorfloat)4 Monitorlong (alma.ACS.Monitorlong)4 ROdouble (alma.ACS.ROdouble)3 OffShoot (alma.ACS.OffShoot)2 LampUnavailable (alma.demo.LampUnavailable)2 NoPermissionEx (alma.maciErrType.NoPermissionEx)2 POAManager (org.omg.PortableServer.POAManager)2 ClientInfo (si.ijs.maci.ClientInfo)2 Manager (si.ijs.maci.Manager)2 CBDescOut (alma.ACS.CBDescOut)1 CBdouble (alma.ACS.CBdouble)1 CBlongPOA (alma.ACS.CBlongPOA)1