IO server in java

Hello,

I have an Ewon flexy 205 with an io extention card. For testing i have an io test card.
Screen Shot 2020-07-06 at 15.10.17

I want to read the values from the digital input, but I can’t find how to do this in java.
On the developers page for java is a document calledt eWON Java I/O Server interface. In this document a class IoTestServer has been created, but it doesn’t explain on how to use the class.

I want to read the value that is on the digital input as a bool. I found a way to do this in basic, but all my code is already written in java and I didn’t find a way to use self written basic routines in java.

The basic code that I found is from this post.

DoSwitch:
If (Switch@=1) Then
rem Open Internet connection
Setsys COM,"load"
Setsys COM,"WANCnx","2"
Setsys COM,"WANPermCnx","1"
Setsys COM,"save"
Print Time$;" Connection opened"
else
rem Close Internet connection
Setsys COM,"load"
Setsys COM,"WANCnx","0"
Setsys COM,"save"
Print Time$;" Connection closed"
endif

Can someone explain on how to do this? Or link me to an explanation?

Hello,

So the code you have listed above is our BASIC script for enabling/disabling internet via IO module. This will not work in Java.

The following link would be a better example

I would also review the Tag Creation with IO document:

I am alittle unclear on what you are looking for.

Do you require assistance with creating Java code to read a Tag value generated by the IO extension card?

Yes. Sorry that it wasn’t clear.
I want to read a tag value generated by the IO extention card.

I looked at these links and this is what I wanted. Thank you.

One more question. Is it possible to be detect when a tag changes values without being in a constant loop that watches the tag value?
For example that if the tag goes from 0 to 1 that it will automaticly go to a function.
Like an interrupt.

Hello Debora,

I would look at the ONCHANGE for Basic Scripts. This will do exactly what you want it to do. I have attached the document below.

However, we do not have the Java functionality… Java will require constant polling to detect the change.

2 Likes

Hello Kevin,

Thank you for the reply.
I haven’t worked in basic and the reference guide doesn’t really help. Can you help?
I want to detect when the digital input changes. and I want to set a tag in memory so I can read that in java and execute a function there.

I can’t write that function in Basic because of it’s size and complexity. That’s why I want to notify java. And if i can give java a string with the time it happened, I can just handel it there anytime. But I do need the time it happened. So in the memory tag I want to put a string.

So if I have a DI tag called start. And a MEM tag called stringVar.
And ONCHANGE has the following structure:
ONCHANGE"MyTag","GOTOMyTagChange"

So following that, I would need to do this:

start@ = GETSYSTAG,“start”
ONCHANGE start@, “GOTO tagChangeFunction”

tagChangeFunction:
//fill the MEM tag with a string

Is this the right way? And if it is, how do i set the content of the MEM tag?

This is how I set up the tags:


And:

Hello,

I managed to write the basic code. It looks like this:

GiveToJava:
Print "It works"
a% = GETSYS PRG, "Msec"
stringVar@= STR$ a%
Print stringVar@
END

When testing this, I did not get the results i wanted. I think it has something to do with too many threads that take up a lot of time.
I must work with milliseconds, so when the on change starts too late, I don’t get the right time.

So I went back to java. And wrote a loop that constantly checks the IO. I know this isn’t a nice approach and that it is very intense on the CPU, but for now it works.

I put this loop in a thread with a high priority. The other threads get a sleep function when they are not needed. This way i give more time to my pinWatcher thread.

Thank you for all your help.
Kind regards,
Debora