mirror of
https://github.com/RfidResearchGroup/RFIDtools.git
synced 2026-05-12 11:19:59 -07:00
Communication rebuild(worked).
This commit is contained in:
@@ -17,24 +17,27 @@ public abstract class DeviceChecker implements Serializable, Closeable {
|
||||
this.communication = communication;
|
||||
}
|
||||
|
||||
private void initCom() {
|
||||
// Auto init communication to mapper.
|
||||
LocalComBridgeAdapter.getInstance()
|
||||
.setInputStream(communication.getInput())
|
||||
.setOutputStream(communication.getOutput())
|
||||
.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a device is can work!
|
||||
*
|
||||
* @return if can work return true, if no, return false
|
||||
*/
|
||||
public boolean check() throws IOException {
|
||||
initCom();
|
||||
return false;
|
||||
public final boolean check() throws IOException {
|
||||
// Auto init communication to mapper.
|
||||
LocalComBridgeAdapter.getInstance()
|
||||
.setInputStream(communication.getInput())
|
||||
.setOutputStream(communication.getOutput())
|
||||
.startServer();
|
||||
if (!checkDevice()) {
|
||||
// if check failed, we must to close device!
|
||||
LocalComBridgeAdapter.getInstance().stopClient();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected abstract boolean checkDevice() throws IOException;
|
||||
|
||||
/**
|
||||
* Close the device(Should no close communication. only close device!)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user