diff --git a/.classpath b/.classpath index 90ca769a..4339aee1 100644 --- a/.classpath +++ b/.classpath @@ -6,7 +6,7 @@ - + diff --git a/.gitignore b/.gitignore index c9419840..61250077 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ settings.xml .classpath .classpath .classpath +.classpath diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml index 779f85b1..9b36655e 100644 --- a/dependency-reduced-pom.xml +++ b/dependency-reduced-pom.xml @@ -4,7 +4,7 @@ org.pamguard Pamguard Pamguard Java12+ - 2.02.07b + 2.02.07f Pamguard for Java 12+, using Maven to control dependcies www.pamguard.org diff --git a/pom.xml b/pom.xml index b0c17c13..64d85708 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 org.pamguard Pamguard - 2.02.07b + 2.02.07f Pamguard Java12+ Pamguard for Java 12+, using Maven to control dependcies www.pamguard.org diff --git a/src/Acquisition/AcquisitionControl.java b/src/Acquisition/AcquisitionControl.java index f0bd367d..406796c8 100644 --- a/src/Acquisition/AcquisitionControl.java +++ b/src/Acquisition/AcquisitionControl.java @@ -873,4 +873,19 @@ public class AcquisitionControl extends RawInputControlledUnit implements PamSet 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; + } + } + } diff --git a/src/Acquisition/FolderInputSystem.java b/src/Acquisition/FolderInputSystem.java index 445b3243..12505cab 100644 --- a/src/Acquisition/FolderInputSystem.java +++ b/src/Acquisition/FolderInputSystem.java @@ -50,6 +50,7 @@ import PamView.dialog.PamGridBagContraints; import PamView.dialog.PamLabel; import PamView.panel.PamPanel; import PamView.panel.PamProgressBar; +import PamguardMVC.debug.Debug; /** * Read multiple files in sequence. Options exist to either pause and @@ -118,7 +119,7 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D if (folderInputParameters == null) setFolderInputParameters(new FolderInputParameters(getSystemType())); // PamSettingManager.getInstance().registerSettings(this); //calling super already registers this in the FileInputSystem constructor - checkComandLine(); +// checkComandLine(); makeSelFileList(); newFileTimer = new Timer(1000, new RestartTimer()); newFileTimer.setRepeats(false); @@ -128,21 +129,24 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D /** * Check to see if acquisition source folder was set in the command line. */ - private void checkComandLine() { + private String[] checkComandLineFolder() { String globalFolder = GlobalArguments.getParam(GlobalWavFolderArg); + Debug.out.println("Checking -wavfilefolder option: is " + globalFolder); if (globalFolder == null) { - return; + return null; } // see if it at least exists, though will we want to do this for Network folders ? File aFile = new File(globalFolder); if (aFile.exists() == false) { - System.err.println("Command line folder does not exist: " + globalFolder); + System.err.printf("Command line wav folder \"%s\" does not exist", globalFolder); +// return null; } String[] selList = {globalFolder}; - folderInputParameters.setSelectedFiles(selList); +// folderInputParameters.setSelectedFiles(selList); // need to immediately make the allfiles list since it's about to get used by the reprocess manager // need to worry about how to wait for this since it's starting in a different thread. - makeSelFileList(); + //makeSelFileList(); + return selList; } /** @@ -295,15 +299,24 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D } /** - * Make a list of wav files within a folder. + * Make a list of wav files within a folder. In some circumstances this can be a list + * of actual files in a folder. Also needs to handle the possibility of it using + * a globally set folder name. * @return flag to indicate...nothing? */ public int makeSelFileList() { - if (fileInputParameters.recentFiles == null || fileInputParameters.recentFiles.size() < 1) { - return 0; + String[] selection = checkComandLineFolder(); + + if (selection == null) { + if (fileInputParameters.recentFiles == null || fileInputParameters.recentFiles.size() < 1) { + return 0; + } + selection = folderInputParameters.getSelectedFiles(); + } + if (selection.length > 0) { + System.out.println("FolderInputSystem.makeSelFileList(): Searching for sound files in " + selection[0]); } - String[] selection = folderInputParameters.getSelectedFiles(); return makeSelFileList(selection); } @@ -863,16 +876,30 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D * processing will continue from there. */ if (allFiles == null || allFiles.size() == 0) { + System.out.println("Daq setanal start time: no files to check against"); return false; } + System.out.printf("setAnalysisStarttTime: checking %d files for start time of %s\n", allFiles.size(), PamCalendar.formatDBDateTime(startTime)); + /* + * If the starttime is maxint then there is nothing to do, but we do need to set the file index + * correctly to not over confuse the batch processing system. + */ + long lastFileTime = getFileStartTime(allFiles.get(allFiles.size()-1).getAbsoluteFile()); + if (startTime > lastFileTime) { + currentFile = allFiles.size(); + System.out.println("Folder Acquisition processing is complete and no files require processing"); + return true; + } for (int i = 0; i < allFiles.size(); i++) { long fileStart = getFileStartTime(allFiles.get(i).getAbsoluteFile()); if (fileStart >= startTime) { currentFile = i; PamCalendar.setSoundFile(true); - PamCalendar.setSessionStartTime(startTime); - System.out.printf("Sound Acquisition start processing at file %s time %s\n", allFiles.get(i).getName(), - PamCalendar.formatDBDateTime(fileStart)); + if (startTime > 0) { + PamCalendar.setSessionStartTime(startTime); + System.out.printf("Sound Acquisition start processing at file %s time %s\n", allFiles.get(i).getName(), + PamCalendar.formatDBDateTime(fileStart)); + } return true; } } @@ -880,5 +907,19 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D 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; + } + } diff --git a/src/Acquisition/filedate/StandardFileDate.java b/src/Acquisition/filedate/StandardFileDate.java index aa87e973..53033f60 100644 --- a/src/Acquisition/filedate/StandardFileDate.java +++ b/src/Acquisition/filedate/StandardFileDate.java @@ -284,9 +284,12 @@ public class StandardFileDate implements FileDate, PamSettings { } catch (ParseException e) { // TODO Auto-generated catch block // e.printStackTrace(); - System.out.println(e.getMessage()); + System.out.println("StandardfileDate.forcedDataFormat:" + e.getMessage()); } //throws ParseException if no match setLastFormat(forcedDateFormat); + if (d == null) { + return 0; + } return d.getTime(); } diff --git a/src/IshmaelLocator/IshLocProcess.java b/src/IshmaelLocator/IshLocProcess.java index cdec7212..9b34462d 100644 --- a/src/IshmaelLocator/IshLocProcess.java +++ b/src/IshmaelLocator/IshLocProcess.java @@ -368,7 +368,7 @@ abstract public class IshLocProcess extends PamProcess implements SpectrogramMar selectionSams = daqBlock.getSamples(startSam, (int)durationSam, channelMap); } catch (RawDataUnavailableException e) { - System.out.println(e.getMessage()); + System.out.println("RawDataUnavailableException in IshLocProcess:" + e.getMessage()); // if the raw data has already been discarded, adjust the natural lifetime to try and avoid this in the future int newTime; diff --git a/src/JSSHTerminal/SSHSession.java b/src/JSSHTerminal/SSHSession.java index daf2e2f1..af5ccd56 100644 --- a/src/JSSHTerminal/SSHSession.java +++ b/src/JSSHTerminal/SSHSession.java @@ -287,7 +287,7 @@ public final class SSHSession implements UserInfo { out.write(k); out.flush(); } catch (IOException e) { - System.out.println(e.getMessage()); + System.out.println("IOException in SSHSession.write: " + e.getMessage()); } } @@ -349,7 +349,7 @@ public final class SSHSession implements UserInfo { } } } catch (IOException e) { - System.out.println(e.getMessage()); + System.out.println("Error in SSHSession.pump: " + e.getMessage()); } finally { closeQuietly(in); closeQuietly(out); diff --git a/src/NMEA/AcquireNmeaData.java b/src/NMEA/AcquireNmeaData.java index 95a0f39b..e86d0ba2 100644 --- a/src/NMEA/AcquireNmeaData.java +++ b/src/NMEA/AcquireNmeaData.java @@ -203,7 +203,7 @@ public class AcquireNmeaData extends PamProcess implements ActionListener, Modul try { pjSerialComm = PJSerialComm.openSerialPort(params.serialPortName, params.serialPortBitsPerSecond); } catch (PJSerialException e) { - System.out.println(e.getMessage()); + System.out.println("PJSerialException in AcquireNMEAData" + e.getMessage()); // WarnOnce.sho return; } diff --git a/src/PamController/PamController.java b/src/PamController/PamController.java index 1d32efc7..2b54ec35 100644 --- a/src/PamController/PamController.java +++ b/src/PamController/PamController.java @@ -55,7 +55,7 @@ import generalDatabase.DBControlUnit; import javafx.application.Platform; import javafx.stage.Stage; import Array.ArrayManager; -import PamController.command.MultiportController; +import PamController.command.MulticastController; import PamController.command.NetworkController; import PamController.command.TerminalController; import PamController.command.WatchdogComms; @@ -258,8 +258,8 @@ public class PamController implements PamControllerInterface, PamSettings { if (pamBuoyGlobals.getNetworkControlPort() != null) { networkController = new NetworkController(this); } - if (pamBuoyGlobals.getMultiportAddress() != null) { - new MultiportController(this); + if (pamBuoyGlobals.getMulticastAddress() != null) { + new MulticastController(this); } guiFrameManager = PamGUIManager.createGUI(this, object); @@ -1316,7 +1316,12 @@ public class PamController implements PamControllerInterface, PamSettings { @Override public void run() { + long t1 = System.currentTimeMillis(); while (checkRunStatus()) { + long t2 = System.currentTimeMillis(); + if (t2 - t1 > 5000) { + System.out.printf("Stopping, but stuck in loop for CheckRunStatus for %3.1fs\n", (double) (t2-t1)/1000.); + } try { Thread.sleep(10); } catch (InterruptedException e) { diff --git a/src/PamController/PamSettingManager.java b/src/PamController/PamSettingManager.java index e9119294..42488e1d 100644 --- a/src/PamController/PamSettingManager.java +++ b/src/PamController/PamSettingManager.java @@ -1752,10 +1752,10 @@ public class PamSettingManager { fIs.close(); fOs.close(); } catch (FileNotFoundException e) { - System.out.println(e.getMessage()); + System.out.println("FileNotFound exception in PamSettingsManager: " + e.getMessage()); return false; } catch (IOException e) { - System.out.println(e.getMessage()); + System.out.println("IO exception in PamSettingsManager: " + e.getMessage()); return false; } return true; diff --git a/src/PamController/PamguardVersionInfo.java b/src/PamController/PamguardVersionInfo.java index 072ba3de..791c56a3 100644 --- a/src/PamController/PamguardVersionInfo.java +++ b/src/PamController/PamguardVersionInfo.java @@ -31,12 +31,12 @@ public class PamguardVersionInfo { * Version number, major version.minorversion.sub-release. * Note: can't go higher than sub-release 'f' */ - static public final String version = "2.02.07b"; + static public final String version = "2.02.07f"; /** * Release date */ - static public final String date = "19 January 2023"; + static public final String date = "4 April 2023"; // /** // * Release type - Beta or Core diff --git a/src/PamController/command/BatchCommand.java b/src/PamController/command/BatchCommand.java new file mode 100644 index 00000000..a3dadfa8 --- /dev/null +++ b/src/PamController/command/BatchCommand.java @@ -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; + } + +} diff --git a/src/PamController/command/BatchStatusCommand.java b/src/PamController/command/BatchStatusCommand.java new file mode 100644 index 00000000..a58012b2 --- /dev/null +++ b/src/PamController/command/BatchStatusCommand.java @@ -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(); + } + +} diff --git a/src/PamController/command/CommandManager.java b/src/PamController/command/CommandManager.java index 01533e28..87f4b888 100644 --- a/src/PamController/command/CommandManager.java +++ b/src/PamController/command/CommandManager.java @@ -40,6 +40,8 @@ public abstract class CommandManager extends PamControlledUnit { commandsList.add(new HelpCommand(this)); commandsList.add(new GetXMLSettings()); 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); if (extCommand == null) { - sendData("Cmd \"" + commandString + "\" Not Recognised."); + sendData(extCommand, "Cmd \"" + commandString + "\" Not Recognised."); return false; } if (extCommand.canExecute() == false) { - sendData("Cmd \"" + command + "\" Cannot Execute."); + sendData(extCommand, "Cmd \"" + command + "\" Cannot Execute."); // sendData(" Cmd return string = " + extCommand.getReturnString()); return false; } String output = extCommand.executeCommand(commandString); - sendData(output); + sendData(extCommand,output); return true; @@ -154,9 +156,10 @@ public abstract class CommandManager extends PamControlledUnit { /** * Reply to data called from InterpredData + * @param extCommand * @param dataString * @return true if replay successful */ - abstract public boolean sendData(String dataString); + abstract public boolean sendData(ExtCommand extCommand, String dataString); } diff --git a/src/PamController/command/ExitCommand.java b/src/PamController/command/ExitCommand.java index a44c91ce..f12a6dd6 100644 --- a/src/PamController/command/ExitCommand.java +++ b/src/PamController/command/ExitCommand.java @@ -10,15 +10,20 @@ import PamController.PamSettingManager; */ public class ExitCommand extends ExtCommand { + public static final String commandId = "Exit"; + public ExitCommand() { - super("Exit", false); + super(commandId, false); } @Override public String execute(String command) { PamController.getInstance().pamStop(); PamSettingManager.getInstance().saveFinalSettings(); - System.exit(0); + PamController pamController = PamController.getInstance(); + pamController.pamClose(); + // shut down the JavaFX thread and the JVM + pamController.shutDownPamguard(); return getName(); } diff --git a/src/PamController/command/HelpCommand.java b/src/PamController/command/HelpCommand.java index 400516ad..3350c828 100644 --- a/src/PamController/command/HelpCommand.java +++ b/src/PamController/command/HelpCommand.java @@ -25,7 +25,7 @@ public class HelpCommand extends ExtCommand { out += "\n"; } } - commandManager.sendData(out); + commandManager.sendData(this, out); return getName(); } diff --git a/src/PamController/command/MultiportController.java b/src/PamController/command/MulticastController.java similarity index 65% rename from src/PamController/command/MultiportController.java rename to src/PamController/command/MulticastController.java index ead9e397..de92b6ae 100644 --- a/src/PamController/command/MultiportController.java +++ b/src/PamController/command/MulticastController.java @@ -12,12 +12,14 @@ import java.nio.charset.StandardCharsets; import PamController.PamController; 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 - private static String unitName = "Multiport Controller"; + private static String unitName = "Multicast Controller"; private PamController pamController; private String mAddress; private int mPort; @@ -29,11 +31,11 @@ public class MultiportController extends CommandManager { private byte[] byteBuffer = new byte[MAX_COMMAND_LENGTH]; private DatagramPacket lastDatagram; - public MultiportController(PamController pamController) { + public MulticastController(PamController pamController) { super(pamController, unitName); this.pamController = pamController; - this.mAddress = pamBuoyGlobals.getMultiportAddress(); - this.mPort = pamBuoyGlobals.getMuliportPort(); + this.mAddress = pamBuoyGlobals.getMulticastAddress(); + this.mPort = pamBuoyGlobals.getMulticastPort(); Thread t = new Thread(new ListenerThread()); t.start(); @@ -83,17 +85,35 @@ public class MultiportController extends CommandManager { 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 + "\""); + str = str.substring(0, datagram.getLength()); +// System.out.println("Datagram received \"" + str + "\""); interpretCommand(str); } @Override - public boolean sendData(String dataString) { + public boolean sendData(ExtCommand extCommand, String dataString) { + if (dataString == null || dataString.length() == 0) { + return false; + } 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"; - DatagramPacket packet = new DatagramPacket(dataString.getBytes(), dataString.length()); + DatagramPacket packet = new DatagramPacket(bigString.getBytes(), bigString.length()); packet.setAddress(senderInfo.getAddress()); packet.setPort(senderInfo.getPort()); try { diff --git a/src/PamController/command/NetworkController.java b/src/PamController/command/NetworkController.java index 2090851b..82268bd1 100644 --- a/src/PamController/command/NetworkController.java +++ b/src/PamController/command/NetworkController.java @@ -124,16 +124,14 @@ public class NetworkController extends CommandManager { } } - - public boolean sendData(String dataString) { + @Override + public boolean sendData(ExtCommand extCommand, String dataString) { DatagramPacket packet = new DatagramPacket(dataString.getBytes(), dataString.length()); packet.setAddress(udpPacket.getAddress()); packet.setPort(udpPacket.getPort()); try { receiveSocket.send(packet); -// receiveSocket. } catch (IOException e) { - // TODO Auto-generated catch block e.printStackTrace(); return false; } diff --git a/src/PamController/command/TerminalController.java b/src/PamController/command/TerminalController.java index e8589cd2..533b23ee 100644 --- a/src/PamController/command/TerminalController.java +++ b/src/PamController/command/TerminalController.java @@ -17,7 +17,7 @@ public class TerminalController extends CommandManager { } @Override - public boolean sendData(String dataString) { + public boolean sendData(ExtCommand extcommand, String dataString) { System.out.println(dataString); return true; } diff --git a/src/PamController/extern/ExternalCapture.java b/src/PamController/extern/ExternalCapture.java index a4ff2259..8413467f 100644 --- a/src/PamController/extern/ExternalCapture.java +++ b/src/PamController/extern/ExternalCapture.java @@ -46,7 +46,7 @@ public class ExternalCapture extends ExternalController { } } } catch (IOException e) { - System.out.println(e.getMessage()); + System.out.println("IOError in ExternalCapture.readInputStream: " + e.getMessage()); } } diff --git a/src/PamController/fileprocessing/ReprocessManager.java b/src/PamController/fileprocessing/ReprocessManager.java index 69ebf54f..4f05913a 100644 --- a/src/PamController/fileprocessing/ReprocessManager.java +++ b/src/PamController/fileprocessing/ReprocessManager.java @@ -54,13 +54,19 @@ public class ReprocessManager { // need to decide what to do based on the list of possible choices. ReprocessStoreChoice choice = chosePartStoreAction(choiceSummary); + + /** + * Need to call this even though we aren't reprocessing so that + * the Folderinput stream reports correctly on how many files have + * been processed. + */ + boolean setupOK = setupInputStream(choiceSummary, choice); if (choice == ReprocessStoreChoice.DONTSSTART) { return false; } boolean deleteOK = deleteOldData(choiceSummary, choice); - boolean setupOK = setupInputStream(choiceSummary, choice); return true; @@ -169,9 +175,11 @@ public class ReprocessManager { ArrayList outputStores = PamController.getInstance().findControlledUnits(DataOutputStore.class, true); boolean partStores = false; + int nOutputStores = 0; for (PamControlledUnit aPCU : outputStores) { DataOutputStore offlineStore = (DataOutputStore) aPCU; StoreStatus status = offlineStore.getStoreStatus(false); + nOutputStores++; if (status == null) { continue; } @@ -185,8 +193,8 @@ public class ReprocessManager { } if (partStores == false) { - choiceSummary.addChoice(ReprocessStoreChoice.STARTNORMAL); - return choiceSummary; +// choiceSummary.addChoice(ReprocessStoreChoice.STARTNORMAL); + return null; // no part full stores, so can start without questions } if (choiceSummary.getInputStartTime() >= choiceSummary.getOutputEndTime()) { /* diff --git a/src/PamController/fileprocessing/ReprocessStoreChoice.java b/src/PamController/fileprocessing/ReprocessStoreChoice.java index 0a6835db..6a6bd019 100644 --- a/src/PamController/fileprocessing/ReprocessStoreChoice.java +++ b/src/PamController/fileprocessing/ReprocessStoreChoice.java @@ -16,7 +16,7 @@ public enum ReprocessStoreChoice { public String toString() { switch (this) { case STARTNORMAL: - return "Start normally. No risk of overwriting"; + return "Start normally. Note risk of overwriting!"; case CONTINUECURRENTFILE: return "Continue from start of last input file processed"; case CONTINUENEXTFILE: diff --git a/src/PamController/pamBuoyGlobals.java b/src/PamController/pamBuoyGlobals.java index dee3a1db..9b0a436f 100644 --- a/src/PamController/pamBuoyGlobals.java +++ b/src/PamController/pamBuoyGlobals.java @@ -14,9 +14,9 @@ public class pamBuoyGlobals { // public static Integer useGstreamer = 0; // public static boolean useNetworkCont = false; private static Integer networkControlPort = null; -private static String multiportAddress; +private static String multicastAddress; // private static boolean useDSP = false; -private static int muliportPort; +private static int mulicastPort; /** * @return the networkControlPort @@ -33,28 +33,28 @@ private static int muliportPort; } /** - * Set parameters for mulitport configutation. + * Set parameters for mulitport configuration. * @param mAddr * @param mPort */ public static void setMultiportConfig(String mAddr, int mPort) { - multiportAddress = mAddr; - muliportPort = mPort; + multicastAddress = mAddr; + mulicastPort = mPort; } /** * @return the multiportAddress */ - public static String getMultiportAddress() { - return multiportAddress; + public static String getMulticastAddress() { + return multicastAddress; } /** * @return the muliportPort */ - public static int getMuliportPort() { - return muliportPort; + public static int getMulticastPort() { + return mulicastPort; } diff --git a/src/PamController/settings/output/xml/PamguardXMLWriter.java b/src/PamController/settings/output/xml/PamguardXMLWriter.java index ec656589..af35b51e 100644 --- a/src/PamController/settings/output/xml/PamguardXMLWriter.java +++ b/src/PamController/settings/output/xml/PamguardXMLWriter.java @@ -714,7 +714,7 @@ public class PamguardXMLWriter implements PamSettings { } } catch (Exception e) { - System.out.println(e.getMessage()); + System.out.println("Error in PamguardXMLWriter.writeArray: " + e.getMessage()); } return null; } @@ -756,7 +756,7 @@ public class PamguardXMLWriter implements PamSettings { return e; } catch (Exception e) { - System.out.println(e.getMessage()); + System.out.println("Error in PamguardXMLWriter.writeObjectArray: " + e.getMessage()); } return null; } @@ -781,7 +781,7 @@ public class PamguardXMLWriter implements PamSettings { // el.appendChild(e); } catch (Exception e) { - System.out.println(e.getMessage()); + System.out.println("Error in PamguardXMLWriter.writePrimativeArray: " + e.getMessage()); } return null; } diff --git a/src/PamUtils/FileFunctions.java b/src/PamUtils/FileFunctions.java index 6d3d1319..739a7a92 100644 --- a/src/PamUtils/FileFunctions.java +++ b/src/PamUtils/FileFunctions.java @@ -108,7 +108,7 @@ public class FileFunctions { return attrib; } catch (Error e) { - System.out.println(e.getMessage()); + System.out.println("Error in FileFunctions.getAttributes: " + e.getMessage()); return 0; } } diff --git a/src/PamUtils/PamCalendar.java b/src/PamUtils/PamCalendar.java index 3ce2eebc..d41aa018 100644 --- a/src/PamUtils/PamCalendar.java +++ b/src/PamUtils/PamCalendar.java @@ -46,6 +46,8 @@ public class PamCalendar { public static TimeZone defaultTimeZone = TimeZone.getTimeZone("UTC"); + + private static TimeZone localTimeZone = TimeZone.getDefault(); public static final long millisPerDay = 1000L*24L*3600L; @@ -174,8 +176,9 @@ public class PamCalendar { } public static TimeZone getDisplayTimeZone(boolean useLocal) { - return TimeZone.getTimeZone("UTC"); - // return useLocal ? CalendarControl.getInstance().getChosenTimeZone() : defaultTimeZone; +// return TimeZone.getTimeZone("UTC"); +// return useLocal ? CalendarControl.getInstance().getChosenTimeZone() : defaultTimeZone; + return useLocal ? localTimeZone : defaultTimeZone; } public static String formatDateTime(Date date) { diff --git a/src/PamUtils/worker/filelist/FileListWorker.java b/src/PamUtils/worker/filelist/FileListWorker.java index 56c52caa..e613ced0 100644 --- a/src/PamUtils/worker/filelist/FileListWorker.java +++ b/src/PamUtils/worker/filelist/FileListWorker.java @@ -8,6 +8,7 @@ import PamUtils.PamFileFilter; import PamUtils.worker.PamWorkProgressMessage; import PamUtils.worker.PamWorkWrapper; import PamUtils.worker.PamWorker; +import PamguardMVC.debug.Debug; /** * Class to list files in one or more directories. @@ -64,6 +65,9 @@ public abstract class FileListWorker implements PamWorkWrapper>>>>>>>Starting file search in " + rootList[i]); + } if (noChange(rootList, subFolders, useOldIfPossible)) { SwingUtilities.invokeLater(new Runnable() { @Override @@ -162,6 +166,7 @@ public abstract class FileListWorker implements PamWorkWrapper> pamWorker, FileListData newFileList, File folder) { newFileList.addFolder(); pamWorker.update(new PamWorkProgressMessage(-1, "Searching folder " + folder.getAbsolutePath())); + Debug.out.println(">>>> Searching for files in abs path " + folder.getAbsolutePath()); // System.out.println(folder.getAbsolutePath()); File[] moreFiles = folder.listFiles(fileFilter); if (moreFiles == null) { diff --git a/src/PamView/component/DataBlockTableView.java b/src/PamView/component/DataBlockTableView.java index 124addfc..f8ae214f 100644 --- a/src/PamView/component/DataBlockTableView.java +++ b/src/PamView/component/DataBlockTableView.java @@ -106,6 +106,13 @@ public abstract class DataBlockTableView { } } + /** + * Call the table data changed function to update table values. + */ + public void fireTableDataChanged() { + blockTableModel.fireTableDataChanged(); + } + public JComponent getComponent() { return tablePanel; } @@ -150,13 +157,22 @@ public abstract class DataBlockTableView { String tip = null; java.awt.Point p = e.getPoint(); int rowIndex = rowAtPoint(p); +// int column = columnAtPoint(p); +// System.out.println("Get tooltip for row " + rowIndex + " column" + column); if (rowIndex < 0) { return null; } int colIndex = columnAtPoint(p); int realColumnIndex = convertColumnIndexToModel(colIndex); - T dataUnit = getDataUnit(rowIndex); - return DataBlockTableView.this.getToolTipText(dataUnit, realColumnIndex); + try { + T dataUnit = getDataUnit(rowIndex); + return DataBlockTableView.this.getToolTipText(dataUnit, realColumnIndex); + } + catch (Exception ex) { + // I once got an index out of bounds here, or it might have been + // a concurrent modification exception ? Either way return null; + return null; + } } } @@ -226,13 +242,16 @@ public abstract class DataBlockTableView { /** * Get the number of rows in the table - default behaviour is the - * number of rows in the datablock, but this may be overridded if + * number of rows in the datablock, but this may be overridden if * data are being selected in a different way. * @return number of table rows to show. */ public int getRowCount() { if (dataUnitCopy == null) { - return 0; + updatePamData(); + if (dataUnitCopy == null) { + return 0; + } } return dataUnitCopy.size(); } diff --git a/src/Resources/css/primer-dark.css b/src/Resources/css/primer-dark.css index 82062a73..6c1e53ca 100644 --- a/src/Resources/css/primer-dark.css +++ b/src/Resources/css/primer-dark.css @@ -3699,7 +3699,7 @@ Text { #label-title1 { - -fx-font: bold 16pt -fx-font-family; + -fx-font: bold 14pt -fx-font-family; } #label-title2 { diff --git a/src/RightWhaleEdgeDetector/RWEProcess.java b/src/RightWhaleEdgeDetector/RWEProcess.java index d8fa8ae4..081489c9 100644 --- a/src/RightWhaleEdgeDetector/RWEProcess.java +++ b/src/RightWhaleEdgeDetector/RWEProcess.java @@ -181,7 +181,7 @@ public class RWEProcess extends PamProcess { minSoundType = rweControl.rweParameters.minSoundType; classifier.setSoundData(getSampleRate(), sourceDataBlock.getFftLength(), sourceDataBlock.getFftHop()); - System.out.println("Create right whale channel process " + iChannel); +// System.out.println("Create right whale channel process " + iChannel); } diff --git a/src/alarm/AlarmProcess.java b/src/alarm/AlarmProcess.java index c6194ced..a8e3ee36 100644 --- a/src/alarm/AlarmProcess.java +++ b/src/alarm/AlarmProcess.java @@ -225,6 +225,11 @@ public class AlarmProcess extends PamProcess { } + @Override + public void updateData(PamObservable o, PamDataUnit arg) { + newData(o, arg); + } + public boolean setupAlarm() { dataSource = PamController.getInstance().getDataBlock(PamDataUnit.class, alarmControl.alarmParameters.dataSourceName); if (dataSource == null) { diff --git a/src/alarm/actions/sound/PlaySound.java b/src/alarm/actions/sound/PlaySound.java index 0d3a13fe..e02ac14f 100644 --- a/src/alarm/actions/sound/PlaySound.java +++ b/src/alarm/actions/sound/PlaySound.java @@ -94,7 +94,7 @@ public class PlaySound extends AlarmAction implements PamSettings { double secs = fl/sr*1000; } catch (Exception e) { - System.out.println(e.getMessage()); + System.out.println("Error in PlaySound.playSound:" + e.getMessage()); return false; } return true; @@ -114,10 +114,10 @@ public class PlaySound extends AlarmAction implements PamSettings { System.out.println(f.getMessage()); return currentClip = null; } catch (IOException e) { - System.out.println(e.getMessage()); + System.out.println("IOError in PlaySound.prepareClip: " + e.getMessage()); return currentClip = null; } catch (LineUnavailableException e) { - System.out.println(e.getMessage()); + System.out.println("LineUnavailableException in PlaySound.prepareClip: " + e.getMessage()); return currentClip = null; } currentFile = soundFile; diff --git a/src/backupmanager/stream/BackupStream.java b/src/backupmanager/stream/BackupStream.java index ae4f87e4..bc0e3d14 100644 --- a/src/backupmanager/stream/BackupStream.java +++ b/src/backupmanager/stream/BackupStream.java @@ -118,7 +118,7 @@ public abstract class BackupStream implements PamSettings, BackupFunction { try { ok = doAction(backupManager, action, item); } catch (BackupException e) { - System.out.println(e.getMessage()); + System.out.println("Error in BackupStream.runAction:" + e.getMessage()); backupManager.updateProgress(new BackupProgress(this, action, STATE.PROBLEM, toDoList.size(), iDone, "Error " + e.getMessage())); ok = false; //otherwise, OK stays true! This will leave a true null entry in the database, so file will be selected next time around diff --git a/src/binaryFileStorage/BinaryDataSource.java b/src/binaryFileStorage/BinaryDataSource.java index ccd07440..bb2888ba 100644 --- a/src/binaryFileStorage/BinaryDataSource.java +++ b/src/binaryFileStorage/BinaryDataSource.java @@ -41,6 +41,8 @@ public abstract class BinaryDataSource { private boolean saveUpdates = false; private BackgroundBinaryWriter backgroundBinaryWriter; + + public static final Object packSynchObject = new Object(); /** * Create a binary data source. These are used both to store data in binary @@ -224,11 +226,13 @@ public abstract class BinaryDataSource { * Then pack the data */ BinaryObjectData data; - if (pamDataUnit instanceof BackgroundDataUnit) { - data = getBackgroundBinaryWriter().packBackgroundData((BackgroundDataUnit) pamDataUnit); - } - else { - data = getPackedData(pamDataUnit); + synchronized (packSynchObject) { + if (pamDataUnit instanceof BackgroundDataUnit) { + data = getBackgroundBinaryWriter().packBackgroundData((BackgroundDataUnit) pamDataUnit); + } + else { + data = getPackedData(pamDataUnit); + } } /* * Then put it back to how it was a moment ago. diff --git a/src/binaryFileStorage/BinaryStoreProcess.java b/src/binaryFileStorage/BinaryStoreProcess.java index f1f06fd8..c3a728b4 100644 --- a/src/binaryFileStorage/BinaryStoreProcess.java +++ b/src/binaryFileStorage/BinaryStoreProcess.java @@ -46,7 +46,6 @@ public class BinaryStoreProcess extends PamProcess { startTime = PamCalendar.getTimeInMillis(); long round = binaryStore.binaryStoreSettings.fileSeconds * 1000; nextFileTime = (startTime/round) * round + round; - // this was a print of the time of the NEXT binary file. Not really of interest. // System.out.println("Next file start at " + PamCalendar.formatDateTime(nextFileTime)); timer = new Timer(); timer.schedule(new FileTimerTask(), 1000, 1000); diff --git a/src/clickDetector/ClickDetector.java b/src/clickDetector/ClickDetector.java index db602360..d7330047 100644 --- a/src/clickDetector/ClickDetector.java +++ b/src/clickDetector/ClickDetector.java @@ -1809,7 +1809,7 @@ public class ClickDetector extends PamProcess { newClick.setStartSample(newClick.getStartSample() - firstFilterDelay - secondFilterDelay); waveDataError = false; } catch (RawDataUnavailableException e) { - System.out.println("RawDataUnavailableException"); + System.out.println(" Click Detector RawDataUnavailableException"); System.out.println(e.getMessage()); } for (int k = 0; k < nChannels; k++) { diff --git a/src/clickDetector/layoutFX/clickClassifiers/SweepClassifierSetPaneFX.java b/src/clickDetector/layoutFX/clickClassifiers/SweepClassifierSetPaneFX.java index 6fd77115..e11aec29 100644 --- a/src/clickDetector/layoutFX/clickClassifiers/SweepClassifierSetPaneFX.java +++ b/src/clickDetector/layoutFX/clickClassifiers/SweepClassifierSetPaneFX.java @@ -51,12 +51,18 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JPanel; import PamController.SettingsPane; import PamUtils.PamUtils; import PamView.PamSymbol; import PamView.dialog.PamGridBagContraints; import PamView.symbol.SymbolData; -import PamguardMVC.debug.Debug; +import clickDetector.ClickControl; import clickDetector.ClickClassifiers.basicSweep.CodeHost; import clickDetector.ClickClassifiers.basicSweep.SweepClassifier; import clickDetector.ClickClassifiers.basicSweep.SweepClassifierSet; @@ -238,11 +244,10 @@ public class SweepClassifierSetPaneFX extends SettingsPane { //create holder pane borderPane=new PamBorderPane(); this.setCenter(borderPane); - + PamHBox hBox = new PamHBox(); hBox.setSpacing(5); - if (borderTitle != null) { label=new Label(borderTitle); @@ -765,6 +770,8 @@ public class SweepClassifierSetPaneFX extends SettingsPane { */ PamSpinner threshold; + private PamVBox vboxholder; + ClickLengthBox() { super("Click Length", true); @@ -883,10 +890,11 @@ public class SweepClassifierSetPaneFX extends SettingsPane { @Override protected void disbleControls(boolean disable) { - smoothing.setDisable(disable); - minLengthms.setDisable(disable); - maxLengthms.setDisable(disable); - threshold.setDisable(disable); + vboxholder.setDisable(disable); +// smoothing.setDisable(disable); +// minLengthms.setDisable(disable); +// maxLengthms.setDisable(disable); +// threshold.setDisable(disable); } } @@ -930,13 +938,13 @@ public class SweepClassifierSetPaneFX extends SettingsPane { pamGridPane.setVgap(5); Label freqLabel=new Label("Frequency (Hz)"); - pamGridPane.add(freqLabel, 0, 0); - pamGridPane.add(new Label("Threshold (dB)"), 2, 0); - PamGridPane.setHalignment(freqLabel, HPos.CENTER); - PamGridPane.setColumnSpan(pamGridPane, 2); - - //test band - pamGridPane.add(new Label("Test Band"), 0, 1); +//// gridPaneHolder.add(freqLabel, 0, 0); +//// gridPaneHolder.add(new Label("Threshold (dB)"), 2, 0); +// PamGridPane.setHalignment(freqLabel, HPos.CENTER); +// PamGridPane.setColumnSpan(gridPaneHolder, 2); +// +// //test band +// gridPaneHolder.add(new Label("Test Band"), 0, 1); testBandFreqPane=new FreqBandPane(Orientation.HORIZONTAL); testBandFreqPane.setBandText(""); @@ -1095,6 +1103,9 @@ public class SweepClassifierSetPaneFX extends SettingsPane { private PamSpinner threshold; private FreqBandPane searchRange; private FreqBandPane meanFreq; + + //the main holder pane. + private PamGridPane gridPaneHolder; FrequencySearchBlock() { super("Peak and Mean Frequency", true); @@ -1177,14 +1188,12 @@ public class SweepClassifierSetPaneFX extends SettingsPane { addValidatorFreqCheck(getValidator(), peakWidthPane, "peak width ", "peak_width"); gridy++; - pamGridPane.add(new Label(""), 1,gridy); threshold=new PamSpinner(1., 300., 6.,1.); threshold.getStyleClass().add(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL); threshold.setPrefWidth(100); GridPane.setMargin(threshold, new Insets(0,0,0,5)); //bit of a hack to make sure everything lines up nicely with the frequency pane. - pamGridPane.add(threshold,2,gridy); pamGridPane.add(new Label("dB"), 3,gridy); @@ -1217,8 +1226,6 @@ public class SweepClassifierSetPaneFX extends SettingsPane { @Override protected void setParams() { setEnableBox(sweepClassifierSet.enableEnergyBands); - - } @Override @@ -1228,6 +1235,22 @@ public class SweepClassifierSetPaneFX extends SettingsPane { } @Override +// protected void disbleControls(boolean disable) { +// this.gridPaneHolder.setDisable(disable); + +// peakFreqCheckBox.setDisable(enable); +// peakWidthCheckBox.setDisable(enable); +// meanFreqCheckBox.setDisable(enable); +// +// +// /** +// * Pane to set frequency band range */ +// peakFreqPane.setDisable(enable); +// smoothing.setDisable(enable); +// peakWidthPane.setDisable(enable); +// threshold.setDisable(enable); +// searchRange.setDisable(enable); +// meanFreq.setDisable(enable); protected void disbleControls(boolean enable) { peakFreqCheckBox.setDisable(enable); peakWidthCheckBox.setDisable(enable); @@ -1275,6 +1298,11 @@ public class SweepClassifierSetPaneFX extends SettingsPane { */ private PamSpinner freqZeroMax; + /** + * The main holder + */ + private PamGridPane gridPaneHolder; + ZeroCrossingsBox() { super("Zero Crossings", true); this.getHolderPane().setCenter(createZeroCrossPane()); @@ -1601,6 +1629,7 @@ public class SweepClassifierSetPaneFX extends SettingsPane { p.setLayout(new GridBagLayout()); GridBagConstraints c = new PamGridBagContraints(); + // c.gridx = 0; // addComponent(p, enableBearings, c); // c.gridx += c.gridwidth; @@ -1708,7 +1737,7 @@ public class SweepClassifierSetPaneFX extends SettingsPane { // } // } // else multiChan = true; -// Debug.out.println("Check multi-channel: " + multiChan); +// Debug.out.println("Check multi-channel: " + multiChan); return multiChan; } @@ -1833,12 +1862,19 @@ public class SweepClassifierSetPaneFX extends SettingsPane { } - private boolean showWarning(String string, String string2) { //PamController.getInstance(); PamDialogFX.showWarning(null, string, string2); return false; } + + /** + * Get the click control associated with the classifier. + * @return the click control. + */ + public ClickControl getClickControl() { + return this.sweepClassifier.getClickDetector().getClickControl(); + } /** @@ -1863,4 +1899,4 @@ public class SweepClassifierSetPaneFX extends SettingsPane { private boolean isPaneShowing() { return sweepClassifier.getClassifierPane().getFlipPane().isBackVisible(); } -} +} \ No newline at end of file diff --git a/src/clipgenerator/ClipProcess.java b/src/clipgenerator/ClipProcess.java index e3738243..b61c0a43 100644 --- a/src/clipgenerator/ClipProcess.java +++ b/src/clipgenerator/ClipProcess.java @@ -291,7 +291,7 @@ public class ClipProcess extends SpectrogramMarkProcess { try { rawData = rawDataBlock.getSamples(startSample, numSamples, channelMap); } catch (RawDataUnavailableException e) { - System.out.println(e.getMessage()); + System.out.println("RawDataUnavailableException in ClipProcess.spectrogramNotification :" + e.getMessage()); return false; } if (rawData == null) { diff --git a/src/dbht/DbHtDialog.java b/src/dbht/DbHtDialog.java index ce861737..78fbe704 100644 --- a/src/dbht/DbHtDialog.java +++ b/src/dbht/DbHtDialog.java @@ -199,7 +199,7 @@ public class DbHtDialog extends PamDialog { params.calculateFilterThings(currentSampleRate); } catch (DbHtException e) { - System.out.println(e.getMessage()); + System.out.println("Error in DbHtDialog.updateEverything: " + e.getMessage()); return; } double[] f = params.getFilterFrequencies(currentSampleRate); diff --git a/src/difar/DifarProcess.java b/src/difar/DifarProcess.java index fe1a2886..694c4529 100644 --- a/src/difar/DifarProcess.java +++ b/src/difar/DifarProcess.java @@ -1110,7 +1110,7 @@ public class DifarProcess extends PamProcess { rawData[0] = rawDataAll[0]; // is fine since getSamples was fed a channel map. } } catch (RawDataUnavailableException e) { - System.out.println(e.getMessage()); + System.out.println("Error in DifarProcess.difarTrigger" + e.getMessage()); return; } if (rawData[0] == null) { diff --git a/src/difar/demux/NativeDemux.java b/src/difar/demux/NativeDemux.java index 73a8b9d3..d9edd318 100644 --- a/src/difar/demux/NativeDemux.java +++ b/src/difar/demux/NativeDemux.java @@ -98,7 +98,7 @@ public class NativeDemux extends GreenridgeDemux { return true; } catch (UnsatisfiedLinkError e) { - System.out.println(e.getMessage()); + System.out.println("Error in NativeDemux.loadLibrary" + e.getMessage()); return false; } } diff --git a/src/generalDatabase/DBControl.java b/src/generalDatabase/DBControl.java index 1dc9584a..ed22b885 100644 --- a/src/generalDatabase/DBControl.java +++ b/src/generalDatabase/DBControl.java @@ -412,8 +412,9 @@ PamSettingsSource { } - if (dbParameters.getUseAutoCommit() == false) { +// if (dbParameters.getUseAutoCommit() == false) { JMenuItem commitItem = new JMenuItem("Commit Changes"); + commitItem.setEnabled(dbParameters.getUseAutoCommit() == false); commitItem.setToolTipText("Immediately commit recent changes to the database"); commitItem.addActionListener(new ActionListener() { @Override @@ -422,7 +423,7 @@ PamSettingsSource { } }); menu.add(commitItem); - } +// } if (SMRUEnable.isEnable()) { JMenuItem speedMenu = new JMenuItem("Test database speed"); diff --git a/src/generalDatabase/DBSpeedTest.java b/src/generalDatabase/DBSpeedTest.java index 1f0cecad..d39367c2 100644 --- a/src/generalDatabase/DBSpeedTest.java +++ b/src/generalDatabase/DBSpeedTest.java @@ -190,7 +190,7 @@ public class DBSpeedTest { dropStmt.execute(); } catch (SQLException e) { // e.printStackTrace(); - System.out.println(e.getMessage()); + System.out.println("Error in DBSpeedTest testSpeed2:" + e.getMessage()); } } try { diff --git a/src/generalDatabase/PamTableItem.java b/src/generalDatabase/PamTableItem.java index caaa916a..e73772e8 100644 --- a/src/generalDatabase/PamTableItem.java +++ b/src/generalDatabase/PamTableItem.java @@ -488,6 +488,15 @@ public class PamTableItem implements Cloneable { if (value == null) { return Float.NaN; } + if (value instanceof String) { + try { + double val = Double.valueOf((String) value); + return (float) val; + } + catch (NumberFormatException ex) { + return Float.NaN; + } + } if (value.getClass() == Double.class) { double dVal = (Double) value; return (float) dVal; diff --git a/src/generalDatabase/sqlite/SqliteSystem.java b/src/generalDatabase/sqlite/SqliteSystem.java index 3ba3e90f..22a1bc61 100644 --- a/src/generalDatabase/sqlite/SqliteSystem.java +++ b/src/generalDatabase/sqlite/SqliteSystem.java @@ -279,7 +279,9 @@ public class SqliteSystem extends DBSystem implements PamSettings { { if(connection != null){ // if (USEAUTOCOMMIT == false) { - connection.getConnection().commit(); + if (connection.getConnection().getAutoCommit()) { + connection.getConnection().commit(); + } // } connection.getConnection().close(); } diff --git a/src/gpl/contour/ContourFinder.java b/src/gpl/contour/ContourFinder.java index 7acc7476..ea89b9a4 100644 --- a/src/gpl/contour/ContourFinder.java +++ b/src/gpl/contour/ContourFinder.java @@ -261,7 +261,13 @@ public class ContourFinder { * Note that binData is padded, whiteData isn't. */ GPLContour newContour = new GPLContour(iT-1, iF-1+gplProcess.binLo, whiteData[iT-1][iF-1], energyData[iT-1][iF-1]); - findAdjacentPoints(newContour, iT, iF, binData, whiteData, energyData, con); + try { + findAdjacentPoints(newContour, iT, iF, binData, whiteData, energyData, con); + } + catch (StackOverflowError e) { + System.out.println("Stack overflow in GPLContour.findRegion for bloated contour size " + newContour.getArea()); + System.out.println("The contour is incomplete, but has not been discarded"); + } return newContour; } @@ -282,6 +288,10 @@ public class ContourFinder { * Separate loops to get above and to sides, NOT diagonal matches. * could also easily change to connect 8 instead of connect 4. */ + if (newContour.getArea() >= 500) { + System.out.println("GPL Contour size exceeds maximum value of 500 points so ceasing to grow it"); + return; + } binData[currT][currF] = 0; // set current point to 0 so it doesn't get found again int nX = binData.length-1; int nY = binData[0].length-1; diff --git a/src/group3dlocaliser/algorithm/hyperbolic/HyperbolicLocaliser.java b/src/group3dlocaliser/algorithm/hyperbolic/HyperbolicLocaliser.java index 5a4884cf..dc6e5eb4 100644 --- a/src/group3dlocaliser/algorithm/hyperbolic/HyperbolicLocaliser.java +++ b/src/group3dlocaliser/algorithm/hyperbolic/HyperbolicLocaliser.java @@ -217,7 +217,7 @@ public class HyperbolicLocaliser extends TOADBaseAlgorithm { // answer2 = rightMatrix.times(leftInverse.transpose()); } catch (Exception e) { - System.out.println(e.getMessage()); + System.out.println("Error in HyperbolicLocaliser.processTOADsPlane: " + e.getMessage()); // Matrix m = leftMatrix.transpose(); // m = m.inverse(); return null; @@ -254,7 +254,7 @@ public class HyperbolicLocaliser extends TOADBaseAlgorithm { } catch (Exception e) { - System.out.println(e.getMessage()); + System.out.println("Error2 in HyperbolicLocaliser.processTOADsPlane: " + e.getMessage()); } // now need to rotate back from the plane that we're in to get back to the original position. @@ -736,7 +736,7 @@ public class HyperbolicLocaliser extends TOADBaseAlgorithm { } catch (Exception e) { - System.out.println(e.getMessage()); + System.out.println("Error in HyperbolicLocaliser.processTOADs3D: " + e.getMessage()); } LatLong pos = geometry.getReferenceGPS().addDistanceMeters(centre.getCoordinate(0)+answer.get(0,0), diff --git a/src/group3dlocaliser/algorithm/toadsimplex/ToadSimplexLocaliser.java b/src/group3dlocaliser/algorithm/toadsimplex/ToadSimplexLocaliser.java index e16db196..d362a8ef 100644 --- a/src/group3dlocaliser/algorithm/toadsimplex/ToadSimplexLocaliser.java +++ b/src/group3dlocaliser/algorithm/toadsimplex/ToadSimplexLocaliser.java @@ -146,7 +146,7 @@ public class ToadSimplexLocaliser extends TOADBaseAlgorithm { try { result = optimiser.optimize(chiFunc, goal, start); } catch (OptimizationException | FunctionEvaluationException | IllegalArgumentException e) { - System.out.println(e.getMessage()); + System.out.println("Error in TOADSimplexLocaliser.processTOADs: " + e.getMessage()); nFails++; System.out.printf("%d fails out of %d = %3.2f%%\n", nFails, nCalls, (double) nFails * 100. / nCalls); resultChiData[iStart] = null; diff --git a/src/networkTransfer/emulator/EmulatorStream.java b/src/networkTransfer/emulator/EmulatorStream.java index 088e2d65..a62d19a3 100644 --- a/src/networkTransfer/emulator/EmulatorStream.java +++ b/src/networkTransfer/emulator/EmulatorStream.java @@ -129,7 +129,7 @@ public class EmulatorStream { try { emSocket.getOutputStream().write(data); } catch (IOException e) { - System.out.println(e.getMessage()); + System.out.println("Error in EmulatorStream.sendPamCommand: " + e.getMessage()); } } private boolean openSocket() { @@ -137,9 +137,9 @@ public class EmulatorStream { try { emSocket = new Socket(sktParams.ipAddress, sktParams.portNumber); } catch (UnknownHostException e) { - System.out.println(e.getMessage()); + System.out.println("UnknownHostException in EmulatorStream.sendPamCommand: " + e.getMessage()); } catch (IOException e) { - System.out.println(e.getMessage()); + System.out.println("IOException in EmulatorStream.sendPamCommand: " + e.getMessage()); } if (emSocket != null) { status.socketStatus = emSocket.isConnected(); diff --git a/src/networkTransfer/receive/NetworkReceiver.java b/src/networkTransfer/receive/NetworkReceiver.java index 67d5a5cb..3bb9fc02 100644 --- a/src/networkTransfer/receive/NetworkReceiver.java +++ b/src/networkTransfer/receive/NetworkReceiver.java @@ -458,7 +458,7 @@ public class NetworkReceiver extends PamControlledUnit implements PamSettings, N // checkExistingThreads(clientSocket, rxThread); } } catch (IOException e) { - System.out.println(e.getMessage()); + System.out.println("IOException in NeetworkReceiver" + e.getMessage()); } } diff --git a/src/networkTransfer/send/NetworkObjectPacker.java b/src/networkTransfer/send/NetworkObjectPacker.java index 08b9aa0d..ee3aac88 100644 --- a/src/networkTransfer/send/NetworkObjectPacker.java +++ b/src/networkTransfer/send/NetworkObjectPacker.java @@ -75,7 +75,10 @@ public class NetworkObjectPacker { BinaryDataSource binarySource = dataBlock.getBinaryDataSource(); int dataType2 = dataBlock.getQuickId(); - BinaryObjectData packedObject = binarySource.getPackedData(dataUnit); + BinaryObjectData packedObject = null; + synchronized (BinaryDataSource.packSynchObject) { + packedObject = binarySource.getPackedData(dataUnit); + } byte[] data = packedObject.getData(); int duDataLength = data.length + 12; DataUnitBaseData baseData = dataUnit.getBasicData(); diff --git a/src/networkTransfer/send/NetworkSender.java b/src/networkTransfer/send/NetworkSender.java index a5a3b011..65f2774b 100644 --- a/src/networkTransfer/send/NetworkSender.java +++ b/src/networkTransfer/send/NetworkSender.java @@ -23,10 +23,12 @@ import javax.swing.SwingWorker; import networkTransfer.emulator.NetworkEmulator; import networkTransfer.receive.NetworkReceiver; +import pamguard.GlobalArguments; import org.w3c.dom.Document; import org.w3c.dom.Element; +import Acquisition.FolderInputSystem; import PamController.PamControlledUnit; import PamController.PamControlledUnitSettings; import PamController.PamController; @@ -44,6 +46,11 @@ import PamguardMVC.PamDataBlock; * */ public class NetworkSender extends PamControlledUnit implements PamSettings { + + public static final String ADDRESS = "-netSend.address"; + public static final String PORT = "-netSend.port"; + public static final String ID1 = "-netSend.id1"; + public static final String ID2 = "-netSend.id2"; protected NetworkSendParams networkSendParams = new NetworkSendParams(); private NetworkEmulator networkEmulator; @@ -169,6 +176,28 @@ public class NetworkSender extends PamControlledUnit implements PamSettings { public boolean restoreSettings( PamControlledUnitSettings pamControlledUnitSettings) { networkSendParams = ((NetworkSendParams) pamControlledUnitSettings.getSettings()).clone(); + + String address = GlobalArguments.getParam(ADDRESS); + String portString = GlobalArguments.getParam(PORT); + String id1String = GlobalArguments.getParam(ID1); + String id2String = GlobalArguments.getParam(ID2); + + if (address != null) { + networkSendParams.ipAddress = address; // remember it. + } + + if(portString != null) { + networkSendParams.portNumber = Integer.valueOf(portString); + } + + if(id1String!=null) { + networkSendParams.stationId1 = Integer.valueOf(id1String); + } + + if(id2String!=null) { + networkSendParams.stationId1 = Integer.valueOf(id2String); + } + return (networkSendParams != null); } @@ -452,7 +481,7 @@ public class NetworkSender extends PamControlledUnit implements PamSettings { return true; } catch (IOException e) { // e.printStackTrace(); - System.out.println(e.getMessage()); + System.out.println("IOException in NeetworkSender.writeByteData: " + e.getMessage()); currStatus = "Socket Closed"; return false; } @@ -465,7 +494,7 @@ public class NetworkSender extends PamControlledUnit implements PamSettings { return true; } catch (IOException e) { // e.printStackTrace(); - System.out.println(e.getMessage()); + System.out.println("IOException in NeetworkSender.writeStringData" + e.getMessage()); currStatus = "Socket Closed"; return false; } @@ -513,7 +542,7 @@ public class NetworkSender extends PamControlledUnit implements PamSettings { tcpWriter.close(); } catch (IOException e) { // e.printStackTrace(); - System.out.println(e.getMessage()); + System.out.println("IOException in NeetworkSender.closeconnection" + e.getMessage()); } tcpSocket = null; tcpWriter = null; diff --git a/src/nmeaEmulator/SerialOutput.java b/src/nmeaEmulator/SerialOutput.java index bff19830..4ec93884 100644 --- a/src/nmeaEmulator/SerialOutput.java +++ b/src/nmeaEmulator/SerialOutput.java @@ -68,7 +68,7 @@ public class SerialOutput { SerialPort.NO_PARITY, SerialPort.FLOW_CONTROL_DISABLED); // disable flow control, since this is the RXTX default and it's not specified above } catch (PJSerialException e) { - System.out.println(e.getMessage()); + System.out.println("PJSerialException in SerialOutput: " + e.getMessage()); e.printStackTrace(); return false; } diff --git a/src/offlineProcessing/DataCopyTask.java b/src/offlineProcessing/DataCopyTask.java index 40071cdf..c67a00c9 100644 --- a/src/offlineProcessing/DataCopyTask.java +++ b/src/offlineProcessing/DataCopyTask.java @@ -21,8 +21,6 @@ import dataMap.OfflineDataMapPoint; * @param */ public class DataCopyTask extends OfflineTask { - - private PamDataBlock pamDataBlock; private SQLLogging sqlLogging; @@ -40,7 +38,6 @@ public class DataCopyTask extends OfflineTask { */ public DataCopyTask(PamDataBlock pamDataBlock) { super(pamDataBlock); - this.pamDataBlock = pamDataBlock; this.sqlLogging = pamDataBlock.getLogging(); this.binaryDataSource = pamDataBlock.getBinaryDataSource(); setParentDataBlock(pamDataBlock); @@ -77,7 +74,7 @@ public class DataCopyTask extends OfflineTask { @Override public String getName() { - return "Copy " + pamDataBlock.getDataName() + " To database"; + return "Copy " + getDataBlock().getDataName() + " To database"; } @Override diff --git a/src/offlineProcessing/OfflineTask.java b/src/offlineProcessing/OfflineTask.java index a1dc9e15..7f3e0ec1 100644 --- a/src/offlineProcessing/OfflineTask.java +++ b/src/offlineProcessing/OfflineTask.java @@ -458,5 +458,4 @@ public abstract class OfflineTask { } - } diff --git a/src/pamViewFX/fxNodes/pamAxis/PamAxisPane2.java b/src/pamViewFX/fxNodes/pamAxis/PamAxisPane2.java index 905109bc..1a84a220 100644 --- a/src/pamViewFX/fxNodes/pamAxis/PamAxisPane2.java +++ b/src/pamViewFX/fxNodes/pamAxis/PamAxisPane2.java @@ -250,7 +250,7 @@ public class PamAxisPane2 extends StackPane { // } } catch (Exception e) { - System.out.println(e.getMessage()); + System.out.println("Exception in PamAxisPanel2.ScaledNumberFormatter: " + e.getMessage()); e.printStackTrace(); return "Err"; } diff --git a/src/pamViewFX/fxNodes/utilityPanes/GroupedSourcePaneFX.java b/src/pamViewFX/fxNodes/utilityPanes/GroupedSourcePaneFX.java index c2fe9295..43a9338c 100644 --- a/src/pamViewFX/fxNodes/utilityPanes/GroupedSourcePaneFX.java +++ b/src/pamViewFX/fxNodes/utilityPanes/GroupedSourcePaneFX.java @@ -109,7 +109,7 @@ public class GroupedSourcePaneFX extends SourcePaneFX { channelPanel.setSpacing(5); Label channelLabel = new Label("Channels"); -// channelLabel.setFont(PamGuiManagerFXAWT.titleFontSize2); + PamGuiManagerFX.titleFont2style(channelLabel); sourcePane.add(channelLabel,0,2); //create radio buttons to allow user to quickly select type of grouping. diff --git a/src/pamViewFX/fxNodes/utilityPanes/SimpleFilterPaneFX.java b/src/pamViewFX/fxNodes/utilityPanes/SimpleFilterPaneFX.java index fd7e288f..efb71e85 100644 --- a/src/pamViewFX/fxNodes/utilityPanes/SimpleFilterPaneFX.java +++ b/src/pamViewFX/fxNodes/utilityPanes/SimpleFilterPaneFX.java @@ -238,11 +238,13 @@ public class SimpleFilterPaneFX extends DynamicSettingsPane{ * @param disable - true to disable the pane */ public void setDisableFilterPane(boolean disable){ - highPass.setDisable(disable); - lowPass.setDisable(disable); - bandPass.setDisable(disable); - bandStop.setDisable(disable); - freqPane.setDisableFreqPane(disable); + mainPane.setDisable(disable); + +// highPass.setDisable(disable); +// lowPass.setDisable(disable); +// bandPass.setDisable(disable); +// bandStop.setDisable(disable); +// freqPane.setDisableFreqPane(disable); } public double getSampleRate() { diff --git a/src/pamguard/Pamguard.java b/src/pamguard/Pamguard.java index 79069e9d..a80c16cc 100644 --- a/src/pamguard/Pamguard.java +++ b/src/pamguard/Pamguard.java @@ -43,6 +43,7 @@ import PamguardMVC.debug.Debug; import binaryFileStorage.BinaryStore; import dataPlotsFX.JamieDev; import generalDatabase.DBControl; +import networkTransfer.send.NetworkSender; import rocca.RoccaDev; import java.io.BufferedReader; @@ -122,6 +123,7 @@ public class Pamguard { int runMode = PamController.RUN_NORMAL; String InputPsf = "NULL"; + // set up the system to output to both a log file and the console window. Also @@ -137,6 +139,14 @@ public class Pamguard { // TimeZone.setDefault(PamCalendar.defaultTimeZone); System.out.println("**********************************************************"); + // print out the entire command line + if (args != null && args.length > 0) { + System.out.printf("Command line options: "); + for (int i = 0; i < args.length; i++) { + System.out.printf("\"%s\" ", args[i]); + } + System.out.printf("\n"); + } try { // get the java runnable file name. // http://stackoverflow.com/questions/4294522/jar-file-name-form-java-code @@ -210,22 +220,25 @@ public class Pamguard { } else if (anArg.equalsIgnoreCase("-nogui")) { PamGUIManager.setType(PamGUIManager.NOGUI); + System.out.println("no gui operation."); } - /////////////// - else if (anArg.equalsIgnoreCase("-psf")) { + else if (anArg.equalsIgnoreCase("-psf") || anArg.equalsIgnoreCase("-psfx")) { String autoPsf = args[iArg++]; PamSettingManager.remote_psf = autoPsf; System.out.println("Running using settings from " + autoPsf); } else if (anArg.equalsIgnoreCase("-port")) { // port id to open a udp port to receive commands - pamBuoyGlobals.setNetworkControlPort(Integer.parseInt(args[iArg++])); + String port = args[iArg++]; + pamBuoyGlobals.setNetworkControlPort(Integer.parseInt(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) String mAddr = args[iArg++]; int mPort = Integer.parseInt(args[iArg++]); pamBuoyGlobals.setMultiportConfig(mAddr, mPort); + System.out.printf("Setting multicast control addr %s port %d\n", mAddr, mPort); } else if (anArg.equalsIgnoreCase("-nolog")) { System.out.println("Disabling log file from command line switch..."); @@ -233,23 +246,47 @@ public class Pamguard { } else if (anArg.equalsIgnoreCase(BinaryStore.GlobalFolderArg)) { // output folder for binary files. - GlobalArguments.setParam(BinaryStore.GlobalFolderArg, args[iArg++]); + String binFolder = args[iArg++]; + GlobalArguments.setParam(BinaryStore.GlobalFolderArg, binFolder); + System.out.println("Setting output folder for binary files to " + binFolder); } else if (anArg.equalsIgnoreCase(DBControl.GlobalDatabaseNameArg)) { // database file name - GlobalArguments.setParam(DBControl.GlobalDatabaseNameArg, args[iArg++]); + String dbName = args[iArg++]; + GlobalArguments.setParam(DBControl.GlobalDatabaseNameArg, dbName); + System.out.println("Setting output database file to " + dbName); } else if (anArg.equalsIgnoreCase(FolderInputSystem.GlobalWavFolderArg)) { // source folder for wav files (or other supported sound files) - GlobalArguments.setParam(FolderInputSystem.GlobalWavFolderArg, args[iArg++]); + String wavFolder = args[iArg++]; + GlobalArguments.setParam(FolderInputSystem.GlobalWavFolderArg, wavFolder); + System.out.println("Setting input wav file folder to " + wavFolder); } else if (anArg.equalsIgnoreCase(PamController.AUTOSTART)) { // auto start processing. GlobalArguments.setParam(PamController.AUTOSTART, PamController.AUTOSTART); + System.out.println("Setting autostart ON"); } else if (anArg.equalsIgnoreCase(PamController.AUTOEXIT)) { // auto exit at end of processing. GlobalArguments.setParam(PamController.AUTOEXIT, PamController.AUTOEXIT); + System.out.println("Setting autoexit ON"); + } + else if (anArg.equalsIgnoreCase(NetworkSender.ADDRESS)) { + // auto exit at end of processing. + GlobalArguments.setParam(NetworkSender.ADDRESS, args[iArg++]); + } + else if (anArg.equalsIgnoreCase(NetworkSender.ID1)) { + // auto exit at end of processing. + GlobalArguments.setParam(NetworkSender.ID1, args[iArg++]); + } + else if (anArg.equalsIgnoreCase(NetworkSender.ID2)) { + // auto exit at end of processing. + GlobalArguments.setParam(NetworkSender.ID2, args[iArg++]); + } + else if (anArg.equalsIgnoreCase(NetworkSender.PORT)) { + // auto exit at end of processing. + GlobalArguments.setParam(NetworkSender.PORT, args[iArg++]); } else if (anArg.equalsIgnoreCase(ReprocessStoreChoice.paramName)) { String arg = args[iArg++]; diff --git a/src/rawDeepLearningClassifier/dataPlotFX/DLPredictionPlotInfoFX.java b/src/rawDeepLearningClassifier/dataPlotFX/DLPredictionPlotInfoFX.java index aa1f5739..945561b5 100644 --- a/src/rawDeepLearningClassifier/dataPlotFX/DLPredictionPlotInfoFX.java +++ b/src/rawDeepLearningClassifier/dataPlotFX/DLPredictionPlotInfoFX.java @@ -317,10 +317,12 @@ public class DLPredictionPlotInfoFX extends GenericLinePlotInfo { @Override public double[][] getDetData(PamDataUnit pamDataUnit) { - double[] data = PamArrayUtils.float2Double(((DLDataUnit) pamDataUnit).getPredicitionResult().getPrediction()); + double[] data = PamArrayUtils.float2Double(((DLDataUnit) pamDataUnit).getPredicitionResult().getPrediction()); + double[][] dataD = new double[data.length][]; for (int i=0; i transforms = getDLTransforms(); - WaveTransform waveTransForm ; - FreqTransform freqTranform ; +// ArrayList transforms = getDLTransforms(); +// WaveTransform waveTransForm ; +// FreqTransform freqTranform ; - //extra things that may need changed... - for (DLTransform dlTransfrom: transforms) { - switch (dlTransfrom.getDLTransformType()) { - case DECIMATE: - waveTransForm = ((WaveTransform) dlTransfrom); - - //change if the example sample rate is higher to if there is a large differenc in sample rates and decimation. - if (exampleSound.getSampleRate()4) { - waveTransForm.setParams(new Number[] {exampleSound.getSampleRate()}); //set the correct samplerate - dlTransformPane.getDLTransformPanes().get(transforms.indexOf(dlTransfrom)).setParams(waveTransForm); - } - break; - case PREEMPHSIS: - waveTransForm = ((WaveTransform) dlTransfrom); - if (exampleSound.getSampleRate()<10000 && waveTransForm.getParams()[0].doubleValue()>0.1) { - waveTransForm.setParams(new Number[] {0.1}); //set the correct samplerate - dlTransformPane.getDLTransformPanes().get(transforms.indexOf(dlTransfrom)).setParams(waveTransForm); - } - break; - case SPEC2DB: - break; - case SPECCLAMP: - break; - case SPECCROPINTERP: - - freqTranform = ((FreqTransform) dlTransfrom); - Number[] params = freqTranform.getParams(); - - double highestFreq = exampleSound.getSampleRate()/2; //nyquist - - if (params[0].doubleValue()>=highestFreq) params[0]=0.0; - - //this will break stuff if interp frequency is greater than nyquist - if (params[1].doubleValue()>highestFreq) { -// System.out.println("----HERE 1----"); - params[1]=highestFreq; //nyquist - } - //if we switch to a high frequency want to the interp not to just select the lowest band - -// else if (params[1].doubleValue()4) { +// waveTransForm.setParams(new Number[] {exampleSound.getSampleRate()}); //set the correct samplerate +// dlTransformPane.getDLTransformPanes().get(transforms.indexOf(dlTransfrom)).setParams(waveTransForm); +// } +// break; +// case PREEMPHSIS: +// waveTransForm = ((WaveTransform) dlTransfrom); +// if (exampleSound.getSampleRate()<10000 && waveTransForm.getParams()[0].doubleValue()>0.1) { +// waveTransForm.setParams(new Number[] {0.1}); //set the correct samplerate +// dlTransformPane.getDLTransformPanes().get(transforms.indexOf(dlTransfrom)).setParams(waveTransForm); +// } +// break; +// case SPEC2DB: +// break; +// case SPECCLAMP: +// break; +// case SPECCROPINTERP: +// +// freqTranform = ((FreqTransform) dlTransfrom); +// Number[] params = freqTranform.getParams(); +// +// double highestFreq = exampleSound.getSampleRate()/2; //nyquist +// +// if (params[0].doubleValue()>=highestFreq) params[0]=0.0; +// +// //this will break stuff if interp frequency is greater than nyquist +// if (params[1].doubleValue()>highestFreq) { +//// System.out.println("----HERE 1----"); // params[1]=highestFreq; //nyquist // } - - //System.out.println("Interp params: " + params[0] + " " + params[1] + " " + params[2]); - freqTranform.setParams(params); - - dlTransformPane.getDLTransformPanes().get(transforms.indexOf(dlTransfrom)).setParams(freqTranform); - - break; - case SPECNORMALISE: - break; - case SPECNORMALISEROWSUM: - break; - case SPECTROGRAM: - break; - case TRIM: - break; - default: - break; - - } - } +// //if we switch to a high frequency want to the interp not to just select the lowest band +// +//// else if (params[1].doubleValue()