OPCHDA ReadRaw: how to pass [in, out] structures?

Help
2014-01-23
2014-02-27
  • Hello,

    This has been asked on the list already and the solution has apparently been found but no details were given:

    https://sourceforge.net/projects/j-interop/forums/forum/600730/topic/1922535

    and later

    https://sourceforge.net/p/j-interop/discussion/600730/thread/390f67c8/

    but I cannot get it to work and hence my request for help.

    I am working on the implementation of the OPC HDA ReadRaw method and it requires to pass two [in, out] structure pointers

    typedef struct tagOPCHDA_TIME
    {
    BOOL bString;
    [string] LPWSTR szTime;
    FILETIME ftTime;
    }
    OPCHDA_TIME;

    The call is

    HRESULT ReadRaw(
    [in, out] OPCHDA_TIME htStartTime,

    [in, out] OPCHDA_TIME
    htEndTime,
    [in] DWORD dwNumValues,
    [in] BOOL bBounds,
    [in] DWORD dwNumItems,
    [in, size_is(dwNumItems)] OPCHANDLE* phServer,
    [out, size_is(,dwNumItems)] OPCHDA_ITEM ppItemValues,

    [out, size_is(,dwNumItems)] HRESULT
    ppErrors
    );

    I do it the following way but it results in 0x800706F7 (Stub received bad data) error:

        callObject.addInParamAsPointer(new JIPointer(startTime.toStruct(), true), JIFlags.FLAG_NULL);
        callObject.addInParamAsPointer(new JIPointer(endTime.toStruct(), true), JIFlags.FLAG_NULL);
    
        callObject.addInParamAsInt(nValues, JIFlags.FLAG_NULL);
        callObject.addInParamAsBoolean(bounds, JIFlags.FLAG_NULL);
        callObject.addInParamAsInt(handles.length, JIFlags.FLAG_NULL);
        callObject.addInParamAsArray(new JIArray(handles, true), JIFlags.FLAG_NULL);
    
        // this is to get OPCHDA_Time structures back
        callObject.addOutParamAsObject(new JIPointer(OPCHDATime.getStruct()), JIFlags.FLAG_NULL);
        callObject.addOutParamAsObject(new JIPointer(OPCHDATime.getStruct()), JIFlags.FLAG_NULL);
    
        callObject.addOutParamAsObject(new JIPointer(new JIArray(OPCHDAItem.getStruct(), null, 1, true)), JIFlags.FLAG_NULL);
        callObject.addOutParamAsObject(new JIPointer(new JIArray(Integer.class, null, 1, true)), JIFlags.FLAG_NULL);
    
        Object result[] = Helper.callRespectSFALSE(getCOMObject(), callObject);
    

    Can anybody please let me know what might be wrong? Is this the correct way to work with [in, out] agruments?

    I also see that sometimes people pass Integers instead of Booleans in the arguments, I have tried both ways in this call and the result is the same. So I assume the problem is elsewhere.

    Thanks a lot.

    Best regards,
    AR

     
  • Hello,

    I would really appreciate it if somebody could share their thoughts on this.

    Thanks.

    AR