Search in sources :

Example 91 with Any

use of org.omg.CORBA.Any in project ACS by ACS-Community.

the class CorbaAnyExtractionTest method create_any.

private Any create_any() {
    Any ret = acsCorba.getORB().create_any();
    assertThat(ret, notNullValue());
    return ret;
}
Also used : Any(org.omg.CORBA.Any)

Example 92 with Any

use of org.omg.CORBA.Any in project ACS by ACS-Community.

the class CorbaAnyExtractionTest method testExtractData_doubleBlobDataSeq.

/**
	 * Test of extractData method for 'doubleBlobDataSeq' data.
	 */
@Test
public void testExtractData_doubleBlobDataSeq() throws Exception {
    String propertyName = "MODULE_MODE_STATUS";
    Any any = create_any();
    double[] doubleDataArray = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 };
    doubleBlobData[] doubleBlobDataArray = createDoubleBlobData(doubleDataArray);
    doubleBlobDataSeqHelper.insert(any, doubleBlobDataArray);
    List<MonitorPointTimeSeries> extractedData = anyExtractor.extractData(any, propertyName);
    assertThat(extractedData, hasSize(1));
    // Check the raw data
    MonitorPointTimeSeries mpTs = extractedData.get(0);
    assertThat(mpTs.getCorbaTypeId(), equalTo("IDL:alma/TMCDB/doubleBlobDataSeq:1.0"));
    assertThat(mpTs.getMonitorPointIndex(), equalTo(0));
    List<MonitorPointValue> dataList = mpTs.getDataList();
    assertThat(dataList, hasSize(doubleDataArray.length));
    for (int i = 0; i < doubleBlobDataArray.length; i++) {
        MonitorPointValue mpVal = dataList.get(i);
        assertThat(mpVal.getTime(), equalTo(BASE_TIME + i));
        assertThat(mpVal.getData(), contains((Object) new Double(doubleDataArray[i])));
    }
    // Generate and check the CLOB data
    String clobActual = clobber.generateClob(mpTs);
    String clobExpected = BASE_TIME + "|1.0|" + (BASE_TIME + 1) + "|2.0|" + (BASE_TIME + 2) + "|3.0|" + (BASE_TIME + 3) + "|4.0|" + (BASE_TIME + 4) + "|5.0|" + (BASE_TIME + 5) + "|6.0|" + (BASE_TIME + 6) + "|7.0|" + (BASE_TIME + 7) + "|8.0|" + (BASE_TIME + 8) + "|9.0|" + (BASE_TIME + 9) + "|10.0\n";
    assertThat(clobActual, equalTo(clobExpected));
    logger.info("Validated doubleBlobDataSeq.");
}
Also used : TMCDB.doubleBlobData(alma.TMCDB.doubleBlobData) MonitorPointValue(alma.acs.monitoring.MonitorPointValue) Any(org.omg.CORBA.Any) MonitorPointTimeSeries(alma.acs.monitoring.MonitorPointTimeSeries) Test(org.junit.Test)

Example 93 with Any

use of org.omg.CORBA.Any in project ACS by ACS-Community.

the class BACIRemoteAccess method invokeAccessor.

/**
	 * Insert the method's description here.
	 * Creation date: (7.11.2000 22:52:30)
	 * @return si.ijs.acs.objectexplorer.engine.BACI.BACIRemoteCall
	 * @param att si.ijs.acs.objectexplorer.engine.BACI.BACIAttribute
	 */
BACIRemoteCall invokeAccessor(BACIAttribute att) {
    if (att == null)
        throw new NullPointerException("att");
    BACIRemote target = (BACIRemote) att.getIntrospectable();
    if (target.getCORBARef() == null)
        throw new RemoteException("Cannot invoke attribute accessor '" + att + "' on object '" + target.getName() + "' because it is not connected.");
    org.omg.CORBA.Object remote = target.getCORBARef();
    AttributeDescription desc = att.getAttributeDesc();
    /* begin DII stanza */
    Request req = remote._request(BACIIntrospector.attributeNameToMethodName(desc.name));
    req.set_return_type(desc.type);
    java.lang.Object[] params = new java.lang.Object[0];
    int time = 0;
    notifier.reportMessage("Invoking accessor '" + target.getName() + "." + att + "()'.");
    notifier.reportDebug("BACIRemoteAccess::invokeAccessor", "Sending deferred attribute accessor '" + target.getName() + "." + att + "()'.");
    try {
        req.send_deferred();
        while (!req.poll_response()) {
            try {
                Thread.sleep(POLL_SLEEP);
                time += POLL_SLEEP;
            } catch (InterruptedException ie) {
            }
            if (time > POLL_TIMEOUT) {
                notifier.reportError("Timeout (" + POLL_TIMEOUT + " ms) while polling for response from '" + att + "' on '" + target.getName() + "'.");
                return new BACIRemoteCall(target, att, params, null, true, null);
            }
        }
        // check exception
        checkException(target, req);
        notifier.reportDebug("BACIRemoteAccess::invokeAccessor", "Received response for '" + target.getName() + "." + att + "()'.");
        //	req.get_response();
        Any anyRet = req.return_value();
        java.lang.Object oRet = null;
        if (anyRet != null)
            oRet = baciIntrospector.extractAny(anyRet);
        notifier.reportDebug("BACIRemoteAccess::invokeAccessor", "Successfully unpacked response for '" + target.getName() + "." + att + "()'.");
        return new BACIRemoteCall(target, att, params, oRet, false, null);
    } catch (Exception e) {
        notifier.reportError("Exception during deferred remote invocation.", e);
        return new BACIRemoteCall(target, att, params, null, false, e);
    }
/* end DII stanza */
}
Also used : Request(org.omg.CORBA.Request) Any(org.omg.CORBA.Any) IntrospectionInconsistentException(si.ijs.acs.objectexplorer.engine.IntrospectionInconsistentException) AcsJException(alma.acs.exceptions.AcsJException) DataException(si.ijs.acs.objectexplorer.engine.DataException) NonStickyConnectFailedRemoteException(si.ijs.acs.objectexplorer.engine.NonStickyConnectFailedRemoteException) RemoteException(si.ijs.acs.objectexplorer.engine.RemoteException) AttributeDescription(org.omg.CORBA.AttributeDescription) NonStickyConnectFailedRemoteException(si.ijs.acs.objectexplorer.engine.NonStickyConnectFailedRemoteException) RemoteException(si.ijs.acs.objectexplorer.engine.RemoteException)

Example 94 with Any

use of org.omg.CORBA.Any in project ACS by ACS-Community.

the class BACIIntrospector method displaySequence.

public void displaySequence(TypeCode tc, Any argument) {
    if (tc == null)
        throw new NullPointerException("tc");
    if (argument == null)
        throw new NullPointerException("argument");
    DynAny dany = null;
    try {
        dany = ra.getDynFact().create_dyn_any(argument);
    } catch (org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode e) {
        e.printStackTrace();
    }
    //Class<?> cl = getClassType(argument.type());
    Any[] els;
    if (tc.kind() == TCKind.tk_sequence)
        els = ((DynSequence) dany).get_elements();
    else if (tc.kind() == TCKind.tk_array)
        els = ((DynArray) dany).get_elements();
    else
        els = new Any[0];
    for (int i = 0; i < els.length; i++) {
        displayAny(els[i]);
    }
}
Also used : DynSequence(org.omg.DynamicAny.DynSequence) DynAny(org.omg.DynamicAny.DynAny) Any(org.omg.CORBA.Any) DynAny(org.omg.DynamicAny.DynAny)

Example 95 with Any

use of org.omg.CORBA.Any in project ACS by ACS-Community.

the class BACIIntrospector method insertSequence.

public Any insertSequence(TypeCode tc, Any argument, java.lang.Object obj) {
    if (argument == null)
        throw new NullPointerException("argument");
    if (obj == null)
        throw new NullPointerException("obj");
    if (!obj.getClass().isArray())
        throw new IllegalArgumentException("The parameter obj has to be a sequence");
    java.lang.Object[] objs;
    if (obj.getClass().getComponentType().isPrimitive())
        objs = DataFormatter.convertPrimitiveArray(obj);
    else
        objs = (java.lang.Object[]) obj;
    DynAny dany;
    try {
        dany = ra.getDynFact().create_dyn_any_from_type_code(tc);
    } catch (org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode e) {
        e.printStackTrace();
        return null;
    }
    Any[] els = new Any[objs.length];
    try {
        for (int i = 0; i < els.length; i++) {
            DynAny dany2;
            try {
                dany2 = ra.getDynFact().create_dyn_any_from_type_code(tc.content_type());
            } catch (org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode e) {
                e.printStackTrace();
                return null;
            }
            els[i] = dany2.to_any();
            els[i] = insertAny(tc.content_type(), els[i], objs[i]);
        }
        if (tc.kind() == TCKind.tk_sequence) {
            ((DynSequence) dany).set_elements(els);
            ((DynSequence) dany).set_length(els.length);
        } else if (tc.kind() == TCKind.tk_array)
            ((DynArray) dany).set_elements(els);
    } catch (org.omg.DynamicAny.DynAnyPackage.TypeMismatch e) {
        e.printStackTrace();
    } catch (org.omg.DynamicAny.DynAnyPackage.InvalidValue e) {
        e.printStackTrace();
    } catch (org.omg.CORBA.TypeCodePackage.BadKind e) {
        e.printStackTrace();
    }
    return dany.to_any();
}
Also used : DynArray(org.omg.DynamicAny.DynArray) Any(org.omg.CORBA.Any) DynAny(org.omg.DynamicAny.DynAny) DynSequence(org.omg.DynamicAny.DynSequence) DynAny(org.omg.DynamicAny.DynAny) IRObject(org.omg.CORBA.IRObject)

Aggregations

Any (org.omg.CORBA.Any)107 MonitorBlob (alma.TMCDB.MonitorBlob)20 MonitorDataBlock (alma.TMCDB.MonitorDataBlock)20 ComponentData (alma.acs.monitoring.DAO.ComponentData)15 ServiceContext (org.omg.IOP.ServiceContext)13 BAD_PARAM (org.omg.CORBA.BAD_PARAM)10 SASContextBody (org.omg.CSI.SASContextBody)10 AcsJException (alma.acs.exceptions.AcsJException)9 Test (org.junit.Test)9 Description (org.omg.CORBA.ContainedPackage.Description)9 FormatMismatch (org.omg.IOP.CodecPackage.FormatMismatch)8 TypeMismatch (org.omg.IOP.CodecPackage.TypeMismatch)8 ContainedOperations (org.omg.CORBA.ContainedOperations)7 NVList (org.omg.CORBA.NVList)7 InvalidTypeForEncoding (org.omg.IOP.CodecPackage.InvalidTypeForEncoding)7 TMCDB.doubleBlobData (alma.TMCDB.doubleBlobData)6 TMCDB.doubleSeqBlobData (alma.TMCDB.doubleSeqBlobData)6 TMCDB.floatBlobData (alma.TMCDB.floatBlobData)6 MonitorPointTimeSeries (alma.acs.monitoring.MonitorPointTimeSeries)6 MonitorPointValue (alma.acs.monitoring.MonitorPointValue)6