logo       

Trying to Bride OPC Interfaces: msg#00021

windows.devel.jawin

Subject: Trying to Bride OPC Interfaces

Hello Everybody,

I am new to the list.

I want to be able to access to OPC Interfaces (OLE for Process Control)
through Java, and i have found JAWIN. Seems very interesting.

That OPC Interfaces uses COM VTable style for accesing.

I have the interface OPCServer in .IDL, .C and .dll so i have no problems to
generate stubs with the TypeBrowser Utitlity of JAWIG. But all the subs are
mainly not implemented. For that i have to create the code to generate the
interface between java and COM.

I have problems trying to pass structures by reference to the COM World

For example the "GetStatus" Function.

I have accomplished that the comInvoke() function doesn't throw me a
COMException but i can't get the correct data. I don't know what i amd doing
wrong.

I try to understand all the "instructions" but there is little or no
documentation that explains how works.
I have problems mainy with "structures" of data.


--------------------------------------------------------------------------
Code to get IPOCServer interface

String OPCServerName = "ICONICS.SimulatorOPCDA";
Ole32.CoInitialize(COINIT.MULTITHREADED);
IOPCServer opcServer = new IOPCServer(OPCServerName);
opcServer.GetStatus(null); <-- here i call the function (i dont
pass arguments yet because i am doing test, the arguments are harcoded inside

--------------------------------------------------------------------------
Code for GetStatus call:

int vTable = (3 /*Reserved Slots for IUnknown*/ + /* Slot for
GetStatus*/ 3 ) * 4;
//int resultSize = 16 + 16 + 16 + 4 + 16 + 16 + 8 + 8+ 8+ 8 + 4;
//String instructions ="A:H:n"+resultSize;
int sizeStructure = 16 + 16 + 16 + 4 + 8 + 8 + 4 + 4 + 4 + 4 + 4;
String instructions = "M"+sizeStructure+"G::n"+sizeStructure;
int stackSize = 4;

NakedByteStream nbs = new NakedByteStream();
LittleEndianOutputStream leos = newLittleEndianOutputStream(nbs);
leos.writeZeroBytes(sizeStructure); // there is no in arguments that i want
nbs.size();

byte[] result =comInvoke(vTable,instructions,stackSize,nbs,null);


LittleEndianInputStream leis = new LittleEndianInputStream(new
ByteArrayInputStream(result));
int resultMehtod = leis.readInt();

long fileTime1 = leis.readLong();
long fileTime2 = leis.readLong();

long fileTime3 = leis.readLong();
long fileTime4 = leis.readLong();

long fileTime5 = leis.readLong();
long fileTime6 = leis.readLong();

int serverState = leis.readInt();
long groupCont = leis.readLong();
long bandwitdh = leis.readLong();
int majorVersion = leis.readInt();
int minorVersion = leis.readInt();
int buildNumber = leis.readInt();
int reserved = leis.readInt();

return 0;
------------------------------------------------------



IDL definition for GetStatus procedure and structure involved
// Method from interface
// HRESULT GetStatus(
// [out] OPCSERVERSTATUS** ppServerStatus
// );


// typedef struct tagOPCSERVERSTATUS
// {
// FILETIME ftStartTime;
// FILETIME ftCurrentTime;
// FILETIME ftLastUpdateTime;
// OPCSERVERSTATE dwServerState;
// DWORD dwGroupCount;
// DWORD dwBandWidth;
// WORD wMajorVersion;
// WORD wMinorVersion;
// WORD wBuildNumber;
// WORD wReserved;
// [string] LPWSTR szVendorInfo;
// }
// OPCSERVERSTATUS;


// typedef enum tagOPCSERVERSTATE
// {
// OPC_STATUS_RUNNING = 1,
// OPC_STATUS_FAILED,
// OPC_STATUS_NOCONFIG,
// OPC_STATUS_SUSPENDED,
// OPC_STATUS_TEST,
// OPC_STATUS_COMM_FAULT
// }
// OPCSERVERSTATE;


// typedef struct _FILETIME {
// DWORD dwLowDateTime;
// DWORD dwHighDateTime;
// } FILETIME;
------------------------------------------------------

How is supposed that i have to read the structure OPCSERVERSTATUS?

I have full of structures to pass to COM World and receive from COM Wolrd.

Can you help me with that method? I have succesfully call the method without
throwing a COM exception , but the data returned is not valid.




Thank you very much for your patience and help.

Kind Regards.



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise