refactored classes
This commit is contained in:
@@ -79,22 +79,22 @@ public class RemoteAcquisitionMain {
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
||||
String scriptname = "fda_scan";
|
||||
String scriptname = "scan";
|
||||
|
||||
Integer iterations = null;
|
||||
String server = null;
|
||||
boolean nogui = false;
|
||||
List<File> files = new ArrayList<>();
|
||||
|
||||
OptionBuilder.hasArg();
|
||||
OptionBuilder.withArgName("iterations");
|
||||
OptionBuilder.withDescription("Number of iterations");
|
||||
OptionBuilder.withType(new Integer(1));
|
||||
Option o_iterations = OptionBuilder.create("iterations");
|
||||
OptionBuilder.withArgName("hostname");
|
||||
OptionBuilder.withDescription("Hostname server");
|
||||
OptionBuilder.withType(new String());
|
||||
Option o_server = OptionBuilder.create("server");
|
||||
|
||||
Option o_nogui = new Option("nogui", "Do not show scan GUI");
|
||||
|
||||
Options options = new Options();
|
||||
options.addOption(o_iterations);
|
||||
options.addOption(o_server);
|
||||
options.addOption(o_nogui);
|
||||
|
||||
CommandLineParser parser = new GnuParser();
|
||||
@@ -105,8 +105,8 @@ public class RemoteAcquisitionMain {
|
||||
throw new ParseException("One argument is required");
|
||||
}
|
||||
|
||||
if (line.hasOption(o_iterations.getOpt())) {
|
||||
iterations = Integer.parseInt(line.getOptionValue(o_iterations.getOpt()));
|
||||
if (line.hasOption(o_server.getOpt())) {
|
||||
server = line.getOptionValue(o_server.getOpt());
|
||||
}
|
||||
|
||||
if (line.hasOption(o_nogui.getOpt())) {
|
||||
@@ -131,7 +131,7 @@ public class RemoteAcquisitionMain {
|
||||
try {
|
||||
for (File file : files) {
|
||||
RemoteAcquisitionMain m = new RemoteAcquisitionMain();
|
||||
m.execute(file, iterations, nogui);
|
||||
m.execute(server, file, nogui);
|
||||
}
|
||||
} catch (Exception ee) {
|
||||
logger.log(Level.SEVERE, "Acquisition failed due to: ", ee);
|
||||
@@ -146,7 +146,7 @@ public class RemoteAcquisitionMain {
|
||||
* @param iterations
|
||||
* @param nogui
|
||||
*/
|
||||
public void execute(File file, Integer iterations, boolean nogui) {
|
||||
public void execute(final String server, File file, boolean nogui) {
|
||||
|
||||
trackingId = UUID.randomUUID().toString();
|
||||
logger.info("TrackingID of job: " + trackingId);
|
||||
@@ -169,7 +169,7 @@ public class RemoteAcquisitionMain {
|
||||
|
||||
|
||||
EventBus b = new AsyncEventBus(Executors.newSingleThreadExecutor());
|
||||
final ControlClient client = new ControlClient();
|
||||
final RestClient client = new RestClient(server, 8080); // TODO hardcoded server port
|
||||
|
||||
|
||||
|
||||
@@ -278,7 +278,7 @@ public class RemoteAcquisitionMain {
|
||||
Executors.newSingleThreadExecutor().execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
streamClient.listen("tcp://emac:10000");
|
||||
streamClient.listen("tcp://"+server+":10000");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+8
-3
@@ -28,10 +28,15 @@ import org.glassfish.jersey.jackson.JacksonFeature;
|
||||
|
||||
import ch.psi.fda.edescriptor.EDescriptor;
|
||||
|
||||
public class ControlClient {
|
||||
public class RestClient {
|
||||
|
||||
private Client client = ClientBuilder.newClient().register(JacksonFeature.class);
|
||||
private WebTarget target = client.target("http://emac:8080").path("fda");
|
||||
private final Client client;
|
||||
private final WebTarget target;
|
||||
|
||||
public RestClient(String servername, int port){
|
||||
client = ClientBuilder.newClient().register(JacksonFeature.class);
|
||||
target = client.target("http://"+servername+":"+port).path("fda");
|
||||
}
|
||||
|
||||
public String acquire(String trackingId, EDescriptor edescriptor){
|
||||
return target.path(trackingId).request().put(Entity.entity(edescriptor, MediaType.APPLICATION_XML), String.class);
|
||||
Reference in New Issue
Block a user