WIP
parent
70e68bdda8
commit
817abe6146
|
@ -0,0 +1,3 @@
|
|||
Manifest-Version: 1.0
|
||||
Sealed: true
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<jardesc>
|
||||
<jar path="bootstrapper/lib/org.hwo.servicelink.jar"/>
|
||||
<options buildIfNeeded="true" compress="true" descriptionLocation="/org.hwo.servicelink/org.hwo.servicelink.jardesc" exportErrors="false" exportWarnings="true" includeDirectoryEntries="false" overwrite="true" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
|
||||
<storedRefactorings deprecationInfo="true" structuralOnly="false"/>
|
||||
<selectedProjects/>
|
||||
<manifest generateManifest="false" manifestLocation="/org.hwo.servicelink/MANIFEST.MF" manifestVersion="1.0" reuseManifest="true" saveManifest="true" usesManifest="true">
|
||||
<sealing sealJar="true">
|
||||
<packagesToSeal/>
|
||||
<packagesToUnSeal/>
|
||||
</sealing>
|
||||
</manifest>
|
||||
<selectedElements exportClassFiles="true" exportJavaFiles="false" exportOutputFolder="false">
|
||||
<javaElement handleIdentifier="=org.hwo.servicelink/src"/>
|
||||
</selectedElements>
|
||||
</jardesc>
|
|
@ -1,5 +1,6 @@
|
|||
package org.hwo.servicelink.ng;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Hashtable;
|
||||
import static bootstrapper.logging.Logging.*;
|
||||
import static bootstrapper.logging.LogLevel.*;
|
||||
|
@ -37,6 +38,7 @@ public class ServiceLink implements RegBUSInterface {
|
|||
|
||||
public void close() {
|
||||
this.stream.close();
|
||||
this.closed = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -171,7 +173,7 @@ public class ServiceLink implements RegBUSInterface {
|
|||
private void reader() {
|
||||
ServiceLinkRequestBuffer buffer = new ServiceLinkRequestBuffer();
|
||||
|
||||
while (!closed) {
|
||||
while (!this.closed) {
|
||||
if ((this.stream == null) || !this.stream.isConnected()) {
|
||||
try {
|
||||
log(DEBUG,"ServiceLink:reader() sleeps...");
|
||||
|
@ -220,7 +222,14 @@ public class ServiceLink implements RegBUSInterface {
|
|||
|
||||
}
|
||||
|
||||
|
||||
public static ServiceLink fromURI(URI uri) {
|
||||
if (uri == null) {
|
||||
return null;
|
||||
}
|
||||
StreamContainer sls = new StreamContainer(uri);
|
||||
ServiceLink serviceLink = new ServiceLink(new TelegramStreamV2(sls));
|
||||
return serviceLink;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
import java.net.URI;
|
||||
|
||||
import static bootstrapper.logging.Logging.*;
|
||||
|
||||
|
@ -11,6 +12,7 @@ import org.hwo.io.NewSerialPort.NewSerialPort;
|
|||
|
||||
public class StreamContainer {
|
||||
|
||||
URI uri;
|
||||
boolean exceptionCaught = false;
|
||||
|
||||
InputStream inStream;
|
||||
|
@ -19,23 +21,13 @@ public class StreamContainer {
|
|||
Socket socket = null;
|
||||
NewSerialPort newSerialPort = null;
|
||||
|
||||
public StreamContainer(String url) {
|
||||
|
||||
int dots = url.indexOf(':');
|
||||
String proto,target;
|
||||
|
||||
if (dots == -1) {
|
||||
proto = "serial";
|
||||
target = url;
|
||||
} else {
|
||||
proto = url.substring(0, dots);
|
||||
target = url.substring(dots + 1);
|
||||
}
|
||||
|
||||
switch (proto) {
|
||||
public StreamContainer(URI uri) {
|
||||
this.uri = uri;
|
||||
|
||||
switch (this.uri.getScheme()) {
|
||||
case "serial":
|
||||
|
||||
newSerialPort = new NewSerialPort(target);
|
||||
newSerialPort = new NewSerialPort(uri.getPath());
|
||||
newSerialPort.setTimeOut(250);
|
||||
if (newSerialPort.open()) {
|
||||
inStream = newSerialPort.getInputStream();
|
||||
|
@ -46,7 +38,10 @@ public class StreamContainer {
|
|||
case "tcp":
|
||||
|
||||
try {
|
||||
socket = new Socket(target,3009);
|
||||
socket = new Socket(
|
||||
this.uri.getHost(),
|
||||
this.uri.getPort() > 0 ? this.uri.getPort() : 3009
|
||||
);
|
||||
socket.setSoTimeout(150);
|
||||
socket.setTcpNoDelay(true);
|
||||
|
||||
|
@ -63,6 +58,10 @@ public class StreamContainer {
|
|||
|
||||
}
|
||||
|
||||
public URI getURI() {
|
||||
return this.uri;
|
||||
}
|
||||
|
||||
public StreamContainer(InputStream inStream,OutputStream outStream)
|
||||
{
|
||||
this.inStream = inStream;
|
||||
|
|
Loading…
Reference in New Issue