Search in sources :

Example 1 with SimpleMasterComponent

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();
}
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)

Aggregations

CBDescIn (alma.ACS.CBDescIn)1 MonitorstringSeq (alma.ACS.MonitorstringSeq)1 ROstringSeq (alma.ACS.ROstringSeq)1 CompletionHolder (alma.ACSErr.CompletionHolder)1 NoPermissionEx (alma.maciErrType.NoPermissionEx)1 POAManager (org.omg.PortableServer.POAManager)1 ClientInfo (si.ijs.maci.ClientInfo)1 Manager (si.ijs.maci.Manager)1 SimpleMasterComponent (test.jbaci.SimpleMasterComponent)1