Search in sources :

Example 1 with SampObj

use of alma.acssamp.SampObj in project ACS by ACS-Community.

the class SamplingManagerTest method testGetSampObjExceptions.

public void testGetSampObjExceptions() throws Exception {
    SamplingManager man1 = SamplingManager.getInstance("SAMP1");
    SampObj temp = null;
    boolean exceptionCaught;
    exceptionCaught = false;
    try {
        temp = man1.getSamplingObj(new SampDetail("SAMPLED4", "my_ROdouble", 100, 1));
    } catch (CouldntAccessComponentEx e) {
        exceptionCaught = true;
    }
    assertTrue(exceptionCaught);
    exceptionCaught = false;
    try {
        temp = man1.getSamplingObj(new SampDetail("SAMPLED1", "my_ROstring", 100, 1));
    } catch (TypeNotSupportedEx e) {
        exceptionCaught = true;
    }
    assertTrue(exceptionCaught);
    exceptionCaught = false;
    try {
        temp = man1.getSamplingObj(new SampDetail("SAMPLED2", "my_RWdouble", 100, 1));
    } catch (Exception e) {
        exceptionCaught = true;
    }
    assertTrue(!exceptionCaught);
    assertNotNull(temp);
}
Also used : SampDetail(cl.utfsm.samplingSystemUI.core.SampDetail) SampObj(alma.acssamp.SampObj) SamplingManager(cl.utfsm.samplingSystemUI.core.SamplingManager) TypeNotSupportedEx(alma.ACSErrTypeCommon.TypeNotSupportedEx) CouldntAccessComponentEx(alma.ACSErrTypeCommon.CouldntAccessComponentEx) SamplingManagerException(cl.utfsm.samplingSystemUI.core.SamplingManagerException)

Example 2 with SampObj

use of alma.acssamp.SampObj in project ACS by ACS-Community.

the class SamplingManagerTest method testGetSampObj.

public void testGetSampObj() throws Exception {
    SamplingManager man1 = null;
    SampDetail sDetail1 = new SampDetail("LAMP1", "brightness", 100, 1);
    SampDetail sDetail2 = new SampDetail("LAMP1", "brightness", 200, 1);
    SampObj temp;
    man1 = SamplingManager.getInstance("SAMP1");
    temp = man1.getSamplingObj(sDetail1);
    assertNotNull(temp);
    assertNotNull(man1.getSamplingObj(sDetail2));
    assertEquals(man1.getSamplingObj(sDetail1), temp);
    assertEquals(man1.getSamplingObj(sDetail1), man1.getSamplingObj(sDetail1));
    assertNotSame(man1.getSamplingObj(sDetail2), temp);
}
Also used : SampDetail(cl.utfsm.samplingSystemUI.core.SampDetail) SampObj(alma.acssamp.SampObj) SamplingManager(cl.utfsm.samplingSystemUI.core.SamplingManager)

Example 3 with SampObj

use of alma.acssamp.SampObj in project ACS by ACS-Community.

the class acssampSupplier method sampleLampBrightness.

/**
	 * Calls methods on our samp component to sample LAMP1.brightness,
	 * with the full show of suspending, resuming, stopping and eventually destroying this. 
	 */
public void sampleLampBrightness() throws AcsJContainerServicesEx {
    // get (CORBA) reference to C++ Samp component (type IDL:alma/acssamp/Samp:1.0)
    String sampCurl = "SAMP1";
    Samp samp = SampHelper.narrow(getContainerServices().getComponent(sampCurl));
    m_logger.info("Will now get component 'SAMP1' to sample the lamp brightness...");
    SampObj sampObj = null;
    try {
        // register for sampling the 'brightness' property of the Lamp component
        // in a way that the report rate is 10 times slower than the sampling rate
        sampObj = samp.initSampObj("LAMP1", "brightness", 1000000, 10000000);
        sampObj.start();
        m_logger.info("ACS sampling of Lamp#brightness has started. Will sample this for one minute.");
        Thread.sleep(60000);
        sampObj.suspend();
        m_logger.info("ACS sampling suspended. Will resume after 5 seconds.");
        Thread.sleep(5000);
        sampObj.resume();
        m_logger.info("ACS sampling resumed. Will sample another 6 seconds.");
        Thread.sleep(6000);
        sampObj.stop();
        m_logger.info("ACS sampling stopped. Will destroy the sampling object in 2 seconds.");
        Thread.sleep(2000);
    } catch (Exception e) {
        m_logger.log(Level.SEVERE, "Unexpected exception occured while using the samp component.", e);
    } finally {
        if (sampObj != null) {
            sampObj.destroy();
        }
        if (samp != null) {
            getContainerServices().releaseComponent(sampCurl);
        }
        m_logger.info("ACS sampling destroyed.");
    }
}
Also used : Samp(alma.acssamp.Samp) SampObj(alma.acssamp.SampObj)

Aggregations

SampObj (alma.acssamp.SampObj)3 SampDetail (cl.utfsm.samplingSystemUI.core.SampDetail)2 SamplingManager (cl.utfsm.samplingSystemUI.core.SamplingManager)2 CouldntAccessComponentEx (alma.ACSErrTypeCommon.CouldntAccessComponentEx)1 TypeNotSupportedEx (alma.ACSErrTypeCommon.TypeNotSupportedEx)1 Samp (alma.acssamp.Samp)1 SamplingManagerException (cl.utfsm.samplingSystemUI.core.SamplingManagerException)1