From 37a9f89a20b0940ab869b09f28fadd9a9f6d6936 Mon Sep 17 00:00:00 2001 From: Simon Ebner Date: Wed, 18 Dec 2013 11:36:18 +0100 Subject: [PATCH] FDA-98 Improved (standalone) main method to also support stopping the data acquisition --- ch.psi.fdaq/Readme.md | 12 ++++-- .../src/main/java/ch/psi/fdaq/FdaqMain.java | 38 +++++++++++++------ 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/ch.psi.fdaq/Readme.md b/ch.psi.fdaq/Readme.md index efd6376..5793275 100644 --- a/ch.psi.fdaq/Readme.md +++ b/ch.psi.fdaq/Readme.md @@ -3,15 +3,21 @@ This software is used to readout the FDAQ box developed at X10SA. On The FDAQ box there are 2 socket servers, one for retrieving the data and one for resetting the socket server for data retrieval. -The fdaq code provides exactly 2 to functionalities, it can query on the data socket for data (specifying how many data point) -and can send a reset request on the reset channel. +The fdaq code provides exactly 2 functionalities. It can query on the data socket for data (need to specifying how many data point to read), +and it can send a reset request on the reset channel. # Usage To acquire data into a file use: ``` -fdaq +fdaq acquire +``` + +Send stop/reset request (to abort an data collection) + +``` +fdaq stop ``` This will take the default connections settings: diff --git a/ch.psi.fdaq/src/main/java/ch/psi/fdaq/FdaqMain.java b/ch.psi.fdaq/src/main/java/ch/psi/fdaq/FdaqMain.java index 24368bb..8e71c16 100644 --- a/ch.psi.fdaq/src/main/java/ch/psi/fdaq/FdaqMain.java +++ b/ch.psi.fdaq/src/main/java/ch/psi/fdaq/FdaqMain.java @@ -26,26 +26,42 @@ import ch.psi.fda.serializer.SerializerTXT; import com.google.common.eventbus.AsyncEventBus; import com.google.common.eventbus.EventBus; -/** - * - */ public class FdaqMain { public static void main(String[] args) { - if(args.length != 1){ - System.err.println("Usage: fdaq "); + if(args.length < 1 || args.length >2){ + System.err.println("Usage:\n fdaq acquire \n fdaq stop"); + System.exit(-1); } - File file = new File(args[0]); + boolean acquire = false; + File file = null; + if(args[0].equals("acquire")){ + acquire = true; + file = new File(args[1]); + } + else if(args[0].equals("stop")){ + } + else{ + System.err.println("Usage:\n fdaq acquire \n fdaq stop"); + System.exit(-1); + } + + EventBus bus = new AsyncEventBus(Executors.newSingleThreadExecutor()); FdaqService fdaq = new FdaqService(bus); - - SerializerTXT serializer = new SerializerTXT(file); - bus.register(serializer); - - fdaq.acquire(); + + if(acquire){ + SerializerTXT serializer = new SerializerTXT(file); + bus.register(serializer); + + fdaq.acquire(); + } + else{ + fdaq.stop(); + } } }