mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-25 08:32:32 +00:00
Merge DG branch (#45)
* Variable sound output level Mods to SoundPlayback module to allow additional parameters. Implemented system for NI cards to allow changes to selected output voltage range meaning output can be boosted to level higher than current default. * Code to support nogui operations when no screens present on headless system * Fix problem of nogui headless operation trying to access screen size. * Click detector display fixes 1. ICI not displaying correctly 2. Component sizes in display dialog on hres monitors * Work on batch processing, after testing of options to autostart, autoexit and set wav file folder, database and binary store. * Update MHTClickTrainAlgorithm.java Fix unsynchronised access to a datablock in click train detector which was causing index errors. * Revamp of offline process messaging and control Includes some databsae logging of completed tasks * Offline task logging Bit more work, including notes and database storage of task reprocessing. Guess this could all become 'proper' PAMGuard data and be shown in a table on the display but that not priority enough. * Dialog packing Fix a couple of dialogs which don't back well on HDPI monitors * UDP Control Added multiport functionality
This commit is contained in:
parent
016cfd0da5
commit
49cd547aee
@ -55,6 +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.NetworkController;
|
import PamController.command.NetworkController;
|
||||||
import PamController.command.TerminalController;
|
import PamController.command.TerminalController;
|
||||||
import PamController.command.WatchdogComms;
|
import PamController.command.WatchdogComms;
|
||||||
@ -255,6 +256,9 @@ 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) {
|
||||||
|
new MultiportController(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// binaryStore = new BinaryStore(this);
|
// binaryStore = new BinaryStore(this);
|
||||||
|
118
src/PamController/command/MultiportController.java
Normal file
118
src/PamController/command/MultiportController.java
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
package PamController.command;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.DatagramPacket;
|
||||||
|
import java.net.DatagramSocket;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
import java.net.MulticastSocket;
|
||||||
|
import java.net.NetworkInterface;
|
||||||
|
import java.net.SocketAddress;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
import PamController.PamController;
|
||||||
|
import PamController.pamBuoyGlobals;
|
||||||
|
|
||||||
|
public class MultiportController extends CommandManager {
|
||||||
|
|
||||||
|
//The multicast addresses are in the range 224.0.0.0 through 239.255.255.255
|
||||||
|
|
||||||
|
private static String unitName = "Multiport Controller";
|
||||||
|
private PamController pamController;
|
||||||
|
private String mAddress;
|
||||||
|
private int mPort;
|
||||||
|
private MulticastSocket socket;
|
||||||
|
InetAddress inetAddr;
|
||||||
|
|
||||||
|
static private final int MAX_COMMAND_LENGTH = 4096;
|
||||||
|
|
||||||
|
private byte[] byteBuffer = new byte[MAX_COMMAND_LENGTH];
|
||||||
|
private DatagramPacket lastDatagram;
|
||||||
|
|
||||||
|
public MultiportController(PamController pamController) {
|
||||||
|
super(pamController, unitName);
|
||||||
|
this.pamController = pamController;
|
||||||
|
this.mAddress = pamBuoyGlobals.getMultiportAddress();
|
||||||
|
this.mPort = pamBuoyGlobals.getMuliportPort();
|
||||||
|
|
||||||
|
Thread t = new Thread(new ListenerThread());
|
||||||
|
t.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void runListenerLoop() {
|
||||||
|
try {
|
||||||
|
// inetAddr = InetAddress.getByName(mAddress);
|
||||||
|
// SocketAddress sockAddr = new SocketAddress()
|
||||||
|
// socket = new MulticastSocket(mPort);
|
||||||
|
// socket.joinGroup(inetAddr, null);
|
||||||
|
// socket.joinG
|
||||||
|
|
||||||
|
// open port
|
||||||
|
InetAddress mcastaddr = InetAddress.getByName(mAddress);
|
||||||
|
InetSocketAddress group = new InetSocketAddress(mcastaddr, mPort);
|
||||||
|
NetworkInterface netIf = NetworkInterface.getByName("bge0");
|
||||||
|
socket = new MulticastSocket(mPort);
|
||||||
|
socket.joinGroup(group, netIf);
|
||||||
|
socket.setSoTimeout(0);
|
||||||
|
|
||||||
|
System.out.printf("Waiting for multicast messages at %s port %d\n", mAddress, mPort);
|
||||||
|
|
||||||
|
// sit in loop
|
||||||
|
while (true) {
|
||||||
|
try {
|
||||||
|
DatagramPacket datagram = new DatagramPacket(byteBuffer, MAX_COMMAND_LENGTH);
|
||||||
|
socket.receive(datagram);
|
||||||
|
processDatagram(datagram);
|
||||||
|
}
|
||||||
|
catch (IOException ioE) {
|
||||||
|
ioE.printStackTrace();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// close port.
|
||||||
|
|
||||||
|
socket.leaveGroup(group, netIf);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void processDatagram(DatagramPacket datagram) {
|
||||||
|
lastDatagram = datagram;
|
||||||
|
String str = new String(datagram.getData(), 0, datagram.getLength());
|
||||||
|
// str = str.substring(0, datagram.getLength());
|
||||||
|
System.out.println("Datagram received \"" + str + "\"");
|
||||||
|
interpretCommand(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean sendData(String dataString) {
|
||||||
|
DatagramPacket senderInfo = lastDatagram;
|
||||||
|
System.out.printf("Send back data \"%s\" to %s port %d\n", dataString, senderInfo.getAddress(), senderInfo.getPort());
|
||||||
|
// dataString += "\n";
|
||||||
|
DatagramPacket packet = new DatagramPacket(dataString.getBytes(), dataString.length());
|
||||||
|
packet.setAddress(senderInfo.getAddress());
|
||||||
|
packet.setPort(senderInfo.getPort());
|
||||||
|
try {
|
||||||
|
socket.send(packet);
|
||||||
|
// receiveSocket.
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ListenerThread implements Runnable {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
runListenerLoop();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -14,7 +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 boolean useDSP = false;
|
// private static boolean useDSP = false;
|
||||||
|
private static int muliportPort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the networkControlPort
|
* @return the networkControlPort
|
||||||
@ -29,6 +31,31 @@ public class pamBuoyGlobals {
|
|||||||
public static void setNetworkControlPort(Integer networkControlPort) {
|
public static void setNetworkControlPort(Integer networkControlPort) {
|
||||||
pamBuoyGlobals.networkControlPort = networkControlPort;
|
pamBuoyGlobals.networkControlPort = networkControlPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set parameters for mulitport configutation.
|
||||||
|
* @param mAddr
|
||||||
|
* @param mPort
|
||||||
|
*/
|
||||||
|
public static void setMultiportConfig(String mAddr, int mPort) {
|
||||||
|
multiportAddress = mAddr;
|
||||||
|
muliportPort = mPort;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the multiportAddress
|
||||||
|
*/
|
||||||
|
public static String getMultiportAddress() {
|
||||||
|
return multiportAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the muliportPort
|
||||||
|
*/
|
||||||
|
public static int getMuliportPort() {
|
||||||
|
return muliportPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//public static HashMap pbHash = new HashMap(10,0.75);
|
//public static HashMap pbHash = new HashMap(10,0.75);
|
||||||
|
@ -24,10 +24,23 @@ public class GlobalArguments {
|
|||||||
/**
|
/**
|
||||||
* Get a global parameter value
|
* Get a global parameter value
|
||||||
* @param name value name
|
* @param name value name
|
||||||
* @return value
|
* @return value in original String format
|
||||||
*/
|
*/
|
||||||
public static String getParam(String name) {
|
public static String getParam(String name) {
|
||||||
return globalFlags.get(name);
|
return globalFlags.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a param read as an integer
|
||||||
|
* @param name
|
||||||
|
* @return value as integer or null if not set. Throws exception if invalid integer.
|
||||||
|
*/
|
||||||
|
public static Integer getParamI(String name) {
|
||||||
|
String val = getParam(name);
|
||||||
|
if (val == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return Integer.valueOf(val);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -212,8 +212,15 @@ public class Pamguard {
|
|||||||
System.out.println("Running using settings from " + autoPsf);
|
System.out.println("Running using settings from " + autoPsf);
|
||||||
}
|
}
|
||||||
else if (anArg.equalsIgnoreCase("-port")) {
|
else if (anArg.equalsIgnoreCase("-port")) {
|
||||||
|
// port id to open a udp port to receive commands
|
||||||
pamBuoyGlobals.setNetworkControlPort(Integer.parseInt(args[iArg++]));
|
pamBuoyGlobals.setNetworkControlPort(Integer.parseInt(args[iArg++]));
|
||||||
}
|
}
|
||||||
|
else if (anArg.equalsIgnoreCase("-mport")) {
|
||||||
|
// multicast control (for multiple PAMGuards)
|
||||||
|
String mAddr = args[iArg++];
|
||||||
|
int mPort = Integer.parseInt(args[iArg++]);
|
||||||
|
pamBuoyGlobals.setMultiportConfig(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...");
|
||||||
ProxyPrintStream.disableLogFile();
|
ProxyPrintStream.disableLogFile();
|
||||||
|
Loading…
Reference in New Issue
Block a user