Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLC Connection #2

Closed
DamianOczkowski opened this issue May 25, 2019 · 3 comments
Closed

PLC Connection #2

DamianOczkowski opened this issue May 25, 2019 · 3 comments
Labels
question Further information is requested.

Comments

@DamianOczkowski
Copy link

Hello.
I just started using this lib, and I try integrate JHipster and PLC device using this. I would like to ask if it's any possibility to connect with PLC device all the time? I saw in documentation that in connection params we cantype timeout connection param (deafult 5000). It means that every time when I send request from server, I must create new instance of connection and after recive data close the connection?
eg.:

try {
      fatekPLC = new FatekPLC(connectionParam);
      List<RegValue> list = new FatekReadDataCmd(fatekPLC, temperatureReg, 12).send();
      fatekPLC.close();
} catch (Exception e) {
	System.out.println("error during connection");
}
@slawekjaranowski slawekjaranowski added the question Further information is requested. label May 27, 2019
@slawekjaranowski
Copy link
Member

You can create connection once and use it many times, as standard socket connection.

I did't test FatekPLC connection in multithread environment so you should synchronize access to share connecton socket.

Of course your application should be ready to recreate connection if some error occurs.

Example shows usage in simple case.

@DamianOczkowski
Copy link
Author

OK, so how can I check if connection is active ? I don't see any methods in FatekPLC class.

@slawekjaranowski
Copy link
Member

Ok. I checked again.

You needn't check connection status.

Once you create FatekPLC object connection is managed in this object. When some IOException occurs internal connection is closed and new connection is established when you call next send method.
If everything is ok - old connection is reused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested.
Development

No branches or pull requests

2 participants