Search in sources :

Example 1 with LampUnavailable

use of alma.demo.LampUnavailable 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 2 with LampUnavailable

use of alma.demo.LampUnavailable 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 3 with LampUnavailable

use of alma.demo.LampUnavailable in project ACS by ACS-Community.

the class LampCallbackImpl method stopMonitor.

/**
	 * Stops the monitor upon request.
	 * @see alma.demo.LampCallbackOperations#stopMonitor()
	 * @throws alma.demo.LampUnavailable
	 */
public void stopMonitor() throws LampUnavailable {
    if (m_monitor != null) {
        try {
            m_monitor.destroy();
            m_containerServices.deactivateOffShoot(m_cb);
            m_logger.finer("deactivated CBdoubleLampCallback offshoot CORBA object.");
        } catch (Exception ex) {
            m_logger.log(Level.SEVERE, "ex in stopMonitor impl", ex);
            throw new LampUnavailable(ex.getMessage());
        }
    }
}
Also used : LampUnavailable(alma.demo.LampUnavailable) ACSException(alma.ACSErr.ACSException) AcsJException(alma.acs.exceptions.AcsJException)

Example 4 with LampUnavailable

use of alma.demo.LampUnavailable in project ACS by ACS-Community.

the class LampAccessImpl method getLampBrightnessProperty.

/////////////////////////////////////////////////////////////
// other
/////////////////////////////////////////////////////////////	
/**
	 * Gets the lamp component's (LAMP1) brightness as RWdouble.
	 * @return RWdouble
	 * @throws LampUnavailable
	 */
RWdouble getLampBrightnessProperty() throws LampUnavailable {
    if (m_brightness == null) {
        org.omg.CORBA.Object cmp = null;
        try {
            cmp = m_containerServices.getComponent(m_lampCurl);
            Lamp lamp = LampHelper.narrow(cmp);
            m_brightness = lamp.brightness();
        } catch (Exception ex) {
            throw new LampUnavailable(ex.getMessage());
        }
        if (m_brightness == null) {
            throw new LampUnavailable("failed to obtain the lamp component's brightness property (NULL).");
        }
    }
    return m_brightness;
}
Also used : LampUnavailable(alma.demo.LampUnavailable) Lamp(alma.acsexmplLamp.Lamp) ComponentLifecycleException(alma.acs.component.ComponentLifecycleException)

Example 5 with LampUnavailable

use of alma.demo.LampUnavailable in project ACS by ACS-Community.

the class LampAccessImpl method getLampBrightness.

/**
	 * Returns the magnitude of the lamp component's brightness. 
	 * @return double
	 * @see alma.demo.LampAccessOperations#getLampBrightness()
	 * @throws LampUnavailable
	 */
public double getLampBrightness() throws LampUnavailable {
    m_logger.finer("LampAccess:getLampBrightness() called...");
    try {
        m_brightness = getLampBrightnessProperty();
        CompletionHolder compHolder = new CompletionHolder();
        return m_brightness.get_sync(compHolder);
    } catch (Exception ex) {
        throw new LampUnavailable(ex.getMessage());
    }
}
Also used : LampUnavailable(alma.demo.LampUnavailable) CompletionHolder(alma.ACSErr.CompletionHolder) ComponentLifecycleException(alma.acs.component.ComponentLifecycleException)

Aggregations

LampUnavailable (alma.demo.LampUnavailable)5 ComponentLifecycleException (alma.acs.component.ComponentLifecycleException)3 CBDescIn (alma.ACS.CBDescIn)2 ACSException (alma.ACSErr.ACSException)2 CompletionHolder (alma.ACSErr.CompletionHolder)2 AcsJException (alma.acs.exceptions.AcsJException)2 CBdouble (alma.ACS.CBdouble)1 Monitordouble (alma.ACS.Monitordouble)1 RWdouble (alma.ACS.RWdouble)1 Lamp (alma.acsexmplLamp.Lamp)1