use of alma.acssamp.Samp in project ACS by ACS-Community.
the class SamplingManagerTest method testGetSamplingObj.
public void testGetSamplingObj() throws Exception {
SamplingManager man1 = null;
SamplingManager man2 = null;
Samp sampManager1 = null;
Samp sampManager2 = null;
man1 = SamplingManager.getInstance("SAMP1");
assertNotNull(man1);
sampManager1 = man1.getSampReference();
assertNotNull(sampManager1);
sampManager2 = man1.getSampReference();
assertNotNull(sampManager2);
assertEquals(sampManager1, sampManager2);
man2 = SamplingManager.getInstance("SAMP2");
assertNotNull(man2);
sampManager1 = man2.getSampReference();
assertNotNull(sampManager1);
sampManager2 = man2.getSampReference();
assertNotNull(sampManager2);
assertEquals(sampManager1, sampManager2);
sampManager1 = man1.getSampReference();
sampManager2 = man2.getSampReference();
assertNotSame(sampManager1, sampManager2);
}
use of alma.acssamp.Samp 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.");
}
}
Aggregations