From ff048eed9fe86e14ef39351ba2b8001874f20919 Mon Sep 17 00:00:00 2001 From: Douglas Gillespie <50671166+douggillespie@users.noreply.github.com> Date: Sun, 27 Feb 2022 14:06:26 +0000 Subject: [PATCH] Fixes to NoGUI, Network send and spectrogram graphics. (#23) * Update .project * Terminal commands * Fix network sender since it was hopelessly out of date and did not send data in the correct format. OK now, though only tested on NARW. * Fix NoGui operatoin and Network sender --- .project | 2 +- src/PamController/PamController.java | 11 +- src/PamController/PamGUIManager.java | 3 +- src/PamController/command/CommandManager.java | 118 +++++++++++++++ src/PamController/command/ExitCommand.java | 6 +- src/PamController/command/ExtCommand.java | 8 +- src/PamController/command/HelpCommand.java | 42 ++++++ src/PamController/command/KillCommand.java | 5 + .../command/NetworkController.java | 88 +---------- src/PamController/command/PingCommand.java | 4 + src/PamController/command/StartCommand.java | 5 + src/PamController/command/StatusCommand.java | 5 + src/PamController/command/StopCommand.java | 4 + src/PamController/command/SummaryCommand.java | 12 +- .../command/TerminalController.java | 69 +++++++++ src/PamView/NullGuiController.java | 140 ++++++++++++++++++ src/PamView/PamDetectionOverlayGraphics.java | 10 +- .../RWEOverlayGraphics.java | 12 ++ .../receive/NetworkReceiver.java | 6 +- .../send/NetworkObjectPacker.java | 18 ++- src/pamguard/Pamguard.java | 5 +- 21 files changed, 469 insertions(+), 104 deletions(-) create mode 100644 src/PamController/command/CommandManager.java create mode 100644 src/PamController/command/HelpCommand.java create mode 100644 src/PamController/command/TerminalController.java create mode 100644 src/PamView/NullGuiController.java diff --git a/.project b/.project index 97130237..b03f57d2 100644 --- a/.project +++ b/.project @@ -1,6 +1,6 @@ - PamGuard Main + PamGuard SMRUConsulting diff --git a/src/PamController/PamController.java b/src/PamController/PamController.java index e0e7549c..1a4e48bb 100644 --- a/src/PamController/PamController.java +++ b/src/PamController/PamController.java @@ -54,6 +54,7 @@ import generalDatabase.DBControlUnit; import javafx.stage.Stage; import Array.ArrayManager; import PamController.command.NetworkController; +import PamController.command.TerminalController; import PamController.command.WatchdogComms; import PamController.masterReference.MasterReferencePoint; import PamController.settings.output.xml.PamguardXMLWriter; @@ -269,6 +270,11 @@ public class PamController implements PamControllerInterface, PamSettings { setupPamguard(); setupGarbageCollector(); + + +// if (PamGUIManager.getGUIType() == PamGUIManager.NOGUI) { +// } + // diagnosticTimer = new Timer(1000, new DiagnosticTimer()); // diagnosticTimer.start(); } @@ -293,7 +299,10 @@ public class PamController implements PamControllerInterface, PamSettings { */ public static void create(int runMode) { if (uniqueController == null) { - new PamController(runMode, null); + PamController pamcontroller = new PamController(runMode, null); + // I don't see any reason not have have this running with the GUI. + TerminalController tc = new TerminalController(pamcontroller); + tc.getTerminalCommands(); } } diff --git a/src/PamController/PamGUIManager.java b/src/PamController/PamGUIManager.java index e3fd7409..8c122328 100644 --- a/src/PamController/PamGUIManager.java +++ b/src/PamController/PamGUIManager.java @@ -1,6 +1,7 @@ package PamController; import PamView.GuiFrameManager; +import PamView.NullGuiController; import pamViewFX.PamGuiManagerFX; /** @@ -39,7 +40,7 @@ public class PamGUIManager { public static PAMControllerGUI createGUI(PamController pamController, Object object) { switch (guiType) { case NOGUI: - return null; + return new NullGuiController(pamController); case SWING: return new GuiFrameManager(pamController); case FX: diff --git a/src/PamController/command/CommandManager.java b/src/PamController/command/CommandManager.java new file mode 100644 index 00000000..0d7bb6b5 --- /dev/null +++ b/src/PamController/command/CommandManager.java @@ -0,0 +1,118 @@ +package PamController.command; + +import java.util.ArrayList; + +import PamController.PamControlledUnit; +import PamController.PamController; + +/** + * Interpret commands which may have come either from a terminal or from a Network + * (e.g. UDP) interface. + * @author dg50 + * + */ +public abstract class CommandManager extends PamControlledUnit { + + private PamController pamController; + + private static String unitType = "Command Manager"; + + private ArrayList commandsList = new ArrayList(); + + public CommandManager(PamController pamController, String unitName) { + super(unitType, unitName); + this.pamController = pamController; + + commandsList.add(new StartCommand()); + commandsList.add(new StopCommand()); + commandsList.add(new PingCommand()); + commandsList.add(new StatusCommand()); + commandsList.add(new SummaryCommand()); + commandsList.add(new ExitCommand()); + commandsList.add(new KillCommand()); + commandsList.add(new HelpCommand(this)); + + } + + protected ArrayList getCommandsList() { + return commandsList; + } + + public ExtCommand findCommand(String command) { + for (ExtCommand aCommand:commandsList) { + if (aCommand.getName().equals(command)) { + return aCommand; + } + } + return null; + } + + /** + * Interpret and act on a udp command string. + * @param command command string + * @return false if the command was to exit + * the program (in which case this thread will + * exit and close the port). True otherwise. + */ + public boolean interpretCommand(String command) { + //System.out.println(String.format("New UDP Command %s", command)); + + command = command.toLowerCase(); + // strip of the first two letters if they begin pg ... + if (command.substring(0,2).equals("pg")) { + command = command.substring(2); + } + ExtCommand extCommand = findCommand(command); + if (extCommand == null) { + sendData("Cmd \"" + command + "\" Not Recognised."); + return false; + } + if (extCommand.canExecute() == false) { + sendData("Cmd \"" + command + "\" Cannot Execute."); + sendData(" Cmd return string = " + extCommand.getReturnString()); + return false; + } + extCommand.execute(); + sendData(extCommand.getReturnString()); + +// +// if (command.equals("pgstart")) { +// sendData("PgAck " + "pgstart"); +// pamController.pamStart(); +// } +// else if (command.equals("pgstop")) { +// sendData("PgAck " + "pgstop"); +// pamController.pamStop(); +// } +// else if (command.equals("pgping")) { +// sendData("PgAck " + "pgping"); +// } +// else if (command.equals("pgstatus")) { +// sendData("PgAck Status " + pamController.getPamStatus()); +// } +// else if (command.equals("pgsetrec")) { +// sendData("PgAck pgsetrec"); +// +// //triggerRecording(String name, int seconds); +// } +// else if (command.equals("pgexit")) { +// sendData("Exiting PAMGUARD"); +// System.exit(0); +// return false; +// } +// else{ +// sendData("PgAck " + "Cmd Not Recognised."); +// } + + + return true; + } + + /** + * Reply to data called from InterpredData + * @param dataString + * @return true if replay successful + */ + abstract public boolean sendData(String dataString); + +} diff --git a/src/PamController/command/ExitCommand.java b/src/PamController/command/ExitCommand.java index 11e66537..b0ea0d8a 100644 --- a/src/PamController/command/ExitCommand.java +++ b/src/PamController/command/ExitCommand.java @@ -21,7 +21,11 @@ public class ExitCommand extends ExtCommand { System.exit(0); return true; } - + + @Override + public String getHint() { + return "Exit PAMGuard, stopping detectors prior to exiting"; + } } diff --git a/src/PamController/command/ExtCommand.java b/src/PamController/command/ExtCommand.java index 669da3ad..cf131cf6 100644 --- a/src/PamController/command/ExtCommand.java +++ b/src/PamController/command/ExtCommand.java @@ -107,5 +107,11 @@ public abstract class ExtCommand { this.immediate = immediate; } - + /** + * Get a hint text for the help command. + * @return hint text. + */ + public String getHint() { + return null; + }; } diff --git a/src/PamController/command/HelpCommand.java b/src/PamController/command/HelpCommand.java new file mode 100644 index 00000000..d307bf3c --- /dev/null +++ b/src/PamController/command/HelpCommand.java @@ -0,0 +1,42 @@ +package PamController.command; + +import java.util.ArrayList; + +public class HelpCommand extends ExtCommand { + + private CommandManager commandManager; + + public HelpCommand(CommandManager commandManager) { + super("help", true); + this.commandManager = commandManager; + } + + @Override + public boolean execute() { + ArrayList commands = commandManager.getCommandsList(); + String out = "Available commands are:\n"; + for (ExtCommand command : commands) { + out += command.getName(); + String hint = command.getHint(); + if (hint != null) { + out += String.format(": %s\n", hint); + } + else { + out += "\n"; + } + } + commandManager.sendData(out); + return true; + } + + @Override + public String getReturnString() { + return super.getReturnString(); + } + + @Override + public String getHint() { + return "Get a list of available commands"; + } + +} diff --git a/src/PamController/command/KillCommand.java b/src/PamController/command/KillCommand.java index 460b19ba..fa7dd466 100644 --- a/src/PamController/command/KillCommand.java +++ b/src/PamController/command/KillCommand.java @@ -17,5 +17,10 @@ public class KillCommand extends ExtCommand { System.exit(0); return true; } + + @Override + public String getHint() { + return "kill PAMguard, don't necessarily stop detectors or clean anything up"; + } } diff --git a/src/PamController/command/NetworkController.java b/src/PamController/command/NetworkController.java index c06abb76..d384d26a 100644 --- a/src/PamController/command/NetworkController.java +++ b/src/PamController/command/NetworkController.java @@ -25,7 +25,7 @@ import SoundRecorder.trigger.RecorderTriggerData; * @author Doug Gillespie * */ -public class NetworkController extends PamControlledUnit { +public class NetworkController extends CommandManager { private PamController pamController; @@ -44,22 +44,12 @@ public class NetworkController extends PamControlledUnit { private NetworkRecorderTrigger[] recorderTriggers; - private static String unitType = "Network Controller"; - - private ArrayList networkCommands = new ArrayList(); + private static String unitName = "Network Controller"; public NetworkController(PamController pamController) { - super(unitType, unitType); + super(pamController, unitName); this.pamController = pamController; - networkCommands.add(new StartCommand()); - networkCommands.add(new StopCommand()); - networkCommands.add(new PingCommand()); - networkCommands.add(new StatusCommand()); - networkCommands.add(new SummaryCommand()); - networkCommands.add(new ExitCommand()); - networkCommands.add(new KillCommand()); - listenerThread = new ListenerThread(); Thread aThread = new Thread(listenerThread); aThread.start(); @@ -130,77 +120,8 @@ public class NetworkController extends PamControlledUnit { } } - /** - * Interpret and act on a udp command string. - * @param command command string - * @return false if the command was to exit - * the program (in which case this thread will - * exit and close the port). True otherwise. - */ - private boolean interpretCommand(String command) { - //System.out.println(String.format("New UDP Command %s", command)); - - command = command.toLowerCase(); - // strip of the first two letters if they begin pg ... - if (command.substring(0,2).equals("pg")) { - command = command.substring(2); - } - ExtCommand extCommand = findCommand(command); - if (extCommand == null) { - sendData("Cmd \"" + command + "\" Not Recognised."); - return false; - } - if (extCommand.canExecute() == false) { - sendData("Cmd \"" + command + "\" Cannot Execute."); - sendData(" Cmd return string = " + extCommand.getReturnString()); - return false; - } - extCommand.execute(); - sendData(extCommand.getReturnString()); - -// -// if (command.equals("pgstart")) { -// sendData("PgAck " + "pgstart"); -// pamController.pamStart(); -// } -// else if (command.equals("pgstop")) { -// sendData("PgAck " + "pgstop"); -// pamController.pamStop(); -// } -// else if (command.equals("pgping")) { -// sendData("PgAck " + "pgping"); -// } -// else if (command.equals("pgstatus")) { -// sendData("PgAck Status " + pamController.getPamStatus()); -// } -// else if (command.equals("pgsetrec")) { -// sendData("PgAck pgsetrec"); -// -// //triggerRecording(String name, int seconds); -// } -// else if (command.equals("pgexit")) { -// sendData("Exiting PAMGUARD"); -// System.exit(0); -// return false; -// } -// else{ -// sendData("PgAck " + "Cmd Not Recognised."); -// } - - - return true; - } - private ExtCommand findCommand(String command) { - for (ExtCommand aCommand:networkCommands) { - if (aCommand.getName().equals(command)) { - return aCommand; - } - } - return null; - } - - private boolean sendData(String dataString) { + public boolean sendData(String dataString) { DatagramPacket packet = new DatagramPacket(dataString.getBytes(), dataString.length()); packet.setAddress(udpPacket.getAddress()); packet.setPort(udpPacket.getPort()); @@ -229,6 +150,7 @@ public class NetworkController extends PamControlledUnit { return new String(udpPacket.getData(), 0, udpPacket.getLength()); } + @Override public void notifyModelChanged(int changeType) { switch (changeType){ case PamControllerInterface.INITIALIZATION_COMPLETE: diff --git a/src/PamController/command/PingCommand.java b/src/PamController/command/PingCommand.java index 0d5c43ac..54c26955 100644 --- a/src/PamController/command/PingCommand.java +++ b/src/PamController/command/PingCommand.java @@ -13,4 +13,8 @@ public class PingCommand extends ExtCommand { return true; } + @Override + public String getHint() { + return "ping PAMGuard to see if it's alive"; + } } diff --git a/src/PamController/command/StartCommand.java b/src/PamController/command/StartCommand.java index 08e445fd..f3498614 100644 --- a/src/PamController/command/StartCommand.java +++ b/src/PamController/command/StartCommand.java @@ -35,4 +35,9 @@ public class StartCommand extends ExtCommand { return returnString; } + @Override + public String getHint() { + return "Start PAMGuard processing"; + } + } diff --git a/src/PamController/command/StatusCommand.java b/src/PamController/command/StatusCommand.java index d451ba0d..b71342b2 100644 --- a/src/PamController/command/StatusCommand.java +++ b/src/PamController/command/StatusCommand.java @@ -61,4 +61,9 @@ public class StatusCommand extends ExtCommand { return watchdogComms.getModifiedWatchdogState(status); } + + @Override + public String getHint() { + return "Get the current PAMGuard status. 0=idle, 1=running"; + } } diff --git a/src/PamController/command/StopCommand.java b/src/PamController/command/StopCommand.java index d50ac21f..684657d3 100644 --- a/src/PamController/command/StopCommand.java +++ b/src/PamController/command/StopCommand.java @@ -15,4 +15,8 @@ public class StopCommand extends ExtCommand { } + @Override + public String getHint() { + return "Stop PAMGuard processing"; + } } diff --git a/src/PamController/command/SummaryCommand.java b/src/PamController/command/SummaryCommand.java index d45aaf42..809ea03c 100644 --- a/src/PamController/command/SummaryCommand.java +++ b/src/PamController/command/SummaryCommand.java @@ -35,7 +35,7 @@ public class SummaryCommand extends ExtCommand { lastCallTime = PamCalendar.getSessionStartTime(); } long nowTime = PamCalendar.getTimeInMillis(); - totalString = PamCalendar.formatDateTime(lastCallTime) + "-" + PamCalendar.formatDateTime(nowTime); + totalString = PamCalendar.formatDBDateTime(lastCallTime) + "-" + PamCalendar.formatDBDateTime(nowTime); int usedModules = 0; for (int i = 0; i < nMod; i++) { aModule = pamController.getControlledUnit(i); @@ -44,16 +44,14 @@ public class SummaryCommand extends ExtCommand { continue; } usedModules ++; - /* - strcat(moduleSummaryText, "\n"); - strcat(moduleSummaryText, module->getModuleName()); - strcat(moduleSummaryText, ":"); - strcat(moduleSummaryText, moduleText); - */ totalString += String.format("\n<%s>%s:%s<\\%s>", aModule.getShortUnitType(), aModule.getUnitName(), aString, aModule.getShortUnitType()); } return totalString; } + @Override + public String getHint() { + return "Get summary information about each running process"; + } } diff --git a/src/PamController/command/TerminalController.java b/src/PamController/command/TerminalController.java new file mode 100644 index 00000000..e8589cd2 --- /dev/null +++ b/src/PamController/command/TerminalController.java @@ -0,0 +1,69 @@ +package PamController.command; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +import PamController.PamController; + +public class TerminalController extends CommandManager { + + private BufferedReader reader; + + private static String unitName = "Terminal Controller"; + + public TerminalController(PamController pamController) { + super(pamController, unitName); + } + + @Override + public boolean sendData(String dataString) { + System.out.println(dataString); + return true; + } + + @Override + public void pamClose() { + super.pamClose(); + try { + reader.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public void getTerminalCommands() { + Thread t = new Thread(new TerminalTread()); + t.start(); + } + + private class TerminalTread implements Runnable { + + @Override + public void run() { + readCommands(); + } + + } + + private void readCommands() { + + reader = new BufferedReader( + new InputStreamReader(System.in)); + try { + while (true) { + String command = reader.readLine(); + if (command != null && command.length() > 0) { + interpretCommand(command); + } +// System.out.println("you typed: " + inLine); +// if (inLine.contains("exit")) { +// break; +// } + } + } catch (IOException e) { + e.printStackTrace(); + } + System.out.println("Exiting PAMGuard, leave control thread"); + } +} diff --git a/src/PamView/NullGuiController.java b/src/PamView/NullGuiController.java new file mode 100644 index 00000000..6c1ad3d1 --- /dev/null +++ b/src/PamView/NullGuiController.java @@ -0,0 +1,140 @@ +package PamView; + +import javax.swing.JFrame; + +import PamController.PAMControllerGUI; +import PamController.PamControlledUnit; +import PamController.PamController; +import PamController.PamSettings; +import PamModel.PamModel; +import PamModel.PamModuleInfo; +import pamViewFX.pamTask.PamTaskUpdate; + +/** + * Null GUI controller which will get used with the -nogui options. + * @author dg50 + * + */ +public class NullGuiController implements PAMControllerGUI { + + private PamController pamController; + + public NullGuiController(PamController pamController) { + this.pamController = pamController; + } + + @Override + public void pamStarted() { + // TODO Auto-generated method stub + + } + + @Override + public void pamEnded() { + // TODO Auto-generated method stub + + } + + @Override + public void modelChanged(int changeType) { + // TODO Auto-generated method stub + + } + + @Override + public void addControlledUnit(PamControlledUnit controlledUnit) { + // TODO Auto-generated method stub + + } + + @Override + public void showControlledUnit(PamControlledUnit unit) { + // TODO Auto-generated method stub + + } + + @Override + public void removeControlledUnit(PamControlledUnit controlledUnit) { + // TODO Auto-generated method stub + + } + + @Override + public void setTitle(String title) { + // TODO Auto-generated method stub + + } + + @Override + public int getFrameNumber() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public JFrame getGuiFrame() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void enableGUIControl(boolean enable) { + // TODO Auto-generated method stub + + } + + @Override + public void addView(PamViewInterface newView) { + // TODO Auto-generated method stub + + } + + @Override + public void destroyModel() { + // TODO Auto-generated method stub + + } + + @Override + public void notifyModelChanged(int changeType) { + // TODO Auto-generated method stub + + } + + @Override + public void notifyLoadProgress(PamTaskUpdate progress) { + // TODO Auto-generated method stub + + } + + @Override + public PamSettings getInitialSettings() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void init() { + // TODO Auto-generated method stub + + } + + @Override + public PamViewInterface initPrimaryView(PamController pamController, PamModel pamModelInterface) { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean hasCallBack() { + // TODO Auto-generated method stub + return false; + } + + @Override + public String getModuleName(Object parentFrame, PamModuleInfo moduleInfo) { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/PamView/PamDetectionOverlayGraphics.java b/src/PamView/PamDetectionOverlayGraphics.java index 769cdb6a..81b86197 100644 --- a/src/PamView/PamDetectionOverlayGraphics.java +++ b/src/PamView/PamDetectionOverlayGraphics.java @@ -700,8 +700,11 @@ public class PamDetectionOverlayGraphics extends PanelOverlayDraw { pamDetection.getSampleDuration() * 1000./parentDataBlock.getSampleRate(), frequency[0], 0); + boolean isWrapped = false; if (botRight.x < topLeft.x){ - botRight.x = g.getClipBounds().width; + // this means it's wrapped. + isWrapped = true; + botRight.x += g.getClipBounds().width; } if (generalProjector.isViewer()) { Coordinate3d middle = new Coordinate3d(); @@ -723,8 +726,13 @@ public class PamDetectionOverlayGraphics extends PanelOverlayDraw { // Not actually drawing on a spectrogramProjector, so don't have any info on the background color } + if (isWrapped) { + g.drawRect((int) topLeft.x-g.getClipBounds().width, (int) topLeft.y, + (int) botRight.x - (int) topLeft.x, (int) botRight.y - (int) topLeft.y); + } g.drawRect((int) topLeft.x, (int) topLeft.y, (int) botRight.x - (int) topLeft.x, (int) botRight.y - (int) topLeft.y); + return new Rectangle((int) topLeft.x, (int) topLeft.y, (int) botRight.x - (int) topLeft.x, (int) botRight.y - (int) topLeft.y); } diff --git a/src/RightWhaleEdgeDetector/RWEOverlayGraphics.java b/src/RightWhaleEdgeDetector/RWEOverlayGraphics.java index 1cc55684..f090f681 100644 --- a/src/RightWhaleEdgeDetector/RWEOverlayGraphics.java +++ b/src/RightWhaleEdgeDetector/RWEOverlayGraphics.java @@ -65,12 +65,17 @@ public class RWEOverlayGraphics extends PamDetectionOverlayGraphics { int[] polyY = new int[pf.length]; int[] edgeX = new int[pf.length*2]; int[] edgeY = new int[pf.length*2]; + boolean isWrapped = false; for (int i = 0, j = pf.length*2-1; i < pf.length; i++, j--) { double t = t0 + (double) tbin[i] * ffthop / fs * 1000.; double f = pf[i] * fs/fftLen; Point2D pos = generalProjector.getCoord3d(t, f, 0).getPoint2D(); polyX[i] = (int) pos.getX(); polyY[i] = (int) pos.getY(); + if (polyX[i] < polyX[0]) { + isWrapped = true; + polyX[i] += g.getClipBounds().width; + } edgeX[i] = edgeX[j] = polyX[i]; Point2D pe = generalProjector.getCoord3d(t, highF[i]*fs/fftLen, 0).getPoint2D(); edgeY[i] = (int) pe.getY(); @@ -87,6 +92,13 @@ public class RWEOverlayGraphics extends PamDetectionOverlayGraphics { } // g.drawPolyline(polyX, polyY, polyX.length); g.drawPolygon(edgeX, edgeY, edgeX.length); + if (isWrapped) { + int dx = g.getClipBounds().width; + for (int i = 0; i < edgeX.length; i++) { + edgeX[i] -= dx; + } + g.drawPolygon(edgeX, edgeY, edgeX.length); + } return r; } diff --git a/src/networkTransfer/receive/NetworkReceiver.java b/src/networkTransfer/receive/NetworkReceiver.java index a1252149..212b020c 100644 --- a/src/networkTransfer/receive/NetworkReceiver.java +++ b/src/networkTransfer/receive/NetworkReceiver.java @@ -646,15 +646,17 @@ public class NetworkReceiver extends PamControlledUnit implements PamSettings, N try { objectId = ds.readInt(); moduleVersion = ds.readInt(); - baseData.readBaseData(ds, receivedData.getDataVersion()); // millis = ds.readLong(); // if (dataVersion2 >= 2) { // nanos = ds.readLong(); // channelMap = ds.readInt(); // } + baseData.readBaseData(ds, receivedData.getDataVersion()); dataLength = ds.readInt(); data = new byte[dataLength]; - ds.read(data); + int bytesRead = ds.read(data); +// System.out.printf("NetRX read %d of expected %d bytes\n", bytesRead, dataLength); +// if (1>0) return null; ds.close(); } catch (IOException e) { e.printStackTrace(); diff --git a/src/networkTransfer/send/NetworkObjectPacker.java b/src/networkTransfer/send/NetworkObjectPacker.java index 57609de1..08b9aa0d 100644 --- a/src/networkTransfer/send/NetworkObjectPacker.java +++ b/src/networkTransfer/send/NetworkObjectPacker.java @@ -6,12 +6,13 @@ import java.io.IOException; import networkTransfer.NetworkObject; import networkTransfer.receive.NetworkReceiver; - +import PamguardMVC.DataUnitBaseData; import PamguardMVC.PamDataBlock; import PamguardMVC.PamDataUnit; import binaryFileStorage.BinaryDataSource; import binaryFileStorage.BinaryObjectData; +import binaryFileStorage.BinaryStore; import jsonStorage.JSONObjectDataSource; //import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream; @@ -73,16 +74,23 @@ public class NetworkObjectPacker { short dataType1 = NetworkReceiver.NET_PAM_DATA; BinaryDataSource binarySource = dataBlock.getBinaryDataSource(); int dataType2 = dataBlock.getQuickId(); + BinaryObjectData packedObject = binarySource.getPackedData(dataUnit); byte[] data = packedObject.getData(); - int duDataLength = data.length + 20; + int duDataLength = data.length + 12; + DataUnitBaseData baseData = dataUnit.getBasicData(); + int baseDataLength = baseData.getBaseDataBinaryLength(); + duDataLength += baseDataLength; + + // ByteOutputStream bos = new ByteOutputStream(duDataLength); ByteArrayOutputStream bos = new ByteArrayOutputStream(duDataLength); DataOutputStream dos = new DataOutputStream(bos); - try { + try { // these are the extra 20 bytes refered to above. dos.writeInt(packedObject.getObjectType()); dos.writeInt(binarySource.getModuleVersion()); - dos.writeLong(dataUnit.getTimeMilliseconds()); +// dos.writeLong(dataUnit.getTimeMilliseconds()); + baseData.writeBaseData(dos, BinaryStore.getCurrentFileFormat()); dos.writeInt(data.length); dos.write(data); } catch (IOException e) { @@ -131,7 +139,7 @@ public class NetworkObjectPacker { try { dos.writeInt(DATASTARTFLAG); dos.writeInt(totalSize); - dos.writeShort(1); // header version + dos.writeShort(BinaryStore.getCurrentFileFormat()); // header version dos.writeShort(buoyId1); dos.writeShort(buoyId2); dos.writeShort(dataType1); diff --git a/src/pamguard/Pamguard.java b/src/pamguard/Pamguard.java index 737739b2..ebc980a0 100644 --- a/src/pamguard/Pamguard.java +++ b/src/pamguard/Pamguard.java @@ -28,6 +28,7 @@ import PamController.PamGUIManager; import PamController.PamSettingManager; import PamController.PamguardVersionInfo; import PamController.pamBuoyGlobals; +import PamController.command.TerminalController; import PamModel.SMRUEnable; import PamUtils.FileFunctions; import PamUtils.PamExceptionHandler; @@ -298,7 +299,7 @@ public class Pamguard { if(runMode == PamController.RUN_REMOTE) { spashTime = 0; } - if (spashTime > 0) { + if (spashTime > 0 && (PamGUIManager.getGUIType() != PamGUIManager.NOGUI)) { new Splash(spashTime, chosenRunMode); } // @@ -323,9 +324,11 @@ public class Pamguard { else { PamController.create(chosenRunMode); } + } + static private String writePropertyString(String key) { String property = System.getProperty(key); if (property == null) {