mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-21 22:52:22 +00:00
Support batch processing
Multicast controller and a couple of additional commands to work with the batch processing plugin.
This commit is contained in:
parent
2bb8c0b164
commit
a2da810690
@ -873,4 +873,19 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet
|
|||||||
return getDaqProcess().setAnalysisStartTime(startTime);
|
return getDaqProcess().setAnalysisStartTime(startTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Very specific command handler for batch status which will only work
|
||||||
|
* with the folderinputSystem.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getBatchStatus() {
|
||||||
|
DaqSystem runningSystem = getAcquisitionProcess().getRunningSystem();
|
||||||
|
if (runningSystem instanceof FolderInputSystem) {
|
||||||
|
return ((FolderInputSystem) runningSystem).getBatchStatus();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -893,5 +893,19 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a status update for batch processing.
|
||||||
|
*/
|
||||||
|
public String getBatchStatus() {
|
||||||
|
int nFiles = 0;
|
||||||
|
if (allFiles != null) {
|
||||||
|
nFiles = allFiles.size();
|
||||||
|
}
|
||||||
|
int generalStatus = PamController.getInstance().getPamStatus();
|
||||||
|
File currFile = getCurrentFile();
|
||||||
|
String bs = String.format("%d,%d,%d,%s", nFiles,currentFile,generalStatus,currFile);
|
||||||
|
return bs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ import generalDatabase.DBControlUnit;
|
|||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import Array.ArrayManager;
|
import Array.ArrayManager;
|
||||||
import PamController.command.MultiportController;
|
import PamController.command.MulticastController;
|
||||||
import PamController.command.NetworkController;
|
import PamController.command.NetworkController;
|
||||||
import PamController.command.TerminalController;
|
import PamController.command.TerminalController;
|
||||||
import PamController.command.WatchdogComms;
|
import PamController.command.WatchdogComms;
|
||||||
@ -258,8 +258,8 @@ public class PamController implements PamControllerInterface, PamSettings {
|
|||||||
if (pamBuoyGlobals.getNetworkControlPort() != null) {
|
if (pamBuoyGlobals.getNetworkControlPort() != null) {
|
||||||
networkController = new NetworkController(this);
|
networkController = new NetworkController(this);
|
||||||
}
|
}
|
||||||
if (pamBuoyGlobals.getMultiportAddress() != null) {
|
if (pamBuoyGlobals.getMulticastAddress() != null) {
|
||||||
new MultiportController(this);
|
new MulticastController(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
guiFrameManager = PamGUIManager.createGUI(this, object);
|
guiFrameManager = PamGUIManager.createGUI(this, object);
|
||||||
|
64
src/PamController/command/BatchCommand.java
Normal file
64
src/PamController/command/BatchCommand.java
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
package PamController.command;
|
||||||
|
|
||||||
|
import networkTransfer.send.NetworkSender;
|
||||||
|
import pamguard.GlobalArguments;
|
||||||
|
|
||||||
|
public class BatchCommand extends ExtCommand {
|
||||||
|
|
||||||
|
public static final String commandId = "batchcommand";
|
||||||
|
private CommandManager commandManager;
|
||||||
|
|
||||||
|
public BatchCommand(CommandManager commandManager) {
|
||||||
|
super(commandId, true);
|
||||||
|
this.commandManager = commandManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String execute(String command) {
|
||||||
|
/**
|
||||||
|
* this should have to identifiers. If they match the identifiers of
|
||||||
|
* this pamguard instance, then the command part is passed back to the manager
|
||||||
|
* otherwise it is ignored.
|
||||||
|
*/
|
||||||
|
if (command == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String[] bits = command.split(" ");
|
||||||
|
if (bits.length < 4) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
int id1 = 0;
|
||||||
|
int id2 = 0;
|
||||||
|
int expId1 = 0, expId2 = 0;
|
||||||
|
try {
|
||||||
|
id1 = Integer.valueOf(bits[1]);
|
||||||
|
id2 = Integer.valueOf(bits[2]);
|
||||||
|
}
|
||||||
|
catch (NumberFormatException e) {
|
||||||
|
System.out.println("Invalid BatchCommand: " + command);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String nid1 = GlobalArguments.getParam(NetworkSender.ID1);
|
||||||
|
String nid2 = GlobalArguments.getParam(NetworkSender.ID2);
|
||||||
|
if (bits[1].trim().equals(nid1) == false) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// now trim the string to the end of the third comma and send on the rest
|
||||||
|
int comPos = -1;
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
comPos = command.indexOf(" ", comPos+1);
|
||||||
|
if (comPos < 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String trueCommand = command.substring(comPos);
|
||||||
|
trueCommand = trueCommand.trim();
|
||||||
|
// System.out.printf(">>>>>>>>>>>>>>>>>>> Batchcommand execute \"%s\" in command manager %s\n", trueCommand, commandManager.getClass().getName());
|
||||||
|
if (commandManager.interpretCommand(trueCommand)) {
|
||||||
|
// return commandManager.get
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
31
src/PamController/command/BatchStatusCommand.java
Normal file
31
src/PamController/command/BatchStatusCommand.java
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package PamController.command;
|
||||||
|
|
||||||
|
import Acquisition.AcquisitionControl;
|
||||||
|
import PamController.PamController;
|
||||||
|
import pamViewFX.PamControlledGUIFX;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Command to get PAMGuard to send back the batch processing status.
|
||||||
|
*
|
||||||
|
* @author dg50
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class BatchStatusCommand extends ExtCommand {
|
||||||
|
|
||||||
|
public static final String commandId = "batchstatus";
|
||||||
|
|
||||||
|
public BatchStatusCommand() {
|
||||||
|
super(commandId, true);
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String execute(String command) {
|
||||||
|
AcquisitionControl daqControl = (AcquisitionControl) PamController.getInstance().findControlledUnit(AcquisitionControl.class, null);
|
||||||
|
if (daqControl == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return daqControl.getBatchStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -40,6 +40,8 @@ public abstract class CommandManager extends PamControlledUnit {
|
|||||||
commandsList.add(new HelpCommand(this));
|
commandsList.add(new HelpCommand(this));
|
||||||
commandsList.add(new GetXMLSettings());
|
commandsList.add(new GetXMLSettings());
|
||||||
commandsList.add(new SetXMLSettings());
|
commandsList.add(new SetXMLSettings());
|
||||||
|
commandsList.add(new BatchStatusCommand());
|
||||||
|
commandsList.add(new BatchCommand(this));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,16 +83,16 @@ public abstract class CommandManager extends PamControlledUnit {
|
|||||||
}
|
}
|
||||||
ExtCommand extCommand = findCommand(command);
|
ExtCommand extCommand = findCommand(command);
|
||||||
if (extCommand == null) {
|
if (extCommand == null) {
|
||||||
sendData("Cmd \"" + commandString + "\" Not Recognised.");
|
sendData(extCommand, "Cmd \"" + commandString + "\" Not Recognised.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (extCommand.canExecute() == false) {
|
if (extCommand.canExecute() == false) {
|
||||||
sendData("Cmd \"" + command + "\" Cannot Execute.");
|
sendData(extCommand, "Cmd \"" + command + "\" Cannot Execute.");
|
||||||
// sendData(" Cmd return string = " + extCommand.getReturnString());
|
// sendData(" Cmd return string = " + extCommand.getReturnString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String output = extCommand.executeCommand(commandString);
|
String output = extCommand.executeCommand(commandString);
|
||||||
sendData(output);
|
sendData(extCommand,output);
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -154,9 +156,10 @@ public abstract class CommandManager extends PamControlledUnit {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Reply to data called from InterpredData
|
* Reply to data called from InterpredData
|
||||||
|
* @param extCommand
|
||||||
* @param dataString
|
* @param dataString
|
||||||
* @return true if replay successful
|
* @return true if replay successful
|
||||||
*/
|
*/
|
||||||
abstract public boolean sendData(String dataString);
|
abstract public boolean sendData(ExtCommand extCommand, String dataString);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,10 @@ import PamController.PamSettingManager;
|
|||||||
*/
|
*/
|
||||||
public class ExitCommand extends ExtCommand {
|
public class ExitCommand extends ExtCommand {
|
||||||
|
|
||||||
|
public static final String commandId = "Exit";
|
||||||
|
|
||||||
public ExitCommand() {
|
public ExitCommand() {
|
||||||
super("Exit", false);
|
super(commandId, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -25,7 +25,7 @@ public class HelpCommand extends ExtCommand {
|
|||||||
out += "\n";
|
out += "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
commandManager.sendData(out);
|
commandManager.sendData(this, out);
|
||||||
return getName();
|
return getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,12 +12,14 @@ import java.nio.charset.StandardCharsets;
|
|||||||
|
|
||||||
import PamController.PamController;
|
import PamController.PamController;
|
||||||
import PamController.pamBuoyGlobals;
|
import PamController.pamBuoyGlobals;
|
||||||
|
import networkTransfer.send.NetworkSender;
|
||||||
|
import pamguard.GlobalArguments;
|
||||||
|
|
||||||
public class MultiportController extends CommandManager {
|
public class MulticastController extends CommandManager {
|
||||||
|
|
||||||
//The multicast addresses are in the range 224.0.0.0 through 239.255.255.255
|
//The multicast addresses are in the range 224.0.0.0 through 239.255.255.255
|
||||||
|
|
||||||
private static String unitName = "Multiport Controller";
|
private static String unitName = "Multicast Controller";
|
||||||
private PamController pamController;
|
private PamController pamController;
|
||||||
private String mAddress;
|
private String mAddress;
|
||||||
private int mPort;
|
private int mPort;
|
||||||
@ -29,11 +31,11 @@ public class MultiportController extends CommandManager {
|
|||||||
private byte[] byteBuffer = new byte[MAX_COMMAND_LENGTH];
|
private byte[] byteBuffer = new byte[MAX_COMMAND_LENGTH];
|
||||||
private DatagramPacket lastDatagram;
|
private DatagramPacket lastDatagram;
|
||||||
|
|
||||||
public MultiportController(PamController pamController) {
|
public MulticastController(PamController pamController) {
|
||||||
super(pamController, unitName);
|
super(pamController, unitName);
|
||||||
this.pamController = pamController;
|
this.pamController = pamController;
|
||||||
this.mAddress = pamBuoyGlobals.getMultiportAddress();
|
this.mAddress = pamBuoyGlobals.getMulticastAddress();
|
||||||
this.mPort = pamBuoyGlobals.getMuliportPort();
|
this.mPort = pamBuoyGlobals.getMulticastPort();
|
||||||
|
|
||||||
Thread t = new Thread(new ListenerThread());
|
Thread t = new Thread(new ListenerThread());
|
||||||
t.start();
|
t.start();
|
||||||
@ -83,17 +85,35 @@ public class MultiportController extends CommandManager {
|
|||||||
private void processDatagram(DatagramPacket datagram) {
|
private void processDatagram(DatagramPacket datagram) {
|
||||||
lastDatagram = datagram;
|
lastDatagram = datagram;
|
||||||
String str = new String(datagram.getData(), 0, datagram.getLength());
|
String str = new String(datagram.getData(), 0, datagram.getLength());
|
||||||
// str = str.substring(0, datagram.getLength());
|
str = str.substring(0, datagram.getLength());
|
||||||
System.out.println("Datagram received \"" + str + "\"");
|
// System.out.println("Datagram received \"" + str + "\"");
|
||||||
interpretCommand(str);
|
interpretCommand(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean sendData(String dataString) {
|
public boolean sendData(ExtCommand extCommand, String dataString) {
|
||||||
|
if (dataString == null || dataString.length() == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
DatagramPacket senderInfo = lastDatagram;
|
DatagramPacket senderInfo = lastDatagram;
|
||||||
System.out.printf("Send back data \"%s\" to %s port %d\n", dataString, senderInfo.getAddress(), senderInfo.getPort());
|
String commandName;
|
||||||
|
if (extCommand == null) {
|
||||||
|
commandName = "Unknown";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
commandName = extCommand.getName();
|
||||||
|
}
|
||||||
|
// System.out.printf("Send back data \"%s\" to %s port %d\n", dataString, senderInfo.getAddress(), senderInfo.getPort());
|
||||||
|
/*
|
||||||
|
* for multicast, we need to send a slightly different string back which has the station id as part of
|
||||||
|
* the returned string. These will be 0 if they weren't passed in at the command line.
|
||||||
|
*/
|
||||||
|
String id1 = GlobalArguments.getParam(NetworkSender.ID1);
|
||||||
|
String id2 = GlobalArguments.getParam(NetworkSender.ID2);
|
||||||
|
String bigString = String.format("%s,%s,%s,%s", commandName, id1, id2, dataString);
|
||||||
|
|
||||||
// dataString += "\n";
|
// dataString += "\n";
|
||||||
DatagramPacket packet = new DatagramPacket(dataString.getBytes(), dataString.length());
|
DatagramPacket packet = new DatagramPacket(bigString.getBytes(), bigString.length());
|
||||||
packet.setAddress(senderInfo.getAddress());
|
packet.setAddress(senderInfo.getAddress());
|
||||||
packet.setPort(senderInfo.getPort());
|
packet.setPort(senderInfo.getPort());
|
||||||
try {
|
try {
|
@ -124,16 +124,14 @@ public class NetworkController extends CommandManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean sendData(String dataString) {
|
public boolean sendData(ExtCommand extCommand, String dataString) {
|
||||||
DatagramPacket packet = new DatagramPacket(dataString.getBytes(), dataString.length());
|
DatagramPacket packet = new DatagramPacket(dataString.getBytes(), dataString.length());
|
||||||
packet.setAddress(udpPacket.getAddress());
|
packet.setAddress(udpPacket.getAddress());
|
||||||
packet.setPort(udpPacket.getPort());
|
packet.setPort(udpPacket.getPort());
|
||||||
try {
|
try {
|
||||||
receiveSocket.send(packet);
|
receiveSocket.send(packet);
|
||||||
// receiveSocket.
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ public class TerminalController extends CommandManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean sendData(String dataString) {
|
public boolean sendData(ExtCommand extcommand, String dataString) {
|
||||||
System.out.println(dataString);
|
System.out.println(dataString);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,9 @@ public class pamBuoyGlobals {
|
|||||||
// public static Integer useGstreamer = 0;
|
// public static Integer useGstreamer = 0;
|
||||||
// public static boolean useNetworkCont = false;
|
// public static boolean useNetworkCont = false;
|
||||||
private static Integer networkControlPort = null;
|
private static Integer networkControlPort = null;
|
||||||
private static String multiportAddress;
|
private static String multicastAddress;
|
||||||
// private static boolean useDSP = false;
|
// private static boolean useDSP = false;
|
||||||
private static int muliportPort;
|
private static int mulicastPort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the networkControlPort
|
* @return the networkControlPort
|
||||||
@ -33,28 +33,28 @@ private static int muliportPort;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set parameters for mulitport configutation.
|
* Set parameters for mulitport configuration.
|
||||||
* @param mAddr
|
* @param mAddr
|
||||||
* @param mPort
|
* @param mPort
|
||||||
*/
|
*/
|
||||||
public static void setMultiportConfig(String mAddr, int mPort) {
|
public static void setMultiportConfig(String mAddr, int mPort) {
|
||||||
multiportAddress = mAddr;
|
multicastAddress = mAddr;
|
||||||
muliportPort = mPort;
|
mulicastPort = mPort;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the multiportAddress
|
* @return the multiportAddress
|
||||||
*/
|
*/
|
||||||
public static String getMultiportAddress() {
|
public static String getMulticastAddress() {
|
||||||
return multiportAddress;
|
return multicastAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the muliportPort
|
* @return the muliportPort
|
||||||
*/
|
*/
|
||||||
public static int getMuliportPort() {
|
public static int getMulticastPort() {
|
||||||
return muliportPort;
|
return mulicastPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -222,8 +222,7 @@ public class Pamguard {
|
|||||||
PamGUIManager.setType(PamGUIManager.NOGUI);
|
PamGUIManager.setType(PamGUIManager.NOGUI);
|
||||||
System.out.println("no gui operation.");
|
System.out.println("no gui operation.");
|
||||||
}
|
}
|
||||||
///////////////
|
else if (anArg.equalsIgnoreCase("-psf") || anArg.equalsIgnoreCase("-psfx")) {
|
||||||
else if (anArg.equalsIgnoreCase("-psf")) {
|
|
||||||
String autoPsf = args[iArg++];
|
String autoPsf = args[iArg++];
|
||||||
PamSettingManager.remote_psf = autoPsf;
|
PamSettingManager.remote_psf = autoPsf;
|
||||||
System.out.println("Running using settings from " + autoPsf);
|
System.out.println("Running using settings from " + autoPsf);
|
||||||
@ -234,12 +233,12 @@ public class Pamguard {
|
|||||||
pamBuoyGlobals.setNetworkControlPort(Integer.parseInt(port));
|
pamBuoyGlobals.setNetworkControlPort(Integer.parseInt(port));
|
||||||
System.out.println("Setting UDP control port " + port);
|
System.out.println("Setting UDP control port " + port);
|
||||||
}
|
}
|
||||||
else if (anArg.equalsIgnoreCase("-mport")) {
|
else if (anArg.equalsIgnoreCase("-multicast") || anArg.equalsIgnoreCase("-mport")) {
|
||||||
// multicast control (for multiple PAMGuards)
|
// multicast control (for multiple PAMGuards)
|
||||||
String mAddr = args[iArg++];
|
String mAddr = args[iArg++];
|
||||||
int mPort = Integer.parseInt(args[iArg++]);
|
int mPort = Integer.parseInt(args[iArg++]);
|
||||||
pamBuoyGlobals.setMultiportConfig(mAddr, mPort);
|
pamBuoyGlobals.setMultiportConfig(mAddr, mPort);
|
||||||
System.out.printf("Setting multiport control addr %s port %d\n", mAddr, mPort);
|
System.out.printf("Setting multicast control addr %s port %d\n", mAddr, mPort);
|
||||||
}
|
}
|
||||||
else if (anArg.equalsIgnoreCase("-nolog")) {
|
else if (anArg.equalsIgnoreCase("-nolog")) {
|
||||||
System.out.println("Disabling log file from command line switch...");
|
System.out.println("Disabling log file from command line switch...");
|
||||||
|
Loading…
Reference in New Issue
Block a user