Receiving empty values from KepServer (as an alternative to a TOP server)

382 views
Skip to first unread message

Seong

unread,
Feb 18, 2015, 10:51:34 AM2/18/15
to open...@googlegroups.com

Hi there,


I am experimenting an opc example with Kepware from the help of the utgard website: "https://openscada.atlassian.net/wiki/display/OP/HowToStartWithUtgard"

The following code is part of my example:


// connect to server

server.connect();

// add sync access, poll every 500 ms

final AccessBase access = new SyncAccess(server, 500);

access.addItem(itemId, new DataCallback() {

@Override

public void changed(Item item, ItemState state) {

System.out.println(state);

}

});

// start reading

access.bind();

// wait a little bit

Thread.sleep(10 * 1000);

// stop reading

access.unbind();


The program connects and runs successfully

There are times where I actually receive values of boolean tags that are either true or false (1 or 0) but this is rare.

However I mainly receive the following line:

Value: [[org.jinterop.dcom.core.VariantBody$EMPTY@d60b970]], Timestamp: Wed Feb 18 22:58:23 GMT 2015, Quality: 0, ErrorCode: 00000000


is there an explanation why I receive this?


Nevertheless, my main question is the following.


The example is focused on getting values of a same tag over a certain period of time.

Is there any way to get data without specifying a time period?


Thanks in advance.


Kind regards


Seong 

Jens Reimann

unread,
Feb 25, 2015, 6:03:14 AM2/25/15
to open...@googlegroups.com
Hi,

well "EMPTY" is a valid return value for OPC. So the question is why your server provides this value?! But I cannot answer this for you, sorry.

What do you mean by "time period"?

Best regards

Jens

--
You received this message because you are subscribed to the Google Groups "openSCADA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openscada+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Seong

unread,
Mar 3, 2015, 5:32:49 AM3/3/15
to open...@googlegroups.com
Hi Jens,

I am so sorry. I apologise. I saw your message yesterday night.

Thank you. The server sometimes returns an empty value. I don't know why. I think it's Kep server(program) problem.

What I meant by 'time period' was,

final AccessBase access = new SyncAccess(server, 500);
&
Thread.sleep(10 * 1000);

both 500ms and 10000ms. I interpret it as it tries to get a value over 10000ms every 500ms.
What a program I wrote does, it prolongs a server connection until it gets a value from the server.

I am looking for a method that retrieves a value without asking a user to specify a time period.
Is there such method? The program I wrote using your code does the job. However I think your method is certainly going to be much more robust and fast.

Thank you for your valuable comment.

Kind regards

Seong

Jens Reimann

unread,
Mar 3, 2015, 12:03:46 PM3/3/15
to open...@googlegroups.com

Hi,

Well if you need only a one time read you can use the low level api. Just look into the source of SyncAccess.

Jens

Seong

unread,
Mar 4, 2015, 7:40:50 AM3/4/15
to open...@googlegroups.com
Hi Jens,

Thank you for your valuable and previous comment. I really appreciate your kindness.

I have looked at the source code. I have decided to stick to the previous way (your high-level method).

I think runOnce() method may not get the right value at once because Kep server seems not fully compatible to Open Scada and it doesn't return the right value at once. I have to iterate until it does so.

Getting a value for each item(tag) takes around 20ms - 100ms. There seems many items that needs to be queried. I think there are more than 1,000,000 items. Can you suggest me a quicker way or appropriate values for SyncAccess and thread.sleep please?

or do you have a method that checks values for a group of items and returns changed values?
like
Group group = server.addGroup ( "test" );
group.addItem ( "Saw-toothed Waves.Int2" );
group.addItems( "Saw-toothed Waves.Int2", "Saw-toothed Waves.Int4" );
Nevertheless, I don't know how to get item values from group object. Because
access.addItem(itemId, new DataCallback() {
@Override
public void changed(Item item, ItemState state) {
        // System.out.println(state);  // System.out.println(item);
is for one item.

or I just have to ask you for a quicker way to get values for many items.

Thank you.

Kind regards

Seong

Psyco Tik

unread,
Mar 5, 2015, 3:28:38 AM3/5/15
to open...@googlegroups.com
state.getValue() inside the changed method returns a JIVariant type. From there you can use;

switch (input.getObject().getClass().getSimpleName()) {
case "JIUnsignedShort":
output = input.getObjectAsUnsigned().getValue().shortValue();
break;
case "JIUnsignedInteger":
output = input.getObjectAsUnsigned().getValue().intValue();
break;
case "Integer":
output = input.getObjectAsInt();
break;
case "Short":
output = input.getObjectAsShort();
break;
case "Boolean":
output = input.getObjectAsBoolean();
break;
case "Float":
output = input.getObjectAsFloat();
break;
default:
output = input.getObject().getClass().getSimpleName();
break;

where input is state.getValue().

Is this what you are looking for?

Seong

unread,
Mar 12, 2015, 11:59:54 AM3/12/15
to open...@googlegroups.com
Hi,
 
I much appreciate your instructions however they seemed focused on how to get a value one by one from a set which is already queried from PLC.
 
Nevertheless , I would like to know how to put items in a group and to then retrieve values of those items in the group through a single query.
 
I looked at examples (Tests.java files) but just could not figure it out.
 
Thanks in advance
 
Kind regards
 
Seong
Reply all
Reply to author
Forward
0 new messages