use of test.jbaci.SimpleMasterComponent 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();
}
Aggregations