Search in sources :

Example 31 with CBDescIn

use of alma.ACS.CBDescIn in project ACS by ACS-Community.

the class PropertySeqTest method testCreateMonitorDouble.

public void testCreateMonitorDouble() {
    // TODO do test with null callback ;)
    // TODO implement...
    CBdoubleSeqImpl cb = new CBdoubleSeqImpl();
    CBDescIn descIn = new CBDescIn(50000, 50000, 1208);
    Monitordouble monitor = ROpropertyDoubleSeq.create_monitor(cb._this(orb), descIn);
    try {
        // 10.5 sec
        Thread.sleep(10500);
    } catch (InterruptedException ie) {
    }
    synchronized (cb) {
        try {
            monitor.destroy();
            // wait for 3s
            cb.wait(3000);
        } catch (InterruptedException ie) {
        }
    }
// TODO test if done was called
}
Also used : CBDescIn(alma.ACS.CBDescIn) Monitordouble(alma.ACS.Monitordouble)

Example 32 with CBDescIn

use of alma.ACS.CBDescIn in project ACS by ACS-Community.

the class StateChangeListener method createMonitor.

/**
	 * Creates a monitor for <code>statesProperty</code> from this instance.
	 * 
	 * @param statesProperty
	 * @param contSrv
	 * @return  usually not needed
	 * @throws Exception
	 */
public MonitorstringSeq createMonitor(ROstringSeq statesProperty, ContainerServices contSrv) throws Exception {
    this.contSrv = contSrv;
    if (monitor != null) {
        destroyMonitor();
    }
    this.statesProperty = statesProperty;
    // register this callback object with CORBA
    OffShoot offshoot = contSrv.activateOffShoot(this);
    CBstringSeq cbStringSeq = CBstringSeqHelper.narrow(offshoot);
    // register callback CORBA object with the statesProperty as a monitor  
    monitor = statesProperty.create_monitor(cbStringSeq, new CBDescIn());
    // baci.idl: "On creation, the only trigger present will be the timer trigger. 
    // Calling the set_value_trigger method determines the behaviour of the value trigger. 
    // The enable parameter determines whether the value trigger is active or not ." 
    // Strings have no triggerable value, thus don't care 
    monitor.set_value_trigger(new String[0], true);
    // baci.idl: "Timer trigger can be disabled by passing the value 0 for timer parameter." 
    monitor.set_timer_trigger(0);
    return monitor;
}
Also used : OffShoot(alma.ACS.OffShoot) CBDescIn(alma.ACS.CBDescIn) CBstringSeq(alma.ACS.CBstringSeq)

Example 33 with CBDescIn

use of alma.ACS.CBDescIn in project ACS by ACS-Community.

the class ManagerProxy method releaseComponentAsync.

public void releaseComponentAsync(int id, URI curl, LongCompletionCallback callback) throws AcsJNoPermissionEx, AcsJBadParameterEx {
    try {
        final LongCompletionCallback fcallback = callback;
        CBlongPOA cbo = new CBlongPOA() {

            public boolean negotiate(long time_to_transmit, CBDescOut desc) {
                return false;
            }

            public void working(int value, Completion c, CBDescOut desc) {
            // noop
            }

            public void done(int value, Completion c, CBDescOut desc) {
                if (c.code == 0 && c.type == 0)
                    fcallback.done(value);
                else
                    // TODO maybe convert to specific exceptions
                    fcallback.failed(value, AcsJCompletion.fromCorbaCompletion(c).getAcsJException());
            }
        };
        CBDescIn desc = new CBDescIn(0, 0, 0);
        manager.release_component_async(id, curl.toString(), cbo._this(), desc);
    } catch (NoPermissionEx nop) {
        throw new AcsJNoPermissionEx(nop);
    }
}
Also used : Completion(alma.ACSErr.Completion) AcsJCompletion(alma.acs.exceptions.AcsJCompletion) CBDescOut(alma.ACS.CBDescOut) AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) CBlongPOA(alma.ACS.CBlongPOA) NoPermissionEx(alma.maciErrType.NoPermissionEx) AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) CBDescIn(alma.ACS.CBDescIn)

Example 34 with CBDescIn

use of alma.ACS.CBDescIn in project ACS by ACS-Community.

the class BuildingTest 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 = "BUILDING1";
            org.omg.CORBA.Object obj;
            try {
                obj = manager.get_component(clientInfo.h, COMPONENT_NAME, true);
                Building building = BuildingHelper.narrow(obj);
                ROstring version = building.version();
                // syncvalue retrival
                System.out.println("Version: " + version.get_sync(new CompletionHolder()));
                // create a monitor
                Monitor monitor = version.create_monitor(new CBstringImpl()._this(orb), new CBDescIn());
                // 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 (Exception ex) {
                ex.printStackTrace();
                System.out.println("Failed to release component.");
            }
            logout(manager, clientInfo);
        }
    }
    finalizeCORBA();
}
Also used : POAManager(org.omg.PortableServer.POAManager) Manager(si.ijs.maci.Manager) ROstring(alma.ACS.ROstring) CBDescIn(alma.ACS.CBDescIn) Monitor(alma.ACS.Monitor) CompletionHolder(alma.ACSErr.CompletionHolder) ClientInfo(si.ijs.maci.ClientInfo)

Example 35 with CBDescIn

use of alma.ACS.CBDescIn in project ACS by ACS-Community.

the class PropertySeqTest method testOnChangeMonitorLong.

public void testOnChangeMonitorLong() {
    // TODO implement...
    CBlongSeqImpl cb = new CBlongSeqImpl();
    CBDescIn descIn = new CBDescIn(50000, 50000, 1208);
    Monitorlong monitor = ROpropertyLongSeq.create_monitor(cb._this(orb), descIn);
    // disable on time trigger
    monitor.set_timer_trigger(0);
    try {
        // sleep for 5 sec
        Thread.sleep(3000);
    } catch (InterruptedException ie) {
    }
    // TODO monitors should not come
    // every change test
    monitor.set_value_trigger(0, true);
    // TODO change value here...
    // ups RO monitor ;)
    // !!! TMP - tested with backdoor via alarm_high_on()...
    ROpropertyLongSeq.alarm_high_on();
    try {
        Thread.sleep(3000);
    } catch (InterruptedException ie) {
    }
    // disable test
    monitor.set_value_trigger(0, false);
    ROpropertyLongSeq.alarm_high_on();
    try {
        Thread.sleep(3000);
    } catch (InterruptedException ie) {
    }
    monitor.set_value_trigger(0, true);
    ROpropertyLongSeq.alarm_high_on();
    try {
        Thread.sleep(3000);
    } catch (InterruptedException ie) {
    }
    System.out.println("------");
    // disable test
    monitor.suspend();
    ROpropertyLongSeq.alarm_high_on();
    try {
        Thread.sleep(3000);
    } catch (InterruptedException ie) {
    }
    // / ... this should revive it
    monitor.resume();
    System.out.println("------");
    ROpropertyLongSeq.alarm_high_on();
    try {
        Thread.sleep(3000);
    } catch (InterruptedException ie) {
    }
    synchronized (cb) {
        try {
            monitor.destroy();
            // wait for 3s
            cb.wait(3000);
        } catch (InterruptedException ie) {
        }
    }
// TODO test if done was called
}
Also used : Monitorlong(alma.ACS.Monitorlong) CBDescIn(alma.ACS.CBDescIn)

Aggregations

CBDescIn (alma.ACS.CBDescIn)57 CompletionHolder (alma.ACSErr.CompletionHolder)11 Monitordouble (alma.ACS.Monitordouble)10 Completion (alma.ACSErr.Completion)7 Callback (alma.ACS.Callback)6 BACIDispatchAction (alma.ACS.jbaci.BACIDispatchAction)6 NO_IMPLEMENT (org.omg.CORBA.NO_IMPLEMENT)6 RWdouble (alma.ACS.RWdouble)5 Monitorfloat (alma.ACS.Monitorfloat)4 Monitorlong (alma.ACS.Monitorlong)4 ROdouble (alma.ACS.ROdouble)3 OffShoot (alma.ACS.OffShoot)2 LampUnavailable (alma.demo.LampUnavailable)2 NoPermissionEx (alma.maciErrType.NoPermissionEx)2 POAManager (org.omg.PortableServer.POAManager)2 ClientInfo (si.ijs.maci.ClientInfo)2 Manager (si.ijs.maci.Manager)2 CBDescOut (alma.ACS.CBDescOut)1 CBdouble (alma.ACS.CBdouble)1 CBlongPOA (alma.ACS.CBlongPOA)1