Newbie on OPC

1,175 views
Skip to first unread message

hades79

unread,
Aug 26, 2011, 5:16:34 AM8/26/11
to openSCADA
Hi!
I'm starting in the PLC and OPC world, 'cause I need to develop an
opc client in Java for my company. I've downloaded utgard jars, but
I'm a bit lost now. Do you have some manual, sample codes, or
something useful to start?

Thanks,
David

Jens Reimann

unread,
Aug 26, 2011, 10:05:37 AM8/26/11
to open...@googlegroups.com
Hi,

there is a "*sample*" project which might help you a little bit.

best regards

Jens Reimann

Victor Rocha Pusch

unread,
Aug 26, 2011, 5:12:45 PM8/26/11
to open...@googlegroups.com
Hello all,

Maybe this can help beginners too,
we have used Utgard to develop an OPC-DA client for our SCADA package.

This project (which we call "opc master") compiles to a jar file, which
allows adding/listing/querying OPC tags:
http://scadabr.svn.sourceforge.net/viewvc/scadabr/OPCClient/src/br/org/scadabr/

and in this specific file below, we use the above "master" as one of its
dependencies.
http://scadabr.svn.sourceforge.net/viewvc/scadabr/ScadaBR/src/br/org/scadabr/rt/dataSource/opc/OPCDataSource.java?revision=1156&view=markup

Hope that helps, Utgard is wonderful! :-)

best regards

David Gonzalez

unread,
Aug 29, 2011, 4:51:00 AM8/29/11
to open...@googlegroups.com
Thanks to everyone. I'll take a look to the code.

2011/8/26 Victor Rocha Pusch <rocha...@gmail.com>

Edsoncv

unread,
Sep 26, 2011, 1:18:41 PM9/26/11
to openSCADA
Hello all
I'm trying to connect to an OPC server at the local machine (the
server and the client are in the same computer). I hava Iconics
simulator opc and Matrikon simulator opc. If I use another windows
based client, I can list the opc servers, even read and write tags
(which I have write permissions). I would like to use Utgard to list
the Opc servers, read and write tags and so on, but I could'nt get the
connection. Bellow is a part of my code and the log output:
code (/org.openscada.opc.dcom.test/src/org/openscada/opc/dcom/da/
Test2.java)


public static void main ( final String[] args ) throws
IllegalArgumentException, UnknownHostException, JIException
{
final TestConfiguration configuration = new
MatrikonSimulationServerConfiguration ();

OPCServer server = null;
try
{
IconicsSimulationServerConfiguration m1 = new
IconicsSimulationServerConfiguration();
JISystem.setAutoRegisteration ( true );

_session = JISession.createSession ( "", "edsoncv",
"taschen$VR" );

//JIComServer comServer = new JIComServer
( JIClsid.valueOf ( configuration.getCLSID () ), args[0], _session );
final JIComServer comServer = new JIComServer
( JIProgId.valueOf ( m1.getProgId () ), "127.0.0.1", _session );

final IJIComObject serverObject = comServer.createInstance
();
server = new OPCServer ( serverObject );

final OPCGroupStateMgt group = server.addGroup ( "test",
true, 100, 1234, 60, 0.0f, 1033 );

testItems ( server, group, configuration.getReadItems
() );
server.removeGroup ( group, true );
}
catch ( final JIException e )
{
e.printStackTrace ();
showError ( server, e.getErrorCode () );
}
finally
{
if ( _session != null )
{
JISession.destroySession ( _session );
}
_session = null;
}
}
}

the error code:

26/09/2011 14:13:16 org.jinterop.dcom.core.JIComOxidRuntime
$ClientPingTimerTask run
INFO: Running ClientPingTimerTask !
26/09/2011 14:13:16 org.jinterop.dcom.core.JIComOxidRuntime
$ServerPingTimerTask run
INFO: Running ServerPingTimerTask !
26/09/2011 14:13:16 org.jinterop.dcom.core.JISession createSession
INFO: Created Session: 279282342
26/09/2011 14:13:16 org.jinterop.dcom.core.JISession
$Release_References_TimerTask run
INFO: Release_References_TimerTask:[RUN] Session: 279282342 ,
listOfDeferencedIpids.size(): 0
26/09/2011 14:13:16 org.jinterop.dcom.common.JISystem
saveDBPathAndLoadFile
INFO: progIdVsClsidDB file located at: file:/C:/Users/edsoncv/
workspace/org.openscada.opc.dcom/bin/progIdVsClsidDB.properties
26/09/2011 14:13:16 org.jinterop.dcom.common.JISystem
saveDBPathAndLoadFile
INFO: progIdVsClsidDB: {Word.Application=000209ff-0000-0000-
c000-000000000046,
TestCOM123.TestServer2=92a065a9-106a-4cc3-8d67-43e3a1e73df3,
SYSINFO.SysInfo=6fba474b-43ac-11ce-9a0e-00aa0062bb4c,
ADODB.Connection=00000514-0000-0010-8000-00aa006d2ea4,
TestJavaServer.TestServer2=617d5a31-a3bf-440f-a58f-1f57f6ac7527,
TestJavaServer.TestServer1=56bad610-0fcb-418a-b25e-174159a4adce,
InternetExplorer.Application=0002df01-0000-0000-c000-000000000046,
Excel.Application=00024500-0000-0000-c000-000000000046,
StdCollection.VBCollection=4b738074-ea47-11d2-b25a-00105a022091,
PowerPoint.Application=91493441-5a91-11cf-8700-00aa0060263b,
WbemScripting.SWbemLocator=76a64158-cb41-11d1-8b02-00600806d9b6}
org.jinterop.dcom.common.JIException: Message not found for errorCode:
0xC0000034
at
org.jinterop.winreg.smb.JIWinRegStub.winreg_OpenHKLM(JIWinRegStub.java:
115)
at org.jinterop.dcom.core.JIProgId.getIdFromWinReg(JIProgId.java:130)
at
org.jinterop.dcom.core.JIProgId.getCorrespondingCLSID(JIProgId.java:
162)
at org.jinterop.dcom.core.JIComServer.<init>(JIComServer.java:413)
at org.openscada.opc.dcom.da.Test2.main(Test2.java:191)
Caused by: jcifs.smb.SmbException: The system cannot find the file
specified.
at jcifs.smb.SmbTransport.checkStatus(SmbTransport.java:522)
at jcifs.smb.SmbTransport.send(SmbTransport.java:622)
at jcifs.smb.SmbSession.send(SmbSession.java:239)
at jcifs.smb.SmbTree.send(SmbTree.java:109)
at jcifs.smb.SmbFile.send(SmbFile.java:718)
at jcifs.smb.SmbFile.open0(SmbFile.java:923)
at jcifs.smb.SmbFile.open(SmbFile.java:940)
at jcifs.smb.SmbFileOutputStream.<init>(SmbFileOutputStream.java:142)
at
jcifs.smb.TransactNamedPipeOutputStream.<init>(TransactNamedPipeOutputStream.java:
32)
at jcifs.smb.SmbNamedPipe.getNamedPipeOutputStream(SmbNamedPipe.java:
187)
at rpc.ncacn_np.RpcTransport.attach(RpcTransport.java:92)
at rpc.Stub.attach(Stub.java:106)
at rpc.Stub.call(Stub.java:110)
at
org.jinterop.winreg.smb.JIWinRegStub.winreg_OpenHKLM(JIWinRegStub.java:
113)
... 4 more
26/09/2011 14:13:23 org.jinterop.dcom.core.JISession postDestroy
INFO: About to destroy links for Session: 279282342 , size of which is
0
26/09/2011 14:13:23 org.jinterop.dcom.core.JIComOxidRuntime
destroySessionOIDs
INFO: destroySessionOIDs for session: 279282342
Exception in thread "main" java.lang.NullPointerException
at org.openscada.opc.dcom.da.Test2.showError(Test2.java:56)
at org.openscada.opc.dcom.da.Test2.main(Test2.java:204)

Jens Reimann

unread,
Sep 26, 2011, 4:10:04 PM9/26/11
to open...@googlegroups.com

Just to be sure, can you try using the class I'd instead of the prog id. There was an issue with that in the past. Though it is fixed in rhr git repositories it is not in the latest release build.

Edsoncv

unread,
Sep 27, 2011, 7:05:03 AM9/27/11
to openSCADA
Hello Jens
With classID it works, but I get access denied error, I've configured
Dcom access to OPC's, any clue how to solve it. Bellow is the error
message:

27/09/2011 08:00:18 org.jinterop.dcom.core.JIComOxidRuntime
$ServerPingTimerTask run
INFO: Running ServerPingTimerTask !
27/09/2011 08:00:18 org.jinterop.dcom.core.JISession
$Release_References_TimerTask run
INFO: Release_References_TimerTask:[RUN] Session: 1589659305 ,
listOfDeferencedIpids.size(): 0
27/09/2011 08:00:18 org.jinterop.dcom.core.JIComOxidRuntime
$ClientPingTimerTask run
INFO: Running ClientPingTimerTask !
27/09/2011 08:00:18 org.jinterop.dcom.core.JISession createSession
INFO: Created Session: 1589659305
27/09/2011 08:00:18 org.jinterop.dcom.common.JISystem internal_dumpMap
INFO: mapOfHostnamesVsIPs: {}
27/09/2011 08:00:18 rpc.DefaultConnection processOutgoing
INFO:
Sending BIND
27/09/2011 08:00:18 rpc.DefaultConnection processIncoming
INFO:
Recieved BIND_ACK
27/09/2011 08:00:18 rpc.DefaultConnection processOutgoing
INFO:
Sending AUTH3
27/09/2011 08:00:19 rpc.DefaultConnection processOutgoing
INFO:
Sending ALTER_CTX
27/09/2011 08:00:19 rpc.DefaultConnection processIncoming
INFO:
Recieved ALTER_CTX_RESP
27/09/2011 08:00:19 rpc.DefaultConnection processOutgoing
INFO:
Sending REQUEST
27/09/2011 08:00:19 rpc.DefaultConnection processIncoming
INFO:
Recieved FAULT
org.jinterop.dcom.common.JIException: Access is denied, please check
whether the [domain-username-password] are correct. Also, if not
already done please check the GETTING STARTED and FAQ sections in
readme.htm. They provide information on how to correctly configure the
Windows machine for DCOM access, so as to avoid such exceptions.
[0x00000005]
at org.jinterop.dcom.core.JIComServer.init(JIComServer.java:572)
at org.jinterop.dcom.core.JIComServer.initialise(JIComServer.java:
481)
at org.jinterop.dcom.core.JIComServer.<init>(JIComServer.java:445)
at org.openscada.opc.dcom.da.Test2.main(Test2.java:192)
Caused by: rpc.FaultException: Received fault. (unknown)
at
rpc.ConnectionOrientedEndpoint.call(ConnectionOrientedEndpoint.java:
141)
at rpc.Stub.call(Stub.java:113)
at org.jinterop.dcom.core.JIComServer.init(JIComServer.java:568)
... 3 more
27/09/2011 08:00:19 org.jinterop.dcom.core.JISession postDestroy
INFO: About to destroy links for Session: 1589659305 , size of which
is 0
27/09/2011 08:00:19 org.jinterop.dcom.core.JIComOxidRuntime
destroySessionOIDs
INFO: destroySessionOIDs for session: 1589659305
Exception in thread "main" java.lang.NullPointerException
at org.openscada.opc.dcom.da.Test2.showError(Test2.java:57)
at org.openscada.opc.dcom.da.Test2.main(Test2.java:205)

On 26 set, 17:10, Jens Reimann <ctron1...@gmail.com> wrote:
> Just to be sure, can you try using the class I'd instead of the prog id.
> There was an issue with that in the past. Though it is fixed in rhr git
> repositories it is not in the latest release build.

Jens Reimann

unread,
Sep 28, 2011, 2:08:10 PM9/28/11
to open...@googlegroups.com

Well the first thing to try in this case is to use another computer and connect to that machine use a standard OPC client. This ensures that it is no utgard issue.

And the switches that can be wrong on this case are numerous and too much to write here.

The best thing is to allow everything and see if it works. And then start restricting again until it breaks.

Nathan Heine

unread,
Oct 17, 2011, 12:04:00 PM10/17/11
to open...@googlegroups.com
Greetings,

I've been work with this code a bit, and I'm having a problem that I hope you can help with.

I'm connecting to a Kepware EX V5 server that has several channels setup in it, each with 1 or more devices configured.  The opUtils.getItems method is returning 1009 tag names, and that list looks correct.  However, when calling the opcUtils.addItems() method, it is only returning Items for devices under one of the channels, specifically the last one listed in the OPC server.

Any thoughts as to what would cause this?

- Nathan Heine
Reply all
Reply to author
Forward
0 new messages